diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-13 21:33:06 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-13 21:35:19 +0200 |
commit | 28bc8c0edb549cdbbe0832c4202630a039f738b1 (patch) | |
tree | 9989f31a5121f82af5aa264ebfe7096c5ea5030f /src/gui | |
parent | 627e1bc7eee5b821d29b2161dec4991cae7bf9c0 (diff) | |
download | mana-client-28bc8c0edb549cdbbe0832c4202630a039f738b1.tar.gz mana-client-28bc8c0edb549cdbbe0832c4202630a039f738b1.tar.bz2 mana-client-28bc8c0edb549cdbbe0832c4202630a039f738b1.tar.xz mana-client-28bc8c0edb549cdbbe0832c4202630a039f738b1.zip |
Some cleanup of the Configuration interface
Mainly avoid all the convertions from integer to float and then to
string and also back from string to float and then to integer.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 2 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 18 | ||||
-rw-r--r-- | src/gui/setup_audio.cpp | 19 | ||||
-rw-r--r-- | src/gui/setup_players.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 41 |
5 files changed, 39 insertions, 43 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 7f08ec48..48acefee 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -107,7 +107,7 @@ ChatWindow::ChatWindow(): ChatWindow::~ChatWindow() { - config.setValue("ReturnToggles", mReturnToggles ? "1" : "0"); + config.setValue("ReturnToggles", mReturnToggles); delete mRecorder; delete_all(mWhispers); delete mItemLinkHandler; diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 061a2ace..3762043c 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -19,19 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/font.hpp> +#include "gui/minimap.h" -#include "minimap.h" +#include "being.h" +#include "beingmanager.h" +#include "configuration.h" +#include "graphics.h" +#include "localplayer.h" -#include "../being.h" -#include "../beingmanager.h" -#include "../configuration.h" -#include "../graphics.h" -#include "../localplayer.h" +#include "resources/image.h" -#include "../resources/image.h" +#include "utils/gettext.h" -#include "../utils/gettext.h" +#include <guichan/font.hpp> bool Minimap::mShow = true; diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 5e13574e..3f98c44f 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -79,9 +79,14 @@ Setup_Audio::Setup_Audio(): void Setup_Audio::apply() { - if (mSoundCheckBox->isSelected()) + mSoundEnabled = mSoundCheckBox->isSelected(); + mSfxVolume = (int) config.getValue("sfxVolume", 100); + mMusicVolume = (int) config.getValue("musicVolume", 60); + + config.setValue("sound", mSoundEnabled); + + if (mSoundEnabled) { - config.setValue("sound", 1); try { sound.init(); @@ -92,20 +97,16 @@ void Setup_Audio::apply() logger->log("Warning: %s", err); } - if (engine) { + if (engine) + { Map *currentMap = engine->getCurrentMap(); sound.playMusic(currentMap->getProperty("music"), -1); } } else { - config.setValue("sound", 0); sound.close(); } - - mSoundEnabled = config.getValue("sound", 0); - mSfxVolume = (int) config.getValue("sfxVolume", 100); - mMusicVolume = (int) config.getValue("musicVolume", 60); } void Setup_Audio::cancel() @@ -118,7 +119,7 @@ void Setup_Audio::cancel() sound.setMusicVolume(mMusicVolume); mMusicSlider->setValue(mMusicVolume); - config.setValue("sound", mSoundEnabled ? 1 : 0); + config.setValue("sound", mSoundEnabled); config.setValue("sfxVolume", mSfxVolume); config.setValue("musicVolume", mMusicVolume); } diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 8925016b..9a3d6967 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -157,7 +157,7 @@ public: gcn::DropDown *choicebox = dynamic_cast<gcn::DropDown *>( getElementAt(row, RELATION_CHOICE_COLUMN)); player_relations.setRelation(getPlayerAt(row), - static_cast<PlayerRelation::relation>( + static_cast<PlayerRelation::Relation>( choicebox->getSelected())); } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 8f3d7399..8f358eda 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -109,7 +109,7 @@ Setup_Video::Setup_Video(): mFullScreenEnabled(config.getValue("screen", false)), mOpenGLEnabled(config.getValue("opengl", false)), mCustomCursorEnabled(config.getValue("customcursor", true)), - mVisibleNamesEnabled(config.getValue("visiblenames", 1)), + mVisibleNamesEnabled(config.getValue("visiblenames", true)), mParticleEffectsEnabled(config.getValue("particleeffects", true)), mNameEnabled(config.getValue("showownname", false)), mPickupChatEnabled(config.getValue("showpickupchat", true)), @@ -351,13 +351,13 @@ void Setup_Video::apply() _("Restart needed for changes to take effect.")); } #endif - config.setValue("screen", fullscreen ? true : false); + config.setValue("screen", fullscreen); } // OpenGL change if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled) { - config.setValue("opengl", mOpenGLCheckBox->isSelected() ? true : false); + config.setValue("opengl", mOpenGLCheckBox->isSelected()); // OpenGL can currently only be changed by restarting, notify user. new OkDialog(_("Changing OpenGL"), @@ -370,7 +370,7 @@ void Setup_Video::apply() // We sync old and new values at apply time mFullScreenEnabled = config.getValue("screen", false); mCustomCursorEnabled = config.getValue("customcursor", true); - mVisibleNamesEnabled = config.getValue("visiblenames", 1); + mVisibleNamesEnabled = config.getValue("visiblenames", true); mParticleEffectsEnabled = config.getValue("particleeffects", true); mNameEnabled = config.getValue("showownname", false); mSpeechMode = (int) config.getValue("speech", 3); @@ -419,19 +419,18 @@ void Setup_Video::cancel() updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius"); updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness"); - config.setValue("screen", mFullScreenEnabled ? true : false); - config.setValue("customcursor", mCustomCursorEnabled ? true : false); - config.setValue("visiblenames", mVisibleNamesEnabled ? 1 : 0); - config.setValue("particleeffects", mParticleEffectsEnabled ? true : false); + config.setValue("screen", mFullScreenEnabled); + config.setValue("customcursor", mCustomCursorEnabled); + config.setValue("visiblenames", mVisibleNamesEnabled); + config.setValue("particleeffects", mParticleEffectsEnabled); config.setValue("speech", mSpeechMode); - config.setValue("showownname", mNameEnabled ? true : false); + config.setValue("showownname", mNameEnabled); if (player_node) player_node->mUpdateName = true; config.setValue("guialpha", mOpacity); - config.setValue("opengl", mOpenGLEnabled ? true : false); - config.setValue("showpickupchat", mPickupChatEnabled ? true : false); - config.setValue("showpickupparticle", mPickupParticleEnabled ? - true : false); + config.setValue("opengl", mOpenGLEnabled); + config.setValue("showpickupchat", mPickupChatEnabled); + config.setValue("showpickupparticle", mPickupParticleEnabled); } void Setup_Video::action(const gcn::ActionEvent &event) @@ -455,31 +454,28 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (event.getId() == "customcursor") { - config.setValue("customcursor", - mCustomCursorCheckBox->isSelected() ? true : false); + config.setValue("customcursor", mCustomCursorCheckBox->isSelected()); } else if (event.getId() == "visiblenames") { - config.setValue("visiblenames", - mVisibleNamesCheckBox->isSelected() ? 1 : 0); + config.setValue("visiblenames", mVisibleNamesCheckBox->isSelected()); } else if (event.getId() == "particleeffects") { config.setValue("particleeffects", - mParticleEffectsCheckBox->isSelected() ? true : false); + mParticleEffectsCheckBox->isSelected()); new OkDialog(_("Particle effect settings changed."), _("Restart your client or change maps " "for the change to take effect.")); } else if (event.getId() == "pickupchat") { - config.setValue("showpickupchat", mPickupChatCheckBox->isSelected() - ? true : false); + config.setValue("showpickupchat", mPickupChatCheckBox->isSelected()); } else if (event.getId() == "pickupparticle") { config.setValue("showpickupparticle", - mPickupParticleCheckBox->isSelected() ? true : false); + mPickupParticleCheckBox->isSelected()); } else if (event.getId() == "speech") { @@ -508,8 +504,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) // and requires an update if (player_node) player_node->mUpdateName = true; - config.setValue("showownname", - mNameCheckBox->isSelected() ? true : false); + config.setValue("showownname", mNameCheckBox->isSelected()); } else if (event.getId() == "fpslimitslider") { |