diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-02 19:42:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-02 19:42:02 +0300 |
commit | e8f92c8a476c35f76212ccaccbbb55901a49058e (patch) | |
tree | 741bdd9b2068ded23ab92a06586422b400c53d24 /src | |
parent | 2d0696abd547cf00fda04f070fb713c92acaf91b (diff) | |
download | manaplus-e8f92c8a476c35f76212ccaccbbb55901a49058e.tar.gz manaplus-e8f92c8a476c35f76212ccaccbbb55901a49058e.tar.bz2 manaplus-e8f92c8a476c35f76212ccaccbbb55901a49058e.tar.xz manaplus-e8f92c8a476c35f76212ccaccbbb55901a49058e.zip |
Add "no frame" option to hide window frame. Disabled by default.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 14 | ||||
-rw-r--r-- | src/client.h | 6 | ||||
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/graphics.cpp | 16 | ||||
-rw-r--r-- | src/graphics.h | 8 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 50 | ||||
-rw-r--r-- | src/gui/setup_video.h | 2 | ||||
-rw-r--r-- | src/opengl1graphics.cpp | 8 | ||||
-rw-r--r-- | src/opengl1graphics.h | 2 | ||||
-rw-r--r-- | src/openglgraphics.cpp | 6 | ||||
-rw-r--r-- | src/openglgraphics.h | 3 |
11 files changed, 77 insertions, 39 deletions
diff --git a/src/client.cpp b/src/client.cpp index 634fa1e80..c21194834 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -525,10 +525,11 @@ void Client::gameInit() const bool fullscreen = config.getBoolValue("screen"); const bool hwaccel = config.getBoolValue("hwaccel"); const bool enableResize = config.getBoolValue("enableresize"); + const bool noFrame = config.getBoolValue("noframe"); // Try to set the desired video mode if (!mainGraphics->setVideoMode(width, height, bpp, - fullscreen, hwaccel, enableResize)) + fullscreen, hwaccel, enableResize, noFrame)) { logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); @@ -546,7 +547,7 @@ void Client::gameInit() config.setValueInt("screenheight", oldHeight); config.setValue("screen", oldFullscreen); if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, - oldFullscreen, hwaccel, enableResize)) + oldFullscreen, hwaccel, enableResize, noFrame)) { logger->error(strprintf("Couldn't restore %dx%dx%d " "video mode: %s", oldWidth, oldHeight, bpp, @@ -843,7 +844,7 @@ int Client::gameExec() break; case SDL_VIDEORESIZE: - resizeVideo(event.resize.w, event.resize.h); + resizeVideo(event.resize.w, event.resize.h, false); break; } @@ -2360,7 +2361,7 @@ bool Client::isTmw() return false; } -void Client::resizeVideo(int width, int height) +void Client::resizeVideo(int width, int height, bool always) { // Keep a minimum size. This isn't adhered to by the actual window, but // it keeps some window positions from getting messed up. @@ -2369,8 +2370,11 @@ void Client::resizeVideo(int width, int height) if (!mainGraphics) return; - if (mainGraphics->mWidth == width && mainGraphics->mHeight == height) + if (!always && mainGraphics->mWidth == width + && mainGraphics->mHeight == height) + { return; + } if (mainGraphics->resizeScreen(width, height)) { diff --git a/src/client.h b/src/client.h index 5c9dfdaa1..6c93adbdf 100644 --- a/src/client.h +++ b/src/client.h @@ -258,8 +258,8 @@ public: static std::string getServerName() { return instance()->mServerName; } - static void resize(int width, int height) - { instance()->resizeVideo(width, height); } + static void resize(int width, int height, bool always = false) + { instance()->resizeVideo(width, height, always); } static void setGuiAlpha(float n); @@ -285,7 +285,7 @@ public: void writePacketLimits(std::string packetLimitsName); - void resizeVideo(int width, int height); + void resizeVideo(int width, int height, bool always); static bool limitPackets(int type); diff --git a/src/defaults.cpp b/src/defaults.cpp index cd183920d..1bce806ff 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -226,6 +226,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "useInactiveJoystick", false); AddDEF(configData, "testInfo", ""); AddDEF(configData, "enableresize", true); + AddDEF(configData, "noframe", false); return configData; } diff --git a/src/graphics.cpp b/src/graphics.cpp index 30aece5dc..5848d8c14 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -49,7 +49,8 @@ Graphics::Graphics(): mDoubleBuffer(false), mSecure(false), mOpenGL(0), - mEnableResize(false) + mEnableResize(false), + mNoFrame(false) { mRect.x = 0; mRect.y = 0; @@ -63,7 +64,7 @@ Graphics::~Graphics() } bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, - bool hwaccel, bool resize) + bool hwaccel, bool resize, bool noFrame) { logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); @@ -76,6 +77,7 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, mFullscreen = fs; mHWAccel = hwaccel; mEnableResize = resize; + mNoFrame = noFrame; if (fs) displayFlags |= SDL_FULLSCREEN; @@ -87,6 +89,9 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, else displayFlags |= SDL_SWSURFACE; + if (noFrame) + displayFlags |= SDL_NOFRAME; + setTarget(SDL_SetVideoMode(w, h, bpp, displayFlags)); if (!mTarget) @@ -143,7 +148,8 @@ bool Graphics::setFullscreen(bool fs) if (mFullscreen == fs) return true; - return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel, mEnableResize); + return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel, + mEnableResize, mNoFrame); } bool Graphics::resizeScreen(int width, int height) @@ -157,14 +163,14 @@ bool Graphics::resizeScreen(int width, int height) _endDraw(); bool success = setVideoMode(width, height, mBpp, - mFullscreen, mHWAccel, mEnableResize); + mFullscreen, mHWAccel, mEnableResize, mNoFrame); // If it didn't work, try to restore the previous size. If that didn't // work either, bail out (but then we're in deep trouble). if (!success) { if (!setVideoMode(prevWidth, prevHeight, mBpp, - mFullscreen, mHWAccel, mEnableResize)) + mFullscreen, mHWAccel, mEnableResize, mNoFrame)) { return false; } diff --git a/src/graphics.h b/src/graphics.h index 497327b81..d1409be8a 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -96,8 +96,8 @@ class Graphics : public gcn::SDLGraphics /** * Try to create a window with the given settings. */ - virtual bool setVideoMode(int w, int h, int bpp, - bool fs, bool hwaccel, bool resize); + virtual bool setVideoMode(int w, int h, int bpp, bool fs, + bool hwaccel, bool resize, bool noFrame); /** * Set fullscreen mode. @@ -287,6 +287,9 @@ class Graphics : public gcn::SDLGraphics int getOpenGL() { return mOpenGL; } + void setNoFrame(bool n) + { mNoFrame = n; } + int mWidth; int mHeight; @@ -304,6 +307,7 @@ class Graphics : public gcn::SDLGraphics bool mSecure; int mOpenGL; bool mEnableResize; + bool mNoFrame; }; extern Graphics *mainGraphics; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 48d489513..9a5b30ea7 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -282,6 +282,7 @@ Setup_Video::Setup_Video(): mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), mEnableResize(config.getBoolValue("enableresize")), + mNoFrame(config.getBoolValue("noframe")), mSpeechMode(static_cast<Being::Speech>( config.getIntValue("speech"))), mModeListModel(new ModeListModel), @@ -298,6 +299,7 @@ Setup_Video::Setup_Video(): mPickupParticleCheckBox(new CheckBox(_("as particle"), mPickupParticleEnabled)), mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)), + mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)), mSpeechSlider(new Slider(0, 3)), mSpeechLabel(new Label("")), mAlphaSlider(new Slider(0.1, 1.0)), @@ -370,6 +372,7 @@ Setup_Video::Setup_Video(): mParticleDetailField->setActionEventId("particledetailfield"); mOpenGLDropDown->setActionEventId("opengl"); mEnableResizeCheckBox->setActionEventId("enableresize"); + mNoFrameCheckBox->setActionEventId("noframe"); mModeList->addActionListener(this); mCustomCursorCheckBox->addActionListener(this); @@ -387,6 +390,7 @@ Setup_Video::Setup_Video(): mParticleDetailField->addKeyListener(this); mOpenGLDropDown->addActionListener(this); mEnableResizeCheckBox->addActionListener(this); + mNoFrameCheckBox->addActionListener(this); mSpeechLabel->setCaption(speechModeToString(mSpeechMode)); mSpeechSlider->setValue(mSpeechMode); @@ -410,35 +414,36 @@ Setup_Video::Setup_Video(): place(1, 1, mCustomCursorCheckBox, 3); - place(1, 2, mParticleEffectsCheckBox, 2); + place(1, 2, mEnableResizeCheckBox, 2); + place(1, 3, mNoFrameCheckBox, 2); - place(1, 3, mEnableResizeCheckBox, 2); + place(1, 4, mParticleEffectsCheckBox, 2); - place(1, 4, mPickupNotifyLabel, 4); - place(1, 5, mPickupChatCheckBox, 1); - place(2, 5, mPickupParticleCheckBox, 2); + place(1, 5, mPickupNotifyLabel, 4); + place(1, 6, mPickupChatCheckBox, 1); + place(2, 6, mPickupParticleCheckBox, 2); place(0, 7, mAlphaSlider); place(1, 7, alphaLabel, 3); - place(0, 8, mFpsSlider); - place(1, 8, mFpsCheckBox).setPadding(3); - place(2, 8, mFpsLabel).setPadding(1); + place(0, 9, mFpsSlider); + place(1, 9, mFpsCheckBox).setPadding(3); + place(2, 9, mFpsLabel).setPadding(1); - place(0, 9, mAltFpsSlider); - place(1, 9, mAltFpsLabel).setPadding(3); + place(0, 10, mAltFpsSlider); + place(1, 10, mAltFpsLabel).setPadding(3); - place(0, 10, mSpeechSlider); - place(1, 10, speechLabel); - place(2, 10, mSpeechLabel, 3).setPadding(2); + place(0, 11, mSpeechSlider); + place(1, 11, speechLabel); + place(2, 11, mSpeechLabel, 3).setPadding(2); - place(0, 11, mOverlayDetailSlider); - place(1, 11, overlayDetailLabel); - place(2, 11, mOverlayDetailField, 3).setPadding(2); + place(0, 12, mOverlayDetailSlider); + place(1, 12, overlayDetailLabel); + place(2, 12, mOverlayDetailField, 3).setPadding(2); - place(0, 12, mParticleDetailSlider); - place(1, 12, particleDetailLabel); - place(2, 12, mParticleDetailField, 3).setPadding(2); + place(0, 13, mParticleDetailSlider); + place(1, 13, particleDetailLabel); + place(2, 13, mParticleDetailField, 3).setPadding(2); int width = 600; @@ -546,6 +551,7 @@ void Setup_Video::apply() mPickupChatEnabled = config.getBoolValue("showpickupchat"); mPickupParticleEnabled = config.getBoolValue("showpickupparticle"); mEnableResize = config.getBoolValue("enableresize"); + mNoFrame = config.getBoolValue("noframe"); } void Setup_Video::cancel() @@ -567,6 +573,7 @@ void Setup_Video::cancel() ? toString(mFps) : _("None")); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps)); mEnableResizeCheckBox->setSelected(mEnableResize); + mNoFrameCheckBox->setSelected(mNoFrame); config.setValue("screen", mFullScreenEnabled); @@ -586,6 +593,7 @@ void Setup_Video::cancel() config.setValue("showpickupchat", mPickupChatEnabled); config.setValue("showpickupparticle", mPickupParticleEnabled); config.setValue("enableresize", mEnableResize); + config.setValue("noframe", mNoFrame); } void Setup_Video::action(const gcn::ActionEvent &event) @@ -727,6 +735,10 @@ void Setup_Video::action(const gcn::ActionEvent &event) { config.setValue("enableresize", mEnableResizeCheckBox->isSelected()); } + else if (id == "noframe") + { + config.setValue("noframe", mNoFrameCheckBox->isSelected()); + } } void Setup_Video::externalUpdated() diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 0cc8190ec..31d45d93d 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -63,6 +63,7 @@ class Setup_Video : public SetupTab, public gcn::KeyListener int mFps; int mAltFps; bool mEnableResize; + bool mNoFrame; Being::Speech mSpeechMode; ModeListModel *mModeListModel; @@ -87,6 +88,7 @@ class Setup_Video : public SetupTab, public gcn::KeyListener gcn::CheckBox *mPickupParticleCheckBox; gcn::CheckBox *mEnableResizeCheckBox; + gcn::CheckBox *mNoFrameCheckBox; gcn::Slider *mSpeechSlider; gcn::Label *mSpeechLabel; diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 41a665524..34e9fcda3 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -61,8 +61,8 @@ void OpenGL1Graphics::setSync(bool sync) mSync = sync; } -bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, - bool fs, bool hwaccel, bool resize) +bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, bool fs, + bool hwaccel, bool resize, bool noFrame) { logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); @@ -75,6 +75,7 @@ bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, mFullscreen = fs; mHWAccel = hwaccel; mEnableResize = resize; + mNoFrame = noFrame; if (fs) { @@ -90,6 +91,9 @@ bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, #endif } + if (noFrame) + displayFlags |= SDL_NOFRAME; + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (!(mTarget = SDL_SetVideoMode(w, h, bpp, displayFlags))) diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h index fd6ec2df0..76dc3ef00 100644 --- a/src/opengl1graphics.h +++ b/src/opengl1graphics.h @@ -50,7 +50,7 @@ class OpenGL1Graphics : public Graphics { return mSync; } bool setVideoMode(int w, int h, int bpp, bool fs, - bool hwaccel, bool resize); + bool hwaccel, bool resize, bool noFrame); bool drawImage(Image *image, int srcX, int srcY, diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 069af6c7f..2c3d914b0 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -72,7 +72,7 @@ void OpenGLGraphics::setSync(bool sync) } bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, - bool hwaccel, bool resize) + bool hwaccel, bool resize, bool noFrame) { logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); @@ -85,6 +85,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, mFullscreen = fs; mHWAccel = hwaccel; mEnableResize = resize; + mNoFrame = noFrame; if (fs) { @@ -100,6 +101,9 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, #endif } + if (noFrame) + displayFlags |= SDL_NOFRAME; + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (!(mTarget = SDL_SetVideoMode(w, h, bpp, displayFlags))) diff --git a/src/openglgraphics.h b/src/openglgraphics.h index 065a77512..f3bdc4470 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -45,11 +45,12 @@ class OpenGLGraphics : public Graphics * the next call to setVideoMode(). Only implemented on MacOS for now. */ void setSync(bool sync); + bool getSync() const { return mSync; } bool setVideoMode(int w, int h, int bpp, bool fs, - bool hwaccel, bool resize); + bool hwaccel, bool resize, bool noFrame); bool drawImage(Image *image, int srcX, int srcY, |