online highscore can now be selected from Options menu

main
Martin Felis 2011-03-27 22:38:26 +02:00
parent 1c6cb70590
commit 057bf0e1cc
4 changed files with 29 additions and 3 deletions

View File

@ -928,8 +928,25 @@ void View::DrawUiOptions() {
Engine::SetMusicVolume(music_volume);
}
bool use_online_mode = Model::UseServerHighscore.GetBoolValue();
if (Engine::GUI::Button (5, "Back", screen_right * 0.5 - 100, 380, button_width, button_height)
std::string online_button_caption;
if (use_online_mode) {
online_button_caption = "Highscore: online";
} else {
online_button_caption = "Highscore: offline";
}
if (Engine::GUI::CheckButton (12, online_button_caption.c_str(), use_online_mode,
screen_right*0.5 - 130, 360,
300, button_height)) {
if (use_online_mode)
Model::UseServerHighscore.Set("no");
else
Model::UseServerHighscore.Set("yes");
}
if (Engine::GUI::Button (5, "Back", screen_right * 0.5 - 100, 480, button_width, button_height)
|| Engine::GUI::CheckKeyPressed(SDLK_ESCAPE) ) {
PopViewState();
}

View File

@ -357,7 +357,7 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
&& controller->uistate.hotitem == id
&& controller->uistate.activeitem == id) {
controller->uistate.lastwidget = id;
return true;
}
@ -389,7 +389,7 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
controller->uistate.last_keysym = SDLK_CLEAR;
// As we (probably) exit the current set of widgets, we have to clear
// the uistate.kbditem value.
controller->uistate.kbditem = 0;
return true;
break;
}

View File

@ -81,6 +81,12 @@ Variable::Variable (const std::string &name, const std::string &value) {
}
}
void Variable::Set (const std::string &value) {
mStringValue = value;
mFloatValue = atof (value.c_str());
mBoolValue = ParseBoolValue (value);
}
void Variable::RegisterVariable (const std::string &name) {
if (! VariablesInstance ) {
LogError ("Unable to register Variable '%s': Variables System not initialized!", name.c_str());

View File

@ -21,6 +21,9 @@ class Variable {
*/
Variable (const std::string &name, const std::string &value);
/** \brief Parses and sets the corresponding value */
void Set (const std::string &value);
/** \brief Returns the string value of the Variable */
std::string& GetStringValue () {
return mStringValue;