summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp8
-rw-r--r--src/graphics.cpp23
-rw-r--r--src/graphics.h5
-rw-r--r--src/gui/setup_video.cpp54
-rw-r--r--src/gui/setup_video.h3
-rw-r--r--src/opengl1graphics.cpp6
-rw-r--r--src/opengl1graphics.h4
-rw-r--r--src/openglgraphics.cpp7
-rw-r--r--src/openglgraphics.h3
9 files changed, 73 insertions, 40 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2d4de8a9f..18318acb6 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -524,9 +524,11 @@ void Client::gameInit()
const int bpp = 0;
const bool fullscreen = config.getBoolValue("screen");
const bool hwaccel = config.getBoolValue("hwaccel");
+ const bool enableResize = config.getBoolValue("enableresize");
// Try to set the desired video mode
- if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
+ if (!mainGraphics->setVideoMode(width, height, bpp,
+ fullscreen, hwaccel, enableResize))
{
logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s",
width, height, bpp, SDL_GetError()));
@@ -544,7 +546,7 @@ void Client::gameInit()
config.setValueInt("screenheight", oldHeight);
config.setValue("screen", oldFullscreen);
if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp,
- oldFullscreen, hwaccel))
+ oldFullscreen, hwaccel, enableResize))
{
logger->error(strprintf("Couldn't restore %dx%dx%d "
"video mode: %s", oldWidth, oldHeight, bpp,
@@ -2368,7 +2370,7 @@ void Client::resizeVideo(int width, int height)
if (mainGraphics->mWidth == width && mainGraphics->mHeight == height)
return;
- if (mainGraphics->resize(width, height))
+ if (mainGraphics->resizeScreen(width, height))
{
if (gui)
gui->videoResized();
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 46433639e..30aece5dc 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -47,13 +47,14 @@ Graphics::Graphics():
mBlitMode(BLIT_NORMAL),
mRedraw(false),
mDoubleBuffer(false),
- mSecure(false)
+ mSecure(false),
+ mOpenGL(0),
+ mEnableResize(false)
{
mRect.x = 0;
mRect.y = 0;
mRect.w = 0;
mRect.h = 0;
- mOpenGL = 0;
}
Graphics::~Graphics()
@@ -61,7 +62,8 @@ Graphics::~Graphics()
_endDraw();
}
-bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
+bool Graphics::setVideoMode(int w, int h, int bpp, bool fs,
+ bool hwaccel, bool resize)
{
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
@@ -73,10 +75,11 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
+ mEnableResize = resize;
if (fs)
displayFlags |= SDL_FULLSCREEN;
- else
+ else if (resize)
displayFlags |= SDL_RESIZABLE;
if (hwaccel)
@@ -140,10 +143,10 @@ bool Graphics::setFullscreen(bool fs)
if (mFullscreen == fs)
return true;
- return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel);
+ return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel, mEnableResize);
}
-bool Graphics::resize(int width, int height)
+bool Graphics::resizeScreen(int width, int height)
{
if (mWidth == width && mHeight == height)
return true;
@@ -153,14 +156,18 @@ bool Graphics::resize(int width, int height)
_endDraw();
- bool success = setVideoMode(width, height, mBpp, mFullscreen, mHWAccel);
+ bool success = setVideoMode(width, height, mBpp,
+ mFullscreen, mHWAccel, mEnableResize);
// 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))
+ if (!setVideoMode(prevWidth, prevHeight, mBpp,
+ mFullscreen, mHWAccel, mEnableResize))
+ {
return false;
+ }
}
_beginDraw();
diff --git a/src/graphics.h b/src/graphics.h
index 7fab02cbb..497327b81 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -97,7 +97,7 @@ 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 fs, bool hwaccel, bool resize);
/**
* Set fullscreen mode.
@@ -107,7 +107,7 @@ class Graphics : public gcn::SDLGraphics
/**
* Resize the window to the specified size.
*/
- bool resize(int width, int height);
+ bool resizeScreen(int width, int height);
/**
* Blits an image onto the screen.
@@ -303,6 +303,7 @@ class Graphics : public gcn::SDLGraphics
SDL_Rect mRect;
bool mSecure;
int mOpenGL;
+ bool mEnableResize;
};
extern Graphics *mainGraphics;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 4b56c7cea..d0a6ac257 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -281,6 +281,7 @@ Setup_Video::Setup_Video():
mOpacity(config.getFloatValue("guialpha")),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
+ mEnableResize(config.getBoolValue("enableresize")),
mSpeechMode(static_cast<Being::Speech>(
config.getIntValue("speech"))),
mModeListModel(new ModeListModel),
@@ -296,6 +297,7 @@ Setup_Video::Setup_Video():
// TRANSLATORS: Refers to "Show own name"
mPickupParticleCheckBox(new CheckBox(_("as particle"),
mPickupParticleEnabled)),
+ mEnableResizeCheckBox(new CheckBox(_("Enable resize"), mEnableResize)),
mSpeechSlider(new Slider(0, 3)),
mSpeechLabel(new Label("")),
mAlphaSlider(new Slider(0.1, 1.0)),
@@ -367,6 +369,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->setActionEventId("particledetailslider");
mParticleDetailField->setActionEventId("particledetailfield");
mOpenGLDropDown->setActionEventId("opengl");
+ mEnableResizeCheckBox->setActionEventId("enableresize");
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
@@ -383,6 +386,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->addActionListener(this);
mParticleDetailField->addKeyListener(this);
mOpenGLDropDown->addActionListener(this);
+ mEnableResizeCheckBox->addActionListener(this);
mSpeechLabel->setCaption(speechModeToString(mSpeechMode));
mSpeechSlider->setValue(mSpeechMode);
@@ -397,8 +401,8 @@ Setup_Video::Setup_Video():
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, scrollArea, 1, 5).setPadding(2);
- place(0, 5, mOpenGLDropDown, 1);
+ place(0, 0, scrollArea, 1, 6).setPadding(2);
+ place(0, 6, mOpenGLDropDown, 1);
// place(0, 6, mHwAccelCheckBox, 6);
@@ -408,32 +412,33 @@ Setup_Video::Setup_Video():
place(1, 2, mParticleEffectsCheckBox, 2);
- place(1, 3, mPickupNotifyLabel, 4);
+ place(1, 3, mEnableResizeCheckBox, 2);
- place(1, 4, mPickupChatCheckBox, 1);
- place(2, 4, mPickupParticleCheckBox, 2);
+ place(1, 4, mPickupNotifyLabel, 4);
+ place(1, 5, mPickupChatCheckBox, 1);
+ place(2, 5, mPickupParticleCheckBox, 2);
- place(0, 6, mAlphaSlider);
- place(1, 6, alphaLabel, 3);
+ place(0, 7, mAlphaSlider);
+ place(1, 7, alphaLabel, 3);
- place(0, 7, mFpsSlider);
- place(1, 7, mFpsCheckBox).setPadding(3);
- place(2, 7, mFpsLabel).setPadding(1);
+ place(0, 8, mFpsSlider);
+ place(1, 8, mFpsCheckBox).setPadding(3);
+ place(2, 8, mFpsLabel).setPadding(1);
- place(0, 8, mAltFpsSlider);
- place(1, 8, mAltFpsLabel).setPadding(3);
+ place(0, 9, mAltFpsSlider);
+ place(1, 9, mAltFpsLabel).setPadding(3);
- place(0, 9, mSpeechSlider);
- place(1, 9, speechLabel);
- place(2, 9, mSpeechLabel, 3).setPadding(2);
+ place(0, 10, mSpeechSlider);
+ place(1, 10, speechLabel);
+ place(2, 10, mSpeechLabel, 3).setPadding(2);
- place(0, 10, mOverlayDetailSlider);
- place(1, 10, overlayDetailLabel);
- place(2, 10, mOverlayDetailField, 3).setPadding(2);
+ place(0, 11, mOverlayDetailSlider);
+ place(1, 11, overlayDetailLabel);
+ place(2, 11, mOverlayDetailField, 3).setPadding(2);
- place(0, 11, mParticleDetailSlider);
- place(1, 11, particleDetailLabel);
- place(2, 11, mParticleDetailField, 3).setPadding(2);
+ place(0, 12, mParticleDetailSlider);
+ place(1, 12, particleDetailLabel);
+ place(2, 12, mParticleDetailField, 3).setPadding(2);
int width = 600;
@@ -540,6 +545,7 @@ void Setup_Video::apply()
mOpenGLEnabled = config.getIntValue("opengl");
mPickupChatEnabled = config.getBoolValue("showpickupchat");
mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
+ mEnableResize = config.getBoolValue("enableresize");
}
void Setup_Video::cancel()
@@ -560,6 +566,7 @@ void Setup_Video::cancel()
mFpsLabel->setCaption(mFpsCheckBox->isSelected()
? toString(mFps) : _("None"));
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
+ mEnableResizeCheckBox->setSelected(mEnableResize);
config.setValue("screen", mFullScreenEnabled);
@@ -578,6 +585,7 @@ void Setup_Video::cancel()
config.setValue("opengl", mOpenGLEnabled);
config.setValue("showpickupchat", mPickupChatEnabled);
config.setValue("showpickupparticle", mPickupParticleEnabled);
+ config.setValue("enableresize", mEnableResize);
}
void Setup_Video::action(const gcn::ActionEvent &event)
@@ -715,6 +723,10 @@ void Setup_Video::action(const gcn::ActionEvent &event)
mAltFpsSlider->setValue(mAltFps);
mAltFpsSlider->setEnabled(mAltFps > 0);
}
+ else if (id == "enableresize")
+ {
+ config.setValue("enableresize", mEnableResizeCheckBox->isSelected());
+ }
}
void Setup_Video::externalUpdated()
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 0c82ab272..0cc8190ec 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -62,6 +62,7 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
float mOpacity;
int mFps;
int mAltFps;
+ bool mEnableResize;
Being::Speech mSpeechMode;
ModeListModel *mModeListModel;
@@ -85,6 +86,8 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
gcn::CheckBox *mPickupChatCheckBox;
gcn::CheckBox *mPickupParticleCheckBox;
+ gcn::CheckBox *mEnableResizeCheckBox;
+
gcn::Slider *mSpeechSlider;
gcn::Label *mSpeechLabel;
gcn::Slider *mAlphaSlider;
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index 7995b122b..41a665524 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -62,7 +62,7 @@ void OpenGL1Graphics::setSync(bool sync)
}
bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp,
- bool fs, bool hwaccel)
+ bool fs, bool hwaccel, bool resize)
{
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
@@ -74,6 +74,7 @@ bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp,
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
+ mEnableResize = resize;
if (fs)
{
@@ -84,7 +85,8 @@ bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp,
// Resizing currently not supported on Windows, where it would require
// reuploading all textures.
#if !defined(_WIN32)
- displayFlags |= SDL_RESIZABLE;
+ if (resize)
+ displayFlags |= SDL_RESIZABLE;
#endif
}
diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h
index 87458d8b9..fd6ec2df0 100644
--- a/src/opengl1graphics.h
+++ b/src/opengl1graphics.h
@@ -45,10 +45,12 @@ class OpenGL1Graphics : 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 setVideoMode(int w, int h, int bpp, bool fs,
+ bool hwaccel, bool resize);
bool drawImage(Image *image,
int srcX, int srcY,
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 9fb91b201..069af6c7f 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -71,7 +71,8 @@ void OpenGLGraphics::setSync(bool sync)
mSync = sync;
}
-bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
+bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs,
+ bool hwaccel, bool resize)
{
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
@@ -83,6 +84,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
+ mEnableResize = resize;
if (fs)
{
@@ -93,7 +95,8 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
// Resizing currently not supported on Windows, where it would require
// reuploading all textures.
#if !defined(_WIN32)
- displayFlags |= SDL_RESIZABLE;
+ if (resize)
+ displayFlags |= SDL_RESIZABLE;
#endif
}
diff --git a/src/openglgraphics.h b/src/openglgraphics.h
index 1047223ad..065a77512 100644
--- a/src/openglgraphics.h
+++ b/src/openglgraphics.h
@@ -48,7 +48,8 @@ class OpenGLGraphics : public Graphics
bool getSync() const
{ return mSync; }
- bool setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel);
+ bool setVideoMode(int w, int h, int bpp, bool fs,
+ bool hwaccel, bool resize);
bool drawImage(Image *image,
int srcX, int srcY,