From 2f62eba6c22207f1c7cff2aa16b2e060eacb1eb9 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 8 Jun 2008 18:35:31 +0100 Subject: [PATCH] Link in options screen --- src/Main.cpp | 4 ++++ src/Menu.cpp | 22 ++++++++++++++++------ src/Menu.hpp | 2 ++ src/Options.cpp | 12 +++++++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 6e22859..083681a 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -18,6 +18,7 @@ */ #include "Game.hpp" +#include "Options.hpp" #define DEBUG_WINDOW #define DEBUG_WIN_X 800 @@ -69,11 +70,13 @@ int main(int argc, char **argv) MainMenu *mm = new MainMenu(); Game *g = new Game(); HighScores *hs = new HighScores(); + Options *opt = new Options(); ScreenManager &sm = ScreenManager::GetInstance(); sm.AddScreen("MAIN MENU", mm); sm.AddScreen("GAME", g); sm.AddScreen("HIGH SCORES", hs); + sm.AddScreen("OPTIONS", opt); // Run the game sm.SelectScreen("MAIN MENU"); @@ -83,6 +86,7 @@ int main(int argc, char **argv) delete mm; delete g; delete hs; + delete opt; } catch (std::runtime_error e) { #ifdef WIN32 diff --git a/src/Menu.cpp b/src/Menu.cpp index b8afb78..eb7198b 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -174,8 +174,7 @@ void MainMenu::Process() // Apply fade if (fade <= 0.0f) { // Move to the options screen - // TODO! - sm.SelectScreen("MAIN MENU"); + sm.SelectScreen("OPTIONS"); } else { fade -= MENU_FADE_SPEED; @@ -194,7 +193,11 @@ void MainMenu::Process() } } - // Move the stars + MoveStars(); +} + +void MainMenu::MoveStars() +{ StarListIt it = stars.begin(); while (it != stars.end()) { if ((*it).Move()) { @@ -210,13 +213,20 @@ void MainMenu::Process() stars.push_back(MenuStar()); } +/* + * This is also used by the options screen. + */ +void MainMenu::DisplayStars() +{ + for (StarListIt it = stars.begin(); it != stars.end(); ++it) + (*it).Display(); +} + void MainMenu::Display() { OpenGL &opengl = OpenGL::GetInstance(); - - for (StarListIt it = stars.begin(); it != stars.end(); ++it) - (*it).Display(); + DisplayStars(); // Draw logo and menu items startOpt.Display(selOption == optStart, bigness, fade); diff --git a/src/Menu.hpp b/src/Menu.hpp index 1058166..42b233c 100644 --- a/src/Menu.hpp +++ b/src/Menu.hpp @@ -66,6 +66,8 @@ public: void Load(); void Process(); void Display(); + void DisplayStars(); + void MoveStars(); private: enum MenuState { msFadeIn, msInMenu, msFadeToStart, diff --git a/src/Options.cpp b/src/Options.cpp index 829d627..82004b2 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -16,6 +16,7 @@ */ #include "Options.hpp" +#include "Menu.hpp" Options::Options() { @@ -24,16 +25,21 @@ Options::Options() void Options::Load() { - cout << "Options loaded" << endl; + } void Options::Process() { - + static_cast + (ScreenManager::GetInstance().GetScreenById("MAIN MENU")) + ->MoveStars(); } void Options::Display() { - + // Delegate star drawing to the menu + static_cast + (ScreenManager::GetInstance().GetScreenById("MAIN MENU")) + ->DisplayStars(); } -- 2.39.2