diff --git a/asteroids/View.cc b/asteroids/View.cc index 7798322..c2cbc3a 100644 --- a/asteroids/View.cc +++ b/asteroids/View.cc @@ -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(); } diff --git a/engine/IMGUIControls.cc b/engine/IMGUIControls.cc index a8cefb5..6047d48 100644 --- a/engine/IMGUIControls.cc +++ b/engine/IMGUIControls.cc @@ -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; } diff --git a/engine/Variables.cc b/engine/Variables.cc index 6e36ced..169d003 100644 --- a/engine/Variables.cc +++ b/engine/Variables.cc @@ -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()); diff --git a/engine/VariablesGlobal.h b/engine/VariablesGlobal.h index 0efc970..895cb7b 100644 --- a/engine/VariablesGlobal.h +++ b/engine/VariablesGlobal.h @@ -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;