wudd/source/ApplicationState.h

64 lines
1.8 KiB
C
Raw Normal View History

2021-10-09 00:58:55 +02:00
#pragma once
#include <utils/WiiUScreen.h>
#include <utils/ScreenUtils.h>
2021-10-09 00:58:55 +02:00
class ApplicationState {
public:
enum eSubState {
SUBSTATE_RUNNING,
SUBSTATE_RETURN,
2021-10-09 00:58:55 +02:00
};
virtual ~ApplicationState() = default;
2021-10-09 00:58:55 +02:00
virtual void render() = 0;
2021-10-09 01:24:12 +02:00
virtual eSubState update(Input *input) = 0;
2021-10-09 00:58:55 +02:00
virtual void proccessMenuNavigationY(Input *input, int32_t maxOptionValue) {
if (input->data.buttons_d & Input::BUTTON_UP) {
this->selectedOptionY--;
} else if (input->data.buttons_d & Input::BUTTON_DOWN) {
this->selectedOptionY++;
}
if (this->selectedOptionY < 0) {
this->selectedOptionY = maxOptionValue;
} else if (this->selectedOptionY >= maxOptionValue) {
this->selectedOptionY = 0;
}
}
virtual void proccessMenuNavigationX(Input *input, int32_t maxOptionValue) {
if (input->data.buttons_d & Input::BUTTON_LEFT) {
this->selectedOptionX--;
} else if (input->data.buttons_d & Input::BUTTON_RIGHT) {
this->selectedOptionX++;
}
if (this->selectedOptionX < 0) {
this->selectedOptionX = maxOptionValue;
} else if (this->selectedOptionX >= maxOptionValue) {
this->selectedOptionX = 0;
}
}
2021-10-09 00:58:55 +02:00
virtual bool entrySelected(Input *input) {
return input->data.buttons_d & Input::BUTTON_A;
}
2021-10-09 00:58:55 +02:00
virtual void printHeader() {
WiiUScreen::drawLine("Wudump");
WiiUScreen::drawLine("==================");
WiiUScreen::drawLine("");
}
2021-10-09 00:58:55 +02:00
virtual void printFooter() {
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_TV, 0, 27, "By Maschell");
ScreenUtils::printTextOnScreen(CONSOLE_SCREEN_DRC, 0, 17, "By Maschell");
}
2021-10-09 00:58:55 +02:00
int selectedOptionY = 0;
int selectedOptionX = 0;
2021-10-09 00:58:55 +02:00
};