summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphics.cpp2
-rw-r--r--src/gui/setup_video.cpp33
-rw-r--r--src/main.cpp21
-rw-r--r--src/resources/colordb.cpp2
4 files changed, 43 insertions, 15 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 6920bcb0..82404bce 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -42,6 +42,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
+ logger->log("Bits per pixel: %d", bpp);
+
int displayFlags = SDL_ANYFORMAT;
mFullscreen = fs;
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());
}
diff --git a/src/main.cpp b/src/main.cpp
index e9ec365f..b6d2b74f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -378,11 +378,11 @@ void init_engine(const Options &options)
graphics = new Graphics();
#endif
- int width = (int) config.getValue("screenwidth", defaultScreenWidth);
- int height = (int) config.getValue("screenheight", defaultScreenHeight);
- int bpp = 0;
- bool fullscreen = ((int) config.getValue("screen", 0) == 1);
- bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
+ const int width = (int) config.getValue("screenwidth", defaultScreenWidth);
+ const int height = (int) config.getValue("screenheight", defaultScreenHeight);
+ 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))
@@ -759,15 +759,14 @@ int main(int argc, char *argv[])
defaultScreenHeight));
std::string wallpaperName;
- if (screenWidth <= 800)
- wallpaperName = "graphics/images/login_wallpaper.png";
- else if (screenWidth <= 1024)
+ wallpaperName = "graphics/images/login_wallpaper.png";
+ if (screenWidth == 1024)
wallpaperName = "graphics/images/login_wallpaper_1024x768.png";
- else if (screenWidth <= 1280)
+ else if (screenWidth == 1280)
wallpaperName = "graphics/images/login_wallpaper_1280x960.png";
- else if (screenWidth <= 1440)
+ else if (screenWidth == 1440)
wallpaperName = "graphics/images/login_wallpaper_1440x1080.png";
- else
+ else if (screenWidth >= 1600)
wallpaperName = "graphics/images/login_wallpaper_1600x1200.png";
login_wallpaper = ResourceManager::getInstance()-> getImage(wallpaperName);
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 3d2e15e0..bdc6211a 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -84,8 +84,6 @@ void ColorDB::load()
TMWHair ? mColors[id] = XML::getProperty(node, "value", "#FFFFFF") :
mColors[id] = XML::getProperty(node, "dye", "#FFFFFF");
-
- logger->log("%d %s", id, mColors[id].c_str());
}
}