From af355fcb1211b0fb3eebdd852e04aacf361f5d3c Mon Sep 17 00:00:00 2001 From: TheXaman Date: Fri, 2 Jul 2021 11:49:32 +0200 Subject: [PATCH] added Debug to StartMenu via DEBUG_MENU option --- include/debug.h | 2 ++ src/field_control_avatar.c | 6 ++-- src/start_menu.c | 69 +++++++++++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/include/debug.h b/include/debug.h index 4c9c3fffc..864176e4f 100644 --- a/include/debug.h +++ b/include/debug.h @@ -5,4 +5,6 @@ void Debug_ShowMainMenu(void); #endif +#define DEBUG_MENU FALSE + #endif // GUARD_DEBUG_H \ No newline at end of file diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index fa607cd42..916287b0b 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -132,7 +132,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) else if (heldKeys & DPAD_RIGHT) input->dpadDirection = DIR_EAST; - +#if DEBUGGING && !DEBUG_MENU //DEBUG if (heldKeys & R_BUTTON) { @@ -158,7 +158,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) input->pressedStartButton = FALSE; } } - // +#endif } @@ -219,7 +219,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input) if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE) return TRUE; -#if DEBUGGING +#if DEBUGGING && !DEBUG_MENU if (input->input_field_1_2) { PlaySE(SE_WIN_OPEN); diff --git a/src/start_menu.c b/src/start_menu.c index fa51766e8..b76576151 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -3,6 +3,7 @@ #include "battle_pyramid.h" #include "battle_pyramid_bag.h" #include "bg.h" +#include "debug.h" #include "event_data.h" #include "event_object_movement.h" #include "event_object_lock.h" @@ -61,7 +62,8 @@ enum MENU_ACTION_PLAYER_LINK, MENU_ACTION_REST_FRONTIER, MENU_ACTION_RETIRE_FRONTIER, - MENU_ACTION_PYRAMID_BAG + MENU_ACTION_PYRAMID_BAG, + MENU_ACTION_DEBUG, }; // Save status @@ -102,6 +104,7 @@ static bool8 StartMenuSafariZoneRetireCallback(void); static bool8 StartMenuLinkModePlayerNameCallback(void); static bool8 StartMenuBattlePyramidRetireCallback(void); static bool8 StartMenuBattlePyramidBagCallback(void); +static bool8 StartMenuDebugCallback(void); // Menu callbacks static bool8 SaveStartCallback(void); @@ -153,6 +156,8 @@ static const u8* const sPyramindFloorNames[] = static const struct WindowTemplate sPyramidFloorWindowTemplate_2 = {0, 1, 1, 0xA, 4, 0xF, 8}; static const struct WindowTemplate sPyramidFloorWindowTemplate_1 = {0, 1, 1, 0xC, 4, 0xF, 8}; +static const u8 gText_MenuDebug[] = _("DEBUG"); + static const struct MenuAction sStartMenuItems[] = { {gText_MenuPokedex, {.u8_void = StartMenuPokedexCallback}}, @@ -167,7 +172,8 @@ static const struct MenuAction sStartMenuItems[] = {gText_MenuPlayer, {.u8_void = StartMenuLinkModePlayerNameCallback}}, {gText_MenuRest, {.u8_void = StartMenuSaveCallback}}, {gText_MenuRetire, {.u8_void = StartMenuBattlePyramidRetireCallback}}, - {gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}} + {gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}}, + {gText_MenuDebug, {.u8_void = StartMenuDebugCallback}}, }; static const struct BgTemplate sUnknown_085105A8[] = @@ -195,6 +201,7 @@ static const struct WindowTemplate sSaveInfoWindowTemplate = {0, 1, 1, 0xE, 0xA, static void BuildStartMenuActions(void); static void AddStartMenuAction(u8 action); static void BuildNormalStartMenu(void); +static void BuildDebugStartMenu(void); static void BuildSafariZoneStartMenu(void); static void BuildLinkModeStartMenu(void); static void BuildUnionRoomStartMenu(void); @@ -223,6 +230,7 @@ static void CB2_SaveAfterLinkBattle(void); static void ShowSaveInfoWindow(void); static void RemoveSaveInfoWindow(void); static void HideStartMenuWindow(void); +static void HideStartMenuDebug(void); void SetDexPokemonPokenavFlags(void) // unused { @@ -259,10 +267,17 @@ static void BuildStartMenuActions(void) { BuildMultiPartnerRoomStartMenu(); } + #if DEBUGGING && DEBUG_MENU + else + { + BuildDebugStartMenu(); + } + #else else - { - BuildNormalStartMenu(); - } + { + BuildNormalStartMenu(); + } + #endif } static void AddStartMenuAction(u8 action) @@ -294,6 +309,30 @@ static void BuildNormalStartMenu(void) AddStartMenuAction(MENU_ACTION_EXIT); } +static void BuildDebugStartMenu(void) +{ + if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE) + { + AddStartMenuAction(MENU_ACTION_POKEDEX); + } + if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE) + { + AddStartMenuAction(MENU_ACTION_POKEMON); + } + + AddStartMenuAction(MENU_ACTION_BAG); + + if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE) + { + AddStartMenuAction(MENU_ACTION_POKENAV); + } + + AddStartMenuAction(MENU_ACTION_PLAYER); + AddStartMenuAction(MENU_ACTION_SAVE); + AddStartMenuAction(MENU_ACTION_OPTION); + AddStartMenuAction(MENU_ACTION_DEBUG); +} + static void BuildSafariZoneStartMenu(void) { AddStartMenuAction(MENU_ACTION_RETIRE_SAFARI); @@ -575,6 +614,7 @@ static bool8 HandleStartMenuInput(void) if (gMenuCallback != StartMenuSaveCallback && gMenuCallback != StartMenuExitCallback + && gMenuCallback != StartMenuDebugCallback && gMenuCallback != StartMenuSafariZoneRetireCallback && gMenuCallback != StartMenuBattlePyramidRetireCallback) { @@ -710,6 +750,18 @@ static bool8 StartMenuExitCallback(void) return TRUE; } +static bool8 StartMenuDebugCallback(void) +{ + RemoveExtraStartMenuWindows(); + HideStartMenuDebug(); // Hide start menu without enabling movement + + #if DEBUGGING + Debug_ShowMainMenu(); + #endif + + return TRUE; +} + static bool8 StartMenuSafariZoneRetireCallback(void) { RemoveExtraStartMenuWindows(); @@ -719,6 +771,13 @@ static bool8 StartMenuSafariZoneRetireCallback(void) return TRUE; } +static void HideStartMenuDebug(void) +{ + PlaySE(SE_SELECT); + ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE); + RemoveStartMenuWindow(); +} + static bool8 StartMenuLinkModePlayerNameCallback(void) { if (!gPaletteFade.active)