2018-03-12 09:26:20 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "constants/songs.h"
|
2018-03-15 11:37:24 +01:00
|
|
|
#include "bg.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "decoration.h"
|
|
|
|
#include "event_scripts.h"
|
|
|
|
#include "field_fadetransition.h"
|
2018-06-11 15:34:19 +02:00
|
|
|
#include "event_object_movement.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "field_screen.h"
|
|
|
|
#include "field_weather.h"
|
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "item.h"
|
2018-03-15 11:37:24 +01:00
|
|
|
#include "item_icon.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "item_menu.h"
|
|
|
|
#include "constants/items.h"
|
2018-03-13 10:11:39 +01:00
|
|
|
#include "list_menu.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "mail.h"
|
|
|
|
#include "main.h"
|
2018-03-13 10:11:39 +01:00
|
|
|
#include "malloc.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
2018-03-19 11:27:33 +01:00
|
|
|
#include "party_menu.h"
|
|
|
|
#include "pokenav.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "player_pc.h"
|
|
|
|
#include "script.h"
|
|
|
|
#include "sound.h"
|
2018-03-15 11:37:24 +01:00
|
|
|
#include "sprite.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "window.h"
|
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
// structures
|
2018-03-13 10:11:39 +01:00
|
|
|
struct Struct203BCC4
|
|
|
|
{
|
|
|
|
struct ListMenuItem unk0[51];
|
|
|
|
u8 unk198[51][0x18];
|
2018-03-15 11:37:24 +01:00
|
|
|
u8 windowIds[6];
|
2018-03-13 10:11:39 +01:00
|
|
|
u8 unk666;
|
2018-03-15 11:37:24 +01:00
|
|
|
u8 spriteId;
|
|
|
|
u8 spriteIds[7];
|
2018-03-13 10:11:39 +01:00
|
|
|
};
|
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
// static functions
|
2018-03-19 11:27:33 +01:00
|
|
|
static void InitPlayerPCMenu(u8 taskId);
|
|
|
|
static void PlayerPCProcessMenuInput(u8 taskId);
|
|
|
|
static void InitItemStorageMenu(u8 taskId, u8 var);
|
|
|
|
|
|
|
|
static u8 GetMailboxMailCount(void);
|
|
|
|
static void Mailbox_UpdateMailList(void);
|
|
|
|
static void Mailbox_DrawMailboxMenu(u8 taskId);
|
|
|
|
static void Mailbox_ProcessInput(u8 taskId);
|
|
|
|
static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId);
|
|
|
|
static void Mailbox_ReturnToPlayerPC(u8);
|
|
|
|
static void Mailbox_PrintMailOptions(u8 taskId);
|
|
|
|
static void Mailbox_MailOptionsProcessInput(u8 taskId);
|
|
|
|
|
|
|
|
static void PlayerPC_ItemStorage(u8 taskId);
|
|
|
|
static void PlayerPC_Mailbox(u8 taskId);
|
|
|
|
static void PlayerPC_Decoration(u8 var);
|
|
|
|
static void PlayerPC_TurnOff(u8 taskId);
|
|
|
|
|
|
|
|
static void Mailbox_DoMailMoveToBag(u8 taskId);
|
|
|
|
static void Mailbox_DoMailRead(u8 taskId);
|
|
|
|
static void Mailbox_MoveToBag(u8 taskId);
|
|
|
|
static void Mailbox_Give(u8 taskId);
|
|
|
|
static void Mailbox_Cancel(u8 taskId);
|
|
|
|
|
|
|
|
static void Mailbox_CancelMoveToBag(u8 taskId);
|
|
|
|
static void Mailbox_MoveToBagYesNoPrompt(u8 taskId);
|
|
|
|
static void Mailbox_DrawYesNoBeforeMove(u8 taskId);
|
|
|
|
static void Mailbox_DoGiveMailPokeMenu(u8 taskId);
|
|
|
|
static void Mailbox_NoPokemonForMail(u8 taskId);
|
|
|
|
|
|
|
|
static void Mailbox_FadeAndReadMail(u8 taskId);
|
|
|
|
static void Mailbox_ReturnToFieldFromReadMail(void);
|
|
|
|
static void Mailbox_DoRedrawMailboxMenuAfterReturn(void);
|
|
|
|
static void pal_fill_for_maplights_or_black(void);
|
|
|
|
static void Mailbox_HandleReturnToProcessInput(u8 taskId);
|
2018-03-19 11:45:13 +01:00
|
|
|
static void Mailbox_UpdateMailListAfterDeposit(void);
|
2018-03-19 11:27:33 +01:00
|
|
|
|
|
|
|
static void ItemStorage_Withdraw(u8 taskId);
|
|
|
|
static void ItemStorage_Deposit(u8 taskId);
|
|
|
|
static void ItemStorage_Toss(u8 taskId);
|
|
|
|
static void ItemStorage_Exit(u8 taskId);
|
|
|
|
static void ItemStorage_ResumeInputFromYesToss(u8 taskId);
|
|
|
|
static void ItemStorage_ResumeInputFromNoToss(u8 taskId);
|
|
|
|
|
|
|
|
static void ItemStorageMenuPrint(const u8 *);
|
|
|
|
static void ItemStorageMenuProcessInput(u8 taskId);
|
|
|
|
static void ItemStorage_ProcessWithdrawTossInput(u8 taskId);
|
|
|
|
static void ItemStorage_SetItemAndMailCount(u8);
|
|
|
|
static void ItemStorage_HandleReturnToProcessInput(u8 taskId);
|
|
|
|
|
|
|
|
static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss);
|
|
|
|
static void Task_ItemStorage_Deposit(u8 taskId);
|
|
|
|
static void ItemStorage_DoItemWithdraw(u8 taskId);
|
|
|
|
static void ItemStorage_DoItemToss(u8 taskid);
|
|
|
|
static void ItemStorage_HandleQuantityRolling(u8 taskid);
|
|
|
|
static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId);
|
|
|
|
static void ItemStorage_ItemSwapChoosePrompt(u8 taskId);
|
|
|
|
static void ItemStorage_DoItemAction(u8 taskId);
|
|
|
|
static void ItemStorage_ProcessInput(u8 taskId);
|
|
|
|
static void ItemStorage_DoItemSwap(u8 taskId, bool8 a);
|
|
|
|
static void ItemStorage_HandleRemoveItem(u8 taskId);
|
|
|
|
static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId);
|
|
|
|
static void ItemStorage_StartScrollIndicatorAndProcessInput(u8 taskId);
|
|
|
|
|
|
|
|
static const u8* ItemStorage_GetItemPcResponse(u16);
|
|
|
|
static void CopyItemName_PlayerPC(u8 *string, u16 itemId);
|
|
|
|
|
|
|
|
static void sub_816BC14(void);
|
|
|
|
static void sub_816BFE0(u8 y, u8, u8 speed);
|
|
|
|
static void sub_816BCC4(u8);
|
|
|
|
static void sub_816C690(u8);
|
|
|
|
static void sub_816C4FC(u8 taskId);
|
|
|
|
static void sub_816C0C8(void);
|
|
|
|
static void sub_816C060(u16 itemId);
|
|
|
|
static void sub_816BEF0(s32 id);
|
|
|
|
static void sub_816B4DC(u8 taskId);
|
2018-03-19 11:45:13 +01:00
|
|
|
static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu * thisMenu);
|
2018-03-19 11:27:33 +01:00
|
|
|
static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset);
|
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
// EWRAM
|
2018-03-19 11:27:33 +01:00
|
|
|
static EWRAM_DATA const u8 *gPcItemMenuOptionOrder = NULL;
|
2018-03-12 09:26:20 +01:00
|
|
|
static EWRAM_DATA u8 gPcItemMenuOptionsNum = 0;
|
2018-03-19 11:27:33 +01:00
|
|
|
EWRAM_DATA struct PlayerPCItemPageStruct playerPCItemPageInfo = {0, 0, 0, 0, {0, 0, 0}, 0};
|
|
|
|
static EWRAM_DATA struct Struct203BCC4 *gUnknown_0203BCC4 = NULL;
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
// .rodata
|
2018-03-19 11:27:33 +01:00
|
|
|
static const u8 *const gPCText_OptionDescList[] =
|
|
|
|
{
|
|
|
|
gText_TakeOutItemsFromPC,
|
|
|
|
gText_StoreItemsInPC,
|
|
|
|
gText_ThrowAwayItemsInPC,
|
|
|
|
gText_GoBackPrevMenu,
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct MenuAction sPlayerPCMenuActions[] =
|
|
|
|
{
|
|
|
|
{ gText_ItemStorage, PlayerPC_ItemStorage },
|
|
|
|
{ gText_Mailbox, PlayerPC_Mailbox },
|
|
|
|
{ gText_Decoration, PlayerPC_Decoration },
|
|
|
|
{ gText_TurnOff, PlayerPC_TurnOff }
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const u8 gBedroomPC_OptionOrder[] =
|
|
|
|
{
|
|
|
|
PLAYERPC_MENU_ITEMSTORAGE,
|
|
|
|
PLAYERPC_MENU_MAILBOX,
|
|
|
|
PLAYERPC_MENU_DECORATION,
|
|
|
|
PLAYERPC_MENU_TURNOFF
|
|
|
|
};
|
2018-03-13 10:11:39 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const u8 gPlayerPC_OptionOrder[] =
|
|
|
|
{
|
|
|
|
PLAYERPC_MENU_ITEMSTORAGE,
|
|
|
|
PLAYERPC_MENU_MAILBOX,
|
|
|
|
PLAYERPC_MENU_TURNOFF
|
|
|
|
};
|
2018-03-13 10:11:39 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct MenuAction gPCText_ItemPCOptionsText[] =
|
|
|
|
{
|
|
|
|
{ gText_WithdrawItem, ItemStorage_Withdraw },
|
|
|
|
{ gText_DepositItem, ItemStorage_Deposit },
|
|
|
|
{ gText_TossItem, ItemStorage_Toss },
|
|
|
|
{ gText_Cancel, ItemStorage_Exit }
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct ItemSlot gNewGamePCItems[] =
|
|
|
|
{
|
|
|
|
{ ITEM_POTION, 1 },
|
|
|
|
{ ITEM_NONE, 0 }
|
|
|
|
};
|
2018-03-13 10:11:39 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
const struct MenuAction gMailboxMailOptions[] =
|
|
|
|
{
|
|
|
|
{ gText_Read, Mailbox_DoMailRead },
|
|
|
|
{ gText_MoveToBag, Mailbox_MoveToBag },
|
|
|
|
{ gText_Give2, Mailbox_Give },
|
|
|
|
{ gText_Cancel2, Mailbox_Cancel }
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct WindowTemplate gUnknown_085DFF24[3] =
|
|
|
|
{
|
|
|
|
{0x00, 0x01, 0x01, 0x09, 0x06, 0x0F, 0x0001},
|
|
|
|
{0x00, 0x01, 0x01, 0x09, 0x08, 0x0F, 0x0001},
|
|
|
|
{0x00, 0x01, 0x01, 0x0A, 0x08, 0x0F, 0x0001}
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
static const struct YesNoFuncTable ResumeFromWithdrawYesNoFuncList = // ResumeFromWithdrawYesNoFuncList
|
2018-03-19 11:27:33 +01:00
|
|
|
{
|
|
|
|
ItemStorage_ResumeInputFromYesToss,
|
|
|
|
ItemStorage_ResumeInputFromNoToss
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct ListMenuTemplate gUnknown_085DFF44 = {
|
|
|
|
NULL,
|
2018-03-19 11:45:13 +01:00
|
|
|
ItemStorage_MoveCursor,
|
2018-03-19 11:27:33 +01:00
|
|
|
fish4_goto_x5_or_x6,
|
|
|
|
0, 0,
|
|
|
|
0, 0, 8, 0,
|
|
|
|
9, 2, 1, 3, FALSE, 0, FALSE, 7
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct WindowTemplate gUnknown_085DFF5C[5] =
|
|
|
|
{
|
|
|
|
{0x00, 0x10, 0x01, 0x0D, 0x12, 0x0F, 0x0001},
|
|
|
|
{0x00, 0x01, 0x0D, 0x0D, 0x06, 0x0F, 0x00EB},
|
|
|
|
{0x00, 0x01, 0x08, 0x03, 0x03, 0x0F, 0x0153},
|
|
|
|
{0x00, 0x01, 0x01, 0x0D, 0x02, 0x0F, 0x0139},
|
|
|
|
{0x00, 0x08, 0x09, 0x06, 0x02, 0x0F, 0x015C}
|
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct WindowTemplate gUnknown_085DFF84 =
|
|
|
|
{
|
|
|
|
0x00, 0x09, 0x07, 0x05, 0x04, 0x0F, 0x0168
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 gUnknown_085DFF8C[] = {0x01, 0x03, 0x02, 0x00};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
// text
|
2018-03-12 09:26:20 +01:00
|
|
|
void NewGameInitPCItems(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
// because Game Freak don't know how to use a struct or a 2d array
|
|
|
|
for(i = 0, ClearItemSlots(gSaveBlock1Ptr->pcItems, ARRAY_COUNT(gSaveBlock1Ptr->pcItems)); NEW_GAME_PC_ITEMS(i, PC_ITEM_ID) && NEW_GAME_PC_ITEMS(i, PC_QUANTITY) &&
|
|
|
|
AddPCItem(NEW_GAME_PC_ITEMS(i, PC_ITEM_ID), NEW_GAME_PC_ITEMS(i, PC_QUANTITY)) == TRUE; i++);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BedroomPC(void)
|
|
|
|
{
|
|
|
|
gPcItemMenuOptionOrder = gBedroomPC_OptionOrder;
|
|
|
|
gPcItemMenuOptionsNum = 4;
|
|
|
|
DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerPC(void)
|
|
|
|
{
|
|
|
|
gPcItemMenuOptionOrder = gPlayerPC_OptionOrder;
|
|
|
|
gPcItemMenuOptionsNum = 3;
|
|
|
|
DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void InitPlayerPCMenu(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data;
|
|
|
|
struct WindowTemplate windowTemplate;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gPcItemMenuOptionsNum == 3)
|
|
|
|
windowTemplate = gUnknown_085DFF24[0];
|
|
|
|
else
|
|
|
|
windowTemplate = gUnknown_085DFF24[1];
|
|
|
|
windowTemplate.width = sub_81DB3D8(sPlayerPCMenuActions, gPcItemMenuOptionOrder, gPcItemMenuOptionsNum);
|
|
|
|
data[4] = AddWindow(&windowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(data[4], 0);
|
|
|
|
sub_81995E4(data[4], gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], gPcItemMenuOptionsNum, 0);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
gTasks[taskId].func = PlayerPCProcessMenuInput;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPCProcessMenuInput(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data;
|
|
|
|
s8 inputOptionId;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gPcItemMenuOptionsNum > 3)
|
|
|
|
inputOptionId = ProcessMenuInput();
|
|
|
|
else
|
|
|
|
inputOptionId = ProcessMenuInputNoWrapAround();
|
|
|
|
|
|
|
|
switch(inputOptionId)
|
|
|
|
{
|
|
|
|
case -2:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_8198070(data[4], FALSE);
|
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
gTasks[taskId].func = PlayerPC_TurnOff;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sub_8198070(data[4], FALSE);
|
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
gTasks[taskId].func = sPlayerPCMenuActions[gPcItemMenuOptionOrder[inputOptionId]].func.void_u8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReshowPlayerPC(u8 var)
|
|
|
|
{
|
|
|
|
DisplayItemMessageOnField(var, gText_WhatWouldYouLike, InitPlayerPCMenu);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPC_ItemStorage(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW);
|
|
|
|
gTasks[taskId].func = ItemStorageMenuProcessInput;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPC_Mailbox(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
playerPCItemPageInfo.count = GetMailboxMailCount();
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-15 11:37:24 +01:00
|
|
|
if (playerPCItemPageInfo.count == 0)
|
2018-03-12 09:26:20 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC);
|
|
|
|
else
|
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
playerPCItemPageInfo.cursorPos = 0;
|
|
|
|
playerPCItemPageInfo.itemsAbove = 0;
|
|
|
|
playerPCItemPageInfo.scrollIndicatorId = 0xFF;
|
2018-03-12 09:26:20 +01:00
|
|
|
Mailbox_UpdateMailList();
|
|
|
|
ItemStorage_SetItemAndMailCount(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
sub_8197434(0, 0);
|
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
gTasks[taskId].func = Mailbox_ProcessInput;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPC_Decoration(u8 var)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
sub_8126B2C(var); //DoPlayerPCDecoration(var);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPC_TurnOff(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling.
|
|
|
|
{
|
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
|
|
|
ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_1F863F);
|
|
|
|
else
|
|
|
|
ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_1F958F);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void InitItemStorageMenu(u8 taskId, u8 var)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data;
|
|
|
|
struct WindowTemplate windowTemplate;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
windowTemplate = gUnknown_085DFF24[2];
|
|
|
|
windowTemplate.width = GetMaxWidthInMenuTable(gPCText_ItemPCOptionsText, 4);
|
|
|
|
data[4] = AddWindow(&windowTemplate);
|
|
|
|
SetStandardWindowBorderStyle(data[4], 0);
|
|
|
|
PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
ItemStorageMenuPrint(gPCText_OptionDescList[var]);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorageMenuPrint(const u8 *textPtr)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
NewMenuHelpers_DrawDialogueFrame(0, 0);
|
|
|
|
PrintTextOnWindow(0, 1, textPtr, 0, 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorageMenuProcessInput(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
s8 r5;
|
|
|
|
s8 r2;
|
|
|
|
s8 inputOptionId;
|
|
|
|
|
|
|
|
r5 = GetMenuCursorPos();
|
|
|
|
inputOptionId = ProcessMenuInput();
|
|
|
|
r2 = GetMenuCursorPos();
|
|
|
|
switch(inputOptionId)
|
|
|
|
{
|
|
|
|
case -2:
|
|
|
|
if (r5 != r2)
|
|
|
|
ItemStorageMenuPrint(gPCText_OptionDescList[r2]);
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_Exit(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
gPCText_ItemPCOptionsText[inputOptionId].func.void_u8(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_Deposit(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
gTasks[taskId].func = Task_ItemStorage_Deposit;
|
|
|
|
FadeScreen(1, 0);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Task_ItemStorage_Deposit(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
overworld_free_bg_tilemaps();
|
|
|
|
sub_81AAC14();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_816B31C(void)
|
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
gFieldCallback = Mailbox_DoRedrawMailboxMenuAfterReturn;
|
2018-03-12 09:26:20 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
void Mailbox_DoRedrawMailboxMenuAfterReturn(void)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
sub_81973A4();
|
|
|
|
NewMenuHelpers_DrawDialogueFrame(0, 1);
|
|
|
|
InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1);
|
|
|
|
pal_fill_black();
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_HandleReturnToProcessInput(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2018-05-11 01:36:57 +02:00
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
2018-03-12 09:26:20 +01:00
|
|
|
gTasks[taskId].func = ItemStorageMenuProcessInput;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_Withdraw(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2018-04-29 13:36:26 +02:00
|
|
|
NUM_ITEMS = CountUsedPCItemSlots();
|
2018-03-12 09:26:20 +01:00
|
|
|
if (NUM_ITEMS != 0)
|
2018-03-13 10:11:39 +01:00
|
|
|
ItemStorage_WithdrawToss_Helper(taskId, FALSE);
|
2018-03-12 09:26:20 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_816B4DC(taskId);
|
|
|
|
DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_Toss(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2018-04-29 13:36:26 +02:00
|
|
|
NUM_ITEMS = CountUsedPCItemSlots();
|
2018-03-12 09:26:20 +01:00
|
|
|
if (NUM_ITEMS != 0)
|
2018-03-13 10:11:39 +01:00
|
|
|
ItemStorage_WithdrawToss_Helper(taskId, TRUE);
|
2018-03-12 09:26:20 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_816B4DC(taskId);
|
|
|
|
DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
data[3] = toss;
|
|
|
|
sub_816B4DC(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
playerPCItemPageInfo.cursorPos = 0;
|
|
|
|
playerPCItemPageInfo.itemsAbove = 0;
|
|
|
|
playerPCItemPageInfo.scrollIndicatorId = 0xFF;
|
2018-03-12 09:26:20 +01:00
|
|
|
ItemStorage_SetItemAndMailCount(taskId);
|
|
|
|
sub_816BC14();
|
|
|
|
gpu_pal_allocator_reset__manage_upper_four();
|
|
|
|
LoadListMenuArrowsGfx();
|
2018-03-15 11:37:24 +01:00
|
|
|
sub_8122344(gUnknown_0203BCC4->spriteIds, 7);
|
2018-03-12 09:26:20 +01:00
|
|
|
sub_8197434(0,0);
|
2018-03-19 11:27:33 +01:00
|
|
|
gTasks[taskId].func = ItemStorage_ProcessWithdrawTossInput;
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_Exit(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
sub_816B4DC(taskId);
|
|
|
|
ReshowPlayerPC(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_SetItemAndMailCount(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
if (playerPCItemPageInfo.count > 7)
|
|
|
|
playerPCItemPageInfo.pageItems = 8;
|
2018-03-12 09:26:20 +01:00
|
|
|
else
|
2018-03-15 11:37:24 +01:00
|
|
|
playerPCItemPageInfo.pageItems = playerPCItemPageInfo.count + 1;
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816B4DC(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
sub_8198070(data[4], FALSE);
|
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static u8 GetMailboxMailCount(void)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u8 i, j;
|
|
|
|
|
|
|
|
for(i = 0, j = 6; j < 16; j++)
|
|
|
|
if(gSaveBlock1Ptr->mail[j].itemId != 0)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_UpdateMailList(void)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
struct MailStruct mailBuffer;
|
|
|
|
u8 i, j;
|
|
|
|
|
|
|
|
for (i=6; i<15; i++)
|
|
|
|
{
|
|
|
|
for (j=i+1; j<16; j++)
|
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->mail[i].itemId == 0)
|
|
|
|
{
|
|
|
|
mailBuffer = gSaveBlock1Ptr->mail[i];
|
|
|
|
gSaveBlock1Ptr->mail[i] = gSaveBlock1Ptr->mail[j];
|
|
|
|
gSaveBlock1Ptr->mail[j] = mailBuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_DrawMailboxMenu(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u8 windowId;
|
|
|
|
|
|
|
|
windowId = sub_81D1C84(0);
|
|
|
|
sub_81D1C84(1);
|
|
|
|
PrintTextOnWindow(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2018-03-15 11:37:24 +01:00
|
|
|
gTasks[taskId].data[5] = sub_81D1DC0(&playerPCItemPageInfo);
|
|
|
|
sub_81D1E90(&playerPCItemPageInfo);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_ProcessInput(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u16 *data = gTasks[taskId].data;
|
|
|
|
s32 inputOptionId;
|
|
|
|
|
|
|
|
if(!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
inputOptionId = ListMenuHandleInputGetItemId(data[5]);
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-12 09:26:20 +01:00
|
|
|
|
|
|
|
switch(inputOptionId)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-15 11:37:24 +01:00
|
|
|
RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId);
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_ReturnToPlayerPC(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_81D1D04(0);
|
|
|
|
sub_81D1D04(1);
|
2018-03-19 11:45:13 +01:00
|
|
|
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-12 09:26:20 +01:00
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2018-03-15 11:37:24 +01:00
|
|
|
RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId);
|
2018-03-13 10:11:39 +01:00
|
|
|
gTasks[taskId].func = Mailbox_PrintWhatToDoWithPlayerMailText;
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
StringCopy(gStringVar1, gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos].playerName);
|
2018-03-12 09:26:20 +01:00
|
|
|
sub_81DB554(gStringVar1, 0);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail);
|
2018-03-13 10:11:39 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_ReturnToPlayerPC(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
sub_81D1D04(0);
|
|
|
|
sub_81D1D04(1);
|
2018-03-19 11:45:13 +01:00
|
|
|
DestroyListMenuTask(data[5], NULL, NULL);
|
2018-03-12 09:26:20 +01:00
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
sub_81D1EC0();
|
|
|
|
ReshowPlayerPC(taskId);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_PrintMailOptions(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
u8 r4 = sub_81D1C84(2);
|
2018-03-13 10:11:39 +01:00
|
|
|
PrintMenuTable(r4, 4, gMailboxMailOptions);
|
2018-03-12 09:26:20 +01:00
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2018-03-13 10:11:39 +01:00
|
|
|
gTasks[taskId].func = Mailbox_MailOptionsProcessInput;
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_MailOptionsProcessInput(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
s8 inputOptionId = ProcessMenuInput_other();
|
|
|
|
|
|
|
|
switch(inputOptionId)
|
|
|
|
{
|
|
|
|
case -2:
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_Cancel(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
2018-03-19 11:27:33 +01:00
|
|
|
|
2018-03-12 09:26:20 +01:00
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-13 10:11:39 +01:00
|
|
|
gMailboxMailOptions[inputOptionId].func.void_u8(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_DoMailRead(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
FadeScreen(1, 0);
|
2018-03-13 10:11:39 +01:00
|
|
|
gTasks[taskId].func = Mailbox_FadeAndReadMail;
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_FadeAndReadMail(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
if(!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
sub_81D1EC0();
|
|
|
|
overworld_free_bg_tilemaps();
|
2018-03-15 11:37:24 +01:00
|
|
|
ReadMail(&(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE);
|
2018-03-12 09:26:20 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_ReturnToFieldFromReadMail(void)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
gFieldCallback = pal_fill_for_maplights_or_black;
|
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void pal_fill_for_maplights_or_black(void)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
sub_81973A4();
|
|
|
|
taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0);
|
2018-03-15 11:37:24 +01:00
|
|
|
if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
else
|
|
|
|
DestroyTask(taskId);
|
|
|
|
pal_fill_black();
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_HandleReturnToProcessInput(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-05-11 01:36:57 +02:00
|
|
|
if(IsWeatherNotFadingIn() == TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
gTasks[taskId].func = Mailbox_ProcessInput;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_MoveToBag(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
DisplayItemMessageOnField(taskId, gText_MessageWillBeLost, Mailbox_DrawYesNoBeforeMove);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_DrawYesNoBeforeMove(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
sub_8197930();
|
|
|
|
gTasks[taskId].func = Mailbox_MoveToBagYesNoPrompt;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_MoveToBagYesNoPrompt(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
switch(ProcessMenuInputNoWrap_())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
Mailbox_DoMailMoveToBag(taskId);
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
case 1:
|
|
|
|
Mailbox_CancelMoveToBag(taskId);
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_DoMailMoveToBag(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]);
|
2018-03-13 10:11:39 +01:00
|
|
|
if(!AddBagItem(mailStruct->itemId, 1))
|
|
|
|
{
|
|
|
|
DisplayItemMessageOnField(taskId, gText_BagIsFull, Mailbox_Cancel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayItemMessageOnField(taskId, gText_MailToBagMessageErased, Mailbox_Cancel);
|
|
|
|
ClearMailStruct(mailStruct);
|
|
|
|
Mailbox_UpdateMailList();
|
2018-03-15 11:37:24 +01:00
|
|
|
playerPCItemPageInfo.count--;
|
|
|
|
if(playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove) && playerPCItemPageInfo.itemsAbove != 0)
|
|
|
|
playerPCItemPageInfo.itemsAbove--;
|
2018-03-13 10:11:39 +01:00
|
|
|
ItemStorage_SetItemAndMailCount(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_CancelMoveToBag(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
Mailbox_Cancel(taskId);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_Give(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
if(CalculatePlayerPartyCount() == 0)
|
|
|
|
Mailbox_NoPokemonForMail(taskId);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FadeScreen(1, 0);
|
|
|
|
gTasks[taskId].func = Mailbox_DoGiveMailPokeMenu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_DoGiveMailPokeMenu(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
if(!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
sub_81D1EC0();
|
|
|
|
overworld_free_bg_tilemaps();
|
|
|
|
sub_81B8448();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mailbox_ReturnToMailListAfterDeposit(void)
|
|
|
|
{
|
|
|
|
gFieldCallback = Mailbox_UpdateMailListAfterDeposit;
|
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_UpdateMailListAfterDeposit(void)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
u8 prevCount;
|
|
|
|
taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0);
|
2018-03-15 11:37:24 +01:00
|
|
|
prevCount = playerPCItemPageInfo.count;
|
|
|
|
playerPCItemPageInfo.count = GetMailboxMailCount();
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_UpdateMailList();
|
2018-03-15 11:37:24 +01:00
|
|
|
if(prevCount != playerPCItemPageInfo.count && (playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove))
|
|
|
|
&& playerPCItemPageInfo.itemsAbove != 0)
|
|
|
|
playerPCItemPageInfo.itemsAbove--;
|
2018-03-13 10:11:39 +01:00
|
|
|
ItemStorage_SetItemAndMailCount(taskId);
|
|
|
|
sub_81973A4();
|
2018-03-15 11:37:24 +01:00
|
|
|
if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
else
|
|
|
|
DestroyTask(taskId);
|
|
|
|
pal_fill_black();
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_NoPokemonForMail(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
DisplayItemMessageOnField(taskId, gText_NoPokemon, Mailbox_Cancel);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_Cancel(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
sub_81D1D04(2);
|
|
|
|
sub_8197434(0, 0);
|
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
gTasks[taskId].func = Mailbox_ProcessInput;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BC14(void)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
gUnknown_0203BCC4 = AllocZeroed(sizeof(struct Struct203BCC4));
|
2018-03-15 11:37:24 +01:00
|
|
|
memset(gUnknown_0203BCC4->windowIds, 0xFF, 0x6);
|
2018-03-13 10:11:39 +01:00
|
|
|
gUnknown_0203BCC4->unk666 = 0xFF;
|
2018-03-15 11:37:24 +01:00
|
|
|
gUnknown_0203BCC4->spriteId = 0xFF;
|
2018-03-13 10:11:39 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BC58(void)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for(i = 0; i < 6; i++)
|
|
|
|
sub_816BCC4(i);
|
|
|
|
Free(gUnknown_0203BCC4);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static u8 sub_816BC7C(u8 a)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]);
|
2018-03-13 10:11:39 +01:00
|
|
|
if(*windowIdLoc == 0xFF)
|
|
|
|
{
|
|
|
|
*windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]);
|
|
|
|
SetWindowBorderStyle(*windowIdLoc, FALSE, 0x214, 0xE);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
}
|
|
|
|
return *windowIdLoc;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BCC4(u8 a)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-03-15 11:37:24 +01:00
|
|
|
u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]);
|
2018-03-13 10:11:39 +01:00
|
|
|
if(*windowIdLoc != 0xFF)
|
|
|
|
{
|
|
|
|
sub_8198070(*windowIdLoc, FALSE);
|
|
|
|
ClearWindowTilemap(*windowIdLoc);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
|
|
|
RemoveWindow(*windowIdLoc);
|
|
|
|
*windowIdLoc = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
void ItemStorage_RefreshListMenu(void)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2018-03-15 11:37:24 +01:00
|
|
|
for(i = 0; i < playerPCItemPageInfo.count - 1; i++)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
CopyItemName_PlayerPC(&(gUnknown_0203BCC4->unk198[i][0]), gSaveBlock1Ptr->pcItems[i].itemId);
|
2018-03-13 10:11:39 +01:00
|
|
|
gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]);
|
|
|
|
gUnknown_0203BCC4->unk0[i].id = i;
|
|
|
|
}
|
|
|
|
StringCopy(&(gUnknown_0203BCC4->unk198[i][0]) ,gText_Cancel2);
|
|
|
|
gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]);
|
|
|
|
gUnknown_0203BCC4->unk0[i].id = -2;
|
|
|
|
gMultiuseListMenuTemplate = gUnknown_085DFF44;
|
2018-03-19 11:45:13 +01:00
|
|
|
gMultiuseListMenuTemplate.windowId = sub_816BC7C(0);
|
2018-03-15 11:37:24 +01:00
|
|
|
gMultiuseListMenuTemplate.totalItems = playerPCItemPageInfo.count;
|
2018-03-13 10:11:39 +01:00
|
|
|
gMultiuseListMenuTemplate.items = gUnknown_0203BCC4->unk0;
|
2018-03-15 11:37:24 +01:00
|
|
|
gMultiuseListMenuTemplate.maxShowed = playerPCItemPageInfo.pageItems;
|
2018-03-13 10:11:39 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
void CopyItemName_PlayerPC(u8 *string, u16 itemId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
CopyItemName(itemId, string);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:45:13 +01:00
|
|
|
static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu *thisMenu)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
if(b != TRUE)
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
if(gUnknown_0203BCC4->unk666 == 0xFF)
|
|
|
|
{
|
|
|
|
sub_816C0C8();
|
|
|
|
if(id != -2)
|
|
|
|
sub_816C060(gSaveBlock1Ptr->pcItems[id].itemId);
|
|
|
|
else
|
2018-03-15 11:37:24 +01:00
|
|
|
sub_816C060(ITEMPC_GO_BACK_TO_PREV);
|
2018-03-13 10:11:39 +01:00
|
|
|
sub_816BEF0(id);
|
|
|
|
}
|
|
|
|
}
|
2018-03-15 11:37:24 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
if(id != -2)
|
|
|
|
{
|
|
|
|
if(gUnknown_0203BCC4->unk666 != 0xFF)
|
|
|
|
{
|
|
|
|
if(gUnknown_0203BCC4->unk666 == (u8)id)
|
|
|
|
sub_816BFE0(yOffset, 0, 0xFF);
|
|
|
|
else
|
|
|
|
sub_816BFE0(yOffset, 0xFF, 0xFF);
|
|
|
|
}
|
|
|
|
ConvertIntToDecimalStringN(gStringVar1, gSaveBlock1Ptr->pcItems[id].quantity, STR_CONV_MODE_RIGHT_ALIGN, 3);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
|
|
|
PrintTextOnWindow(windowId, 7, gStringVar4, GetStringRightAlignXOffset(7, gStringVar4, 104), yOffset, 0xFF, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BEF0(s32 id)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
const u8* description;
|
|
|
|
u8 windowId = gUnknown_0203BCC4->windowIds[1];
|
|
|
|
|
|
|
|
if(id != -2)
|
|
|
|
description = (u8 *)ItemId_GetDescription(gSaveBlock1Ptr->pcItems[id].itemId);
|
|
|
|
else
|
2018-03-19 11:27:33 +01:00
|
|
|
description = ItemStorage_GetItemPcResponse(ITEMPC_GO_BACK_TO_PREV);
|
2018-03-15 11:37:24 +01:00
|
|
|
FillWindowPixelBuffer(windowId, 17);
|
|
|
|
PrintTextOnWindow(windowId, 1, description, 0, 1, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_StartScrollIndicator(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
if(playerPCItemPageInfo.scrollIndicatorId == 0xFF)
|
2018-07-15 13:23:38 +02:00
|
|
|
playerPCItemPageInfo.scrollIndicatorId = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xB0, 0xC, 0x94, playerPCItemPageInfo.count - playerPCItemPageInfo.pageItems, 0x13F8, 0x13F8, &(playerPCItemPageInfo.itemsAbove));
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_RemoveScrollIndicator(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
if(playerPCItemPageInfo.scrollIndicatorId != 0xFF)
|
|
|
|
{
|
|
|
|
RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId);
|
|
|
|
playerPCItemPageInfo.scrollIndicatorId = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BFB8(u8 a, u8 b, u8 speed)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
sub_816BFE0(ListMenuGetYCoordForPrintingArrowCursor(a), b, speed);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816BFE0(u8 y, u8 b, u8 speed)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
u8 windowId = gUnknown_0203BCC4->windowIds[0];
|
|
|
|
if(b == 0xFF)
|
|
|
|
FillWindowPixelRect(windowId, 17, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
|
|
|
|
else
|
|
|
|
AddTextPrinterParameterized2(windowId, 1, 0, y, 0, 0, gUnknown_085DFF8C, speed, gText_SelectorArrow2);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C060(u16 itemId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId);
|
|
|
|
|
|
|
|
if(*spriteIdLoc == 0xFF)
|
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(0x13F6);
|
|
|
|
FreeSpritePaletteByTag(0x13F6);
|
|
|
|
spriteId = AddItemIconSprite(0x13F6, 0x13F6, itemId);
|
|
|
|
if(spriteId != 64)
|
|
|
|
{
|
|
|
|
*spriteIdLoc = spriteId;
|
|
|
|
gSprites[spriteId].oam.priority = 0;
|
|
|
|
gSprites[spriteId].pos2.x = 24;
|
|
|
|
gSprites[spriteId].pos2.y = 80;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C0C8(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId);
|
|
|
|
if(*spriteIdLoc != 0xFF)
|
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(0x13F6);
|
|
|
|
FreeSpritePaletteByTag(0x13F6);
|
|
|
|
DestroySprite(&(gSprites[*spriteIdLoc]));
|
|
|
|
*spriteIdLoc = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C110(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2018-04-29 13:36:26 +02:00
|
|
|
CompactPCItems();
|
2018-03-15 11:37:24 +01:00
|
|
|
sub_812220C(gSaveBlock1Ptr->pcItems, 50, &(playerPCItemPageInfo.pageItems), &(playerPCItemPageInfo.count), 0x8);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C140(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
sub_812225C(&(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos), playerPCItemPageInfo.pageItems, playerPCItemPageInfo.count);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_ProcessWithdrawTossInput(u8 taskId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
bool32 toss;
|
|
|
|
u32 i, x;
|
|
|
|
u8 windowId;
|
|
|
|
const u8* text;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
for(i = 0; i <=3; i++)
|
|
|
|
sub_816BC7C(i);
|
|
|
|
toss = data[3];
|
|
|
|
text = gText_TossItem;
|
|
|
|
if(!toss)
|
|
|
|
text = gText_WithdrawItem;
|
|
|
|
x = GetStringCenterAlignXOffset(1, text, 104);
|
|
|
|
PrintTextOnWindow(gUnknown_0203BCC4->windowIds[3], 1, text, x, 1, 0, NULL);
|
|
|
|
CopyWindowToVram(gUnknown_0203BCC4->windowIds[2], 2);
|
|
|
|
sub_816C110();
|
|
|
|
sub_816C140();
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_RefreshListMenu();
|
2018-03-15 11:37:24 +01:00
|
|
|
data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_StartScrollIndicator();
|
2018-03-15 11:37:24 +01:00
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2018-03-19 11:27:33 +01:00
|
|
|
gTasks[taskId].func = ItemStorage_ProcessInput;
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const u8* ItemStorage_GetItemPcResponse(u16 itemId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
const u8 *string;
|
|
|
|
|
|
|
|
switch(itemId)
|
|
|
|
{
|
|
|
|
case ITEMPC_GO_BACK_TO_PREV:
|
|
|
|
string = gText_GoBackPrevMenu;
|
|
|
|
break;
|
|
|
|
case ITEMPC_HOW_MANY_TO_WITHDRAW:
|
|
|
|
string = gText_WithdrawHowManyItems;
|
|
|
|
break;
|
|
|
|
case ITEMPC_WITHDREW_THING:
|
|
|
|
string = gText_WithdrawXItems;
|
|
|
|
break;
|
|
|
|
case ITEMPC_HOW_MANY_TO_TOSS:
|
|
|
|
string = gText_TossHowManyVar1s;
|
|
|
|
break;
|
|
|
|
case ITEMPC_THREW_AWAY_ITEM:
|
|
|
|
string = gText_ThrewAwayVar2Var1s;
|
|
|
|
break;
|
|
|
|
case ITEMPC_NO_MORE_ROOM:
|
|
|
|
string = gText_NoRoomInBag;
|
|
|
|
break;
|
|
|
|
case ITEMPC_TOO_IMPORTANT:
|
|
|
|
string = gText_TooImportantToToss;
|
|
|
|
break;
|
|
|
|
case ITEMPC_OKAY_TO_THROW_AWAY:
|
|
|
|
string = gText_ConfirmTossItems;
|
|
|
|
break;
|
|
|
|
case ITEMPC_SWITCH_WHICH_ITEM:
|
|
|
|
string = gText_MoveVar1Where;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
string = ItemId_GetDescription(itemId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_PrintItemPcResponse(const u8 *string)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
u8 windowId = gUnknown_0203BCC4->windowIds[1];
|
|
|
|
FillWindowPixelBuffer(windowId, 0x11);
|
|
|
|
StringExpandPlaceholders(gStringVar4, string);
|
|
|
|
PrintTextOnWindow(windowId, 1, gStringVar4, 0, 1, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_ProcessInput(u8 taskId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
s32 id;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gMain.newKeys & SELECT_BUTTON)
|
|
|
|
{
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-15 11:37:24 +01:00
|
|
|
if((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1))
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_ItemSwapChoosePrompt(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
id = ListMenuHandleInputGetItemId(data[5]);
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-15 11:37:24 +01:00
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_GoBackToPlayerPCMenu(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemAction(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_GoBackToPlayerPCMenu_InitStorage(u8 taskId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
NewMenuHelpers_DrawDialogueFrame(0, 0);
|
|
|
|
if(!data[3])
|
2018-03-19 11:27:33 +01:00
|
|
|
InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW);
|
2018-03-15 11:37:24 +01:00
|
|
|
else
|
2018-03-19 11:27:33 +01:00
|
|
|
InitItemStorageMenu(taskId, ITEMPC_MENU_TOSS);
|
2018-03-15 11:37:24 +01:00
|
|
|
gTasks[taskId].func = ItemStorageMenuProcessInput;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
sub_816C0C8();
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_RemoveScrollIndicator();
|
2018-03-19 11:45:13 +01:00
|
|
|
DestroyListMenuTask(data[5], NULL, NULL);
|
2018-03-15 11:37:24 +01:00
|
|
|
sub_81223B0(gUnknown_0203BCC4->spriteIds, 7);
|
|
|
|
sub_816BC58();
|
2018-03-19 11:27:33 +01:00
|
|
|
gTasks[taskId].func = ItemStorage_GoBackToPlayerPCMenu_InitStorage;
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_ItemSwapChoosePrompt(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuSetUnkIndicatorsStructField(data[5], 16, 1);
|
2018-03-16 11:31:11 +01:00
|
|
|
gUnknown_0203BCC4->unk666 = (playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos);
|
|
|
|
sub_816BFB8(data[5], 0, 0);
|
|
|
|
sub_816C690(gUnknown_0203BCC4->unk666);
|
|
|
|
CopyItemName(gSaveBlock1Ptr->pcItems[gUnknown_0203BCC4->unk666].itemId, gStringVar1);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_SWITCH_WHICH_ITEM));
|
2018-03-16 11:31:11 +01:00
|
|
|
gTasks[taskId].func = sub_816C4FC;
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C4FC(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
s32 id;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gMain.newKeys & SELECT_BUTTON)
|
|
|
|
{
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemSwap(taskId, FALSE);
|
2018-03-16 11:31:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
id = ListMenuHandleInputGetItemId(data[5]);
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-16 11:31:11 +01:00
|
|
|
sub_81223FC(gUnknown_0203BCC4->spriteIds, 7, 0);
|
|
|
|
sub_816C690(playerPCItemPageInfo.cursorPos);
|
|
|
|
switch(id)
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
if(gMain.newKeys & A_BUTTON)
|
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemSwap(taskId, FALSE);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemSwap(taskId, TRUE);
|
2018-03-16 11:31:11 +01:00
|
|
|
break;
|
|
|
|
default:
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemSwap(taskId, FALSE);
|
2018-03-16 11:31:11 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_DoItemSwap(u8 taskId, bool8 a)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 b;
|
|
|
|
u8 c;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
b = (playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos);
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:45:13 +01:00
|
|
|
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-16 11:31:11 +01:00
|
|
|
if(!a)
|
|
|
|
{
|
|
|
|
c = gUnknown_0203BCC4->unk666;
|
|
|
|
if(c != b)
|
|
|
|
{
|
|
|
|
if(c != b - 1)
|
|
|
|
{
|
2018-04-29 13:36:26 +02:00
|
|
|
MoveItemSlotInList(gSaveBlock1Ptr->pcItems, c, b);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_RefreshListMenu();
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
goto LABEL_SKIP_CURSOR_DECREMENT;
|
|
|
|
}
|
|
|
|
if (gUnknown_0203BCC4->unk666 < b)
|
|
|
|
playerPCItemPageInfo.cursorPos--;
|
|
|
|
LABEL_SKIP_CURSOR_DECREMENT:
|
|
|
|
sub_81223FC(gUnknown_0203BCC4->spriteIds, 7, 1);
|
|
|
|
gUnknown_0203BCC4->unk666 = 0xFF;
|
|
|
|
data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos);
|
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2018-03-19 11:27:33 +01:00
|
|
|
gTasks[taskId].func = ItemStorage_ProcessInput;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C690(u8 a)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
sub_8122448(gUnknown_0203BCC4->spriteIds, 7, 128, ((a+1) * 16));
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void sub_816C6BC(u8 windowId, u16 value, u32 mode, u8 x, u8 y, u8 n)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
ConvertIntToDecimalStringN(gStringVar1, value, mode, n);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
|
|
|
PrintTextOnWindow(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 48), y, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_DoItemAction(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 b;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_RemoveScrollIndicator();
|
2018-03-16 11:31:11 +01:00
|
|
|
data[2] = 1;
|
|
|
|
if(!data[3])
|
|
|
|
{
|
|
|
|
if(gSaveBlock1Ptr->pcItems[b].quantity == 1)
|
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemWithdraw(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_HOW_MANY_TO_WITHDRAW));
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(gSaveBlock1Ptr->pcItems[b].quantity == 1)
|
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemToss(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_HOW_MANY_TO_TOSS));
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3);
|
2018-03-19 11:27:33 +01:00
|
|
|
gTasks[taskId].func = ItemStorage_HandleQuantityRolling;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_HandleQuantityRolling(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 b;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove);
|
|
|
|
if(AdjustQuantityAccordingToDPadInput(&(data[2]), gSaveBlock1Ptr->pcItems[b].quantity) == TRUE)
|
|
|
|
sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(gMain.newKeys & A_BUTTON)
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_816BCC4(4);
|
|
|
|
if(!data[3])
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemWithdraw(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
else
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemToss(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else if(gMain.newKeys & B_BUTTON)
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_816BCC4(4);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[b].itemId));
|
|
|
|
ItemStorage_StartScrollIndicatorAndProcessInput(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_DoItemWithdraw(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 b;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove);
|
|
|
|
if(AddBagItem(gSaveBlock1Ptr->pcItems[b].itemId, data[2]) == TRUE)
|
|
|
|
{
|
|
|
|
CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1);
|
|
|
|
ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_WITHDREW_THING));
|
|
|
|
gTasks[taskId].func = ItemStorage_HandleRemoveItem;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data[2] = 0;
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_NO_MORE_ROOM));
|
|
|
|
gTasks[taskId].func = ItemStorage_WaitPressHandleResumeProcessInput;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_DoItemToss(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 b;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove);
|
2018-04-29 13:36:26 +02:00
|
|
|
if(!ItemId_GetImportance(gSaveBlock1Ptr->pcItems[b].itemId))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1);
|
|
|
|
ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_OKAY_TO_THROW_AWAY));
|
2018-03-19 11:45:13 +01:00
|
|
|
CreateYesNoMenuWithCallbacks(taskId, &gUnknown_085DFF84, 1, 0, 1, 0x214, 0xE, &ResumeFromWithdrawYesNoFuncList);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data[2] = 0;
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_TOO_IMPORTANT));
|
|
|
|
gTasks[taskId].func = ItemStorage_WaitPressHandleResumeProcessInput;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_ResumeInputFromYesToss(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_THREW_AWAY_ITEM));
|
|
|
|
gTasks[taskId].func = ItemStorage_HandleRemoveItem;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_ResumeInputFromNoToss(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId));
|
|
|
|
ItemStorage_StartScrollIndicatorAndProcessInput(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_HandleRemoveItem(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gMain.newKeys & (A_BUTTON | B_BUTTON))
|
|
|
|
{
|
2018-04-29 13:36:26 +02:00
|
|
|
RemovePCItem((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]);
|
2018-03-19 11:45:13 +01:00
|
|
|
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-03-16 11:31:11 +01:00
|
|
|
sub_816C110();
|
|
|
|
sub_816C140();
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_RefreshListMenu();
|
2018-03-16 11:31:11 +01:00
|
|
|
data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_StartScrollIndicatorAndProcessInput(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if(gMain.newKeys & (A_BUTTON | B_BUTTON))
|
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId));
|
|
|
|
ItemStorage_StartScrollIndicatorAndProcessInput(taskId);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_StartScrollIndicatorAndProcessInput(u8 taskId)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_StartScrollIndicator();
|
|
|
|
gTasks[taskId].func = ItemStorage_ProcessInput;
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|