diff --git a/src/PowderToy.cpp b/src/PowderToy.cpp index 8ef3dd403..0a0470eff 100644 --- a/src/PowderToy.cpp +++ b/src/PowderToy.cpp @@ -293,6 +293,7 @@ int Main(int argc, char *argv[]) prefs.Get("Fullscreen", false), prefs.Get("AltFullscreen", false), prefs.Get("ForceIntegerScaling", true), + prefs.Get("BlurryScaling", false), }; auto graveExitsConsole = prefs.Get("GraveExitsConsole", true); momentumScroll = prefs.Get("MomentumScroll", true); diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 45b4b1ae8..d5a0483c3 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -127,11 +127,6 @@ void SDLOpen() } } - if constexpr (SET_WINDOW_ICON) - { - WindowIcon(sdl_window); - } - StopTextInput(); } @@ -179,6 +174,7 @@ void SDLSetScreen() // see https://github.com/jacob1/The-Powder-Toy/issues/24 newFrameOpsNorm.resizable != currentFrameOpsNorm.resizable || newFrameOpsNorm.changeResolution != currentFrameOpsNorm.changeResolution || + newFrameOpsNorm.blurryScaling != currentFrameOpsNorm.blurryScaling || newVsyncHint != vsyncHint; if (!(recreate || @@ -189,6 +185,10 @@ void SDLSetScreen() } auto size = WINDOW * newFrameOpsNorm.scale; + if (sdl_window && newFrameOpsNorm.resizable) + { + SDL_GetWindowSize(sdl_window, &size.X, &size.Y); + } if (recreate) { @@ -229,6 +229,12 @@ void SDLSetScreen() fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError()); Platform::Exit(-1); } + if constexpr (SET_WINDOW_ICON) + { + WindowIcon(sdl_window); + } + SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, newFrameOpsNorm.blurryScaling ? "linear" : "nearest"); sdl_renderer = SDL_CreateRenderer(sdl_window, -1, rendererFlags); if (!sdl_renderer) { @@ -250,10 +256,6 @@ void SDLSetScreen() Platform::Exit(-1); } SDL_RaiseWindow(sdl_window); - SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); - //Uncomment this to enable resizing - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - //SDL_SetWindowResizable(sdl_window, SDL_TRUE); } SDL_RenderSetIntegerScale(sdl_renderer, newFrameOpsNorm.forceIntegerScaling ? SDL_TRUE : SDL_FALSE); if (!(newFrameOpsNorm.resizable && SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_MAXIMIZED)) diff --git a/src/gui/WindowFrameOps.h b/src/gui/WindowFrameOps.h index cceac8920..1ac533c98 100644 --- a/src/gui/WindowFrameOps.h +++ b/src/gui/WindowFrameOps.h @@ -8,6 +8,7 @@ struct WindowFrameOps bool fullscreen = false; bool changeResolution = false; bool forceIntegerScaling = false; + bool blurryScaling = false; WindowFrameOps Normalize() const { @@ -17,6 +18,7 @@ struct WindowFrameOps fullscreen , fullscreen ? changeResolution : false, fullscreen ? forceIntegerScaling : false, + blurryScaling , }; } }; diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h index b2145cfd0..4649f2f0e 100644 --- a/src/gui/interface/Engine.h +++ b/src/gui/interface/Engine.h @@ -128,10 +128,12 @@ namespace ui void SetChangeResolution (bool setChangeResolution ) { windowFrameOps.changeResolution = setChangeResolution; } void SetForceIntegerScaling(bool newForceIntegerScaling) { windowFrameOps.forceIntegerScaling = newForceIntegerScaling; } void SetResizable (bool newResizable ) { windowFrameOps.resizable = newResizable; } + void SetBlurryScaling (bool newBlurryScaling ) { windowFrameOps.blurryScaling = newBlurryScaling; } int GetScale () const { return windowFrameOps.scale; } bool GetFullscreen () const { return windowFrameOps.fullscreen; } bool GetChangeResolution () const { return windowFrameOps.changeResolution; } bool GetForceIntegerScaling() const { return windowFrameOps.forceIntegerScaling; } bool GetResizable () const { return windowFrameOps.resizable; } + bool GetBlurryScaling () const { return windowFrameOps.blurryScaling; } }; } diff --git a/src/gui/options/OptionsController.cpp b/src/gui/options/OptionsController.cpp index b6191927d..9cc876f4e 100644 --- a/src/gui/options/OptionsController.cpp +++ b/src/gui/options/OptionsController.cpp @@ -87,6 +87,11 @@ void OptionsController::SetForceIntegerScaling(bool forceIntegerScaling) model->SetForceIntegerScaling(forceIntegerScaling); } +void OptionsController::SetBlurryScaling(bool newBlurryScaling) +{ + model->SetBlurryScaling(newBlurryScaling); +} + void OptionsController::SetShowAvatars(bool showAvatars) { model->SetShowAvatars(showAvatars); diff --git a/src/gui/options/OptionsController.h b/src/gui/options/OptionsController.h index 88c7aed01..56bc30678 100644 --- a/src/gui/options/OptionsController.h +++ b/src/gui/options/OptionsController.h @@ -27,6 +27,7 @@ public: void SetFullscreen(bool fullscreen); void SetChangeResolution(bool newChangeResolution); void SetForceIntegerScaling(bool forceIntegerScaling); + void SetBlurryScaling(bool newBlurryScaling); void SetScale(int scale); void SetGraveExitsConsole(bool graveExitsConsole); void SetResizable(bool resizable); diff --git a/src/gui/options/OptionsModel.cpp b/src/gui/options/OptionsModel.cpp index 27442a9ce..9cce68ac0 100644 --- a/src/gui/options/OptionsModel.cpp +++ b/src/gui/options/OptionsModel.cpp @@ -215,6 +215,18 @@ void OptionsModel::SetForceIntegerScaling(bool forceIntegerScaling) notifySettingsChanged(); } +bool OptionsModel::GetBlurryScaling() +{ + return ui::Engine::Ref().GetBlurryScaling(); +} + +void OptionsModel::SetBlurryScaling(bool newBlurryScaling) +{ + ui::Engine::Ref().SetBlurryScaling(newBlurryScaling); + GlobalPrefs::Ref().Set("BlurryScaling", newBlurryScaling); + notifySettingsChanged(); +} + bool OptionsModel::GetFastQuit() { return ui::Engine::Ref().GetFastQuit(); diff --git a/src/gui/options/OptionsModel.h b/src/gui/options/OptionsModel.h index 7adebe427..1e39d6c17 100644 --- a/src/gui/options/OptionsModel.h +++ b/src/gui/options/OptionsModel.h @@ -49,6 +49,8 @@ public: void SetChangeResolution(bool newChangeResolution); bool GetForceIntegerScaling(); void SetForceIntegerScaling(bool forceIntegerScaling); + bool GetBlurryScaling(); + void SetBlurryScaling(bool newBlurryScaling); bool GetFastQuit(); void SetFastQuit(bool fastquit); int GetDecoSpace(); diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index cbb119220..0bebe8a57 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -268,6 +268,9 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340)) c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); }); } + blurryScaling = addCheckbox(0, "Blurry scaling \bg- more blurry, better on very big screens", "", [this] { + c->SetBlurryScaling(blurryScaling->GetChecked()); + }); addSeparator(); if (ALLOW_QUIT) { @@ -448,6 +451,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender) { forceIntegerScaling->SetChecked(sender->GetForceIntegerScaling()); } + if (blurryScaling) + { + blurryScaling->SetChecked(sender->GetBlurryScaling()); + } if (fastquit) { fastquit->SetChecked(sender->GetFastQuit()); diff --git a/src/gui/options/OptionsView.h b/src/gui/options/OptionsView.h index d598140e4..409f8fa09 100644 --- a/src/gui/options/OptionsView.h +++ b/src/gui/options/OptionsView.h @@ -31,6 +31,7 @@ class OptionsView: public ui::Window ui::Checkbox *fullscreen{}; ui::Checkbox *changeResolution{}; ui::Checkbox *forceIntegerScaling{}; + ui::Checkbox *blurryScaling{}; ui::Checkbox *fastquit{}; ui::DropDown *decoSpace{}; ui::Checkbox *showAvatars{};