persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
UIMenu.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <etl/span.h>
4
#include <etl/stack.h>
5
#include <maxmod9.h>
6
#include <nds.h>
7
#include <string>
8
9
#include "
components/TextComponent.hpp
"
10
#include "
types/UITypes.hpp
"
11
#include "
uiAnimation/UIAnimator.hpp
"
12
13
using
MenuOptionFunc
=
ViewState
(
UIMenu
::*)();
14
15
template
<
typename
Method>
constexpr
MenuOptionFunc
menuBind
(Method method)
16
{
17
return
static_cast<
MenuOptionFunc
>
(method);
18
}
19
20
class
UIMenu
21
{
22
protected
:
23
std::string
pauseMessage
=
"Pause"
;
24
bool
isActive
=
false
;
25
TextComponent
*
text
=
nullptr
;
26
27
// options
28
etl::span<MenuOption>
options
;
29
int
selectedOption
= 0;
30
int
startIndex
= 0;
31
38
ViewState
changeMenu
(etl::span<MenuOption> newOptions);
39
40
private
:
41
friend
class
UISystem
;
42
43
// options
45
int
visibleOptions
= 0;
46
const
bool
customRender
;
47
etl::stack<MenuState, 5>
prevOptions
;
48
ViewState
nextViewState
=
ViewState::KEEP_CURRENT
;
49
int
selectionX
= 0;
50
UIAnimator
animator
;
51
52
void
animateSelection
();
53
59
virtual
void
prevOption
();
60
64
virtual
void
resetHook
() = 0;
65
69
virtual
void
closeHook
() = 0;
70
71
public
:
77
UIMenu
(
bool
iCustomRender =
false
) :
customRender
(iCustomRender)
78
{
79
}
80
84
virtual
void
resetMenu
();
85
91
virtual
ViewState
updateHook
();
92
93
void
updateAnimation
();
94
int
selectionOffset
()
const
;
95
101
int
getSelectedOption
()
const
102
{
103
return
selectedOption
;
104
}
105
111
int
getStartIndex
()
const
112
{
113
return
startIndex
;
114
}
115
121
etl::span<MenuOption>
getOptions
()
const
122
{
123
return
options
;
124
}
125
131
void
setVisibleOptions
(
int
count)
132
{
133
visibleOptions
= count;
134
}
135
};
ViewState
ViewState
Definition
StateTypes.hpp:4
ViewState::KEEP_CURRENT
@ KEEP_CURRENT
Definition
StateTypes.hpp:6
TextComponent.hpp
Orchestrates rendering text from a bitmap.
UIAnimator.hpp
Runs a fixed-capacity set of concurrent UI animations.
MenuOptionFunc
ViewState(UIMenu::*)() MenuOptionFunc
Definition
UIMenu.hpp:13
menuBind
constexpr MenuOptionFunc menuBind(Method method)
Definition
UIMenu.hpp:15
UITypes.hpp
TextComponent
Definition
TextComponent.hpp:19
UIAnimator
Owns and ticks active UI animations. Safe against cancel-during-tick.
Definition
UIAnimator.hpp:25
UIMenu
Definition
UIMenu.hpp:21
UIMenu::animateSelection
void animateSelection()
Definition
UIMenu.cpp:41
UIMenu::options
etl::span< MenuOption > options
Definition
UIMenu.hpp:28
UIMenu::prevOptions
etl::stack< MenuState, 5 > prevOptions
Definition
UIMenu.hpp:47
UIMenu::visibleOptions
int visibleOptions
Definition
UIMenu.hpp:45
UIMenu::prevOption
virtual void prevOption()
Changes the current options to the previous options.
Definition
UIMenu.cpp:70
UIMenu::setVisibleOptions
void setVisibleOptions(int count)
Sets the visible option count of a custom render menu, as UISystem only sets it for the menus it draw...
Definition
UIMenu.hpp:131
UIMenu::selectionOffset
int selectionOffset() const
Definition
UIMenu.cpp:36
UIMenu::UISystem
friend class UISystem
Definition
UIMenu.hpp:41
UIMenu::text
TextComponent * text
Definition
UIMenu.hpp:25
UIMenu::updateHook
virtual ViewState updateHook()
Optional hook to call during the update loop.
Definition
UIMenu.cpp:89
UIMenu::animator
UIAnimator animator
Definition
UIMenu.hpp:50
UIMenu::updateAnimation
void updateAnimation()
Definition
UIMenu.cpp:30
UIMenu::resetMenu
virtual void resetMenu()
Resets the menu to its initial state.
Definition
UIMenu.cpp:7
UIMenu::resetHook
virtual void resetHook()=0
Used to set the default pauseMessage and options values.
UIMenu::changeMenu
ViewState changeMenu(etl::span< MenuOption > newOptions)
Changes the active menu.
Definition
UIMenu.cpp:48
UIMenu::isActive
bool isActive
Definition
UIMenu.hpp:24
UIMenu::customRender
const bool customRender
Definition
UIMenu.hpp:46
UIMenu::getSelectedOption
int getSelectedOption() const
Gets the index of the selected option.
Definition
UIMenu.hpp:101
UIMenu::selectedOption
int selectedOption
Definition
UIMenu.hpp:29
UIMenu::nextViewState
ViewState nextViewState
Definition
UIMenu.hpp:48
UIMenu::UIMenu
UIMenu(bool iCustomRender=false)
Construct a new UIMenu.
Definition
UIMenu.hpp:77
UIMenu::getOptions
etl::span< MenuOption > getOptions() const
Gets the options of the active menu.
Definition
UIMenu.hpp:121
UIMenu::startIndex
int startIndex
Definition
UIMenu.hpp:30
UIMenu::getStartIndex
int getStartIndex() const
Gets the index of the first visible option.
Definition
UIMenu.hpp:111
UIMenu::closeHook
virtual void closeHook()=0
Execute logic after the root menu is exited.
UIMenu::pauseMessage
std::string pauseMessage
Definition
UIMenu.hpp:23
UIMenu::selectionX
int selectionX
Definition
UIMenu.hpp:49
source
components
menus
UIMenu.hpp
Generated by
1.15.0