summaryrefslogtreecommitdiff
path: root/src/gui/setup_video.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/setup_video.cpp')
-rw-r--r--src/gui/setup_video.cpp142
1 files changed, 109 insertions, 33 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 53041a9c..2381ab41 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -19,11 +19,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "setup_video.h"
-
+#include <SDL.h>
#include <string>
#include <vector>
-#include <SDL.h>
#include <guichan/key.hpp>
#include <guichan/listmodel.hpp>
@@ -34,6 +32,7 @@
#include "listbox.h"
#include "ok_dialog.h"
#include "scrollarea.h"
+#include "setup_video.h"
#include "slider.h"
#include "textfield.h"
@@ -41,6 +40,7 @@
#include "../configuration.h"
#include "../graphics.h"
+#include "../localplayer.h"
#include "../log.h"
#include "../main.h"
#include "../particle.h"
@@ -89,9 +89,9 @@ ModeListModel::ModeListModel()
/* Check which modes are available */
if (modes == (SDL_Rect **)0) {
- logger->log("No modes available");
+ logger->log(_("No modes available"));
} else if (modes == (SDL_Rect **)-1) {
- logger->log("All resolutions available");
+ logger->log(_("All resolutions available"));
} else {
//logger->log("Available Modes");
for (int i = 0; modes[i]; ++i) {
@@ -107,6 +107,9 @@ Setup_Video::Setup_Video():
mFullScreenEnabled(config.getValue("screen", 0)),
mOpenGLEnabled(config.getValue("opengl", 0)),
mCustomCursorEnabled(config.getValue("customcursor", 1)),
+ mParticleEffectsEnabled(config.getValue("particleeffects", 1)),
+ mSpeechBubbleEnabled(config.getValue("speechbubble", 1)),
+ mNameEnabled(config.getValue("showownname", 0)),
mOpacity(config.getValue("guialpha", 0.8)),
mFps((int) config.getValue("fpslimit", 0)),
mModeListModel(new ModeListModel),
@@ -114,6 +117,9 @@ Setup_Video::Setup_Video():
mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)),
+ mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), mParticleEffectsEnabled)),
+ mSpeechBubbleCheckBox(new CheckBox(_("Speech bubbles"), mSpeechBubbleEnabled)),
+ mNameCheckBox(new CheckBox(_("Show name"), mNameEnabled)),
mAlphaSlider(new Slider(0.2, 1.0)),
mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
mFpsSlider(new Slider(10, 200)),
@@ -137,13 +143,12 @@ Setup_Video::Setup_Video():
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
gcn::Label *alphaLabel = new gcn::Label(_("Gui opacity"));
-
gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius"));
gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness"));
gcn::Label *overlayDetailLabel = new gcn::Label(_("Ambient FX"));
gcn::Label *particleDetailLabel = new gcn::Label(_("Particle Detail"));
- mModeList->setEnabled(false);
+ mModeList->setEnabled(true);
#ifndef USE_OPENGL
mOpenGLCheckBox->setEnabled(false);
#endif
@@ -159,7 +164,11 @@ Setup_Video::Setup_Video():
mFpsSlider->setEnabled(mFps > 0);
mFpsCheckBox->setSelected(mFps > 0);
+ mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
+ mParticleEffectsCheckBox->setActionEventId("particleeffects");
+ mSpeechBubbleCheckBox->setActionEventId("speechbubble");
+ mNameCheckBox->setActionEventId("showownname");
mAlphaSlider->setActionEventId("guialpha");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mFpsSlider->setActionEventId("fpslimitslider");
@@ -172,7 +181,11 @@ Setup_Video::Setup_Video():
mParticleDetailSlider->setActionEventId("particledetailslider");
mParticleDetailField->setActionEventId("particledetailfield");
+ mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
+ mParticleEffectsCheckBox->addActionListener(this);
+ mSpeechBubbleCheckBox->addActionListener(this);
+ mNameCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
@@ -227,30 +240,33 @@ Setup_Video::Setup_Video():
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, scrollArea, 1, 4).setPadding(2);
+ place(0, 0, scrollArea, 1, 6).setPadding(2);
place(1, 0, mFsCheckBox, 3);
place(1, 1, mOpenGLCheckBox, 3);
place(1, 2, mCustomCursorCheckBox, 3);
-
- place(0, 4, mAlphaSlider);
- place(0, 5, mFpsSlider);
- place(0, 6, mScrollRadiusSlider);
- place(0, 7, mScrollLazinessSlider);
- place(0, 8, mOverlayDetailSlider);
- place(0, 9, mParticleDetailSlider);
-
- place(1, 4, alphaLabel, 2);
- place(1, 5, mFpsCheckBox).setPadding(3);
- place(1, 6, scrollRadiusLabel);
- place(1, 7, scrollLazinessLabel);
- place(1, 8, overlayDetailLabel);
- place(1, 9, particleDetailLabel);
-
- place(2, 5, mFpsField).setPadding(1);
- place(2, 6, mScrollRadiusField).setPadding(1);
- place(2, 7, mScrollLazinessField).setPadding(1);
- place(2, 8, mOverlayDetailField, 2).setPadding(2);
- place(2, 9, mParticleDetailField, 2).setPadding(2);
+ place(1, 3, mSpeechBubbleCheckBox, 3);
+ place(1, 4, mNameCheckBox, 3);
+ place(1, 5, mParticleEffectsCheckBox, 3);
+
+ place(0, 7, mAlphaSlider);
+ place(0, 8, mFpsSlider);
+ place(0, 9, mScrollRadiusSlider);
+ place(0, 10, mScrollLazinessSlider);
+ place(0, 11, mOverlayDetailSlider);
+ place(0, 12, mParticleDetailSlider);
+
+ place(1, 7, alphaLabel, 2);
+ place(1, 8, mFpsCheckBox).setPadding(3);
+ place(1, 9, scrollRadiusLabel);
+ place(1, 10, scrollLazinessLabel);
+ place(1, 11, overlayDetailLabel);
+ place(1, 12, particleDetailLabel);
+
+ place(2, 8, mFpsField).setPadding(1);
+ place(2, 9, mScrollRadiusField).setPadding(1);
+ place(2, 10, mScrollLazinessField).setPadding(1);
+ place(2, 11, mOverlayDetailField, 2).setPadding(2);
+ place(2, 12, mParticleDetailField, 2).setPadding(2);
setDimension(gcn::Rectangle(0, 0, 295, 250));
}
@@ -284,9 +300,9 @@ void Setup_Video::apply()
if (!graphics->setFullscreen(fullscreen))
{
std::stringstream error;
- error << "Failed to switch to " <<
- (fullscreen ? "windowed" : "fullscreen") <<
- "mode and restoration of old mode also failed!" <<
+ error << _("Failed to switch to ") <<
+ (fullscreen ? _("windowed") : _("fullscreen")) <<
+ _("mode and restoration of old mode also failed!") <<
std::endl;
logger->error(error.str());
}
@@ -316,8 +332,11 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getValue("screen", 0);
mCustomCursorEnabled = config.getValue("customcursor", 1);
+ mParticleEffectsEnabled = config.getValue("particleeffects", 1);
+ mSpeechBubbleEnabled = config.getValue("speechbubble", 1);
+ mNameEnabled = config.getValue("showownname", 0);
mOpacity = config.getValue("guialpha", 0.8);
- mOverlayDetail = (int)config.getValue("OverlayDetail", 2);
+ mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
mOpenGLEnabled = config.getValue("opengl", 0);
}
@@ -346,6 +365,9 @@ void Setup_Video::cancel()
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLCheckBox->setSelected(mOpenGLEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
+ mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
+ mSpeechBubbleCheckBox->setSelected(mSpeechBubbleEnabled);
+ mNameCheckBox->setSelected(mNameEnabled);
mAlphaSlider->setValue(mOpacity);
mOverlayDetailSlider->setValue(mOverlayDetail);
mParticleDetailSlider->setValue(mParticleDetail);
@@ -357,13 +379,46 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled ? 1 : 0);
config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
+ config.setValue("particleeffects", mParticleEffectsEnabled ? 1 : 0);
+ config.setValue("speechbubble", mSpeechBubbleEnabled ? 1 : 0);
+ config.setValue("showownname", mNameEnabled ? 1 : 0);
config.setValue("guialpha", mOpacity);
config.setValue("opengl", mOpenGLEnabled ? 1 : 0);
}
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->_endDraw();
+ graphics->_beginDraw();
+ graphics->updateScreen();
+
+ // 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());
}
@@ -372,6 +427,27 @@ void Setup_Video::action(const gcn::ActionEvent &event)
config.setValue("customcursor",
mCustomCursorCheckBox->isSelected() ? 1 : 0);
}
+ else if (event.getId() == "particleeffects")
+ {
+ config.setValue("particleeffects",
+ mParticleEffectsCheckBox->isSelected() ? 1 : 0);
+ new OkDialog(_("Particle effect settings changed"),
+ _("Restart your client or change maps for the change to take effect."));
+ }
+ else if (event.getId() == "speechbubble")
+ {
+ config.setValue("speechbubble",
+ mSpeechBubbleCheckBox->isSelected() ? 1 : 0);
+ }
+ else if (event.getId() == "showownname")
+ {
+ // Notify the local player that settings have changed for the name
+ // and requires an update
+ if (player_node)
+ player_node->mUpdateName = true;
+ config.setValue("showownname",
+ mNameCheckBox->isSelected() ? 1 : 0);
+ }
else if (event.getId() == "fpslimitslider")
{
mFps = (int) mFpsSlider->getValue();