-
Notifications
You must be signed in to change notification settings - Fork 2
/
UI.h
executable file
·137 lines (122 loc) · 4.09 KB
/
UI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "lang.h"
#define UI_OFFSET_X 8
#define UI_OFFSET_Y 8
#define UI_FONT_WIDTH FNT_CHAR_WIDTH
#define UI_FONT_HEIGHT FNT_CHAR_HEIGHT
#define UI_TAB_STOPS FNT_TAB_STOPS
// In VSYNC ticks
#define UI_PAD_REPEAT_START_DELAY 20
#define UI_PAD_REPEAT_DELAY 5
enum MENU_ITEM {
MITEM_SEPERATOR,
MITEM_TAB,
MITEM_SPACE,
MITEM_BREAK,
MITEM_DASH,
MITEM_COLON,
MITEM_DOT,
MITEM_SLASH,
MITEM_PROGRESS,
MITEM_LABEL, // Last non-selectable item.
MITEM_STRING,
MITEM_VALUE,
MITEM_BUTTON,
MITEM_TOGGLE,
MITEM_ENUM,
MITEM_TERMINATOR,
MITEM_COUNT
};
enum MENU_ITEM_FORMAT {
MITEM_FORMAT_DEC = 0,
MITEM_FORMAT_UDEC,
MITEM_FORMAT_HEX,
MITEM_FORMAT_POINTER,
MITEM_FORMAT_FLOAT,
MITEM_FORMAT_COUNT
};
#define MITEM_FLAG_HIDDEN 0x01
#define MITEM_FLAG_READONLY 0x02
#define MITEM_FLAG_DISABLED 0x04
#define MITEM_FLAG_UNIT_PREFIX 0x08 // For formats with a unit prefix, show it.
#define MITEM_FLAG_POS_ABS 0x10 // Coordinates are absolute.
#define MITEM_FLAG_POS_MID 0x20 // Aligned to the middle. Only for buttons.
struct UIMenuItem
{
unsigned char type;
unsigned char id; // ID 0 is reserved for items that do not need to be tracked (i.e. labels).
unsigned char flags;
unsigned char format;
unsigned char width;
short int x;
short int y;
union
{ // Limits do not have to be specified, if the values are not going to be changeable by the user.
struct
{
int value;
int min, max;
} value;
struct
{
const char *buffer;
int maxlen;
} string;
struct
{
const int *labels;
int count;
int selectedIndex;
} enumeration;
struct
{
int id;
int TextWidth;
} label;
};
};
struct UIBtnHint
{
short int button;
short int label;
};
struct UIMenu
{
struct UIMenu *next, *prev;
struct UIMenuItem *items;
struct UIBtnHint hints[2];
};
enum UI_MENU_TRANSITION {
UIMT_LEFT_OUT,
UIMT_RIGHT_OUT,
UIMT_LEFT_IN,
UIMT_RIGHT_IN,
UIMT_FADE_IN,
UIMT_FADE_OUT,
};
const char *GetUIString(unsigned int id);
const char *GetUILabel(unsigned int id);
int InitializeUI(int BufferFont);
int ReinitializeUI(void);
void DeinitializeUI(void);
int ShowMessageBox(int Option1Label, int Option2Label, int Option3Label, int Option4Label, const char *message, int title);
void DisplayWarningMessage(unsigned int message);
void DisplayErrorMessage(unsigned int message);
void DisplayInfoMessage(unsigned int message);
int DisplayPromptMessage(unsigned int message, unsigned char Button1Label, unsigned char Button2Label);
void DisplayFlashStatusUpdate(unsigned int message);
struct UIMenuItem *UIGetItem(struct UIMenu *menu, unsigned char id);
void UISetVisible(struct UIMenu *menu, unsigned char id, int visible);
void UISetReadonly(struct UIMenu *menu, unsigned char id, int readonly);
void UISetEnabled(struct UIMenu *menu, unsigned char id, int enabled);
void UISetValue(struct UIMenu *menu, unsigned char id, int value);
int UIGetValue(struct UIMenu *menu, unsigned char id);
void UISetLabel(struct UIMenu *menu, unsigned char id, int label);
void UISetString(struct UIMenu *menu, unsigned char id, const char *string);
void UISetType(struct UIMenu *menu, unsigned char id, unsigned char type);
void UISetFormat(struct UIMenu *menu, unsigned char id, unsigned char format, unsigned char width);
void UISetEnum(struct UIMenu *menu, unsigned char id, const int *labels, int count);
void UISetEnumSelectedIndex(struct UIMenu *menu, unsigned char id, int selectedIndex);
int UIGetEnumSelectedIndex(struct UIMenu *menu, unsigned char id);
void UIDrawMenu(struct UIMenu *menu, unsigned short int frame, short int StartX, short int StartY, short int selection);
void UITransition(struct UIMenu *menu, int type, int SelectedOption);
int UIExecMenu(struct UIMenu *FirstMenu, short int SelectedItem, struct UIMenu **CurrentMenu, int (*callback)(struct UIMenu *menu, unsigned short int frame, int selection, u32 padstatus));