2018-01-30 19:19:37 +01:00
|
|
|
#include "global.h"
|
2018-03-04 18:41:07 +01:00
|
|
|
#include "item_menu.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "battle.h"
|
|
|
|
#include "battle_controllers.h"
|
2019-02-08 00:41:44 +01:00
|
|
|
#include "battle_pyramid.h"
|
2018-10-30 22:17:03 +01:00
|
|
|
#include "frontier_util.h"
|
2019-10-18 01:22:03 +02:00
|
|
|
#include "battle_pyramid_bag.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "berry_tag_screen.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "bg.h"
|
|
|
|
#include "constants/items.h"
|
|
|
|
#include "constants/songs.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "decompress.h"
|
|
|
|
#include "event_data.h"
|
2018-06-12 00:33:50 +02:00
|
|
|
#include "event_object_movement.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "field_player_avatar.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "field_specials.h"
|
|
|
|
#include "graphics.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "item.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "item_menu_icons.h"
|
|
|
|
#include "item_use.h"
|
|
|
|
#include "lilycove_lady.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "list_menu.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "link.h"
|
|
|
|
#include "mail.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "main.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "map_name_popup.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "menu.h"
|
|
|
|
#include "money.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "overworld.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "palette.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "party_menu.h"
|
|
|
|
#include "player_pc.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "pokemon.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "pokemon_summary_screen.h"
|
2018-01-31 06:03:52 +01:00
|
|
|
#include "scanline_effect.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "script.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "shop.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "string.h"
|
2018-02-09 03:00:28 +01:00
|
|
|
#include "strings.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "string_util.h"
|
|
|
|
#include "task.h"
|
2018-02-05 05:47:47 +01:00
|
|
|
#include "text_window.h"
|
2018-01-30 19:19:37 +01:00
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "window.h"
|
2018-10-14 17:00:41 +02:00
|
|
|
#include "apprentice.h"
|
2018-11-12 14:35:56 +01:00
|
|
|
#include "battle_pike.h"
|
2019-04-04 23:05:46 +02:00
|
|
|
#include "constants/rgb.h"
|
2018-11-01 21:31:10 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SWITCH_POCKET_NONE,
|
|
|
|
SWITCH_POCKET_LEFT,
|
|
|
|
SWITCH_POCKET_RIGHT
|
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void (*postExitMenuMainCallback2)());
|
2018-01-30 19:19:37 +01:00
|
|
|
void CB2_Bag(void);
|
2019-05-19 19:10:06 +02:00
|
|
|
bool8 SetupBagMenu(void);
|
|
|
|
void BagMenu_InitBGs(void);
|
|
|
|
bool8 LoadBagMenu_Graphics(void);
|
|
|
|
void SetupBagMenu_Textboxes(void);
|
|
|
|
void AllocateBagItemListBuffers(void);
|
|
|
|
void LoadBagItemListBuffers(u8);
|
|
|
|
void BagMenu_PrintPocketNames(const u8*, const u8*);
|
|
|
|
void BagMenu_CopyPocketNameToWindow(u32);
|
2020-08-28 19:31:58 +02:00
|
|
|
static void DrawPocketIndicatorSquare(u8 x, bool8 isCurrentPocket);
|
2020-05-14 10:37:09 +02:00
|
|
|
void CreatePocketScrollArrowPair(void);
|
|
|
|
void CreatePocketSwitchArrowPair(void);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_PrepareTMHMMoveWindow(void);
|
2018-01-30 19:19:37 +01:00
|
|
|
bool8 IsWallysBag(void);
|
|
|
|
void Task_WallyTutorialBagMenu(u8);
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_BagMenu_HandleInput(u8);
|
2019-05-19 19:10:06 +02:00
|
|
|
void GetItemName(s8*, u16);
|
2018-01-30 19:19:37 +01:00
|
|
|
u16 ItemIdToBattleMoveId(u16);
|
|
|
|
u16 BagGetItemIdByPocketPosition(u8, u16);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_PrintDescription(int);
|
|
|
|
void BagMenu_PrintCursor(u8, u8);
|
|
|
|
void BagMenu_Print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8);
|
2018-04-29 13:36:26 +02:00
|
|
|
bool8 ItemId_GetImportance(u16);
|
2018-01-30 19:19:37 +01:00
|
|
|
u16 BagGetQuantityByPocketPosition(u8, u16);
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagDestroyPocketSwitchArrowPair(void);
|
2019-05-19 19:10:06 +02:00
|
|
|
void TaskCloseBagMenu_2(u8);
|
2018-01-30 19:19:37 +01:00
|
|
|
u8 AddItemMessageWindow(u8);
|
2020-08-28 19:31:58 +02:00
|
|
|
void BagMenu_RemoveBagItemMessageindow(u8);
|
2018-01-30 19:19:37 +01:00
|
|
|
void set_callback3_to_bag(u8);
|
2019-06-30 00:47:48 +02:00
|
|
|
void PrintItemDepositAmount(u8, s16);
|
2020-08-28 19:31:58 +02:00
|
|
|
static u8 BagMenu_AddWindow(u8);
|
|
|
|
static u8 GetSwitchBagPocketDirection(void);
|
|
|
|
static void SwitchBagPocket(u8, s16, u16);
|
|
|
|
static bool8 CanSwapItems(void);
|
|
|
|
static void BagMenu_SwapItems(u8 taskId);
|
|
|
|
static void sub_81AC10C(u8);
|
|
|
|
static void Task_HandleSwappingItemsInput(u8);
|
2018-02-05 05:47:47 +01:00
|
|
|
void sub_81AC498(u8);
|
|
|
|
void sub_81AC590(u8);
|
|
|
|
void PrintTMHMMoveData(u16);
|
|
|
|
void sub_81ACAF8(u8);
|
|
|
|
void sub_81ACB54(u8, u8, u8);
|
|
|
|
void Task_HandleInBattleItemMenuInput(u8);
|
|
|
|
void Task_HandleOutOfBattleItemMenuInput(u8);
|
|
|
|
bool8 sub_81ACDFC(s8);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_RemoveWindow(u8);
|
|
|
|
void BagMenu_PrintThereIsNoPokemon(u8);
|
2018-02-05 05:47:47 +01:00
|
|
|
void Task_ChooseHowManyToToss(u8);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_TossItems(u8);
|
|
|
|
void BagMenu_YesNo(u8, u8, const struct YesNoFuncTable*);
|
2018-02-05 05:47:47 +01:00
|
|
|
void Task_ActuallyToss(u8);
|
|
|
|
void ItemMenu_Cancel(u8);
|
|
|
|
void sub_81AD350(u8);
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_PrintItemCantBeHeld(u8);
|
|
|
|
static void DisplayCurrentMoneyWindow(void);
|
|
|
|
static void DisplaySellItemPriceAndConfirm(u8);
|
2018-02-05 05:47:47 +01:00
|
|
|
void sub_81AD730(u8);
|
|
|
|
void sub_81AD6E4(u8);
|
2020-08-28 19:31:58 +02:00
|
|
|
static void RemoveMoneyWindow(void);
|
|
|
|
static void Task_SellHowManyDialogueHandleInput(u8);
|
|
|
|
static void BagMenu_Sell_UpdateItemListAndMoney(u8);
|
|
|
|
static void BagMenu_Sell_WaitForABPress(u8);
|
|
|
|
static void BagMenu_TryDepositItem(u8);
|
|
|
|
static void Task_ChooseHowManyToDeposit(u8 taskId);
|
|
|
|
static void BagMenu_Deposit_WaitForABPress(u8);
|
2019-11-19 17:36:38 +01:00
|
|
|
void CB2_ApprenticeExitBagMenu(void);
|
2019-08-06 02:37:09 +02:00
|
|
|
void CB2_FavorLadyExitBagMenu(void);
|
|
|
|
void CB2_QuizLadyExitBagMenu(void);
|
2020-05-14 10:37:09 +02:00
|
|
|
void All_CalculateNItemsAndMaxShowed(void);
|
2018-12-15 19:08:13 +01:00
|
|
|
static void SetPocketListPositions(void);
|
2020-05-14 10:37:09 +02:00
|
|
|
void UpdatePocketScrollPositions(void);
|
|
|
|
u8 CreateBagInputHandlerTask(u8);
|
2018-02-09 03:00:28 +01:00
|
|
|
void sub_81AC23C(u8);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*);
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 a);
|
2018-02-12 19:59:42 +01:00
|
|
|
void ItemMenu_UseOutOfBattle(u8 taskId);
|
|
|
|
void ItemMenu_Toss(u8 taskId);
|
|
|
|
void ItemMenu_Register(u8 taskId);
|
|
|
|
void ItemMenu_Give(u8 taskId);
|
|
|
|
void ItemMenu_Cancel(u8 taskId);
|
|
|
|
void ItemMenu_UseInBattle(u8 taskId);
|
|
|
|
void ItemMenu_CheckTag(u8 taskId);
|
2020-01-08 11:43:06 +01:00
|
|
|
void Task_FadeAndCloseBagMenu(u8 taskId);
|
2018-02-12 19:59:42 +01:00
|
|
|
void unknown_ItemMenu_Show(u8 taskId);
|
|
|
|
void unknown_ItemMenu_Give2(u8 taskId);
|
|
|
|
void unknown_ItemMenu_Confirm2(u8 taskId);
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_FieldOrBattle(u8 taskId);
|
|
|
|
void Task_ItemContext_FieldGive(u8 taskId);
|
|
|
|
void Task_ItemContext_Sell(u8 taskId);
|
|
|
|
void Task_ItemContext_Deposit(u8 taskId);
|
|
|
|
void Task_ItemContext_ItemPC_2(u8 taskId);
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_ConfirmToss(u8 taskId);
|
|
|
|
void BagMenu_CancelToss(u8 taskId);
|
|
|
|
void BagMenu_ConfirmSell(u8 taskId);
|
|
|
|
void BagMenu_CancelSell(u8 taskId);
|
2018-02-12 19:59:42 +01:00
|
|
|
|
|
|
|
// .rodata
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const struct BgTemplate sBgTemplates_ItemMenu[] =
|
2018-09-02 15:49:29 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 3,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0,
|
|
|
|
},
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
static const struct ListMenuTemplate sItemListMenu =
|
2018-09-02 15:49:29 +02:00
|
|
|
{
|
2018-09-02 17:26:23 +02:00
|
|
|
.items = NULL,
|
2019-05-19 19:10:06 +02:00
|
|
|
.moveCursorFunc = BagMenu_MoveCursorCallback,
|
2020-05-14 10:37:09 +02:00
|
|
|
.itemPrintFunc = BagMenu_ItemPrintCallback,
|
2018-09-02 15:49:29 +02:00
|
|
|
.totalItems = 0,
|
|
|
|
.maxShowed = 0,
|
|
|
|
.windowId = 0,
|
|
|
|
.header_X = 0,
|
|
|
|
.item_X = 8,
|
|
|
|
.cursor_X = 0,
|
|
|
|
.upText_Y = 1,
|
|
|
|
.cursorPal = 1,
|
|
|
|
.fillValue = 0,
|
|
|
|
.cursorShadowPal = 3,
|
|
|
|
.lettersSpacing = 0,
|
|
|
|
.itemVerticalPadding = 0,
|
|
|
|
.scrollMultiple = 0,
|
|
|
|
.fontId = 7,
|
|
|
|
.cursorKind = 0
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const struct MenuAction sItemMenuActions[] = {
|
|
|
|
[ITEMMENUACTION_USE] = {gMenuText_Use, ItemMenu_UseOutOfBattle},
|
|
|
|
[ITEMMENUACTION_TOSS] = {gMenuText_Toss, ItemMenu_Toss},
|
|
|
|
[ITEMMENUACTION_REGISTER] = {gMenuText_Register, ItemMenu_Register},
|
|
|
|
[ITEMMENUACTION_GIVE] = {gMenuText_Give, ItemMenu_Give},
|
|
|
|
[ITEMMENUACTION_CANCEL] = {gText_Cancel2, ItemMenu_Cancel},
|
|
|
|
[ITEMMENUACTION_BATTLE_USE] = {gMenuText_Use, ItemMenu_UseInBattle},
|
|
|
|
[ITEMMENUACTION_CHECK] = {gMenuText_Check, ItemMenu_UseOutOfBattle},
|
|
|
|
[ITEMMENUACTION_WALK] = {gMenuText_Walk, ItemMenu_UseOutOfBattle},
|
|
|
|
[ITEMMENUACTION_DESELECT] = {gMenuText_Deselect, ItemMenu_Register},
|
|
|
|
[ITEMMENUACTION_CHECK_TAG] = {gMenuText_CheckTag, ItemMenu_CheckTag},
|
|
|
|
[ITEMMENUACTION_CONFIRM] = {gMenuText_Confirm, Task_FadeAndCloseBagMenu},
|
|
|
|
[ITEMMENUACTION_SHOW] = {gMenuText_Show, unknown_ItemMenu_Show},
|
|
|
|
[ITEMMENUACTION_GIVE_2] = {gMenuText_Give2, unknown_ItemMenu_Give2},
|
|
|
|
[ITEMMENUACTION_CONFIRM_2] = {gMenuText_Confirm, unknown_ItemMenu_Confirm2},
|
|
|
|
[ITEMMENUACTION_DUMMY] = {gText_EmptyString2, NULL}
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
// these are all 2D arrays with a width of 2 but are represented as 1D arrays
|
|
|
|
// ITEMMENUACTION_DUMMY is used to represent blank spaces
|
|
|
|
static const u8 sContextMenuItems_ItemsPocket[] = {
|
|
|
|
ITEMMENUACTION_USE, ITEMMENUACTION_GIVE,
|
|
|
|
ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const u8 sContextMenuItems_KeyItemsPocket[] = {
|
|
|
|
ITEMMENUACTION_USE, ITEMMENUACTION_REGISTER,
|
|
|
|
ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_BallsPocket[] = {
|
|
|
|
ITEMMENUACTION_GIVE, ITEMMENUACTION_DUMMY,
|
|
|
|
ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_TmHmPocket[] = {
|
|
|
|
ITEMMENUACTION_USE, ITEMMENUACTION_GIVE,
|
|
|
|
ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_BerriesPocket[] = {
|
|
|
|
ITEMMENUACTION_CHECK_TAG, ITEMMENUACTION_DUMMY,
|
|
|
|
ITEMMENUACTION_USE, ITEMMENUACTION_GIVE,
|
|
|
|
ITEMMENUACTION_TOSS, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_BattleUse[] = {
|
|
|
|
ITEMMENUACTION_BATTLE_USE, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_Give[] = {
|
|
|
|
ITEMMENUACTION_GIVE, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_Cancel[] = {
|
|
|
|
ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_BerryBlenderCrush[] = {
|
|
|
|
ITEMMENUACTION_CONFIRM, ITEMMENUACTION_CHECK_TAG,
|
|
|
|
ITEMMENUACTION_DUMMY, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sContextMenuItems_Apprentice[] = {
|
|
|
|
ITEMMENUACTION_SHOW, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
2018-02-12 19:59:42 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const u8 sContextMenuItems_FavorLady[] = {
|
|
|
|
ITEMMENUACTION_GIVE_2, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
2018-02-12 19:59:42 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const u8 sContextMenuItems_QuizLady[] = {
|
|
|
|
ITEMMENUACTION_CONFIRM_2, ITEMMENUACTION_CANCEL
|
|
|
|
};
|
2018-02-12 19:59:42 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
static const TaskFunc gUnknown_08614054[] = {
|
|
|
|
[ITEMMENULOCATION_FIELD] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_BATTLE] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_PARTY] = Task_ItemContext_FieldGive,
|
|
|
|
[ITEMMENULOCATION_SHOP] = Task_ItemContext_Sell,
|
|
|
|
[ITEMMENULOCATION_BERRY_TREE] = Task_FadeAndCloseBagMenu,
|
|
|
|
[ITEMMENULOCATION_BERRY_BLENDER_CRUSH] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_ITEMPC] = Task_ItemContext_Deposit,
|
|
|
|
[ITEMMENULOCATION_FAVOR_LADY] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_QUIZ_LADY] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_APPRENTICE] = Task_ItemContext_FieldOrBattle,
|
|
|
|
[ITEMMENULOCATION_WALLY] = NULL,
|
|
|
|
[ITEMMENULOCATION_PCBOX] = Task_ItemContext_ItemPC_2
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct YesNoFuncTable sYesNoTossFunctions = {BagMenu_ConfirmToss, BagMenu_CancelToss};
|
|
|
|
|
|
|
|
static const struct YesNoFuncTable sYesNoSellItemFunctions = {BagMenu_ConfirmSell, BagMenu_CancelSell};
|
|
|
|
|
|
|
|
static const struct ScrollArrowsTemplate sBagScrollArrowsTemplate = {
|
|
|
|
.firstArrowType = SCROLL_ARROW_LEFT,
|
|
|
|
.firstX = 28,
|
|
|
|
.firstY = 16,
|
|
|
|
.secondArrowType = SCROLL_ARROW_RIGHT,
|
|
|
|
.secondX = 100,
|
|
|
|
.secondY = 16,
|
|
|
|
.fullyUpThreshold = -1,
|
|
|
|
.fullyDownThreshold = -1,
|
|
|
|
.tileTag = 111,
|
|
|
|
.palTag = 111,
|
|
|
|
.palNum = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sRegisteredSelect_Gfx[] = INCBIN_U8("graphics/interface/select_button.4bpp");
|
2018-02-12 19:59:42 +01:00
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
static const u8 sFontColorTable[][3] = {
|
|
|
|
// bgColor, textColor, shadowColor
|
2018-02-14 01:12:17 +01:00
|
|
|
{0, 1, 3},
|
2018-02-12 19:59:42 +01:00
|
|
|
{0, 1, 4},
|
|
|
|
{0, 3, 6},
|
|
|
|
{2, 1, 3},
|
|
|
|
{0, 14, 10}
|
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
const struct WindowTemplate sDefaultBagWindows[] =
|
2018-09-02 15:49:29 +02:00
|
|
|
{
|
2018-12-15 19:08:13 +01:00
|
|
|
{ // Item names
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 14,
|
|
|
|
.tilemapTop = 2,
|
|
|
|
.width = 15,
|
|
|
|
.height = 16,
|
|
|
|
.paletteNum = 1,
|
|
|
|
.baseBlock = 0x27,
|
|
|
|
},
|
2018-12-15 19:08:13 +01:00
|
|
|
{ // Description
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 14,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 1,
|
|
|
|
.baseBlock = 0x117,
|
|
|
|
},
|
2018-12-15 19:08:13 +01:00
|
|
|
{ // Pocket name
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 4,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 8,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 1,
|
|
|
|
.baseBlock = 0x1A1,
|
|
|
|
},
|
2018-12-15 19:08:13 +01:00
|
|
|
{ // TM/HM info icons
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 5,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 12,
|
|
|
|
.baseBlock = 0x16B,
|
|
|
|
},
|
2018-12-15 19:08:13 +01:00
|
|
|
{// TM/HM info
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 7,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 4,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 12,
|
|
|
|
.baseBlock = 0x189,
|
|
|
|
},
|
2018-12-15 19:08:13 +01:00
|
|
|
{ // Field message box
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 27,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1B1,
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE,
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
const struct WindowTemplate sContextMenuWindowTemplates[] =
|
2018-09-02 15:49:29 +02:00
|
|
|
{
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 22,
|
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 7,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 22,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 7,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 15,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 14,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 15,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 14,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 27,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1B1,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 24,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 21,
|
|
|
|
.tilemapTop = 9,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 24,
|
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x21D,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 18,
|
|
|
|
.tilemapTop = 11,
|
|
|
|
.width = 10,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x245,
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 15:49:29 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 10,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x231,
|
|
|
|
},
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// .text
|
|
|
|
|
|
|
|
struct ListBuffer1 {
|
2020-05-14 10:37:09 +02:00
|
|
|
struct ListMenuItem subBuffers[MAX_POCKET_ITEMS];
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ListBuffer2 {
|
2020-05-14 10:37:09 +02:00
|
|
|
s8 name[MAX_POCKET_ITEMS][24];
|
2018-02-12 19:59:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TempWallyStruct {
|
2020-02-04 12:24:39 +01:00
|
|
|
struct ItemSlot bagPocket_Items[BAG_ITEMS_COUNT];
|
|
|
|
struct ItemSlot bagPocket_PokeBalls[BAG_POKEBALLS_COUNT];
|
2018-12-10 10:32:00 +01:00
|
|
|
u16 cursorPosition[POCKETS_COUNT];
|
|
|
|
u16 scrollPosition[POCKETS_COUNT];
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 filler[2];
|
2018-02-12 19:59:42 +01:00
|
|
|
u16 pocket;
|
|
|
|
};
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
EWRAM_DATA struct BagMenuStruct *gBagMenu = 0;
|
|
|
|
EWRAM_DATA struct BagStruct gBagPositionStruct = {0};
|
2018-12-15 19:08:13 +01:00
|
|
|
static EWRAM_DATA struct ListBuffer1 *sListBuffer1 = 0;
|
|
|
|
static EWRAM_DATA struct ListBuffer2 *sListBuffer2 = 0;
|
2018-02-12 19:59:42 +01:00
|
|
|
EWRAM_DATA u16 gSpecialVar_ItemId = 0;
|
2020-02-04 12:42:25 +01:00
|
|
|
static EWRAM_DATA struct TempWallyStruct *sTempWallyBag = 0;
|
2018-02-12 19:59:42 +01:00
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
extern u8 *const gPocketNamesStringsTable[];
|
2018-01-30 19:19:37 +01:00
|
|
|
extern u8* gReturnToXStringsTable[];
|
2019-03-22 03:10:56 +01:00
|
|
|
extern const u8 EventScript_SelectWithoutRegisteredItem[];
|
2018-02-12 20:06:52 +01:00
|
|
|
extern const u16 gUnknown_0860F074[];
|
2018-01-30 19:19:37 +01:00
|
|
|
|
|
|
|
void ResetBagScrollPositions(void)
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagPositionStruct.pocket = ITEMS_POCKET;
|
|
|
|
memset(gBagPositionStruct.cursorPosition, 0, 10);
|
|
|
|
memset(gBagPositionStruct.scrollPosition, 0, 10);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CB2_BagMenuFromStartMenu(void)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_FIELD, POCKETS_COUNT, CB2_ReturnToFieldWithOpenMenu);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void CB2_BagMenuFromBattle(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
if (!InBattlePyramid())
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2);
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2019-10-18 01:22:03 +02:00
|
|
|
GoToBattlePyramidBagMenu(1, CB2_SetUpReshowBattleScreenAfterMenu2);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-08-23 00:20:22 +02:00
|
|
|
// Choosing berry to plant
|
2018-01-30 19:19:37 +01:00
|
|
|
void CB2_ChooseBerry(void)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_BERRY_TREE, BERRIES_POCKET, CB2_ReturnToFieldContinueScript);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-08-23 00:20:22 +02:00
|
|
|
// Choosing berry for Berry Blender or Berry Crush
|
|
|
|
void ChooseBerryForMachine(void (*exitCallback)(void))
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-08-23 00:20:22 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_BERRY_BLENDER_CRUSH, BERRIES_POCKET, exitCallback);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CB2_GoToSellMenu(void)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_SHOP, POCKETS_COUNT, CB2_ExitSellMenu);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void CB2_GoToItemDepositMenu(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_ITEMPC, POCKETS_COUNT, sub_816B31C);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-11-19 17:36:38 +01:00
|
|
|
void ApprenticeOpenBagMenu(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_APPRENTICE, POCKETS_COUNT, CB2_ApprenticeExitBagMenu);
|
2019-11-20 23:36:52 +01:00
|
|
|
gSpecialVar_0x8005 = ITEM_NONE;
|
|
|
|
gSpecialVar_Result = FALSE;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:37:09 +02:00
|
|
|
void FavorLadyOpenBagMenu(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_FAVOR_LADY, POCKETS_COUNT, CB2_FavorLadyExitBagMenu);
|
2019-11-20 23:36:52 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:37:09 +02:00
|
|
|
void QuizLadyOpenBagMenu(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_QUIZ_LADY, POCKETS_COUNT, CB2_QuizLadyExitBagMenu);
|
2019-11-20 23:36:52 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void GoToBagMenu(u8 location, u8 pocket, void ( *postExitMenuMainCallback2)())
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagMenu = AllocZeroed(sizeof(struct BagMenuStruct));
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu == NULL)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2018-01-30 19:19:37 +01:00
|
|
|
SetMainCallback2(postExitMenuMainCallback2);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (location != ITEMMENULOCATION_LAST)
|
|
|
|
gBagPositionStruct.location = location;
|
2018-01-30 19:19:37 +01:00
|
|
|
if (postExitMenuMainCallback2)
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagPositionStruct.bagCallback = postExitMenuMainCallback2;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (pocket < POCKETS_COUNT)
|
|
|
|
gBagPositionStruct.pocket = pocket;
|
|
|
|
if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_TREE ||
|
|
|
|
gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH)
|
|
|
|
gBagMenu->pocketSwitchDisabled = TRUE;
|
|
|
|
gBagMenu->exitCallback = NULL;
|
|
|
|
gBagMenu->itemOriginalLocation = 0xFF;
|
|
|
|
gBagMenu->pocketScrollArrowsTask = 0xFF;
|
|
|
|
gBagMenu->pocketSwitchArrowsTask = 0xFF;
|
2019-05-19 19:10:06 +02:00
|
|
|
memset(gBagMenu->spriteId, 0xFF, sizeof(gBagMenu->spriteId));
|
|
|
|
memset(gBagMenu->windowPointers, 0xFF, 10);
|
2018-01-30 19:19:37 +01:00
|
|
|
SetMainCallback2(CB2_Bag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void CB2_BagMenuRun(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
2020-06-20 01:58:56 +02:00
|
|
|
DoScheduledBgTilemapCopiesToVram();
|
2018-01-30 19:19:37 +01:00
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void VBlankCB_BagMenuRun(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
#define tItemCount data[8]
|
|
|
|
|
2018-01-30 19:19:37 +01:00
|
|
|
void CB2_Bag(void)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
while(MenuHelpers_CallLinkSomething() != TRUE && SetupBagMenu() != TRUE && MenuHelpers_LinkSomething() != TRUE) {};
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
bool8 SetupBagMenu(void)
|
2018-01-30 19:19:37 +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
|
|
|
u32 index;
|
2018-01-30 19:19:37 +01:00
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
2020-06-20 01:58:56 +02:00
|
|
|
ClearScheduledBgCopiesToVram();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ResetPaletteFade();
|
|
|
|
gPaletteFade.bufferTransferDisabled = TRUE;
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ResetSpriteData();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 6:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (!MenuHelpers_LinkSomething())
|
2018-01-30 19:19:37 +01:00
|
|
|
ResetTasks();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 7:
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_InitBGs();
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState = 0;
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 8:
|
2019-05-19 19:10:06 +02:00
|
|
|
if (!LoadBagMenu_Graphics())
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 9:
|
2019-05-19 19:10:06 +02:00
|
|
|
SetupBagMenu_Textboxes();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 10:
|
2020-05-14 10:37:09 +02:00
|
|
|
All_CalculateNItemsAndMaxShowed();
|
2018-12-15 19:08:13 +01:00
|
|
|
SetPocketListPositions();
|
2020-05-14 10:37:09 +02:00
|
|
|
UpdatePocketScrollPositions();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 11:
|
2019-05-19 19:10:06 +02:00
|
|
|
AllocateBagItemListBuffers();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 12:
|
2019-05-19 19:10:06 +02:00
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 13:
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintPocketNames(gPocketNamesStringsTable[gBagPositionStruct.pocket], 0);
|
|
|
|
BagMenu_CopyPocketNameToWindow(0);
|
2020-08-28 19:31:58 +02:00
|
|
|
DrawPocketIndicatorSquare(gBagPositionStruct.pocket, TRUE);
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 14:
|
2020-05-14 10:37:09 +02:00
|
|
|
taskId = CreateBagInputHandlerTask(gBagPositionStruct.location);
|
2019-05-19 19:10:06 +02:00
|
|
|
gTasks[taskId].data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2018-01-30 19:19:37 +01:00
|
|
|
gTasks[taskId].data[3] = 0;
|
2020-03-08 05:03:21 +01:00
|
|
|
gTasks[taskId].tItemCount = 0;
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 15:
|
2019-05-19 19:10:06 +02:00
|
|
|
AddBagVisualSprite(gBagPositionStruct.pocket);
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
sub_80D4FAC();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 17:
|
2020-05-14 10:37:09 +02:00
|
|
|
CreatePocketScrollArrowPair();
|
|
|
|
CreatePocketSwitchArrowPair();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 18:
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrepareTMHMMoveWindow();
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 19:
|
2020-05-14 10:37:09 +02:00
|
|
|
BlendPalettes(0xFFFFFFFF, 16, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 20:
|
2019-04-04 23:05:46 +02:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
|
2018-01-30 19:19:37 +01:00
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
default:
|
2020-05-14 10:37:09 +02:00
|
|
|
SetVBlankCallback(VBlankCB_BagMenuRun);
|
|
|
|
SetMainCallback2(CB2_BagMenuRun);
|
2018-01-30 19:19:37 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_InitBGs(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
ResetVramOamAndBgCntRegs();
|
2019-05-19 19:10:06 +02:00
|
|
|
memset(gBagMenu->tilemapBuffer, 0, 0x800);
|
2018-01-30 19:19:37 +01:00
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2018-12-15 19:08:13 +01:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates_ItemMenu, 3);
|
2019-05-19 19:10:06 +02:00
|
|
|
SetBgTilemapBuffer(2, gBagMenu->tilemapBuffer);
|
2018-01-30 19:19:37 +01:00
|
|
|
ResetAllBgsCoordinates();
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2018-02-12 19:59:42 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
2018-01-30 19:19:37 +01:00
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
bool8 LoadBagMenu_Graphics(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
switch (gBagMenu->graphicsLoadState)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2020-05-14 10:37:09 +02:00
|
|
|
ResetTempTileDataBuffers();
|
|
|
|
DecompressAndCopyTileDataToVram(2, gBagScreen_Gfx, 0, 0, 0);
|
|
|
|
gBagMenu->graphicsLoadState++;
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (FreeTempTileDataBuffersIfPossible() != TRUE)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
LZDecompressWram(gBagScreen_GfxTileMap, gBagMenu->tilemapBuffer);
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState++;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsWallysBag() && gSaveBlock2Ptr->playerGender != MALE)
|
|
|
|
LoadCompressedPalette(gBagScreenFemale_Pal, 0, 0x40);
|
|
|
|
else
|
|
|
|
LoadCompressedPalette(gBagScreenMale_Pal, 0, 0x40);
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState++;
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (IsWallysBag() == TRUE || gSaveBlock2Ptr->playerGender == MALE)
|
2019-05-19 19:10:06 +02:00
|
|
|
LoadCompressedSpriteSheet(&gBagMaleSpriteSheet);
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
LoadCompressedSpriteSheet(&gBagFemaleSpriteSheet);
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState++;
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2019-05-19 19:10:06 +02:00
|
|
|
LoadCompressedSpritePalette(&gBagPaletteTable);
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState++;
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LoadListMenuArrowsGfx();
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->graphicsLoadState = 0;
|
2018-01-30 19:19:37 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 CreateBagInputHandlerTask(u8 location)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (location == ITEMMENULOCATION_WALLY)
|
2018-01-30 19:19:37 +01:00
|
|
|
taskId = CreateTask(Task_WallyTutorialBagMenu, 0);
|
|
|
|
else
|
2020-05-14 10:37:09 +02:00
|
|
|
taskId = CreateTask(Task_BagMenu_HandleInput, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void AllocateBagItemListBuffers(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2018-12-15 19:08:13 +01:00
|
|
|
sListBuffer1 = Alloc(sizeof(struct ListBuffer1));
|
|
|
|
sListBuffer2 = Alloc(sizeof(struct ListBuffer2));
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void LoadBagItemListBuffers(u8 pocketId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
struct BagPocket *pocket = &gBagPockets[pocketId];
|
|
|
|
struct ListMenuItem *subBuffer;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
if (!gBagMenu->hideCloseBagText)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
for (i = 0; i < gBagMenu->numItemStacks[pocketId] - 1; i++)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
GetItemName(sListBuffer2->name[i], pocket->itemSlots[i].itemId);
|
2018-12-15 19:08:13 +01:00
|
|
|
subBuffer = sListBuffer1->subBuffers;
|
|
|
|
subBuffer[i].name = sListBuffer2->name[i];
|
2018-01-30 19:19:37 +01:00
|
|
|
subBuffer[i].id = i;
|
|
|
|
}
|
2018-12-15 19:08:13 +01:00
|
|
|
StringCopy(sListBuffer2->name[i], gText_CloseBag);
|
|
|
|
subBuffer = sListBuffer1->subBuffers;
|
|
|
|
subBuffer[i].name = sListBuffer2->name[i];
|
2020-05-14 10:37:09 +02:00
|
|
|
subBuffer[i].id = LIST_CANCEL;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
for (i = 0; i < gBagMenu->numItemStacks[pocketId]; i++)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
GetItemName(sListBuffer2->name[i], pocket->itemSlots[i].itemId);
|
2018-12-15 19:08:13 +01:00
|
|
|
subBuffer = sListBuffer1->subBuffers;
|
|
|
|
subBuffer[i].name = sListBuffer2->name[i];
|
2018-01-30 19:19:37 +01:00
|
|
|
subBuffer[i].id = i;
|
|
|
|
}
|
|
|
|
}
|
2018-12-15 19:08:13 +01:00
|
|
|
gMultiuseListMenuTemplate = sItemListMenu;
|
2019-05-19 19:10:06 +02:00
|
|
|
gMultiuseListMenuTemplate.totalItems = gBagMenu->numItemStacks[pocketId];
|
2018-12-15 19:08:13 +01:00
|
|
|
gMultiuseListMenuTemplate.items = sListBuffer1->subBuffers;
|
2019-05-19 19:10:06 +02:00
|
|
|
gMultiuseListMenuTemplate.maxShowed = gBagMenu->numShownItems[pocketId];
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void GetItemName(s8 *dest, u16 itemId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
switch (gBagPositionStruct.pocket)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2018-12-10 10:32:00 +01:00
|
|
|
case TMHM_POCKET:
|
2018-01-30 19:19:37 +01:00
|
|
|
StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(itemId)]);
|
|
|
|
if (itemId >= ITEM_HM01)
|
|
|
|
{
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_HM01 + 1, STR_CONV_MODE_LEADING_ZEROS, 1);
|
2018-01-30 19:19:37 +01:00
|
|
|
StringExpandPlaceholders(dest, gText_ClearTo11Var1Clear5Var2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_TM01 + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
|
2019-12-10 19:48:20 +01:00
|
|
|
StringExpandPlaceholders(dest, gText_NumberVar1Clear7Var2);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
break;
|
2018-12-10 10:32:00 +01:00
|
|
|
case BERRIES_POCKET:
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_CHERI_BERRY + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
|
2018-01-30 19:19:37 +01:00
|
|
|
CopyItemName(itemId, gStringVar2);
|
2019-12-10 19:48:20 +01:00
|
|
|
StringExpandPlaceholders(dest, gText_NumberVar1Clear7Var2);
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CopyItemName(itemId, dest);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_MoveCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (onInit != TRUE)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-05-14 10:37:09 +02:00
|
|
|
ShakeBagSprite();
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->itemOriginalLocation == 0xFF)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
RemoveBagItemIconSprite(gBagMenu->itemIconSlot ^ 1);
|
|
|
|
if (itemIndex != LIST_CANCEL)
|
|
|
|
AddBagItemIconSprite(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex), gBagMenu->itemIconSlot);
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2020-05-14 10:37:09 +02:00
|
|
|
AddBagItemIconSprite(-1, gBagMenu->itemIconSlot);
|
|
|
|
gBagMenu->itemIconSlot ^= 1;
|
|
|
|
if (!gBagMenu->inhibitItemDescriptionPrint)
|
|
|
|
BagMenu_PrintDescription(itemIndex);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 y)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u16 itemId;
|
|
|
|
u16 itemQuantity;
|
|
|
|
int offset;
|
2020-05-14 10:37:09 +02:00
|
|
|
|
|
|
|
if (itemIndex != LIST_CANCEL)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->itemOriginalLocation != 0xFF)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->itemOriginalLocation == (u8)itemIndex)
|
|
|
|
BagMenu_PrintCursor(y, 2);
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2020-05-14 10:37:09 +02:00
|
|
|
BagMenu_PrintCursor(y, 0xFF);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
|
|
|
|
itemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex);
|
|
|
|
itemQuantity = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex);
|
|
|
|
|
2018-09-02 00:28:03 +02:00
|
|
|
if (itemId >= ITEM_HM01 && itemId <= ITEM_HM08)
|
2020-05-14 10:37:09 +02:00
|
|
|
BlitBitmapToWindow(windowId, gBagMenuHMIcon_Gfx, 8, y - 1, 16, 16);
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagPositionStruct.pocket == BERRIES_POCKET)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-09-25 17:18:52 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BERRY_CAPACITY_DIGITS);
|
2018-01-30 19:19:37 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
2020-05-14 10:37:09 +02:00
|
|
|
offset = GetStringRightAlignXOffset(7, gStringVar4, 119);
|
|
|
|
BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, -1, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
else if (gBagPositionStruct.pocket != KEYITEMS_POCKET && ItemId_GetImportance(itemId) == FALSE)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-09-25 17:18:52 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BAG_ITEM_CAPACITY_DIGITS);
|
2018-01-30 19:19:37 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
2020-05-14 10:37:09 +02:00
|
|
|
offset = GetStringRightAlignXOffset(7, gStringVar4, 119);
|
|
|
|
BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, -1, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->registeredItem && gSaveBlock1Ptr->registeredItem == itemId)
|
2020-05-14 10:37:09 +02:00
|
|
|
BlitBitmapToWindow(windowId, sRegisteredSelect_Gfx, 96, y - 1, 24, 16);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_PrintDescription(int itemIndex)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2018-09-02 00:28:03 +02:00
|
|
|
const u8 *str;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (itemIndex != LIST_CANCEL)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
str = ItemId_GetDescription(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, itemIndex));
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
StringCopy(gStringVar1, gReturnToXStringsTable[gBagPositionStruct.location]);
|
2018-02-09 03:00:28 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1);
|
2018-01-30 19:19:37 +01:00
|
|
|
str = gStringVar4;
|
|
|
|
}
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, str, 3, 1, 0, 0, 0, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_PrintCursor_(u8 listTaskId, u8 colorIndex)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
BagMenu_PrintCursor(ListMenuGetYCoordForPrintingArrowCursor(listTaskId), colorIndex);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_PrintCursor(u8 y, u8 colorIndex)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (colorIndex == 0xFF)
|
|
|
|
FillWindowPixelRect(0, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2020-05-14 10:37:09 +02:00
|
|
|
BagMenu_Print(0, 1, gText_SelectorArrow2, 0, y, 0, 0, 0, colorIndex);
|
2018-01-30 19:19:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void CreatePocketScrollArrowPair(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->pocketScrollArrowsTask == 0xFF)
|
|
|
|
gBagMenu->pocketScrollArrowsTask = AddScrollIndicatorArrowPairParameterized(
|
|
|
|
SCROLL_ARROW_UP,
|
|
|
|
172,
|
|
|
|
12,
|
|
|
|
148,
|
|
|
|
gBagMenu->numItemStacks[gBagPositionStruct.pocket] - gBagMenu->numShownItems[gBagPositionStruct.pocket],
|
|
|
|
110,
|
|
|
|
110,
|
|
|
|
&gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagDestroyPocketScrollArrowPair(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->pocketScrollArrowsTask != 0xFF)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(gBagMenu->pocketScrollArrowsTask);
|
|
|
|
gBagMenu->pocketScrollArrowsTask = 0xFF;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
BagDestroyPocketSwitchArrowPair();
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void CreatePocketSwitchArrowPair(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->pocketSwitchDisabled != TRUE && gBagMenu->pocketSwitchArrowsTask == 0xFF)
|
|
|
|
gBagMenu->pocketSwitchArrowsTask = AddScrollIndicatorArrowPair(&sBagScrollArrowsTemplate, &gBagPositionStruct.unk6);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagDestroyPocketSwitchArrowPair(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->pocketSwitchArrowsTask != 0xFF)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(gBagMenu->pocketSwitchArrowsTask);
|
|
|
|
gBagMenu->pocketSwitchArrowsTask = 0xFF;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void FreeBagItemListBuffers(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2018-12-15 19:08:13 +01:00
|
|
|
Free(sListBuffer2);
|
|
|
|
Free(sListBuffer1);
|
2018-01-30 19:19:37 +01:00
|
|
|
FreeAllWindowBuffers();
|
2019-05-19 19:10:06 +02:00
|
|
|
Free(gBagMenu);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
void Task_FadeAndCloseBagMenu(u8 taskId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-04-04 23:05:46 +02:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
|
2019-05-19 19:10:06 +02:00
|
|
|
gTasks[taskId].func = TaskCloseBagMenu_2;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void TaskCloseBagMenu_2(u8 taskId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
DestroyListMenuTask(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->exitCallback != NULL)
|
|
|
|
SetMainCallback2(gBagMenu->exitCallback);
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
SetMainCallback2(gBagPositionStruct.bagCallback);
|
2020-05-14 10:37:09 +02:00
|
|
|
BagDestroyPocketScrollArrowPair();
|
2018-01-30 19:19:37 +01:00
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
2019-05-19 19:10:06 +02:00
|
|
|
FreeBagItemListBuffers();
|
2018-01-30 19:19:37 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
void UpdatePocketItemList(u8 pocketId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
struct BagPocket *pocket = &gBagPockets[pocketId];
|
|
|
|
switch (pocketId)
|
|
|
|
{
|
2018-12-10 10:32:00 +01:00
|
|
|
case TMHM_POCKET:
|
|
|
|
case BERRIES_POCKET:
|
2018-04-29 13:36:26 +02:00
|
|
|
SortBerriesOrTMHMs(pocket);
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
2018-04-29 13:36:26 +02:00
|
|
|
CompactItemsInBagPocket(pocket);
|
2018-01-30 19:19:37 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagMenu->numItemStacks[pocketId] = 0;
|
2020-05-14 10:37:09 +02:00
|
|
|
|
2018-01-30 19:19:37 +01:00
|
|
|
for (i = 0; i < pocket->capacity && pocket->itemSlots[i].itemId; i++)
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagMenu->numItemStacks[pocketId]++;
|
2018-12-15 19:08:13 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
if (!gBagMenu->hideCloseBagText)
|
|
|
|
gBagMenu->numItemStacks[pocketId]++;
|
2018-12-15 19:08:13 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagMenu->numItemStacks[pocketId] > 8)
|
|
|
|
gBagMenu->numShownItems[pocketId] = 8;
|
2018-01-30 19:19:37 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagMenu->numShownItems[pocketId] = gBagMenu->numItemStacks[pocketId];
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void All_CalculateNItemsAndMaxShowed(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-12-10 10:32:00 +01:00
|
|
|
for (i = 0; i < POCKETS_COUNT; i++)
|
2020-01-08 11:43:06 +01:00
|
|
|
UpdatePocketItemList(i);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
void SetInitialScrollAndCursorPositions(u8 pocketId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_812225C(&gBagPositionStruct.scrollPosition[pocketId], &gBagPositionStruct.cursorPosition[pocketId], gBagMenu->numShownItems[pocketId], gBagMenu->numItemStacks[pocketId]);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
static void SetPocketListPositions(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-12-10 10:32:00 +01:00
|
|
|
for (i = 0; i < POCKETS_COUNT; i++)
|
2018-12-15 19:08:13 +01:00
|
|
|
SetInitialScrollAndCursorPositions(i);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void UpdatePocketScrollPositions(void)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-12-10 10:32:00 +01:00
|
|
|
for (i = 0; i < POCKETS_COUNT; i++)
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_8122298(&gBagPositionStruct.scrollPosition[i], &gBagPositionStruct.cursorPosition[i], gBagMenu->numShownItems[i], gBagMenu->numItemStacks[i], 8);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2018-12-15 19:08:13 +01:00
|
|
|
u8 GetItemListPosition(u8 pocketId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
return gBagPositionStruct.scrollPosition[pocketId] + gBagPositionStruct.cursorPosition[pocketId];
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void (*callback)(u8 taskId))
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-01-30 19:19:37 +01:00
|
|
|
data[10] = AddItemMessageWindow(4);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(data[10], PIXEL_FILL(1));
|
2018-11-06 18:30:21 +01:00
|
|
|
DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeedDelay(), str, callback);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_InitListsMenu(u8 taskId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2020-08-28 19:31:58 +02:00
|
|
|
BagMenu_RemoveBagItemMessageindow(4);
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2020-01-08 11:43:06 +01:00
|
|
|
UpdatePocketItemList(gBagPositionStruct.pocket);
|
2019-05-19 19:10:06 +02:00
|
|
|
SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket);
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-01-30 19:19:37 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81ABC3C(u8 a)
|
|
|
|
{
|
2019-06-30 00:47:48 +02:00
|
|
|
PrintItemDepositAmount(BagMenu_AddWindow(a), 1);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-09-30 21:53:24 +02:00
|
|
|
void PrintItemDepositAmount(u8 windowId, s16 numDeposited)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-09-25 17:18:52 +02:00
|
|
|
u8 numDigits = (gBagPositionStruct.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS;
|
2019-09-30 21:53:24 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, numDeposited, STR_CONV_MODE_LEADING_ZEROS, numDigits);
|
2018-01-30 19:19:37 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
2019-09-30 21:53:24 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 0x28), 2, 0, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2019-09-30 21:53:24 +02:00
|
|
|
void PrintItemSoldAmount(int windowId, int numSold, int moneyEarned)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-09-25 17:18:52 +02:00
|
|
|
u8 numDigits = (gBagPositionStruct.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS;
|
2019-09-30 21:53:24 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, numSold, STR_CONV_MODE_LEADING_ZEROS, numDigits);
|
2018-01-30 19:19:37 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
2019-09-30 21:53:24 +02:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gStringVar4, 0, 1, -1, 0);
|
|
|
|
PrintMoneyAmount(windowId, 38, 1, moneyEarned, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_BagMenu_HandleInput(u8 taskId)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2020-05-14 10:37:09 +02:00
|
|
|
s32 listPosition;
|
|
|
|
|
|
|
|
if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
|
|
|
switch (GetSwitchBagPocketDirection())
|
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
case SWITCH_POCKET_LEFT:
|
|
|
|
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
return;
|
2020-08-28 19:31:58 +02:00
|
|
|
case SWITCH_POCKET_RIGHT:
|
|
|
|
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0);
|
2018-01-30 19:19:37 +01:00
|
|
|
return;
|
2020-05-14 10:37:09 +02:00
|
|
|
default:
|
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 (gMain.newKeys & SELECT_BUTTON)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (CanSwapItems() == TRUE)
|
2020-05-14 10:37:09 +02:00
|
|
|
{
|
|
|
|
ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos);
|
|
|
|
if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1)
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
BagMenu_SwapItems(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
break;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
|
|
|
|
listPosition = ListMenu_ProcessInput(data[0]);
|
|
|
|
ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos);
|
|
|
|
switch (listPosition)
|
2018-01-30 19:19:37 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
|
|
|
break;
|
|
|
|
case LIST_CANCEL:
|
|
|
|
if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH)
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2018-02-09 03:00:28 +01:00
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
}
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
gSpecialVar_ItemId = ITEM_NONE;
|
|
|
|
gTasks[taskId].func = Task_FadeAndCloseBagMenu;
|
|
|
|
break;
|
|
|
|
default: // A_BUTTON
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
BagDestroyPocketScrollArrowPair();
|
|
|
|
BagMenu_PrintCursor_(data[0], 2);
|
|
|
|
data[1] = listPosition;
|
|
|
|
data[2] = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, listPosition);
|
|
|
|
gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, listPosition);
|
|
|
|
gUnknown_08614054[gBagPositionStruct.location](taskId);
|
|
|
|
break;
|
2018-01-30 19:19:37 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-30 22:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_callback3_to_bag(u8 taskId)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
CreatePocketScrollArrowPair();
|
|
|
|
CreatePocketSwitchArrowPair();
|
2018-01-30 22:12:40 +01:00
|
|
|
ClearWindowTilemap(3);
|
|
|
|
ClearWindowTilemap(4);
|
|
|
|
PutWindowTilemap(1);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
gTasks[taskId].func = Task_BagMenu_HandleInput;
|
2018-01-30 22:12:40 +01:00
|
|
|
}
|
2018-02-01 02:22:51 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static u8 GetSwitchBagPocketDirection(void)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
|
|
|
u8 LRKeys;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->pocketSwitchDisabled)
|
2020-08-28 19:31:58 +02:00
|
|
|
return SWITCH_POCKET_NONE;
|
2019-10-18 01:22:03 +02:00
|
|
|
LRKeys = GetLRKeysPressed();
|
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 ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
return SWITCH_POCKET_LEFT;
|
2018-02-01 02:22:51 +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
|
|
|
if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == MENU_R_PRESSED)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
return SWITCH_POCKET_RIGHT;
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
2020-08-28 19:31:58 +02:00
|
|
|
return SWITCH_POCKET_NONE;
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
2018-12-10 10:32:00 +01:00
|
|
|
if (deltaBagPocketId == 1 && *bagPocketId == POCKETS_COUNT - 1)
|
2018-02-01 02:22:51 +01:00
|
|
|
*bagPocketId = 0;
|
|
|
|
else if (deltaBagPocketId == -1 && *bagPocketId == 0)
|
2018-12-10 10:32:00 +01:00
|
|
|
*bagPocketId = POCKETS_COUNT - 1;
|
2018-02-01 02:22:51 +01:00
|
|
|
else
|
|
|
|
*bagPocketId += deltaBagPocketId;
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
|
|
|
u8 pocketId;
|
|
|
|
|
|
|
|
data[13] = 0;
|
|
|
|
data[12] = 0;
|
|
|
|
data[11] = deltaBagPocketId;
|
|
|
|
if (a3 == 0)
|
|
|
|
{
|
|
|
|
ClearWindowTilemap(0);
|
|
|
|
ClearWindowTilemap(1);
|
2019-05-19 19:10:06 +02:00
|
|
|
DestroyListMenuTask(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
gSprites[gBagMenu->spriteId[2 + (gBagMenu->itemIconSlot ^ 1)]].invisible = TRUE;
|
|
|
|
BagDestroyPocketScrollArrowPair();
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
pocketId = gBagPositionStruct.pocket;
|
2018-02-01 02:22:51 +01:00
|
|
|
ChangeBagPocketId(&pocketId, deltaBagPocketId);
|
2020-08-28 19:31:58 +02:00
|
|
|
if (deltaBagPocketId == MENU_CURSOR_DELTA_RIGHT)
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintPocketNames(gPocketNamesStringsTable[gBagPositionStruct.pocket], gPocketNamesStringsTable[pocketId]);
|
|
|
|
BagMenu_CopyPocketNameToWindow(0);
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintPocketNames(gPocketNamesStringsTable[pocketId], gPocketNamesStringsTable[gBagPositionStruct.pocket]);
|
|
|
|
BagMenu_CopyPocketNameToWindow(8);
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
2020-08-28 19:31:58 +02:00
|
|
|
DrawPocketIndicatorSquare(gBagPositionStruct.pocket, FALSE);
|
|
|
|
DrawPocketIndicatorSquare(pocketId, TRUE);
|
2018-02-01 02:22:51 +01:00
|
|
|
FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2018-02-01 02:22:51 +01:00
|
|
|
SetBagVisualPocketId(pocketId, 1);
|
2018-03-04 18:41:07 +01:00
|
|
|
RemoveBagSprite(1);
|
|
|
|
AddSwitchPocketRotatingBallSprite(deltaBagPocketId);
|
2018-02-01 02:22:51 +01:00
|
|
|
SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AC10C(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
if (!MenuHelpers_LinkSomething() && !IsWallysBag())
|
2018-02-01 02:22:51 +01:00
|
|
|
{
|
|
|
|
switch (GetSwitchBagPocketDirection())
|
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
case SWITCH_POCKET_LEFT:
|
2019-05-19 19:10:06 +02:00
|
|
|
ChangeBagPocketId(&gBagPositionStruct.pocket, data[11]);
|
2018-02-01 02:22:51 +01:00
|
|
|
SwitchTaskToFollowupFunc(taskId);
|
2020-08-28 19:31:58 +02:00
|
|
|
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 1);
|
2018-02-01 02:22:51 +01:00
|
|
|
return;
|
2020-08-28 19:31:58 +02:00
|
|
|
case SWITCH_POCKET_RIGHT:
|
2019-05-19 19:10:06 +02:00
|
|
|
ChangeBagPocketId(&gBagPositionStruct.pocket, data[11]);
|
2018-02-01 02:22:51 +01:00
|
|
|
SwitchTaskToFollowupFunc(taskId);
|
2020-08-28 19:31:58 +02:00
|
|
|
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 1);
|
2018-02-01 02:22:51 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (data[13])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_81AC23C(data[12]);
|
|
|
|
if (!(++data[12] & 1))
|
|
|
|
{
|
|
|
|
if (data[11] == 1)
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_CopyPocketNameToWindow((u8)(data[12] >> 1));
|
2018-02-01 02:22:51 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_CopyPocketNameToWindow((u8)(8 - (data[12] >> 1)));
|
2018-02-01 02:22:51 +01:00
|
|
|
}
|
|
|
|
if (data[12] == 16)
|
|
|
|
data[13]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-05-19 19:10:06 +02:00
|
|
|
ChangeBagPocketId(&gBagPositionStruct.pocket, data[11]);
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2018-02-01 02:22:51 +01:00
|
|
|
PutWindowTilemap(1);
|
|
|
|
PutWindowTilemap(2);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
CreatePocketScrollArrowPair();
|
|
|
|
CreatePocketSwitchArrowPair();
|
2018-02-01 02:22:51 +01:00
|
|
|
SwitchTaskToFollowupFunc(taskId);
|
|
|
|
}
|
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
|
|
|
|
void sub_81AC23C(u8 a)
|
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect_Palette0(2, 17, 14, a + 2, 15, 1);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void DrawPocketIndicatorSquare(u8 x, bool8 isCurrentPocket)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (!isCurrentPocket)
|
2018-02-05 05:47:47 +01:00
|
|
|
FillBgTilemapBufferRect_Palette0(2, 0x1017, x + 5, 3, 1, 1);
|
|
|
|
else
|
|
|
|
FillBgTilemapBufferRect_Palette0(2, 0x102B, x + 5, 3, 1, 1);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static bool8 CanSwapItems(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagPositionStruct.location <= ITEMMENULOCATION_BATTLE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
u8 temp = gBagPositionStruct.pocket - 2;
|
2018-02-05 05:47:47 +01:00
|
|
|
if (temp > 1)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_SwapItems(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-07-15 13:23:38 +02:00
|
|
|
ListMenuSetUnkIndicatorsStructField(data[0], 16, 1);
|
2019-05-19 19:10:06 +02:00
|
|
|
data[1] = gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket] + gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->itemOriginalLocation = data[1];
|
2019-05-19 19:10:06 +02:00
|
|
|
CopyItemName(BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, data[1]), gStringVar1);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_80D4FEC(data[1]);
|
2020-05-14 10:37:09 +02:00
|
|
|
BagDestroyPocketSwitchArrowPair();
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 2);
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = Task_HandleSwappingItemsInput;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void Task_HandleSwappingItemsInput(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-02-02 11:04:38 +01:00
|
|
|
int input;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
if (MenuHelpers_CallLinkSomething() != TRUE)
|
2018-02-05 05:47:47 +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
|
|
|
if (gMain.newKeys & SELECT_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
ListMenuGetScrollAndRow(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_81AC498(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
input = ListMenu_ProcessInput(data[0]);
|
2019-05-19 19:10:06 +02:00
|
|
|
ListMenuGetScrollAndRow(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_80D4FC8(0);
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_80D4FEC(gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]);
|
2019-02-02 11:04:38 +01:00
|
|
|
switch (input)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2018-02-05 05:47:47 +01:00
|
|
|
PlaySE(SE_SELECT);
|
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 (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_81AC498(taskId);
|
|
|
|
else
|
|
|
|
sub_81AC590(taskId);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_81AC498(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AC498(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2018-02-09 03:00:28 +01:00
|
|
|
u16 realPos = (*scrollPos + *cursorPos);
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[1] == realPos || data[1] == (realPos - 1))
|
|
|
|
sub_81AC590(taskId);
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
MoveItemSlotInList(gBagPockets[gBagPositionStruct.pocket].itemSlots, data[1], realPos);
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->itemOriginalLocation = -1;
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[1] < realPos)
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]--;
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
|
|
|
sub_80D4FC8(1);
|
2020-05-14 10:37:09 +02:00
|
|
|
CreatePocketSwitchArrowPair();
|
|
|
|
gTasks[taskId].func = Task_BagMenu_HandleInput;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AC590(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->itemOriginalLocation = -1;
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[1] < (*scrollPos + *cursorPos))
|
2019-05-19 19:10:06 +02:00
|
|
|
gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]--;
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
|
|
|
sub_80D4FC8(1);
|
2020-05-14 10:37:09 +02:00
|
|
|
CreatePocketSwitchArrowPair();
|
|
|
|
gTasks[taskId].func = Task_BagMenu_HandleInput;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void OpenContextMenu(u8 unused)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
switch (gBagPositionStruct.location)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_BATTLE:
|
|
|
|
case ITEMMENULOCATION_WALLY:
|
2018-02-05 05:47:47 +01:00
|
|
|
if (ItemId_GetBattleUsage(gSpecialVar_ItemId))
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_BattleUse;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BattleUse);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_BERRY_BLENDER_CRUSH:
|
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_BerryBlenderCrush;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BerryBlenderCrush);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_APPRENTICE:
|
2018-04-29 13:36:26 +02:00
|
|
|
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Apprentice;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Apprentice);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_FAVOR_LADY:
|
2018-04-29 13:36:26 +02:00
|
|
|
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_FavorLady;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_FavorLady);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_QUIZ_LADY:
|
2018-04-29 13:36:26 +02:00
|
|
|
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_QuizLady;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_QuizLady);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-05-14 10:37:09 +02:00
|
|
|
case ITEMMENULOCATION_PARTY:
|
|
|
|
case ITEMMENULOCATION_SHOP:
|
|
|
|
case ITEMMENULOCATION_BERRY_TREE:
|
|
|
|
case ITEMMENULOCATION_ITEMPC:
|
2018-02-05 05:47:47 +01:00
|
|
|
default:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (MenuHelpers_LinkSomething() == TRUE || InUnionRoom() == TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagPositionStruct.pocket == KEYITEMS_POCKET || !sub_8122148(gSpecialVar_ItemId))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Cancel;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Cancel);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_Give;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_Give);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
switch (gBagPositionStruct.pocket)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2018-12-10 10:32:00 +01:00
|
|
|
case ITEMS_POCKET:
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = gBagMenu->contextMenuItemsBuffer;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_ItemsPocket);
|
|
|
|
memcpy(&gBagMenu->contextMenuItemsBuffer, &sContextMenuItems_ItemsPocket, sizeof(sContextMenuItems_ItemsPocket));
|
2018-02-05 05:47:47 +01:00
|
|
|
if (ItemIsMail(gSpecialVar_ItemId) == TRUE)
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsBuffer[0] = ITEMMENUACTION_CHECK;
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2018-12-10 10:32:00 +01:00
|
|
|
case KEYITEMS_POCKET:
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = gBagMenu->contextMenuItemsBuffer;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_KeyItemsPocket);
|
|
|
|
memcpy(&gBagMenu->contextMenuItemsBuffer, &sContextMenuItems_KeyItemsPocket, sizeof(sContextMenuItems_KeyItemsPocket));
|
2018-02-05 05:47:47 +01:00
|
|
|
if (gSaveBlock1Ptr->registeredItem == gSpecialVar_ItemId)
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsBuffer[1] = ITEMMENUACTION_DESELECT;
|
2018-02-05 05:47:47 +01:00
|
|
|
if (gSpecialVar_ItemId == ITEM_MACH_BIKE || gSpecialVar_ItemId == ITEM_ACRO_BIKE)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
|
|
|
|
gBagMenu->contextMenuItemsBuffer[0] = ITEMMENUACTION_WALK;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2018-12-10 10:32:00 +01:00
|
|
|
case BALLS_POCKET:
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_BallsPocket;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BallsPocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2018-12-10 10:32:00 +01:00
|
|
|
case TMHM_POCKET:
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_TmHmPocket;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_TmHmPocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2018-12-10 10:32:00 +01:00
|
|
|
case BERRIES_POCKET:
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->contextMenuItemsPtr = sContextMenuItems_BerriesPocket;
|
|
|
|
gBagMenu->contextMenuNumItems = ARRAY_COUNT(sContextMenuItems_BerriesPocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagPositionStruct.pocket == TMHM_POCKET)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
ClearWindowTilemap(1);
|
|
|
|
PrintTMHMMoveData(gSpecialVar_ItemId);
|
|
|
|
PutWindowTilemap(3);
|
|
|
|
PutWindowTilemap(4);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->contextMenuNumItems == 1)
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_81ACAF8(BagMenu_AddWindow(0));
|
2020-05-14 10:37:09 +02:00
|
|
|
else if (gBagMenu->contextMenuNumItems == 2)
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_81ACAF8(BagMenu_AddWindow(1));
|
2020-05-14 10:37:09 +02:00
|
|
|
else if (gBagMenu->contextMenuNumItems == 4)
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_81ACB54(BagMenu_AddWindow(2), 2, 2);
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
sub_81ACB54(BagMenu_AddWindow(3), 2, 3);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81ACAF8(u8 a)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
AddItemMenuActionTextPrinters(a, 7, 8, 1, 0, 16, gBagMenu->contextMenuNumItems, sItemMenuActions, gBagMenu->contextMenuItemsPtr);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(a, gBagMenu->contextMenuNumItems, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81ACB54(u8 a, u8 b, u8 c)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
sub_8198DBC(a, 7, 8, 1, 0x38, b, c, sItemMenuActions, gBagMenu->contextMenuItemsPtr);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_8199944(a, 0x38, b, c, 0);
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_FieldOrBattle(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
OpenContextMenu(taskId);
|
|
|
|
if (gBagMenu->contextMenuNumItems <= 2)
|
2018-02-05 05:47:47 +01:00
|
|
|
gTasks[taskId].func = Task_HandleInBattleItemMenuInput;
|
|
|
|
else
|
|
|
|
gTasks[taskId].func = Task_HandleOutOfBattleItemMenuInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Task_HandleInBattleItemMenuInput(u8 taskId)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (MenuHelpers_CallLinkSomething() != TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
s8 selection = Menu_ProcessInputNoWrap();
|
|
|
|
switch (selection)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_NOTHING_CHOSEN:
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_B_PRESSED:
|
2018-02-05 05:47:47 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2020-05-14 10:37:09 +02:00
|
|
|
sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
2020-05-14 10:37:09 +02:00
|
|
|
sItemMenuActions[gBagMenu->contextMenuItemsPtr[selection]].func.void_u8(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Task_HandleOutOfBattleItemMenuInput(u8 taskId)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (MenuHelpers_CallLinkSomething() != TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
s8 cursorPos = Menu_GetCursorPos();
|
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 (gMain.newKeys & DPAD_UP)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2))
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & DPAD_DOWN)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && sub_81ACDFC(cursorPos + 2))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
|
2018-02-05 05:47:47 +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
|
|
|
else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1))
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
|
2018-02-05 05:47:47 +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
|
|
|
else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1))
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-05-14 10:37:09 +02:00
|
|
|
sItemMenuActions[gBagMenu->contextMenuItemsPtr[cursorPos]].func.void_u8(taskId);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-05-14 10:37:09 +02:00
|
|
|
sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 sub_81ACDFC(s8 a)
|
|
|
|
{
|
|
|
|
if (a < 0)
|
|
|
|
return FALSE;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (a > gBagMenu->contextMenuNumItems)
|
2018-02-05 05:47:47 +01:00
|
|
|
return FALSE;
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->contextMenuItemsPtr[a] == 14)
|
2018-02-05 05:47:47 +01:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_RemoveSomeWindow(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
if (gBagMenu->contextMenuNumItems == 1)
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(0);
|
2020-05-14 10:37:09 +02:00
|
|
|
else if (gBagMenu->contextMenuNumItems == 2)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(1);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
else if (gBagMenu->contextMenuNumItems == 4)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(2);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(3);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_UseOutOfBattle(u8 taskId)
|
|
|
|
{
|
|
|
|
if (ItemId_GetFieldFunc(gSpecialVar_ItemId))
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2018-02-05 05:47:47 +01:00
|
|
|
if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == 1)
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintThereIsNoPokemon(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagPositionStruct.pocket != BERRIES_POCKET)
|
2018-02-05 05:47:47 +01:00
|
|
|
ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId);
|
|
|
|
else
|
2019-10-20 08:31:51 +02:00
|
|
|
ItemUseOutOfBattle_Berry(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_Toss(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2020-03-08 05:03:21 +01:00
|
|
|
tItemCount = 1;
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[2] == 1)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_TossItems(taskId);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_81ABC3C(7);
|
|
|
|
gTasks[taskId].func = Task_ChooseHowManyToToss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_TossItems(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
2020-09-25 17:18:52 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
|
|
|
BagMenu_YesNo(taskId, 5, &sYesNoTossFunctions);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_CancelToss(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintDescription(data[1]);
|
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Task_ChooseHowManyToToss(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2020-07-11 16:22:34 +02:00
|
|
|
PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
|
2018-02-09 03:00:28 +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
|
|
|
else if (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(7);
|
|
|
|
BagMenu_TossItems(taskId);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(7);
|
|
|
|
BagMenu_CancelToss(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_ConfirmToss(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
2020-09-25 17:18:52 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
gTasks[taskId].func = Task_ActuallyToss;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Task_ActuallyToss(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2018-02-14 01:12:17 +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
|
|
|
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-03-08 05:03:21 +01:00
|
|
|
RemoveBagItem(gSpecialVar_ItemId, tItemCount);
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2020-01-08 11:43:06 +01:00
|
|
|
UpdatePocketItemList(gBagPositionStruct.pocket);
|
2019-05-19 19:10:06 +02:00
|
|
|
SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket);
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_Register(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
if (gSaveBlock1Ptr->registeredItem == gSpecialVar_ItemId)
|
|
|
|
gSaveBlock1Ptr->registeredItem = 0;
|
|
|
|
else
|
|
|
|
gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId;
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2019-05-19 19:10:06 +02:00
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-02-05 05:47:47 +01:00
|
|
|
ItemMenu_Cancel(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_Give(u8 taskId)
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2018-02-05 05:47:47 +01:00
|
|
|
if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId))
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2018-02-05 05:47:47 +01:00
|
|
|
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-04-29 13:36:26 +02:00
|
|
|
else if (!ItemId_GetImportance(gSpecialVar_ItemId))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if (CalculatePlayerPartyCount() == 0)
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintThereIsNoPokemon(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->exitCallback = CB2_ChooseMonToGiveItem;
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintItemCantBeHeld(taskId);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_PrintThereIsNoPokemon(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
DisplayItemMessage(taskId, 1, gText_NoPokemon, sub_81AD350);
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_PrintItemCantBeHeld(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld);
|
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD350);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AD350(u8 taskId)
|
|
|
|
{
|
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 (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_InitListsMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_CheckTag(u8 taskId)
|
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
gBagMenu->exitCallback = DoBerryTagScreen;
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_Cancel(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
|
|
|
BagMenu_PrintDescription(data[1]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemMenu_UseInBattle(u8 taskId)
|
|
|
|
{
|
|
|
|
if (ItemId_GetBattleFunc(gSpecialVar_ItemId))
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2018-02-05 05:47:47 +01:00
|
|
|
ItemId_GetBattleFunc(gSpecialVar_ItemId)(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
void CB2_ReturnToBagMenuPocket(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_LAST, POCKETS_COUNT, NULL);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_FieldGive(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId))
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2018-02-05 05:47:47 +01:00
|
|
|
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
else if (!sub_8122148(gSpecialVar_ItemId))
|
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeldHere);
|
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD350);
|
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
else if (gBagPositionStruct.pocket != KEYITEMS_POCKET && !ItemId_GetImportance(gSpecialVar_ItemId))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintItemCantBeHeld(taskId);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_ItemPC_2(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
if (ItemIsMail(gSpecialVar_ItemId) == TRUE)
|
|
|
|
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
|
2019-05-19 19:10:06 +02:00
|
|
|
else if (gBagPositionStruct.pocket != KEYITEMS_POCKET && !ItemId_GetImportance(gSpecialVar_ItemId))
|
2020-01-08 11:43:06 +01:00
|
|
|
gTasks[taskId].func = Task_FadeAndCloseBagMenu;
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintItemCantBeHeld(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
#define tUsingRegisteredKeyItem data[3]
|
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
bool8 UseRegisteredKeyItemOnField(void)
|
|
|
|
{
|
|
|
|
u8 taskId;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
if (InUnionRoom() == TRUE || InBattlePyramid() || InBattlePike() || InMultiPartnerRoom() == TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
return FALSE;
|
2018-02-09 03:00:28 +01:00
|
|
|
HideMapNamePopUpWindow();
|
|
|
|
ChangeBgY_ScreenOff(0, 0, 0);
|
|
|
|
if (gSaveBlock1Ptr->registeredItem != ITEM_NONE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2018-02-09 03:00:28 +01:00
|
|
|
if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2018-02-09 03:00:28 +01:00
|
|
|
ScriptContext2_Enable();
|
2019-11-21 04:55:44 +01:00
|
|
|
FreezeObjectEvents();
|
2018-02-09 03:00:28 +01:00
|
|
|
sub_808B864();
|
|
|
|
sub_808BCF4();
|
|
|
|
gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem;
|
|
|
|
taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8);
|
2020-01-08 11:43:06 +01:00
|
|
|
gTasks[taskId].tUsingRegisteredKeyItem = TRUE;
|
2018-02-09 03:00:28 +01:00
|
|
|
return TRUE;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2018-02-09 03:00:28 +01:00
|
|
|
else
|
2020-01-08 11:43:06 +01:00
|
|
|
{
|
2018-02-09 03:00:28 +01:00
|
|
|
gSaveBlock1Ptr->registeredItem = ITEM_NONE;
|
2020-01-08 11:43:06 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2019-03-22 03:10:56 +01:00
|
|
|
ScriptContext1_SetupScript(EventScript_SelectWithoutRegisteredItem);
|
2018-02-05 05:47:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-01-08 11:43:06 +01:00
|
|
|
#undef tUsingRegisteredKeyItem
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_Sell(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-04-29 13:36:26 +02:00
|
|
|
if (ItemId_GetPrice(gSpecialVar_ItemId) == 0)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar2);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CantBuyKeyItem);
|
2019-05-19 19:10:06 +02:00
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_InitListsMenu);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2018-02-14 01:12:17 +01:00
|
|
|
else
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-03-08 05:03:21 +01:00
|
|
|
tItemCount = 1;
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[2] == 1)
|
|
|
|
{
|
2020-03-08 05:03:21 +01:00
|
|
|
DisplayCurrentMoneyWindow();
|
|
|
|
DisplaySellItemPriceAndConfirm(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar2);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_HowManyToSell);
|
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD730);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void DisplaySellItemPriceAndConfirm(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount, STR_CONV_MODE_LEFT_ALIGN, 6);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ICanPayVar1);
|
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD6E4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AD6E4(u8 taskId)
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_YesNo(taskId, 6, &sYesNoSellItemFunctions);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_CancelSell(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
RemoveMoneyWindow();
|
|
|
|
BagMenu_RemoveBagItemMessageindow(4);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_81AD730(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u8 windowId = BagMenu_AddWindow(8);
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
PrintItemSoldAmount(windowId, 1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
|
|
|
|
DisplayCurrentMoneyWindow();
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = Task_SellHowManyDialogueHandleInput;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void Task_SellHowManyDialogueHandleInput(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2020-07-11 16:22:34 +02:00
|
|
|
PrintItemSoldAmount(gBagMenu->windowPointers[8], tItemCount, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
|
2018-02-09 03:00:28 +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
|
|
|
else if (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(8);
|
2020-03-08 05:03:21 +01:00
|
|
|
DisplaySellItemPriceAndConfirm(taskId);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
2020-08-28 19:31:58 +02:00
|
|
|
RemoveMoneyWindow();
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(8);
|
2020-08-28 19:31:58 +02:00
|
|
|
BagMenu_RemoveBagItemMessageindow(4);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_ConfirmSell(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar2);
|
2020-03-08 05:03:21 +01:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount, STR_CONV_MODE_LEFT_ALIGN, 6);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_TurnedOverVar1ForVar2);
|
2020-08-28 19:31:58 +02:00
|
|
|
DisplayItemMessage(taskId, 1, gStringVar4, BagMenu_Sell_UpdateItemListAndMoney);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_Sell_UpdateItemListAndMoney(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2019-05-19 19:10:06 +02:00
|
|
|
u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket];
|
|
|
|
u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket];
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_SHOP);
|
2020-03-08 05:03:21 +01:00
|
|
|
RemoveBagItem(gSpecialVar_ItemId, tItemCount);
|
|
|
|
AddMoney(&gSaveBlock1Ptr->money, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
2020-01-08 11:43:06 +01:00
|
|
|
UpdatePocketItemList(gBagPositionStruct.pocket);
|
2019-05-19 19:10:06 +02:00
|
|
|
SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket);
|
|
|
|
LoadBagItemListBuffers(gBagPositionStruct.pocket);
|
2018-02-05 05:47:47 +01:00
|
|
|
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 2);
|
2020-07-11 16:22:34 +02:00
|
|
|
PrintMoneyAmountInMoneyBox(gBagMenu->windowPointers[9], GetMoney(&gSaveBlock1Ptr->money), 0);
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = BagMenu_Sell_WaitForABPress;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_Sell_WaitForABPress(u8 taskId)
|
2018-02-05 05:47:47 +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
|
|
|
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
RemoveMoneyWindow();
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_InitListsMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void Task_ItemContext_Deposit(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
tItemCount = 1;
|
2018-02-05 05:47:47 +01:00
|
|
|
if (data[2] == 1)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
BagMenu_TryDepositItem(taskId);
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_DepositHowManyVar1);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
sub_81ABC3C(7);
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = Task_ChooseHowManyToDeposit;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void Task_ChooseHowManyToDeposit(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2020-07-11 16:22:34 +02:00
|
|
|
PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
|
2018-02-09 03:00:28 +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
|
|
|
else if (gMain.newKeys & A_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(7);
|
2020-08-28 19:31:58 +02:00
|
|
|
BagMenu_TryDepositItem(taskId);
|
2018-02-05 05:47:47 +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
|
|
|
else if (gMain.newKeys & B_BUTTON)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintDescription(data[1]);
|
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
|
|
|
BagMenu_RemoveWindow(7);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_TryDepositItem(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
2018-04-29 13:36:26 +02:00
|
|
|
if (ItemId_GetImportance(gSpecialVar_ItemId))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, 0);
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = BagMenu_Deposit_WaitForABPress;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2020-03-08 05:03:21 +01:00
|
|
|
else if (AddPCItem(gSpecialVar_ItemId, tItemCount) == TRUE)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
2020-09-25 17:18:52 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS);
|
2018-02-05 05:47:47 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_DepositedVar2Var1s);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
gTasks[taskId].func = Task_ActuallyToss;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(1, 1, gText_NoRoomForItems, 3, 1, 0, 0, 0, 0);
|
2020-08-28 19:31:58 +02:00
|
|
|
gTasks[taskId].func = BagMenu_Deposit_WaitForABPress;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void BagMenu_Deposit_WaitForABPress(u8 taskId)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +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
|
|
|
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintDescription(data[1]);
|
|
|
|
BagMenu_PrintCursor_(data[0], 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
set_callback3_to_bag(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 IsWallysBag(void)
|
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
if (gBagPositionStruct.location == 10)
|
2018-02-05 05:47:47 +01:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrepareBagForWallyTutorial(void)
|
|
|
|
{
|
|
|
|
u32 i;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-02-04 12:42:25 +01:00
|
|
|
sTempWallyBag = AllocZeroed(sizeof(struct TempWallyStruct));
|
|
|
|
memcpy(sTempWallyBag->bagPocket_Items, gSaveBlock1Ptr->bagPocket_Items, sizeof(gSaveBlock1Ptr->bagPocket_Items));
|
|
|
|
memcpy(sTempWallyBag->bagPocket_PokeBalls, gSaveBlock1Ptr->bagPocket_PokeBalls, sizeof(gSaveBlock1Ptr->bagPocket_PokeBalls));
|
|
|
|
sTempWallyBag->pocket = gBagPositionStruct.pocket;
|
2018-02-05 05:47:47 +01:00
|
|
|
for (i = 0; i <= 4; i++)
|
|
|
|
{
|
2020-02-04 12:42:25 +01:00
|
|
|
sTempWallyBag->cursorPosition[i] = gBagPositionStruct.cursorPosition[i];
|
|
|
|
sTempWallyBag->scrollPosition[i] = gBagPositionStruct.scrollPosition[i];
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2020-02-04 12:24:39 +01:00
|
|
|
ClearItemSlots(gSaveBlock1Ptr->bagPocket_Items, BAG_ITEMS_COUNT);
|
|
|
|
ClearItemSlots(gSaveBlock1Ptr->bagPocket_PokeBalls, BAG_POKEBALLS_COUNT);
|
2018-02-05 05:47:47 +01:00
|
|
|
ResetBagScrollPositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RestoreBagAfterWallyTutorial(void)
|
|
|
|
{
|
|
|
|
u32 i;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-02-04 12:42:25 +01:00
|
|
|
memcpy(gSaveBlock1Ptr->bagPocket_Items, sTempWallyBag->bagPocket_Items, sizeof(sTempWallyBag->bagPocket_Items));
|
|
|
|
memcpy(gSaveBlock1Ptr->bagPocket_PokeBalls, sTempWallyBag->bagPocket_PokeBalls, sizeof(sTempWallyBag->bagPocket_PokeBalls));
|
|
|
|
gBagPositionStruct.pocket = sTempWallyBag->pocket;
|
2018-02-05 05:47:47 +01:00
|
|
|
for (i = 0; i <= 4; i++)
|
|
|
|
{
|
2020-02-04 12:42:25 +01:00
|
|
|
gBagPositionStruct.cursorPosition[i] = sTempWallyBag->cursorPosition[i];
|
|
|
|
gBagPositionStruct.scrollPosition[i] = sTempWallyBag->scrollPosition[i];
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2020-02-04 12:42:25 +01:00
|
|
|
Free(sTempWallyBag);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DoWallyTutorialBagMenu(void)
|
|
|
|
{
|
|
|
|
PrepareBagForWallyTutorial();
|
|
|
|
AddBagItem(ITEM_POTION, 1);
|
|
|
|
AddBagItem(ITEM_POKE_BALL, 1);
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_WALLY, ITEMS_POCKET, CB2_SetUpReshowBattleScreenAfterMenu2);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Task_WallyTutorialBagMenu(u8 taskId)
|
|
|
|
{
|
|
|
|
s16* data = gTasks[taskId].data;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-03-09 02:11:19 +01:00
|
|
|
switch (data[8])
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
case 0x66:
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-28 19:31:58 +02:00
|
|
|
SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0);
|
2020-03-09 02:11:19 +01:00
|
|
|
data[8]++;
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
case 0xCC:
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_PrintCursor_(data[0], 2);
|
2018-02-05 05:47:47 +01:00
|
|
|
gSpecialVar_ItemId = ITEM_POKE_BALL;
|
2020-05-14 10:37:09 +02:00
|
|
|
OpenContextMenu(taskId);
|
2020-03-09 02:11:19 +01:00
|
|
|
data[8]++;
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
case 0x132:
|
|
|
|
PlaySE(SE_SELECT);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2018-03-02 16:34:31 +01:00
|
|
|
DestroyListMenuTask(data[0], 0, 0);
|
2018-02-05 05:47:47 +01:00
|
|
|
RestoreBagAfterWallyTutorial();
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
2020-03-09 02:11:19 +01:00
|
|
|
data[8]++;
|
2018-02-05 05:47:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
#undef tItemCount
|
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
void unknown_ItemMenu_Show(u8 taskId)
|
|
|
|
{
|
|
|
|
gSpecialVar_0x8005 = gSpecialVar_ItemId;
|
|
|
|
gSpecialVar_Result = 1;
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-11-19 17:36:38 +01:00
|
|
|
void CB2_ApprenticeExitBagMenu(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2018-10-14 17:00:41 +02:00
|
|
|
gFieldCallback = Apprentice_EnableBothScriptContexts;
|
2018-02-14 01:12:17 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void unknown_ItemMenu_Give2(u8 taskId)
|
|
|
|
{
|
|
|
|
RemoveBagItem(gSpecialVar_ItemId, 1);
|
|
|
|
gSpecialVar_Result = 1;
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:37:09 +02:00
|
|
|
void CB2_FavorLadyExitBagMenu(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-08-06 02:37:09 +02:00
|
|
|
gFieldCallback = FieldCallback_FavorLadyEnableScriptContexts;
|
2018-02-14 01:12:17 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void unknown_ItemMenu_Confirm2(u8 taskId)
|
|
|
|
{
|
|
|
|
gSpecialVar_Result = 1;
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveSomeWindow();
|
2020-01-08 11:43:06 +01:00
|
|
|
Task_FadeAndCloseBagMenu(taskId);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:37:09 +02:00
|
|
|
void CB2_QuizLadyExitBagMenu(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-08-06 02:37:09 +02:00
|
|
|
gFieldCallback = FieldCallback_QuizLadyEnableScriptContexts;
|
2018-02-14 01:12:17 +01:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_PrintPocketNames(const u8 *pocketName1, const u8 *pocketName2)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
struct WindowTemplate window = {0, 0, 0, 0, 0, 0, 0};
|
|
|
|
u16 windowId;
|
|
|
|
int offset;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2018-02-05 05:47:47 +01:00
|
|
|
window.width = 16;
|
|
|
|
window.height = 2;
|
|
|
|
windowId = AddWindow(&window);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
|
2018-02-05 05:47:47 +01:00
|
|
|
offset = GetStringCenterAlignXOffset(1, pocketName1, 0x40);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(windowId, 1, pocketName1, offset, 1, 0, 0, -1, 1);
|
2018-02-05 05:47:47 +01:00
|
|
|
if (pocketName2)
|
|
|
|
{
|
|
|
|
offset = GetStringCenterAlignXOffset(1, pocketName2, 0x40);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(windowId, 1, pocketName2, offset + 0x40, 1, 0, 0, -1, 1);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
CpuCopy32((u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA), gBagMenu->pocketNameBuffer, 0x400);
|
2018-02-05 05:47:47 +01:00
|
|
|
RemoveWindow(windowId);
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_CopyPocketNameToWindow(u32 a)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
u8 (* r4)[32][32];
|
|
|
|
u8* windowAttribute;
|
|
|
|
int b;
|
|
|
|
if (a > 8)
|
|
|
|
a = 8;
|
2019-05-19 19:10:06 +02:00
|
|
|
r4 = &gBagMenu->pocketNameBuffer;
|
2018-07-15 13:23:38 +02:00
|
|
|
windowAttribute = (u8*)GetWindowAttribute(2, WINDOW_TILE_DATA);
|
2018-02-05 05:47:47 +01:00
|
|
|
CpuCopy32(r4[0][a], windowAttribute, 0x100);
|
|
|
|
b = a + 16;
|
|
|
|
CpuCopy32(r4[0][b], windowAttribute + 0x100, 0x100);
|
|
|
|
CopyWindowToVram(2, 2);
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void SetupBagMenu_Textboxes(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
InitWindows(sDefaultBagWindows);
|
2018-02-05 05:47:47 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2018-09-02 00:28:03 +02:00
|
|
|
LoadUserWindowBorderGfx(0, 1, 0xE0);
|
|
|
|
LoadMessageBoxGfx(0, 10, 0xD0);
|
2020-05-30 10:09:21 +02:00
|
|
|
ListMenuLoadStdPalAt(0xC0, 1);
|
2018-02-05 05:47:47 +01:00
|
|
|
LoadPalette(&gUnknown_0860F074, 0xF0, 0x20);
|
2018-02-12 19:59:42 +01:00
|
|
|
for (i = 0; i < 3; i++)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2018-02-05 05:47:47 +01:00
|
|
|
PutWindowTilemap(i);
|
|
|
|
}
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_Print(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIndex)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
AddTextPrinterParameterized4(windowId, fontId, left, top, letterSpacing, lineSpacing, sFontColorTable[colorIndex], speed, str);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-03-08 05:03:21 +01:00
|
|
|
//Unused
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 sub_81AE124(u8 which)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
return gBagMenu->windowPointers[which];
|
2018-02-14 01:12:17 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 BagMenu_AddWindow(u8 which)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 *ptr = &gBagMenu->windowPointers[which];
|
2018-12-05 15:31:01 +01:00
|
|
|
if (*ptr == 0xFF)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
*ptr = AddWindow(&sContextMenuWindowTemplates[which]);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdFrameWithCustomTileAndPalette(*ptr, 0, 1, 14);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void BagMenu_RemoveWindow(u8 which)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 *ptr = &gBagMenu->windowPointers[which];
|
2018-12-05 15:31:01 +01:00
|
|
|
if (*ptr != 0xFF)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(*ptr, FALSE);
|
2018-02-05 05:47:47 +01:00
|
|
|
ClearWindowTilemap(*ptr);
|
|
|
|
RemoveWindow(*ptr);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-05 15:31:01 +01:00
|
|
|
*ptr = 0xFF;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 AddItemMessageWindow(u8 which)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 *ptr = &gBagMenu->windowPointers[which];
|
2018-12-05 15:31:01 +01:00
|
|
|
if (*ptr == 0xFF)
|
2020-05-14 10:37:09 +02:00
|
|
|
*ptr = AddWindow(&sContextMenuWindowTemplates[which]);
|
2018-02-05 05:47:47 +01:00
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
void BagMenu_RemoveBagItemMessageindow(u8 which)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
u8 *ptr = &gBagMenu->windowPointers[which];
|
2018-12-05 15:31:01 +01:00
|
|
|
if (*ptr != 0xFF)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearDialogWindowAndFrameToTransparent(*ptr, FALSE);
|
|
|
|
// This ClearWindowTilemap call is redundant, since ClearDialogWindowAndFrameToTransparent already calls it.
|
2018-02-05 05:47:47 +01:00
|
|
|
ClearWindowTilemap(*ptr);
|
|
|
|
RemoveWindow(*ptr);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-05 15:31:01 +01:00
|
|
|
*ptr = 0xFF;
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_YesNo(u8 a, u8 b, const struct YesNoFuncTable *funcTable)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
CreateYesNoMenuWithCallbacks(a, &sContextMenuWindowTemplates[b], 1, 0, 2, 1, 14, funcTable);
|
2018-02-05 05:47:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void DisplayCurrentMoneyWindow(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
u8 windowId = BagMenu_AddWindow(9);
|
2018-02-05 05:47:47 +01:00
|
|
|
PrintMoneyAmountInMoneyBoxWithBorder(windowId, 1, 14, GetMoney(&gSaveBlock1Ptr->money));
|
|
|
|
AddMoneyLabelObject(19, 11);
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
static void RemoveMoneyWindow(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_RemoveWindow(9);
|
2018-02-05 05:47:47 +01:00
|
|
|
RemoveMoneyLabelObject();
|
|
|
|
}
|
|
|
|
|
2019-05-19 19:10:06 +02:00
|
|
|
void BagMenu_PrepareTMHMMoveWindow(void)
|
2018-02-05 05:47:47 +01:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(3, PIXEL_FILL(0));
|
2018-02-05 05:47:47 +01:00
|
|
|
blit_move_info_icon(3, 19, 0, 0);
|
|
|
|
blit_move_info_icon(3, 20, 0, 12);
|
|
|
|
blit_move_info_icon(3, 21, 0, 24);
|
|
|
|
blit_move_info_icon(3, 22, 0, 36);
|
|
|
|
CopyWindowToVram(3, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintTMHMMoveData(u16 itemId)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u16 moveId;
|
2018-02-12 19:59:42 +01:00
|
|
|
const u8* text;
|
2018-02-14 01:12:17 +01:00
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(4, PIXEL_FILL(0));
|
2018-02-05 05:47:47 +01:00
|
|
|
if (itemId == ITEM_NONE)
|
|
|
|
{
|
2018-02-12 19:59:42 +01:00
|
|
|
for (i = 0; i < 4; i++)
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(4, 1, gText_ThreeDashes, 7, i * 12, 0, 0, -1, 4);
|
2018-02-05 05:47:47 +01:00
|
|
|
CopyWindowToVram(4, 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
moveId = ItemIdToBattleMoveId(itemId);
|
|
|
|
blit_move_info_icon(4, gBattleMoves[moveId].type + 1, 0, 0);
|
|
|
|
if (gBattleMoves[moveId].power <= 1)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2018-02-05 05:47:47 +01:00
|
|
|
text = gText_ThreeDashes;
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].power, STR_CONV_MODE_RIGHT_ALIGN, 3);
|
2018-02-05 05:47:47 +01:00
|
|
|
text = gStringVar1;
|
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(4, 1, text, 7, 12, 0, 0, -1, 4);
|
2018-02-05 05:47:47 +01:00
|
|
|
if (gBattleMoves[moveId].accuracy == 0)
|
2018-02-09 03:00:28 +01:00
|
|
|
{
|
2018-02-05 05:47:47 +01:00
|
|
|
text = gText_ThreeDashes;
|
2018-02-09 03:00:28 +01:00
|
|
|
}
|
2018-02-05 05:47:47 +01:00
|
|
|
else
|
|
|
|
{
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].accuracy, STR_CONV_MODE_RIGHT_ALIGN, 3);
|
2018-02-05 05:47:47 +01:00
|
|
|
text = gStringVar1;
|
|
|
|
}
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(4, 1, text, 7, 24, 0, 0, -1, 4);
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].pp, STR_CONV_MODE_RIGHT_ALIGN, 3);
|
2019-05-19 19:10:06 +02:00
|
|
|
BagMenu_Print(4, 1, gStringVar1, 7, 36, 0, 0, -1, 4);
|
2018-02-05 05:47:47 +01:00
|
|
|
CopyWindowToVram(4, 2);
|
|
|
|
}
|
|
|
|
}
|