Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
list_menu.inc.c
Go to the documentation of this file.
1/*
2 * The parts of a list menu (StageListMenu), up to eight options that each
3 * open a message: WSTAG210's guide (event 8), WSTAG924's on the starters'
4 * digivolutions and on raising (events 1602 and 1604) and WSTAG935's on card
5 * battles and cards (1616 and 1618). The stage defines MENU_TEXT, the menus'
6 * text file, before it includes this.
7 */
8
9/* Creates the menu's eight option lines, its hidden cursor and its message box */
10static inline void createListMenu(StageListMenu *task, StageListMenuChildren *children) {
11 s32 i;
12
13 task->nextState(task);
14 task->tweens[0].duration = 10;
15 task->tweens[1].duration = 10;
16 for (i = 0; i < 8; i++) {
17 children->options[i] = createTextWindow(FIELD_LAYER_MAP, 1, 0xBD, 0x21 + i * 14);
18 children->options[i]->setDepth(children->options[i], 1);
19 }
20 children->cursor = createCursor(FIELD_LAYER_MAP, 1, 0xAF, 0x21);
21 children->cursor->setVisible(children->cursor, 0);
22 children->message = createTextWindow(FIELD_LAYER_MAP, 1, 0x12, 0xB0);
23 children->message->setLines(children->message, 3);
24 task->count = 8;
25}
26
27/*
28 * Writes the options, lines 1 on of the menus' text entry n (each option's
29 * message is a line from 9 on), and shows the cursor
30 */
31static inline void showListMenuOptions(StageListMenu *task, StageListMenuChildren *children, s32 n) {
32 s32 i;
33
34 for (i = 0; i < task->count; i++) {
35 children->options[i]->setString(children->options[i], FILE_CACHE.getEntry(TEXT_ENTRY(MENU_TEXT, n)), i + 1);
36 }
37 children->cursor->setVisible(children->cursor, 1);
38}
39
40/* Moves the cursor up or down the list, held buttons repeating, without leaving it */
41static inline void moveListMenuCursor(StageListMenu *task) {
43 if (--task->cursor < 0) {
44 task->cursor = 0;
45 }
46 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
47 task->cursor++;
48 if (task->cursor > task->count - 1) {
49 task->cursor = task->count - 1;
50 }
51 }
52}
53
54/* Starts typing the message of the option under the cursor, from the menus' text entry n */
55static inline void openListMenuMessage(StageListMenu *task, StageListMenuChildren *children, s32 n) {
56 children->message->setString(children->message, FILE_CACHE.getEntry(TEXT_ENTRY(MENU_TEXT, n)), task->cursor + 9);
57 children->message->setTypeDelay(children->message, 6);
58}
59
60/*
61 * Pages through the option's message with X, the arrow blinking while a page
62 * waits for it, and moves on to the next substate once the message is done
63 */
64static inline void readListMenuMessage(StageListMenu *task, StageListMenuChildren *children) {
65 if (children->message->isFinished(children->message)) {
66 task->substate++;
67 } else if (children->message->isWaitingForButton(children->message)) {
70 task->showArrow = 0;
71 } else {
72 task->showArrow = 1;
73 }
74 } else if (PAD_PRESSED(PAD_CROSS)) {
75 children->message->showPage(children->message);
76 }
77}
78
79/* Hides the options and the cursor and starts closing the list's window */
80static inline void closeListMenu(StageListMenu *task, StageListMenuChildren *children) {
81 s32 i;
82
83 for (i = 0; i < task->count; i++) {
84 children->options[i]->setVisible(children->options[i], 0);
85 }
86 children->cursor->setVisible(children->cursor, 0);
87 stageFuncs.start(&task->tweens[0], 0);
88 task->substate++;
89}
signed int s32
Definition common.h:11
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
#define TEXT_ENTRY(file, n)
Definition stage.h:707
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
static void closeListMenu(StageListMenu *task, StageListMenuChildren *children)
Hides the options and the cursor and starts closing the list's window.
static void readListMenuMessage(StageListMenu *task, StageListMenuChildren *children)
Pages through the option's message with X, the arrow blinking while a page waits for it,...
static void moveListMenuCursor(StageListMenu *task)
Moves the cursor up or down the list, held buttons repeating, without leaving it.
static void showListMenuOptions(StageListMenu *task, StageListMenuChildren *children, s32 n)
Writes the options, lines 1 on of the menus' text entry n (each option's message is a line from 9 on)...
static void openListMenuMessage(StageListMenu *task, StageListMenuChildren *children, s32 n)
Starts typing the message of the option under the cursor, from the menus' text entry n.
static void createListMenu(StageListMenu *task, StageListMenuChildren *children)
Creates the menu's eight option lines, its hidden cursor and its message box.
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
Definition pad.h:140
#define PAD_UP
Definition pad.h:22
#define PAD_REPEATED(button)
Definition pad.h:141
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
void(* setVisible)()
(cursor, visible)
Definition text.h:33
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32 duration
Definition menu.h:19
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
TextWindow * message
Definition stage.h:688
TextWindow * options[8]
Definition stage.h:686
A list menu whose entries show a message.
Definition stage.h:675
PanelAnim tweens[2]
list, message box
Definition stage.h:682
void(* nextState)(struct StageListMenu *task)
Definition stage.h:676
s32 substate
Definition stage.h:676
s32 showArrow
Definition stage.h:679
s32(* isWaitingForButton)()
Definition text.h:188
s32(* isFinished)()
s32: callers don't truncate the result to a byte
Definition text.h:186
void(* setDepth)()
Definition text.h:183
void(* setTypeDelay)()
Definition text.h:172
void(* setLines)()
no prototype: callers would truncate u8 args
Definition text.h:184
void(* setString)()
Definition text.h:165
void(* showPage)()
Definition text.h:170
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
void(* stageFuncs[])(void)
The stage's functions (common/start_stage.inc.c calls the first): a StageFuncs in the stages with a t...
Definition wstag211.c:585
#define MENU_TEXT
The text file of the menus.
Definition wstag924.c:15