Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
menu_strats.c File Reference

Go to the source code of this file.

Macros

#define MENU_CAPACITY   6
 
#define MENU_LINE_HEIGHT   13
 
#define MENU_MAX_VISIBLE   6
 

Enumerations

enum  {
  BTL_SUBMENU_STATE_CANCEL = -2 , BTL_SUBMENU_STATE_SELECT = -1 , BTL_SUBMENU_STATE_INIT = 0 , BTL_SUBMENU_STATE_CHOOSING = 1 ,
  BTL_SUBMENU_STATE_HIDE_INIT = 10 , BTL_SUBMENU_STATE_HIDE_HOLD = 11 , BTL_SUBMENU_STATE_RESTORE = 20 , BTL_SUBMENU_STATE_LOCK = 30 ,
  BTL_SUBMENU_STATE_ERROR_INIT = 40 , BTL_SUBMENU_STATE_ERROR_SHOW = 41 , BTL_SUBMENU_STATE_ERROR_DONE = 42
}
 

Functions

void btl_menu_strats_draw_content (void *data, s32 x, s32 y)
 
void btl_menu_strats_show_title (void *data, s32 x, s32 y)
 
void btl_menu_strats_show_desc (void *data, s32 x, s32 y)
 
void btl_menu_strats_show_error (void *data, s32 x, s32 y)
 
void btl_menu_strats_init (void)
 
void btl_submenu_strats_hide (void)
 
void btl_submenu_strats_destroy (void)
 
void btl_submenu_strats_resume_choose (void)
 
void btl_submenu_strats_restore_choose (void)
 
void btl_submenu_strats_restore_locked (void)
 
s32 btl_submenu_strats_update (void)
 

Variables

HudScript HES_GreenArrowDown
 
HudScript HES_GreenArrowUp
 
HudScript HES_HandPointer
 
BSS HudElemID HID_StratsArrowUp
 
BSS HudElemID HID_StratsArrowDown
 
BSS HudElemID HID_StratsCursor
 
BSS s16 StratsMenuPosX
 
BSS s16 StratsMenuPosY
 
BSS s8 StratsMenuState
 
BSS s32 StratsPrevSelected
 
BSS HudScriptStratsOptionHudScripts [6]
 
BSS s32 StratsOptionHIDs [6]
 
BSS s32 StratsOptionNames [6]
 
BSS s32 StratsOptionMenuTypes [6]
 
BSS b32 StratsOptionEnabled [6]
 
BSS s32 StratsOptionMessage [6]
 
BSS s32 StratsOptionError [6]
 
BSS s32 StratsOptionCount
 
BSS s8 StratsCursorPos
 
BSS s8 StratsPrevCursorPos
 
BSS s8 StratsVisibleStart
 
BSS s8 StratsVisibleEnd
 
BSS s8 StratsMenuLines
 
BSS s8 StratsDescVisible
 
BSS s16 StratsScrollOffset
 
BSS s16 StratsCursorOffset
 
BSS s8 ShowingErrorMessage
 
BSS s16 StratsErrorCode
 
BSS s16 StratsErrorTimer
 
BSS s8 StratsTextColor
 
BSS s32 StratsTextAlpha
 

Macro Definition Documentation

◆ MENU_CAPACITY

#define MENU_CAPACITY   6

Definition at line 4 of file menu_strats.c.

◆ MENU_LINE_HEIGHT

#define MENU_LINE_HEIGHT   13

◆ MENU_MAX_VISIBLE

#define MENU_MAX_VISIBLE   6

Definition at line 6 of file menu_strats.c.

Referenced by btl_menu_strats_init(), and btl_submenu_strats_update().

Enumeration Type Documentation

◆ anonymous enum

Enumerator
BTL_SUBMENU_STATE_CANCEL 
BTL_SUBMENU_STATE_SELECT 
BTL_SUBMENU_STATE_INIT 
BTL_SUBMENU_STATE_CHOOSING 
BTL_SUBMENU_STATE_HIDE_INIT 
BTL_SUBMENU_STATE_HIDE_HOLD 
BTL_SUBMENU_STATE_RESTORE 
BTL_SUBMENU_STATE_LOCK 
BTL_SUBMENU_STATE_ERROR_INIT 
BTL_SUBMENU_STATE_ERROR_SHOW 
BTL_SUBMENU_STATE_ERROR_DONE 

Definition at line 8 of file menu_strats.c.

8 {
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};
@ 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

Function Documentation

◆ btl_menu_strats_draw_content()

void btl_menu_strats_draw_content ( void * data,
s32 x,
s32 y )

Definition at line 360 of file menu_strats.c.

360 {
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}
BSS s32 PopupMenu_SelectedIndex
#define draw_msg
@ DRAW_MSG_STYLE_MENU
Definition enums.h:4970
@ MSG_PAL_37
Definition enums.h:5045
@ MSG_PAL_0B
Definition enums.h:5001
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:3831
@ ABILITY_QUICK_CHANGE
Definition enums.h:462
s32 is_ability_active(s32 arg0)
Definition inventory.c:1735
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_draw_without_clipping(s32 id)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
void hud_element_draw_clipped(s32 id)
BSS HudElemID HID_StratsArrowDown
Definition menu_strats.c:27
BSS s8 StratsMenuLines
Definition menu_strats.c:49
BSS s32 StratsOptionHIDs[6]
Definition menu_strats.c:37
BSS s32 StratsOptionMenuTypes[6]
Definition menu_strats.c:39
BSS s32 StratsOptionCount
Definition menu_strats.c:43
BSS s8 StratsVisibleStart
Definition menu_strats.c:47
#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
BSS s16 StratsScrollOffset
Definition menu_strats.c:51
BSS b32 StratsOptionEnabled[6]
Definition menu_strats.c:40
BSS s8 StratsTextColor
Definition menu_strats.c:58
BSS s32 StratsTextAlpha
Definition menu_strats.c:59
BSS s16 StratsCursorOffset
Definition menu_strats.c:52
BSS s8 StratsMenuState
Definition menu_strats.c:33
BSS s32 StratsOptionNames[6]
Definition menu_strats.c:38
Gfx * gMainGfxPos
Definition cam_main.c:14

Referenced by btl_submenu_strats_update().

◆ btl_menu_strats_show_title()

void btl_menu_strats_show_title ( void * data,
s32 x,
s32 y )

Definition at line 451 of file menu_strats.c.

451 {
453}
@ MSG_PAL_33
Definition enums.h:5041

Referenced by btl_submenu_strats_update().

◆ btl_menu_strats_show_desc()

void btl_menu_strats_show_desc ( void * data,
s32 x,
s32 y )

Definition at line 455 of file menu_strats.c.

455 {
456 switch (StratsMenuState) {
462 if (StratsDescVisible) {
464 }
465 break;
466 }
467}
BSS s32 StratsOptionMessage[6]
Definition menu_strats.c:41
BSS s8 StratsDescVisible
Definition menu_strats.c:50

Referenced by btl_submenu_strats_update().

◆ btl_menu_strats_show_error()

void btl_menu_strats_show_error ( void * data,
s32 x,
s32 y )

Definition at line 469 of file menu_strats.c.

469 {
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}
@ MSG_PAL_0F
Definition enums.h:5005
BSS s16 StratsErrorCode
Definition menu_strats.c:55

Referenced by btl_submenu_strats_update().

◆ btl_menu_strats_init()

◆ btl_submenu_strats_hide()

void btl_submenu_strats_hide ( void )

◆ btl_submenu_strats_destroy()

void btl_submenu_strats_destroy ( void )

Definition at line 106 of file menu_strats.c.

106 {
107 s32 i;
108
112
113 for (i = 0; i < StratsOptionCount; i++) {
115 }
116
120}
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ WIN_BTL_STRATS_MENU
Definition enums.h:4832
@ WIN_BTL_STRATS_TITLE
Definition enums.h:4833
@ WIN_BTL_DESC_BOX
Definition enums.h:4834
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void hud_element_free(s32 id)

Referenced by btl_state_update_partner_menu(), btl_state_update_player_menu(), and btl_submenu_strats_update().

◆ btl_submenu_strats_resume_choose()

void btl_submenu_strats_resume_choose ( void )

Definition at line 124 of file menu_strats.c.

124 {
125 s32 i;
126
127 for (i = 0; i < StratsOptionCount; i++) {
128 hud_element_set_tint(StratsOptionHIDs[i], 255, 255, 255);
129 }
130
139 StratsTextAlpha = 255;
142}
@ MSG_PAL_STANDARD
Definition enums.h:5000
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ WINDOW_UPDATE_TRANSPARENT
Definition enums.h:4900
HudScript HES_AnimatedHandPointer
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b)

Referenced by btl_state_update_partner_menu(), and btl_state_update_player_menu().

◆ btl_submenu_strats_restore_choose()

◆ btl_submenu_strats_restore_locked()

◆ btl_submenu_strats_update()

s32 btl_submenu_strats_update ( void )

Definition at line 176 of file menu_strats.c.

176 {
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}
u32 pressedButtons[4]
s32 HudElemID
#define get_msg_width
@ 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_0D
Definition enums.h:5003
@ WINDOW_UPDATE_DARKENED
Definition enums.h:4899
@ POPUP_RESULT_CANCEL
Definition enums.h:3212
@ POPUP_RESULT_CHOOSING
Definition enums.h:3211
@ POPUP_RESULT_INVALID
Definition enums.h:3209
@ 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_POPUP
Definition enums.h:4835
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
void hud_element_set_scale(s32 index, f32 scale)
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.
@ 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
BSS s16 StratsMenuPosY
Definition menu_strats.c:31
HudScript HES_HandPointer
BSS HudScript * StratsOptionHudScripts[6]
Definition menu_strats.c:36
void btl_menu_strats_show_title(void *data, s32 x, s32 y)
void btl_menu_strats_show_desc(void *data, s32 x, s32 y)
HudScript HES_GreenArrowDown
HudScript HES_GreenArrowUp
BSS s16 StratsMenuPosX
Definition menu_strats.c:30
void btl_menu_strats_draw_content(void *data, s32 x, s32 y)
void btl_submenu_strats_destroy(void)
BSS s16 StratsErrorTimer
Definition menu_strats.c:56
void btl_menu_strats_show_error(void *data, s32 x, s32 y)
BSS s32 StratsOptionError[6]
Definition menu_strats.c:42
void sfx_play_sound(s32 soundID)
#define SCREEN_WIDTH
Definition macros.h:109
GameStatus * gGameStatusPtr
Definition main_loop.c:31
BattleStatus gBattleStatus
Definition battle.cpp:14

Referenced by btl_state_update_partner_menu(), and btl_state_update_player_menu().

Variable Documentation

◆ HES_GreenArrowDown

HudScript HES_GreenArrowDown
extern

Definition at line 1866 of file global_hud_scripts.c.

1866 {
1868 hs_SetCustomSize(16, 8)
1869 hs_Loop
1875 hs_End
1876};
#define hs_SetCustomSize(arg0, arg1)
#define hs_SetVisible
#define hs_End
@ HUD_ELEMENT_FLAG_INVISIBLE
Definition hud_element.h:92
#define hs_Restart
#define hs_Loop
#define hs_SetCI(time, name)
#define hs_ClearFlags(arg0)
#define hs_SetFlags(arg0)

Referenced by btl_submenu_strats_update().

◆ HES_GreenArrowUp

HudScript HES_GreenArrowUp
extern

◆ HES_HandPointer

HudScript HES_HandPointer
extern

Definition at line 727 of file global_hud_scripts.c.

Referenced by btl_submenu_strats_update().

◆ HID_StratsArrowUp

◆ HID_StratsArrowDown

◆ HID_StratsCursor

◆ StratsMenuPosX

BSS s16 StratsMenuPosX

Definition at line 30 of file menu_strats.c.

Referenced by btl_submenu_strats_update().

◆ StratsMenuPosY

BSS s16 StratsMenuPosY

Definition at line 31 of file menu_strats.c.

Referenced by btl_submenu_strats_update().

◆ StratsMenuState

◆ StratsPrevSelected

BSS s32 StratsPrevSelected

◆ StratsOptionHudScripts

BSS HudScript* StratsOptionHudScripts[6]

◆ StratsOptionHIDs

◆ StratsOptionNames

BSS s32 StratsOptionNames[6]

◆ StratsOptionMenuTypes

BSS s32 StratsOptionMenuTypes[6]

◆ StratsOptionEnabled

◆ StratsOptionMessage

BSS s32 StratsOptionMessage[6]

◆ StratsOptionError

BSS s32 StratsOptionError[6]

◆ StratsOptionCount

◆ StratsCursorPos

◆ StratsPrevCursorPos

BSS s8 StratsPrevCursorPos

Definition at line 46 of file menu_strats.c.

Referenced by btl_menu_strats_init(), and btl_submenu_strats_update().

◆ StratsVisibleStart

BSS s8 StratsVisibleStart

◆ StratsVisibleEnd

BSS s8 StratsVisibleEnd

◆ StratsMenuLines

BSS s8 StratsMenuLines

◆ StratsDescVisible

◆ StratsScrollOffset

BSS s16 StratsScrollOffset

◆ StratsCursorOffset

BSS s16 StratsCursorOffset

◆ ShowingErrorMessage

◆ StratsErrorCode

BSS s16 StratsErrorCode

Definition at line 55 of file menu_strats.c.

Referenced by btl_menu_strats_show_error(), and btl_submenu_strats_update().

◆ StratsErrorTimer

BSS s16 StratsErrorTimer

Definition at line 56 of file menu_strats.c.

Referenced by btl_submenu_strats_update().

◆ StratsTextColor

◆ StratsTextAlpha