2017-12-10 19:02:51 +01:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2017-12-16 00:08:23 +01:00
|
|
|
#include "battle.h"
|
|
|
|
#include "battle_controllers.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "battle_message.h"
|
|
|
|
#include "bg.h"
|
2017-12-16 00:08:23 +01:00
|
|
|
#include "decompress.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "event_data.h"
|
2018-12-24 00:02:29 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "graphics.h"
|
2017-12-16 00:08:23 +01:00
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "item.h"
|
2018-12-24 00:02:29 +01:00
|
|
|
#include "item_menu.h"
|
2017-12-16 15:10:29 +01:00
|
|
|
#include "lilycove_lady.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "list_menu.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_helpers.h"
|
2018-05-11 01:36:57 +02:00
|
|
|
#include "overworld.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "palette.h"
|
|
|
|
#include "pokeblock.h"
|
|
|
|
#include "pokemon.h"
|
|
|
|
#include "safari_zone.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "constants/items.h"
|
|
|
|
#include "constants/songs.h"
|
2019-04-04 23:05:46 +02:00
|
|
|
#include "constants/rgb.h"
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
#define MAX_MENU_ITEMS 9
|
|
|
|
#define MENU_MIDPOINT (MAX_MENU_ITEMS / 2)
|
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
#define TILE_HIGHLIGHT_NONE 0x0005 // Tile number for the bg of an unselected menu item
|
|
|
|
#define TILE_HIGHLIGHT_BLUE 0x1005 // Tile number for the bg of a selected menu item
|
2021-04-11 22:23:10 +02:00
|
|
|
#define TILE_HIGHLIGHT_RED 0x2005 // Tile number for the bg of a menu item to swap
|
|
|
|
|
|
|
|
#define TAG_POKEBLOCK_CASE 14800
|
|
|
|
#define TAG_SCROLL_ARROW 1110
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
#define POKEBLOCK_MAX_FEEL 99
|
2021-04-11 22:23:10 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
WIN_TITLE,
|
|
|
|
WIN_LIST,
|
|
|
|
WIN_SPICY,
|
|
|
|
WIN_DRY,
|
|
|
|
WIN_SWEET,
|
|
|
|
WIN_BITTER,
|
|
|
|
WIN_SOUR,
|
|
|
|
WIN_FEEL,
|
|
|
|
WIN_ACTIONS_TALL,
|
|
|
|
WIN_ACTIONS,
|
|
|
|
WIN_TOSS_MSG,
|
|
|
|
};
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
struct PokeblockMenuStruct
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
u8 tilemap[BG_SCREEN_SIZE];
|
2017-12-16 15:10:29 +01:00
|
|
|
void (*callbackOnUse)(void);
|
2021-04-11 22:23:10 +02:00
|
|
|
const u8 *pokeblockActionIds;
|
|
|
|
u8 numActions;
|
2017-12-16 00:08:23 +01:00
|
|
|
u8 caseId;
|
|
|
|
u8 itemsNo;
|
|
|
|
u8 maxShowed;
|
|
|
|
struct ListMenuItem items[POKEBLOCKS_COUNT + 1];
|
2021-04-11 22:23:10 +02:00
|
|
|
u8 menuItemsStrings[POKEBLOCKS_COUNT + 1][32]; // + 1 because of STOW CASE item
|
2017-12-16 00:08:23 +01:00
|
|
|
u8 pokeblockCaseSpriteId;
|
2021-04-11 22:23:10 +02:00
|
|
|
u8 swapLineSpriteIds[7];
|
|
|
|
u8 arrowTaskId;
|
2017-12-16 00:08:23 +01:00
|
|
|
bool8 isSwapping;
|
|
|
|
s16 gfxState;
|
2017-12-16 15:12:55 +01:00
|
|
|
u8 unused[8];
|
2017-12-16 00:08:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PokeblockSavedData
|
|
|
|
{
|
|
|
|
void (*callback)(void);
|
2021-04-11 22:23:10 +02:00
|
|
|
u16 selectedRow;
|
|
|
|
u16 scrollOffset;
|
2017-12-16 00:08:23 +01:00
|
|
|
};
|
2017-12-10 19:02:51 +01:00
|
|
|
|
2017-12-11 16:52:28 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PKBL_USE_ON_FIELD,
|
|
|
|
PKBL_TOSS,
|
|
|
|
PKBL_CANCEL,
|
|
|
|
PKBL_USE_IN_BATTLE,
|
|
|
|
PKBL_USE_ON_FEEDER,
|
|
|
|
PKBL_GIVE_TO_LADY
|
|
|
|
};
|
2017-12-10 19:02:51 +01:00
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void CB2_InitPokeblockMenu(void);
|
|
|
|
static bool8 InitPokeblockMenu(void);
|
2017-12-16 00:08:23 +01:00
|
|
|
static bool8 LoadPokeblockMenuGfx(void);
|
|
|
|
static void HandleInitBackgrounds(void);
|
|
|
|
static void HandleInitWindows(void);
|
2017-12-16 15:10:29 +01:00
|
|
|
static void SetMenuItemsCountAndMaxShowed(void);
|
2021-04-11 22:23:10 +02:00
|
|
|
static void LimitMenuScrollAndRow(void);
|
|
|
|
static void SetInitialScroll(void);
|
|
|
|
static void UpdatePokeblockList(void);
|
|
|
|
static void CreateScrollArrows(void);
|
|
|
|
static void MovePokeblockMenuCursor(s32, bool8, struct ListMenu *);
|
|
|
|
static void DrawPokeblockMenuTitleText(void);
|
|
|
|
static void DrawPokeblockMenuHighlight(u16, u16);
|
|
|
|
static void PutPokeblockListMenuString(u8 *, u16);
|
|
|
|
static void Task_HandlePokeblockMenuInput(u8);
|
|
|
|
static void PokeblockAction_UseOnField(u8);
|
|
|
|
static void PokeblockAction_Toss(u8);
|
|
|
|
static void PokeblockAction_Cancel(u8);
|
|
|
|
static void PokeblockAction_UseInBattle(u8);
|
|
|
|
static void PokeblockAction_UseOnPokeblockFeeder(u8);
|
|
|
|
static void PokeblockAction_GiveToContestLady(u8);
|
|
|
|
static void TossedPokeblockMessage(u8);
|
|
|
|
static void CloseTossPokeblockWindow(u8);
|
|
|
|
static void Task_FreeDataAndExitPokeblockCase(u8);
|
|
|
|
static void Task_HandlePokeblockActionsInput(u8);
|
|
|
|
static void ShowPokeblockActionsWindow(u8);
|
|
|
|
static void Task_HandlePokeblocksSwapInput(u8);
|
|
|
|
static void SpriteCB_ShakePokeblockCase(struct Sprite *);
|
|
|
|
static void DrawPokeblockInfo(s32);
|
|
|
|
static void UpdatePokeblockSwapMenu(u8, bool8);
|
2017-12-16 15:10:29 +01:00
|
|
|
static void UsePokeblockOnField(void);
|
|
|
|
static void ReturnToPokeblockCaseOnField(void);
|
2021-04-11 22:23:10 +02:00
|
|
|
static void CreateTossPokeblockYesNoMenu(u8);
|
|
|
|
static void TossPokeblock(u8);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
EWRAM_DATA static struct PokeblockSavedData sSavedPokeblockData = {0};
|
|
|
|
EWRAM_DATA static struct PokeblockMenuStruct *sPokeblockMenu = NULL;
|
2017-12-11 16:52:28 +01:00
|
|
|
|
2020-07-17 02:12:12 +02:00
|
|
|
const s8 gPokeblockFlavorCompatibilityTable[NUM_NATURES * FLAVOR_COUNT] =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Spicy, Dry, Sweet, Bitter, Sour
|
2017-12-11 16:52:28 +01:00
|
|
|
0, 0, 0, 0, 0, // Hardy
|
|
|
|
1, 0, 0, 0, -1, // Lonely
|
|
|
|
1, 0, -1, 0, 0, // Brave
|
|
|
|
1, -1, 0, 0, 0, // Adamant
|
|
|
|
1, 0, 0, -1, 0, // Naughty
|
|
|
|
-1, 0, 0, 0, 1, // Bold
|
|
|
|
0, 0, 0, 0, 0, // Docile
|
|
|
|
0, 0, -1, 0, 1, // Relaxed
|
|
|
|
0, -1, 0, 0, 1, // Impish
|
|
|
|
0, 0, 0, -1, 1, // Lax
|
|
|
|
-1, 0, 1, 0, 0, // Timid
|
|
|
|
0, 0, 1, 0, -1, // Hasty
|
|
|
|
0, 0, 0, 0, 0, // Serious
|
|
|
|
0, -1, 1, 0, 0, // Jolly
|
|
|
|
0, 0, 1, -1, 0, // Naive
|
|
|
|
-1, 1, 0, 0, 0, // Modest
|
|
|
|
0, 1, 0, 0, -1, // Mild
|
|
|
|
0, 1, -1, 0, 0, // Quiet
|
|
|
|
0, 0, 0, 0, 0, // Bashful
|
|
|
|
0, 1, 0, -1, 0, // Rash
|
|
|
|
-1, 0, 0, 1, 0, // Calm
|
|
|
|
0, 0, 0, 1, -1, // Gentle
|
|
|
|
0, 0, -1, 1, 0, // Sassy
|
|
|
|
0, -1, 0, 1, 0, // Careful
|
|
|
|
0, 0, 0, 0, 0 // Quirky
|
|
|
|
};
|
|
|
|
|
2017-12-16 00:08:23 +01:00
|
|
|
static const struct BgTemplate sBgTemplatesForPokeblockMenu[] =
|
2017-12-11 16:52:28 +01: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
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const u8 *const gPokeblockNames[] =
|
|
|
|
{
|
2020-08-24 20:52:33 +02:00
|
|
|
[PBLOCK_CLR_NONE] = NULL,
|
|
|
|
[PBLOCK_CLR_RED] = gText_RedPokeblock,
|
|
|
|
[PBLOCK_CLR_BLUE] = gText_BluePokeblock,
|
|
|
|
[PBLOCK_CLR_PINK] = gText_PinkPokeblock,
|
|
|
|
[PBLOCK_CLR_GREEN] = gText_GreenPokeblock,
|
|
|
|
[PBLOCK_CLR_YELLOW] = gText_YellowPokeblock,
|
|
|
|
[PBLOCK_CLR_PURPLE] = gText_PurplePokeblock,
|
|
|
|
[PBLOCK_CLR_INDIGO] = gText_IndigoPokeblock,
|
|
|
|
[PBLOCK_CLR_BROWN] = gText_BrownPokeblock,
|
|
|
|
[PBLOCK_CLR_LITE_BLUE] = gText_LiteBluePokeblock,
|
|
|
|
[PBLOCK_CLR_OLIVE] = gText_OlivePokeblock,
|
|
|
|
[PBLOCK_CLR_GRAY] = gText_GrayPokeblock,
|
|
|
|
[PBLOCK_CLR_BLACK] = gText_BlackPokeblock,
|
|
|
|
[PBLOCK_CLR_WHITE] = gText_WhitePokeblock,
|
|
|
|
[PBLOCK_CLR_GOLD] = gText_GoldPokeblock
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static const struct MenuAction sPokeblockMenuActions[] =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
[PKBL_USE_ON_FIELD] = {gMenuText_Use, PokeblockAction_UseOnField},
|
|
|
|
[PKBL_TOSS] = {gMenuText_Toss, PokeblockAction_Toss},
|
|
|
|
[PKBL_CANCEL] = {gText_Cancel2, PokeblockAction_Cancel},
|
|
|
|
[PKBL_USE_IN_BATTLE] = {gMenuText_Use, PokeblockAction_UseInBattle},
|
|
|
|
[PKBL_USE_ON_FEEDER] = {gMenuText_Use, PokeblockAction_UseOnPokeblockFeeder},
|
|
|
|
[PKBL_GIVE_TO_LADY] = {gMenuText_Give2, PokeblockAction_GiveToContestLady},
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static const u8 sActionsOnField[] = {PKBL_USE_ON_FIELD, PKBL_TOSS, PKBL_CANCEL};
|
|
|
|
static const u8 sActionsInBattle[] = {PKBL_USE_IN_BATTLE, PKBL_CANCEL};
|
|
|
|
static const u8 sActionsOnPokeblockFeeder[] = {PKBL_USE_ON_FEEDER, PKBL_CANCEL};
|
|
|
|
static const u8 sActionsWhenGivingToLady[] = {PKBL_GIVE_TO_LADY, PKBL_CANCEL};
|
2017-12-11 16:52:28 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static const struct YesNoFuncTable sTossYesNoFuncTable = {TossedPokeblockMessage, CloseTossPokeblockWindow};
|
2017-12-11 16:52:28 +01:00
|
|
|
|
|
|
|
static const u8 sContestStatsMonData[] = {MON_DATA_COOL, MON_DATA_BEAUTY, MON_DATA_CUTE, MON_DATA_SMART, MON_DATA_TOUGH};
|
|
|
|
|
|
|
|
static const struct OamData sOamData_PokeblockCase =
|
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2017-12-11 16:52:28 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2017-12-11 16:52:28 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2017-12-11 16:52:28 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd sSpriteAnim_PokeblockCase[] =
|
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const sSpriteAnimTable_PokeblockCase[] =
|
|
|
|
{
|
|
|
|
sSpriteAnim_PokeblockCase
|
|
|
|
};
|
|
|
|
|
2021-04-26 20:41:15 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_PokeblockCaseShake[] =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0, 0, -2, 2),
|
|
|
|
AFFINEANIMCMD_FRAME(0, 0, 2, 4),
|
|
|
|
AFFINEANIMCMD_FRAME(0, 0, -2, 4),
|
|
|
|
AFFINEANIMCMD_FRAME(0, 0, 2, 2),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-26 20:41:15 +02:00
|
|
|
static const union AffineAnimCmd *const sAffineAnims_PokeblockCaseShake[] =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
2021-04-26 20:41:15 +02:00
|
|
|
sAffineAnim_PokeblockCaseShake
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet =
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
gMenuPokeblockDevice_Gfx, 0x800, TAG_POKEBLOCK_CASE
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct CompressedSpritePalette gPokeblockCase_SpritePal =
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
gMenuPokeblockDevice_Pal, TAG_POKEBLOCK_CASE
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
2017-12-16 00:08:23 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PokeblockCase =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
.tileTag = TAG_POKEBLOCK_CASE,
|
|
|
|
.paletteTag = TAG_POKEBLOCK_CASE,
|
|
|
|
.oam = &sOamData_PokeblockCase,
|
|
|
|
.anims = sSpriteAnimTable_PokeblockCase,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static const u8 sTextColor[3] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY};
|
2017-12-11 16:52:28 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static const struct Pokeblock sFavoritePokeblocksTable[FLAVOR_COUNT] =
|
2017-12-11 16:52:28 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
[FLAVOR_SPICY] = { PBLOCK_CLR_RED, 20, 0, 0, 0, 0, 20},
|
|
|
|
[FLAVOR_DRY] = { PBLOCK_CLR_BLUE, 0, 20, 0, 0, 0, 20},
|
|
|
|
[FLAVOR_SWEET] = { PBLOCK_CLR_PINK, 0, 0, 20, 0, 0, 20},
|
|
|
|
[FLAVOR_BITTER] = { PBLOCK_CLR_GREEN, 0, 0, 0, 20, 0, 20},
|
|
|
|
[FLAVOR_SOUR] = { PBLOCK_CLR_YELLOW, 0, 0, 0, 0, 20, 20}
|
2017-12-11 16:52:28 +01:00
|
|
|
};
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static const struct WindowTemplate sWindowTemplates[] =
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_TITLE] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 9,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1E
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_LIST] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 15,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 14,
|
|
|
|
.height = 18,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x30
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_SPICY] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x12C
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_DRY] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x136
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_SWEET] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x140
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_BITTER] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 8,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x14A
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_SOUR] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 8,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 5,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x154
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_FEEL] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 11,
|
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 2,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x15E
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_ACTIONS_TALL] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 7,
|
|
|
|
.tilemapTop = 5,
|
|
|
|
.width = 6,
|
|
|
|
.height = 6,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x162
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_ACTIONS] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 7,
|
|
|
|
.tilemapTop = 7,
|
|
|
|
.width = 6,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x186
|
|
|
|
},
|
2021-04-11 22:23:10 +02:00
|
|
|
[WIN_TOSS_MSG] = {
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 27,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x19E
|
|
|
|
},
|
2017-12-16 00:08:23 +01:00
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
2018-09-02 18:53:52 +02:00
|
|
|
static const struct WindowTemplate sTossPkblockWindowTemplate =
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 1,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 21,
|
|
|
|
.tilemapTop = 9,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x20A
|
|
|
|
};
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
static const struct ListMenuTemplate sPokeblockListMenuTemplate =
|
|
|
|
{
|
|
|
|
.items = NULL,
|
|
|
|
.moveCursorFunc = MovePokeblockMenuCursor,
|
2018-07-15 13:23:38 +02:00
|
|
|
.itemPrintFunc = NULL,
|
2017-12-16 00:08:23 +01:00
|
|
|
.totalItems = 0,
|
|
|
|
.maxShowed = 0,
|
2021-04-11 22:23:10 +02:00
|
|
|
.windowId = WIN_LIST,
|
2018-07-15 13:23:38 +02:00
|
|
|
.header_X = 0,
|
|
|
|
.item_X = 1,
|
2018-03-03 14:58:41 +01:00
|
|
|
.cursor_X = 0,
|
2017-12-16 00:08:23 +01:00
|
|
|
.upText_Y = 1,
|
2018-03-02 16:34:31 +01:00
|
|
|
.cursorPal = 2,
|
2018-03-03 14:58:41 +01:00
|
|
|
.fillValue = 0,
|
2018-03-02 16:34:31 +01:00
|
|
|
.cursorShadowPal = 3,
|
2018-03-03 14:58:41 +01:00
|
|
|
.lettersSpacing = 0,
|
2018-07-15 13:23:38 +02:00
|
|
|
.itemVerticalPadding = 0,
|
2018-03-02 16:34:31 +01:00
|
|
|
.scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD,
|
2021-10-30 22:47:37 +02:00
|
|
|
.fontId = FONT_NORMAL,
|
2017-12-16 00:08:23 +01:00
|
|
|
.cursorKind = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
void OpenPokeblockCase(u8 caseId, void (*callback)(void))
|
|
|
|
{
|
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
|
|
|
sPokeblockMenu = Alloc(sizeof(*sPokeblockMenu));
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->caseId = caseId;
|
2017-12-16 15:10:29 +01:00
|
|
|
sPokeblockMenu->callbackOnUse = NULL;
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->arrowTaskId = TASK_NONE;
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->isSwapping = FALSE;
|
|
|
|
sSavedPokeblockData.callback = callback;
|
|
|
|
|
|
|
|
switch (sPokeblockMenu->caseId)
|
|
|
|
{
|
|
|
|
case PBLOCK_CASE_BATTLE:
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->pokeblockActionIds = sActionsInBattle;
|
|
|
|
sPokeblockMenu->numActions = ARRAY_COUNT(sActionsInBattle);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
case PBLOCK_CASE_FEEDER:
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->pokeblockActionIds = sActionsOnPokeblockFeeder;
|
|
|
|
sPokeblockMenu->numActions = ARRAY_COUNT(sActionsOnPokeblockFeeder);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
case PBLOCK_CASE_GIVE:
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->pokeblockActionIds = sActionsWhenGivingToLady;
|
|
|
|
sPokeblockMenu->numActions = ARRAY_COUNT(sActionsWhenGivingToLady);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
2019-12-22 01:01:38 +01:00
|
|
|
default: // PBLOCK_CASE_FIELD
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->pokeblockActionIds = sActionsOnField;
|
|
|
|
sPokeblockMenu->numActions = ARRAY_COUNT(sActionsOnField);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetMainCallback2(CB2_InitPokeblockMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenPokeblockCaseInBattle(void)
|
|
|
|
{
|
2019-10-18 01:22:03 +02:00
|
|
|
OpenPokeblockCase(PBLOCK_CASE_BATTLE, CB2_SetUpReshowBattleScreenAfterMenu2);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenPokeblockCaseOnFeeder(void)
|
|
|
|
{
|
2018-02-14 00:58:22 +01:00
|
|
|
OpenPokeblockCase(PBLOCK_CASE_FEEDER, CB2_ReturnToField);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void CB2_PokeblockMenu(void)
|
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
2020-06-20 01:58:56 +02:00
|
|
|
DoScheduledBgTilemapCopiesToVram();
|
2017-12-16 00:08:23 +01:00
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VBlankCB_PokeblockMenu(void)
|
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void CB2_InitPokeblockMenu(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
if (InitPokeblockMenu() == TRUE)
|
|
|
|
break;
|
2021-11-01 23:06:15 +01:00
|
|
|
if (MenuHelpers_IsLinkActive() == TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
#define tListTaskId data[0]
|
|
|
|
#define tWindowId data[1]
|
|
|
|
#define tToSwapId data[2]
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static bool8 InitPokeblockMenu(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankHBlankCallbacksToNull();
|
2020-06-20 01:58:56 +02:00
|
|
|
ClearScheduledBgCopiesToVram();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-01-16 18:59:06 +01:00
|
|
|
ScanlineEffect_Stop();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ResetPaletteFade();
|
2021-04-11 22:23:10 +02:00
|
|
|
gPaletteFade.bufferTransferDisabled = TRUE;
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ResetSpriteData();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (sPokeblockMenu->caseId != PBLOCK_CASE_BATTLE)
|
|
|
|
ResetTasks();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
HandleInitBackgrounds();
|
|
|
|
sPokeblockMenu->gfxState = 0;
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (!LoadPokeblockMenuGfx())
|
|
|
|
return FALSE;
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
SetMenuItemsCountAndMaxShowed();
|
2021-04-11 22:23:10 +02:00
|
|
|
LimitMenuScrollAndRow();
|
|
|
|
SetInitialScroll();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
sPokeblockMenu->pokeblockCaseSpriteId = CreatePokeblockCaseSprite(56, 64, 0);
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 10:
|
2021-04-11 22:23:10 +02:00
|
|
|
CreateSwapLineSprites(sPokeblockMenu->swapLineSpriteIds, ARRAY_COUNT(sPokeblockMenu->swapLineSpriteIds));
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 11:
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockMenuHighlight(sSavedPokeblockData.selectedRow, TILE_HIGHLIGHT_BLUE);
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
HandleInitWindows();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 13:
|
2021-04-11 22:23:10 +02:00
|
|
|
UpdatePokeblockList();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 14:
|
2021-04-11 22:23:10 +02:00
|
|
|
CreateScrollArrows();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
taskId = CreateTask(Task_HandlePokeblockMenuInput, 0);
|
2021-04-11 22:23:10 +02:00
|
|
|
gTasks[taskId].tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, sSavedPokeblockData.scrollOffset, sSavedPokeblockData.selectedRow);
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 16:
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockMenuTitleText();
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 17:
|
2021-04-11 22:23:10 +02:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, 0);
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 18:
|
2021-04-11 22:23:10 +02:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
2017-12-16 00:08:23 +01:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetVBlankCallback(VBlankCB_PokeblockMenu);
|
|
|
|
SetMainCallback2(CB2_PokeblockMenu);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleInitBackgrounds(void)
|
|
|
|
{
|
|
|
|
ResetVramOamAndBgCntRegs();
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
|
|
|
InitBgsFromTemplates(0, sBgTemplatesForPokeblockMenu, ARRAY_COUNT(sBgTemplatesForPokeblockMenu));
|
|
|
|
SetBgTilemapBuffer(2, sPokeblockMenu->tilemap);
|
|
|
|
ResetAllBgsCoordinates();
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 LoadPokeblockMenuGfx(void)
|
|
|
|
{
|
|
|
|
switch (sPokeblockMenu->gfxState)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-05-14 10:37:09 +02:00
|
|
|
ResetTempTileDataBuffers();
|
|
|
|
DecompressAndCopyTileDataToVram(2, gMenuPokeblock_Gfx, 0, 0, 0);
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->gfxState++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-05-14 10:37:09 +02:00
|
|
|
if (FreeTempTileDataBuffersIfPossible() != TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
LZDecompressWram(gMenuPokeblock_Tilemap, sPokeblockMenu->tilemap);
|
|
|
|
sPokeblockMenu->gfxState++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
LoadCompressedPalette(gMenuPokeblock_Pal, 0, 0xC0);
|
|
|
|
sPokeblockMenu->gfxState++;
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&gPokeblockCase_SpriteSheet);
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->gfxState++;
|
|
|
|
break;
|
|
|
|
case 4:
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpritePalette(&gPokeblockCase_SpritePal);
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->gfxState++;
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-11 22:23:10 +02:00
|
|
|
LoadListMenuSwapLineGfx();
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->gfxState = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleInitWindows(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
InitWindows(sWindowTemplates);
|
2017-12-16 00:08:23 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadUserWindowBorderGfx(0, 1, 0xE0);
|
2018-06-17 16:48:58 +02:00
|
|
|
LoadMessageBoxGfx(0, 0xA, 0xD0);
|
2021-10-26 22:52:23 +02:00
|
|
|
LoadPalette(gStandardMenuPalette, 0xF0, 0x20);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sWindowTemplates) - 1; i++)
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(i, PIXEL_FILL(0));
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, 1, 0, 0, sTextColor, 0, string);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void DrawPokeblockMenuTitleText(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2018-04-29 13:36:26 +02:00
|
|
|
const u8 *itemName = ItemId_GetName(ITEM_POKEBLOCK_CASE);
|
2021-10-30 22:47:37 +02:00
|
|
|
PrintOnPokeblockWindow(WIN_TITLE, itemName, GetStringCenterAlignXOffset(FONT_NORMAL, itemName, 0x48));
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
PrintOnPokeblockWindow(WIN_SPICY, gText_Spicy, 0);
|
|
|
|
PrintOnPokeblockWindow(WIN_DRY, gText_Dry, 0);
|
|
|
|
PrintOnPokeblockWindow(WIN_SWEET, gText_Sweet, 0);
|
|
|
|
PrintOnPokeblockWindow(WIN_BITTER, gText_Bitter, 0);
|
|
|
|
PrintOnPokeblockWindow(WIN_SOUR, gText_Sour, 0);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
for (i = 0; i < WIN_ACTIONS_TALL; i++)
|
2017-12-16 00:08:23 +01:00
|
|
|
PutWindowTilemap(i);
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void UpdatePokeblockList(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < sPokeblockMenu->itemsNo - 1; i++)
|
|
|
|
{
|
|
|
|
PutPokeblockListMenuString(sPokeblockMenu->menuItemsStrings[i], i);
|
|
|
|
sPokeblockMenu->items[i].name = sPokeblockMenu->menuItemsStrings[i];
|
|
|
|
sPokeblockMenu->items[i].id = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringCopy(sPokeblockMenu->menuItemsStrings[i], gText_StowCase);
|
|
|
|
sPokeblockMenu->items[i].name = sPokeblockMenu->menuItemsStrings[i];
|
2019-03-03 08:50:40 +01:00
|
|
|
sPokeblockMenu->items[i].id = LIST_CANCEL;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
gMultiuseListMenuTemplate = sPokeblockListMenuTemplate;
|
2021-10-30 22:47:37 +02:00
|
|
|
gMultiuseListMenuTemplate.fontId = FONT_NARROW;
|
2017-12-16 00:08:23 +01:00
|
|
|
gMultiuseListMenuTemplate.totalItems = sPokeblockMenu->itemsNo;
|
|
|
|
gMultiuseListMenuTemplate.items = sPokeblockMenu->items;
|
|
|
|
gMultiuseListMenuTemplate.maxShowed = sPokeblockMenu->maxShowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PutPokeblockListMenuString(u8 *dst, u16 pkblId)
|
|
|
|
{
|
|
|
|
struct Pokeblock *pkblock = &gSaveBlock1Ptr->pokeblocks[pkblId];
|
|
|
|
u8 *txtPtr = StringCopy(dst, gPokeblockNames[pkblock->color]);
|
|
|
|
|
|
|
|
*(txtPtr++) = EXT_CTRL_CODE_BEGIN;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr++) = EXT_CTRL_CODE_SKIP;
|
2020-08-24 20:52:33 +02:00
|
|
|
*(txtPtr++) = CHAR_BLOCK_1;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
ConvertIntToDecimalStringN(gStringVar1, GetHighestPokeblocksFlavorLevel(pkblock), STR_CONV_MODE_LEFT_ALIGN, 3);
|
|
|
|
StringExpandPlaceholders(txtPtr, gText_LvVar1);
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void MovePokeblockMenuCursor(s32 pkblId, bool8 onInit, struct ListMenu *list)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (onInit != TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
gSprites[sPokeblockMenu->pokeblockCaseSpriteId].callback = SpriteCB_ShakePokeblockCase;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!sPokeblockMenu->isSwapping)
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockInfo(pkblId);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void DrawPokeblockInfo(s32 pkblId)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
struct Pokeblock *pokeblock;
|
|
|
|
u16 rectTilemapSrc[2];
|
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(7, PIXEL_FILL(0));
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2019-03-03 08:50:40 +01:00
|
|
|
if (pkblId != LIST_CANCEL)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
pokeblock = &gSaveBlock1Ptr->pokeblocks[pkblId];
|
|
|
|
rectTilemapSrc[0] = 0x17;
|
|
|
|
rectTilemapSrc[1] = 0x18;
|
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (GetPokeblockData(pokeblock, PBLOCK_SPICY + i) > 0)
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Pokéblock has this flavor, draw Pokéblock icon next to it
|
2021-03-30 23:38:09 +02:00
|
|
|
rectTilemapSrc[0] = (i << 12) + 0x17;
|
|
|
|
rectTilemapSrc[1] = (i << 12) + 0x18;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Pokéblock doesn't have this flavor, draw regular tiles
|
2017-12-16 00:08:23 +01:00
|
|
|
rectTilemapSrc[0] = 0xF;
|
|
|
|
rectTilemapSrc[1] = 0xF;
|
|
|
|
}
|
|
|
|
CopyToBgTilemapBufferRect(2, rectTilemapSrc, (i / 3 * 6) + 1, (i % 3 * 2) + 13, 1, 2);
|
|
|
|
}
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
// Print the Pokéblock's feel
|
2017-12-16 00:08:23 +01:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, GetPokeblocksFeel(pokeblock), STR_CONV_MODE_RIGHT_ALIGN, 2);
|
2021-04-11 22:23:10 +02:00
|
|
|
PrintOnPokeblockWindow(WIN_FEEL, gStringVar1, 4);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Selected cancel, erase info
|
2017-12-16 00:08:23 +01:00
|
|
|
rectTilemapSrc[0] = 0xF;
|
|
|
|
rectTilemapSrc[1] = 0xF;
|
|
|
|
|
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
|
|
|
CopyToBgTilemapBufferRect(2, rectTilemapSrc, (i / 3 * 6) + 1, (i % 3 * 2) + 13, 1, 2);
|
2021-04-11 22:23:10 +02:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(7, COPYWIN_GFX);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void DrawPokeblockMenuHighlight(u16 cursorPos, u16 tileNum)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
FillBgTilemapBufferRect_Palette0(2, tileNum, 0xF, (cursorPos * 2) + 1, 0xE, 2);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(2);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void CompactPokeblockSlots(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u16 i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < POKEBLOCKS_COUNT - 1; i++)
|
|
|
|
{
|
|
|
|
for (j = i + 1; j < POKEBLOCKS_COUNT; j++)
|
|
|
|
{
|
2020-08-24 20:52:33 +02:00
|
|
|
if (gSaveBlock1Ptr->pokeblocks[i].color == PBLOCK_CLR_NONE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
struct Pokeblock temp = gSaveBlock1Ptr->pokeblocks[i];
|
|
|
|
gSaveBlock1Ptr->pokeblocks[i] = gSaveBlock1Ptr->pokeblocks[j];
|
|
|
|
gSaveBlock1Ptr->pokeblocks[j] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void SwapPokeblockMenuItems(u32 id1, u32 id2)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
s16 i, count;
|
|
|
|
struct Pokeblock *pokeblocks = gSaveBlock1Ptr->pokeblocks;
|
|
|
|
struct Pokeblock *copyPokeblock1;
|
|
|
|
|
|
|
|
if (id1 == id2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
copyPokeblock1 = Alloc(sizeof(struct Pokeblock));
|
|
|
|
*copyPokeblock1 = pokeblocks[id1];
|
|
|
|
|
|
|
|
if (id2 > id1)
|
|
|
|
{
|
|
|
|
id2--;
|
|
|
|
for (count = id2, i = id1; i < count; i++)
|
|
|
|
pokeblocks[i] = pokeblocks[i + 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (count = id2, i = id1; i > count; i--)
|
|
|
|
pokeblocks[i] = pokeblocks[i - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
pokeblocks[id2] = *copyPokeblock1;
|
|
|
|
Free(copyPokeblock1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetPokeblockScrollPositions(void)
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
sSavedPokeblockData.selectedRow = 0;
|
|
|
|
sSavedPokeblockData.scrollOffset = 0;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void SetMenuItemsCountAndMaxShowed(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
CompactPokeblockSlots();
|
|
|
|
|
|
|
|
for (sPokeblockMenu->itemsNo = 0, i = 0; i < POKEBLOCKS_COUNT; i++)
|
|
|
|
{
|
2020-08-24 20:52:33 +02:00
|
|
|
if (gSaveBlock1Ptr->pokeblocks[i].color != PBLOCK_CLR_NONE)
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->itemsNo++;
|
|
|
|
}
|
|
|
|
|
|
|
|
sPokeblockMenu->itemsNo++; // STOW CASE menu item
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sPokeblockMenu->itemsNo > MAX_MENU_ITEMS)
|
|
|
|
sPokeblockMenu->maxShowed = MAX_MENU_ITEMS;
|
2017-12-16 00:08:23 +01:00
|
|
|
else
|
|
|
|
sPokeblockMenu->maxShowed = sPokeblockMenu->itemsNo;
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void LimitMenuScrollAndRow(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sSavedPokeblockData.scrollOffset != 0)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sSavedPokeblockData.scrollOffset + sPokeblockMenu->maxShowed > sPokeblockMenu->itemsNo)
|
|
|
|
sSavedPokeblockData.scrollOffset = sPokeblockMenu->itemsNo - sPokeblockMenu->maxShowed;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sSavedPokeblockData.scrollOffset + sSavedPokeblockData.selectedRow >= sPokeblockMenu->itemsNo)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
if (sPokeblockMenu->itemsNo == 0)
|
2021-04-11 22:23:10 +02:00
|
|
|
sSavedPokeblockData.selectedRow = 0;
|
2017-12-16 00:08:23 +01:00
|
|
|
else
|
2021-04-11 22:23:10 +02:00
|
|
|
sSavedPokeblockData.selectedRow = sPokeblockMenu->itemsNo - 1;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void SetInitialScroll(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sSavedPokeblockData.selectedRow > MENU_MIDPOINT)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0;
|
2021-04-11 22:23:10 +02:00
|
|
|
(i < sSavedPokeblockData.selectedRow - MENU_MIDPOINT) && (sSavedPokeblockData.scrollOffset + sPokeblockMenu->maxShowed != sPokeblockMenu->itemsNo);
|
|
|
|
sSavedPokeblockData.selectedRow--, sSavedPokeblockData.scrollOffset++, i++);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void CreateScrollArrows(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sPokeblockMenu->arrowTaskId == TASK_NONE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenu->arrowTaskId = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xB0, 8, 0x98, sPokeblockMenu->itemsNo - sPokeblockMenu->maxShowed,
|
|
|
|
TAG_SCROLL_ARROW, TAG_SCROLL_ARROW, &sSavedPokeblockData.scrollOffset);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void DestroyScrollArrows(void)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sPokeblockMenu->arrowTaskId != TASK_NONE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(sPokeblockMenu->arrowTaskId);
|
|
|
|
sPokeblockMenu->arrowTaskId = TASK_NONE;
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CreatePokeblockCaseSprite(s16 x, s16 y, u8 subpriority)
|
|
|
|
{
|
|
|
|
return CreateSprite(&sSpriteTemplate_PokeblockCase, x, y, subpriority);
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
#define sState data[0]
|
|
|
|
#define sTimer data[1]
|
|
|
|
|
|
|
|
static void SpriteCB_ShakePokeblockCase(struct Sprite *sprite)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sprite->sState > 1)
|
|
|
|
sprite->sState = 0;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
switch (sprite->sState)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
2021-04-26 20:41:15 +02:00
|
|
|
sprite->affineAnims = sAffineAnims_PokeblockCaseShake;
|
2017-12-16 00:08:23 +01:00
|
|
|
InitSpriteAffineAnim(sprite);
|
2021-04-11 22:23:10 +02:00
|
|
|
sprite->sState = 1;
|
|
|
|
sprite->sTimer = 0;
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-11 22:23:10 +02:00
|
|
|
if (++sprite->sTimer > 11)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
|
2021-04-11 22:23:10 +02:00
|
|
|
sprite->sState = 0;
|
|
|
|
sprite->sTimer = 0;
|
2017-12-16 00:08:23 +01:00
|
|
|
FreeOamMatrix(sprite->oam.matrixNum);
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void FadePaletteAndSetTaskToClosePokeblockCase(u8 taskId)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2017-12-16 00:08:23 +01:00
|
|
|
gTasks[taskId].func = Task_FreeDataAndExitPokeblockCase;
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void Task_FreeDataAndExitPokeblockCase(u8 taskId)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
if (sPokeblockMenu->caseId == PBLOCK_CASE_FEEDER || sPokeblockMenu->caseId == PBLOCK_CASE_GIVE)
|
2019-12-17 09:24:44 +01:00
|
|
|
gFieldCallback = FieldCB_ContinueScriptHandleMusic;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
DestroyListMenuTask(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
|
|
|
DestroyScrollArrows();
|
2017-12-16 00:08:23 +01:00
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
if (sPokeblockMenu->callbackOnUse != NULL)
|
|
|
|
SetMainCallback2(sPokeblockMenu->callbackOnUse);
|
2017-12-16 00:08:23 +01:00
|
|
|
else
|
|
|
|
SetMainCallback2(sSavedPokeblockData.callback);
|
|
|
|
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
Free(sPokeblockMenu);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:10:29 +01:00
|
|
|
static void Task_HandlePokeblockMenuInput(u8 taskId)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
if (!gPaletteFade.active && MenuHelpers_ShouldWaitForLinkRecv() != TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
ListMenuGetScrollAndRow(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
|
|
|
if (sSavedPokeblockData.scrollOffset + sSavedPokeblockData.selectedRow != sPokeblockMenu->itemsNo - 1)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Chose menu item to swap
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockMenuHighlight(sSavedPokeblockData.selectedRow, TILE_HIGHLIGHT_RED);
|
|
|
|
tToSwapId = sSavedPokeblockData.scrollOffset + sSavedPokeblockData.selectedRow;
|
2017-12-16 00:08:23 +01:00
|
|
|
sPokeblockMenu->isSwapping = TRUE;
|
|
|
|
gTasks[taskId].func = Task_HandlePokeblocksSwapInput;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
u16 oldPosition = sSavedPokeblockData.selectedRow;
|
|
|
|
s32 input = ListMenu_ProcessInput(tListTaskId);
|
|
|
|
ListMenuGetScrollAndRow(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (oldPosition != sSavedPokeblockData.selectedRow)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Moved cursor
|
|
|
|
DrawPokeblockMenuHighlight(oldPosition, TILE_HIGHLIGHT_NONE);
|
|
|
|
DrawPokeblockMenuHighlight(sSavedPokeblockData.selectedRow, TILE_HIGHLIGHT_BLUE);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
switch (input)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
case LIST_NOTHING_CHOSEN:
|
|
|
|
break;
|
2019-03-03 08:50:40 +01:00
|
|
|
case LIST_CANCEL:
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-12-05 15:31:01 +01:00
|
|
|
gSpecialVar_Result = 0xFFFF;
|
2017-12-16 00:08:23 +01:00
|
|
|
gSpecialVar_ItemId = 0;
|
|
|
|
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
|
|
|
|
break;
|
|
|
|
default:
|
2021-04-11 22:23:10 +02:00
|
|
|
// Selected Pokéblock
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
gSpecialVar_ItemId = input;
|
|
|
|
ShowPokeblockActionsWindow(taskId);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_HandlePokeblocksSwapInput(u8 taskId)
|
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE)
|
2017-12-16 00:08:23 +01:00
|
|
|
return;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
// Swap items
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
ListMenuGetScrollAndRow(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
|
|
|
UpdatePokeblockSwapMenu(taskId, FALSE);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
u16 i = sSavedPokeblockData.scrollOffset;
|
|
|
|
u16 row = sSavedPokeblockData.selectedRow;
|
|
|
|
s32 input = ListMenu_ProcessInput(tListTaskId);
|
|
|
|
ListMenuGetScrollAndRow(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (i != sSavedPokeblockData.scrollOffset || row != sSavedPokeblockData.selectedRow)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
for (i = 0; i < MAX_MENU_ITEMS; i++)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
row = i + sSavedPokeblockData.scrollOffset;
|
|
|
|
if (row == tToSwapId)
|
|
|
|
DrawPokeblockMenuHighlight(i, TILE_HIGHLIGHT_RED);
|
2017-12-16 00:08:23 +01:00
|
|
|
else
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockMenuHighlight(i, TILE_HIGHLIGHT_NONE);
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
SetSwapLineSpritesInvisibility(sPokeblockMenu->swapLineSpriteIds, ARRAY_COUNT(sPokeblockMenu->swapLineSpriteIds), FALSE);
|
|
|
|
UpdateSwapLineSpritesPos(sPokeblockMenu->swapLineSpriteIds, ARRAY_COUNT(sPokeblockMenu->swapLineSpriteIds), 128, (sSavedPokeblockData.selectedRow * 16) + 8);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
switch (input)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
case LIST_NOTHING_CHOSEN:
|
|
|
|
break;
|
2021-04-11 22:23:10 +02:00
|
|
|
case LIST_CANCEL:
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
if (JOY_NEW(A_BUTTON)) // Pointless check, B Button has been pressed here
|
|
|
|
UpdatePokeblockSwapMenu(taskId, FALSE);
|
2017-12-16 00:08:23 +01:00
|
|
|
else
|
2021-04-11 22:23:10 +02:00
|
|
|
UpdatePokeblockSwapMenu(taskId, TRUE); // Canceled swapping
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
default:
|
2021-04-11 22:23:10 +02:00
|
|
|
// Swap items
|
2017-12-16 00:08:23 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
UpdatePokeblockSwapMenu(taskId, FALSE);
|
2017-12-16 00:08:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void UpdatePokeblockSwapMenu(u8 taskId, bool8 noSwap)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
s16 *data = gTasks[taskId].data;
|
2021-04-11 22:23:10 +02:00
|
|
|
u16 swappedFromId = sSavedPokeblockData.scrollOffset + sSavedPokeblockData.selectedRow;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
|
|
|
sPokeblockMenu->isSwapping = FALSE;
|
2021-04-11 22:23:10 +02:00
|
|
|
DestroyListMenuTask(tListTaskId, &sSavedPokeblockData.scrollOffset, &sSavedPokeblockData.selectedRow);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (!noSwap && tToSwapId != swappedFromId && tToSwapId != swappedFromId - 1)
|
2017-12-16 00:08:23 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
SwapPokeblockMenuItems(tToSwapId, swappedFromId);
|
|
|
|
UpdatePokeblockList();
|
2017-12-16 00:08:23 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (tToSwapId < swappedFromId)
|
|
|
|
sSavedPokeblockData.selectedRow--;
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, sSavedPokeblockData.scrollOffset, sSavedPokeblockData.selectedRow);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2021-04-11 22:23:10 +02:00
|
|
|
SetSwapLineSpritesInvisibility(sPokeblockMenu->swapLineSpriteIds, ARRAY_COUNT(sPokeblockMenu->swapLineSpriteIds), TRUE);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
for (i = 0; i < MAX_MENU_ITEMS; i++)
|
|
|
|
DrawPokeblockMenuHighlight(i, TILE_HIGHLIGHT_NONE);
|
2017-12-16 00:08:23 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
DrawPokeblockMenuHighlight(sSavedPokeblockData.selectedRow, TILE_HIGHLIGHT_BLUE);
|
2017-12-16 00:08:23 +01:00
|
|
|
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
|
|
|
|
}
|
2017-12-16 15:10:29 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void ShowPokeblockActionsWindow(u8 taskId)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
if (sPokeblockMenu->numActions == 3)
|
|
|
|
tWindowId = WIN_ACTIONS_TALL;
|
2017-12-16 15:10:29 +01:00
|
|
|
else
|
2021-04-11 22:23:10 +02:00
|
|
|
tWindowId = WIN_ACTIONS;
|
2017-12-16 15:10:29 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
DestroyScrollArrows();
|
|
|
|
DrawStdFrameWithCustomTileAndPalette(tWindowId, 0, 1, 0xE);
|
2021-11-04 04:20:59 +01:00
|
|
|
PrintMenuActionTextsInUpperLeftCorner(tWindowId, sPokeblockMenu->numActions, sPokeblockMenuActions, sPokeblockMenu->pokeblockActionIds);
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuInUpperLeftCornerNormal(tWindowId, sPokeblockMenu->numActions, 0);
|
2021-04-11 22:23:10 +02:00
|
|
|
PutWindowTilemap(tWindowId);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2017-12-16 15:10:29 +01:00
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
gTasks[taskId].func = Task_HandlePokeblockActionsInput;
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void Task_HandlePokeblockActionsInput(u8 taskId)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
|
|
|
s8 itemId;
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE)
|
2017-12-16 15:10:29 +01:00
|
|
|
return;
|
|
|
|
|
2018-11-05 21:45:54 +01:00
|
|
|
itemId = Menu_ProcessInputNoWrap();
|
2017-12-16 15:10:29 +01:00
|
|
|
if (itemId == MENU_NOTHING_CHOSEN)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (itemId == MENU_B_PRESSED)
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
PokeblockAction_Cancel(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-11 22:23:10 +02:00
|
|
|
sPokeblockMenuActions[sPokeblockMenu->pokeblockActionIds[itemId]].func.void_u8(taskId);
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_UseOnField(u8 taskId)
|
|
|
|
{
|
|
|
|
sPokeblockMenu->callbackOnUse = UsePokeblockOnField;
|
|
|
|
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UsePokeblockOnField(void)
|
|
|
|
{
|
|
|
|
ChooseMonToGivePokeblock(&gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId], ReturnToPokeblockCaseOnField);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReturnToPokeblockCaseOnField(void)
|
|
|
|
{
|
|
|
|
OpenPokeblockCase(PBLOCK_CASE_FIELD, sSavedPokeblockData.callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_Toss(u8 taskId)
|
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(tWindowId, FALSE);
|
2017-12-16 15:10:29 +01:00
|
|
|
StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ThrowAwayVar1);
|
2021-10-30 22:47:37 +02:00
|
|
|
DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, FONT_NORMAL, GetPlayerTextSpeedDelay(), gStringVar4, CreateTossPokeblockYesNoMenu);
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void CreateTossPokeblockYesNoMenu(u8 taskId)
|
|
|
|
{
|
|
|
|
CreateYesNoMenuWithCallbacks(taskId, &sTossPkblockWindowTemplate, 1, 0, 2, 1, 0xE, &sTossYesNoFuncTable);
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void TossedPokeblockMessage(u8 taskId)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_Var1ThrownAway);
|
2021-10-30 22:47:37 +02:00
|
|
|
DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, FONT_NORMAL, GetPlayerTextSpeedDelay(), gStringVar4, TossPokeblock);
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void TossPokeblock(u8 taskId)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
|
|
|
s16 *data;
|
2021-04-11 22:23:10 +02:00
|
|
|
u16 *scrollOffset, *selectedRow;
|
2017-12-16 15:10:29 +01:00
|
|
|
|
|
|
|
TryClearPokeblock(gSpecialVar_ItemId);
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
scrollOffset = &sSavedPokeblockData.scrollOffset;
|
|
|
|
selectedRow = &sSavedPokeblockData.selectedRow;
|
2017-12-16 15:10:29 +01:00
|
|
|
data = gTasks[taskId].data;
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
DestroyListMenuTask(tListTaskId, scrollOffset, selectedRow);
|
|
|
|
DrawPokeblockMenuHighlight(*selectedRow, TILE_HIGHLIGHT_NONE);
|
2017-12-16 15:10:29 +01:00
|
|
|
SetMenuItemsCountAndMaxShowed();
|
2021-04-11 22:23:10 +02:00
|
|
|
LimitMenuScrollAndRow();
|
|
|
|
UpdatePokeblockList();
|
|
|
|
tListTaskId = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow);
|
|
|
|
DrawPokeblockMenuHighlight(*selectedRow, TILE_HIGHLIGHT_BLUE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2021-04-11 22:23:10 +02:00
|
|
|
CloseTossPokeblockWindow(taskId);
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
static void CloseTossPokeblockWindow(u8 taskId)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
2021-04-11 22:23:10 +02:00
|
|
|
ClearDialogWindowAndFrameToTransparent(WIN_TOSS_MSG, FALSE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2021-04-11 22:23:10 +02:00
|
|
|
CreateScrollArrows();
|
2017-12-16 15:10:29 +01:00
|
|
|
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_UseInBattle(u8 taskId)
|
|
|
|
{
|
|
|
|
u8 nature = GetNature(&gEnemyParty[0]);
|
|
|
|
s16 gain = PokeblockGetGain(nature, &gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId]);
|
|
|
|
StringCopy(gBattleTextBuff1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
|
|
|
|
TryClearPokeblock(gSpecialVar_ItemId);
|
|
|
|
|
|
|
|
gSpecialVar_ItemId = gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color << 8;
|
|
|
|
if (gain == 0)
|
|
|
|
gSpecialVar_ItemId += 1;
|
|
|
|
else if (gain > 0)
|
|
|
|
gSpecialVar_ItemId += 2;
|
|
|
|
else
|
|
|
|
gSpecialVar_ItemId += 3;
|
|
|
|
|
|
|
|
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_UseOnPokeblockFeeder(u8 taskId)
|
|
|
|
{
|
|
|
|
SafariZoneActivatePokeblockFeeder(gSpecialVar_ItemId);
|
|
|
|
StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
|
|
|
|
gSpecialVar_Result = gSpecialVar_ItemId;
|
|
|
|
TryClearPokeblock(gSpecialVar_ItemId);
|
|
|
|
gSpecialVar_ItemId = 0;
|
|
|
|
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_GiveToContestLady(u8 taskId)
|
|
|
|
{
|
|
|
|
gSpecialVar_0x8004 = GivePokeblockToContestLady(&gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId]);
|
|
|
|
gSpecialVar_Result = gSpecialVar_ItemId;
|
|
|
|
TryClearPokeblock(gSpecialVar_ItemId);
|
|
|
|
gSpecialVar_ItemId = 0;
|
|
|
|
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PokeblockAction_Cancel(u8 taskId)
|
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2021-04-11 22:23:10 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(tWindowId, FALSE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2021-04-11 22:23:10 +02:00
|
|
|
CreateScrollArrows();
|
2017-12-16 15:10:29 +01:00
|
|
|
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ClearPokeblock(u8 pkblId)
|
|
|
|
{
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].color = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].spicy = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].dry = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].sweet = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].bitter = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].sour = 0;
|
|
|
|
gSaveBlock1Ptr->pokeblocks[pkblId].feel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearPokeblocks(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < POKEBLOCKS_COUNT; i++)
|
|
|
|
ClearPokeblock(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetHighestPokeblocksFlavorLevel(const struct Pokeblock *pokeblock)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 maxFlavor = GetPokeblockData(pokeblock, PBLOCK_SPICY);
|
|
|
|
|
|
|
|
for (i = PBLOCK_SPICY; i < FLAVOR_COUNT; i++)
|
|
|
|
{
|
|
|
|
u8 currFlavor = GetPokeblockData(pokeblock, PBLOCK_SPICY + i);
|
|
|
|
if (maxFlavor < currFlavor)
|
|
|
|
maxFlavor = currFlavor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxFlavor;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetPokeblocksFeel(const struct Pokeblock *pokeblock)
|
|
|
|
{
|
|
|
|
u8 feel = GetPokeblockData(pokeblock, PBLOCK_FEEL);
|
|
|
|
if (feel > POKEBLOCK_MAX_FEEL)
|
|
|
|
feel = POKEBLOCK_MAX_FEEL;
|
|
|
|
|
|
|
|
return feel;
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 GetFirstFreePokeblockSlot(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < POKEBLOCKS_COUNT; i++)
|
|
|
|
{
|
2020-08-24 20:52:33 +02:00
|
|
|
if (gSaveBlock1Ptr->pokeblocks[i].color == PBLOCK_CLR_NONE)
|
2017-12-16 15:10:29 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 AddPokeblock(const struct Pokeblock *pokeblock)
|
|
|
|
{
|
|
|
|
s8 slot = GetFirstFreePokeblockSlot();
|
|
|
|
|
|
|
|
if (slot == -1)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSaveBlock1Ptr->pokeblocks[slot] = *pokeblock;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 TryClearPokeblock(u8 pkblId)
|
|
|
|
{
|
2020-08-24 20:52:33 +02:00
|
|
|
if (gSaveBlock1Ptr->pokeblocks[pkblId].color == PBLOCK_CLR_NONE)
|
2017-12-16 15:10:29 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ClearPokeblock(pkblId);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 field)
|
|
|
|
{
|
|
|
|
if (field == PBLOCK_COLOR)
|
|
|
|
return pokeblock->color;
|
|
|
|
if (field == PBLOCK_SPICY)
|
|
|
|
return pokeblock->spicy;
|
|
|
|
if (field == PBLOCK_DRY)
|
|
|
|
return pokeblock->dry;
|
|
|
|
if (field == PBLOCK_SWEET)
|
|
|
|
return pokeblock->sweet;
|
|
|
|
if (field == PBLOCK_BITTER)
|
|
|
|
return pokeblock->bitter;
|
|
|
|
if (field == PBLOCK_SOUR)
|
|
|
|
return pokeblock->sour;
|
|
|
|
if (field == PBLOCK_FEEL)
|
|
|
|
return pokeblock->feel;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock)
|
|
|
|
{
|
|
|
|
u8 flavor;
|
|
|
|
s16 curGain, totalGain = 0;
|
|
|
|
|
|
|
|
for (flavor = 0; flavor < FLAVOR_COUNT; flavor++)
|
|
|
|
{
|
|
|
|
curGain = GetPokeblockData(pokeblock, flavor + PBLOCK_SPICY);
|
|
|
|
if (curGain > 0)
|
2020-07-17 02:12:12 +02:00
|
|
|
totalGain += curGain * gPokeblockFlavorCompatibilityTable[FLAVOR_COUNT * nature + flavor];
|
2017-12-16 15:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return totalGain;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PokeblockCopyName(const struct Pokeblock *pokeblock, u8 *dest)
|
|
|
|
{
|
|
|
|
u8 color = GetPokeblockData(pokeblock, PBLOCK_COLOR);
|
|
|
|
StringCopy(dest, gPokeblockNames[color]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 CopyMonFavoritePokeblockName(u8 nature, u8 *dest)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (PokeblockGetGain(nature, &sFavoritePokeblocksTable[i]) > 0)
|
|
|
|
{
|
|
|
|
StringCopy(dest, gPokeblockNames[i + 1]);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetPokeblocksFlavor(const struct Pokeblock *pokeblock)
|
|
|
|
{
|
|
|
|
s16 bestFlavor = 0;
|
|
|
|
s16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (GetPokeblockData(pokeblock, bestFlavor + 1) < GetPokeblockData(pokeblock, i + 1))
|
|
|
|
bestFlavor = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bestFlavor;
|
|
|
|
}
|