Skip to content

Commit

Permalink
Merge pull request #280 from lhearachel/list-menu
Browse files Browse the repository at this point in the history
Document menu.c, list_menu.c
  • Loading branch information
lhearachel authored Oct 27, 2024
2 parents c0dce46 + 4b4f4a9 commit 4994206
Show file tree
Hide file tree
Showing 131 changed files with 3,694 additions and 3,814 deletions.
2 changes: 2 additions & 0 deletions include/bg_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define TILEMAP_FILL_VAL_KEEP_PALETTE 16 // do not replace the selected palette index
#define TILEMAP_FILL_VAL_INCLUDES_PALETTE 17

#define PIXEL_FILL(color) (((color) << 4) | (color))

enum DSScreen {
DS_SCREEN_MAIN = 0,
DS_SCREEN_SUB,
Expand Down
7 changes: 4 additions & 3 deletions include/core_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ enum ButtonMode {
BUTTON_MODE_L_IS_A = 3,
};

#define PAD_KEY (PAD_KEY_UP | PAD_KEY_DOWN | PAD_KEY_LEFT | PAD_KEY_RIGHT)
#define JOY_NEW(buttons) (gCoreSys.pressedKeys & (buttons))
#define JOY_HELD(buttons) (gCoreSys.heldKeys & (buttons))
#define PAD_KEY (PAD_KEY_UP | PAD_KEY_DOWN | PAD_KEY_LEFT | PAD_KEY_RIGHT)
#define JOY_NEW(buttons) (gCoreSys.pressedKeys & (buttons))
#define JOY_HELD(buttons) (gCoreSys.heldKeys & (buttons))
#define JOY_REPEAT(buttons) (gCoreSys.pressedKeysRepeatable & (buttons))

typedef struct CoreSys {
Callback mainCallback;
Expand Down
111 changes: 111 additions & 0 deletions include/list_menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#ifndef POKEPLATINUM_LIST_MENU_H
#define POKEPLATINUM_LIST_MENU_H

#include "bg_window.h"
#include "colored_arrow.h"
#include "string_list.h"

#define LIST_NOTHING_CHOSEN -1
#define LIST_CANCEL -2
#define LIST_HEADER -3

enum ListMenuPagerMode {
PAGER_MODE_NONE = 0,
PAGER_MODE_LEFT_RIGHT_PAD,
PAGER_MODE_SHOULDER_BUTTONS,
};

enum ListMenuAction {
LIST_MENU_ACTION_NONE = 0,
LIST_MENU_ACTION_MOVE_UP,
LIST_MENU_ACTION_MOVE_DOWN,
LIST_MENU_ACTION_PAGE_UP,
LIST_MENU_ACTION_PAGE_DOWN,
};

enum ListMenuAttribute {
LIST_MENU_CURSOR_CALLBACK = 0,
LIST_MENU_PRINT_CALLBACK,
LIST_MENU_COUNT,
LIST_MENU_MAX_DISPLAY,
LIST_MENU_UNUSED_4,
LIST_MENU_HEADER_X_OFFSET,
LIST_MENU_TEXT_X_OFFSET,
LIST_MENU_CURSOR_X_OFFSET,
LIST_MENU_Y_OFFSET,
LIST_MENU_LINE_HEIGHT,
LIST_MENU_TEXT_COLOR_FG,
LIST_MENU_TEXT_COLOR_BG,
LIST_MENU_TEXT_COLOR_SHADOW,
LIST_MENU_LETTER_SPACING,
LIST_MENU_LINE_SPACING,
LIST_MENU_PAGER_MODE,
LIST_MENU_FONT_ID,
LIST_MENU_CURSOR_TYPE,
LIST_MENU_WINDOW,
LIST_MENU_TMP,
};

typedef struct ListMenu ListMenu;

typedef void (*CursorCallback)(ListMenu *menu, u32 index, u8 onInit);
typedef void (*PrintCallback)(ListMenu *menu, u32 index, u8 yOffset);

typedef struct ListMenuTemplate {
const StringList *choices;
CursorCallback cursorCallback;
PrintCallback printCallback;
Window *window;
u16 count;
u16 maxDisplay;
u8 headerXOffset;
u8 textXOffset;
u8 cursorXOffset;
u8 yOffset : 4;
u8 textColorFg : 4;
u8 textColorBg : 4;
u8 textColorShadow : 4;
u16 letterSpacing : 3;
u16 lineSpacing : 4;
u16 pagerMode : 2;
u16 fontID : 6;
u16 cursorType : 1;
void *tmp;
} ListMenuTemplate;

struct ListMenu {
ListMenuTemplate template;
struct {
u8 textColorFg : 4;
u8 textColorBg : 4;
u8 textColorShadow : 4;
u8 letterSpacing : 6;
u8 dummy : 6;
u8 fontID : 7;
u8 prefer : 1;
} altFont;
ColoredArrow *cursor;
u16 listPos;
u16 cursorPos;
u8 dummy2C;
u8 dummy2D;
u8 dummy2E;
u8 lastAction;
u8 heapID;
};

ListMenu *ListMenu_New(const ListMenuTemplate *template, u16 startListPos, u16 startCursorPos, u8 heapID);
u32 ListMenu_ProcessInput(ListMenu *menu);
void ListMenu_Free(ListMenu *menu, u16 *outListPos, u16 *outCursorPos);
void ListMenu_Draw(ListMenu *menu);
void ListMenu_SetTextColors(ListMenu *menu, u8 fg, u8 bg, u8 shadow);
u32 ListMenu_TestInput(ListMenu *menu, ListMenuTemplate *template, u16 listPos, u16 cursorPos, u16 updateCursor, u16 input, u16 *outListPos, u16 *outCursorPos);
void ListMenu_SetAltTextColors(ListMenu *menu, u8 fg, u8 bg, u8 shadow);
void ListMenu_CalcTrueCursorPos(ListMenu *menu, u16 *outPos);
void ListMenu_GetListAndCursorPos(ListMenu *menu, u16 *outListPos, u16 *outCursorPos);
u8 ListMenu_GetLastAction(ListMenu *menu);
u32 ListMenu_GetIndexOfChoice(ListMenu *menu, u16 choice);
u32 ListMenu_GetAttribute(ListMenu *menu, u8 attribute);
void ListMenu_SetChoices(ListMenu *menu, StringList *choices);

#endif // POKEPLATINUM_LIST_MENU_H
71 changes: 71 additions & 0 deletions include/menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef POKEPLATINUM_MENU_H
#define POKEPLATINUM_MENU_H

#include "bg_window.h"
#include "colored_arrow.h"
#include "string_list.h"

#define MENU_NOTHING_CHOSEN -1
#define MENU_CANCELED -2
#define MENU_DUMMY -3

enum MenuAction {
MENU_ACTION_NONE = 0,
MENU_ACTION_MOVE_UP,
MENU_ACTION_MOVE_DOWN,
MENU_ACTION_MOVE_LEFT,
MENU_ACTION_MOVE_RIGHT,
};

enum MenuExternalInput {
MENU_INPUT_CONFIRM = 0,
MENU_INPUT_CANCEL,
MENU_INPUT_MOVE_UP,
MENU_INPUT_MOVE_DOWN,
MENU_INPUT_MOVE_LEFT,
MENU_INPUT_MOVE_RIGHT,
};

typedef struct MenuTemplate {
StringList *choices;
Window *window;
u8 fontID;
u8 xSize;
u8 ySize;
u8 lineSpacing : 4;
u8 suppressCursor : 2;
u8 loopAround : 2;
} MenuTemplate;

typedef struct Menu {
MenuTemplate template;
ColoredArrow *cursor;
u32 cancelKeys;
u8 dummy14;
u8 cursorPos;
u8 width;
u8 xOffset;
u8 yOffset;
u8 letterWidth;
u8 lineHeight;
u8 lastAction;
u8 heapID;
} Menu;

Menu *Menu_New(const MenuTemplate *template, u8 xOffset, u8 yOffset, u8 cursorStart, u8 heapID, u32 cancelKeys);
Menu *Menu_NewAndCopyToVRAM(const MenuTemplate *template, u8 xOffset, u8 yOffset, u8 cursorStart, u8 heapID, u32 cancelKeys);
Menu *Menu_NewSimple(const MenuTemplate *template, u8 cursorStart, u8 heapID);
void Menu_Free(Menu *menu, u8 *outCursorPos);
u32 Menu_ProcessInput(Menu *menu);
u32 Menu_ProcessInputWithSound(Menu *menu, u16 sdatID);
u32 Menu_ProcessExternalInput(Menu *menu, u8 input);
u8 Menu_GetCursorPos(Menu *menu);
u8 Menu_GetLastAction(Menu *menu);
Menu *Menu_MakeYesNoChoiceWithCursorAt(BgConfig *bgConfig, const WindowTemplate *winTemplate, u16 borderTileStart, u8 borderPalette, u8 cursorStart, u32 heapID);
Menu *Menu_MakeYesNoChoice(BgConfig *bgConfig, const WindowTemplate *winTemplate, u16 borderTileStart, u8 borderPalette, u32 heapID);
u32 Menu_ProcessInputAndHandleExit(Menu *menu, u32 heapID);
u32 Menu_ProcessExternalInputAndHandleExit(Menu *menu, u8 input, u32 heapID);
void Menu_DestroyForExit(Menu *menu, u32 heapID);
void Window_DrawMenuCursor(Window *window, u32 x, u32 y);

#endif // POKEPLATINUM_MENU_H
14 changes: 7 additions & 7 deletions include/overlay007/struct_ov7_0224D008.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#ifndef POKEPLATINUM_STRUCT_OV7_0224D008_H
#define POKEPLATINUM_STRUCT_OV7_0224D008_H

#include "struct_decls/struct_0200112C_decl.h"
#include "struct_decls/struct_02001AF4_decl.h"
#include "struct_decls/struct_0200C440_decl.h"
#include "struct_decls/struct_02013A04_decl.h"

#include "overlay005/struct_ov5_021D30A8.h"

Expand All @@ -14,9 +11,12 @@
#include "game_options.h"
#include "game_records.h"
#include "journal.h"
#include "list_menu.h"
#include "menu.h"
#include "message.h"
#include "savedata.h"
#include "strbuf.h"
#include "string_list.h"
#include "string_template.h"
#include "trainer_info.h"
#include "vars_flags.h"
Expand All @@ -26,10 +26,10 @@ typedef struct {
void *unk_04;
Window unk_08[6];
Window unk_68;
BmpList *unk_78;
ResourceMetadata *unk_7C;
UIControlData *unk_80;
ResourceMetadata *unk_84;
ListMenu *unk_78;
StringList *unk_7C;
Menu *unk_80;
StringList *unk_84;
MessageLoader *unk_88;
StringTemplate *unk_8C;
Camera *camera;
Expand Down
4 changes: 2 additions & 2 deletions include/overlay023/funcptr_ov23_022515D8.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef POKEPLATINUM_FUNCPTR_OV23_022515D8_H
#define POKEPLATINUM_FUNCPTR_OV23_022515D8_H

#include "struct_decls/struct_0200112C_decl.h"
#include "list_menu.h"

typedef void (*UnkFuncPtr_ov23_022515D8)(BmpList *, u32, u8);
typedef void (*UnkFuncPtr_ov23_022515D8)(ListMenu *, u32, u8);

#endif // POKEPLATINUM_FUNCPTR_OV23_022515D8_H
5 changes: 3 additions & 2 deletions include/overlay023/ov23_02248C08.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

#include "overlay023/funcptr_ov23_02248D20.h"
#include "overlay023/struct_ov23_02248D20.h"
#include "overlay084/struct_ov84_02240FA8.h"

UnkStruct_ov23_02248D20 *ov23_02248C08(UnkStruct_ov84_02240FA8 *param0, u16 param1, u16 param2, u8 param3, UnkFuncPtr_ov23_02248D20 param4, UndergroundData *param5, BOOL param6);
#include "list_menu.h"

UnkStruct_ov23_02248D20 *ov23_02248C08(ListMenuTemplate *param0, u16 param1, u16 param2, u8 param3, UnkFuncPtr_ov23_02248D20 param4, UndergroundData *param5, BOOL param6);
u32 ov23_02248D20(UnkStruct_ov23_02248D20 *param0);
void ov23_02248EF8(UnkStruct_ov23_02248D20 *param0, u16 *param1, u16 *param2);

Expand Down
8 changes: 4 additions & 4 deletions include/overlay023/ov23_0224F294.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef POKEPLATINUM_OV23_0224F294_H
#define POKEPLATINUM_OV23_0224F294_H

#include "struct_decls/struct_0200112C_decl.h"
#include "struct_decls/struct_020298B0_decl.h"

#include "field/field_system_decl.h"
#include "overlay023/funcptr_ov23_0224F758.h"
#include "overlay023/struct_ov23_02250CD4.h"

#include "list_menu.h"
#include "sys_task_manager.h"

void ov23_0224F588(UndergroundData *param0);
Expand All @@ -26,16 +26,16 @@ BOOL ov23_0224F744(int param0);
void ov23_0224F758(UnkFuncPtr_ov23_0224F758 param0, FieldSystem *fieldSystem);
void ov23_0224FB7C(UnkStruct_ov23_02250CD4 *param0);
void ov23_0224FD68(int param0);
void ov23_0224FD84(BmpList *param0, u32 param1, u8 param2);
void ov23_0224FD84(ListMenu *param0, u32 param1, u8 param2);
void ov23_0224FDBC(UnkStruct_ov23_02250CD4 *param0);
void ov23_0224FDE0(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250128(int param0);
void ov23_02250184(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250540(BmpList *param0, u32 param1, u8 param2);
void ov23_02250540(ListMenu *param0, u32 param1, u8 param2);
void ov23_02250578(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250598(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250A50(UnkFuncPtr_ov23_0224F758 param0, FieldSystem *fieldSystem);
void ov23_02250C3C(BmpList *param0, u32 param1, u8 param2);
void ov23_02250C3C(ListMenu *param0, u32 param1, u8 param2);
void ov23_02250CB0(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250CD4(UnkStruct_ov23_02250CD4 *param0);
void ov23_02250D2C(UnkStruct_ov23_02250CD4 *param0);
Expand Down
4 changes: 2 additions & 2 deletions include/overlay023/ov23_02253D40.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "overlay023/struct_ov23_02253E2C_decl.h"
#include "overlay023/struct_ov23_02253F60.h"
#include "overlay084/struct_ov84_02240FA8.h"

#include "bg_window.h"
#include "list_menu.h"
#include "message.h"
#include "trainer_info.h"

const UnkStruct_ov84_02240FA8 *ov23_02253D40(void);
const ListMenuTemplate *ov23_02253D40(void);
UnkStruct_ov23_02253E2C *ov23_02253D48(int param0, int param1, BgConfig *param2, int param3, int param4);
void ov23_02253DD8(UnkStruct_ov23_02253E2C *param0);
void ov23_02253DFC(UnkStruct_ov23_02253E2C *param0, int param1, int param2);
Expand Down
8 changes: 4 additions & 4 deletions include/overlay023/struct_ov23_02248D20.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef POKEPLATINUM_STRUCT_OV23_02248D20_H
#define POKEPLATINUM_STRUCT_OV23_02248D20_H

#include "struct_decls/struct_0200112C_decl.h"
#include "struct_decls/struct_02013A04_decl.h"
#include "struct_decls/struct_020298B0_decl.h"

#include "overlay023/funcptr_ov23_02248D20.h"

#include "colored_arrow.h"
#include "list_menu.h"
#include "string_list.h"

typedef struct {
UnkFuncPtr_ov23_02248D20 unk_00;
UndergroundData *unk_04;
ResourceMetadata *unk_08;
BmpList *unk_0C;
StringList *unk_08;
ListMenu *unk_0C;
ColoredArrow *unk_10;
u16 unk_14;
u16 unk_16;
Expand Down
20 changes: 10 additions & 10 deletions include/overlay023/struct_ov23_02250CD4.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define POKEPLATINUM_STRUCT_OV23_02250CD4_H

#include "struct_decls/cell_actor_data.h"
#include "struct_decls/struct_0200112C_decl.h"
#include "struct_decls/struct_02001AF4_decl.h"
#include "struct_decls/struct_02013A04_decl.h"
#include "struct_defs/struct_0206A844.h"

#include "field/field_system_decl.h"
Expand All @@ -17,7 +14,10 @@
#include "overlay023/struct_ov23_02248D20.h"

#include "bg_window.h"
#include "list_menu.h"
#include "menu.h"
#include "strbuf.h"
#include "string_list.h"
#include "string_template.h"
#include "sys_task_manager.h"

Expand All @@ -29,14 +29,14 @@ typedef struct {
Window unk_10;
Window unk_20;
Window unk_30;
ResourceMetadata *unk_40;
ResourceMetadata *unk_44;
BmpList *unk_48;
StringList *unk_40;
StringList *unk_44;
ListMenu *unk_48;
UnkStruct_ov23_02248D20 *unk_4C;
BmpList *unk_50;
UIControlData *unk_54;
ResourceMetadata *unk_58;
UIControlData *unk_5C;
ListMenu *unk_50;
Menu *unk_54;
StringList *unk_58;
Menu *unk_5C;
UnkFuncPtr_ov23_022515D8 unk_60;
UnkFuncPtr_ov23_022515D8 unk_64;
Strbuf *unk_68;
Expand Down
Loading

0 comments on commit 4994206

Please sign in to comment.