From e0631fde0d5a272194cfb5ef9b90b97934f2ae52 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 7 Jun 2020 12:01:23 -0600 Subject: [PATCH 1/7] merge e814021ce05c1ccaa57c859a84f330e05f473157 --- include/item.h | 1 + include/item_menu.h | 5 +- src/item.c | 2 +- src/item_menu.c | 814 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 802 insertions(+), 20 deletions(-) diff --git a/include/item.h b/include/item.h index 87ff57bc79e8..6f114b93aa0e 100644 --- a/include/item.h +++ b/include/item.h @@ -31,6 +31,7 @@ struct BagPocket extern struct BagPocket gBagPockets[]; +u16 GetBagItemQuantity(u16 *quantity); void ApplyNewEncryptionKeyToBagItems(u32 newKey); void ApplyNewEncryptionKeyToBagItems_(u32 newKey); void SetBagItemsPointers(void); diff --git a/include/item_menu.h b/include/item_menu.h index a99272b0cafe..4b7ec96ed343 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -32,7 +32,10 @@ #define ITEMMENUACTION_SHOW 11 #define ITEMMENUACTION_GIVE_2 12 #define ITEMMENUACTION_CONFIRM_2 13 -#define ITEMMENUACTION_DUMMY 14 +#define ITEMMENUACTION_BY_NAME 14 +#define ITEMMENUACTION_BY_TYPE 15 +#define ITEMMENUACTION_BY_AMOUNT 16 +#define ITEMMENUACTION_DUMMY 17 // Exported type declarations struct BagStruct diff --git a/src/item.c b/src/item.c index 89209218497d..9bb335d6f288 100644 --- a/src/item.c +++ b/src/item.c @@ -30,7 +30,7 @@ EWRAM_DATA struct BagPocket gBagPockets[POCKETS_COUNT] = {0}; #include "data/items.h" // code -static u16 GetBagItemQuantity(u16 *quantity) +u16 GetBagItemQuantity(u16 *quantity) { return gSaveBlock2Ptr->encryptionKey ^ *quantity; } diff --git a/src/item_menu.c b/src/item_menu.c index 8836c0c63271..f904f0a82b6d 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -59,6 +59,7 @@ enum }; void GoToBagMenu(u8 bagMenuType, u8 pocketId, void (*postExitMenuMainCallback2)()); + void CB2_Bag(void); bool8 SetupBagMenu(void); void BagMenu_InitBGs(void); @@ -154,6 +155,19 @@ void BagMenu_ConfirmToss(u8 taskId); void BagMenu_CancelToss(u8 taskId); void BagMenu_ConfirmSell(u8 taskId); void BagMenu_CancelSell(u8 taskId); +//bag sort +static void Task_LoadBagSortOptions(u8 taskId); +static void ItemMenu_SortByName(u8 taskId); +static void ItemMenu_SortByType(u8 taskId); +static void ItemMenu_SortByAmount(u8 taskId); +static void SortBagItems(u8 taskId); +static void Task_SortFinish(u8 taskId); +static void SortItemsInBag(u8 pocket, u8 type); +static void MergeSort(struct ItemSlot* array, u32 low, u32 high, s8 (*comparator)(struct ItemSlot*, struct ItemSlot*)); +static void Merge(struct ItemSlot* array, u32 low, u32 mid, u32 high, s8 (*comparator)(struct ItemSlot*, struct ItemSlot*)); +static s8 CompareItemsAlphabetically(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); +static s8 CompareItemsByMost(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); +static s8 CompareItemsByType(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); // .rodata @@ -210,6 +224,9 @@ static const struct ListMenuTemplate sItemListMenu = .cursorKind = 0 }; +static const u8 sMenuText_ByName[] = _("Name"); +static const u8 sMenuText_ByType[] = _("Type"); +static const u8 sMenuText_ByAmount[] = _("Amount"); static const struct MenuAction sItemMenuActions[] = { [ITEMMENUACTION_USE] = {gMenuText_Use, ItemMenu_UseOutOfBattle}, [ITEMMENUACTION_TOSS] = {gMenuText_Toss, ItemMenu_Toss}, @@ -225,6 +242,9 @@ static const struct MenuAction sItemMenuActions[] = { [ITEMMENUACTION_SHOW] = {gMenuText_Show, unknown_ItemMenu_Show}, [ITEMMENUACTION_GIVE_2] = {gMenuText_Give2, unknown_ItemMenu_Give2}, [ITEMMENUACTION_CONFIRM_2] = {gMenuText_Confirm, unknown_ItemMenu_Confirm2}, + [ITEMMENUACTION_BY_NAME] = {sMenuText_ByName, ItemMenu_SortByName}, + [ITEMMENUACTION_BY_TYPE] = {sMenuText_ByType, ItemMenu_SortByType}, + [ITEMMENUACTION_BY_AMOUNT] = {sMenuText_ByAmount, ItemMenu_SortByAmount}, [ITEMMENUACTION_DUMMY] = {gText_EmptyString2, NULL} }; @@ -1158,27 +1178,36 @@ void Task_BagMenu_HandleInput(u8 taskId) { switch (GetSwitchBagPocketDirection()) { - case SWITCH_POCKET_LEFT: - SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 0); - return; - case SWITCH_POCKET_RIGHT: - SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0); - return; - default: - if (JOY_NEW(SELECT_BUTTON)) + case SWITCH_POCKET_LEFT: + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_LEFT, 0); + return; + case SWITCH_POCKET_RIGHT: + SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0); + return; + default: + if (JOY_NEW(SELECT_BUTTON)) + { + if (CanSwapItems() == TRUE) { - if (CanSwapItems() == TRUE) + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); + if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) { - ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); - if ((*scrollPos + *cursorPos) != gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) - { - PlaySE(SE_SELECT); - BagMenu_SwapItems(taskId); - } + PlaySE(SE_SELECT); + BagMenu_SwapItems(taskId); } - return; } - break; + return; + } + else if (JOY_NEW(START_BUTTON)) + { + PlaySE(SE_SELECT); + sub_81AB824(); + BagMenu_PrintCursor_(data[0], 2); + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); + gTasks[taskId].func = Task_LoadBagSortOptions; + return; + } + break; } listPosition = ListMenu_ProcessInput(data[0]); @@ -1694,7 +1723,7 @@ bool8 sub_81ACDFC(s8 a) return FALSE; if (a > gBagMenu->contextMenuNumItems) return FALSE; - if (gBagMenu->contextMenuItemsPtr[a] == 14) + if (gBagMenu->contextMenuItemsPtr[a] == ITEMMENUACTION_COUNT) return FALSE; return TRUE; } @@ -2504,3 +2533,752 @@ void PrintTMHMMoveData(u16 itemId) CopyWindowToVram(4, 2); } } + +// bag sorting +enum BagSortOptions +{ + SORT_ALPHABETICALLY, + SORT_BY_TYPE, + SORT_BY_AMOUNT, //greatest->least +}; +enum ItemSortType +{ + ITEM_TYPE_FIELD_USE, + ITEM_TYPE_HEALTH_RECOVERY, + ITEM_TYPE_STATUS_RECOVERY, + ITEM_TYPE_PP_RECOVERY, + ITEM_TYPE_STAT_BOOST_DRINK, + ITEM_TYPE_STAT_BOOST_WING, + ITEM_TYPE_EVOLUTION_STONE, + ITEM_TYPE_EVOLUTION_ITEM, + ITEM_TYPE_BATTLE_ITEM, + ITEM_TYPE_FLUTE, + ITEM_TYPE_STAT_BOOST_HELD_ITEM, + ITEM_TYPE_HELD_ITEM, + ITEM_TYPE_GEM, + ITEM_TYPE_PLATE, + ITEM_TYPE_MEMORY, + ITEM_TYPE_DRIVE, + ITEM_TYPE_INCENSE, + ITEM_TYPE_MEGA_STONE, + ITEM_TYPE_Z_CRYSTAL, + ITEM_TYPE_NECTAR, + ITEM_TYPE_SELLABLE, + ITEM_TYPE_RELIC, + ITEM_TYPE_SHARD, + ITEM_TYPE_FOSSIL, + ITEM_TYPE_MAIL, +}; +static const u8 sText_SortItemsHow[] = _("Sort items how?"); +static const u8 sText_Name[] = _("name"); +static const u8 sText_Type[] = _("type"); +static const u8 sText_Amount[] = _("amount"); +static const u8 sText_ItemsSorted[] = _("Items sorted by {STR_VAR_1}!"); +static const u8 *const sSortTypeStrings[] = +{ + [SORT_ALPHABETICALLY] = sText_Name, + [SORT_BY_TYPE] = sText_Type, + [SORT_BY_AMOUNT] = sText_Amount, +}; + +static const u8 sBagMenuSortItems[] = +{ + ITEMMENUACTION_BY_NAME, + ITEMMENUACTION_BY_TYPE, + ITEMMENUACTION_BY_AMOUNT, + ITEMMENUACTION_CANCEL, +}; + +static const u8 sBagMenuSortKeyItems[] = +{ + ITEMMENUACTION_BY_NAME, + ITEMMENUACTION_CANCEL, +}; + +static const u8 sBagMenuSortPokeBallsBerries[] = +{ + ITEMMENUACTION_BY_NAME, + ITEMMENUACTION_BY_AMOUNT, + ITEMMENUACTION_COUNT, + ITEMMENUACTION_CANCEL, +}; + +const u16 gItemsByType[ITEMS_COUNT] = +{ + [ITEM_REPEL] = ITEM_TYPE_FIELD_USE, + [ITEM_SUPER_REPEL] = ITEM_TYPE_FIELD_USE, + [ITEM_MAX_REPEL] = ITEM_TYPE_FIELD_USE, + [ITEM_ESCAPE_ROPE] = ITEM_TYPE_FIELD_USE, + [ITEM_HEART_SCALE] = ITEM_TYPE_FIELD_USE, + + [ITEM_POTION] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_FULL_RESTORE] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_MAX_POTION] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_HYPER_POTION] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_SUPER_POTION] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_REVIVE] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_MAX_REVIVE] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_FRESH_WATER] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_SODA_POP] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_LEMONADE] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_MOOMOO_MILK] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_ENERGY_POWDER] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_ENERGY_ROOT] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_REVIVAL_HERB] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_BERRY_JUICE] = ITEM_TYPE_HEALTH_RECOVERY, + [ITEM_SACRED_ASH] = ITEM_TYPE_HEALTH_RECOVERY, + + [ITEM_ANTIDOTE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_BURN_HEAL] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_ICE_HEAL] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_AWAKENING] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_PARALYZE_HEAL] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_FULL_HEAL] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_LAVA_COOKIE] = ITEM_TYPE_STATUS_RECOVERY, + /* + [ITEM_HONEY] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_BIG_MALASADA] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_CASTELIACONE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_LUMIOSE_GALETTE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_RAGE_CANDY_BAR] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_SHALOUR_SABLE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_OLD_GATEAU] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_HEAL_POWDER] = ITEM_TYPE_STATUS_RECOVERY, + */ + [ITEM_ETHER] = ITEM_TYPE_PP_RECOVERY, + [ITEM_MAX_ETHER] = ITEM_TYPE_PP_RECOVERY, + [ITEM_ELIXIR] = ITEM_TYPE_PP_RECOVERY, + [ITEM_MAX_ELIXIR] = ITEM_TYPE_PP_RECOVERY, + + [ITEM_HP_UP] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_PROTEIN] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_IRON] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_CARBOS] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_CALCIUM] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_RARE_CANDY] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_PP_UP] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_ZINC] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_PP_MAX] = ITEM_TYPE_STAT_BOOST_DRINK, + /* + [ITEM_ABILITY_CAPSULE] = ITEM_TYPE_STAT_BOOST_DRINK, + + [ITEM_HEALTH_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_MUSCLE_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_RESIST_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_GENIUS_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_CLEVER_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_SWIFT_WING] = ITEM_TYPE_STAT_BOOST_WING, + [ITEM_PRETTY_WING] = ITEM_TYPE_STAT_BOOST_WING, + */ + //[ITEM_POWER_BRACER] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + //[ITEM_POWER_BELT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + //[ITEM_POWER_LENS] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + //[ITEM_POWER_BAND] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + //[ITEM_POWER_ANKLET] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + //[ITEM_POWER_WEIGHT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_MACHO_BRACE] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + + [ITEM_SUN_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_MOON_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_FIRE_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_THUNDER_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_WATER_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_LEAF_STONE] = ITEM_TYPE_EVOLUTION_STONE, + //[ITEM_DAWN_STONE] = ITEM_TYPE_EVOLUTION_STONE, + //[ITEM_DUSK_STONE] = ITEM_TYPE_EVOLUTION_STONE, + //[ITEM_SHINY_STONE] = ITEM_TYPE_EVOLUTION_STONE, + //[ITEM_ICE_STONE] = ITEM_TYPE_EVOLUTION_STONE, + //[ITEM_OVAL_STONE] = ITEM_TYPE_EVOLUTION_STONE, + + [ITEM_KINGS_ROCK] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_DEEP_SEA_TOOTH] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_DEEP_SEA_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_EVERSTONE] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_METAL_COAT] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_DRAGON_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_UP_GRADE] = ITEM_TYPE_EVOLUTION_ITEM, + /* + [ITEM_PROTECTOR] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_MAGMARIZER] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_PRISM_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_SACHET] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_WHIPPED_DREAM] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_RAZOR_CLAW] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_RAZOR_FANG] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_REAPER_CLOTH] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_DUBIOUS_DISC] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_ELECTIRIZER] = ITEM_TYPE_EVOLUTION_ITEM, + */ + [ITEM_GUARD_SPEC] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_DIRE_HIT] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_X_ATTACK] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_X_DEFEND] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_X_SPEED] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_X_ACCURACY] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_X_SPECIAL] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_POKE_DOLL] = ITEM_TYPE_BATTLE_ITEM, + [ITEM_FLUFFY_TAIL] = ITEM_TYPE_BATTLE_ITEM, + + [ITEM_BRIGHT_POWDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_WHITE_HERB] = ITEM_TYPE_HELD_ITEM, + [ITEM_EXP_SHARE] = ITEM_TYPE_HELD_ITEM, + [ITEM_QUICK_CLAW] = ITEM_TYPE_HELD_ITEM, + [ITEM_SOOTHE_BELL] = ITEM_TYPE_HELD_ITEM, + [ITEM_MENTAL_HERB] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHOICE_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_SILVER_POWDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_AMULET_COIN] = ITEM_TYPE_HELD_ITEM, + [ITEM_CLEANSE_TAG] = ITEM_TYPE_HELD_ITEM, + [ITEM_SOUL_DEW] = ITEM_TYPE_HELD_ITEM, + [ITEM_SMOKE_BALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_FOCUS_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUCKY_EGG] = ITEM_TYPE_HELD_ITEM, + [ITEM_SCOPE_LENS] = ITEM_TYPE_HELD_ITEM, + [ITEM_LEFTOVERS] = ITEM_TYPE_HELD_ITEM, + [ITEM_LIGHT_BALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_SOFT_SAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_HARD_STONE] = ITEM_TYPE_HELD_ITEM, + [ITEM_MIRACLE_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLACK_GLASSES] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLACK_BELT] = ITEM_TYPE_HELD_ITEM, + [ITEM_MAGNET] = ITEM_TYPE_HELD_ITEM, + [ITEM_MYSTIC_WATER] = ITEM_TYPE_HELD_ITEM, + [ITEM_SHARP_BEAK] = ITEM_TYPE_HELD_ITEM, + [ITEM_POISON_BARB] = ITEM_TYPE_HELD_ITEM, + [ITEM_NEVER_MELT_ICE] = ITEM_TYPE_HELD_ITEM, + [ITEM_SPELL_TAG] = ITEM_TYPE_HELD_ITEM, + [ITEM_TWISTED_SPOON] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHARCOAL] = ITEM_TYPE_HELD_ITEM, + [ITEM_DRAGON_FANG] = ITEM_TYPE_HELD_ITEM, + [ITEM_SILK_SCARF] = ITEM_TYPE_HELD_ITEM, + [ITEM_SHELL_BELL] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUCKY_PUNCH] = ITEM_TYPE_HELD_ITEM, + [ITEM_METAL_POWDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_THICK_CLUB] = ITEM_TYPE_HELD_ITEM, + [ITEM_STICK] = ITEM_TYPE_HELD_ITEM, + /* + [ITEM_ADAMANT_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUSTROUS_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRISEOUS_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_EXPERT_BELT] = ITEM_TYPE_HELD_ITEM, + [ITEM_POWER_HERB] = ITEM_TYPE_HELD_ITEM, + [ITEM_WIDE_LENS] = ITEM_TYPE_HELD_ITEM, + [ITEM_ZOOM_LENS] = ITEM_TYPE_HELD_ITEM, + [ITEM_DESTINY_KNOT] = ITEM_TYPE_HELD_ITEM, + [ITEM_SMOOTH_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_DAMP_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_HEAT_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_ICY_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_BIG_ROOT] = ITEM_TYPE_HELD_ITEM, + [ITEM_LIGHT_CLAY] = ITEM_TYPE_HELD_ITEM, + [ITEM_SAFETY_GOGGLES] = ITEM_TYPE_HELD_ITEM, + [ITEM_ROCKY_HELMET] = ITEM_TYPE_HELD_ITEM, + [ITEM_WEAKNESS_POLICY] = ITEM_TYPE_HELD_ITEM, + [ITEM_ASSAULT_VEST] = ITEM_TYPE_HELD_ITEM, + [ITEM_EVIOLITE] = ITEM_TYPE_HELD_ITEM, + [ITEM_ABSORB_BULB] = ITEM_TYPE_HELD_ITEM, + [ITEM_AIR_BALLOON] = ITEM_TYPE_HELD_ITEM, + [ITEM_ADRENALINE_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_BINDING_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_CELL_BATTERY] = ITEM_TYPE_HELD_ITEM, + [ITEM_EJECT_BUTTON] = ITEM_TYPE_HELD_ITEM, + [ITEM_FLOAT_STONE] = ITEM_TYPE_HELD_ITEM, + [ITEM_FOCUS_SASH] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRIP_CLAW] = ITEM_TYPE_HELD_ITEM, + [ITEM_IRON_BALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_LAGGING_TAIL] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUMINOUS_MOSS] = ITEM_TYPE_HELD_ITEM, + [ITEM_QUICK_POWDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_METRONOME] = ITEM_TYPE_HELD_ITEM, + [ITEM_MUSCLE_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_PROTECTIVE_PADS] = ITEM_TYPE_HELD_ITEM, + [ITEM_RED_CARD] = ITEM_TYPE_HELD_ITEM, + [ITEM_RING_TARGET] = ITEM_TYPE_HELD_ITEM, + [ITEM_SHED_SHELL] = ITEM_TYPE_HELD_ITEM, + [ITEM_SNOWBALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_STICKY_BARB] = ITEM_TYPE_HELD_ITEM, + [ITEM_TERRAIN_EXTENDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_WISE_GLASSES] = ITEM_TYPE_HELD_ITEM, + [ITEM_ELECTRIC_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRASSY_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_MISTY_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_PSYCHIC_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_LIFE_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_TOXIC_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_FLAME_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLACK_SLUDGE] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHOICE_SPECS] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHOICE_SCARF] = ITEM_TYPE_HELD_ITEM, + [ITEM_EJECT_PACK] = ITEM_TYPE_HELD_ITEM, + [ITEM_ROOM_SERVICE] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLUNDER_POLICY] = ITEM_TYPE_HELD_ITEM, + [ITEM_HEAVY_DUTY_BOOTS] = ITEM_TYPE_HELD_ITEM, + [ITEM_UTILITY_UMBRELLA] = ITEM_TYPE_HELD_ITEM, + [ITEM_THROAT_SPRAY] = ITEM_TYPE_HELD_ITEM, + + [ITEM_FIST_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SKY_PLATE] = ITEM_TYPE_PLATE, + [ITEM_TOXIC_PLATE] = ITEM_TYPE_PLATE, + [ITEM_EARTH_PLATE] = ITEM_TYPE_PLATE, + [ITEM_STONE_PLATE] = ITEM_TYPE_PLATE, + [ITEM_INSECT_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SPOOKY_PLATE] = ITEM_TYPE_PLATE, + [ITEM_IRON_PLATE] = ITEM_TYPE_PLATE, + [ITEM_FLAME_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SPLASH_PLATE] = ITEM_TYPE_PLATE, + [ITEM_MEADOW_PLATE] = ITEM_TYPE_PLATE, + [ITEM_ZAP_PLATE] = ITEM_TYPE_PLATE, + [ITEM_MIND_PLATE] = ITEM_TYPE_PLATE, + [ITEM_ICICLE_PLATE] = ITEM_TYPE_PLATE, + [ITEM_DRACO_PLATE] = ITEM_TYPE_PLATE, + [ITEM_DREAD_PLATE] = ITEM_TYPE_PLATE, + [ITEM_PIXIE_PLATE] = ITEM_TYPE_PLATE, + + [ITEM_FIGHTING_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FLYING_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_POISON_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GROUND_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ROCK_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_BUG_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GHOST_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_STEEL_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FIRE_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_WATER_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GRASS_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ELECTRIC_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_PSYCHIC_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ICE_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_DRAGON_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_DARK_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FAIRY_MEMORY] = ITEM_TYPE_MEMORY, + + [ITEM_BURN_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_DOUSE_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_SHOCK_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_CHILL_DRIVE] = ITEM_TYPE_DRIVE, + + [ITEM_NORMAL_GEM] = ITEM_TYPE_GEM, + [ITEM_FIGHTING_GEM] = ITEM_TYPE_GEM, + [ITEM_FLYING_GEM] = ITEM_TYPE_GEM, + [ITEM_POISON_GEM] = ITEM_TYPE_GEM, + [ITEM_GROUND_GEM] = ITEM_TYPE_GEM, + [ITEM_ROCK_GEM] = ITEM_TYPE_GEM, + [ITEM_BUG_GEM] = ITEM_TYPE_GEM, + [ITEM_GHOST_GEM] = ITEM_TYPE_GEM, + [ITEM_STEEL_GEM] = ITEM_TYPE_GEM, + [ITEM_FIRE_GEM] = ITEM_TYPE_GEM, + [ITEM_WATER_GEM] = ITEM_TYPE_GEM, + [ITEM_GRASS_GEM] = ITEM_TYPE_GEM, + [ITEM_ELECTRIC_GEM] = ITEM_TYPE_GEM, + [ITEM_PSYCHIC_GEM] = ITEM_TYPE_GEM, + [ITEM_ICE_GEM] = ITEM_TYPE_GEM, + [ITEM_DRAGON_GEM] = ITEM_TYPE_GEM, + [ITEM_DARK_GEM] = ITEM_TYPE_GEM, + [ITEM_FAIRY_GEM] = ITEM_TYPE_GEM, + */ + [ITEM_SEA_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_LAX_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_LUCK_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_FULL_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_ODD_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_PURE_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_ROCK_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_ROSE_INCENSE] = ITEM_TYPE_INCENSE, + //[ITEM_WAVE_INCENSE] = ITEM_TYPE_INCENSE, + /* + [ITEM_VENUSAURITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_CHARIZARDITE_X] = ITEM_TYPE_MEGA_STONE, + [ITEM_CHARIZARDITE_Y] = ITEM_TYPE_MEGA_STONE, + [ITEM_BLASTOISINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BEEDRILLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_PIDGEOTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ALAKAZITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SLOWBRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GENGARITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_KANGASKHANITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_PINSIRITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GYARADOSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AERODACTYLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEWTWONITE_X] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEWTWONITE_Y] = ITEM_TYPE_MEGA_STONE, + [ITEM_AMPHAROSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_STEELIXITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SCIZORITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_HERACRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_HOUNDOOMINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_TYRANITARITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SCEPTILITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BLAZIKENITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SWAMPERTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GARDEVOIRITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SABLENITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MAWILITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AGGRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEDICHAMITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MANECTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SHARPEDONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_CAMERUPTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ALTARIANITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BANETTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ABSOLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GLALITITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SALAMENCITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_METAGROSSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LATIASITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LATIOSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LOPUNNITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GARCHOMPITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LUCARIONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ABOMASITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GALLADITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AUDINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_DIANCITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ULTRANECROZIUM_Z] = ITEM_TYPE_MEGA_STONE, + */ + [ITEM_RED_ORB] = ITEM_TYPE_MEGA_STONE, + [ITEM_BLUE_ORB] = ITEM_TYPE_MEGA_STONE, + /* + [ITEM_NORMALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FIGHTINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FLYINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_POISONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GROUNDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ROCKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_BUGINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GHOSTIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_STEELIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_WATERIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GRASSIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ELECTRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PSYCHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ICIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DRAGONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DARKINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FAIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ALORAICHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DECIDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_EEVIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_INCINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_KOMMONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_LUNALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_LYCANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MARSHADIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MEWNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MIMIKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PIKANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PIKASHUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PRIMARIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_SNORLIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_SOLGANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_TAPUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + */ + [ITEM_BLUE_FLUTE] = ITEM_TYPE_FLUTE, + [ITEM_YELLOW_FLUTE] = ITEM_TYPE_FLUTE, + [ITEM_RED_FLUTE] = ITEM_TYPE_FLUTE, + [ITEM_BLACK_FLUTE] = ITEM_TYPE_FLUTE, + [ITEM_WHITE_FLUTE] = ITEM_TYPE_FLUTE, + + //[ITEM_RED_NECTAR] = ITEM_TYPE_NECTAR, + //[ITEM_YELLOW_NECTAR] = ITEM_TYPE_NECTAR, + //[ITEM_PINK_NECTAR] = ITEM_TYPE_NECTAR, + //[ITEM_PURPLE_NECTAR] = ITEM_TYPE_NECTAR, + + [ITEM_SHOAL_SALT] = ITEM_TYPE_SELLABLE, + [ITEM_SHOAL_SHELL] = ITEM_TYPE_SELLABLE, + [ITEM_TINY_MUSHROOM] = ITEM_TYPE_SELLABLE, + [ITEM_BIG_MUSHROOM] = ITEM_TYPE_SELLABLE, + [ITEM_PEARL] = ITEM_TYPE_SELLABLE, + [ITEM_BIG_PEARL] = ITEM_TYPE_SELLABLE, + [ITEM_STARDUST] = ITEM_TYPE_SELLABLE, + [ITEM_STAR_PIECE] = ITEM_TYPE_SELLABLE, + [ITEM_NUGGET] = ITEM_TYPE_SELLABLE, + /* + [ITEM_RARE_BONE] = ITEM_TYPE_SELLABLE, + [ITEM_PEARL_STRING] = ITEM_TYPE_SELLABLE, + [ITEM_BIG_NUGGET] = ITEM_TYPE_SELLABLE, + [ITEM_COMET_SHARD] = ITEM_TYPE_SELLABLE, + [ITEM_BALM_MUSHROOM] = ITEM_TYPE_SELLABLE, + [ITEM_ODD_KEYSTONE] = ITEM_TYPE_SELLABLE, + [ITEM_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, + [ITEM_GOLD_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, + [ITEM_WISHING_PIECE] = ITEM_TYPE_SELLABLE, + + [ITEM_RELIC_COPPER] = ITEM_TYPE_RELIC, + [ITEM_RELIC_SILVER] = ITEM_TYPE_RELIC, + [ITEM_RELIC_GOLD] = ITEM_TYPE_RELIC, + [ITEM_RELIC_VASE] = ITEM_TYPE_RELIC, + [ITEM_RELIC_BAND] = ITEM_TYPE_RELIC, + [ITEM_RELIC_STATUE] = ITEM_TYPE_RELIC, + [ITEM_RELIC_CROWN] = ITEM_TYPE_RELIC, + */ + [ITEM_RED_SHARD] = ITEM_TYPE_SHARD, + [ITEM_BLUE_SHARD] = ITEM_TYPE_SHARD, + [ITEM_YELLOW_SHARD] = ITEM_TYPE_SHARD, + [ITEM_GREEN_SHARD] = ITEM_TYPE_SHARD, + + [ITEM_HELIX_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_DOME_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_OLD_AMBER] = ITEM_TYPE_FOSSIL, + //[ITEM_ROOT_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_CLAW_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_SKULL_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_ARMOR_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_COVER_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_PLUME_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_JAW_FOSSIL] = ITEM_TYPE_FOSSIL, + //[ITEM_SAIL_FOSSIL] = ITEM_TYPE_FOSSIL, + + [ITEM_ORANGE_MAIL] = ITEM_TYPE_MAIL, + [ITEM_HARBOR_MAIL] = ITEM_TYPE_MAIL, + [ITEM_GLITTER_MAIL] = ITEM_TYPE_MAIL, + [ITEM_MECH_MAIL] = ITEM_TYPE_MAIL, + [ITEM_WOOD_MAIL] = ITEM_TYPE_MAIL, + [ITEM_WAVE_MAIL] = ITEM_TYPE_MAIL, + [ITEM_BEAD_MAIL] = ITEM_TYPE_MAIL, + [ITEM_SHADOW_MAIL] = ITEM_TYPE_MAIL, + [ITEM_TROPIC_MAIL] = ITEM_TYPE_MAIL, + [ITEM_DREAM_MAIL] = ITEM_TYPE_MAIL, + [ITEM_FAB_MAIL] = ITEM_TYPE_MAIL, + [ITEM_RETRO_MAIL] = ITEM_TYPE_MAIL, +}; + +static void AddBagSortSubMenu(void) +{ + switch (gBagPositionStruct.pocket + 1) + { + case POCKET_KEY_ITEMS: + gBagMenu->unk820 = sBagMenuSortKeyItems; + memcpy(&gBagMenu->unk824, &sBagMenuSortKeyItems, NELEMS(sBagMenuSortKeyItems)); + gBagMenu->unk828 = NELEMS(sBagMenuSortKeyItems); + break; + case POCKET_POKE_BALLS: + case POCKET_BERRIES: + case POCKET_TM_HM: + gBagMenu->unk820 = sBagMenuSortPokeBallsBerries; + memcpy(&gBagMenu->unk824, &sBagMenuSortPokeBallsBerries, NELEMS(sBagMenuSortPokeBallsBerries)); + gBagMenu->unk828 = NELEMS(sBagMenuSortPokeBallsBerries); + break; + default: + gBagMenu->unk820 = sBagMenuSortItems; + memcpy(&gBagMenu->unk824, &sBagMenuSortItems, NELEMS(sBagMenuSortItems)); + gBagMenu->unk828 = NELEMS(sBagMenuSortItems); + break; + } + + StringExpandPlaceholders(gStringVar4, sText_SortItemsHow); + FillWindowPixelBuffer(1, PIXEL_FILL(0)); + BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + + if (gBagMenu->unk828 == 2) + sub_81ACAF8(BagMenu_AddWindow(1)); + else if (gBagMenu->unk828 == 4) + sub_81ACB54(BagMenu_AddWindow(2), 2, 2); + else + sub_81ACB54(BagMenu_AddWindow(3), 2, 3); +} + +static void Task_LoadBagSortOptions(u8 taskId) +{ + AddBagSortSubMenu(); + gTasks[taskId].func = Task_HandleOutOfBattleItemMenuInput; +} + +#define tSortType data[2] +static void ItemMenu_SortByName(u8 taskId) +{ + gTasks[taskId].tSortType = SORT_ALPHABETICALLY; + StringCopy(gStringVar1, sSortTypeStrings[SORT_ALPHABETICALLY]); + gTasks[taskId].func = SortBagItems; +} +static void ItemMenu_SortByType(u8 taskId) +{ + gTasks[taskId].tSortType = SORT_BY_TYPE; + StringCopy(gStringVar1, sSortTypeStrings[SORT_BY_TYPE]); + gTasks[taskId].func = SortBagItems; +} +static void ItemMenu_SortByAmount(u8 taskId) +{ + gTasks[taskId].tSortType = SORT_BY_AMOUNT; //greatest->least + StringCopy(gStringVar1, sSortTypeStrings[SORT_BY_AMOUNT]); + gTasks[taskId].func = SortBagItems; +} + +static void SortBagItems(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + BagMenu_RemoveSomeWindow(); + //sItemDescriptionPocket = 0; //Sorting Items + StringCopy(gStringVar1, sSortTypeStrings[tSortType]); + StringExpandPlaceholders(gStringVar4, sText_ItemsSorted); + DisplayItemMessage(taskId, 1, gStringVar4, Task_SortFinish); +} + +static void Task_SortFinish(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; + u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; + + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + //BagPrintTextOnWindow(ShowBagWindow(6, 3), 2, gStringVar4, 0, 2, 1, 0, 0, 1); + SortItemsInBag(gBagPositionStruct.pocket, tSortType); + bag_menu_RemoveBagItem_message_window(4); + DestroyListMenuTask(data[0], scrollPos, cursorPos); + SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); + LoadBagItemListBuffers(gBagPositionStruct.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + schedule_bg_copy_tilemap_to_vram(0); + set_callback3_to_bag(taskId); + } +} + +static void SortItemsInBag(u8 pocket, u8 type) +{ + struct ItemSlot* itemMem; + u16 itemAmount; + s8 (*func)(struct ItemSlot*, struct ItemSlot*); + + switch (pocket) + { + case ITEMS_POCKET: + itemMem = gSaveBlock1Ptr->bagPocket_Items; + itemAmount = BAG_ITEMS_COUNT; + break; + case KEYITEMS_POCKET: + itemMem = gSaveBlock1Ptr->bagPocket_KeyItems; + itemAmount = BAG_KEYITEMS_COUNT; + break; + case BALLS_POCKET: + itemMem = gSaveBlock1Ptr->bagPocket_PokeBalls; + itemAmount = BAG_POKEBALLS_COUNT; + break; + case BERRIES_POCKET: + itemMem = gSaveBlock1Ptr->bagPocket_Berries; + itemAmount = BAG_BERRIES_COUNT; + break; + case TMHM_POCKET: + itemMem = gSaveBlock1Ptr->bagPocket_TMHM; + itemAmount = BAG_TMHM_COUNT; + break; + default: + return; + } + + switch (type) + { + case SORT_ALPHABETICALLY: + MergeSort(itemMem, 0, itemAmount - 1, CompareItemsAlphabetically); + break; + case SORT_BY_AMOUNT: + MergeSort(itemMem, 0, itemAmount - 1, CompareItemsByMost); + break; + default: + MergeSort(itemMem, 0, itemAmount - 1, CompareItemsByType); + break; + } +} + +static void MergeSort(struct ItemSlot* array, u32 low, u32 high, s8 (*comparator)(struct ItemSlot*, struct ItemSlot*)) +{ + u32 mid; + + if (high <= low) + return; + + mid = low + (high - low) / 2; + MergeSort(array, low, mid, comparator); //Sort left half. + MergeSort(array, mid + 1, high, comparator); //Sort right half. + Merge(array, low, mid, high, comparator); //Merge results. +} + +static void Merge(struct ItemSlot* array, u32 low, u32 mid, u32 high, s8 (*comparator)(struct ItemSlot*, struct ItemSlot*)) +{ + u32 i = low; + u32 j = mid + 1; + u32 k; + struct ItemSlot aux[high + 1]; + + for (k = low; k <= high; ++k) + aux[k] = array[k]; + + for (k = low; k <= high; ++k) + { //Merge back to a[low..high] + if (i > mid) + array[k] = aux[j++]; + else if (j > high) + array[k] = aux[i++]; + else if (comparator(&aux[j], &aux[i]) < 0) + array[k] = aux[j++]; + else + array[k] = aux[i++]; + } +} + +static s8 CompareItemsAlphabetically(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2) +{ + u16 item1 = itemSlot1->itemId; + u16 item2 = itemSlot2->itemId; + int i; + const u8 *name1; + const u8 *name2; + + if (item1 == ITEM_NONE) + return 1; + else if (item2 == ITEM_NONE) + return -1; + + name1 = ItemId_GetName(item1); + name2 = ItemId_GetName(item2); + + for (i = 0; ; ++i) + { + if (name1[i] == EOS && name2[i] != EOS) + return -1; + else if (name1[i] != EOS && name2[i] == EOS) + return 1; + else if (name1[i] == EOS && name2[i] == EOS) + return 0; + + if (name1[i] < name2[i]) + return -1; + else if (name1[i] > name2[i]) + return 1; + } + + return 0; //Will never be reached +} + +static s8 CompareItemsByMost(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2) +{ + u16 quantity1 = GetBagItemQuantity(&itemSlot1->quantity); + u16 quantity2 = GetBagItemQuantity(&itemSlot2->quantity); + + if (itemSlot1->itemId == ITEM_NONE) + return 1; + else if (itemSlot2->itemId == ITEM_NONE) + return -1; + + if (quantity1 < quantity2) + return 1; + else if (quantity1 > quantity2) + return -1; + + return CompareItemsAlphabetically(itemSlot1, itemSlot2); //Items have same quantity so sort alphabetically +} + +static s8 CompareItemsByType(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2) +{ + //Null items go last + u8 type1 = (itemSlot1->itemId == ITEM_NONE) ? 0xFF : gItemsByType[itemSlot1->itemId]; + u8 type2 = (itemSlot2->itemId == ITEM_NONE) ? 0xFF : gItemsByType[itemSlot2->itemId]; + + if (type1 < type2) + return -1; + else if (type1 > type2) + return 1; + + return CompareItemsAlphabetically(itemSlot1, itemSlot2); //Items are of same type so sort alphabetically +} From e4a9ac3ad84af2dd7d44c3d09a98df2283060690 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 28 Jan 2021 09:20:39 -0700 Subject: [PATCH 2/7] merge 65d2c1141e876f1797a8ab77eec071c9903f9d13 --- src/item_menu.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index f904f0a82b6d..be24cdb97d53 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -227,6 +227,8 @@ static const struct ListMenuTemplate sItemListMenu = static const u8 sMenuText_ByName[] = _("Name"); static const u8 sMenuText_ByType[] = _("Type"); static const u8 sMenuText_ByAmount[] = _("Amount"); +static const u8 sMenuText_ByNumber[] = _("Number"); +static const u8 sText_NothingToSort[] = _("There's nothing to sort!"); static const struct MenuAction sItemMenuActions[] = { [ITEMMENUACTION_USE] = {gMenuText_Use, ItemMenu_UseOutOfBattle}, [ITEMMENUACTION_TOSS] = {gMenuText_Toss, ItemMenu_Toss}, @@ -1196,10 +1198,23 @@ void Task_BagMenu_HandleInput(u8 taskId) BagMenu_SwapItems(taskId); } } - return; } else if (JOY_NEW(START_BUTTON)) { + if ((gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) <= 1) //can't sort with 0 or 1 item in bag + { + PlaySE(SE_FAILURE); + DisplayItemMessage(taskId, 1, sText_NothingToSort, sub_81AD350); + break; + } + + data[1] = GetItemListPosition(gBagPositionStruct.pocket); + data[2] = BagGetQuantityByPocketPosition(gBagPositionStruct.pocket + 1, data[1]); + if (gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket] == gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) + break; + else + gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, data[1]); + PlaySE(SE_SELECT); sub_81AB824(); BagMenu_PrintCursor_(data[0], 2); @@ -3125,7 +3140,7 @@ static void Task_SortFinish(u8 taskId) { //BagPrintTextOnWindow(ShowBagWindow(6, 3), 2, gStringVar4, 0, 2, 1, 0, 0, 1); SortItemsInBag(gBagPositionStruct.pocket, tSortType); - bag_menu_RemoveBagItem_message_window(4); + BagMenu_RemoveBagItemMessageindow(4); DestroyListMenuTask(data[0], scrollPos, cursorPos); SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); LoadBagItemListBuffers(gBagPositionStruct.pocket); From 28d059b2367e2f87409444bb124b75d90e072375 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 2 Apr 2021 11:04:41 -0600 Subject: [PATCH 3/7] some fixes --- include/item_menu.h | 2 + src/item_menu.c | 97 ++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/include/item_menu.h b/include/item_menu.h index 4b7ec96ed343..4b5285a21f26 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -37,6 +37,8 @@ #define ITEMMENUACTION_BY_AMOUNT 16 #define ITEMMENUACTION_DUMMY 17 +#define ITEMMENUACTION_COUNT ITEMMENUACTION_DUMMY + // Exported type declarations struct BagStruct { diff --git a/src/item_menu.c b/src/item_menu.c index be24cdb97d53..22839d3fb912 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1203,6 +1203,7 @@ void Task_BagMenu_HandleInput(u8 taskId) { if ((gBagMenu->numItemStacks[gBagPositionStruct.pocket] - 1) <= 1) //can't sort with 0 or 1 item in bag { + static const u8 sText_NothingToSort[] = _("There's nothing to sort!"); PlaySE(SE_FAILURE); DisplayItemMessage(taskId, 1, sText_NothingToSort, sub_81AD350); break; @@ -1216,40 +1217,41 @@ void Task_BagMenu_HandleInput(u8 taskId) gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gBagPositionStruct.pocket + 1, data[1]); PlaySE(SE_SELECT); - sub_81AB824(); + BagDestroyPocketScrollArrowPair(); BagMenu_PrintCursor_(data[0], 2); ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); gTasks[taskId].func = Task_LoadBagSortOptions; - return; } - break; - } - - listPosition = ListMenu_ProcessInput(data[0]); - ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); - switch (listPosition) - { - case LIST_NOTHING_CHOSEN: - break; - case LIST_CANCEL: - if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH) + else + { + listPosition = ListMenu_ProcessInput(data[0]); + ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); + switch (listPosition) { - PlaySE(SE_FAILURE); - break; + case LIST_NOTHING_CHOSEN: + break; + case LIST_CANCEL: + if (gBagPositionStruct.location == ITEMMENULOCATION_BERRY_BLENDER_CRUSH) + { + PlaySE(SE_FAILURE); + break; + } + 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; } - 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; + } + break; } } } @@ -2618,7 +2620,7 @@ static const u8 sBagMenuSortPokeBallsBerries[] = ITEMMENUACTION_CANCEL, }; -const u16 gItemsByType[ITEMS_COUNT] = +static const u16 sItemsByType[ITEMS_COUNT] = { [ITEM_REPEL] = ITEM_TYPE_FIELD_USE, [ITEM_SUPER_REPEL] = ITEM_TYPE_FIELD_USE, @@ -2640,6 +2642,7 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_ENERGY_POWDER] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_ENERGY_ROOT] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_REVIVAL_HERB] = ITEM_TYPE_HEALTH_RECOVERY, + //[ITEM_SWEET_HEART] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_BERRY_JUICE] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_SACRED_ASH] = ITEM_TYPE_HEALTH_RECOVERY, @@ -2676,7 +2679,6 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_PP_MAX] = ITEM_TYPE_STAT_BOOST_DRINK, /* [ITEM_ABILITY_CAPSULE] = ITEM_TYPE_STAT_BOOST_DRINK, - [ITEM_HEALTH_WING] = ITEM_TYPE_STAT_BOOST_WING, [ITEM_MUSCLE_WING] = ITEM_TYPE_STAT_BOOST_WING, [ITEM_RESIST_WING] = ITEM_TYPE_STAT_BOOST_WING, @@ -2830,7 +2832,6 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_HEAVY_DUTY_BOOTS] = ITEM_TYPE_HELD_ITEM, [ITEM_UTILITY_UMBRELLA] = ITEM_TYPE_HELD_ITEM, [ITEM_THROAT_SPRAY] = ITEM_TYPE_HELD_ITEM, - [ITEM_FIST_PLATE] = ITEM_TYPE_PLATE, [ITEM_SKY_PLATE] = ITEM_TYPE_PLATE, [ITEM_TOXIC_PLATE] = ITEM_TYPE_PLATE, @@ -2848,7 +2849,6 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_DRACO_PLATE] = ITEM_TYPE_PLATE, [ITEM_DREAD_PLATE] = ITEM_TYPE_PLATE, [ITEM_PIXIE_PLATE] = ITEM_TYPE_PLATE, - [ITEM_FIGHTING_MEMORY] = ITEM_TYPE_MEMORY, [ITEM_FLYING_MEMORY] = ITEM_TYPE_MEMORY, [ITEM_POISON_MEMORY] = ITEM_TYPE_MEMORY, @@ -2866,12 +2866,10 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_DRAGON_MEMORY] = ITEM_TYPE_MEMORY, [ITEM_DARK_MEMORY] = ITEM_TYPE_MEMORY, [ITEM_FAIRY_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_BURN_DRIVE] = ITEM_TYPE_DRIVE, [ITEM_DOUSE_DRIVE] = ITEM_TYPE_DRIVE, [ITEM_SHOCK_DRIVE] = ITEM_TYPE_DRIVE, [ITEM_CHILL_DRIVE] = ITEM_TYPE_DRIVE, - [ITEM_NORMAL_GEM] = ITEM_TYPE_GEM, [ITEM_FIGHTING_GEM] = ITEM_TYPE_GEM, [ITEM_FLYING_GEM] = ITEM_TYPE_GEM, @@ -3018,7 +3016,6 @@ const u16 gItemsByType[ITEMS_COUNT] = [ITEM_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, [ITEM_GOLD_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, [ITEM_WISHING_PIECE] = ITEM_TYPE_SELLABLE, - [ITEM_RELIC_COPPER] = ITEM_TYPE_RELIC, [ITEM_RELIC_SILVER] = ITEM_TYPE_RELIC, [ITEM_RELIC_GOLD] = ITEM_TYPE_RELIC, @@ -3063,21 +3060,21 @@ static void AddBagSortSubMenu(void) switch (gBagPositionStruct.pocket + 1) { case POCKET_KEY_ITEMS: - gBagMenu->unk820 = sBagMenuSortKeyItems; - memcpy(&gBagMenu->unk824, &sBagMenuSortKeyItems, NELEMS(sBagMenuSortKeyItems)); - gBagMenu->unk828 = NELEMS(sBagMenuSortKeyItems); + gBagMenu->contextMenuItemsPtr = sBagMenuSortKeyItems; + memcpy(&gBagMenu->contextMenuItemsBuffer, &sBagMenuSortKeyItems, NELEMS(sBagMenuSortKeyItems)); + gBagMenu->contextMenuNumItems = NELEMS(sBagMenuSortKeyItems); break; case POCKET_POKE_BALLS: case POCKET_BERRIES: case POCKET_TM_HM: - gBagMenu->unk820 = sBagMenuSortPokeBallsBerries; - memcpy(&gBagMenu->unk824, &sBagMenuSortPokeBallsBerries, NELEMS(sBagMenuSortPokeBallsBerries)); - gBagMenu->unk828 = NELEMS(sBagMenuSortPokeBallsBerries); + gBagMenu->contextMenuItemsPtr = sBagMenuSortPokeBallsBerries; + memcpy(&gBagMenu->contextMenuItemsBuffer, &sBagMenuSortPokeBallsBerries, NELEMS(sBagMenuSortPokeBallsBerries)); + gBagMenu->contextMenuNumItems = NELEMS(sBagMenuSortPokeBallsBerries); break; default: - gBagMenu->unk820 = sBagMenuSortItems; - memcpy(&gBagMenu->unk824, &sBagMenuSortItems, NELEMS(sBagMenuSortItems)); - gBagMenu->unk828 = NELEMS(sBagMenuSortItems); + gBagMenu->contextMenuItemsPtr = sBagMenuSortItems; + memcpy(&gBagMenu->contextMenuItemsBuffer, &sBagMenuSortItems, NELEMS(sBagMenuSortItems)); + gBagMenu->contextMenuNumItems = NELEMS(sBagMenuSortItems); break; } @@ -3085,9 +3082,9 @@ static void AddBagSortSubMenu(void) FillWindowPixelBuffer(1, PIXEL_FILL(0)); BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); - if (gBagMenu->unk828 == 2) + if (gBagMenu->contextMenuNumItems == 2) sub_81ACAF8(BagMenu_AddWindow(1)); - else if (gBagMenu->unk828 == 4) + else if (gBagMenu->contextMenuNumItems == 4) sub_81ACB54(BagMenu_AddWindow(2), 2, 2); else sub_81ACB54(BagMenu_AddWindow(3), 2, 3); @@ -3140,12 +3137,12 @@ static void Task_SortFinish(u8 taskId) { //BagPrintTextOnWindow(ShowBagWindow(6, 3), 2, gStringVar4, 0, 2, 1, 0, 0, 1); SortItemsInBag(gBagPositionStruct.pocket, tSortType); - BagMenu_RemoveBagItemMessageindow(4); + BagMenu_RemoveBagItemMessageWindow(4); DestroyListMenuTask(data[0], scrollPos, cursorPos); SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); LoadBagItemListBuffers(gBagPositionStruct.pocket); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); - schedule_bg_copy_tilemap_to_vram(0); + ScheduleBgCopyTilemapToVram(0); set_callback3_to_bag(taskId); } } @@ -3287,8 +3284,8 @@ static s8 CompareItemsByMost(struct ItemSlot* itemSlot1, struct ItemSlot* itemSl static s8 CompareItemsByType(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2) { //Null items go last - u8 type1 = (itemSlot1->itemId == ITEM_NONE) ? 0xFF : gItemsByType[itemSlot1->itemId]; - u8 type2 = (itemSlot2->itemId == ITEM_NONE) ? 0xFF : gItemsByType[itemSlot2->itemId]; + u8 type1 = (itemSlot1->itemId == ITEM_NONE) ? 0xFF : sItemsByType[itemSlot1->itemId]; + u8 type2 = (itemSlot2->itemId == ITEM_NONE) ? 0xFF : sItemsByType[itemSlot2->itemId]; if (type1 < type2) return -1; From 08bfd7a2e453f513f277d0831a03d7148125e46e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 3 Jun 2021 11:32:48 -0400 Subject: [PATCH 4/7] items sorted before msg displays --- src/item_menu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index 0ff9256b82b1..b729284f1fc8 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -3117,10 +3117,19 @@ static void ItemMenu_SortByAmount(u8 taskId) static void SortBagItems(u8 taskId) { - s16* data = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; + u16 *scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; + u16 *cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; BagMenu_RemoveSomeWindow(); - //sItemDescriptionPocket = 0; //Sorting Items + + SortItemsInBag(gBagPositionStruct.pocket, tSortType); + DestroyListMenuTask(data[0], scrollPos, cursorPos); + SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); + LoadBagItemListBuffers(gBagPositionStruct.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + ScheduleBgCopyTilemapToVram(0); + StringCopy(gStringVar1, sSortTypeStrings[tSortType]); StringExpandPlaceholders(gStringVar4, sText_ItemsSorted); DisplayItemMessage(taskId, 1, gStringVar4, Task_SortFinish); @@ -3129,19 +3138,10 @@ static void SortBagItems(u8 taskId) static void Task_SortFinish(u8 taskId) { s16* data = gTasks[taskId].data; - u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; - u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - //BagPrintTextOnWindow(ShowBagWindow(6, 3), 2, gStringVar4, 0, 2, 1, 0, 0, 1); - SortItemsInBag(gBagPositionStruct.pocket, tSortType); BagMenu_RemoveBagItemMessageWindow(4); - DestroyListMenuTask(data[0], scrollPos, cursorPos); - SetInitialScrollAndCursorPositions(gBagPositionStruct.pocket); - LoadBagItemListBuffers(gBagPositionStruct.pocket); - data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); - ScheduleBgCopyTilemapToVram(0); set_callback3_to_bag(taskId); } } From 1a84aacb87053767167bfd1f672fd16cc5200cef Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 3 Jun 2021 11:36:52 -0400 Subject: [PATCH 5/7] add ITEM_EXPANSION ifdef, rename wings to feathers --- src/item_menu.c | 577 ++++++++++++++++++++++++------------------------ 1 file changed, 292 insertions(+), 285 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index b729284f1fc8..0d866d320925 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -2564,7 +2564,7 @@ enum ItemSortType ITEM_TYPE_STATUS_RECOVERY, ITEM_TYPE_PP_RECOVERY, ITEM_TYPE_STAT_BOOST_DRINK, - ITEM_TYPE_STAT_BOOST_WING, + ITEM_TYPE_STAT_BOOST_FEATHER, ITEM_TYPE_EVOLUTION_STONE, ITEM_TYPE_EVOLUTION_ITEM, ITEM_TYPE_BATTLE_ITEM, @@ -2641,7 +2641,6 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_ENERGY_POWDER] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_ENERGY_ROOT] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_REVIVAL_HERB] = ITEM_TYPE_HEALTH_RECOVERY, - //[ITEM_SWEET_HEART] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_BERRY_JUICE] = ITEM_TYPE_HEALTH_RECOVERY, [ITEM_SACRED_ASH] = ITEM_TYPE_HEALTH_RECOVERY, @@ -2652,16 +2651,7 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_PARALYZE_HEAL] = ITEM_TYPE_STATUS_RECOVERY, [ITEM_FULL_HEAL] = ITEM_TYPE_STATUS_RECOVERY, [ITEM_LAVA_COOKIE] = ITEM_TYPE_STATUS_RECOVERY, - /* - [ITEM_HONEY] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_BIG_MALASADA] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_CASTELIACONE] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_LUMIOSE_GALETTE] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_RAGE_CANDY_BAR] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_SHALOUR_SABLE] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_OLD_GATEAU] = ITEM_TYPE_STATUS_RECOVERY, - [ITEM_HEAL_POWDER] = ITEM_TYPE_STATUS_RECOVERY, - */ + [ITEM_ETHER] = ITEM_TYPE_PP_RECOVERY, [ITEM_MAX_ETHER] = ITEM_TYPE_PP_RECOVERY, [ITEM_ELIXIR] = ITEM_TYPE_PP_RECOVERY, @@ -2676,22 +2666,7 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_PP_UP] = ITEM_TYPE_STAT_BOOST_DRINK, [ITEM_ZINC] = ITEM_TYPE_STAT_BOOST_DRINK, [ITEM_PP_MAX] = ITEM_TYPE_STAT_BOOST_DRINK, - /* - [ITEM_ABILITY_CAPSULE] = ITEM_TYPE_STAT_BOOST_DRINK, - [ITEM_HEALTH_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_MUSCLE_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_RESIST_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_GENIUS_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_CLEVER_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_SWIFT_WING] = ITEM_TYPE_STAT_BOOST_WING, - [ITEM_PRETTY_WING] = ITEM_TYPE_STAT_BOOST_WING, - */ - //[ITEM_POWER_BRACER] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, - //[ITEM_POWER_BELT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, - //[ITEM_POWER_LENS] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, - //[ITEM_POWER_BAND] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, - //[ITEM_POWER_ANKLET] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, - //[ITEM_POWER_WEIGHT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_MACHO_BRACE] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, [ITEM_SUN_STONE] = ITEM_TYPE_EVOLUTION_STONE, @@ -2700,11 +2675,6 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_THUNDER_STONE] = ITEM_TYPE_EVOLUTION_STONE, [ITEM_WATER_STONE] = ITEM_TYPE_EVOLUTION_STONE, [ITEM_LEAF_STONE] = ITEM_TYPE_EVOLUTION_STONE, - //[ITEM_DAWN_STONE] = ITEM_TYPE_EVOLUTION_STONE, - //[ITEM_DUSK_STONE] = ITEM_TYPE_EVOLUTION_STONE, - //[ITEM_SHINY_STONE] = ITEM_TYPE_EVOLUTION_STONE, - //[ITEM_ICE_STONE] = ITEM_TYPE_EVOLUTION_STONE, - //[ITEM_OVAL_STONE] = ITEM_TYPE_EVOLUTION_STONE, [ITEM_KINGS_ROCK] = ITEM_TYPE_EVOLUTION_ITEM, [ITEM_DEEP_SEA_TOOTH] = ITEM_TYPE_EVOLUTION_ITEM, @@ -2713,18 +2683,7 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_METAL_COAT] = ITEM_TYPE_EVOLUTION_ITEM, [ITEM_DRAGON_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, [ITEM_UP_GRADE] = ITEM_TYPE_EVOLUTION_ITEM, - /* - [ITEM_PROTECTOR] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_MAGMARIZER] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_PRISM_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_SACHET] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_WHIPPED_DREAM] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_RAZOR_CLAW] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_RAZOR_FANG] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_REAPER_CLOTH] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_DUBIOUS_DISC] = ITEM_TYPE_EVOLUTION_ITEM, - [ITEM_ELECTIRIZER] = ITEM_TYPE_EVOLUTION_ITEM, - */ + [ITEM_GUARD_SPEC] = ITEM_TYPE_BATTLE_ITEM, [ITEM_DIRE_HIT] = ITEM_TYPE_BATTLE_ITEM, [ITEM_X_ATTACK] = ITEM_TYPE_BATTLE_ITEM, @@ -2772,229 +2731,18 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_METAL_POWDER] = ITEM_TYPE_HELD_ITEM, [ITEM_THICK_CLUB] = ITEM_TYPE_HELD_ITEM, [ITEM_STICK] = ITEM_TYPE_HELD_ITEM, - /* - [ITEM_ADAMANT_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_LUSTROUS_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_GRISEOUS_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_EXPERT_BELT] = ITEM_TYPE_HELD_ITEM, - [ITEM_POWER_HERB] = ITEM_TYPE_HELD_ITEM, - [ITEM_WIDE_LENS] = ITEM_TYPE_HELD_ITEM, - [ITEM_ZOOM_LENS] = ITEM_TYPE_HELD_ITEM, - [ITEM_DESTINY_KNOT] = ITEM_TYPE_HELD_ITEM, - [ITEM_SMOOTH_ROCK] = ITEM_TYPE_HELD_ITEM, - [ITEM_DAMP_ROCK] = ITEM_TYPE_HELD_ITEM, - [ITEM_HEAT_ROCK] = ITEM_TYPE_HELD_ITEM, - [ITEM_ICY_ROCK] = ITEM_TYPE_HELD_ITEM, - [ITEM_BIG_ROOT] = ITEM_TYPE_HELD_ITEM, - [ITEM_LIGHT_CLAY] = ITEM_TYPE_HELD_ITEM, - [ITEM_SAFETY_GOGGLES] = ITEM_TYPE_HELD_ITEM, - [ITEM_ROCKY_HELMET] = ITEM_TYPE_HELD_ITEM, - [ITEM_WEAKNESS_POLICY] = ITEM_TYPE_HELD_ITEM, - [ITEM_ASSAULT_VEST] = ITEM_TYPE_HELD_ITEM, - [ITEM_EVIOLITE] = ITEM_TYPE_HELD_ITEM, - [ITEM_ABSORB_BULB] = ITEM_TYPE_HELD_ITEM, - [ITEM_AIR_BALLOON] = ITEM_TYPE_HELD_ITEM, - [ITEM_ADRENALINE_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_BINDING_BAND] = ITEM_TYPE_HELD_ITEM, - [ITEM_CELL_BATTERY] = ITEM_TYPE_HELD_ITEM, - [ITEM_EJECT_BUTTON] = ITEM_TYPE_HELD_ITEM, - [ITEM_FLOAT_STONE] = ITEM_TYPE_HELD_ITEM, - [ITEM_FOCUS_SASH] = ITEM_TYPE_HELD_ITEM, - [ITEM_GRIP_CLAW] = ITEM_TYPE_HELD_ITEM, - [ITEM_IRON_BALL] = ITEM_TYPE_HELD_ITEM, - [ITEM_LAGGING_TAIL] = ITEM_TYPE_HELD_ITEM, - [ITEM_LUMINOUS_MOSS] = ITEM_TYPE_HELD_ITEM, - [ITEM_QUICK_POWDER] = ITEM_TYPE_HELD_ITEM, - [ITEM_METRONOME] = ITEM_TYPE_HELD_ITEM, - [ITEM_MUSCLE_BAND] = ITEM_TYPE_HELD_ITEM, - [ITEM_PROTECTIVE_PADS] = ITEM_TYPE_HELD_ITEM, - [ITEM_RED_CARD] = ITEM_TYPE_HELD_ITEM, - [ITEM_RING_TARGET] = ITEM_TYPE_HELD_ITEM, - [ITEM_SHED_SHELL] = ITEM_TYPE_HELD_ITEM, - [ITEM_SNOWBALL] = ITEM_TYPE_HELD_ITEM, - [ITEM_STICKY_BARB] = ITEM_TYPE_HELD_ITEM, - [ITEM_TERRAIN_EXTENDER] = ITEM_TYPE_HELD_ITEM, - [ITEM_WISE_GLASSES] = ITEM_TYPE_HELD_ITEM, - [ITEM_ELECTRIC_SEED] = ITEM_TYPE_HELD_ITEM, - [ITEM_GRASSY_SEED] = ITEM_TYPE_HELD_ITEM, - [ITEM_MISTY_SEED] = ITEM_TYPE_HELD_ITEM, - [ITEM_PSYCHIC_SEED] = ITEM_TYPE_HELD_ITEM, - [ITEM_LIFE_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_TOXIC_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_FLAME_ORB] = ITEM_TYPE_HELD_ITEM, - [ITEM_BLACK_SLUDGE] = ITEM_TYPE_HELD_ITEM, - [ITEM_CHOICE_SPECS] = ITEM_TYPE_HELD_ITEM, - [ITEM_CHOICE_SCARF] = ITEM_TYPE_HELD_ITEM, - [ITEM_EJECT_PACK] = ITEM_TYPE_HELD_ITEM, - [ITEM_ROOM_SERVICE] = ITEM_TYPE_HELD_ITEM, - [ITEM_BLUNDER_POLICY] = ITEM_TYPE_HELD_ITEM, - [ITEM_HEAVY_DUTY_BOOTS] = ITEM_TYPE_HELD_ITEM, - [ITEM_UTILITY_UMBRELLA] = ITEM_TYPE_HELD_ITEM, - [ITEM_THROAT_SPRAY] = ITEM_TYPE_HELD_ITEM, - [ITEM_FIST_PLATE] = ITEM_TYPE_PLATE, - [ITEM_SKY_PLATE] = ITEM_TYPE_PLATE, - [ITEM_TOXIC_PLATE] = ITEM_TYPE_PLATE, - [ITEM_EARTH_PLATE] = ITEM_TYPE_PLATE, - [ITEM_STONE_PLATE] = ITEM_TYPE_PLATE, - [ITEM_INSECT_PLATE] = ITEM_TYPE_PLATE, - [ITEM_SPOOKY_PLATE] = ITEM_TYPE_PLATE, - [ITEM_IRON_PLATE] = ITEM_TYPE_PLATE, - [ITEM_FLAME_PLATE] = ITEM_TYPE_PLATE, - [ITEM_SPLASH_PLATE] = ITEM_TYPE_PLATE, - [ITEM_MEADOW_PLATE] = ITEM_TYPE_PLATE, - [ITEM_ZAP_PLATE] = ITEM_TYPE_PLATE, - [ITEM_MIND_PLATE] = ITEM_TYPE_PLATE, - [ITEM_ICICLE_PLATE] = ITEM_TYPE_PLATE, - [ITEM_DRACO_PLATE] = ITEM_TYPE_PLATE, - [ITEM_DREAD_PLATE] = ITEM_TYPE_PLATE, - [ITEM_PIXIE_PLATE] = ITEM_TYPE_PLATE, - [ITEM_FIGHTING_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_FLYING_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_POISON_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_GROUND_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_ROCK_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_BUG_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_GHOST_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_STEEL_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_FIRE_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_WATER_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_GRASS_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_ELECTRIC_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_PSYCHIC_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_ICE_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_DRAGON_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_DARK_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_FAIRY_MEMORY] = ITEM_TYPE_MEMORY, - [ITEM_BURN_DRIVE] = ITEM_TYPE_DRIVE, - [ITEM_DOUSE_DRIVE] = ITEM_TYPE_DRIVE, - [ITEM_SHOCK_DRIVE] = ITEM_TYPE_DRIVE, - [ITEM_CHILL_DRIVE] = ITEM_TYPE_DRIVE, - [ITEM_NORMAL_GEM] = ITEM_TYPE_GEM, - [ITEM_FIGHTING_GEM] = ITEM_TYPE_GEM, - [ITEM_FLYING_GEM] = ITEM_TYPE_GEM, - [ITEM_POISON_GEM] = ITEM_TYPE_GEM, - [ITEM_GROUND_GEM] = ITEM_TYPE_GEM, - [ITEM_ROCK_GEM] = ITEM_TYPE_GEM, - [ITEM_BUG_GEM] = ITEM_TYPE_GEM, - [ITEM_GHOST_GEM] = ITEM_TYPE_GEM, - [ITEM_STEEL_GEM] = ITEM_TYPE_GEM, - [ITEM_FIRE_GEM] = ITEM_TYPE_GEM, - [ITEM_WATER_GEM] = ITEM_TYPE_GEM, - [ITEM_GRASS_GEM] = ITEM_TYPE_GEM, - [ITEM_ELECTRIC_GEM] = ITEM_TYPE_GEM, - [ITEM_PSYCHIC_GEM] = ITEM_TYPE_GEM, - [ITEM_ICE_GEM] = ITEM_TYPE_GEM, - [ITEM_DRAGON_GEM] = ITEM_TYPE_GEM, - [ITEM_DARK_GEM] = ITEM_TYPE_GEM, - [ITEM_FAIRY_GEM] = ITEM_TYPE_GEM, - */ + [ITEM_SEA_INCENSE] = ITEM_TYPE_INCENSE, [ITEM_LAX_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_LUCK_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_FULL_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_ODD_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_PURE_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_ROCK_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_ROSE_INCENSE] = ITEM_TYPE_INCENSE, - //[ITEM_WAVE_INCENSE] = ITEM_TYPE_INCENSE, - /* - [ITEM_VENUSAURITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_CHARIZARDITE_X] = ITEM_TYPE_MEGA_STONE, - [ITEM_CHARIZARDITE_Y] = ITEM_TYPE_MEGA_STONE, - [ITEM_BLASTOISINITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_BEEDRILLITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_PIDGEOTITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_ALAKAZITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SLOWBRONITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GENGARITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_KANGASKHANITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_PINSIRITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GYARADOSITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_AERODACTYLITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_MEWTWONITE_X] = ITEM_TYPE_MEGA_STONE, - [ITEM_MEWTWONITE_Y] = ITEM_TYPE_MEGA_STONE, - [ITEM_AMPHAROSITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_STEELIXITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SCIZORITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_HERACRONITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_HOUNDOOMINITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_TYRANITARITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SCEPTILITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_BLAZIKENITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SWAMPERTITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GARDEVOIRITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SABLENITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_MAWILITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_AGGRONITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_MEDICHAMITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_MANECTITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SHARPEDONITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_CAMERUPTITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_ALTARIANITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_BANETTITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_ABSOLITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GLALITITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_SALAMENCITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_METAGROSSITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_LATIASITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_LATIOSITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_LOPUNNITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GARCHOMPITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_LUCARIONITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_ABOMASITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_GALLADITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_AUDINITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_DIANCITE] = ITEM_TYPE_MEGA_STONE, - [ITEM_ULTRANECROZIUM_Z] = ITEM_TYPE_MEGA_STONE, - */ + [ITEM_RED_ORB] = ITEM_TYPE_MEGA_STONE, [ITEM_BLUE_ORB] = ITEM_TYPE_MEGA_STONE, - /* - [ITEM_NORMALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_FIGHTINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_FLYINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_POISONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_GROUNDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_ROCKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_BUGINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_GHOSTIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_STEELIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_FIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_WATERIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_GRASSIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_ELECTRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_PSYCHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_ICIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_DRAGONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_DARKINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_FAIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_ALORAICHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_DECIDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_EEVIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_INCINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_KOMMONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_LUNALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_LYCANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_MARSHADIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_MEWNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_MIMIKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_PIKANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_PIKASHUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_PRIMARIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_SNORLIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_SOLGANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - [ITEM_TAPUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, - */ + [ITEM_BLUE_FLUTE] = ITEM_TYPE_FLUTE, [ITEM_YELLOW_FLUTE] = ITEM_TYPE_FLUTE, [ITEM_RED_FLUTE] = ITEM_TYPE_FLUTE, [ITEM_BLACK_FLUTE] = ITEM_TYPE_FLUTE, [ITEM_WHITE_FLUTE] = ITEM_TYPE_FLUTE, - - //[ITEM_RED_NECTAR] = ITEM_TYPE_NECTAR, - //[ITEM_YELLOW_NECTAR] = ITEM_TYPE_NECTAR, - //[ITEM_PINK_NECTAR] = ITEM_TYPE_NECTAR, - //[ITEM_PURPLE_NECTAR] = ITEM_TYPE_NECTAR, [ITEM_SHOAL_SALT] = ITEM_TYPE_SELLABLE, [ITEM_SHOAL_SHELL] = ITEM_TYPE_SELLABLE, @@ -3005,24 +2753,7 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_STARDUST] = ITEM_TYPE_SELLABLE, [ITEM_STAR_PIECE] = ITEM_TYPE_SELLABLE, [ITEM_NUGGET] = ITEM_TYPE_SELLABLE, - /* - [ITEM_RARE_BONE] = ITEM_TYPE_SELLABLE, - [ITEM_PEARL_STRING] = ITEM_TYPE_SELLABLE, - [ITEM_BIG_NUGGET] = ITEM_TYPE_SELLABLE, - [ITEM_COMET_SHARD] = ITEM_TYPE_SELLABLE, - [ITEM_BALM_MUSHROOM] = ITEM_TYPE_SELLABLE, - [ITEM_ODD_KEYSTONE] = ITEM_TYPE_SELLABLE, - [ITEM_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, - [ITEM_GOLD_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, - [ITEM_WISHING_PIECE] = ITEM_TYPE_SELLABLE, - [ITEM_RELIC_COPPER] = ITEM_TYPE_RELIC, - [ITEM_RELIC_SILVER] = ITEM_TYPE_RELIC, - [ITEM_RELIC_GOLD] = ITEM_TYPE_RELIC, - [ITEM_RELIC_VASE] = ITEM_TYPE_RELIC, - [ITEM_RELIC_BAND] = ITEM_TYPE_RELIC, - [ITEM_RELIC_STATUE] = ITEM_TYPE_RELIC, - [ITEM_RELIC_CROWN] = ITEM_TYPE_RELIC, - */ + [ITEM_RED_SHARD] = ITEM_TYPE_SHARD, [ITEM_BLUE_SHARD] = ITEM_TYPE_SHARD, [ITEM_YELLOW_SHARD] = ITEM_TYPE_SHARD, @@ -3031,14 +2762,6 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_HELIX_FOSSIL] = ITEM_TYPE_FOSSIL, [ITEM_DOME_FOSSIL] = ITEM_TYPE_FOSSIL, [ITEM_OLD_AMBER] = ITEM_TYPE_FOSSIL, - //[ITEM_ROOT_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_CLAW_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_SKULL_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_ARMOR_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_COVER_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_PLUME_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_JAW_FOSSIL] = ITEM_TYPE_FOSSIL, - //[ITEM_SAIL_FOSSIL] = ITEM_TYPE_FOSSIL, [ITEM_ORANGE_MAIL] = ITEM_TYPE_MAIL, [ITEM_HARBOR_MAIL] = ITEM_TYPE_MAIL, @@ -3052,6 +2775,290 @@ static const u16 sItemsByType[ITEMS_COUNT] = [ITEM_DREAM_MAIL] = ITEM_TYPE_MAIL, [ITEM_FAB_MAIL] = ITEM_TYPE_MAIL, [ITEM_RETRO_MAIL] = ITEM_TYPE_MAIL, + + #ifdef ITEM_EXPANSION + [ITEM_HONEY] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_BIG_MALASADA] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_CASTELIACONE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_LUMIOSE_GALETTE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_RAGE_CANDY_BAR] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_SHALOUR_SABLE] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_OLD_GATEAU] = ITEM_TYPE_STATUS_RECOVERY, + [ITEM_HEAL_POWDER] = ITEM_TYPE_STATUS_RECOVERY, + + [ITEM_SWEET_HEART] = ITEM_TYPE_HEALTH_RECOVERY, + + [ITEM_ADAMANT_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUSTROUS_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRISEOUS_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_EXPERT_BELT] = ITEM_TYPE_HELD_ITEM, + [ITEM_POWER_HERB] = ITEM_TYPE_HELD_ITEM, + [ITEM_WIDE_LENS] = ITEM_TYPE_HELD_ITEM, + [ITEM_ZOOM_LENS] = ITEM_TYPE_HELD_ITEM, + [ITEM_DESTINY_KNOT] = ITEM_TYPE_HELD_ITEM, + [ITEM_SMOOTH_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_DAMP_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_HEAT_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_ICY_ROCK] = ITEM_TYPE_HELD_ITEM, + [ITEM_BIG_ROOT] = ITEM_TYPE_HELD_ITEM, + [ITEM_LIGHT_CLAY] = ITEM_TYPE_HELD_ITEM, + [ITEM_SAFETY_GOGGLES] = ITEM_TYPE_HELD_ITEM, + [ITEM_ROCKY_HELMET] = ITEM_TYPE_HELD_ITEM, + [ITEM_WEAKNESS_POLICY] = ITEM_TYPE_HELD_ITEM, + [ITEM_ASSAULT_VEST] = ITEM_TYPE_HELD_ITEM, + [ITEM_EVIOLITE] = ITEM_TYPE_HELD_ITEM, + [ITEM_ABSORB_BULB] = ITEM_TYPE_HELD_ITEM, + [ITEM_AIR_BALLOON] = ITEM_TYPE_HELD_ITEM, + [ITEM_ADRENALINE_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_BINDING_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_CELL_BATTERY] = ITEM_TYPE_HELD_ITEM, + [ITEM_EJECT_BUTTON] = ITEM_TYPE_HELD_ITEM, + [ITEM_FLOAT_STONE] = ITEM_TYPE_HELD_ITEM, + [ITEM_FOCUS_SASH] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRIP_CLAW] = ITEM_TYPE_HELD_ITEM, + [ITEM_IRON_BALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_LAGGING_TAIL] = ITEM_TYPE_HELD_ITEM, + [ITEM_LUMINOUS_MOSS] = ITEM_TYPE_HELD_ITEM, + [ITEM_QUICK_POWDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_METRONOME] = ITEM_TYPE_HELD_ITEM, + [ITEM_MUSCLE_BAND] = ITEM_TYPE_HELD_ITEM, + [ITEM_PROTECTIVE_PADS] = ITEM_TYPE_HELD_ITEM, + [ITEM_RED_CARD] = ITEM_TYPE_HELD_ITEM, + [ITEM_RING_TARGET] = ITEM_TYPE_HELD_ITEM, + [ITEM_SHED_SHELL] = ITEM_TYPE_HELD_ITEM, + [ITEM_SNOWBALL] = ITEM_TYPE_HELD_ITEM, + [ITEM_STICKY_BARB] = ITEM_TYPE_HELD_ITEM, + [ITEM_TERRAIN_EXTENDER] = ITEM_TYPE_HELD_ITEM, + [ITEM_WISE_GLASSES] = ITEM_TYPE_HELD_ITEM, + [ITEM_ELECTRIC_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_GRASSY_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_MISTY_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_PSYCHIC_SEED] = ITEM_TYPE_HELD_ITEM, + [ITEM_LIFE_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_TOXIC_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_FLAME_ORB] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLACK_SLUDGE] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHOICE_SPECS] = ITEM_TYPE_HELD_ITEM, + [ITEM_CHOICE_SCARF] = ITEM_TYPE_HELD_ITEM, + [ITEM_EJECT_PACK] = ITEM_TYPE_HELD_ITEM, + [ITEM_ROOM_SERVICE] = ITEM_TYPE_HELD_ITEM, + [ITEM_BLUNDER_POLICY] = ITEM_TYPE_HELD_ITEM, + [ITEM_HEAVY_DUTY_BOOTS] = ITEM_TYPE_HELD_ITEM, + [ITEM_UTILITY_UMBRELLA] = ITEM_TYPE_HELD_ITEM, + [ITEM_THROAT_SPRAY] = ITEM_TYPE_HELD_ITEM, + [ITEM_FIST_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SKY_PLATE] = ITEM_TYPE_PLATE, + [ITEM_TOXIC_PLATE] = ITEM_TYPE_PLATE, + [ITEM_EARTH_PLATE] = ITEM_TYPE_PLATE, + [ITEM_STONE_PLATE] = ITEM_TYPE_PLATE, + [ITEM_INSECT_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SPOOKY_PLATE] = ITEM_TYPE_PLATE, + [ITEM_IRON_PLATE] = ITEM_TYPE_PLATE, + [ITEM_FLAME_PLATE] = ITEM_TYPE_PLATE, + [ITEM_SPLASH_PLATE] = ITEM_TYPE_PLATE, + [ITEM_MEADOW_PLATE] = ITEM_TYPE_PLATE, + [ITEM_ZAP_PLATE] = ITEM_TYPE_PLATE, + [ITEM_MIND_PLATE] = ITEM_TYPE_PLATE, + [ITEM_ICICLE_PLATE] = ITEM_TYPE_PLATE, + [ITEM_DRACO_PLATE] = ITEM_TYPE_PLATE, + [ITEM_DREAD_PLATE] = ITEM_TYPE_PLATE, + [ITEM_PIXIE_PLATE] = ITEM_TYPE_PLATE, + [ITEM_FIGHTING_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FLYING_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_POISON_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GROUND_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ROCK_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_BUG_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GHOST_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_STEEL_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FIRE_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_WATER_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_GRASS_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ELECTRIC_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_PSYCHIC_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_ICE_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_DRAGON_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_DARK_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_FAIRY_MEMORY] = ITEM_TYPE_MEMORY, + [ITEM_BURN_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_DOUSE_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_SHOCK_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_CHILL_DRIVE] = ITEM_TYPE_DRIVE, + [ITEM_NORMAL_GEM] = ITEM_TYPE_GEM, + [ITEM_FIGHTING_GEM] = ITEM_TYPE_GEM, + [ITEM_FLYING_GEM] = ITEM_TYPE_GEM, + [ITEM_POISON_GEM] = ITEM_TYPE_GEM, + [ITEM_GROUND_GEM] = ITEM_TYPE_GEM, + [ITEM_ROCK_GEM] = ITEM_TYPE_GEM, + [ITEM_BUG_GEM] = ITEM_TYPE_GEM, + [ITEM_GHOST_GEM] = ITEM_TYPE_GEM, + [ITEM_STEEL_GEM] = ITEM_TYPE_GEM, + [ITEM_FIRE_GEM] = ITEM_TYPE_GEM, + [ITEM_WATER_GEM] = ITEM_TYPE_GEM, + [ITEM_GRASS_GEM] = ITEM_TYPE_GEM, + [ITEM_ELECTRIC_GEM] = ITEM_TYPE_GEM, + [ITEM_PSYCHIC_GEM] = ITEM_TYPE_GEM, + [ITEM_ICE_GEM] = ITEM_TYPE_GEM, + [ITEM_DRAGON_GEM] = ITEM_TYPE_GEM, + [ITEM_DARK_GEM] = ITEM_TYPE_GEM, + [ITEM_FAIRY_GEM] = ITEM_TYPE_GEM, + + [ITEM_LUCK_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_FULL_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_ODD_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_PURE_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_ROCK_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_ROSE_INCENSE] = ITEM_TYPE_INCENSE, + [ITEM_WAVE_INCENSE] = ITEM_TYPE_INCENSE, + + [ITEM_VENUSAURITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_CHARIZARDITE_X] = ITEM_TYPE_MEGA_STONE, + [ITEM_CHARIZARDITE_Y] = ITEM_TYPE_MEGA_STONE, + [ITEM_BLASTOISINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BEEDRILLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_PIDGEOTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ALAKAZITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SLOWBRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GENGARITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_KANGASKHANITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_PINSIRITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GYARADOSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AERODACTYLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEWTWONITE_X] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEWTWONITE_Y] = ITEM_TYPE_MEGA_STONE, + [ITEM_AMPHAROSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_STEELIXITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SCIZORITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_HERACRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_HOUNDOOMINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_TYRANITARITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SCEPTILITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BLAZIKENITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SWAMPERTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GARDEVOIRITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SABLENITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MAWILITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AGGRONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MEDICHAMITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_MANECTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SHARPEDONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_CAMERUPTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ALTARIANITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_BANETTITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ABSOLITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GLALITITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_SALAMENCITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_METAGROSSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LATIASITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LATIOSITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LOPUNNITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GARCHOMPITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_LUCARIONITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ABOMASITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_GALLADITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_AUDINITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_DIANCITE] = ITEM_TYPE_MEGA_STONE, + [ITEM_ULTRANECROZIUM_Z] = ITEM_TYPE_MEGA_STONE, + + [ITEM_NORMALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FIGHTINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FLYINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_POISONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GROUNDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ROCKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_BUGINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GHOSTIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_STEELIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_WATERIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_GRASSIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ELECTRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PSYCHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ICIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DRAGONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DARKINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_FAIRIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_ALORAICHIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_DECIDIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_EEVIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_INCINIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_KOMMONIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_LUNALIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_LYCANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MARSHADIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MEWNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_MIMIKIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PIKANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PIKASHUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_PRIMARIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_SNORLIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_SOLGANIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + [ITEM_TAPUNIUM_Z] = ITEM_TYPE_Z_CRYSTAL, + + [ITEM_RED_NECTAR] = ITEM_TYPE_NECTAR, + [ITEM_YELLOW_NECTAR] = ITEM_TYPE_NECTAR, + [ITEM_PINK_NECTAR] = ITEM_TYPE_NECTAR, + [ITEM_PURPLE_NECTAR] = ITEM_TYPE_NECTAR, + + [ITEM_ABILITY_CAPSULE] = ITEM_TYPE_STAT_BOOST_DRINK, + [ITEM_HEALTH_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_MUSCLE_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_RESIST_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_GENIUS_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_CLEVER_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_SWIFT_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + [ITEM_PRETTY_FEATHER] = ITEM_TYPE_STAT_BOOST_FEATHER, + + [ITEM_POWER_BRACER] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_POWER_BELT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_POWER_LENS] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_POWER_BAND] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_POWER_ANKLET] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + [ITEM_POWER_WEIGHT] = ITEM_TYPE_STAT_BOOST_HELD_ITEM, + + [ITEM_DAWN_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_DUSK_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_SHINY_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_ICE_STONE] = ITEM_TYPE_EVOLUTION_STONE, + [ITEM_OVAL_STONE] = ITEM_TYPE_EVOLUTION_STONE, + + [ITEM_PROTECTOR] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_MAGMARIZER] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_PRISM_SCALE] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_SACHET] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_WHIPPED_DREAM] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_RAZOR_CLAW] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_RAZOR_FANG] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_REAPER_CLOTH] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_DUBIOUS_DISC] = ITEM_TYPE_EVOLUTION_ITEM, + [ITEM_ELECTIRIZER] = ITEM_TYPE_EVOLUTION_ITEM, + + [ITEM_RARE_BONE] = ITEM_TYPE_SELLABLE, + [ITEM_PEARL_STRING] = ITEM_TYPE_SELLABLE, + [ITEM_BIG_NUGGET] = ITEM_TYPE_SELLABLE, + [ITEM_COMET_SHARD] = ITEM_TYPE_SELLABLE, + [ITEM_BALM_MUSHROOM] = ITEM_TYPE_SELLABLE, + [ITEM_ODD_KEYSTONE] = ITEM_TYPE_SELLABLE, + [ITEM_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, + [ITEM_GOLD_BOTTLE_CAP] = ITEM_TYPE_SELLABLE, + [ITEM_WISHING_PIECE] = ITEM_TYPE_SELLABLE, + [ITEM_RELIC_COPPER] = ITEM_TYPE_RELIC, + [ITEM_RELIC_SILVER] = ITEM_TYPE_RELIC, + [ITEM_RELIC_GOLD] = ITEM_TYPE_RELIC, + [ITEM_RELIC_VASE] = ITEM_TYPE_RELIC, + [ITEM_RELIC_BAND] = ITEM_TYPE_RELIC, + [ITEM_RELIC_STATUE] = ITEM_TYPE_RELIC, + [ITEM_RELIC_CROWN] = ITEM_TYPE_RELIC, + + [ITEM_ROOT_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_CLAW_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_SKULL_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_ARMOR_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_COVER_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_PLUME_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_JAW_FOSSIL] = ITEM_TYPE_FOSSIL, + [ITEM_SAIL_FOSSIL] = ITEM_TYPE_FOSSIL, + #endif }; static void AddBagSortSubMenu(void) From 6e201ba038508729127ba6d6d8ded50ef6d64047 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 20 Dec 2021 18:58:42 -0500 Subject: [PATCH 6/7] fix sort --- src/item_menu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index 1464aabc0d8b..6dd292399ef8 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1286,9 +1286,10 @@ static void Task_BagMenu_HandleInput(u8 taskId) PlaySE(SE_SELECT); BagDestroyPocketScrollArrowPair(); - BagMenu_PrintCursorAtPos(data[0], 2); + BagMenu_PrintCursor(tListTaskId, COLORID_GRAY_CURSOR); ListMenuGetScrollAndRow(data[0], scrollPos, cursorPos); gTasks[taskId].func = Task_LoadBagSortOptions; + return; } break; } @@ -3187,17 +3188,20 @@ static void AddBagSortSubMenu(void) BagMenu_Print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); if (gBagMenu->contextMenuNumItems == 2) - PrintContextMenuItems(BagMenu_AddWindow(1)); + PrintContextMenuItems(BagMenu_AddWindow(ITEMWIN_1x2)); else if (gBagMenu->contextMenuNumItems == 4) - PrintContextMenuItemGrid(BagMenu_AddWindow(2), 2, 2); + PrintContextMenuItemGrid(BagMenu_AddWindow(ITEMWIN_2x2), 2, 2); else - PrintContextMenuItemGrid(BagMenu_AddWindow(3), 2, 3); + PrintContextMenuItemGrid(BagMenu_AddWindow(ITEMWIN_2x3), 2, 3); } static void Task_LoadBagSortOptions(u8 taskId) { AddBagSortSubMenu(); - gTasks[taskId].func = Task_ItemContext_MultipleRows; + if (gBagMenu->contextMenuNumItems <= 2) + gTasks[taskId].func = Task_ItemContext_SingleRow; + else + gTasks[taskId].func = Task_ItemContext_MultipleRows; } #define tSortType data[2] From 4adc7c51297be0720f6d36c7d2d30c62320877a4 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 7 Jan 2024 13:11:51 +0100 Subject: [PATCH 7/7] Make work with modern and add configs --- include/config/item.h | 2 ++ src/item_menu.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/config/item.h b/include/config/item.h index 78324affeaeb..3234e2998f6a 100644 --- a/include/config/item.h +++ b/include/config/item.h @@ -17,6 +17,8 @@ #define I_PRICE GEN_LATEST // Some items have varied in value across generations. #define I_BERRY_PRICE GEN_7 // Since Berries have become unplantable (Gen8+), their price has gone up. +#define I_BAG_SORT TRUE // Enables sorting the bag by pressing the Start button + // TM config #define I_REUSABLE_TMS FALSE // In Gen5-8, TMs are reusable. Setting this to TRUE will make all vanilla TMs reusable, though they can also be cherry-picked by setting their importance to 1. diff --git a/src/item_menu.c b/src/item_menu.c index 602d864121ad..f8aa31253137 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -218,7 +218,7 @@ static void ConfirmSell(u8); static void CancelSell(u8); static void Task_FadeAndCloseBagMenuIfMulch(u8 taskId); -//bag sort +#if I_BAG_SORT == TRUE static void Task_LoadBagSortOptions(u8 taskId); static void ItemMenu_SortByName(u8 taskId); static void ItemMenu_SortByType(u8 taskId); @@ -231,6 +231,7 @@ static void Merge(struct ItemSlot* array, u32 low, u32 mid, u32 high, s8 (*compa static s8 CompareItemsAlphabetically(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); static s8 CompareItemsByMost(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); static s8 CompareItemsByType(struct ItemSlot* itemSlot1, struct ItemSlot* itemSlot2); +#endif // I_BAG_SORT == TRUE static const struct BgTemplate sBgTemplates_ItemMenu[] = { @@ -305,9 +306,11 @@ static const struct MenuAction sItemMenuActions[] = { [ACTION_SHOW] = {gMenuText_Show, {ItemMenu_Show}}, [ACTION_GIVE_FAVOR_LADY] = {gMenuText_Give2, {ItemMenu_GiveFavorLady}}, [ACTION_CONFIRM_QUIZ_LADY] = {gMenuText_Confirm, {ItemMenu_ConfirmQuizLady}}, +#if I_BAG_SORT == TRUE [ACTION_BY_NAME] = {sMenuText_ByName, {ItemMenu_SortByName}}, [ACTION_BY_TYPE] = {sMenuText_ByType, {ItemMenu_SortByType}}, [ACTION_BY_AMOUNT] = {sMenuText_ByAmount, {ItemMenu_SortByAmount}}, +#endif // I_BAG_SORT == TRUE [ACTION_DUMMY] = {gText_EmptyString2, {NULL}} }; @@ -1293,6 +1296,7 @@ static void Task_BagMenu_HandleInput(u8 taskId) } return; } + #if I_BAG_SORT == TRUE else if (JOY_NEW(START_BUTTON)) { if ((gBagMenu->numItemStacks[gBagPosition.pocket] - 1) <= 1) //can't sort with 0 or 1 item in bag @@ -1317,6 +1321,7 @@ static void Task_BagMenu_HandleInput(u8 taskId) gTasks[taskId].func = Task_LoadBagSortOptions; return; } + #endif // I_BAG_SORT == TRUE break; } @@ -2689,6 +2694,7 @@ static void PrintTMHMMoveData(u16 itemId) } // bag sorting +#if I_BAG_SORT == TRUE enum BagSortOptions { SORT_ALPHABETICALLY, @@ -3285,8 +3291,6 @@ static void SortBagItems(u8 taskId) static void Task_SortFinish(u8 taskId) { - s16* data = gTasks[taskId].data; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { RemoveItemMessageWindow(4); @@ -3298,7 +3302,6 @@ static void SortItemsInBag(u8 pocket, u8 type) { struct ItemSlot* itemMem; u16 itemAmount; - s8 (*func)(struct ItemSlot*, struct ItemSlot*); switch (pocket) { @@ -3441,3 +3444,5 @@ static s8 CompareItemsByType(struct ItemSlot* itemSlot1, struct ItemSlot* itemSl return CompareItemsAlphabetically(itemSlot1, itemSlot2); //Items are of same type so sort alphabetically } + +#endif // I_BAG_SORT == TRUE