#include <UISystem.hpp>
|
| | UISystem () |
| void | lruUpdate (int id, bool isMain) |
| | Updates the order of lruBgSub/lruBgMain for the "least recently updated" id.
|
| void | registerScreen (UIScreen *screen) |
| | Registers screens to UISystem to have them pre-loaded before calling show.
|
| void | hideAllScreens () |
| | hides all screens.
|
| void | cleanupScreens () |
| | Unloads and cleans up all registered screens. Used to reset previous configs.
|
| void | cleanupMenus () |
| | Unloads and cleans up all registered menus. Used to reset previous configs.
|
| void | cancelSFX () |
| | Stops playing the current sound effect, if any.
|
| void | resetUIResources () |
| | Cleans up UISystem related resources.
|
| void | applyPendingScreen () |
| | Loads (if needed) and displays the pending screen, then clears it.
|
|
| UIManager & | ui = UIManager::getInstance() |
| OamState * | oamSub = nullptr |
| OamState * | oamMain = nullptr |
| std::array< int, 3 > | lruBgSub = {0, 0, 0} |
| | background ids. The order of the arrays matter. Front = least recently updated, back = last updated
|
| std::array< int, 2 > | lruBgMain = {0, 0} |
| std::array< int, 3 > | hwBgSub = {0, 0, 0} |
| | original background ids (order doesn't change)
|
| std::array< int, 2 > | hwBgMain = {0, 0} |
| int | screenMainCount = 0 |
| | currently loaded screens (max 3 sub, 2 main)
|
| int | screenSubCount = 0 |
| std::array< UIScreen *, 3 > | loadedSub {nullptr, nullptr, nullptr} |
| std::array< UIScreen *, 2 > | loadedMain = {nullptr, nullptr} |
| std::array< UIMenu *, 10 > | menus = {} |
| UIMenu * | activeMenu = nullptr |
| TextComponent * | text = nullptr |
| SFXComponent * | sfxCmpt = nullptr |
| bool | renderUIText = false |
| UIScreen * | pendingScreen = nullptr |
| | screen requested by ShowScreen, applied at the start of the next update
|
Definition at line 26 of file UISystem.hpp.
◆ UISystem()
◆ applyPendingScreen()
| void UISystem::applyPendingScreen |
( |
| ) |
|
|
private |
Loads (if needed) and displays the pending screen, then clears it.
display sprites on screen
display background on screen
text goes after the background is shown, so it does not extend the time with no background visible
Definition at line 258 of file UISystem.cpp.
◆ cancelSFX()
| void UISystem::cancelSFX |
( |
| ) |
|
|
private |
Stops playing the current sound effect, if any.
Definition at line 554 of file UISystem.cpp.
◆ cleanupMenus()
| void UISystem::cleanupMenus |
( |
| ) |
|
|
private |
Unloads and cleans up all registered menus. Used to reset previous configs.
Definition at line 573 of file UISystem.cpp.
◆ cleanupScreens()
| void UISystem::cleanupScreens |
( |
| ) |
|
|
private |
Unloads and cleans up all registered screens. Used to reset previous configs.
Definition at line 514 of file UISystem.cpp.
◆ hideAllScreens()
| void UISystem::hideAllScreens |
( |
| ) |
|
|
private |
◆ init()
◆ lruUpdate()
| void UISystem::lruUpdate |
( |
int | id, |
|
|
bool | isMain ) |
|
private |
Updates the order of lruBgSub/lruBgMain for the "least recently updated" id.
The lruBgMain/lruBgSub arrays dynamically shuffle to track the Least Recently Used (LRU) hardware layer at index [0], ensuring the oldest visible screen is the one overwritten when capacity is reached.
- Parameters
-
| id | the background id |
| isMain | flag indicating if the screen is to be rendered on the main (or sub) screen |
Definition at line 390 of file UISystem.cpp.
◆ on_receive() [1/9]
ETL message handler to configure UIMenus.
First, it resets any previous configs via cleanupMenus. Second, it sets all menus to be deactivated, and sets their text component pointer.
- Note
- Required to call in order to enable & use UIMenus
- Parameters
-
| config | The event payload containing the UIMenu configuration to apply. |
- Note
- 192px is the screen height. 1 row is reserved for the flashing text. Each line takes the font size height
Definition at line 218 of file UISystem.cpp.
◆ on_receive() [2/9]
ETL message handler to configure UIScreens.
First, it resets any previous configs via cleanupScreens. Second, it sets the background pointers to render screens to. The arrays passed into setGraphics() must contain the actual libnds hardware background layer IDs (e.g., 0, 1, 2, 3). Third, it register screens via registerScreen to have them pre-loaded before calling show.
- Note
- Required to call in order to use UIScreens
- Parameters
-
| config | The event payload containing the UIScreen configuration to apply. |
Definition at line 186 of file UISystem.cpp.
◆ on_receive() [3/9]
ETL message handler to hide all menus.
Definition at line 375 of file UISystem.cpp.
◆ on_receive() [4/9]
ETL message handler to hides all screens.
Wrapper for hideAllScreens
Definition at line 342 of file UISystem.cpp.
◆ on_receive() [5/9]
ETL message handler to render UI text.
Definition at line 385 of file UISystem.cpp.
◆ on_receive() [6/9]
◆ on_receive() [7/9]
ETL message handler to switch to the specified menu.
If another menu is already loaded & hidden, it deactivates that menu and activates the supplied menu pointer instead
- Note
- Cannot load multiple menus at one time.
- Parameters
-
| msg | The event payload containing the UIMenu to switch to. |
Definition at line 347 of file UISystem.cpp.
◆ on_receive() [8/9]
ETL message handler to switch to the specified screen.
The switch is deferred: the screen is stored as pending and applied at the start of the next UISystem::update, so the VRAM writes happen inside VBlank. If the screen is already loaded & hidden, it displays screen. If the screen is not loaded, it loads and displays the screen.
- Note
- Cannot load the same UIScreen on both sub and main. Cannot load multiple UIScreens on the same physical screen (main or sub)
- Parameters
-
| msg | The event payload containing the UIScreen to switch to. |
Definition at line 247 of file UISystem.cpp.
◆ on_receive() [9/9]
◆ on_receive_unknown()
| void UISystem::on_receive_unknown |
( |
const etl::imessage & | msg | ) |
|
|
inline |
Fallback handler for unhandled ETL messages.
Required by the ETL message router interface. Safely ignores any messages routed to the UISystem that do not have a specific handler.
- Parameters
-
| msg | The unhandled incoming message (unused). |
Definition at line 140 of file UISystem.hpp.
◆ registerScreen()
| void UISystem::registerScreen |
( |
UIScreen * | screen | ) |
|
|
private |
Registers screens to UISystem to have them pre-loaded before calling show.
When a screen is registered, it is assigned an available hardware bgId. Persistent = is always loaded into memory. Paged (swappable) = can be loaded/unloaded into memory.
- Parameters
-
| screen | the screen to register |
Definition at line 440 of file UISystem.cpp.
◆ resetUIResources()
| void UISystem::resetUIResources |
( |
| ) |
|
|
private |
◆ setSFXComponent()
◆ shutdown()
| void UISystem::shutdown |
( |
| ) |
|
|
override |
Unloads and cleans up all registered screens. Wrapper for cleanup.
Definition at line 165 of file UISystem.cpp.
◆ update()
| void UISystem::update |
( |
ae::q20_12_t | dt | ) |
|
|
override |
Performs menu navigation logic.
Definition at line 19 of file UISystem.cpp.
◆ Singleton< UISystem >
◆ activeMenu
| UIMenu* UISystem::activeMenu = nullptr |
|
private |
◆ hwBgMain
| std::array<int, 2> UISystem::hwBgMain = {0, 0} |
|
private |
◆ hwBgSub
| std::array<int, 3> UISystem::hwBgSub = {0, 0, 0} |
|
private |
original background ids (order doesn't change)
Definition at line 213 of file UISystem.hpp.
◆ loadedMain
| std::array<UIScreen*, 2> UISystem::loadedMain = {nullptr, nullptr} |
|
private |
◆ loadedSub
| std::array<UIScreen*, 3> UISystem::loadedSub {nullptr, nullptr, nullptr} |
|
private |
◆ lruBgMain
| std::array<int, 2> UISystem::lruBgMain = {0, 0} |
|
private |
◆ lruBgSub
| std::array<int, 3> UISystem::lruBgSub = {0, 0, 0} |
|
private |
background ids. The order of the arrays matter. Front = least recently updated, back = last updated
Definition at line 209 of file UISystem.hpp.
◆ menus
| std::array<UIMenu*, 10> UISystem::menus = {} |
|
private |
◆ oamMain
| OamState* UISystem::oamMain = nullptr |
|
private |
◆ oamSub
| OamState* UISystem::oamSub = nullptr |
|
private |
◆ pendingScreen
| UIScreen* UISystem::pendingScreen = nullptr |
|
private |
screen requested by ShowScreen, applied at the start of the next update
Definition at line 231 of file UISystem.hpp.
◆ renderUIText
| bool UISystem::renderUIText = false |
|
private |
◆ screenMainCount
| int UISystem::screenMainCount = 0 |
|
private |
currently loaded screens (max 3 sub, 2 main)
Definition at line 217 of file UISystem.hpp.
◆ screenSubCount
| int UISystem::screenSubCount = 0 |
|
private |
◆ sfxCmpt
◆ text
◆ ui
| UIManager& UISystem::ui = UIManager::getInstance() |
|
private |
The documentation for this class was generated from the following files: