Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
menu_strats.c
Go to the documentation of this file.
1#include "battle/battle.h"
2#include "hud_element.h"
3
4#define MENU_CAPACITY 6
5#define MENU_LINE_HEIGHT 13
6#define MENU_MAX_VISIBLE 6
7
8enum {
9 BTL_SUBMENU_STATE_CANCEL = -2, // selection is canceled
10 BTL_SUBMENU_STATE_SELECT = -1, // a result is selected
11 BTL_SUBMENU_STATE_INIT = 0, // build and initialize the menu
12 BTL_SUBMENU_STATE_CHOOSING = 1, // selecting an option
20};
21
25
29
32
34BSS s32 StratsPrevSelected; // index of previously selected option, set by caller before initializing the menu
35
44
53
57
60
61void btl_menu_strats_draw_content(void* data, s32 x, s32 y);
62void btl_menu_strats_show_title(void* data, s32 x, s32 y);
63void btl_menu_strats_show_desc(void* data, s32 x, s32 y);
64void btl_menu_strats_show_error(void* data, s32 x, s32 y);
65
101
105
121
122// show submenu after a popup was canceled (Change Partner).
123// restores colors/hand pointer and returns directly to CHOOSE
143
144// show submenu after it was hidden (eg, after handing control to select target)
145// sets state to RESTORE; next update shows windows and returns to CHOOSE
165
166// reopen submenu in a locked/selected state
167// sets state to LOCK; next update switches to SELECT (grayed out and non-interactive)
168// use this when the menu should be visibile, but in the background of another menu
175
179 s32 x, y;
180 s32 width;
181 s32 msgID;
182 s32 i;
183
184 switch (StratsMenuState) {
188 StratsMenuPosX = 20;
189 StratsMenuPosY = 68;
190
191 for (i = 0; i < StratsOptionCount; i++) {
195 }
196
200
204
208
210 x = StratsMenuPosX;
211 y = StratsMenuPosY;
214 x = 20;
215 y = 186;
223 if (!ShowingErrorMessage) {
225
226 // only wrap selection on stick press, not when held
227 if (battleStatus->curButtonsHeld & BUTTON_STICK_UP) {
228 if (StratsCursorPos > 0) {
230 } else if (battleStatus->curButtonsPressed & BUTTON_STICK_UP) {
232 }
233 }
234
235 if (battleStatus->curButtonsHeld & BUTTON_STICK_DOWN) {
238 } else if (battleStatus->curButtonsPressed & BUTTON_STICK_DOWN) {
240 }
241 }
242
243 // wrap the selected index
244 if (StratsCursorPos < 0) {
246 }
248 StratsCursorPos = 0;
249 }
250
254 }
255
258 }
261 }
265 }
266
267 if (battleStatus->curButtonsPressed & BUTTON_A) {
271 } else {
275 }
276 } else if (battleStatus->curButtonsPressed & BUTTON_B) {
280 }
281 }
284 for (i = 0; i < StratsOptionCount; i++) {
285 hud_element_set_tint(StratsOptionHIDs[i], 160, 160, 160);
286 }
295 return StratsCursorPos + 1;
297 return POPUP_RESULT_CANCEL;
303 return StratsCursorPos + 1;
305 return StratsCursorPos + 1;
311 return StratsCursorPos + 1;
325 switch (StratsErrorCode) {
326 case 0:
328 break;
329 case 1:
331 break;
332 default:
334 break;
335 }
336 width = get_msg_width(msgID, 0) + 23;
337 set_window_properties(WIN_BTL_POPUP, (SCREEN_WIDTH / 2) - (width / 2), 80, width, 28, 20, btl_menu_strats_show_error, NULL, -1);
339 StratsErrorTimer = 60;
345 }
346 if (StratsErrorTimer != 0) {
349 }
356 }
358}
359
360void btl_menu_strats_draw_content(void* data, s32 x, s32 y) {
361 s32 target, cur, delta;
362 s32 x1, x2, y1, y2;
363 s32 xPos, yPos;
364 s32 hid;
365 s32 i;
366
367 switch (StratsMenuState) {
375 // simple midpoint easing, move half the distance each frame
378 delta = (target - cur) * 0.5;
379 StratsScrollOffset = (delta != 0) ? cur + delta : target;
380
381 x1 = x + 4;
382 x2 = x + 142;
383 y1 = y + 18;
384 y2 = y + 19 + (StratsMenuLines * MENU_LINE_HEIGHT);
386
387 // draw option messages
388 xPos = x + 33;
389 yPos = y + 19 + StratsScrollOffset;
390 #if VERSION_IQUE
391 yPos -= 3;
392 #endif
393
394 for (i = 0; i < StratsOptionCount; i++) {
395 s32 palette = StratsTextColor;
396
398 palette = MSG_PAL_37;
399 }
400 if (!StratsOptionEnabled[i]) {
401 palette = MSG_PAL_0B;
402 }
405 }
406
407 // draw option icons
408 xPos = x + 24;
409 yPos = y + 24 + StratsScrollOffset;
410
411 for (i = 0; i < StratsOptionCount; i++) {
417 }
418
419 // instant snap to target, no easing
422 delta = (target - cur) * 1.0;
423 StratsCursorOffset = (delta != 0) ? cur + delta : target;
424
425 // draw the cursor
426 xPos = x + 10;
427 yPos = y + 26 + StratsCursorOffset;
428
433
434 // draw nav arrows
435 if (StratsVisibleStart > 0) {
437 hud_element_set_render_pos(hid, x + 67, y + 16);
440 }
443 hud_element_set_render_pos(hid, x + 67, y + 100);
446 }
447 break;
448 }
449}
450
454
468
469void btl_menu_strats_show_error(void* data, s32 x, s32 y) {
470 s32 msgID;
471
472 x += 11;
473 y += 6;
474
475 switch (StratsErrorCode) {
476 case 0:
478 break;
479 case 1:
481 break;
482 default:
484 break;
485 }
486 draw_msg(msgID, x, y, 255, MSG_PAL_0F, 0);
487}
BSS s32 PopupMenu_SelectedIndex
u32 pressedButtons[4]
s32 HudElemID
s32 b32
#define get_msg_width
#define draw_msg
@ DRAW_MSG_STYLE_MENU
Definition enums.h:4970
@ BUTTON_A
Definition enums.h:2776
@ BUTTON_STICK_UP
Definition enums.h:2777
@ BUTTON_STICK_DOWN
Definition enums.h:2778
@ BUTTON_B
Definition enums.h:2775
@ WINDOW_PRIORITY_20
Definition enums.h:3220
@ MSG_PAL_37
Definition enums.h:5045
@ MSG_PAL_0F
Definition enums.h:5005
@ MSG_PAL_0D
Definition enums.h:5003
@ MSG_PAL_STANDARD
Definition enums.h:5000
@ MSG_PAL_0B
Definition enums.h:5001
@ MSG_PAL_33
Definition enums.h:5041
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ WINDOW_UPDATE_TRANSPARENT
Definition enums.h:4900
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ WINDOW_UPDATE_DARKENED
Definition enums.h:4899
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:3831
@ POPUP_RESULT_CANCEL
Definition enums.h:3212
@ POPUP_RESULT_CHOOSING
Definition enums.h:3211
@ POPUP_RESULT_INVALID
Definition enums.h:3209
@ ABILITY_QUICK_CHANGE
Definition enums.h:462
@ SOUND_MENU_BACK
Definition enums.h:704
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:701
@ SOUND_MENU_NEXT
Definition enums.h:703
@ SOUND_MENU_ERROR
Definition enums.h:936
@ WIN_BTL_STRATS_MENU
Definition enums.h:4832
@ WIN_BTL_POPUP
Definition enums.h:4835
@ WIN_BTL_STRATS_TITLE
Definition enums.h:4833
@ WIN_BTL_DESC_BOX
Definition enums.h:4834
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void *drawContents, void *drawContentsArg, s8 parent)
Definition windows.c:373
HudScript HES_AnimatedHandPointer
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_draw_without_clipping(s32 id)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_draw_clipped(s32 id)
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_DROP_SHADOW
Definition hud_element.h:97
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:86
s32 HudScript[]
Definition hud_element.h:9
BSS s32 StratsOptionMessage[6]
Definition menu_strats.c:41
BSS s16 StratsMenuPosY
Definition menu_strats.c:31
BSS s16 StratsErrorCode
Definition menu_strats.c:55
BSS HudElemID HID_StratsArrowDown
Definition menu_strats.c:27
HudScript HES_HandPointer
BSS HudScript * StratsOptionHudScripts[6]
Definition menu_strats.c:36
BSS s8 StratsMenuLines
Definition menu_strats.c:49
void btl_menu_strats_show_title(void *data, s32 x, s32 y)
BSS s8 ShowingErrorMessage
Definition menu_strats.c:54
BSS s32 StratsOptionHIDs[6]
Definition menu_strats.c:37
void btl_submenu_strats_restore_choose(void)
BSS s32 StratsOptionMenuTypes[6]
Definition menu_strats.c:39
void btl_menu_strats_show_desc(void *data, s32 x, s32 y)
HudScript HES_GreenArrowDown
BSS s32 StratsOptionCount
Definition menu_strats.c:43
BSS s8 StratsDescVisible
Definition menu_strats.c:50
BSS s8 StratsVisibleStart
Definition menu_strats.c:47
@ BTL_SUBMENU_STATE_RESTORE
Definition menu_strats.c:15
@ BTL_SUBMENU_STATE_LOCK
Definition menu_strats.c:16
@ BTL_SUBMENU_STATE_HIDE_HOLD
Definition menu_strats.c:14
@ BTL_SUBMENU_STATE_CANCEL
Definition menu_strats.c:9
@ BTL_SUBMENU_STATE_SELECT
Definition menu_strats.c:10
@ BTL_SUBMENU_STATE_ERROR_DONE
Definition menu_strats.c:19
@ BTL_SUBMENU_STATE_HIDE_INIT
Definition menu_strats.c:13
@ BTL_SUBMENU_STATE_ERROR_SHOW
Definition menu_strats.c:18
@ BTL_SUBMENU_STATE_CHOOSING
Definition menu_strats.c:12
@ BTL_SUBMENU_STATE_INIT
Definition menu_strats.c:11
@ BTL_SUBMENU_STATE_ERROR_INIT
Definition menu_strats.c:17
#define MENU_LINE_HEIGHT
Definition menu_strats.c:5
BSS s8 StratsCursorPos
Definition menu_strats.c:45
BSS s8 StratsVisibleEnd
Definition menu_strats.c:48
BSS HudElemID HID_StratsArrowUp
Definition menu_strats.c:26
BSS HudElemID HID_StratsCursor
Definition menu_strats.c:28
HudScript HES_GreenArrowUp
BSS s16 StratsMenuPosX
Definition menu_strats.c:30
BSS s16 StratsScrollOffset
Definition menu_strats.c:51
void btl_submenu_strats_restore_locked(void)
BSS b32 StratsOptionEnabled[6]
Definition menu_strats.c:40
void btl_menu_strats_draw_content(void *data, s32 x, s32 y)
BSS s8 StratsTextColor
Definition menu_strats.c:58
#define MENU_CAPACITY
Definition menu_strats.c:4
void btl_submenu_strats_hide(void)
void btl_submenu_strats_destroy(void)
BSS s16 StratsErrorTimer
Definition menu_strats.c:56
BSS s8 StratsPrevCursorPos
Definition menu_strats.c:46
BSS s32 StratsTextAlpha
Definition menu_strats.c:59
BSS s16 StratsCursorOffset
Definition menu_strats.c:52
void btl_menu_strats_show_error(void *data, s32 x, s32 y)
void btl_menu_strats_init(void)
Definition menu_strats.c:66
BSS s8 StratsMenuState
Definition menu_strats.c:33
s32 btl_submenu_strats_update(void)
BSS s32 StratsOptionNames[6]
Definition menu_strats.c:38
#define MENU_MAX_VISIBLE
Definition menu_strats.c:6
BSS s32 StratsPrevSelected
Definition menu_strats.c:34
BSS s32 StratsOptionError[6]
Definition menu_strats.c:42
void btl_submenu_strats_resume_choose(void)
void sfx_play_sound(s32 soundID)
#define SCREEN_WIDTH
Definition macros.h:109
#define BSS
Definition macros.h:7
GameStatus * gGameStatusPtr
Definition main_loop.c:31
Gfx * gMainGfxPos
Definition cam_main.c:14
BattleStatus gBattleStatus
Definition battle.cpp:14