2017-09-05 13:01:24 +02:00
|
|
|
#include "global.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "battle_pike.h"
|
|
|
|
#include "battle_pyramid.h"
|
|
|
|
#include "battle_pyramid_bag.h"
|
2017-12-23 19:23:55 +01:00
|
|
|
#include "bg.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "event_data.h"
|
|
|
|
#include "event_object_movement.h"
|
2019-12-06 08:55:30 +01:00
|
|
|
#include "event_object_lock.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "event_scripts.h"
|
2019-03-02 09:18:08 +01:00
|
|
|
#include "fieldmap.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "field_effect.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "field_player_avatar.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "field_specials.h"
|
|
|
|
#include "field_weather.h"
|
2019-03-02 09:18:08 +01:00
|
|
|
#include "field_screen_effect.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "frontier_pass.h"
|
|
|
|
#include "frontier_util.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "international_string_util.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "item_menu.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "link.h"
|
|
|
|
#include "load_save.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "new_game.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "option_menu.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "party_menu.h"
|
|
|
|
#include "pokedex.h"
|
2019-03-02 09:18:08 +01:00
|
|
|
#include "pokenav.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "safari_zone.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "save.h"
|
|
|
|
#include "scanline_effect.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "script.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "start_menu.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
2018-03-28 00:33:08 +02:00
|
|
|
#include "text_window.h"
|
2019-01-20 18:24:35 +01:00
|
|
|
#include "trainer_card.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "window.h"
|
2018-03-28 21:09:27 +02:00
|
|
|
#include "constants/songs.h"
|
2019-03-30 19:36:52 +01:00
|
|
|
#include "union_room.h"
|
2019-04-04 23:05:46 +02:00
|
|
|
#include "constants/rgb.h"
|
2018-11-01 21:31:10 +01:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
// Menu actions
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MENU_ACTION_POKEDEX,
|
|
|
|
MENU_ACTION_POKEMON,
|
|
|
|
MENU_ACTION_BAG,
|
|
|
|
MENU_ACTION_POKENAV,
|
|
|
|
MENU_ACTION_PLAYER,
|
|
|
|
MENU_ACTION_SAVE,
|
|
|
|
MENU_ACTION_OPTION,
|
|
|
|
MENU_ACTION_EXIT,
|
|
|
|
MENU_ACTION_RETIRE_SAFARI,
|
|
|
|
MENU_ACTION_PLAYER_LINK,
|
|
|
|
MENU_ACTION_REST_FRONTIER,
|
|
|
|
MENU_ACTION_RETIRE_FRONTIER,
|
|
|
|
MENU_ACTION_PYRAMID_BAG
|
|
|
|
};
|
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
// Save status
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SAVE_IN_PROGRESS,
|
|
|
|
SAVE_SUCCESS,
|
|
|
|
SAVE_CANCELED,
|
|
|
|
SAVE_ERROR
|
|
|
|
};
|
|
|
|
|
2018-11-19 01:03:14 +01:00
|
|
|
// IWRAM common
|
|
|
|
bool8 (*gMenuCallback)(void);
|
|
|
|
|
|
|
|
// EWRAM
|
2018-03-28 15:45:35 +02:00
|
|
|
EWRAM_DATA static u8 sSafariBallsWindowId = 0;
|
|
|
|
EWRAM_DATA static u8 sBattlePyramidFloorWindowId = 0;
|
|
|
|
EWRAM_DATA static u8 sStartMenuCursorPos = 0;
|
|
|
|
EWRAM_DATA static u8 sNumStartMenuActions = 0;
|
|
|
|
EWRAM_DATA static u8 sCurrentStartMenuActions[9] = {0};
|
2019-12-17 09:24:44 +01:00
|
|
|
EWRAM_DATA static u8 sInitStartMenuData[2] = {0};
|
2018-03-28 15:45:35 +02:00
|
|
|
|
|
|
|
EWRAM_DATA static u8 (*sSaveDialogCallback)(void) = NULL;
|
|
|
|
EWRAM_DATA static u8 sSaveDialogTimer = 0;
|
|
|
|
EWRAM_DATA static bool8 sSavingComplete = FALSE;
|
2018-03-28 21:09:27 +02:00
|
|
|
EWRAM_DATA static u8 sSaveInfoWindowId = 0;
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
// Menu action callbacks
|
|
|
|
static bool8 StartMenuPokedexCallback(void);
|
|
|
|
static bool8 StartMenuPokemonCallback(void);
|
|
|
|
static bool8 StartMenuBagCallback(void);
|
|
|
|
static bool8 StartMenuPokeNavCallback(void);
|
|
|
|
static bool8 StartMenuPlayerNameCallback(void);
|
|
|
|
static bool8 StartMenuSaveCallback(void);
|
|
|
|
static bool8 StartMenuOptionCallback(void);
|
|
|
|
static bool8 StartMenuExitCallback(void);
|
|
|
|
static bool8 StartMenuSafariZoneRetireCallback(void);
|
|
|
|
static bool8 StartMenuLinkModePlayerNameCallback(void);
|
|
|
|
static bool8 StartMenuBattlePyramidRetireCallback(void);
|
|
|
|
static bool8 StartMenuBattlePyramidBagCallback(void);
|
|
|
|
|
|
|
|
// Menu callbacks
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 SaveStartCallback(void);
|
|
|
|
static bool8 SaveCallback(void);
|
|
|
|
static bool8 BattlePyramidRetireStartCallback(void);
|
|
|
|
static bool8 BattlePyramidRetireReturnCallback(void);
|
|
|
|
static bool8 BattlePyramidRetireCallback(void);
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 HandleStartMenuInput(void);
|
|
|
|
|
|
|
|
// Save dialog callbacks
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveConfirmSaveCallback(void);
|
|
|
|
static u8 SaveYesNoCallback(void);
|
|
|
|
static u8 SaveConfirmInputCallback(void);
|
|
|
|
static u8 SaveFileExistsCallback(void);
|
2019-02-22 07:40:11 +01:00
|
|
|
static u8 SaveConfirmOverwriteDefaultNoCallback(void);
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveConfirmOverwriteCallback(void);
|
|
|
|
static u8 SaveOverwriteInputCallback(void);
|
|
|
|
static u8 SaveSavingMessageCallback(void);
|
|
|
|
static u8 SaveDoSaveCallback(void);
|
|
|
|
static u8 SaveSuccessCallback(void);
|
|
|
|
static u8 SaveReturnSuccessCallback(void);
|
|
|
|
static u8 SaveErrorCallback(void);
|
|
|
|
static u8 SaveReturnErrorCallback(void);
|
|
|
|
static u8 BattlePyramidConfirmRetireCallback(void);
|
|
|
|
static u8 BattlePyramidRetireYesNoCallback(void);
|
|
|
|
static u8 BattlePyramidRetireInputCallback(void);
|
2018-03-28 15:45:35 +02:00
|
|
|
|
|
|
|
// Task callbacks
|
2018-03-28 21:09:27 +02:00
|
|
|
static void StartMenuTask(u8 taskId);
|
|
|
|
static void SaveGameTask(u8 taskId);
|
2020-06-04 00:00:53 +02:00
|
|
|
static void Task_SaveAfterLinkBattle(u8 taskId);
|
|
|
|
static void Task_WaitForBattleTowerLinkSave(u8 taskId);
|
2019-12-17 09:24:44 +01:00
|
|
|
static bool8 FieldCB_ReturnToFieldStartMenu(void);
|
2018-03-28 15:45:35 +02:00
|
|
|
|
2018-03-29 02:16:02 +02:00
|
|
|
static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8};
|
2017-12-23 19:23:55 +01:00
|
|
|
|
2021-01-05 05:58:33 +01:00
|
|
|
static const u8* const sPyramidFloorNames[] =
|
2017-12-23 19:23:55 +01:00
|
|
|
{
|
|
|
|
gText_Floor1,
|
|
|
|
gText_Floor2,
|
|
|
|
gText_Floor3,
|
|
|
|
gText_Floor4,
|
|
|
|
gText_Floor5,
|
|
|
|
gText_Floor6,
|
|
|
|
gText_Floor7,
|
|
|
|
gText_Peak
|
|
|
|
};
|
|
|
|
|
2018-03-29 02:16:02 +02:00
|
|
|
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};
|
2017-12-23 19:23:55 +01:00
|
|
|
|
2018-03-29 02:16:02 +02:00
|
|
|
static const struct MenuAction sStartMenuItems[] =
|
2017-12-23 19:23:55 +01:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
{gText_MenuPokedex, {.u8_void = StartMenuPokedexCallback}},
|
|
|
|
{gText_MenuPokemon, {.u8_void = StartMenuPokemonCallback}},
|
|
|
|
{gText_MenuBag, {.u8_void = StartMenuBagCallback}},
|
|
|
|
{gText_MenuPokenav, {.u8_void = StartMenuPokeNavCallback}},
|
|
|
|
{gText_MenuPlayer, {.u8_void = StartMenuPlayerNameCallback}},
|
|
|
|
{gText_MenuSave, {.u8_void = StartMenuSaveCallback}},
|
|
|
|
{gText_MenuOption, {.u8_void = StartMenuOptionCallback}},
|
|
|
|
{gText_MenuExit, {.u8_void = StartMenuExitCallback}},
|
|
|
|
{gText_MenuRetire, {.u8_void = StartMenuSafariZoneRetireCallback}},
|
|
|
|
{gText_MenuPlayer, {.u8_void = StartMenuLinkModePlayerNameCallback}},
|
|
|
|
{gText_MenuRest, {.u8_void = StartMenuSaveCallback}},
|
|
|
|
{gText_MenuRetire, {.u8_void = StartMenuBattlePyramidRetireCallback}},
|
|
|
|
{gText_MenuBag, {.u8_void = StartMenuBattlePyramidBagCallback}}
|
2017-12-23 19:23:55 +01:00
|
|
|
};
|
|
|
|
|
2021-03-21 05:54:24 +01:00
|
|
|
static const struct BgTemplate sBgTemplates_LinkBattleSave[] =
|
2017-12-23 19:23:55 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-21 05:54:24 +01:00
|
|
|
static const struct WindowTemplate sWindowTemplates_LinkBattleSave[] =
|
2017-12-23 19:23:55 +01:00
|
|
|
{
|
2021-03-21 05:54:24 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 26,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x194
|
|
|
|
},
|
2017-12-23 19:23:55 +01:00
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
2021-03-21 05:54:24 +01:00
|
|
|
static const struct WindowTemplate sSaveInfoWindowTemplate = {
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 14,
|
|
|
|
.height = 10,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 8
|
|
|
|
};
|
2017-12-23 19:23:55 +01:00
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
// Local functions
|
|
|
|
static void BuildStartMenuActions(void);
|
|
|
|
static void AddStartMenuAction(u8 action);
|
|
|
|
static void BuildNormalStartMenu(void);
|
|
|
|
static void BuildSafariZoneStartMenu(void);
|
|
|
|
static void BuildLinkModeStartMenu(void);
|
|
|
|
static void BuildUnionRoomStartMenu(void);
|
|
|
|
static void BuildBattlePikeStartMenu(void);
|
|
|
|
static void BuildBattlePyramidStartMenu(void);
|
2020-01-08 11:43:06 +01:00
|
|
|
static void BuildMultiPartnerRoomStartMenu(void);
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowSafariBallsWindow(void);
|
|
|
|
static void ShowPyramidFloorWindow(void);
|
2018-03-29 02:16:02 +02:00
|
|
|
static void RemoveExtraStartMenuWindows(void);
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool32 PrintStartMenuActions(s8 *pIndex, u32 count);
|
|
|
|
static bool32 InitStartMenuStep(void);
|
|
|
|
static void InitStartMenu(void);
|
|
|
|
static void CreateStartMenuTask(TaskFunc followupFunc);
|
|
|
|
static void InitSave(void);
|
|
|
|
static u8 RunSaveCallback(void);
|
|
|
|
static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void));
|
2021-03-21 05:54:24 +01:00
|
|
|
static void HideSaveMessageWindow(void);
|
2018-03-28 21:09:27 +02:00
|
|
|
static void HideSaveInfoWindow(void);
|
|
|
|
static void SaveStartTimer(void);
|
|
|
|
static bool8 SaveSuccesTimer(void);
|
|
|
|
static bool8 SaveErrorTimer(void);
|
|
|
|
static void InitBattlePyramidRetire(void);
|
2021-03-21 05:54:24 +01:00
|
|
|
static void VBlankCB_LinkBattleSave(void);
|
2020-06-04 00:00:53 +02:00
|
|
|
static bool32 InitSaveWindowAfterLinkBattle(u8 *par1);
|
|
|
|
static void CB2_SaveAfterLinkBattle(void);
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowSaveInfoWindow(void);
|
|
|
|
static void RemoveSaveInfoWindow(void);
|
|
|
|
static void HideStartMenuWindow(void);
|
|
|
|
|
2018-02-02 19:00:01 +01:00
|
|
|
void SetDexPokemonPokenavFlags(void) // unused
|
|
|
|
{
|
|
|
|
FlagSet(FLAG_SYS_POKEDEX_GET);
|
|
|
|
FlagSet(FLAG_SYS_POKEMON_GET);
|
|
|
|
FlagSet(FLAG_SYS_POKENAV_GET);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildStartMenuActions(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
sNumStartMenuActions = 0;
|
2018-03-28 21:09:27 +02:00
|
|
|
|
2019-02-10 09:54:50 +01:00
|
|
|
if (IsUpdateLinkStateCBActive() == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildLinkModeStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
else if (InUnionRoom() == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildUnionRoomStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
else if (GetSafariZoneFlag() == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildSafariZoneStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
else if (InBattlePike())
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildBattlePikeStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
else if (InBattlePyramid())
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildBattlePyramidStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2020-01-08 11:43:06 +01:00
|
|
|
else if (InMultiPartnerRoom())
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
BuildMultiPartnerRoomStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
else
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
BuildNormalStartMenu();
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void AddStartMenuAction(u8 action)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AppendToList(sCurrentStartMenuActions, &sNumStartMenuActions, action);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildNormalStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
2017-11-08 22:20:10 +01:00
|
|
|
if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_POKEDEX);
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2017-11-08 22:20:10 +01:00
|
|
|
if (FlagGet(FLAG_SYS_POKEMON_GET) == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_BAG);
|
2018-03-28 21:09:27 +02:00
|
|
|
|
2017-11-08 22:20:10 +01:00
|
|
|
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_POKENAV);
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_SAVE);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildSafariZoneStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_RETIRE_SAFARI);
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEDEX);
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_BAG);
|
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildLinkModeStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_BAG);
|
2018-03-28 21:09:27 +02:00
|
|
|
|
2017-11-08 22:20:10 +01:00
|
|
|
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_POKENAV);
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER_LINK);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildUnionRoomStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_BAG);
|
2018-03-28 21:09:27 +02:00
|
|
|
|
2017-11-08 22:20:10 +01:00
|
|
|
if (FlagGet(FLAG_SYS_POKENAV_GET) == TRUE)
|
2018-03-28 21:09:27 +02:00
|
|
|
{
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_POKENAV);
|
2018-03-28 21:09:27 +02:00
|
|
|
}
|
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildBattlePikeStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEDEX);
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void BuildBattlePyramidStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_PYRAMID_BAG);
|
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_REST_FRONTIER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_RETIRE_FRONTIER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
static void BuildMultiPartnerRoomStartMenu(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
AddStartMenuAction(MENU_ACTION_POKEMON);
|
|
|
|
AddStartMenuAction(MENU_ACTION_PLAYER);
|
|
|
|
AddStartMenuAction(MENU_ACTION_OPTION);
|
|
|
|
AddStartMenuAction(MENU_ACTION_EXIT);
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowSafariBallsWindow(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
2018-03-29 02:16:02 +02:00
|
|
|
sSafariBallsWindowId = AddWindow(&sSafariBallsWindowTemplate);
|
2017-09-05 13:01:24 +02:00
|
|
|
PutWindowTilemap(sSafariBallsWindowId);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdWindowFrame(sSafariBallsWindowId, FALSE);
|
2017-09-05 13:01:24 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, gNumSafariBalls, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
2017-09-20 21:38:05 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_SafariBallStock);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSafariBallsWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
|
2017-09-05 13:01:24 +02:00
|
|
|
CopyWindowToVram(sSafariBallsWindowId, 2);
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowPyramidFloorWindow(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
2018-10-21 00:06:42 +02:00
|
|
|
if (gSaveBlock2Ptr->frontier.curChallengeBattleNum == 7)
|
2018-03-29 02:16:02 +02:00
|
|
|
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_1);
|
2017-09-05 13:01:24 +02:00
|
|
|
else
|
2018-03-29 02:16:02 +02:00
|
|
|
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2);
|
2018-03-28 15:45:35 +02:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
PutWindowTilemap(sBattlePyramidFloorWindowId);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE);
|
2021-01-05 05:58:33 +01:00
|
|
|
StringCopy(gStringVar1, sPyramidFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]);
|
2017-09-20 21:38:05 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
|
2017-09-05 13:01:24 +02:00
|
|
|
CopyWindowToVram(sBattlePyramidFloorWindowId, 2);
|
|
|
|
}
|
|
|
|
|
2018-03-29 02:16:02 +02:00
|
|
|
static void RemoveExtraStartMenuWindows(void)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
|
|
|
if (GetSafariZoneFlag())
|
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(sSafariBallsWindowId, FALSE);
|
2017-09-05 13:01:24 +02:00
|
|
|
CopyWindowToVram(sSafariBallsWindowId, 2);
|
|
|
|
RemoveWindow(sSafariBallsWindowId);
|
|
|
|
}
|
|
|
|
if (InBattlePyramid())
|
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(sBattlePyramidFloorWindowId, FALSE);
|
2017-09-05 13:01:24 +02:00
|
|
|
RemoveWindow(sBattlePyramidFloorWindowId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool32 PrintStartMenuActions(s8 *pIndex, u32 count)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
s8 index = *pIndex;
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2017-09-05 13:01:24 +02:00
|
|
|
do
|
|
|
|
{
|
2019-01-19 23:04:33 +01:00
|
|
|
if (sStartMenuItems[sCurrentStartMenuActions[index]].func.u8_void == StartMenuPlayerNameCallback)
|
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
PrintPlayerNameOnWindow(GetStartMenuWindowId(), sStartMenuItems[sCurrentStartMenuActions[index]].text, 8, (index << 4) + 9);
|
|
|
|
}
|
2019-01-19 23:04:33 +01:00
|
|
|
else
|
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, sStartMenuItems[sCurrentStartMenuActions[index]].text);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(GetStartMenuWindowId(), 1, gStringVar4, 8, (index << 4) + 9, 0xFF, NULL);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
index++;
|
2019-01-19 23:04:33 +01:00
|
|
|
if (index >= sNumStartMenuActions)
|
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
*pIndex = index;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
while (count != 0);
|
|
|
|
|
|
|
|
*pIndex = index;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-06-17 12:30:09 +02:00
|
|
|
static bool32 InitStartMenuStep(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-12-17 09:24:44 +01:00
|
|
|
s8 state = sInitStartMenuData[0];
|
2018-03-28 21:09:27 +02:00
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
switch (state)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0]++;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
BuildStartMenuActions();
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0]++;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE);
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[1] = 0;
|
|
|
|
sInitStartMenuData[0]++;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2018-11-17 22:55:39 +01:00
|
|
|
if (GetSafariZoneFlag())
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSafariBallsWindow();
|
2018-11-17 22:55:39 +01:00
|
|
|
if (InBattlePyramid())
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowPyramidFloorWindow();
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0]++;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
if (PrintStartMenuActions(&sInitStartMenuData[1], 2))
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0]++;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
sStartMenuCursorPos = sub_81983AC(GetStartMenuWindowId(), 1, 0, 9, 16, sNumStartMenuActions, sStartMenuCursorPos);
|
|
|
|
CopyWindowToVram(GetStartMenuWindowId(), TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static void InitStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0] = 0;
|
|
|
|
sInitStartMenuData[1] = 0;
|
2019-01-20 18:24:35 +01:00
|
|
|
while (!InitStartMenuStep())
|
|
|
|
;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void StartMenuTask(u8 taskId)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
if (InitStartMenuStep() == TRUE)
|
2018-03-28 00:33:08 +02:00
|
|
|
SwitchTaskToFollowupFunc(taskId);
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void CreateStartMenuTask(TaskFunc followupFunc)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
u8 taskId;
|
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0] = 0;
|
|
|
|
sInitStartMenuData[1] = 0;
|
2018-03-28 21:09:27 +02:00
|
|
|
taskId = CreateTask(StartMenuTask, 0x50);
|
|
|
|
SetTaskFuncWithFollowupFunc(taskId, StartMenuTask, followupFunc);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
static bool8 FieldCB_ReturnToFieldStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
if (InitStartMenuStep() == FALSE)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
ReturnToFieldOpenStartMenu();
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
void ShowReturnToFieldStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-12-17 09:24:44 +01:00
|
|
|
sInitStartMenuData[0] = 0;
|
|
|
|
sInitStartMenuData[1] = 0;
|
|
|
|
gFieldCallback2 = FieldCB_ReturnToFieldStartMenu;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
|
2019-12-11 09:28:55 +01:00
|
|
|
void Task_ShowStartMenu(u8 taskId)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
struct Task* task = &gTasks[taskId];
|
|
|
|
|
2018-06-17 12:30:09 +02:00
|
|
|
switch(task->data[0])
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (InUnionRoom() == TRUE)
|
2020-06-09 00:16:57 +02:00
|
|
|
SetUsingUnionRoomStartMenu();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
gMenuCallback = HandleStartMenuInput;
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (gMenuCallback() == TRUE)
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-11 09:28:55 +01:00
|
|
|
void ShowStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-10 09:54:50 +01:00
|
|
|
if (!IsUpdateLinkStateCBActive())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FreezeObjectEvents();
|
2021-01-26 10:41:13 +01:00
|
|
|
PlayerFreeze();
|
2018-03-28 00:33:08 +02:00
|
|
|
sub_808BCF4();
|
|
|
|
}
|
2019-12-11 09:28:55 +01:00
|
|
|
CreateStartMenuTask(Task_ShowStartMenu);
|
2018-03-28 00:33:08 +02:00
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 HandleStartMenuInput(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(DPAD_UP))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
sStartMenuCursorPos = Menu_MoveCursor(-1);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(DPAD_DOWN))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
sStartMenuCursorPos = Menu_MoveCursor(1);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2018-03-28 15:45:35 +02:00
|
|
|
if (sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func.u8_void == StartMenuPokedexCallback)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-10-07 07:13:34 +02:00
|
|
|
if (GetNationalPokedexCount(FLAG_GET_SEEN) == 0)
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
gMenuCallback = sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func.u8_void;
|
2018-06-17 12:30:09 +02:00
|
|
|
|
|
|
|
if (gMenuCallback != StartMenuSaveCallback
|
2018-03-28 15:45:35 +02:00
|
|
|
&& gMenuCallback != StartMenuExitCallback
|
|
|
|
&& gMenuCallback != StartMenuSafariZoneRetireCallback
|
|
|
|
&& gMenuCallback != StartMenuBattlePyramidRetireCallback)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2017-09-05 13:01:24 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(START_BUTTON | B_BUTTON))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-03-28 21:09:27 +02:00
|
|
|
HideStartMenu();
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuPokedexCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
IncrementGameStat(GAME_STAT_CHECKED_POKEDEX);
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2020-03-08 18:24:22 +01:00
|
|
|
SetMainCallback2(CB2_OpenPokedex);
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuPokemonCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2018-03-28 21:09:27 +02:00
|
|
|
SetMainCallback2(CB2_PartyMenuFromStartMenu); // Display party menu
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-05 13:01:24 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuBagCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
2017-09-05 13:01:24 +02:00
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2018-03-28 21:09:27 +02:00
|
|
|
SetMainCallback2(CB2_BagMenuFromStartMenu); // Display bag menu
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuPokeNavCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2019-03-02 09:18:08 +01:00
|
|
|
SetMainCallback2(CB2_InitPokeNav); // Display PokeNav
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuPlayerNameCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2019-02-10 09:54:50 +01:00
|
|
|
if (IsUpdateLinkStateCBActive() || InUnionRoom())
|
2019-01-20 18:24:35 +01:00
|
|
|
ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
|
2018-03-28 00:33:08 +02:00
|
|
|
else if (FlagGet(FLAG_SYS_FRONTIER_PASS))
|
2019-01-26 14:50:24 +01:00
|
|
|
ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2019-01-20 18:24:35 +01:00
|
|
|
ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuSaveCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (InBattlePyramid())
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
gMenuCallback = SaveStartCallback; // Display save menu
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuOptionCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2018-03-28 21:09:27 +02:00
|
|
|
SetMainCallback2(CB2_InitOptionMenu); // Display option menu
|
2018-03-28 00:33:08 +02:00
|
|
|
gMain.savedCallback = CB2_ReturnToFieldWithOpenMenu;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuExitCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-03-28 21:09:27 +02:00
|
|
|
HideStartMenu(); // Hide start menu
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuSafariZoneRetireCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-03-28 21:09:27 +02:00
|
|
|
HideStartMenu();
|
2018-03-28 00:33:08 +02:00
|
|
|
SafariZoneRetirePrompt();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuLinkModePlayerNameCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2019-02-27 04:04:44 +01:00
|
|
|
ShowTrainerCardInLink(gLocalLinkPlayerId, CB2_ReturnToFieldWithOpenMenu);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuBattlePyramidRetireCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
gMenuCallback = BattlePyramidRetireStartCallback; // Confirm retire
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-11 09:28:55 +01:00
|
|
|
// Functionally unused
|
|
|
|
void ShowBattlePyramidStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrameToTransparent(0, FALSE);
|
2019-11-21 04:55:44 +01:00
|
|
|
ScriptUnfreezeObjectEvents();
|
2019-12-11 09:28:55 +01:00
|
|
|
CreateStartMenuTask(Task_ShowStartMenu);
|
2018-03-28 00:33:08 +02:00
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
static bool8 StartMenuBattlePyramidBagCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2018-08-30 20:10:57 +02:00
|
|
|
SetMainCallback2(CB2_PyramidBagMenuFromStartMenu);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 SaveStartCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
InitSave();
|
|
|
|
gMenuCallback = SaveCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 SaveCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
switch (RunSaveCallback())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case SAVE_IN_PROGRESS:
|
2017-09-05 13:01:24 +02:00
|
|
|
return FALSE;
|
2018-03-28 21:09:27 +02:00
|
|
|
case SAVE_CANCELED: // Back to start menu
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrameToTransparent(0, FALSE);
|
2018-03-28 00:33:08 +02:00
|
|
|
InitStartMenu();
|
|
|
|
gMenuCallback = HandleStartMenuInput;
|
|
|
|
return FALSE;
|
|
|
|
case SAVE_SUCCESS:
|
2018-03-28 21:09:27 +02:00
|
|
|
case SAVE_ERROR: // Close start menu
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
2019-11-21 04:55:44 +01:00
|
|
|
ScriptUnfreezeObjectEvents();
|
2018-03-28 00:33:08 +02:00
|
|
|
ScriptContext2_Disable();
|
2019-02-07 18:37:28 +01:00
|
|
|
SoftResetInBattlePyramid();
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 BattlePyramidRetireStartCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
InitBattlePyramidRetire();
|
|
|
|
gMenuCallback = BattlePyramidRetireCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 BattlePyramidRetireReturnCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
InitStartMenu();
|
|
|
|
gMenuCallback = HandleStartMenuInput;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 BattlePyramidRetireCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
switch (RunSaveCallback())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
case SAVE_SUCCESS: // No (Stay in battle pyramid)
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveExtraStartMenuWindows();
|
2018-03-28 21:09:27 +02:00
|
|
|
gMenuCallback = BattlePyramidRetireReturnCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
case SAVE_IN_PROGRESS:
|
|
|
|
return FALSE;
|
2018-03-28 21:09:27 +02:00
|
|
|
case SAVE_CANCELED: // Yes (Retire from battle pyramid)
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrameToTransparent(0, TRUE);
|
2019-11-21 04:55:44 +01:00
|
|
|
ScriptUnfreezeObjectEvents();
|
2018-03-28 00:33:08 +02:00
|
|
|
ScriptContext2_Disable();
|
2019-12-11 09:28:55 +01:00
|
|
|
ScriptContext1_SetupScript(BattlePyramid_Retire);
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void InitSave(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
save_serialize_map();
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveConfirmSaveCallback;
|
2018-03-28 15:45:35 +02:00
|
|
|
sSavingComplete = FALSE;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 RunSaveCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
// True if text is still printing
|
2018-09-14 19:15:46 +02:00
|
|
|
if (RunTextPrintersAndIsPrinter0Active() == TRUE)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
sSavingComplete = FALSE;
|
|
|
|
return sSaveDialogCallback();
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2019-12-11 09:28:55 +01:00
|
|
|
void SaveGame(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
InitSave();
|
|
|
|
CreateTask(SaveGameTask, 0x50);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, message);
|
|
|
|
sub_819786C(0, TRUE);
|
|
|
|
AddTextPrinterForMessage_2(TRUE);
|
2018-03-28 15:45:35 +02:00
|
|
|
sSavingComplete = TRUE;
|
|
|
|
sSaveDialogCallback = saveCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void SaveGameTask(u8 taskId)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
u8 status = RunSaveCallback();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
switch (status)
|
|
|
|
{
|
|
|
|
case SAVE_CANCELED:
|
|
|
|
case SAVE_ERROR:
|
|
|
|
gSpecialVar_Result = 0;
|
|
|
|
break;
|
|
|
|
case SAVE_SUCCESS:
|
|
|
|
gSpecialVar_Result = status;
|
|
|
|
break;
|
|
|
|
case SAVE_IN_PROGRESS:
|
|
|
|
return;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
|
2021-03-21 05:54:24 +01:00
|
|
|
static void HideSaveMessageWindow(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, TRUE);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void HideSaveInfoWindow(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
RemoveSaveInfoWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void SaveStartTimer(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
sSaveDialogTimer = 60;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 SaveSuccesTimer(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
sSaveDialogTimer--;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(A_BUTTON))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SELECT);
|
2018-03-28 00:33:08 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
if (sSaveDialogTimer == 0)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static bool8 SaveErrorTimer(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
if (sSaveDialogTimer != 0)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 15:45:35 +02:00
|
|
|
sSaveDialogTimer--;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_HELD(A_BUTTON))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveConfirmSaveCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE);
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveStartMenuWindow();
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveInfoWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
if (InBattlePyramid())
|
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_BattlePyramidConfirmRest, SaveYesNoCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_ConfirmSave, SaveYesNoCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 15:45:35 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveYesNoCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes(); // Show Yes/No menu
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveConfirmInputCallback;
|
2018-03-28 15:45:35 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveConfirmInputCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-11-05 21:45:54 +01:00
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0: // Yes
|
|
|
|
switch (gSaveFileStatus)
|
|
|
|
{
|
2020-01-12 21:27:37 +01:00
|
|
|
case SAVE_STATUS_EMPTY:
|
|
|
|
case SAVE_STATUS_CORRUPT:
|
2018-03-28 00:33:08 +02:00
|
|
|
if (gDifferentSaveFile == FALSE)
|
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveFileExistsCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveSavingMessageCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
default:
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveFileExistsCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
case -1: // B Button
|
|
|
|
case 1: // No
|
2018-03-28 21:09:27 +02:00
|
|
|
HideSaveInfoWindow();
|
2021-03-21 05:54:24 +01:00
|
|
|
HideSaveMessageWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_CANCELED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A different save file exists
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveFileExistsCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (gDifferentSaveFile == TRUE)
|
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteDefaultNoCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_AlreadySavedFile, SaveConfirmOverwriteCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
static u8 SaveConfirmOverwriteDefaultNoCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default)
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveOverwriteInputCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveConfirmOverwriteCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes(); // Show Yes/No menu
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveOverwriteInputCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveOverwriteInputCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-11-05 21:45:54 +01:00
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0: // Yes
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = SaveSavingMessageCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
case -1: // B Button
|
|
|
|
case 1: // No
|
2018-03-28 21:09:27 +02:00
|
|
|
HideSaveInfoWindow();
|
2021-03-21 05:54:24 +01:00
|
|
|
HideSaveMessageWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_CANCELED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveSavingMessageCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_SavingDontTurnOff, SaveDoSaveCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveDoSaveCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
u8 saveStatus;
|
|
|
|
|
|
|
|
IncrementGameStat(GAME_STAT_SAVED_GAME);
|
2019-12-11 09:28:55 +01:00
|
|
|
PausePyramidChallenge();
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
if (gDifferentSaveFile == TRUE)
|
|
|
|
{
|
|
|
|
saveStatus = TrySavingData(SAVE_OVERWRITE_DIFFERENT_FILE);
|
|
|
|
gDifferentSaveFile = FALSE;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
saveStatus = TrySavingData(SAVE_NORMAL);
|
|
|
|
}
|
|
|
|
|
2020-01-12 21:27:37 +01:00
|
|
|
if (saveStatus == SAVE_STATUS_OK)
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_PlayerSavedGame, SaveSuccessCallback);
|
2020-01-12 21:27:37 +01:00
|
|
|
else
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_SaveError, SaveErrorCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
SaveStartTimer();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveSuccessCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!IsTextPrinterActive(0))
|
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SAVE);
|
|
|
|
sSaveDialogCallback = SaveReturnSuccessCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveReturnSuccessCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
if (!IsSEPlaying() && SaveSuccesTimer())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
HideSaveInfoWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_SUCCESS;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveErrorCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
if (!IsTextPrinterActive(0))
|
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_BOO);
|
|
|
|
sSaveDialogCallback = SaveReturnErrorCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 SaveReturnErrorCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-06-17 12:30:09 +02:00
|
|
|
if (!SaveErrorTimer())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
return SAVE_IN_PROGRESS;
|
2017-09-05 13:01:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
HideSaveInfoWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void InitBattlePyramidRetire(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = BattlePyramidConfirmRetireCallback;
|
2018-03-28 15:45:35 +02:00
|
|
|
sSavingComplete = FALSE;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 BattlePyramidConfirmRetireCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE);
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveStartMenuWindow();
|
2018-03-28 21:09:27 +02:00
|
|
|
ShowSaveMessage(gText_BattlePyramidConfirmRetire, BattlePyramidRetireYesNoCallback);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 BattlePyramidRetireYesNoCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default)
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveDialogCallback = BattlePyramidRetireInputCallback;
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static u8 BattlePyramidRetireInputCallback(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-11-05 21:45:54 +01:00
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0: // Yes
|
|
|
|
return SAVE_CANCELED;
|
|
|
|
case -1: // B Button
|
|
|
|
case 1: // No
|
2021-03-21 05:54:24 +01:00
|
|
|
HideSaveMessageWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_SUCCESS;
|
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
return SAVE_IN_PROGRESS;
|
|
|
|
}
|
|
|
|
|
2021-03-21 05:54:24 +01:00
|
|
|
static void VBlankCB_LinkBattleSave(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
switch (*state)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0);
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
DmaClear16(3, PLTT, PLTT_SIZE);
|
2021-03-21 05:54:24 +01:00
|
|
|
DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000);
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ResetSpriteData();
|
|
|
|
ResetTasks();
|
|
|
|
ResetPaletteFade();
|
|
|
|
ScanlineEffect_Clear();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2021-03-21 05:54:24 +01:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates_LinkBattleSave, ARRAY_COUNT(sBgTemplates_LinkBattleSave));
|
|
|
|
InitWindows(sWindowTemplates_LinkBattleSave);
|
2018-07-16 20:23:05 +02:00
|
|
|
LoadUserWindowBorderGfx_(0, 8, 224);
|
2019-04-01 00:59:52 +02:00
|
|
|
Menu_LoadStdPalAt(240);
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ShowBg(0);
|
|
|
|
BlendPalettes(-1, 16, 0);
|
2021-03-21 05:54:24 +01:00
|
|
|
SetVBlankCallback(VBlankCB_LinkBattleSave);
|
2018-03-28 00:33:08 +02:00
|
|
|
EnableInterrupts(1);
|
|
|
|
break;
|
|
|
|
case 4:
|
2017-09-05 13:01:24 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
(*state)++;
|
2018-03-28 00:33:08 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
void CB2_SetUpSaveAfterLinkBattle(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
if (InitSaveWindowAfterLinkBattle(&gMain.state))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
CreateTask(Task_SaveAfterLinkBattle, 0x50);
|
|
|
|
SetMainCallback2(CB2_SaveAfterLinkBattle);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
static void CB2_SaveAfterLinkBattle(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
static void Task_SaveAfterLinkBattle(u8 taskId)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
s16 *state = gTasks[taskId].data;
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
switch (*state)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
case 0:
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized2(0,
|
2018-06-17 12:30:09 +02:00
|
|
|
1,
|
2018-03-28 00:33:08 +02:00
|
|
|
gText_SavingDontTurnOffPower,
|
2020-06-04 00:00:53 +02:00
|
|
|
TEXT_SPEED_FF,
|
2018-03-28 00:33:08 +02:00
|
|
|
NULL,
|
2020-06-04 00:00:53 +02:00
|
|
|
TEXT_COLOR_DARK_GREY,
|
|
|
|
TEXT_COLOR_WHITE,
|
|
|
|
TEXT_COLOR_LIGHT_GREY);
|
2019-04-01 00:59:52 +02:00
|
|
|
DrawTextBorderOuter(0, 8, 14);
|
2018-03-28 00:33:08 +02:00
|
|
|
PutWindowTilemap(0);
|
|
|
|
CopyWindowToVram(0, 3);
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
if (gWirelessCommType != 0 && InUnionRoom())
|
|
|
|
{
|
2020-06-08 06:45:06 +02:00
|
|
|
if (Link_AnyPartnersPlayingFRLG_JP())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 1;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
2018-06-17 12:30:09 +02:00
|
|
|
else
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 5;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSoftResetDisabled = 1;
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 1;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-27 23:30:47 +01:00
|
|
|
SetContinueGameWarpStatusToDynamicWarp();
|
2019-02-11 02:42:50 +01:00
|
|
|
FullSaveGame();
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 2;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-02-11 02:42:50 +01:00
|
|
|
if (CheckSaveFile())
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
ClearContinueGameWarpStatus2();
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 3;
|
2018-03-28 00:33:08 +02:00
|
|
|
gSoftResetDisabled = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 4;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
SetMainCallback2(gMain.savedCallback);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-06-04 00:00:53 +02:00
|
|
|
CreateTask(Task_LinkSave, 5);
|
|
|
|
*state = 6;
|
2018-03-28 00:33:08 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-06-04 00:00:53 +02:00
|
|
|
if (!FuncIsActiveTask(Task_LinkSave))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
*state = 3;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void ShowSaveInfoWindow(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-29 02:16:02 +02:00
|
|
|
struct WindowTemplate saveInfoWindow = sSaveInfoWindowTemplate;
|
2018-03-28 00:33:08 +02:00
|
|
|
u8 gender;
|
|
|
|
u8 color;
|
|
|
|
u32 xOffset;
|
|
|
|
u32 yOffset;
|
2018-06-17 12:30:09 +02:00
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
if (!FlagGet(FLAG_SYS_POKEDEX_GET))
|
|
|
|
{
|
|
|
|
saveInfoWindow.height -= 2;
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
sSaveInfoWindowId = AddWindow(&saveInfoWindow);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdWindowFrame(sSaveInfoWindowId, FALSE);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
gender = gSaveBlock2Ptr->playerGender;
|
2018-03-28 21:09:27 +02:00
|
|
|
color = TEXT_COLOR_RED; // Red when female, blue when male.
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
if (gender == MALE)
|
2018-06-17 12:30:09 +02:00
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
color = TEXT_COLOR_BLUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print region name
|
|
|
|
yOffset = 1;
|
2020-02-07 18:48:47 +01:00
|
|
|
BufferSaveMenuText(SAVE_MENU_LOCATION, gStringVar4, TEXT_COLOR_GREEN);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, 0, yOffset, 0xFF, NULL);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
// Print player name
|
2020-02-07 18:48:47 +01:00
|
|
|
yOffset += 16;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingPlayer, 0, yOffset, 0xFF, NULL);
|
2020-02-07 18:48:47 +01:00
|
|
|
BufferSaveMenuText(SAVE_MENU_NAME, gStringVar4, color);
|
2018-03-28 00:33:08 +02:00
|
|
|
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70);
|
2018-03-28 21:09:27 +02:00
|
|
|
PrintPlayerNameOnWindow(sSaveInfoWindowId, gStringVar4, xOffset, yOffset);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
// Print badge count
|
2020-02-07 18:48:47 +01:00
|
|
|
yOffset += 16;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingBadges, 0, yOffset, 0xFF, NULL);
|
2020-02-07 18:48:47 +01:00
|
|
|
BufferSaveMenuText(SAVE_MENU_BADGES, gStringVar4, color);
|
2018-03-28 00:33:08 +02:00
|
|
|
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
|
|
|
if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE)
|
|
|
|
{
|
|
|
|
// Print pokedex count
|
2020-02-07 18:48:47 +01:00
|
|
|
yOffset += 16;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingPokedex, 0, yOffset, 0xFF, NULL);
|
2020-02-07 18:48:47 +01:00
|
|
|
BufferSaveMenuText(SAVE_MENU_CAUGHT, gStringVar4, color);
|
2018-03-28 00:33:08 +02:00
|
|
|
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print play time
|
2020-02-07 18:48:47 +01:00
|
|
|
yOffset += 16;
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingTime, 0, yOffset, 0xFF, NULL);
|
2020-02-07 18:48:47 +01:00
|
|
|
BufferSaveMenuText(SAVE_MENU_PLAY_TIME, gStringVar4, color);
|
2018-03-28 00:33:08 +02:00
|
|
|
xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL);
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
CopyWindowToVram(sSaveInfoWindowId, 2);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void RemoveSaveInfoWindow(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(sSaveInfoWindowId, FALSE);
|
2018-03-28 21:09:27 +02:00
|
|
|
RemoveWindow(sSaveInfoWindowId);
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
static void Task_WaitForBattleTowerLinkSave(u8 taskId)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
if (!FuncIsActiveTask(Task_LinkSave))
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
#define tPartialSave data[2]
|
|
|
|
|
|
|
|
void SaveForBattleTowerLink(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2020-06-04 00:00:53 +02:00
|
|
|
u8 taskId = CreateTask(Task_LinkSave, 5);
|
|
|
|
gTasks[taskId].tPartialSave = TRUE;
|
|
|
|
gTasks[CreateTask(Task_WaitForBattleTowerLinkSave, 6)].data[1] = taskId;
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 00:00:53 +02:00
|
|
|
#undef tPartialSave
|
|
|
|
|
2018-03-28 21:09:27 +02:00
|
|
|
static void HideStartMenuWindow(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
|
2018-03-29 02:16:02 +02:00
|
|
|
RemoveStartMenuWindow();
|
2019-11-21 04:55:44 +01:00
|
|
|
ScriptUnfreezeObjectEvents();
|
2018-03-28 00:33:08 +02:00
|
|
|
ScriptContext2_Disable();
|
|
|
|
}
|
|
|
|
|
2019-12-11 09:28:55 +01:00
|
|
|
void HideStartMenu(void)
|
2018-03-28 00:33:08 +02:00
|
|
|
{
|
2018-03-28 21:09:27 +02:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
HideStartMenuWindow();
|
2018-03-28 00:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppendToList(u8 *list, u8 *pos, u8 newEntry)
|
|
|
|
{
|
|
|
|
list[*pos] = newEntry;
|
|
|
|
(*pos)++;
|
2018-06-17 12:30:09 +02:00
|
|
|
}
|