diff options
-rw-r--r-- | src/client.cpp | 11 | ||||
-rw-r--r-- | src/client.h | 2 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_visual.cpp | 1 | ||||
-rw-r--r-- | src/render/graphics.cpp | 25 | ||||
-rw-r--r-- | src/render/graphics.h | 4 | ||||
-rw-r--r-- | src/render/openglgraphicsdef.hpp | 2 |
7 files changed, 41 insertions, 16 deletions
diff --git a/src/client.cpp b/src/client.cpp index 82652e433..85384b29d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2892,6 +2892,17 @@ void Client::applyKeyRepeat() #endif } +void Client::applyScale() +{ + const int scale = config.getIntValue("scale"); + if (mainGraphics->getScale() == scale) + return; + mainGraphics->setScale(scale); + resizeVideo(mainGraphics->mActualWidth, + mainGraphics->mActualHeight, + true); +} + void Client::setIsMinimized(const bool n) { mIsMinimized = n; diff --git a/src/client.h b/src/client.h index 82bb4be15..90198abf4 100644 --- a/src/client.h +++ b/src/client.h @@ -315,6 +315,8 @@ public: int actualHeight, const bool always); + void applyScale(); + bool limitPackets(const int type) A_WARN_UNUSED; bool checkPackets(const int type) const A_WARN_UNUSED; diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 0a7f78eb6..00cceb22f 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -376,17 +376,7 @@ void GraphicsManager::setVideoMode() int width = config.getIntValue("screenwidth"); int height = config.getIntValue("screenheight"); #endif - - int scale = 1; - if (mainGraphics->allowScale()) - { - if (!scale) - scale = 1; - scale = config.getIntValue("scale"); - if (width / scale < 470 || height / scale < 320) - scale = 1; - logger->log("set scale: %d", scale); - } + const int scale = config.getIntValue("scale"); // Try to set the desired video mode if (!mainGraphics->setVideoMode(width, height, scale, bpp, diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index 067c6e5e9..d8e6a9941 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -225,4 +225,5 @@ void Setup_Visual::apply() { SetupTabScroll::apply(); Client::applyGrabMode(); + client->applyScale(); } diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 27682f1f0..82f44460b 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -120,16 +120,35 @@ void Graphics::setMainFlags(const int w, const int h, logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); - mWidth = w / scale; - mHeight = h / scale; mBpp = bpp; mFullscreen = fs; mHWAccel = hwaccel; mEnableResize = resize; mNoFrame = noFrame; - mScale = scale; mActualWidth = w; mActualHeight = h; + setScale(scale); +} + +void Graphics::setScale(int scale) +{ + if (isAllowScale()) + { + if (!scale) + scale = 1; + if (mActualWidth / scale < 470 || mActualHeight / scale < 320) + scale = 1; + logger->log("set scale: %d", scale); + mScale = scale; + } + else + { + mScale = 1; + } + mWidth = mActualWidth / mScale; + mHeight = mActualHeight / mScale; + mRect.w = mWidth; + mRect.h = mHeight; } int Graphics::getOpenGLFlags() const diff --git a/src/render/graphics.h b/src/render/graphics.h index adf1b97c4..0cb510195 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -348,9 +348,11 @@ class Graphics : public gcn::Graphics int getScale() const { return mScale; } - virtual bool allowScale() const + virtual bool isAllowScale() const { return false; } + void setScale(int scale); + int mWidth; int mHeight; int mActualWidth; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 6654254cb..89f8e63a9 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -142,7 +142,7 @@ void completeCache() override final; - bool allowScale() const override final + bool isAllowScale() const override final { return true; } static void bindTexture(const GLenum target, const GLuint texture); |