diff --git a/asteroids/AsteroidsEnums.h b/asteroids/AsteroidsEnums.h index 4dd8473..912f916 100644 --- a/asteroids/AsteroidsEnums.h +++ b/asteroids/AsteroidsEnums.h @@ -21,6 +21,7 @@ END_ENUM(GameEntityType) BEGIN_ENUM(ViewState) { + DECL_ENUM_ELEMENT(ViewStateUnknown), DECL_ENUM_ELEMENT(ViewStateMainMenu), DECL_ENUM_ELEMENT(ViewStateGameRunning), DECL_ENUM_ELEMENT(ViewStatePaused), diff --git a/asteroids/Model.cc b/asteroids/Model.cc index e5c619f..b67415c 100644 --- a/asteroids/Model.cc +++ b/asteroids/Model.cc @@ -818,7 +818,7 @@ void Model::OnLevelComplete() { mLevelTimeBonusPoints = 0; } - int extra_lives = floor ((mPoints + mLevelPoints) / 200000.f) - floor (mPoints / 200000.f); + int extra_lives = floor ((mPoints + mLevelPoints) / 400000.f) - floor (mPoints / 400000.f); if (extra_lives > 0) { mPlayerLives += extra_lives; } diff --git a/asteroids/View.cc b/asteroids/View.cc index 7247512..621ea5b 100644 --- a/asteroids/View.cc +++ b/asteroids/View.cc @@ -514,13 +514,6 @@ void View::DrawUiMainMenu() { PushViewState(ViewStateCredits); } - /* - if (Engine::GUI::Button (6, "E", screen_right - 48, 20, 32, button_height)) { - PushViewState(ViewStateEditor); - GetController()->ResetLevel(); - } - */ - if (Engine::GUI::Button (5, "Quit", screen_right * 0.5 - 100, 430, button_width, button_height)) { Engine::RunCommand("quit"); } @@ -643,7 +636,7 @@ void View::DrawUiGameOver() { if (mFadeTimerSecValue > 0.) return; - if (Engine::GUI::Button (2, "Continue...", + if (Engine::GUI::Button (2, "Highscores", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 100, button_width, button_height)) { // We do not want the background to show the remaining bits of the game @@ -1055,7 +1048,11 @@ void View::DrawUiHighscore() { if (Engine::GUI::Button (1, "Back to Menu", screen_right * 0.5 - 250 * 0.5, y + 16, button_width, button_height) || Engine::GUI::CheckKeyPressed(SDLK_ESCAPE) ) { - PopViewState(); + // Remove the ViewStateGameRunning + + while (GetViewState() != ViewStateMainMenu) { + PopViewState(); + } } } @@ -1119,9 +1116,9 @@ _Top Level Designer\r\ _Additional Level Design\r\ Martin Felis\r\ michi\r\ - Khai-Long Ho Hoang\r\ Andi\r\ Sebastian Felis\r\ + Khai-Long Ho Hoang\r\ \r\ _Music\r\ DJad - Space Exploration\r\ diff --git a/asteroids/View.h b/asteroids/View.h index 0082624..5abefaa 100644 --- a/asteroids/View.h +++ b/asteroids/View.h @@ -46,7 +46,9 @@ class View : public Engine::ViewBase { return mViewStateStack.top(); } /** \brief Removes the top element of the current ViewState stack */ - void PopViewState () { + ViewState PopViewState () { + ViewState top = mViewStateStack.top(); + // Warning: you must not query for an invalid enum with // GetStringENUM_NAME! std::string popped_name = GetStringViewState(mViewStateStack.top()); @@ -68,6 +70,8 @@ class View : public Engine::ViewBase { Engine::EventBasePtr changeviewstate_event (new Engine::EventBase()); changeviewstate_event->mEventType = EventChangeViewState; QueueEvent (changeviewstate_event); + + return top; } protected: diff --git a/asteroids/main.cc b/asteroids/main.cc index a48de5d..15750bf 100644 --- a/asteroids/main.cc +++ b/asteroids/main.cc @@ -179,6 +179,8 @@ int main (int argc, char* argv[]) { config_file << "set effects_volume " << Engine::GetEffectsVolume() << std::endl; config_file << "set music_volume " << Engine::GetMusicVolume() << std::endl; config_file << "set use_server_highscore " << Engine::GetVariableString("use_server_highscore") << std::endl; + if (Engine::GetVariableBool("cheat_mode")) + config_file << "set cheat_mode " << true << std::endl; config_file.close(); SDL_WM_SetIcon(NULL,NULL); diff --git a/engine/Variables.cc b/engine/Variables.cc index 169d003..249a278 100644 --- a/engine/Variables.cc +++ b/engine/Variables.cc @@ -179,6 +179,24 @@ float &GetVariableFloat (const std::string &name, float def) { return var->GetFloatValue (); } +/** \brief Returns the boolean value of the Variable with the given name */ +bool& GetVariableBool (const std::string &name, bool def) { + /* We use a static result variable for the case that def was not passed to + * is function */ + static bool def_result = def; + + if (! VariablesInstance ) { + LogError ("Unable to register Variable '%s': Variables System not initialized!", name.c_str()); + return def_result; + } + + Variable *var = VariablesInstance->GetVariable (name); + if (!var) { + return def_result; + } + + return var->GetBoolValue (); +} }