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"
|
2018-06-11 15:34:19 +02:00
|
|
|
#include "event_object_movement.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
#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"
|
2019-09-09 03:07:54 +02: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"
|
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"
|
2019-03-08 08:17:01 +01:00
|
|
|
#include "menu_specialized.h"
|
2018-03-12 09:26:20 +01:00
|
|
|
|
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] =
|
|
|
|
{
|
2018-09-02 18:53:52 +02:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 9,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 1
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 9,
|
|
|
|
.height = 8,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 1
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 10,
|
|
|
|
.height = 8,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 1
|
|
|
|
}
|
2018-03-19 11:27:33 +01:00
|
|
|
};
|
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-09-02 18:53:52 +02:00
|
|
|
static const struct ListMenuTemplate gUnknown_085DFF44 =
|
|
|
|
{
|
|
|
|
.items = NULL,
|
|
|
|
.moveCursorFunc = ItemStorage_MoveCursor,
|
|
|
|
.itemPrintFunc = fish4_goto_x5_or_x6,
|
|
|
|
.totalItems = 0,
|
|
|
|
.maxShowed = 0,
|
|
|
|
.windowId = 0,
|
|
|
|
.header_X = 0,
|
|
|
|
.item_X = 8,
|
|
|
|
.cursor_X = 0,
|
|
|
|
.upText_Y = 9,
|
|
|
|
.cursorPal = 2,
|
|
|
|
.fillValue = 1,
|
|
|
|
.cursorShadowPal = 3,
|
|
|
|
.lettersSpacing = FALSE,
|
|
|
|
.itemVerticalPadding = 0,
|
|
|
|
.scrollMultiple = FALSE,
|
|
|
|
.fontId = 7
|
2018-03-19 11:27:33 +01:00
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct WindowTemplate gUnknown_085DFF5C[5] =
|
|
|
|
{
|
2018-09-02 18:53:52 +02:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 16,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 13,
|
|
|
|
.height = 18,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x0001
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 13,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x00EB
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 8,
|
|
|
|
.width = 3,
|
|
|
|
.height = 3,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x0153
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 13,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x0139
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 8,
|
|
|
|
.tilemapTop = 9,
|
|
|
|
.width = 6,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x015C
|
|
|
|
}
|
2018-03-19 11:27:33 +01:00
|
|
|
};
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static const struct WindowTemplate gUnknown_085DFF84 =
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 9,
|
|
|
|
.tilemapTop = 7,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x0168
|
2018-03-19 11:27:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
u16 *data;
|
2018-03-12 09:26:20 +01:00
|
|
|
struct WindowTemplate windowTemplate;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gPcItemMenuOptionsNum == 3)
|
2018-03-12 09:26:20 +01:00
|
|
|
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);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
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
|
|
|
{
|
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
|
|
|
u16 *data;
|
2018-03-12 09:26:20 +01:00
|
|
|
s8 inputOptionId;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gPcItemMenuOptionsNum > 3)
|
2018-11-05 21:45:54 +01:00
|
|
|
inputOptionId = Menu_ProcessInput();
|
2018-03-12 09:26:20 +01:00
|
|
|
else
|
2018-11-05 21:45:54 +01:00
|
|
|
inputOptionId = Menu_ProcessInputNoWrap();
|
2018-03-12 09:26:20 +01:00
|
|
|
|
2019-02-02 11:04:38 +01:00
|
|
|
switch (inputOptionId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_NOTHING_CHOSEN:
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_B_PRESSED:
|
2018-03-12 09:26:20 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(data[4], FALSE);
|
2018-03-12 09:26:20 +01:00
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
gTasks[taskId].func = PlayerPC_TurnOff;
|
|
|
|
break;
|
|
|
|
default:
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(data[4], FALSE);
|
2018-03-12 09:26:20 +01:00
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
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-11-28 21:08:22 +01:00
|
|
|
if (sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, 0);
|
2018-03-12 09:26:20 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
gTasks[taskId].func = Mailbox_ProcessInput;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void PlayerPC_Decoration(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
DoPlayerRoomDecorationMenu(taskId);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void PlayerPC_TurnOff(u8 taskId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-10-23 02:50:41 +02:00
|
|
|
if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC, so do gender specific handling.
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2019-10-23 02:50:41 +02:00
|
|
|
ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_TurnOffPlayerPC);
|
2018-03-12 09:26:20 +01:00
|
|
|
else
|
2019-10-23 02:50:41 +02:00
|
|
|
ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_TurnOffPlayerPC);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
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
|
|
|
u16 *data;
|
2018-03-12 09:26:20 +01:00
|
|
|
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);
|
2021-01-19 10:19:14 +01:00
|
|
|
PrintMenuTable(data[4], ARRAY_COUNT(gPCText_ItemPCOptionsText), gPCText_ItemPCOptionsText);
|
2018-03-12 09:26:20 +01:00
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
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
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawDialogueFrame(0, 0);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(0, 1, textPtr, 0, 1, 0, 0);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
r5 = Menu_GetCursorPos();
|
2018-11-05 21:45:54 +01:00
|
|
|
inputOptionId = Menu_ProcessInput();
|
2018-12-16 21:10:01 +01:00
|
|
|
r2 = Menu_GetCursorPos();
|
2019-02-02 11:04:38 +01:00
|
|
|
switch (inputOptionId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_NOTHING_CHOSEN:
|
2018-03-12 09:26:20 +01:00
|
|
|
if (r5 != r2)
|
|
|
|
ItemStorageMenuPrint(gPCText_OptionDescList[r2]);
|
|
|
|
break;
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_B_PRESSED:
|
2018-03-12 09:26:20 +01:00
|
|
|
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;
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2020-05-14 10:37:09 +02:00
|
|
|
CB2_GoToItemDepositMenu();
|
2018-03-12 09:26:20 +01:00
|
|
|
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
|
|
|
{
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawDialogueFrame(0, 1);
|
2018-03-12 09:26:20 +01:00
|
|
|
InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
u16 *data = gTasks[taskId].data;
|
2018-03-12 09:26:20 +01:00
|
|
|
|
|
|
|
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();
|
2018-09-03 00:20:45 +02:00
|
|
|
FreeAndReserveObjectSpritePalettes();
|
2018-03-12 09:26:20 +01:00
|
|
|
LoadListMenuArrowsGfx();
|
2018-03-15 11:37:24 +01:00
|
|
|
sub_8122344(gUnknown_0203BCC4->spriteIds, 7);
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(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
|
|
|
{
|
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
|
|
|
u16 *data = gTasks[taskId].data;
|
2018-03-12 09:26:20 +01:00
|
|
|
|
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
|
|
|
ClearStdWindowAndFrameToTransparent(data[4], FALSE);
|
2018-03-12 09:26:20 +01:00
|
|
|
ClearWindowTilemap(data[4]);
|
|
|
|
RemoveWindow(data[4]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
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++)
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gSaveBlock1Ptr->mail[j].itemId != 0)
|
2018-03-12 09:26:20 +01:00
|
|
|
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);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(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;
|
|
|
|
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!gPaletteFade.active)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
inputOptionId = ListMenu_ProcessInput(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
|
|
|
|
2019-02-02 11:04:38 +01:00
|
|
|
switch (inputOptionId)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
2018-03-12 09:26:20 +01:00
|
|
|
break;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2018-03-12 09:26:20 +01:00
|
|
|
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));
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(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);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-12 09:26:20 +01:00
|
|
|
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);
|
2021-01-19 10:19:14 +01:00
|
|
|
PrintMenuTable(r4, ARRAY_COUNT(gMailboxMailOptions), gMailboxMailOptions);
|
2018-03-12 09:26:20 +01:00
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(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
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!gPaletteFade.active)
|
2018-03-12 09:26:20 +01:00
|
|
|
{
|
|
|
|
sub_81D1EC0();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
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;
|
|
|
|
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2018-03-13 10:11:39 +01:00
|
|
|
taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
else
|
|
|
|
DestroyTask(taskId);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2018-03-13 10:11:39 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void Mailbox_HandleReturnToProcessInput(u8 taskId)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +01: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
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2018-03-13 10:11:39 +01:00
|
|
|
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
|
|
|
{
|
2018-11-05 21:45:54 +01:00
|
|
|
switch(Menu_ProcessInputNoWrapClearOnChoose())
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
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-11-28 21:08:22 +01:00
|
|
|
if (!AddBagItem(mailStruct->itemId, 1))
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
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--;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove) && playerPCItemPageInfo.itemsAbove != 0)
|
2018-03-15 11:37:24 +01:00
|
|
|
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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (CalculatePlayerPartyCount() == 0)
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_NoPokemonForMail(taskId);
|
|
|
|
else
|
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2018-03-13 10:11:39 +01:00
|
|
|
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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!gPaletteFade.active)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
sub_81D1EC0();
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2019-10-18 01:22:03 +02:00
|
|
|
ChooseMonToGiveMailFromMailbox();
|
2018-03-13 10:11:39 +01:00
|
|
|
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-11-28 21:08:22 +01:00
|
|
|
if (prevCount != playerPCItemPageInfo.count && (playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove))
|
2018-03-15 11:37:24 +01:00
|
|
|
&& playerPCItemPageInfo.itemsAbove != 0)
|
|
|
|
playerPCItemPageInfo.itemsAbove--;
|
2018-03-13 10:11:39 +01:00
|
|
|
ItemStorage_SetItemAndMailCount(taskId);
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2018-11-28 21:08:22 +01:00
|
|
|
if (sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
|
|
|
else
|
|
|
|
DestroyTask(taskId);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2018-03-13 10:11:39 +01:00
|
|
|
}
|
|
|
|
|
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);
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrame(0, 0);
|
2018-03-13 10:11:39 +01:00
|
|
|
Mailbox_DrawMailboxMenu(taskId);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-13 10:11:39 +01:00
|
|
|
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-11-28 21:08:22 +01:00
|
|
|
if (*windowIdLoc == 0xFF)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
*windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdFrameWithCustomTileAndPalette(*windowIdLoc, FALSE, 0x214, 0xE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-13 10:11:39 +01:00
|
|
|
}
|
|
|
|
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-11-28 21:08:22 +01:00
|
|
|
if (*windowIdLoc != 0xFF)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(*windowIdLoc, FALSE);
|
2018-03-13 10:11:39 +01:00
|
|
|
ClearWindowTilemap(*windowIdLoc);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-03-13 10:11:39 +01:00
|
|
|
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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (b != TRUE)
|
2018-03-13 10:11:39 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gUnknown_0203BCC4->unk666 == 0xFF)
|
2018-03-13 10:11:39 +01:00
|
|
|
{
|
|
|
|
sub_816C0C8();
|
2018-11-28 21:08:22 +01:00
|
|
|
if (id != -2)
|
2018-03-13 10:11:39 +01:00
|
|
|
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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (id != -2)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gUnknown_0203BCC4->unk666 != 0xFF)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gUnknown_0203BCC4->unk666 == (u8)id)
|
2018-03-15 11:37:24 +01:00
|
|
|
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);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 7, gStringVar4, GetStringRightAlignXOffset(7, gStringVar4, 104), yOffset, 0xFF, NULL);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
|
2018-11-28 21:08:22 +01:00
|
|
|
if (id != -2)
|
2018-03-15 11:37:24 +01:00
|
|
|
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);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, description, 0, 1, 0, NULL);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-19 11:27:33 +01:00
|
|
|
static void ItemStorage_StartScrollIndicator(void)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +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
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (playerPCItemPageInfo.scrollIndicatorId != 0xFF)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
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];
|
2018-11-28 21:08:22 +01:00
|
|
|
if (b == 0xFF)
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelRect(windowId, PIXEL_FILL(1), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
|
2018-03-15 11:37:24 +01:00
|
|
|
else
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized4(windowId, 1, 0, y, 0, 0, gUnknown_085DFF8C, speed, gText_SelectorArrow2);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2018-11-28 21:08:22 +01:00
|
|
|
if (*spriteIdLoc == 0xFF)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(0x13F6);
|
|
|
|
FreeSpritePaletteByTag(0x13F6);
|
|
|
|
spriteId = AddItemIconSprite(0x13F6, 0x13F6, itemId);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
*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);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (*spriteIdLoc != 0xFF)
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
const u8* text;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
for(i = 0; i <=3; i++)
|
|
|
|
sub_816BC7C(i);
|
|
|
|
toss = data[3];
|
|
|
|
text = gText_TossItem;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!toss)
|
2018-03-15 11:37:24 +01:00
|
|
|
text = gText_WithdrawItem;
|
|
|
|
x = GetStringCenterAlignXOffset(1, text, 104);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(gUnknown_0203BCC4->windowIds[3], 1, text, x, 1, 0, NULL);
|
2018-03-15 11:37:24 +01:00
|
|
|
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();
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(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];
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-03-15 11:37:24 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, string);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gStringVar4, 0, 1, 0, NULL);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
|
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;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2018-03-19 11:45:13 +01:00
|
|
|
ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
2018-11-28 21:08:22 +01:00
|
|
|
if ((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1))
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_ItemSwapChoosePrompt(taskId);
|
2018-03-15 11:37:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
id = ListMenu_ProcessInput(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)
|
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
2018-03-15 11:37:24 +01:00
|
|
|
break;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2018-03-15 11:37:24 +01:00
|
|
|
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;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-03-15 11:37:24 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawDialogueFrame(0, 0);
|
2018-11-28 21:08:22 +01:00
|
|
|
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;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
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;
|
|
|
|
}
|
2019-02-02 11:04:38 +01:00
|
|
|
id = ListMenu_ProcessInput(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)
|
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
2018-03-16 11:31:11 +01:00
|
|
|
break;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-03-19 11:27:33 +01:00
|
|
|
ItemStorage_DoItemSwap(taskId, FALSE);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
else
|
2019-02-02 19:41:34 +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-11-28 21:08:22 +01:00
|
|
|
if (!a)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
c = gUnknown_0203BCC4->unk666;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (c != b)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (c != b - 1)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
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);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(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);
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 48), y, 0, NULL);
|
2018-03-16 11:31:11 +01:00
|
|
|
}
|
|
|
|
|
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;
|
2018-11-28 21:08:22 +01:00
|
|
|
if (!data[3])
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gSaveBlock1Ptr->pcItems[b].quantity == 1)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
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
|
|
|
|
{
|
2018-11-28 21:08:22 +01:00
|
|
|
if (gSaveBlock1Ptr->pcItems[b].quantity == 1)
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
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);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (AdjustQuantityAccordingToDPadInput(&(data[2]), gSaveBlock1Ptr->pcItems[b].quantity) == TRUE)
|
2018-03-16 11:31:11 +01:00
|
|
|
sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3);
|
|
|
|
else
|
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_816BCC4(4);
|
2018-11-28 21:08:22 +01:00
|
|
|
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
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
|
|
|
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);
|
2018-11-28 21:08:22 +01:00
|
|
|
if (AddBagItem(gSaveBlock1Ptr->pcItems[b].itemId, data[2]) == TRUE)
|
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_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);
|
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 (!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;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2018-03-16 11:31:11 +01:00
|
|
|
{
|
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;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
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_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
|
|
|
}
|