summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-12-20 23:28:46 -0700
committerIra Rice <irarice@gmail.com>2008-12-20 23:28:46 -0700
commit3f000858edfbca044a7d8168bd879ef80285e522 (patch)
tree50bb164102401954e6283ade3e8a3ebf75a21be8 /src/gui
parent8e86b8c4d0f3d9be979b53689d35f8f0b1381060 (diff)
downloadmana-3f000858edfbca044a7d8168bd879ef80285e522.tar.gz
mana-3f000858edfbca044a7d8168bd879ef80285e522.tar.bz2
mana-3f000858edfbca044a7d8168bd879ef80285e522.tar.xz
mana-3f000858edfbca044a7d8168bd879ef80285e522.zip
Enabled video mode switching, as well as got rid of an old, unneeded
check in the ColorDB. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup_video.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 2a7d6855..262c17e1 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -136,7 +136,7 @@ Setup_Video::Setup_Video():
ScrollArea *scrollArea = new ScrollArea(mModeList);
gcn::Label *alphaLabel = new gcn::Label("Gui opacity");
- mModeList->setEnabled(false);
+ mModeList->setEnabled(true);
#ifndef USE_OPENGL
mOpenGLCheckBox->setEnabled(false);
#endif
@@ -165,6 +165,7 @@ Setup_Video::Setup_Video():
mFpsSlider->setEnabled(mFps > 0);
mFpsCheckBox->setSelected(mFps > 0);
+ mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
mParticleEffectsCheckBox->setActionEventId("particleeffects");
mSpeechBubbleCheckBox->setActionEventId("speechbubble");
@@ -180,6 +181,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->setActionEventId("particledetailslider");
mParticleDetailField->setActionEventId("particledetailfield");
+ mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
mParticleEffectsCheckBox->addActionListener(this);
mSpeechBubbleCheckBox->addActionListener(this);
@@ -391,7 +393,34 @@ void Setup_Video::cancel()
void Setup_Video::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "guialpha")
+ if (event.getId() == "videomode")
+ {
+ const std::string mode = mModeListModel->getElementAt(mModeList->getSelected());
+ const int width = atoi(mode.substr(0, mode.find("x")).c_str());
+ const int height = atoi(mode.substr(mode.find("x") + 1).c_str());
+ const int bpp = 0;
+ const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
+ const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
+ // Try to set the desired video mode
+ if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
+ {
+ std::cerr << "Couldn't set "
+ << width << "x" << height << "x" << bpp << " video mode: "
+ << SDL_GetError() << std::endl;
+ exit(1);
+ }
+
+ // Initialize for drawing
+ graphics->_beginDraw();
+
+ // TODO: Find out why the drawing area doesn't resize without a restart.
+ new OkDialog("Screen resolution changed",
+ "Restart your client for the change to take effect.");
+
+ config.setValue("screenwidth", width);
+ config.setValue("screenheight", height);
+ }
+ else if (event.getId() == "guialpha")
{
config.setValue("guialpha", mAlphaSlider->getValue());
}