persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
UISystem.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <aegis/system.hpp>
11
12#include "core/routerIDs.hpp"
13#include "events/UIEvents.hpp"
14
16
22
24
25// TODO: add a way to indicate reduced # of bg slots
26class UISystem : public ae::SystemRouter<UISystem,
27 Event::ConfigureUIScreen,
28 Event::ConfigureUIMenu,
29 Event::ShowMenu,
30 Event::HideAllMenus,
31 Event::ShowScreen,
32 Event::HideAllScreens,
33 Event::SwitchView,
34 Event::RenderUIText,
35 Event::ResetUIResources>,
36 public ae::Singleton<UISystem>
37{
38 public:
39 void init() override;
40
44 void update(ae::q20_12_t /*dt*/) override;
45
49 void shutdown() override;
50
51 // TODO: replace with ae dependancy injection
53
54 // TODO: move out of UISystem. Only here as a temporary fix
55 void on_receive(const Event::SwitchView& msg);
56
60 void on_receive(const Event::ResetUIResources& /*msg*/);
61
75 void on_receive(const Event::ConfigureUIScreen& config);
76
87 void on_receive(const Event::ConfigureUIMenu& config);
88
99 void on_receive(const Event::ShowMenu& msg);
100
104 void on_receive(const Event::HideAllMenus& /*msg*/);
105
118 void on_receive(const Event::ShowScreen& msg);
119
125 void on_receive(const Event::HideAllScreens& /*msg*/);
126
130 void on_receive(const Event::RenderUIText& /*msg*/);
131
140 void on_receive_unknown(const etl::imessage& msg)
141 {
142 }
143
144 private:
145 friend class Singleton<UISystem>;
146 UISystem() : SystemRouter(kUISystemRouterID)
147 {
148 }
149
160 void lruUpdate(int id, bool isMain);
161
171 void registerScreen(UIScreen* screen);
172
176 void hideAllScreens();
177
181 void cleanupScreens();
182
186 void cleanupMenus();
187
191 void cancelSFX();
192
196 void resetUIResources();
197
201 void applyPendingScreen();
202
203 UIManager& ui = UIManager::getInstance();
204
205 OamState* oamSub = nullptr;
206 OamState* oamMain = nullptr;
207
209 std::array<int, 3> lruBgSub = {0, 0, 0};
210 std::array<int, 2> lruBgMain = {0, 0};
211
213 std::array<int, 3> hwBgSub = {0, 0, 0};
214 std::array<int, 2> hwBgMain = {0, 0};
215
219 std::array<UIScreen*, 3> loadedSub{nullptr, nullptr, nullptr};
220 std::array<UIScreen*, 2> loadedMain = {nullptr, nullptr};
221
222 // menu
223 std::array<UIMenu*, 10> menus = {};
224 UIMenu* activeMenu = nullptr;
225 TextComponent* text = nullptr;
227
228 bool renderUIText = false;
229
232};
Generic events used across multiple systems.
Orchestrates music.
Orchestrates sfx.
Orchestrates rendering text from a bitmap.
Events for UISystem.
Manager for hardware specific rendering functions related to the UI.
UIScreen * pendingScreen
screen requested by ShowScreen, applied at the start of the next update
Definition UISystem.hpp:231
void cancelSFX()
Stops playing the current sound effect, if any.
Definition UISystem.cpp:554
void shutdown() override
Unloads and cleans up all registered screens. Wrapper for cleanup.
Definition UISystem.cpp:165
std::array< UIScreen *, 2 > loadedMain
Definition UISystem.hpp:220
void applyPendingScreen()
Loads (if needed) and displays the pending screen, then clears it.
Definition UISystem.cpp:258
void resetUIResources()
Cleans up UISystem related resources.
Definition UISystem.cpp:562
int screenSubCount
Definition UISystem.hpp:218
std::array< int, 3 > hwBgSub
original background ids (order doesn't change)
Definition UISystem.hpp:213
std::array< int, 3 > lruBgSub
background ids. The order of the arrays matter. Front = least recently updated, back = last updated
Definition UISystem.hpp:209
int screenMainCount
currently loaded screens (max 3 sub, 2 main)
Definition UISystem.hpp:217
std::array< UIMenu *, 10 > menus
Definition UISystem.hpp:223
std::array< int, 2 > lruBgMain
Definition UISystem.hpp:210
OamState * oamSub
Definition UISystem.hpp:205
std::array< UIScreen *, 3 > loadedSub
Definition UISystem.hpp:219
void hideAllScreens()
hides all screens.
Definition UISystem.cpp:488
void on_receive_unknown(const etl::imessage &msg)
Fallback handler for unhandled ETL messages.
Definition UISystem.hpp:140
TextComponent * text
Definition UISystem.hpp:225
void lruUpdate(int id, bool isMain)
Updates the order of lruBgSub/lruBgMain for the "least recently updated" id.
Definition UISystem.cpp:390
void update(ae::q20_12_t) override
Performs menu navigation logic.
Definition UISystem.cpp:19
void setSFXComponent(SFXComponent *sfx)
Definition UISystem.cpp:170
UIManager & ui
Definition UISystem.hpp:203
void on_receive(const Event::SwitchView &msg)
Definition UISystem.cpp:175
SFXComponent * sfxCmpt
Definition UISystem.hpp:226
bool renderUIText
Definition UISystem.hpp:228
void cleanupMenus()
Unloads and cleans up all registered menus. Used to reset previous configs.
Definition UISystem.cpp:573
void cleanupScreens()
Unloads and cleans up all registered screens. Used to reset previous configs.
Definition UISystem.cpp:514
OamState * oamMain
Definition UISystem.hpp:206
void registerScreen(UIScreen *screen)
Registers screens to UISystem to have them pre-loaded before calling show.
Definition UISystem.cpp:440
UIMenu * activeMenu
Definition UISystem.hpp:224
void init() override
Definition UISystem.cpp:13
std::array< int, 2 > hwBgMain
Definition UISystem.hpp:214
Holds routerIDs used for systems.
constexpr etl::message_router_id_t kUISystemRouterID
Definition routerIDs.hpp:13
All parameters needed to configure UIMenus.
Definition UIEvents.hpp:52
All parameters needed to configure UIScreens.
Definition UIEvents.hpp:22
Event to hide all menus.
Definition UIEvents.hpp:76
Event to trigger hiding all UIScreens.
Definition UIEvents.hpp:96
Event to trigger rendering UI text.
Definition UIEvents.hpp:103
Event payload to release resources owned by the current view.
Event to show specified menu.
Definition UIEvents.hpp:65
Event to show specified screen.
Definition UIEvents.hpp:83
Event payload to switch the ViewState.