-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathMenuMan.h
More file actions
102 lines (78 loc) · 3.86 KB
/
MenuMan.h
File metadata and controls
102 lines (78 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#include "Singleton.h"
#include <memory>
#define g_MenuMan MenuMan::Instance()
namespace RTE {
class AllegroScreen;
class GUIInputWrapper;
class Controller;
class TitleScreen;
class MainMenuGUI;
class ScenarioGUI;
class PauseMenuGUI;
/// The singleton manager responsible for handling all the out-of-game menu screens (main menu, scenario menu, etc.).
class MenuMan : public Singleton<MenuMan> {
public:
#pragma region Creation
/// Constructor method used to instantiate a MenuMan object in system memory. Initialize() should be called before using the object.
MenuMan() = default;
/// Makes the MenuMan object ready for use.
/// @param firstTimeInit Whether this is initializing for the first time, meaning the game is booting up, so the loading screen needs to be shown and all module loading should happen.
void Initialize(bool firstTimeInit = true);
/// Reinitializes all the Main Menu GUIs after a resolution change. Must be done otherwise the GUIs retain the original resolution settings and become all screwy.
void Reinitialize();
#pragma endregion
#pragma region Concrete Methods
/// Sets the appropriate TitleScreen transition before entering the menu loop.
void HandleTransitionIntoMenuLoop();
/// Updates the MenuMan state.
/// @return Whether the MenuMan update has reached a state where the menu loop should be exited so the simulation loop can proceed.
bool Update();
/// Draws the MenuMan to the screen.
void Draw() const;
#pragma endregion
#pragma region Getters/Setters
/// Checks if we're currently in a menu screen.
/// @return True if in a menu screen; false otherwise.
bool GetIsInMenuScreen() const { return m_IsInMenuScreen; }
/// Sets if we're currently in a menu screen.
/// @param isInMenuScreen Whether we're in any menu screen.
void SetIsInMenuScreen(bool isInMenuScreen) { m_IsInMenuScreen = isInMenuScreen; }
#pragma endregion
private:
/// Enumeration for the different menu screens that are active based on transition states.
enum ActiveMenu {
MenusDisabled,
MainMenuActive,
ScenarioMenuActive,
MetaGameMenuActive,
PauseMenuActive,
};
bool m_IsInMenuScreen; //!< Whether we're currently in a menu screen.
ActiveMenu m_ActiveMenu; //!< The currently active menu screen that is being updated and drawn. See ActiveMenu enumeration.
std::unique_ptr<GUIInputWrapper> m_GUIInput; //!< The GUIInput interface of this MenuMan.
std::unique_ptr<AllegroScreen> m_GUIScreen; //!< The GUIScreen interface of this MenuMan.
std::unique_ptr<Controller> m_MenuController; //!< A Controller to handle player input in menu screens that require it.
std::unique_ptr<TitleScreen> m_TitleScreen; //!< The title screen.
std::unique_ptr<MainMenuGUI> m_MainMenu; //!< The main menu screen.
std::unique_ptr<ScenarioGUI> m_ScenarioMenu; //!< The scenario menu screen.
std::unique_ptr<PauseMenuGUI> m_PauseMenu; //!< The game pause menu screen.
#pragma region Updates
/// Sets the active menu screen to be enabled, updated and drawn to the screen, besides the title screen which is always active.
void SetActiveMenu();
/// Updates the main menu screen and handles the update results.
/// @return Whether the program was set to be terminated by the user through the main menu screen.
bool UpdateMainMenu() const;
/// Updates the scenario menu screen and handles the update results.
void UpdateScenarioMenu() const;
/// Updates the MetaGame menu screen and handles the update results.
/// @return Whether the program was set to be terminated by the user through the MetaGame menu screen.
bool UpdateMetaGameMenu() const;
/// Updates the pause menu screen and handles the update results.
void UpdatePauseMenu() const;
#pragma endregion
// Disallow the use of some implicit methods.
MenuMan(const MenuMan& reference) = delete;
MenuMan& operator=(const MenuMan& rhs) = delete;
};
} // namespace RTE