10#include <aegis/ndsTypes.hpp>
11#include <aegis/types.hpp>
33 bool selectionWasMoving =
activeMenu->selectionOffset() != 0;
35 if (selectionWasMoving ||
activeMenu->selectionOffset() != 0)
132 text->clearArea(0, 0, 256,
text->getFontSize() +
text->getLineSpacing());
137 int textSize =
text->getFontSize();
144 const int optionsTop = textSize;
145 const int optionsHeight = textSize *
activeMenu->visibleOptions +
text->getLineSpacing();
146 text->clearArea(0, optionsTop, 256, optionsHeight);
154 text->drawText(
activeMenu->options[option].name, x, textSize + textSize * i, color);
209 if (screen ==
nullptr)
227 int textSize =
text->getFontSize();
237 menu->isActive =
false;
240 if (!menu->customRender)
242 menu->visibleOptions = (192 / textSize) - 1;
249 if (msg.
screen ==
nullptr)
280 for (
int i = 0; i < 2; i++)
293 for (
int i = 0; i < 3; i++)
304 if (oldScreen !=
nullptr)
310 screen->
oam = oldScreen->
oam;
311 oldScreen->
bgId = -1;
312 oldScreen->
oam =
nullptr;
349 if (msg.
menu ==
nullptr)
397 for (
int i = 0; i < 2; i++)
407 for (
int i = pos; i < 1; i++)
420 for (
int i = 0; i < 3; i++)
430 for (
int i = pos; i < 2; i++)
442 if (screen ==
nullptr)
477 "Too many main screens registered. A maximum of 2 main screens can be registered.");
483 "Too many sub screens registered. A maximum of 3 sub screens can be registered.");
497 ui.hideBg(val->bgId);
498 val->removeSprites();
509 ui.hideBg(val->bgId);
510 val->removeSprites();
521 for (
int i = 0; i < 3; i++)
536 for (
int j = 0; j < 2; j++)
585 menu->text =
nullptr;
Generic events used across multiple systems.
TextColor
Human Readable enum for text colors.
Manages the mapping of UIScreens to these hardware layers.
virtual void renderText()
Draws the screen's text. Called after the background is shown.
virtual void load()=0
Loads graphics data into memory & pushes to VRAM.
virtual void unload()=0
Unloads graphics data from memory.
virtual void renderSprites()
Applys sprite colour palette & draws sprites to screen.
UIScreen * pendingScreen
screen requested by ShowScreen, applied at the start of the next update
void cancelSFX()
Stops playing the current sound effect, if any.
void shutdown() override
Unloads and cleans up all registered screens. Wrapper for cleanup.
std::array< UIScreen *, 2 > loadedMain
void applyPendingScreen()
Loads (if needed) and displays the pending screen, then clears it.
void resetUIResources()
Cleans up UISystem related resources.
std::array< int, 3 > hwBgSub
original background ids (order doesn't change)
std::array< int, 3 > lruBgSub
background ids. The order of the arrays matter. Front = least recently updated, back = last updated
int screenMainCount
currently loaded screens (max 3 sub, 2 main)
std::array< UIMenu *, 10 > menus
std::array< int, 2 > lruBgMain
std::array< UIScreen *, 3 > loadedSub
void hideAllScreens()
hides all screens.
void lruUpdate(int id, bool isMain)
Updates the order of lruBgSub/lruBgMain for the "least recently updated" id.
void update(ae::q20_12_t) override
Performs menu navigation logic.
void setSFXComponent(SFXComponent *sfx)
void on_receive(const Event::SwitchView &msg)
void cleanupMenus()
Unloads and cleans up all registered menus. Used to reset previous configs.
void cleanupScreens()
Unloads and cleans up all registered screens. Used to reset previous configs.
void registerScreen(UIScreen *screen)
Registers screens to UISystem to have them pre-loaded before calling show.
std::array< int, 2 > hwBgMain
Holds global variables used game-wide.
volatile u32 systemKeysDown
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Util to handle error logging.
Event to trigger hiding all UIScreens.
Event to trigger rendering UI text.
Event payload to release resources owned by the current view.
Event to show specified screen.
UIScreen * screen
The screen to show.
Event payload to switch the ViewState.