diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-08-03 21:18:31 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-08-03 21:18:31 +0000 |
commit | 2da65e2e57b664cc45c164f08ddae3597e51fcba (patch) | |
tree | 328672b6aee26f5532b79ef51ef01b350fbf3184 /src | |
parent | 741ccf53b036a120cb6b0c90d5c29165a7e78742 (diff) | |
download | mana-2da65e2e57b664cc45c164f08ddae3597e51fcba.tar.gz mana-2da65e2e57b664cc45c164f08ddae3597e51fcba.tar.bz2 mana-2da65e2e57b664cc45c164f08ddae3597e51fcba.tar.xz mana-2da65e2e57b664cc45c164f08ddae3597e51fcba.zip |
Now the 'Apply' and 'Cancel' buttons of the setup window work correctly.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/setup.cpp | 104 | ||||
-rw-r--r-- | src/gui/setup.h | 5 |
3 files changed, 96 insertions, 17 deletions
diff --git a/src/game.cpp b/src/game.cpp index 2279cb5f..7e3e1bd2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -363,10 +363,10 @@ void do_input() { helpWindow->setVisible(false); } - // Close the config window, applying changes if opened + // Close the config window, cancelling changes if opened else if (setupWindow->isVisible()) { - setupWindow->action("apply"); + setupWindow->action("cancel"); } // Else, open the chat edit box else diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 91f64ecc..ad38bae3 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -163,13 +163,31 @@ Setup::Setup(): // Load default settings modeList->setSelected(-1); + + // Full Screen + fullScreenEnabled = config.getValue("screen", 0); + fsCheckBox->setMarked(fullScreenEnabled); + + // Sound + soundEnabled = config.getValue("sound", 0); + soundCheckBox->setMarked(soundEnabled); + + sfxVolume = (int)config.getValue("sfxVolume", 100); + sfxSlider->setValue(sfxVolume); + + musicVolume = (int)config.getValue("musicVolume", 60); + musicSlider->setValue(musicVolume); + + // Graphics + customCursorEnabled = config.getValue("customcursor", 1); + customCursorCheckBox->setMarked(customCursorEnabled); + + opacity = config.getValue("guialpha", 0.8); + alphaSlider->setValue(opacity); + + openGlEnabled = config.getValue("openGL", 0); + openGlCheckBox->setMarked(openGlEnabled); - fsCheckBox->setMarked(config.getValue("screen", 0)); - soundCheckBox->setMarked(config.getValue("sound", 0)); - customCursorCheckBox->setMarked(config.getValue("customcursor", 1)); - alphaSlider->setValue(config.getValue("guialpha", 0.8)); - sfxSlider->setValue(config.getValue("sfxVolume", 100)); - musicSlider->setValue(config.getValue("musicVolume", 60)); } Setup::~Setup() @@ -178,6 +196,7 @@ Setup::~Setup() delete modeList; delete scrollArea; delete fsCheckBox; + delete openGlCheckBox; delete soundCheckBox; delete audioLabel; delete applyButton; @@ -214,12 +233,16 @@ void Setup::action(const std::string &eventId) else if (eventId == "apply") { setVisible(false); - bool fullscreen = fsCheckBox->isMarked(); - if (fullscreen != (config.getValue("screen", 0) == 1)) { - if (!guiGraphics->setFullscreen(fullscreen)) { + // Full screen changes + bool fullscreen = fsCheckBox->isMarked(); + if (fullscreen != (config.getValue("screen", 0) == 1)) + { + if (!guiGraphics->setFullscreen(fullscreen)) + { fullscreen = !fullscreen; - if (!guiGraphics->setFullscreen(fullscreen)) { + if (!guiGraphics->setFullscreen(fullscreen)) + { std::cerr << "Failed to switch to " << (fullscreen ? "windowed" : "fullscreen") << "mode and restoration of old mode also failed!" << @@ -230,21 +253,72 @@ void Setup::action(const std::string &eventId) config.setValue("screen", fullscreen ? 1 : 0); } - // Sound settings - if (soundCheckBox->isMarked()) { + // Sound settings changes + if (soundCheckBox->isMarked()) + { config.setValue("sound", 1); try { sound.init(); } - catch (const char *err) { + catch (const char *err) + { new OkDialog(this, "Sound Engine", err); logger->log("Warning: %s", err); } - } else { + } + else + { config.setValue("sound", 0); sound.close(); } - } else if (eventId == "cancel") { + + //TODO: OpenGL changes at apply time + + + // We sync old and new values at apply time + // Screen + fullScreenEnabled = config.getValue("screen", 0); + + // Sound + soundEnabled = config.getValue("sound", 0); + sfxVolume = (int)config.getValue("sfxVolume", 100); + musicVolume = (int)config.getValue("musicVolume", 60); + + // Graphics + customCursorEnabled = config.getValue("customcursor", 1); + opacity = config.getValue("guialpha", 0.8); + openGlEnabled = config.getValue("openGL", 0); + + } + else if (eventId == "cancel") + { setVisible(false); + + // Restoring old values when cancelling + // Screen + config.setValue("screen", fullScreenEnabled ? 1 : 0); + fsCheckBox->setMarked(fullScreenEnabled); + + // Sound + config.getValue("sound", soundEnabled ? 1 : 0); + soundCheckBox->setMarked(soundEnabled); + + config.getValue("sfxVolume", sfxVolume ? 1 : 0); + sound.setSfxVolume(sfxVolume); + sfxSlider->setValue(sfxVolume); + + config.setValue("musicVolume", musicVolume); + sound.setMusicVolume(musicVolume); + musicSlider->setValue(musicVolume); + + // Graphics + config.setValue("customcursor", customCursorEnabled ? 1 : 0); + customCursorCheckBox->setMarked(customCursorEnabled); + + config.setValue("guialpha", opacity); + alphaSlider->setValue(opacity); + + config.setValue("openGL", openGlEnabled ? 1 : 0); + openGlCheckBox->setMarked(openGlEnabled); } } diff --git a/src/gui/setup.h b/src/gui/setup.h index 02eebae1..70491957 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -83,6 +83,11 @@ class Setup : public Window, public gcn::ActionListener gcn::Button *applyButton; gcn::Button *cancelButton; + // Variables that keeps old settings until the user "apply" them... + int musicVolume, sfxVolume; + double opacity; + bool fullScreenEnabled, openGlEnabled, customCursorEnabled, soundEnabled; + public: /** * Constructor. |