Skip to content

Commit

Permalink
filemenu state upstreams from dx (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a authored Oct 31, 2024
1 parent bf0741c commit b1ca4bd
Show file tree
Hide file tree
Showing 25 changed files with 595 additions and 620 deletions.
2 changes: 1 addition & 1 deletion include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ typedef struct MenuPanel {
/* 0x01 */ s8 col;
/* 0x02 */ s8 row;
/* 0x03 */ u8 selected; // usually set to the current value from gridData
/* 0x04 */ s8 page; // filemenu: 0 = select, 1 = delete, 3 = copy from, 4 = copy to, all else = save
/* 0x04 */ s8 state; // filemenu: 0 = select, 1 = delete, 3 = copy from, 4 = copy to, all else = save
/* 0x05 */ s8 numCols;
/* 0x06 */ s8 numRows;
/* 0x07 */ s8 numPages; // unsure
Expand Down
12 changes: 9 additions & 3 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -5369,14 +5369,14 @@ enum FileMenuMessages {
/* 31 */ FILE_MESSAGE_HAS_BEEN_CREATED, // has been created.[End]
#if VERSION_PAL
// TODO: determine where these new entries should be placed
UNK1,
UNK2,
FILE_MESSAGE_PAL_UNK1,
FILE_MESSAGE_PAL_UNK2,
#endif
/* 32 */ FILE_MESSAGE_ENTER_A_FILE_NAME, // Enter a file name![End]
/* 33 */ FILE_MESSAGE_QUESTION, // ?[End]
/* 34 */ FILE_MESSAGE_PERIOD_34, // .[End]
#if VERSION_PAL
FILE_MESSAGE_BASE_UNK,
FILE_MESSAGE_PAL_UNK3,
#endif
};

Expand Down Expand Up @@ -6033,6 +6033,12 @@ enum MsgChars {

MSG_CHAR_UNK_C3 = 0xC3,

MSG_CHAR_MENU_SPACE = 0xC6,
MSG_CHAR_MENU_USE_CHARSET_B = 0xC7,
MSG_CHAR_MENU_USE_CHARSET_A = 0xC8,
MSG_CHAR_MENU_BACK = 0xC9,
MSG_CHAR_MENU_END = 0xCA,

// special character codes used when reading from the source buffer
MSG_CHAR_READ_ENDL = 0xF0,
MSG_CHAR_READ_WAIT = 0xF1,
Expand Down
63 changes: 57 additions & 6 deletions include/filemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,65 @@
#include "common.h"
#include "filemenu.h"

#define CENTER_WINDOW_X(id) (((gWindows[id].parent != WIN_NONE) \
? (gWindows[gWindows[id].parent].width / 2) \
: (SCREEN_WIDTH / 2)) \
- (gWindows[id].width / 2))

#define CENTER_WINDOW_Y(id) (((gWindows[id].parent != WIN_NONE) \
? (gWindows[gWindows[id].parent].height / 2) \
: (SCREEN_HEIGHT / 2)) \
- (gWindows[id].height / 2))

enum {
FILE_MENU_MAIN = 0, // file selection
FILE_MENU_CONFIRM = 1, // confirmation prompt is open
FILE_MENU_MESSAGE = 2, // message is displayed, e.g. "File X has been deleted."
FILE_MENU_INPUT_NAME = 3, // "Enter a file name!" screen
FILE_MENU_SELECT_LANG = 4, // PAL only
};

enum {
PAGE_0,
PAGE_1,
// states for main menu
FM_MAIN_SELECT_FILE = 0, // choose which file to load
FM_MAIN_SELECT_DELETE, // choose which file to delete
#if !VERSION_PAL
FM_MAIN_SELECT_LANG_DUMMY, // non-PAL versions have an unimplemented dummy language select
#endif
FM_MAIN_SELECT_COPY_FROM,
FM_MAIN_SELECT_COPY_TO,
FM_MAIN_SELECT_LANG_PAL,

// states for confirm submenu
FM_CONFIRM_DELETE = 0,
#if !VERSION_PAL
PAGE_2,
FM_CONFIRM_DUMMY,
#endif
PAGE_3,
PAGE_4,
FM_CONFIRM_CREATE,
FM_CONFIRM_COPY, // unused
FM_CONFIRM_START,

// states for message submenu
FM_MESSAGE_DELETED = 0,
#if !VERSION_PAL
FM_MESSAGE_DUMMY,
#endif
FM_MESSAGE_COPIED,
FM_MESSAGE_CREATED,

// states for input submenu
FM_INPUT_CHARSET_A = 0,
FM_INPUT_CHARSET_B,
};

enum {
FM_MAIN_OPT_FILE_1,
FM_MAIN_OPT_FILE_2,
FM_MAIN_OPT_FILE_3,
FM_MAIN_OPT_FILE_4,
FM_MAIN_OPT_DELETE,
FM_MAIN_OPT_COPY,
FM_MAIN_OPT_CANCEL,
};

extern MenuPanel* filemenu_menus[];
Expand Down Expand Up @@ -44,7 +95,7 @@ extern u8 D_filemenu_8025095C[4];
f32* scaleX, f32* scaleY,\
f32* rotX, f32* rotY, f32* rotZ,\
s32* darkening,\
s32* opacity);\
s32* opacity)

WINDOW_UPDATE_FUNC(filemenu_update_show_name_input);
WINDOW_UPDATE_FUNC(filemenu_update_show_options_left);
Expand Down
4 changes: 2 additions & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ void pause_handle_input(s32 buttonsPressed, s32 buttonsHeld);
void pause_cleanup(void);

// file menu stuff
void filemenu_init(s32);
void filemenu_init(s32 mode);
void filemenu_cleanup(void);
void filemenu_update(void);
s32 func_80244BC4(void);
s32 filemenu_get_exit_mode(void);
void filemenu_set_selected(MenuPanel* menu, s32 col, s32 row);
void filemenu_set_cursor_alpha(s32 arg0);
void filemenu_set_cursor_goal_pos(s32 windowIndex, s32 posX, s32 posY);
Expand Down
2 changes: 1 addition & 1 deletion include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#define ITEM_MENU_PAGE(index) (&gPauseItemsPages[index])

#define MENU_PANEL_SELECTED_GRID_DATA(panel) \
(panel)->gridData[(panel)->page * (panel)->numCols * (panel)->numRows + \
(panel)->gridData[(panel)->state * (panel)->numCols * (panel)->numRows + \
(panel)->numCols * (panel)->row + \
(panel)->col]

Expand Down
36 changes: 18 additions & 18 deletions src/battle/btl_states_menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ BSS s32 D_802AD6D4;
void create_battle_popup_menu(PopupMenu* popup);

s32 get_player_anim_for_status(s32 animID);
void func_802A3C98(void* data, s32 x, s32 y);
void func_802A43DC(void* data, s32 x, s32 y);
void func_802A4448(void* data, s32 x, s32 y);
void func_802A4494(void* data, s32 x, s32 y);
void func_802A4534(void* data, s32 x, s32 y);
void btl_menu_moves_draw_content(void* data, s32 x, s32 y);
void btl_menu_moves_show_title(void* data, s32 x, s32 y);
void btl_menu_moves_show_icon(void* data, s32 x, s32 y);
void btl_menu_moves_show_desc(void* data, s32 x, s32 y);
void btl_menu_moves_show_error(void* data, s32 x, s32 y);
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);
Expand Down Expand Up @@ -1191,21 +1191,21 @@ s32 btl_submenu_moves_update(void) {
moveX = BattleMenu_Moves_PosX;
moveY = BattleMenu_Moves_PosY;
if (!BattleMenu_UsingSpiritsSubmenu) {
set_window_properties(1, moveX, moveY, 150, (D_802AD10E * 13) + 28, 0, func_802A3C98, NULL, -1);
set_window_properties(2, moveX + 16, moveY - 6, 90, 16, 1, func_802A43DC, NULL, -1);
set_window_properties(3, moveX + 114, moveY - 12, 32, 32, 1, func_802A4448, NULL, -1);
set_window_properties(WIN_BTL_MOVES_MENU, moveX, moveY, 150, (D_802AD10E * 13) + 28, 0, btl_menu_moves_draw_content, NULL, -1);
set_window_properties(WIN_BTL_MOVES_TITLE, moveX + 16, moveY - 6, 90, 16, 1, btl_menu_moves_show_title, NULL, -1);
set_window_properties(WIN_BTL_MOVES_ICON, moveX + 114, moveY - 12, 32, 32, 1, btl_menu_moves_show_icon, NULL, -1);
} else {
s16 new_var;

set_window_properties(1, moveX, moveY, 144, (D_802AD10E * 13) + 28, 0, func_802A3C98, NULL, -1);
set_window_properties(WIN_BTL_MOVES_MENU, moveX, moveY, 144, (D_802AD10E * 13) + 28, 0, btl_menu_moves_draw_content, NULL, -1);
new_var = moveY; // todo required to match
set_window_properties(4, moveX + 10, new_var - 6, 100, 16, 1, func_802A43DC, 0, -1);
set_window_properties(5, moveX + 110, new_var - 12, 32, 35, 1, func_802A4448, 0, -1);
set_window_properties(WIN_BTL_SPIRITS_TITLE, moveX + 10, new_var - 6, 100, 16, 1, btl_menu_moves_show_title, 0, -1);
set_window_properties(WIN_BTL_SPIRITS_ICON, moveX + 110, new_var - 12, 32, 35, 1, btl_menu_moves_show_icon, 0, -1);
}

moveX = 20;
moveY = BattleMenu_Moves_PosY;
set_window_properties(8, moveX, 186, 280, 32, WINDOW_PRIORITY_20, func_802A4494, NULL, -1);
set_window_properties(WIN_BTL_DESC_BOX, moveX, 186, 280, 32, WINDOW_PRIORITY_20, btl_menu_moves_show_desc, NULL, -1);
set_window_update(WIN_BTL_MOVES_MENU, WINDOW_UPDATE_SHOW);
if (!BattleMenu_UsingSpiritsSubmenu) {
set_window_update(WIN_BTL_MOVES_TITLE, WINDOW_UPDATE_SHOW);
Expand Down Expand Up @@ -1419,7 +1419,7 @@ s32 btl_submenu_moves_update(void) {

msgWidth = get_msg_width(msgID, 0) + 23;
moveX = (SCREEN_WIDTH / 2) - (msgWidth / 2);
set_window_properties(9, moveX, 80, msgWidth, D_802AB340[get_msg_lines(msgID) - 1], 20, func_802A4534, NULL, -1);
set_window_properties(WIN_BTL_POPUP, moveX, 80, msgWidth, D_802AB340[get_msg_lines(msgID) - 1], 20, btl_menu_moves_show_error, NULL, -1);
set_window_update(WIN_BTL_POPUP, WINDOW_UPDATE_SHOW);
D_802AD10B = 60;
battle_menu_moveState = BTL_SUBMENU_MOVES_STATE_UNK_2A;
Expand Down Expand Up @@ -1458,7 +1458,7 @@ s32 btl_submenu_moves_update(void) {
#define X_VAR2 93
#endif

void func_802A3C98(void* data, s32 x, s32 y) {
void btl_menu_moves_draw_content(void* data, s32 x, s32 y) {
s32 var_t0;
s32 temp_f6;
s32 xPos, yPos;
Expand Down Expand Up @@ -1662,7 +1662,7 @@ void func_802A3C98(void* data, s32 x, s32 y) {
}
}

void func_802A43DC(void* data, s32 x, s32 y) {
void btl_menu_moves_show_title(void* data, s32 x, s32 y) {
s32 msgID;
s32 posX;
s32 posY;
Expand All @@ -1685,15 +1685,15 @@ void func_802A43DC(void* data, s32 x, s32 y) {
draw_msg(msgID, posX, posY, opacity, palette, DRAW_MSG_STYLE_MENU);
}

void func_802A4448(void* data, s32 x, s32 y) {
void btl_menu_moves_show_icon(void* data, s32 x, s32 y) {
s32 icon = BattleMenu_Moves_TitleID;

hud_element_set_render_pos(icon, x + 16, y + 15);
hud_element_set_alpha(icon, BattleMenu_Moves_TextAlpha);
hud_element_draw_clipped(icon);
}

void func_802A4494(void* data, s32 x, s32 y) {
void btl_menu_moves_show_desc(void* data, s32 x, s32 y) {
switch (battle_menu_moveState) {
case BTL_SUBMENU_MOVES_STATE_UNK_NEGATIVE_ONE:
case BTL_SUBMENU_MOVES_STATE_UNK_1:
Expand All @@ -1708,7 +1708,7 @@ void func_802A4494(void* data, s32 x, s32 y) {
}
}

void func_802A4534(void* data, s32 x, s32 y) {
void btl_menu_moves_show_error(void* data, s32 x, s32 y) {
s32 posY = y;
s32 posX;
s32 msgID;
Expand Down
Loading

0 comments on commit b1ca4bd

Please sign in to comment.