2017-10-23 00:55:07 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "decompress.h"
|
|
|
|
#include "decoration.h"
|
|
|
|
#include "decoration_inventory.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "event_object_movement.h"
|
|
|
|
#include "event_scripts.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
#include "field_camera.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "field_player_avatar.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "field_weather.h"
|
|
|
|
#include "fieldmap.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
#include "international_string_util.h"
|
|
|
|
#include "item_icon.h"
|
2020-01-08 11:43:06 +01:00
|
|
|
#include "item_menu.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
#include "list_menu.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "main.h"
|
2018-02-07 07:07:42 +01:00
|
|
|
#include "menu.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "metatile_behavior.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
#include "player_pc.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "script.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
#include "secret_base.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "sound.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
#include "tilesets.h"
|
|
|
|
#include "trader.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "tv.h"
|
|
|
|
#include "constants/decorations.h"
|
2018-06-12 02:11:48 +02:00
|
|
|
#include "constants/event_objects.h"
|
2019-04-06 19:41:55 +02:00
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "constants/region_map_sections.h"
|
2019-06-12 02:57:42 +02:00
|
|
|
#include "constants/metatile_labels.h"
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
#define PLACE_DECORATION_SELECTOR_TAG 0xbe5
|
|
|
|
#define PLACE_DECORATION_PLAYER_TAG 0x008
|
2022-01-09 07:31:42 +01:00
|
|
|
#define NUM_DECORATION_FLAGS (FLAG_DECORATION_14 - FLAG_DECORATION_1 + 1)
|
2017-10-23 01:05:32 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
#define tCursorX data[0]
|
|
|
|
#define tCursorY data[1]
|
|
|
|
#define tState data[2]
|
|
|
|
#define tInitialX data[3]
|
|
|
|
#define tInitialY data[4]
|
|
|
|
#define tDecorWidth data[5]
|
|
|
|
#define tDecorHeight data[6]
|
|
|
|
#define tButton data[10]
|
|
|
|
#define tDecorationMenuCommand data[11]
|
|
|
|
#define tDecorationItemsMenuCommand data[12]
|
|
|
|
#define tMenuTaskId data[13]
|
|
|
|
|
|
|
|
#define DECOR_MENU_PLACE 0
|
|
|
|
#define DECOR_MENU_TOSS 1
|
|
|
|
#define DECOR_MENU_TRADE 2
|
|
|
|
|
|
|
|
#define DECOR_ITEMS_MENU_PLACE 0
|
|
|
|
#define DECOR_ITEMS_MENU_PUT_AWAY 1
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
struct DecorationItemsMenu
|
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
struct ListMenuItem items[41];
|
|
|
|
u8 names[41][24];
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 numMenuItems;
|
|
|
|
u8 maxShownItems;
|
|
|
|
u8 scrollIndicatorsTaskId;
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
struct PlaceDecorationGraphicsDataBuffer
|
|
|
|
{
|
|
|
|
const struct Decoration *decoration;
|
|
|
|
u16 tiles[0x40];
|
|
|
|
u8 image[0x800];
|
|
|
|
u16 palette[16];
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
struct DecorRearrangementDataBuffer
|
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
u8 idx;
|
|
|
|
u8 width;
|
|
|
|
u8 height;
|
|
|
|
u16 flagId;
|
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
struct DecorationPCContext
|
|
|
|
{
|
|
|
|
u8 *items;
|
|
|
|
u8 *pos;
|
|
|
|
u8 size;
|
|
|
|
u8 isPlayerRoom;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Windows
|
|
|
|
{
|
|
|
|
WINDOW_MAIN_MENU,
|
|
|
|
WINDOW_DECORATION_CATEGORIES,
|
|
|
|
WINDOW_DECORATION_CATEGORY_SUMMARY,
|
|
|
|
WINDOW_DECORATION_CATEGORY_ITEMS,
|
|
|
|
WINDOW_COUNT
|
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
EWRAM_DATA u8 *gCurDecorationItems = NULL;
|
|
|
|
EWRAM_DATA static u8 sDecorationActionsCursorPos = 0;
|
|
|
|
EWRAM_DATA static u8 sNumOwnedDecorationsInCurCategory = 0;
|
2019-09-06 08:12:00 +02:00
|
|
|
EWRAM_DATA static u8 sSecretBaseItemsIndicesBuffer[DECOR_MAX_SECRET_BASE] = {};
|
|
|
|
EWRAM_DATA static u8 sPlayerRoomItemsIndicesBuffer[DECOR_MAX_PLAYERS_HOUSE] = {};
|
2019-04-06 19:41:55 +02:00
|
|
|
EWRAM_DATA static u16 sDecorationsCursorPos = 0;
|
|
|
|
EWRAM_DATA static u16 sDecorationsScrollOffset = 0;
|
2017-10-23 02:13:31 +02:00
|
|
|
EWRAM_DATA u8 gCurDecorationIndex = 0;
|
2017-11-15 22:12:18 +01:00
|
|
|
EWRAM_DATA static u8 sCurDecorationCategory = DECORCAT_DESK;
|
2021-01-19 23:50:52 +01:00
|
|
|
EWRAM_DATA static u32 sFiller[2] = {};
|
2020-02-23 16:46:22 +01:00
|
|
|
EWRAM_DATA static struct DecorationPCContext sDecorationContext = {};
|
|
|
|
EWRAM_DATA static u8 sDecorMenuWindowIds[WINDOW_COUNT] = {};
|
2019-04-06 19:41:55 +02:00
|
|
|
EWRAM_DATA static struct DecorationItemsMenu *sDecorationItemsMenu = NULL;
|
2020-02-23 16:46:22 +01:00
|
|
|
EWRAM_DATA static struct PlaceDecorationGraphicsDataBuffer sPlaceDecorationGraphicsDataBuffer = {};
|
2017-11-15 22:12:18 +01:00
|
|
|
EWRAM_DATA static u16 sCurDecorMapX = 0;
|
|
|
|
EWRAM_DATA static u16 sCurDecorMapY = 0;
|
|
|
|
EWRAM_DATA static u8 sDecor_CameraSpriteObjectIdx1 = 0;
|
|
|
|
EWRAM_DATA static u8 sDecor_CameraSpriteObjectIdx2 = 0;
|
|
|
|
EWRAM_DATA static u8 sDecorationLastDirectionMoved = 0;
|
|
|
|
EWRAM_DATA static struct OamData sDecorSelectorOam = {};
|
2019-09-06 08:12:00 +02:00
|
|
|
EWRAM_DATA static struct DecorRearrangementDataBuffer sDecorRearrangementDataBuffer[DECOR_MAX_SECRET_BASE] = {};
|
2017-11-15 22:12:18 +01:00
|
|
|
EWRAM_DATA static u8 sCurDecorSelectedInRearrangement = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void HandleDecorationActionsMenuInput(u8 taskId);
|
|
|
|
static void PrintCurMainMenuDescription(void);
|
|
|
|
static void DecorationMenuAction_Decorate(u8 taskId);
|
|
|
|
static void DecorationMenuAction_PutAway(u8 taskId);
|
|
|
|
static void DecorationMenuAction_Toss(u8 taskId);
|
|
|
|
static void DecorationMenuAction_Cancel(u8 taskId);
|
|
|
|
static void ReturnToDecorationActionsAfterInvalidSelection(u8 taskId);
|
|
|
|
static void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId);
|
|
|
|
static void InitDecorationCategoriesWindow(u8 taskId);
|
|
|
|
static void PrintDecorationCategoryMenuItems(u8 taskId);
|
|
|
|
static void PrintDecorationCategoryMenuItem(u8 winid, u8 category, u8 x, u8 y, bool8 disabled, u8 speed);
|
|
|
|
static void ColorMenuItemString(u8 *str, bool8 disabled);
|
|
|
|
static void HandleDecorationCategoriesMenuInput(u8 taskId);
|
|
|
|
static void SelectDecorationCategory(u8 taskId);
|
|
|
|
static void ReturnToDecorationCategoriesAfterInvalidSelection(u8 taskId);
|
|
|
|
static void ExitDecorationCategoriesMenu(u8 taskId);
|
|
|
|
static void ReturnToActionsMenuFromCategories(u8 taskId);
|
|
|
|
static void ExitTraderDecorationMenu(u8 taskId);
|
|
|
|
static void CopyDecorationMenuItemName(u8 *dest, u16 decoration);
|
|
|
|
static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct ListMenu *menu);
|
2021-06-18 06:15:45 +02:00
|
|
|
static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y);
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ShowDecorationItemsWindow(u8 taskId);
|
|
|
|
static void HandleDecorationItemsMenuInput(u8 taskId);
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PrintDecorationItemDescription(s32 itemIndex);
|
2019-04-06 19:41:55 +02:00
|
|
|
static void RemoveDecorationItemsOtherWindows(void);
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 IsDecorationIndexInSecretBase(u8 idx);
|
|
|
|
static bool8 IsDecorationIndexInPlayersRoom(u8 idx);
|
2019-04-06 19:41:55 +02:00
|
|
|
static void IdentifyOwnedDecorationsCurrentlyInUse(u8 taskId);
|
|
|
|
static void InitDecorationItemsWindow(u8 taskId);
|
|
|
|
static void ShowDecorationCategorySummaryWindow(u8 category);
|
2020-02-23 16:46:22 +01:00
|
|
|
static void DontTossDecoration(u8 taskId);
|
|
|
|
static void DecorationItemsMenuAction_Cancel(u8 taskId);
|
|
|
|
static void DecorationItemsMenuAction_AttemptPlace(u8 taskId);
|
|
|
|
static void Task_PlaceDecoration(u8 taskId);
|
|
|
|
static void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor);
|
|
|
|
static void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data);
|
|
|
|
static void SetUpDecorationShape(u8 taskId);
|
|
|
|
static void AttemptPlaceDecoration(u8 taskId);
|
|
|
|
static void AttemptCancelPlaceDecoration(u8 taskId);
|
|
|
|
static void AttemptPlaceDecoration_(u8 taskId);
|
|
|
|
static void PlaceDecorationPrompt(u8 taskId);
|
|
|
|
static void PlaceDecoration(u8 taskId);
|
|
|
|
static void PlaceDecoration_(u8 taskId);
|
|
|
|
static void CancelDecoratingPrompt(u8 taskId);
|
|
|
|
static void CancelDecorating(u8 taskId);
|
|
|
|
static void CancelDecorating_(u8 taskId);
|
|
|
|
static void c1_overworld_prev_quest(u8 taskId);
|
|
|
|
static void FieldCB_InitDecorationItemsWindow(void);
|
|
|
|
static void ResetCursorMovement(void);
|
|
|
|
static void ContinueDecorating(u8 taskId);
|
|
|
|
static void CantPlaceDecorationPrompt(u8 taskId);
|
|
|
|
static void InitializePuttingAwayCursorSprite(struct Sprite *sprite);
|
|
|
|
static void InitializePuttingAwayCursorSprite2(struct Sprite *sprite);
|
|
|
|
static u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor);
|
|
|
|
static const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode);
|
|
|
|
static bool8 HasDecorationsInUse(u8 taskId);
|
|
|
|
static void Task_ContinuePuttingAwayDecorations(u8 taskId);
|
|
|
|
static void ContinuePuttingAwayDecorations(u8 taskId);
|
|
|
|
static void AttemptPutAwayDecoration(u8 taskId);
|
|
|
|
static void AttemptCancelPutAwayDecoration(u8 taskId);
|
|
|
|
static void AttemptPutAwayDecoration_(u8 taskId);
|
|
|
|
static void ContinuePuttingAwayDecorationsPrompt(u8 taskId);
|
|
|
|
static void AttemptMarkDecorUnderCursorForRemoval(u8 taskId);
|
|
|
|
static void ReturnDecorationPrompt(u8 taskId);
|
|
|
|
static void PutAwayDecoration(u8 taskId);
|
|
|
|
static void StopPuttingAwayDecorationsPrompt(u8 taskId);
|
|
|
|
static void StopPuttingAwayDecorations(u8 taskId);
|
|
|
|
static void StopPuttingAwayDecorations_(u8 taskId);
|
|
|
|
static void Task_StopPuttingAwayDecorations(u8 taskId);
|
|
|
|
static void FieldCB_StopPuttingAwayDecorations(void);
|
|
|
|
static void InitializeCameraSprite1(struct Sprite *sprite);
|
|
|
|
static void LoadPlayerSpritePalette(void);
|
|
|
|
static void FreePlayerSpritePalette(void);
|
|
|
|
static void DecorationItemsMenuAction_AttemptToss(u8 taskId);
|
|
|
|
static void TossDecorationPrompt(u8 taskId);
|
|
|
|
static void TossDecoration(u8 taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
|
|
|
|
#include "data/decoration/tiles.h"
|
|
|
|
#include "data/decoration/description.h"
|
|
|
|
#include "data/decoration/header.h"
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const u8 *const sDecorationCategoryNames[] =
|
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
gText_Desk,
|
|
|
|
gText_Chair,
|
|
|
|
gText_Plant,
|
|
|
|
gText_Ornament,
|
|
|
|
gText_Mat,
|
|
|
|
gText_Poster,
|
|
|
|
gText_Doll,
|
|
|
|
gText_Cushion
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const struct MenuAction sDecorationMainMenuActions[] =
|
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
.text = gText_Decorate,
|
|
|
|
.func = { .void_u8 = DecorationMenuAction_Decorate },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.text = gText_PutAway,
|
|
|
|
.func = { .void_u8 = DecorationMenuAction_PutAway },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.text = gText_Toss2,
|
|
|
|
.func = { .void_u8 = DecorationMenuAction_Toss },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.text = gText_Cancel,
|
|
|
|
.func = { .void_u8 = DecorationMenuAction_Cancel },
|
|
|
|
},
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const u8 *const sSecretBasePCMenuItemDescriptions[] =
|
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
gText_PutOutSelectedDecorItem,
|
|
|
|
gText_StoreChosenDecorInPC,
|
|
|
|
gText_ThrowAwayUnwantedDecors,
|
2017-10-23 00:55:07 +02:00
|
|
|
gText_GoBackPrevMenu
|
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const TaskFunc sSecretBasePC_SelectedDecorationActions[][2] =
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
{ DecorationItemsMenuAction_AttemptPlace, DecorationItemsMenuAction_Cancel },
|
|
|
|
{ DecorationItemsMenuAction_AttemptToss, DecorationItemsMenuAction_Cancel },
|
|
|
|
{ DecorationItemsMenuAction_Trade, DecorationItemsMenuAction_Cancel },
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct WindowTemplate sDecorationWindowTemplates[WINDOW_COUNT] =
|
2018-09-02 18:53:52 +02:00
|
|
|
{
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 18,
|
2020-02-23 16:46:22 +01:00
|
|
|
.height = 2 * ARRAY_COUNT(sDecorationMainMenuActions),
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 15,
|
2018-09-02 18:53:52 +02:00
|
|
|
.baseBlock = 0x0001
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 13,
|
|
|
|
.height = 18,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 13,
|
2018-09-02 18:53:52 +02:00
|
|
|
.baseBlock = 0x0091
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 17,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 12,
|
|
|
|
.height = 2,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 15,
|
2018-09-02 18:53:52 +02:00
|
|
|
.baseBlock = 0x017b
|
|
|
|
},
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 16,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 13,
|
|
|
|
.height = 6,
|
2022-08-19 17:32:00 +02:00
|
|
|
.paletteNum = 15,
|
2018-09-02 18:53:52 +02:00
|
|
|
.baseBlock = 0x0193
|
|
|
|
}
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const u16 sDecorationMenuPalette[] = INCBIN_U16("graphics/decorations/decoration_menu.gbapal");
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const struct ListMenuTemplate sDecorationItemsListMenuTemplate =
|
2018-09-02 18:53:52 +02:00
|
|
|
{
|
|
|
|
.items = NULL,
|
2019-04-06 19:41:55 +02:00
|
|
|
.moveCursorFunc = DecorationItemsMenu_OnCursorMove,
|
2020-02-23 16:46:22 +01:00
|
|
|
.itemPrintFunc = DecorationItemsMenu_PrintDecorationInUse,
|
2018-09-02 18:53:52 +02:00
|
|
|
.totalItems = 0,
|
|
|
|
.maxShowed = 0,
|
|
|
|
.windowId = 0,
|
|
|
|
.header_X = 0,
|
|
|
|
.item_X = 8,
|
|
|
|
.cursor_X = 0,
|
|
|
|
.upText_Y = 9,
|
|
|
|
.cursorPal = 2,
|
|
|
|
.fillValue = 1,
|
|
|
|
.cursorShadowPal = 3,
|
|
|
|
.lettersSpacing = FALSE,
|
|
|
|
.itemVerticalPadding = 0,
|
2022-11-09 21:37:47 +01:00
|
|
|
.scrollMultiple = LIST_NO_MULTIPLE_SCROLL,
|
|
|
|
.fontId = FONT_NARROW,
|
|
|
|
.cursorKind = CURSOR_BLACK_ARROW,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#include "data/decoration/icon.h"
|
|
|
|
#include "data/decoration/tilemaps.h"
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const struct {
|
2017-10-23 00:55:07 +02:00
|
|
|
u8 shape;
|
|
|
|
u8 size;
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 cameraX;
|
|
|
|
u8 cameraY;
|
|
|
|
} sDecorationMovementInfo[] =
|
|
|
|
{
|
|
|
|
[DECORSHAPE_1x1] = {SPRITE_SHAPE(16x16), SPRITE_SIZE(16x16), 120, 78},
|
|
|
|
[DECORSHAPE_2x1] = {SPRITE_SHAPE(32x16), SPRITE_SIZE(32x16), 128, 78},
|
|
|
|
[DECORSHAPE_3x1] = {SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), 144, 86},
|
|
|
|
[DECORSHAPE_4x2] = {SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), 144, 70},
|
|
|
|
[DECORSHAPE_2x2] = {SPRITE_SHAPE(32x32), SPRITE_SIZE(32x32), 128, 70},
|
|
|
|
[DECORSHAPE_1x2] = {SPRITE_SHAPE(16x32), SPRITE_SIZE(16x32), 120, 70},
|
|
|
|
[DECORSHAPE_1x3] = {SPRITE_SHAPE(32x64), SPRITE_SIZE(32x64), 128, 86},
|
|
|
|
[DECORSHAPE_2x4] = {SPRITE_SHAPE(32x64), SPRITE_SIZE(32x64), 128, 54},
|
|
|
|
[DECORSHAPE_3x3] = {SPRITE_SHAPE(64x64), SPRITE_SIZE(64x64), 144, 70},
|
|
|
|
[DECORSHAPE_3x2] = {SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), 144, 70},
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const union AnimCmd sDecorSelectorAnimCmd0[] =
|
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
ANIMCMD_FRAME(0, 0, FALSE, FALSE),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const union AnimCmd *const sDecorSelectorAnimCmds[] = { sDecorSelectorAnimCmd0 };
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const struct SpriteFrameImage sDecorSelectorSpriteFrameImages =
|
|
|
|
{
|
|
|
|
.data = (const u8 *)&sPlaceDecorationGraphicsDataBuffer.image,
|
|
|
|
.size = 0x800,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const struct SpriteTemplate sDecorationSelectorSpriteTemplate =
|
|
|
|
{
|
2021-09-14 19:14:14 +02:00
|
|
|
TAG_NONE,
|
2019-04-06 19:41:55 +02:00
|
|
|
PLACE_DECORATION_SELECTOR_TAG,
|
2017-10-23 02:13:31 +02:00
|
|
|
&sDecorSelectorOam,
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorSelectorAnimCmds,
|
2017-10-23 02:13:31 +02:00
|
|
|
&sDecorSelectorSpriteFrameImages,
|
2017-10-23 00:55:07 +02:00
|
|
|
gDummySpriteAffineAnimTable,
|
|
|
|
SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpriteTemplate sDecorWhilePlacingSpriteTemplate =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
0x0000,
|
|
|
|
0x0000,
|
2017-10-23 02:13:31 +02:00
|
|
|
&sDecorSelectorOam,
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorSelectorAnimCmds,
|
2017-10-23 00:55:07 +02:00
|
|
|
NULL,
|
|
|
|
gDummySpriteAffineAnimTable,
|
|
|
|
SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpritePalette sSpritePal_PlaceDecoration =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
|
|
|
.data = (const u16 *)&sPlaceDecorationGraphicsDataBuffer.palette,
|
|
|
|
.tag = PLACE_DECORATION_SELECTOR_TAG,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sPlaceDecorationYesNoFunctions =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
.yesFunc = PlaceDecoration,
|
|
|
|
.noFunc = ContinueDecorating,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sCancelDecoratingYesNoFunctions =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
.yesFunc = CancelDecorating,
|
|
|
|
.noFunc = ContinueDecorating,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sPlacePutAwayYesNoFunctions[] =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
.yesFunc = AttemptPlaceDecoration,
|
|
|
|
.noFunc = AttemptCancelPlaceDecoration,
|
2019-04-06 19:41:55 +02:00
|
|
|
},
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
.yesFunc = AttemptPutAwayDecoration,
|
|
|
|
.noFunc = AttemptCancelPutAwayDecoration,
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const u8 sDecorationStandElevations[] =
|
|
|
|
{
|
|
|
|
4, 4, 4, 4,
|
|
|
|
0, 3, 3, 0
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static const u8 sDecorationSlideElevation[] =
|
|
|
|
{
|
|
|
|
4, 4,
|
|
|
|
4, 4,
|
|
|
|
0, 4,
|
|
|
|
3, 0,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const u16 sDecorShapeSizes[] = {
|
2017-10-23 00:55:07 +02:00
|
|
|
0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x20
|
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const u16 sBrendanPalette[] = INCBIN_U16("graphics/decorations/brendan.gbapal");
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const u16 sMayPalette[] = INCBIN_U16("graphics/decorations/may.gbapal");
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sReturnDecorationYesNoFunctions =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
.yesFunc = PutAwayDecoration,
|
|
|
|
.noFunc = ContinuePuttingAwayDecorations,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sStopPuttingAwayDecorationsYesNoFunctions =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
.yesFunc = StopPuttingAwayDecorations,
|
|
|
|
.noFunc = ContinuePuttingAwayDecorations,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2022-01-14 18:29:30 +01:00
|
|
|
static const u8 sDecorationPuttingAwayCursor[] = INCBIN_U8("graphics/decorations/put_away_cursor.4bpp");
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpritePalette sSpritePal_PuttingAwayCursorBrendan =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
.data = sBrendanPalette,
|
2019-04-06 19:41:55 +02:00
|
|
|
.tag = PLACE_DECORATION_PLAYER_TAG,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpritePalette sSpritePal_PuttingAwayCursorMay =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
.data = sMayPalette,
|
2019-04-06 19:41:55 +02:00
|
|
|
.tag = PLACE_DECORATION_PLAYER_TAG,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct OamData sPuttingAwayCursorOamData =
|
2019-04-02 00:31:10 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(16x16),
|
2019-04-02 00:31:10 +02:00
|
|
|
.x = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(16x16),
|
2019-04-02 00:31:10 +02:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const union AnimCmd sPuttingAwayCursorAnimCmd0[] =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2017-10-23 00:55:07 +02:00
|
|
|
ANIMCMD_FRAME(0, 0, 0),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const union AnimCmd *const sPuttingAwayCursorAnimCmds[] =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sPuttingAwayCursorAnimCmd0,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpriteFrameImage sPuttingAwayCursorPicTable =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
.data = sDecorationPuttingAwayCursor,
|
|
|
|
.size = sizeof(sDecorationPuttingAwayCursor),
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct SpriteTemplate sPuttingAwayCursorSpriteTemplate =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2021-09-14 19:14:14 +02:00
|
|
|
TAG_NONE,
|
2019-04-06 19:41:55 +02:00
|
|
|
PLACE_DECORATION_PLAYER_TAG,
|
2020-02-23 16:46:22 +01:00
|
|
|
&sPuttingAwayCursorOamData,
|
|
|
|
sPuttingAwayCursorAnimCmds,
|
|
|
|
&sPuttingAwayCursorPicTable,
|
2017-10-23 00:55:07 +02:00
|
|
|
gDummySpriteAffineAnimTable,
|
2020-02-23 16:46:22 +01:00
|
|
|
InitializeCameraSprite1
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const struct YesNoFuncTable sTossDecorationYesNoFunctions =
|
2019-04-06 19:41:55 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
.yesFunc = TossDecoration,
|
2020-02-23 16:46:22 +01:00
|
|
|
.noFunc = DontTossDecoration,
|
2017-10-23 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void InitDecorationContextItems(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (sCurDecorationCategory < DECORCAT_COUNT)
|
|
|
|
gCurDecorationItems = gDecorationInventories[sCurDecorationCategory].items;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.isPlayerRoom == FALSE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations;
|
|
|
|
sDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.isPlayerRoom == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items = gSaveBlock1Ptr->playerRoomDecorations;
|
|
|
|
sDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorationPositions;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static u8 AddDecorationWindow(u8 windowIndex)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 *windowId;
|
2017-10-23 00:55:07 +02:00
|
|
|
struct WindowTemplate template;
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
windowId = &sDecorMenuWindowIds[windowIndex];
|
2020-02-23 16:46:22 +01:00
|
|
|
if (windowIndex == WINDOW_MAIN_MENU)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
template = sDecorationWindowTemplates[WINDOW_MAIN_MENU];
|
2019-04-06 19:41:55 +02:00
|
|
|
template.width = GetMaxWidthInMenuTable(sDecorationMainMenuActions, ARRAY_COUNT(sDecorationMainMenuActions));
|
2017-10-23 00:55:07 +02:00
|
|
|
if (template.width > 18)
|
|
|
|
template.width = 18;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
*windowId = AddWindow(&template);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
*windowId = AddWindow(&sDecorationWindowTemplates[windowIndex]);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
DrawStdFrameWithCustomTileAndPalette(*windowId, FALSE, 0x214, 14);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2019-04-06 19:41:55 +02:00
|
|
|
return *windowId;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void RemoveDecorationWindow(u8 windowIndex)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sDecorMenuWindowIds[windowIndex], FALSE);
|
|
|
|
ClearWindowTilemap(sDecorMenuWindowIds[windowIndex]);
|
|
|
|
RemoveWindow(sDecorMenuWindowIds[windowIndex]);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void AddDecorationActionsWindow(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
u8 windowId = AddDecorationWindow(WINDOW_MAIN_MENU);
|
|
|
|
PrintMenuTable(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationMainMenuActions);
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuInUpperLeftCornerNormal(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationActionsCursorPos);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void InitDecorationActionsWindow(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorationActionsCursorPos = 0;
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2019-04-06 19:41:55 +02:00
|
|
|
AddDecorationActionsWindow();
|
|
|
|
PrintCurMainMenuDescription();
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void DoSecretBaseDecorationMenu(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationActionsWindow();
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations;
|
|
|
|
sDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions;
|
|
|
|
sDecorationContext.size = DECOR_MAX_SECRET_BASE;
|
|
|
|
sDecorationContext.isPlayerRoom = FALSE;
|
2019-04-06 19:41:55 +02:00
|
|
|
gTasks[taskId].func = HandleDecorationActionsMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void DoPlayerRoomDecorationMenu(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationActionsWindow();
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items = gSaveBlock1Ptr->playerRoomDecorations;
|
|
|
|
sDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorationPositions;
|
|
|
|
sDecorationContext.size = DECOR_MAX_PLAYERS_HOUSE;
|
|
|
|
sDecorationContext.isPlayerRoom = TRUE;
|
2019-04-06 19:41:55 +02:00
|
|
|
gTasks[taskId].func = HandleDecorationActionsMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void HandleDecorationActionsMenuInput(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s8 menuPos = Menu_GetCursorPos();
|
2018-11-05 21:45:54 +01:00
|
|
|
switch (Menu_ProcessInput())
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sDecorationMainMenuActions[sDecorationActionsCursorPos].func.void_u8(taskId);
|
|
|
|
break;
|
|
|
|
case MENU_NOTHING_CHOSEN:
|
|
|
|
sDecorationActionsCursorPos = Menu_GetCursorPos();
|
|
|
|
if (menuPos != sDecorationActionsCursorPos)
|
|
|
|
PrintCurMainMenuDescription();
|
|
|
|
break;
|
|
|
|
case MENU_B_PRESSED:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
DecorationMenuAction_Cancel(taskId);
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void PrintCurMainMenuDescription(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2022-07-30 18:41:12 +02:00
|
|
|
AddTextPrinterParameterized2(0, FONT_NORMAL, sSecretBasePCMenuItemDescriptions[sDecorationActionsCursorPos], 0, 0, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void DecorationMenuAction_Decorate(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (GetNumOwnedDecorations() == 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
|
2019-04-06 19:41:55 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationActionsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_PLACE;
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorationCategory = DECORCAT_DESK;
|
|
|
|
SecretBasePC_PrepMenuForSelectingStoredDecors(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void DecorationMenuAction_PutAway(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (!HasDecorationsInUse(taskId))
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoDecorationsInUse);
|
2019-04-06 19:41:55 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationActionsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_MAIN_MENU);
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].func = Task_ContinuePuttingAwayDecorations;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void DecorationMenuAction_Toss(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (GetNumOwnedDecorations() == 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
|
2019-04-06 19:41:55 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationActionsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_TOSS;
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorationCategory = DECORCAT_DESK;
|
|
|
|
SecretBasePC_PrepMenuForSelectingStoredDecors(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void DecorationMenuAction_Cancel(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_MAIN_MENU);
|
|
|
|
if (!sDecorationContext.isPlayerRoom)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-08-15 21:18:12 +02:00
|
|
|
ScriptContext_SetupScript(SecretBase_EventScript_PCCancel);
|
2017-10-23 00:55:07 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-12 09:26:20 +01:00
|
|
|
ReshowPlayerPC(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ReturnToDecorationActionsAfterInvalidSelection(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
PrintCurMainMenuDescription();
|
|
|
|
gTasks[taskId].func = HandleDecorationActionsMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2023-05-23 19:16:18 +02:00
|
|
|
LoadPalette(sDecorationMenuPalette, BG_PLTT_ID(13), sizeof(sDecorationMenuPalette));
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_MAIN_MENU);
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationCategoriesWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void InitDecorationCategoriesWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
u8 windowId = AddDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
PrintDecorationCategoryMenuItems(taskId);
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuInUpperLeftCornerNormal(windowId, DECORCAT_COUNT + 1, sCurDecorationCategory);
|
2019-04-06 19:41:55 +02:00
|
|
|
gTasks[taskId].func = HandleDecorationCategoriesMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ReinitDecorationCategoriesWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
FillWindowPixelBuffer(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], PIXEL_FILL(1));
|
2019-04-06 19:41:55 +02:00
|
|
|
PrintDecorationCategoryMenuItems(taskId);
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuInUpperLeftCornerNormal(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], DECORCAT_COUNT + 1, sCurDecorationCategory);
|
2019-04-06 19:41:55 +02:00
|
|
|
gTasks[taskId].func = HandleDecorationCategoriesMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void PrintDecorationCategoryMenuItems(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
u8 windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES];
|
|
|
|
bool8 isPlayerRoom = sDecorationContext.isPlayerRoom;
|
2019-04-06 19:41:55 +02:00
|
|
|
bool8 shouldDisable = FALSE;
|
2020-02-23 16:46:22 +01:00
|
|
|
if (isPlayerRoom == TRUE && tDecorationMenuCommand == DECOR_MENU_PLACE)
|
2019-04-06 19:41:55 +02:00
|
|
|
shouldDisable = TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < DECORCAT_COUNT; i++)
|
|
|
|
{
|
|
|
|
// Only DOLL and CUSHION decorations are enabled when decorating the player's room.
|
|
|
|
if (shouldDisable == TRUE && i != DECORCAT_DOLL && i != DECORCAT_CUSHION)
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, TRUE, TEXT_SKIP_DRAW);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2021-11-03 23:29:18 +01:00
|
|
|
PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, FALSE, TEXT_SKIP_DRAW);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized(windowId, FONT_NORMAL, gTasks[taskId].tDecorationMenuCommand == DECOR_MENU_TRADE ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void PrintDecorationCategoryMenuItem(u8 winid, u8 category, u8 x, u8 y, bool8 disabled, u8 speed)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 width;
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 *str;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
width = x == 8 ? 104 : 96;
|
|
|
|
y++;
|
|
|
|
ColorMenuItemString(gStringVar4, disabled);
|
|
|
|
str = StringLength(gStringVar4) + gStringVar4;
|
|
|
|
StringCopy(str, sDecorationCategoryNames[category]);
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized(winid, FONT_NORMAL, gStringVar4, x, y, speed, NULL);
|
2019-04-06 19:41:55 +02:00
|
|
|
str = ConvertIntToDecimalStringN(str, GetNumOwnedDecorationsInCategory(category), STR_CONV_MODE_RIGHT_ALIGN, 2);
|
|
|
|
*(str++) = CHAR_SLASH;
|
|
|
|
ConvertIntToDecimalStringN(str, gDecorationInventories[category].size, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
2021-10-30 22:47:37 +02:00
|
|
|
x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, width);
|
|
|
|
AddTextPrinterParameterized(winid, FONT_NORMAL, gStringVar4, x, y, speed, NULL);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ColorMenuItemString(u8 *str, bool8 disabled)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringCopy(str, gText_Color161Shadow161);
|
2019-04-06 19:41:55 +02:00
|
|
|
if (disabled == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
str[2] = 4;
|
|
|
|
str[5] = 5;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
str[2] = 2;
|
|
|
|
str[5] = 3;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void HandleDecorationCategoriesMenuInput(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s8 input = Menu_ProcessInput();
|
2017-10-23 00:55:07 +02:00
|
|
|
switch (input)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case MENU_B_PRESSED:
|
|
|
|
case DECORCAT_COUNT: // CANCEL
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ExitDecorationCategoriesMenu(taskId);
|
|
|
|
break;
|
|
|
|
case MENU_NOTHING_CHOSEN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sCurDecorationCategory = input;
|
|
|
|
SelectDecorationCategory(taskId);
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void SelectDecorationCategory(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sNumOwnedDecorationsInCurCategory = GetNumOwnedDecorationsInCategory(sCurDecorationCategory);
|
|
|
|
if (sNumOwnedDecorationsInCurCategory != 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
CondenseDecorationsInCategory(sCurDecorationCategory);
|
|
|
|
gCurDecorationItems = gDecorationInventories[sCurDecorationCategory].items;
|
2017-10-23 02:13:31 +02:00
|
|
|
IdentifyOwnedDecorationsCurrentlyInUse(taskId);
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorationsScrollOffset = 0;
|
|
|
|
sDecorationsCursorPos = 0;
|
|
|
|
gTasks[taskId].func = ShowDecorationItemsWindow;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
|
2019-04-06 19:41:55 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationCategoriesAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ReturnToDecorationCategoriesAfterInvalidSelection(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationCategoriesWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ExitDecorationCategoriesMenu(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (gTasks[taskId].tDecorationMenuCommand != DECOR_MENU_TRADE)
|
2019-04-06 19:41:55 +02:00
|
|
|
ReturnToActionsMenuFromCategories(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-06 19:41:55 +02:00
|
|
|
ExitTraderDecorationMenu(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ReturnToActionsMenuFromCategories(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
AddDecorationActionsWindow();
|
2022-05-27 02:18:52 +02:00
|
|
|
DrawDialogueFrame(0, FALSE);
|
2019-04-06 19:41:55 +02:00
|
|
|
PrintCurMainMenuDescription();
|
|
|
|
gTasks[taskId].func = HandleDecorationActionsMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void ShowDecorationCategoriesWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2023-05-23 19:16:18 +02:00
|
|
|
LoadPalette(sDecorationMenuPalette, BG_PLTT_ID(13), sizeof(sDecorationMenuPalette));
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_TRADE;
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorationCategory = DECORCAT_DESK;
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationCategoriesWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void CopyDecorationCategoryName(u8 *dest, u8 category)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
StringCopy(dest, sDecorationCategoryNames[category]);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ExitTraderDecorationMenu(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
ExitTraderMenu(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void InitDecorationItemsMenuLimits(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorationItemsMenu->numMenuItems = sNumOwnedDecorationsInCurCategory + 1;
|
|
|
|
if (sDecorationItemsMenu->numMenuItems > 8)
|
|
|
|
sDecorationItemsMenu->maxShownItems = 8;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorationItemsMenu->maxShownItems = sDecorationItemsMenu->numMenuItems;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void InitDecorationItemsMenuScrollAndCursor(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-04-25 18:07:08 +02:00
|
|
|
SetCursorWithinListBounds(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void InitDecorationItemsMenuScrollAndCursor2(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-08-03 08:17:01 +02:00
|
|
|
SetCursorScrollWithinListBounds(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems, 8);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void PrintDecorationItemMenuItems(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
if ((sCurDecorationCategory < DECORCAT_DOLL || sCurDecorationCategory > DECORCAT_CUSHION) && sDecorationContext.isPlayerRoom == TRUE && tDecorationMenuCommand == DECOR_MENU_PLACE)
|
2019-04-06 19:41:55 +02:00
|
|
|
ColorMenuItemString(gStringVar1, TRUE);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-06 19:41:55 +02:00
|
|
|
ColorMenuItemString(gStringVar1, FALSE);
|
|
|
|
|
|
|
|
for (i = 0; i < sDecorationItemsMenu->numMenuItems - 1; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
CopyDecorationMenuItemName(sDecorationItemsMenu->names[i], gCurDecorationItems[i]);
|
|
|
|
sDecorationItemsMenu->items[i].name = sDecorationItemsMenu->names[i];
|
|
|
|
sDecorationItemsMenu->items[i].id = i;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
StringCopy(sDecorationItemsMenu->names[i], gText_Cancel);
|
|
|
|
sDecorationItemsMenu->items[i].name = sDecorationItemsMenu->names[i];
|
2022-11-09 21:37:47 +01:00
|
|
|
sDecorationItemsMenu->items[i].id = LIST_CANCEL;
|
2019-04-06 19:41:55 +02:00
|
|
|
gMultiuseListMenuTemplate = sDecorationItemsListMenuTemplate;
|
2020-02-23 16:46:22 +01:00
|
|
|
gMultiuseListMenuTemplate.windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES];
|
2019-04-06 19:41:55 +02:00
|
|
|
gMultiuseListMenuTemplate.totalItems = sDecorationItemsMenu->numMenuItems;
|
|
|
|
gMultiuseListMenuTemplate.items = sDecorationItemsMenu->items;
|
|
|
|
gMultiuseListMenuTemplate.maxShowed = sDecorationItemsMenu->maxShownItems;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void CopyDecorationMenuItemName(u8 *dest, u16 decoration)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringCopy(dest, gStringVar1);
|
2019-04-06 19:41:55 +02:00
|
|
|
StringAppend(dest, gDecorations[decoration].name);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct ListMenu *menu)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (flag != TRUE)
|
|
|
|
PlaySE(SE_SELECT);
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
PrintDecorationItemDescription(itemIndex);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2021-06-18 06:15:45 +02:00
|
|
|
static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-06-18 06:15:45 +02:00
|
|
|
if (itemIndex != LIST_CANCEL)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (IsDecorationIndexInSecretBase(itemIndex + 1) == TRUE)
|
2020-10-29 21:34:33 +01:00
|
|
|
BlitMenuInfoIcon(windowId, MENU_INFO_ICON_BALL_RED, 92, y + 2);
|
2020-02-23 16:46:22 +01:00
|
|
|
else if (IsDecorationIndexInPlayersRoom(itemIndex + 1) == TRUE)
|
2020-10-29 21:34:33 +01:00
|
|
|
BlitMenuInfoIcon(windowId, MENU_INFO_ICON_BALL_BLUE, 92, y + 2);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void AddDecorationItemsScrollIndicators(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-02-20 05:22:26 +01:00
|
|
|
if (sDecorationItemsMenu->scrollIndicatorsTaskId == TASK_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorationItemsMenu->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
|
|
|
|
SCROLL_ARROW_UP,
|
|
|
|
0x3c,
|
|
|
|
0x0c,
|
|
|
|
0x94,
|
|
|
|
sDecorationItemsMenu->numMenuItems - sDecorationItemsMenu->maxShownItems,
|
|
|
|
0x6e,
|
|
|
|
0x6e,
|
|
|
|
&sDecorationsScrollOffset);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void RemoveDecorationItemsScrollIndicators(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-02-20 05:22:26 +01:00
|
|
|
if (sDecorationItemsMenu->scrollIndicatorsTaskId != TASK_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
RemoveScrollIndicatorArrowPair(sDecorationItemsMenu->scrollIndicatorsTaskId);
|
2021-02-20 05:22:26 +01:00
|
|
|
sDecorationItemsMenu->scrollIndicatorsTaskId = TASK_NONE;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AddDecorationItemsWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
AddDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationItemsWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void InitDecorationItemsWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
AddDecorationWindow(WINDOW_DECORATION_CATEGORY_ITEMS);
|
2019-04-06 19:41:55 +02:00
|
|
|
ShowDecorationCategorySummaryWindow(sCurDecorationCategory);
|
|
|
|
sDecorationItemsMenu = AllocZeroed(sizeof(*sDecorationItemsMenu));
|
2021-02-20 05:22:26 +01:00
|
|
|
sDecorationItemsMenu->scrollIndicatorsTaskId = TASK_NONE;
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationItemsMenuLimits();
|
2020-02-23 16:46:22 +01:00
|
|
|
InitDecorationItemsMenuScrollAndCursor();
|
|
|
|
InitDecorationItemsMenuScrollAndCursor2();
|
2019-04-06 19:41:55 +02:00
|
|
|
PrintDecorationItemMenuItems(taskId);
|
2020-02-23 16:46:22 +01:00
|
|
|
tMenuTaskId = ListMenuInit(&gMultiuseListMenuTemplate, sDecorationsScrollOffset, sDecorationsCursorPos);
|
2019-04-06 19:41:55 +02:00
|
|
|
AddDecorationItemsScrollIndicators();
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ShowDecorationItemsWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationItemsWindow(taskId);
|
|
|
|
gTasks[taskId].func = HandleDecorationItemsMenuInput;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void HandleDecorationItemsMenuInput(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
s32 input;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
input = ListMenu_ProcessInput(tMenuTaskId);
|
|
|
|
ListMenuGetScrollAndRow(tMenuTaskId, &sDecorationsScrollOffset, &sDecorationsCursorPos);
|
2017-10-23 00:55:07 +02:00
|
|
|
switch (input)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case LIST_NOTHING_CHOSEN:
|
|
|
|
break;
|
|
|
|
case LIST_CANCEL:
|
|
|
|
PlaySE(SE_SELECT);
|
2020-02-23 16:46:22 +01:00
|
|
|
sSecretBasePC_SelectedDecorationActions[tDecorationMenuCommand][1](taskId);
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
gCurDecorationIndex = input;
|
|
|
|
RemoveDecorationItemsScrollIndicators();
|
2020-02-23 16:46:22 +01:00
|
|
|
DestroyListMenuTask(tMenuTaskId, &sDecorationsScrollOffset, &sDecorationsCursorPos);
|
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
RemoveDecorationItemsOtherWindows();
|
2022-09-17 01:36:44 +02:00
|
|
|
Free(sDecorationItemsMenu);
|
2020-02-23 16:46:22 +01:00
|
|
|
sSecretBasePC_SelectedDecorationActions[tDecorationMenuCommand][0](taskId);
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ShowDecorationCategorySummaryWindow(u8 category)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
PrintDecorationCategoryMenuItem(AddDecorationWindow(WINDOW_DECORATION_CATEGORY_SUMMARY), category, 0, 0, 0, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PrintDecorationItemDescription(s32 itemIndex)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 windowId;
|
|
|
|
const u8 *str;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORY_ITEMS];
|
2019-04-06 19:41:55 +02:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2020-02-23 16:46:22 +01:00
|
|
|
if ((u32)itemIndex >= sNumOwnedDecorationsInCurCategory)
|
2019-04-06 19:41:55 +02:00
|
|
|
str = gText_GoBackPrevMenu;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-06 19:41:55 +02:00
|
|
|
str = gDecorations[gCurDecorationItems[itemIndex]].description;
|
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized(windowId, FONT_NORMAL, str, 0, 1, 0, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void RemoveDecorationItemsOtherWindows(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORY_ITEMS);
|
|
|
|
RemoveDecorationWindow(WINDOW_DECORATION_CATEGORY_SUMMARY);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 IsDecorationIndexInSecretBase(u8 idx)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseItemsIndicesBuffer); i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
if (sSecretBaseItemsIndicesBuffer[i] == idx)
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 IsDecorationIndexInPlayersRoom(u8 idx)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sPlayerRoomItemsIndicesBuffer); i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
if (sPlayerRoomItemsIndicesBuffer[i] == idx)
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void IdentifyOwnedDecorationsCurrentlyInUseInternal(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
u16 i, j, k;
|
|
|
|
u16 count;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
memset(sSecretBaseItemsIndicesBuffer, 0, sizeof(sSecretBaseItemsIndicesBuffer));
|
|
|
|
memset(sPlayerRoomItemsIndicesBuffer, 0, sizeof(sPlayerRoomItemsIndicesBuffer));
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseItemsIndicesBuffer); i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock1Ptr->secretBases[0].decorations[i] != DECOR_NONE)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < gDecorationInventories[sCurDecorationCategory].size; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (gCurDecorationItems[j] == gSaveBlock1Ptr->secretBases[0].decorations[i])
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (k = 0; k < count && sSecretBaseItemsIndicesBuffer[k] != j + 1; k++)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (k == count)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sSecretBaseItemsIndicesBuffer[count] = j + 1;
|
|
|
|
count++;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sPlayerRoomItemsIndicesBuffer); i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (gSaveBlock1Ptr->playerRoomDecorations[i] != DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < gDecorationInventories[sCurDecorationCategory].size; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (gCurDecorationItems[j] == gSaveBlock1Ptr->playerRoomDecorations[i] && IsDecorationIndexInSecretBase(j + 1) != TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (k = 0; k < count && sPlayerRoomItemsIndicesBuffer[k] != j + 1; k++);
|
|
|
|
if (k == count)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sPlayerRoomItemsIndicesBuffer[count] = j + 1;
|
|
|
|
count++;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void IdentifyOwnedDecorationsCurrentlyInUse(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
IdentifyOwnedDecorationsCurrentlyInUseInternal(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2017-10-23 02:13:31 +02:00
|
|
|
bool8 IsSelectedDecorInThePC(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sSecretBaseItemsIndicesBuffer); i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (sSecretBaseItemsIndicesBuffer[i] == sDecorationsScrollOffset + sDecorationsCursorPos + 1)
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
if (i < ARRAY_COUNT(sPlayerRoomItemsIndicesBuffer)
|
|
|
|
&& sPlayerRoomItemsIndicesBuffer[i] == sDecorationsScrollOffset + sDecorationsCursorPos + 1)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_ShowDecorationItemsWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
AddDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
ShowDecorationItemsWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void DontTossDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].func = Task_ShowDecorationItemsWindow;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ReturnToDecorationItemsAfterInvalidSelection(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
AddDecorationWindow(WINDOW_DECORATION_CATEGORIES);
|
2019-04-06 19:41:55 +02:00
|
|
|
ShowDecorationItemsWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void DecorationItemsMenuAction_Cancel(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
RemoveDecorationItemsScrollIndicators();
|
|
|
|
RemoveDecorationItemsOtherWindows();
|
2020-02-23 16:46:22 +01:00
|
|
|
DestroyListMenuTask(tMenuTaskId, NULL, NULL);
|
2022-09-17 01:36:44 +02:00
|
|
|
Free(sDecorationItemsMenu);
|
2020-02-23 16:46:22 +01:00
|
|
|
ReinitDecorationCategoriesWindow(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetInitialPositions(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tInitialX = gSaveBlock1Ptr->pos.x;
|
|
|
|
gTasks[taskId].tInitialY = gSaveBlock1Ptr->pos.y;
|
|
|
|
PlayerGetDestCoords(&gTasks[taskId].tCursorX, &gTasks[taskId].tCursorY);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void WarpToInitialPosition(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
DrawWholeMapView();
|
2021-11-15 18:04:54 +01:00
|
|
|
SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, WARP_ID_NONE, gTasks[taskId].tInitialX, gTasks[taskId].tInitialY);
|
2018-09-05 00:31:37 +02:00
|
|
|
WarpIntoMap();
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static u16 GetDecorationElevation(u8 decoration, u8 tileIndex)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
u16 elevation = -1;
|
|
|
|
switch (decoration)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case DECOR_STAND:
|
2022-01-19 16:15:32 +01:00
|
|
|
elevation = sDecorationStandElevations[tileIndex] << MAPGRID_ELEVATION_SHIFT;
|
2019-04-06 19:41:55 +02:00
|
|
|
return elevation;
|
|
|
|
case DECOR_SLIDE:
|
2022-01-19 16:15:32 +01:00
|
|
|
elevation = sDecorationSlideElevation[tileIndex] << MAPGRID_ELEVATION_SHIFT;
|
2019-04-06 19:41:55 +02:00
|
|
|
return elevation;
|
|
|
|
default:
|
|
|
|
return elevation;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decoration)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 i, j;
|
|
|
|
s16 x, y;
|
2022-01-19 16:15:32 +01:00
|
|
|
u16 attributes;
|
2019-02-22 09:08:48 +01:00
|
|
|
u16 impassableFlag;
|
2020-02-23 16:46:22 +01:00
|
|
|
u16 overlapsWall;
|
2019-04-05 23:11:24 +02:00
|
|
|
u16 elevation;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
for (j = 0; j < decHeight; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
y = mapY - decHeight + 1 + j;
|
|
|
|
for (i = 0; i < decWidth; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
x = mapX + i;
|
2022-01-19 16:15:32 +01:00
|
|
|
attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
|
2022-09-11 20:14:49 +02:00
|
|
|
if (MetatileBehavior_IsSecretBaseImpassable(attributes & METATILE_ATTR_BEHAVIOR_MASK) == TRUE
|
2022-01-19 16:56:54 +01:00
|
|
|
|| (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT) != METATILE_LAYER_TYPE_NORMAL))
|
2022-01-19 16:15:32 +01:00
|
|
|
impassableFlag = MAPGRID_COLLISION_MASK;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-05 23:11:24 +02:00
|
|
|
impassableFlag = 0;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
// Choose the metatile that has the wall background instead of the floor if overlapping a wall.
|
2019-04-06 19:41:55 +02:00
|
|
|
if (gDecorations[decoration].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE)
|
2020-02-23 16:46:22 +01:00
|
|
|
overlapsWall = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2020-02-23 16:46:22 +01:00
|
|
|
overlapsWall = 0;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
elevation = GetDecorationElevation(gDecorations[decoration].id, j * decWidth + i);
|
2019-04-05 23:11:24 +02:00
|
|
|
if (elevation != 0xFFFF)
|
2021-01-03 07:34:12 +01:00
|
|
|
MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag | elevation);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2021-01-03 07:34:12 +01:00
|
|
|
MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
void ShowDecorationOnMap(u16 mapX, u16 mapY, u16 decoration)
|
|
|
|
{
|
|
|
|
switch (gDecorations[decoration].shape)
|
|
|
|
{
|
|
|
|
case DECORSHAPE_1x1:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 1, 1, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x1:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 2, 1, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x1: // unused
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 3, 1, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_4x2:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 4, 2, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x2:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 2, 2, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_1x2:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 1, 2, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_1x3: // unused
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 1, 3, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x4:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 2, 4, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x3:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 3, 3, decoration);
|
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x2:
|
|
|
|
ShowDecorationOnMap_(mapX, mapY, 3, 2, decoration);
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 08:12:00 +02:00
|
|
|
void SetDecoration(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
|
|
|
|
2019-09-06 08:12:00 +02:00
|
|
|
for (i = 0; i < NUM_DECORATION_FLAGS; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-02 07:25:43 +01:00
|
|
|
if (FlagGet(FLAG_DECORATION_1 + i) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-02 07:25:43 +01:00
|
|
|
FlagClear(FLAG_DECORATION_1 + i);
|
2019-11-21 04:55:44 +01:00
|
|
|
for (j = 0; j < gMapHeader.events->objectEventCount; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gMapHeader.events->objectEvents[j].flagId == FLAG_DECORATION_1 + i)
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
VarSet(
|
2019-11-21 05:12:51 +01:00
|
|
|
VAR_OBJ_GFX_ID_0 + (gMapHeader.events->objectEvents[j].graphicsId - OBJ_EVENT_GFX_VAR_0),
|
2019-04-05 23:11:24 +02:00
|
|
|
sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0]);
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
gSpecialVar_0x8005 = gMapHeader.events->objectEvents[j].localId;
|
2017-10-23 02:13:31 +02:00
|
|
|
gSpecialVar_0x8006 = sCurDecorMapX;
|
|
|
|
gSpecialVar_0x8007 = sCurDecorMapY;
|
2019-11-21 04:55:44 +01:00
|
|
|
TrySpawnObjectEvent(gSpecialVar_0x8005, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
|
|
|
TryMoveObjectEventToMapCoords(gSpecialVar_0x8005, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, gSpecialVar_0x8006, gSpecialVar_0x8007);
|
|
|
|
TryOverrideObjectEventTemplateCoords(gSpecialVar_0x8005, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 HasDecorationSpace(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2020-02-23 16:46:22 +01:00
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.items[i] == DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2020-02-23 16:46:22 +01:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void DecorationItemsMenuAction_AttemptPlace(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.isPlayerRoom == TRUE && sCurDecorationCategory != DECORCAT_DOLL && sCurDecorationCategory != DECORCAT_CUSHION)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CantPlaceInRoom);
|
2020-02-23 16:46:22 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2017-10-23 02:13:31 +02:00
|
|
|
else if (IsSelectedDecorInThePC() == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (HasDecorationSpace() == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].func = Task_PlaceDecoration;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
ConvertIntToDecimalStringN(gStringVar1, sDecorationContext.size, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
|
|
|
if (sDecorationContext.isPlayerRoom == FALSE) {
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations2);
|
|
|
|
}
|
2020-02-23 16:46:22 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_InUseAlready);
|
2020-02-23 16:46:22 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_PlaceDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (gTasks[taskId].tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetInitialPositions(taskId);
|
|
|
|
gTasks[taskId].tState = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gPaletteFade.bufferTransferDisabled = TRUE;
|
2019-04-06 19:41:55 +02:00
|
|
|
ConfigureCameraObjectForPlacingDecoration(&sPlaceDecorationGraphicsDataBuffer, gCurDecorationItems[gCurDecorationIndex]);
|
2020-02-23 16:46:22 +01:00
|
|
|
SetUpDecorationShape(taskId);
|
2017-10-23 02:13:31 +02:00
|
|
|
SetUpPlacingDecorationPlayerAvatar(taskId, &sPlaceDecorationGraphicsDataBuffer);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2017-10-23 00:55:07 +02:00
|
|
|
gPaletteFade.bufferTransferDisabled = FALSE;
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 2;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2018-05-11 01:36:57 +02:00
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorationItemsMenuCommand = DECOR_ITEMS_MENU_PLACE;
|
2019-09-06 08:12:00 +02:00
|
|
|
ContinueDecorating(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2018-10-16 15:55:16 +02:00
|
|
|
sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
|
|
|
|
gFieldCamera.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
|
|
|
|
gSprites[gFieldCamera.spriteId].oam.priority = 1;
|
2020-02-23 16:46:22 +01:00
|
|
|
gSprites[gFieldCamera.spriteId].callback = InitializePuttingAwayCursorSprite;
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[gFieldCamera.spriteId].x = sDecorationMovementInfo[data->decoration->shape].cameraX;
|
|
|
|
gSprites[gFieldCamera.spriteId].y = sDecorationMovementInfo[data->decoration->shape].cameraY;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
u8 x;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
x = 16 * (u8)gTasks[taskId].tDecorWidth + sDecorationMovementInfo[data->decoration->shape].cameraX - 8 * ((u8)gTasks[taskId].tDecorWidth - 1);
|
2017-10-23 00:55:07 +02:00
|
|
|
if (data->decoration->shape == DECORSHAPE_3x1 || data->decoration->shape == DECORSHAPE_3x3 || data->decoration->shape == DECORSHAPE_3x2)
|
2019-04-06 19:41:55 +02:00
|
|
|
x -= 8;
|
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2021-11-18 05:28:43 +01:00
|
|
|
sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, x, 72, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2021-11-18 05:28:43 +01:00
|
|
|
sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, x, 72, 0);
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
|
|
|
|
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
|
2018-10-16 15:55:16 +02:00
|
|
|
sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetUpDecorationShape(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
switch (gDecorations[gCurDecorationItems[gCurDecorationIndex]].shape)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
case DECORSHAPE_1x1:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 1;
|
|
|
|
gTasks[taskId].tDecorHeight = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x1:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 2;
|
|
|
|
gTasks[taskId].tDecorHeight = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x1:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 3;
|
|
|
|
gTasks[taskId].tDecorHeight = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_4x2:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 4;
|
|
|
|
gTasks[taskId].tDecorHeight = 2;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x2:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 2;
|
|
|
|
gTasks[taskId].tDecorHeight = 2;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_1x2:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 1;
|
|
|
|
gTasks[taskId].tDecorHeight = 2;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_1x3:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 1;
|
|
|
|
gTasks[taskId].tDecorHeight = 3;
|
|
|
|
gTasks[taskId].tCursorY++;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_2x4:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 2;
|
|
|
|
gTasks[taskId].tDecorHeight = 4;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x3:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 3;
|
|
|
|
gTasks[taskId].tDecorHeight = 3;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
case DECORSHAPE_3x2:
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tDecorWidth = 3;
|
|
|
|
gTasks[taskId].tDecorHeight = 2;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptPlaceDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 1;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].data[7] = 1;
|
2020-02-23 16:46:22 +01:00
|
|
|
ResetCursorMovement();
|
|
|
|
AttemptPlaceDecoration_(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptCancelPlaceDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 1;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].data[7] = 1;
|
2020-02-23 16:46:22 +01:00
|
|
|
ResetCursorMovement();
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CancelDecorating);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2022-01-19 16:56:54 +01:00
|
|
|
static bool8 IsSecretBaseTrainerSpot(u8 behaviorAt, u16 layerType)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-01-19 16:56:54 +01:00
|
|
|
if (!(MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) == TRUE && layerType == METATILE_LAYER_TYPE_NORMAL))
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-01-19 16:56:54 +01:00
|
|
|
// Can't place decoration where the player was standing when they interacted with the PC
|
2022-01-19 16:15:32 +01:00
|
|
|
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-09-11 20:14:49 +02:00
|
|
|
if (x == gTasks[taskId].tInitialX + MAP_OFFSET
|
2022-01-19 16:56:54 +01:00
|
|
|
&& y == gTasks[taskId].tInitialY + MAP_OFFSET
|
|
|
|
&& layerType != METATILE_LAYER_TYPE_NORMAL)
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-01-19 16:56:54 +01:00
|
|
|
if (MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) != TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2018-10-05 00:57:07 +02:00
|
|
|
if (decoration->id == DECOR_SOLID_BOARD && MetatileBehavior_IsSecretBaseHole(behaviorAt) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
if (MetatileBehavior_IsNormal(behaviorAt))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
|
|
|
u8 behaviorAt;
|
2022-01-19 16:15:32 +01:00
|
|
|
u16 layerType;
|
2017-10-23 00:55:07 +02:00
|
|
|
u8 mapY;
|
|
|
|
u8 mapX;
|
|
|
|
s16 curY;
|
|
|
|
s16 curX;
|
2020-02-23 16:46:22 +01:00
|
|
|
mapY = gTasks[taskId].tDecorHeight;
|
|
|
|
mapX = gTasks[taskId].tDecorWidth;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
|
|
|
switch (decoration->permission)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case DECORPERM_SOLID_FLOOR:
|
|
|
|
case DECORPERM_PASS_FLOOR:
|
|
|
|
for (i = 0; i < mapY; i++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curY = gTasks[taskId].tCursorY - i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < mapX; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curX = gTasks[taskId].tCursorX + j;
|
2017-10-23 00:55:07 +02:00
|
|
|
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
2022-01-19 16:15:32 +01:00
|
|
|
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
|
2020-02-23 16:46:22 +01:00
|
|
|
if (!IsFloorOrBoardAndHole(behaviorAt, decoration))
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2022-01-19 16:15:32 +01:00
|
|
|
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
|
2021-10-09 18:12:18 +02:00
|
|
|
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DECORPERM_BEHIND_FLOOR:
|
|
|
|
for (i = 0; i < mapY - 1; i++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curY = gTasks[taskId].tCursorY - i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < mapX; j++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curX = gTasks[taskId].tCursorX + j;
|
2017-10-23 00:55:07 +02:00
|
|
|
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
2022-01-19 16:15:32 +01:00
|
|
|
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
|
2022-01-19 16:56:54 +01:00
|
|
|
if (!MetatileBehavior_IsNormal(behaviorAt) && !IsSecretBaseTrainerSpot(behaviorAt, layerType))
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-19 16:15:32 +01:00
|
|
|
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
curY = gTasks[taskId].tCursorY - mapY + 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < mapX; j++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curX = gTasks[taskId].tCursorX + j;
|
2019-04-06 19:41:55 +02:00
|
|
|
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
2022-01-19 16:15:32 +01:00
|
|
|
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ATTR_LAYER_MASK;
|
2019-04-06 19:41:55 +02:00
|
|
|
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
|
|
|
|
return FALSE;
|
|
|
|
|
2022-01-19 16:15:32 +01:00
|
|
|
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
|
2021-10-09 18:12:18 +02:00
|
|
|
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DECORPERM_NA_WALL:
|
|
|
|
for (i = 0; i < mapY; i++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curY = gTasks[taskId].tCursorY - i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < mapX; j++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curX = gTasks[taskId].tCursorX + j;
|
2019-04-06 19:41:55 +02:00
|
|
|
if (!MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(curX, curY)))
|
|
|
|
return FALSE;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (MapGridGetMetatileIdAt(curX, curY + 1) == METATILE_SecretBase_SandOrnament_BrokenBase)
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DECORPERM_SPRITE:
|
2020-02-23 16:46:22 +01:00
|
|
|
curY = gTasks[taskId].tCursorY;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (j = 0; j < mapX; j++)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
curX = gTasks[taskId].tCursorX + j;
|
2019-04-06 19:41:55 +02:00
|
|
|
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
|
|
|
if (decoration->shape == DECORSHAPE_1x2)
|
|
|
|
{
|
|
|
|
if (!MetatileBehavior_HoldsLargeDecoration(behaviorAt))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (!MetatileBehavior_HoldsSmallDecoration(behaviorAt))
|
|
|
|
{
|
|
|
|
if (!MetatileBehavior_HoldsLargeDecoration(behaviorAt))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
2019-04-06 19:41:55 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptPlaceDecoration_(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
if (CanPlaceDecoration(taskId, &gDecorations[gCurDecorationItems[gCurDecorationIndex]]) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_PlaceItHere);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, PlaceDecorationPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CantBePlacedHere);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, CantPlaceDecorationPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PlaceDecorationPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-09-06 08:12:00 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sPlaceDecorationYesNoFunctions);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PlaceDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
PlaceDecoration_(taskId);
|
2019-04-06 19:41:55 +02:00
|
|
|
if (gDecorations[gCurDecorationItems[gCurDecorationIndex]].permission != DECORPERM_SPRITE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
ShowDecorationOnMap(gTasks[taskId].tCursorX, gTasks[taskId].tCursorY, gCurDecorationItems[gCurDecorationIndex]);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-09 18:12:18 +02:00
|
|
|
sCurDecorMapX = gTasks[taskId].tCursorX - MAP_OFFSET;
|
|
|
|
sCurDecorMapY = gTasks[taskId].tCursorY - MAP_OFFSET;
|
2022-08-15 21:18:12 +02:00
|
|
|
ScriptContext_SetupScript(SecretBase_EventScript_SetDecoration);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].y += 2;
|
2017-10-29 03:03:33 +01:00
|
|
|
if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE)
|
2021-04-25 23:22:45 +02:00
|
|
|
TryPutSecretBaseVisitOnAir();
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
CancelDecorating_(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PlaceDecoration_(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.items[i] == DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items[i] = gCurDecorationItems[gCurDecorationIndex];
|
2021-10-09 18:12:18 +02:00
|
|
|
sDecorationContext.pos[i] = ((gTasks[taskId].tCursorX - MAP_OFFSET) << 4) + (gTasks[taskId].tCursorY - MAP_OFFSET);
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (!sDecorationContext.isPlayerRoom)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
for (i = 0; i < DECOR_MAX_SECRET_BASE; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sSecretBaseItemsIndicesBuffer[i] == DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sSecretBaseItemsIndicesBuffer[i] = gCurDecorationIndex + 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 08:12:00 +02:00
|
|
|
for (i = 0; i < DECOR_MAX_PLAYERS_HOUSE; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sPlayerRoomItemsIndicesBuffer[i] == DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sPlayerRoomItemsIndicesBuffer[i] = gCurDecorationIndex + 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CancelDecoratingPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-09-06 08:12:00 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sCancelDecoratingYesNoFunctions);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CancelDecorating(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
CancelDecorating_(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CancelDecorating_(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
gTasks[taskId].func = c1_overworld_prev_quest;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void c1_overworld_prev_quest(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (gTasks[taskId].tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2019-04-06 19:41:55 +02:00
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
WarpToInitialPosition(taskId);
|
|
|
|
gTasks[taskId].tState = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-02-23 16:46:22 +01:00
|
|
|
FreePlayerSpritePalette();
|
2019-04-06 19:41:55 +02:00
|
|
|
FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG);
|
2020-02-23 16:46:22 +01:00
|
|
|
gFieldCallback = FieldCB_InitDecorationItemsWindow;
|
2019-04-06 19:41:55 +02:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_InitDecorationItemsWindow(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
|
|
|
HideSecretBaseDecorationSprites();
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-15 21:18:12 +02:00
|
|
|
ScriptContext_SetupScript(SecretBase_EventScript_InitDecorations);
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
|
|
|
gTasks[taskId].func = HandleDecorationItemsMenuInput;
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void FieldCB_InitDecorationItemsWindow(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2020-02-23 16:46:22 +01:00
|
|
|
taskId = CreateTask(Task_InitDecorationItemsWindow, 8);
|
|
|
|
AddDecorationItemsWindow(taskId);
|
|
|
|
gTasks[taskId].tState = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 ApplyCursorMovement_IsInvalid(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationLastDirectionMoved == DIR_SOUTH && tCursorY - tDecorHeight - 6 < 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorY++;
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationLastDirectionMoved == DIR_NORTH && tCursorY - 7 >= gMapHeader.mapLayout->height)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorY--;
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationLastDirectionMoved == DIR_WEST && tCursorX - 7 < 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorX++;
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationLastDirectionMoved == DIR_EAST && tCursorX + tDecorWidth - 8 >= gMapHeader.mapLayout->width)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorX--;
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 IsHoldingDirection(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
u16 heldKeys = JOY_HELD(DPAD_ANY);
|
2017-10-23 00:55:07 +02:00
|
|
|
if (heldKeys != DPAD_UP && heldKeys != DPAD_DOWN && heldKeys != DPAD_LEFT && heldKeys != DPAD_RIGHT)
|
|
|
|
return FALSE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ResetCursorMovement(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorationLastDirectionMoved = 0;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_SelectLocation(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2017-12-02 21:44:50 +01:00
|
|
|
if (!gSprites[sDecor_CameraSpriteObjectIdx1].data[4])
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (tButton == A_BUTTON)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].yesFunc(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
return;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (tButton == B_BUTTON)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].noFunc(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_HELD(DPAD_ANY)) == DPAD_UP)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorationLastDirectionMoved = DIR_SOUTH;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = -2;
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorY--;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_HELD(DPAD_ANY)) == DPAD_DOWN)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorationLastDirectionMoved = DIR_NORTH;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 2;
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorY++;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_HELD(DPAD_ANY)) == DPAD_LEFT)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorationLastDirectionMoved = DIR_WEST;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = -2;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorX--;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if ((JOY_HELD(DPAD_ANY)) == DPAD_RIGHT)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorationLastDirectionMoved = DIR_EAST;
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 2;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
tCursorX++;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (!IsHoldingDirection() || !ApplyCursorMovement_IsInvalid(taskId))
|
|
|
|
ResetCursorMovement();
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 02:13:31 +02:00
|
|
|
if (sDecorationLastDirectionMoved)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[4]++;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[4] &= 7;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
if (!tButton)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2020-02-23 16:46:22 +01:00
|
|
|
tButton = A_BUTTON;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2020-02-23 16:46:22 +01:00
|
|
|
tButton = B_BUTTON;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ContinueDecorating(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, TRUE);
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
|
|
|
gTasks[taskId].func = Task_SelectLocation;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CantPlaceDecorationPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
|
2019-09-06 08:12:00 +02:00
|
|
|
ContinueDecorating(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ClearPlaceDecorationGraphicsDataBuffer(struct PlaceDecorationGraphicsDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
CpuFill16(0, data, sizeof(*data));
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CopyPalette(u16 *dest, u16 pal)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
CpuFastCopy(&((u16 *)gTilesetPointer_SecretBase->palettes)[pal * 16], dest, sizeof(u16) * 16);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void CopyTile(u8 *dest, u16 tile)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
u8 buffer[TILE_SIZE_4BPP];
|
2017-10-23 00:55:07 +02:00
|
|
|
u16 mode;
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
mode = tile >> 10;
|
|
|
|
if (tile != 0)
|
|
|
|
tile &= 0x03FF;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
CpuFastCopy(&((u8 *)gTilesetPointer_SecretBase->tiles)[tile * TILE_SIZE_4BPP], buffer, TILE_SIZE_4BPP);
|
2017-10-23 00:55:07 +02:00
|
|
|
switch (mode)
|
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
2020-02-23 16:46:22 +01:00
|
|
|
CpuFastCopy(buffer, dest, TILE_SIZE_4BPP);
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
2020-02-23 16:46:22 +01:00
|
|
|
case BG_TILE_H_FLIP(0) >> 10:
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
dest[4 * i + 0] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4);
|
2019-04-06 19:41:55 +02:00
|
|
|
dest[4 * i + 1] = (buffer[4 * (i + 1) - 2] >> 4) + ((buffer[4 * (i + 1) - 2] & 0x0F) << 4);
|
|
|
|
dest[4 * i + 2] = (buffer[4 * (i + 1) - 3] >> 4) + ((buffer[4 * (i + 1) - 3] & 0x0F) << 4);
|
|
|
|
dest[4 * i + 3] = (buffer[4 * (i + 1) - 4] >> 4) + ((buffer[4 * (i + 1) - 4] & 0x0F) << 4);
|
|
|
|
}
|
|
|
|
break;
|
2020-02-23 16:46:22 +01:00
|
|
|
case BG_TILE_V_FLIP(0) >> 10:
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
dest[4 * i + 0] = buffer[4 * (7 - i) + 0];
|
2019-04-06 19:41:55 +02:00
|
|
|
dest[4 * i + 1] = buffer[4 * (7 - i) + 1];
|
|
|
|
dest[4 * i + 2] = buffer[4 * (7 - i) + 2];
|
|
|
|
dest[4 * i + 3] = buffer[4 * (7 - i) + 3];
|
|
|
|
}
|
|
|
|
break;
|
2020-02-23 16:46:22 +01:00
|
|
|
case BG_TILE_H_FLIP(BG_TILE_V_FLIP(0)) >> 10:
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
dest[i] = (buffer[31 - i] >> 4) + ((buffer[31 - i] & 0x0F) << 4);
|
|
|
|
}
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetDecorSelectionBoxTiles(struct PlaceDecorationGraphicsDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < 64; i++)
|
2020-02-23 16:46:22 +01:00
|
|
|
CopyTile(&data->image[i * TILE_SIZE_4BPP], data->tiles[i]);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static u16 GetMetatile(u16 tile)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
return ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[tile] & 0xFFF;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetDecorSelectionMetatiles(struct PlaceDecorationGraphicsDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 shape;
|
|
|
|
|
|
|
|
shape = data->decoration->shape;
|
2021-01-03 07:34:12 +01:00
|
|
|
for (i = 0; i < sDecorTilemaps[shape].size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-12-03 23:29:02 +01:00
|
|
|
data->tiles[sDecorTilemaps[shape].tiles[i]] = GetMetatile(data->decoration->tiles[sDecorTilemaps[shape].y[i]] * NUM_TILES_PER_METATILE + sDecorTilemaps[shape].x[i]);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetDecorSelectionBoxOamAttributes(u8 decorShape)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorSelectorOam.y = 0;
|
|
|
|
sDecorSelectorOam.affineMode = ST_OAM_AFFINE_OFF;
|
|
|
|
sDecorSelectorOam.objMode = ST_OAM_OBJ_NORMAL;
|
2022-07-30 03:27:39 +02:00
|
|
|
sDecorSelectorOam.mosaic = FALSE;
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorSelectorOam.bpp = ST_OAM_4BPP;
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorSelectorOam.shape = sDecorationMovementInfo[decorShape].shape;
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorSelectorOam.x = 0;
|
|
|
|
sDecorSelectorOam.matrixNum = 0;
|
2019-04-06 19:41:55 +02:00
|
|
|
sDecorSelectorOam.size = sDecorationMovementInfo[decorShape].size;
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorSelectorOam.tileNum = 0;
|
|
|
|
sDecorSelectorOam.priority = 0;
|
|
|
|
sDecorSelectorOam.paletteNum = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void InitializePuttingAwayCursorSprite(struct Sprite *sprite)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[2] = 0;
|
|
|
|
sprite->data[3] = 0;
|
|
|
|
sprite->data[4] = 0;
|
|
|
|
sprite->data[5] = 0;
|
|
|
|
sprite->data[6] = 0;
|
|
|
|
sprite->data[7] = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
sprite->callback = InitializePuttingAwayCursorSprite2;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void InitializePuttingAwayCursorSprite2(struct Sprite *sprite)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[7] == 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (sprite->data[6] < 15)
|
2019-04-06 19:41:55 +02:00
|
|
|
sprite->invisible = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2019-04-06 19:41:55 +02:00
|
|
|
sprite->invisible = 1;
|
|
|
|
|
|
|
|
sprite->data[6]++;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[6] &= 0x1F;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->invisible = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
ClearPlaceDecorationGraphicsDataBuffer(data);
|
2017-10-23 00:55:07 +02:00
|
|
|
data->decoration = &gDecorations[decor];
|
2019-04-05 23:11:24 +02:00
|
|
|
if (data->decoration->permission == DECORPERM_SPRITE)
|
2021-11-18 05:28:43 +01:00
|
|
|
return CreateObjectGraphicsSprite(data->decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1);
|
2019-04-06 19:41:55 +02:00
|
|
|
|
|
|
|
FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG);
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorSelectionMetatiles(data);
|
2017-10-23 02:13:31 +02:00
|
|
|
SetDecorSelectionBoxOamAttributes(data->decoration->shape);
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorSelectionBoxTiles(data);
|
2022-12-03 23:29:02 +01:00
|
|
|
CopyPalette(data->palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(data->decoration->tiles[0] * NUM_TILES_PER_METATILE) + 7] >> 12);
|
2020-02-23 16:46:22 +01:00
|
|
|
LoadSpritePalette(&sSpritePal_PlaceDecoration);
|
2019-04-06 19:41:55 +02:00
|
|
|
return CreateSprite(&sDecorationSelectorSpriteTemplate, 0, 0, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 decor)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
struct SpriteSheet sheet;
|
|
|
|
struct CompressedSpritePalette palette;
|
|
|
|
struct SpriteTemplate *template;
|
|
|
|
u8 spriteId;
|
|
|
|
|
|
|
|
if (!AllocItemIconTemporaryBuffers())
|
|
|
|
return MAX_SPRITES;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2018-02-02 16:06:20 +01:00
|
|
|
LZDecompressWram(GetDecorationIconPicOrPalette(decor, 0), gItemIconDecompressionBuffer);
|
|
|
|
CopyItemIconPicTo4x4Buffer(gItemIconDecompressionBuffer, gItemIcon4x4Buffer);
|
|
|
|
sheet.data = gItemIcon4x4Buffer;
|
2017-10-23 00:55:07 +02:00
|
|
|
sheet.size = 0x200;
|
|
|
|
sheet.tag = tilesTag;
|
|
|
|
LoadSpriteSheet(&sheet);
|
|
|
|
palette.data = GetDecorationIconPicOrPalette(decor, 1);
|
|
|
|
palette.tag = paletteTag;
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpritePalette(&palette);
|
2022-09-17 01:24:26 +02:00
|
|
|
template = Alloc(sizeof(struct SpriteTemplate));
|
2018-02-02 16:06:20 +01:00
|
|
|
*template = gItemIconSpriteTemplate;
|
2017-10-23 00:55:07 +02:00
|
|
|
template->tileTag = tilesTag;
|
|
|
|
template->paletteTag = paletteTag;
|
|
|
|
spriteId = CreateSprite(template, 0, 0, 0);
|
|
|
|
FreeItemIconTemporaryBuffers();
|
2022-09-17 01:36:44 +02:00
|
|
|
Free(template);
|
2017-10-23 00:55:07 +02:00
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
if (decor > NUM_DECORATIONS)
|
2017-10-23 00:55:07 +02:00
|
|
|
decor = DECOR_NONE;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2019-09-12 19:55:37 +02:00
|
|
|
return gDecorIconTable[decor][mode];
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static u8 AddDecorationIconObjectFromObjectEvent(u16 tilesTag, u16 paletteTag, u8 decor)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct SpriteSheet sheet;
|
|
|
|
struct SpritePalette palette;
|
|
|
|
struct SpriteTemplate *template;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
ClearPlaceDecorationGraphicsDataBuffer(&sPlaceDecorationGraphicsDataBuffer);
|
2017-10-23 02:13:31 +02:00
|
|
|
sPlaceDecorationGraphicsDataBuffer.decoration = &gDecorations[decor];
|
2019-04-05 23:11:24 +02:00
|
|
|
if (sPlaceDecorationGraphicsDataBuffer.decoration->permission != DECORPERM_SPRITE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorSelectionMetatiles(&sPlaceDecorationGraphicsDataBuffer);
|
2017-10-23 02:13:31 +02:00
|
|
|
SetDecorSelectionBoxOamAttributes(sPlaceDecorationGraphicsDataBuffer.decoration->shape);
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorSelectionBoxTiles(&sPlaceDecorationGraphicsDataBuffer);
|
2022-12-03 23:29:02 +01:00
|
|
|
CopyPalette(sPlaceDecorationGraphicsDataBuffer.palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0] * NUM_TILES_PER_METATILE) + 7] >> 12);
|
2017-10-23 02:13:31 +02:00
|
|
|
sheet.data = sPlaceDecorationGraphicsDataBuffer.image;
|
2020-02-23 16:46:22 +01:00
|
|
|
sheet.size = sDecorShapeSizes[sPlaceDecorationGraphicsDataBuffer.decoration->shape] * TILE_SIZE_4BPP;
|
2017-10-23 00:55:07 +02:00
|
|
|
sheet.tag = tilesTag;
|
|
|
|
LoadSpriteSheet(&sheet);
|
2017-10-23 02:13:31 +02:00
|
|
|
palette.data = sPlaceDecorationGraphicsDataBuffer.palette;
|
2017-10-23 00:55:07 +02:00
|
|
|
palette.tag = paletteTag;
|
|
|
|
LoadSpritePalette(&palette);
|
|
|
|
template = Alloc(sizeof(struct SpriteTemplate));
|
2017-10-23 02:13:31 +02:00
|
|
|
*template = sDecorWhilePlacingSpriteTemplate;
|
2017-10-23 00:55:07 +02:00
|
|
|
template->tileTag = tilesTag;
|
|
|
|
template->paletteTag = paletteTag;
|
|
|
|
spriteId = CreateSprite(template, 0, 0, 0);
|
2022-09-17 01:36:44 +02:00
|
|
|
Free(template);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
spriteId = CreateObjectGraphicsSprite(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 AddDecorationIconObject(u8 decor, s16 x, s16 y, u8 priority, u16 tilesTag, u16 paletteTag)
|
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
if (decor > NUM_DECORATIONS)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
spriteId = AddDecorationIconObjectFromIconTable(tilesTag, paletteTag, DECOR_NONE);
|
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
return MAX_SPRITES;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].x2 = x + 4;
|
|
|
|
gSprites[spriteId].y2 = y + 4;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-09-12 19:55:37 +02:00
|
|
|
else if (gDecorIconTable[decor][0] == NULL)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
spriteId = AddDecorationIconObjectFromObjectEvent(tilesTag, paletteTag, decor);
|
2017-10-23 00:55:07 +02:00
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
return MAX_SPRITES;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].x2 = x;
|
2017-10-23 00:55:07 +02:00
|
|
|
if (decor == DECOR_SILVER_SHIELD || decor == DECOR_GOLD_SHIELD)
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].y2 = y - 4;
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].y2 = y;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spriteId = AddDecorationIconObjectFromIconTable(tilesTag, paletteTag, decor);
|
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
return MAX_SPRITES;
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[spriteId].x2 = x + 4;
|
|
|
|
gSprites[spriteId].y2 = y + 4;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
gSprites[spriteId].oam.priority = priority;
|
|
|
|
return spriteId;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ClearDecorationContextIndex(u8 idx)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
sDecorationContext.items[idx] = DECOR_NONE;
|
|
|
|
sDecorationContext.pos[idx] = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
// Input
|
|
|
|
// gSpecialVar_0x8004: Current iteration.
|
|
|
|
//
|
|
|
|
// Output
|
|
|
|
// gSpecialVar_Result: TRUE if all iterations complete.
|
|
|
|
// gSpecialVar_0x8005: flagId of decoration (if any).
|
|
|
|
// gSpecialVar_0x8006: localId of decoration object event (if any).
|
|
|
|
void PutAwayDecorationIteration(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
gSpecialVar_0x8005 = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
gSpecialVar_Result = FALSE;
|
2017-10-23 02:13:31 +02:00
|
|
|
if (gSpecialVar_0x8004 == sCurDecorSelectedInRearrangement)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gSpecialVar_Result = TRUE;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
2020-02-23 16:46:22 +01:00
|
|
|
else if (gDecorations[sDecorationContext.items[sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx]].permission == DECORPERM_SPRITE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
gSpecialVar_0x8005 = sDecorRearrangementDataBuffer[gSpecialVar_0x8004].flagId;
|
2020-02-23 16:46:22 +01:00
|
|
|
ClearDecorationContextIndex(sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx);
|
2019-11-21 04:55:44 +01:00
|
|
|
for (i = 0; i < gMapHeader.events->objectEventCount; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gMapHeader.events->objectEvents[i].flagId == gSpecialVar_0x8005)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gSpecialVar_0x8006 = gMapHeader.events->objectEvents[i].localId;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 10:26:26 +01:00
|
|
|
// Unused
|
2020-01-20 02:21:53 +01:00
|
|
|
void GetObjectEventLocalIdByFlag(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
for (i = 0; i < gMapHeader.events->objectEventCount; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gMapHeader.events->objectEvents[i].flagId == gSpecialVar_0x8004)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gSpecialVar_0x8005 = gMapHeader.events->objectEvents[i].localId;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ClearRearrangementNonSprites(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 y;
|
|
|
|
u8 x;
|
|
|
|
int posX;
|
|
|
|
int posY;
|
|
|
|
u8 perm;
|
|
|
|
|
2019-04-06 19:41:55 +02:00
|
|
|
for (i = 0; i < sCurDecorSelectedInRearrangement; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
perm = gDecorations[sDecorationContext.items[sDecorRearrangementDataBuffer[i].idx]].permission;
|
|
|
|
posX = sDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] >> 4;
|
|
|
|
posY = sDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] & 0x0F;
|
2019-04-05 23:11:24 +02:00
|
|
|
if (perm != DECORPERM_SPRITE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (y = 0; y < sDecorRearrangementDataBuffer[i].height; y++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
for (x = 0; x < sDecorRearrangementDataBuffer[i].width; x++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2021-10-09 18:12:18 +02:00
|
|
|
MapGridSetMetatileEntryAt(posX + MAP_OFFSET + x, posY + MAP_OFFSET - y, gMapHeader.mapLayout->map[posX + x + gMapHeader.mapLayout->width * (posY - y)] | 0x3000);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
ClearDecorationContextIndex(sDecorRearrangementDataBuffer[i].idx);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_PutAwayDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (gTasks[taskId].tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
2020-02-23 16:46:22 +01:00
|
|
|
ClearRearrangementNonSprites();
|
|
|
|
gTasks[taskId].tState = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active) {
|
|
|
|
DrawWholeMapView();
|
2022-08-15 21:18:12 +02:00
|
|
|
ScriptContext_SetupScript(SecretBase_EventScript_PutAwayDecoration);
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, TRUE);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 2;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2019-04-06 19:41:55 +02:00
|
|
|
IdentifyOwnedDecorationsCurrentlyInUseInternal(taskId);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 3;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_DecorationReturnedToPC);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ContinuePuttingAwayDecorationsPrompt);
|
2019-04-06 19:41:55 +02:00
|
|
|
if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE)
|
2021-04-25 23:22:45 +02:00
|
|
|
TryPutSecretBaseVisitOnAir();
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 HasDecorationsInUse(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2020-02-23 16:46:22 +01:00
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.items[i] != DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetUpPuttingAwayDecorationPlayerAvatar(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
GetPlayerFacingDirection();
|
2018-10-16 15:55:16 +02:00
|
|
|
sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0];
|
2020-02-23 16:46:22 +01:00
|
|
|
LoadPlayerSpritePalette();
|
|
|
|
gFieldCamera.spriteId = CreateSprite(&sPuttingAwayCursorSpriteTemplate, 120, 80, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2021-11-18 05:28:43 +01:00
|
|
|
sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, 136, 72, 0);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2021-11-18 05:28:43 +01:00
|
|
|
sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, 136, 72, 0);
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
|
|
|
|
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
|
2018-10-16 15:55:16 +02:00
|
|
|
sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId;
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_ContinuePuttingAwayDecorations(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetInitialPositions(taskId);
|
|
|
|
tState = 1;
|
|
|
|
tDecorHeight = 1;
|
|
|
|
tDecorWidth = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
SetUpPuttingAwayDecorationPlayerAvatar();
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2020-02-23 16:46:22 +01:00
|
|
|
tState = 2;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
tDecorationItemsMenuCommand = DECOR_ITEMS_MENU_PUT_AWAY;
|
2019-09-06 08:12:00 +02:00
|
|
|
ContinuePuttingAwayDecorations(taskId);
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ContinuePuttingAwayDecorations(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, TRUE);
|
2017-12-02 21:44:50 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0;
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE;
|
2020-02-23 16:46:22 +01:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].callback = InitializeCameraSprite1;
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].x = 136;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].y = 72;
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
|
|
|
gTasks[taskId].func = Task_SelectLocation;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptPutAwayDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
|
|
|
ResetCursorMovement();
|
|
|
|
AttemptPutAwayDecoration_(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptCancelPutAwayDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tButton = 0;
|
|
|
|
ResetCursorMovement();
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].callback = SpriteCallbackDummy;
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_StopPuttingAwayDecorations);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, StopPuttingAwayDecorationsPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptPutAwayDecoration_(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
u8 behavior;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
AttemptMarkDecorUnderCursorForRemoval(taskId);
|
2017-10-23 02:13:31 +02:00
|
|
|
if (sCurDecorSelectedInRearrangement != 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_ReturnDecorationToPC);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnDecorationPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
behavior = MapGridGetMetatileBehaviorAt(tCursorX, tCursorY);
|
2018-10-05 00:57:07 +02:00
|
|
|
if (MetatileBehavior_IsSecretBasePC(behavior) == TRUE || MetatileBehavior_IsPlayerRoomPCOn(behavior) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].callback = SpriteCallbackDummy;
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_StopPuttingAwayDecorations);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, StopPuttingAwayDecorationsPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_NoDecorationHere);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ContinuePuttingAwayDecorationsPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ContinuePuttingAwayDecorationsPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
|
2019-09-06 08:12:00 +02:00
|
|
|
ContinuePuttingAwayDecorations(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetDecorRearrangementShape(u8 decor, struct DecorRearrangementDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (gDecorations[decor].shape == DECORSHAPE_1x1)
|
|
|
|
{
|
|
|
|
data->width = 1;
|
|
|
|
data->height = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_2x1)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 2;
|
|
|
|
data->height = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_3x1)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 3;
|
|
|
|
data->height = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_4x2)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 4;
|
|
|
|
data->height = 2;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_2x2)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 2;
|
|
|
|
data->height = 2;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_1x2)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 1;
|
|
|
|
data->height = 2;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_1x3)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 1;
|
|
|
|
data->height = 3;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_2x4)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 2;
|
|
|
|
data->height = 4;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_3x3)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 3;
|
|
|
|
data->height = 3;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
else if (gDecorations[decor].shape == DECORSHAPE_3x2)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
data->width = 3;
|
|
|
|
data->height = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetCameraSpritePosition(u8 x, u8 y)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].invisible = TRUE;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx1].callback = SpriteCallbackDummy;
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].x = x * 16 + 136;
|
|
|
|
gSprites[sDecor_CameraSpriteObjectIdx2].y = y * 16 + 72;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 DecorationIsUnderCursor(u8 taskId, u8 idx, struct DecorRearrangementDataBuffer *data)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 x;
|
|
|
|
u8 y;
|
|
|
|
u8 xOff;
|
|
|
|
u8 yOff;
|
|
|
|
u8 ht;
|
|
|
|
|
2021-10-09 18:12:18 +02:00
|
|
|
x = gTasks[taskId].tCursorX - MAP_OFFSET;
|
|
|
|
y = gTasks[taskId].tCursorY - MAP_OFFSET;
|
2020-02-23 16:46:22 +01:00
|
|
|
xOff = sDecorationContext.pos[idx] >> 4;
|
|
|
|
yOff = sDecorationContext.pos[idx] & 0x0F;
|
2017-10-23 00:55:07 +02:00
|
|
|
ht = data->height;
|
2021-10-09 18:12:18 +02:00
|
|
|
if (sDecorationContext.items[idx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + MAP_OFFSET, yOff + MAP_OFFSET) == METATILE_SecretBase_SandOrnament_BrokenBase)
|
2019-04-06 19:41:55 +02:00
|
|
|
ht--;
|
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
if (x >= xOff && x < xOff + data->width && y > yOff - ht && y <= yOff)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetCameraSpritePosition(data->width - (x - xOff + 1), yOff - y);
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-04-06 19:41:55 +02:00
|
|
|
|
2017-10-23 00:55:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void SetDecorRearrangementFlagIdIfFlagUnset(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 xOff;
|
|
|
|
u8 yOff;
|
|
|
|
u16 i;
|
2017-10-23 02:13:31 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
xOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] >> 4;
|
|
|
|
yOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] & 0x0F;
|
|
|
|
for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gSaveBlock1Ptr->objectEventTemplates[i].x == xOff && gSaveBlock1Ptr->objectEventTemplates[i].y == yOff && !FlagGet(gSaveBlock1Ptr->objectEventTemplates[i].flagId))
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].flagId = gSaveBlock1Ptr->objectEventTemplates[i].flagId;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static bool8 AttemptMarkSpriteDecorUnderCursorForRemoval(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (sDecorationContext.items[i] != DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
if (gDecorations[sDecorationContext.items[i]].permission == DECORPERM_SPRITE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorRearrangementShape(sDecorationContext.items[i], sDecorRearrangementDataBuffer);
|
|
|
|
if (DecorationIsUnderCursor(taskId, i, sDecorRearrangementDataBuffer) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorRearrangementDataBuffer->idx = i;
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorRearrangementFlagIdIfFlagUnset();
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorSelectedInRearrangement = 1;
|
2017-10-23 00:55:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void MarkSpriteDecorsInBoundsForRemoval(u8 left, u8 top, u8 right, u8 bottom)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 xOff;
|
|
|
|
u8 yOff;
|
2020-02-23 16:46:22 +01:00
|
|
|
u8 decor;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
decor = sDecorationContext.items[i];
|
|
|
|
xOff = sDecorationContext.pos[i] >> 4;
|
|
|
|
yOff = sDecorationContext.pos[i] & 0x0F;
|
|
|
|
if (decor != DECOR_NONE && gDecorations[decor].permission == DECORPERM_SPRITE && left <= xOff && top <= yOff && right >= xOff && bottom >= yOff)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx = i;
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorRearrangementFlagIdIfFlagUnset();
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorSelectedInRearrangement++;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void AttemptMarkDecorUnderCursorForRemoval(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 xOff;
|
|
|
|
u8 yOff;
|
2018-02-18 19:12:09 +01:00
|
|
|
u8 var1;
|
|
|
|
u32 var2;
|
2017-10-23 00:55:07 +02:00
|
|
|
|
2017-10-23 02:13:31 +02:00
|
|
|
sCurDecorSelectedInRearrangement = 0;
|
2020-02-23 16:46:22 +01:00
|
|
|
if (AttemptMarkSpriteDecorUnderCursorForRemoval(taskId) != TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
// Not a sprite.
|
|
|
|
for (i = 0; i < sDecorationContext.size; i++)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
var1 = sDecorationContext.items[i];
|
2018-02-18 19:12:09 +01:00
|
|
|
if (var1 != DECOR_NONE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
SetDecorRearrangementShape(var1, &sDecorRearrangementDataBuffer[0]);
|
|
|
|
if (DecorationIsUnderCursor(taskId, i, &sDecorRearrangementDataBuffer[0]) == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2018-02-18 19:12:09 +01:00
|
|
|
sDecorRearrangementDataBuffer[0].idx = i;
|
|
|
|
sCurDecorSelectedInRearrangement++;
|
2017-10-23 00:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-23 02:13:31 +02:00
|
|
|
if (sCurDecorSelectedInRearrangement != 0)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
xOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] >> 4;
|
|
|
|
yOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] & 0x0F;
|
2018-02-18 19:12:09 +01:00
|
|
|
var1 = yOff - sDecorRearrangementDataBuffer[0].height + 1;
|
|
|
|
var2 = sDecorRearrangementDataBuffer[0].width + xOff - 1;
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
// Remove any dolls/cushions on this decoration.
|
|
|
|
MarkSpriteDecorsInBoundsForRemoval(xOff, var1, var2, yOff);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void ReturnDecorationPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-09-06 08:12:00 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sReturnDecorationYesNoFunctions);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void PutAwayDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].func = Task_PutAwayDecoration;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void StopPuttingAwayDecorationsPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-09-06 08:12:00 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sStopPuttingAwayDecorationsYesNoFunctions);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void StopPuttingAwayDecorations(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2022-07-25 20:59:14 +02:00
|
|
|
ClearDialogWindowAndFrame(0, FALSE);
|
2020-02-23 16:46:22 +01:00
|
|
|
StopPuttingAwayDecorations_(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void StopPuttingAwayDecorations_(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2020-02-23 16:46:22 +01:00
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].func = Task_StopPuttingAwayDecorations;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_StopPuttingAwayDecorations(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (gTasks[taskId].tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-02-23 16:46:22 +01:00
|
|
|
WarpToInitialPosition(taskId);
|
|
|
|
gTasks[taskId].tState = 1;
|
2019-04-06 19:41:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-02-23 16:46:22 +01:00
|
|
|
FreePlayerSpritePalette();
|
|
|
|
gFieldCallback = FieldCB_StopPuttingAwayDecorations;
|
2019-04-06 19:41:55 +02:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void Task_ReinitializeDecorationMenuHandler(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
s16 *data = gTasks[taskId].data;
|
2020-02-23 16:46:22 +01:00
|
|
|
switch (tState)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
case 0:
|
|
|
|
HideSecretBaseDecorationSprites();
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-15 21:18:12 +02:00
|
|
|
ScriptContext_SetupScript(SecretBase_EventScript_InitDecorations);
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-15 21:18:12 +02:00
|
|
|
LockPlayerFieldControls();
|
2020-02-23 16:46:22 +01:00
|
|
|
tState++;
|
2019-04-06 19:41:55 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
|
|
|
gTasks[taskId].func = HandleDecorationActionsMenuInput;
|
|
|
|
break;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void FieldCB_StopPuttingAwayDecorations(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2022-05-27 02:18:52 +02:00
|
|
|
DrawDialogueFrame(0, TRUE);
|
2019-04-06 19:41:55 +02:00
|
|
|
InitDecorationActionsWindow();
|
2020-02-23 16:46:22 +01:00
|
|
|
taskId = CreateTask(Task_ReinitializeDecorationMenuHandler, 8);
|
|
|
|
gTasks[taskId].tState = 0;
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void InitializeCameraSprite1(struct Sprite *sprite)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
sprite->data[0]++;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[0] &= 0x1F;
|
|
|
|
if (sprite->data[0] > 15)
|
2017-10-23 00:55:07 +02:00
|
|
|
sprite->invisible = TRUE;
|
|
|
|
else
|
|
|
|
sprite->invisible = FALSE;
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void LoadPlayerSpritePalette(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
|
|
|
if (gSaveBlock2Ptr->playerGender == MALE)
|
2020-02-23 16:46:22 +01:00
|
|
|
LoadSpritePalette(&sSpritePal_PuttingAwayCursorBrendan);
|
2017-10-23 00:55:07 +02:00
|
|
|
else
|
2020-02-23 16:46:22 +01:00
|
|
|
LoadSpritePalette(&sSpritePal_PuttingAwayCursorMay);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void FreePlayerSpritePalette(void)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
FreeSpritePaletteByTag(PLACE_DECORATION_PLAYER_TAG);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void DecorationItemsMenuAction_AttemptToss(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2017-10-23 02:13:31 +02:00
|
|
|
if (IsSelectedDecorInThePC() == TRUE)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
StringCopy(gStringVar1, gDecorations[gCurDecorationItems[gCurDecorationIndex]].name);
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_DecorationWillBeDiscarded);
|
2019-09-06 08:12:00 +02:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, TossDecorationPrompt);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StringExpandPlaceholders(gStringVar4, gText_CantThrowAwayInUse);
|
2020-02-23 16:46:22 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void TossDecorationPrompt(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-02-27 04:30:40 +01:00
|
|
|
DisplayYesNoMenuDefaultYes();
|
2019-09-06 08:12:00 +02:00
|
|
|
DoYesNoFuncWithChoice(taskId, &sTossDecorationYesNoFunctions);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 16:46:22 +01:00
|
|
|
static void TossDecoration(u8 taskId)
|
2017-10-23 00:55:07 +02:00
|
|
|
{
|
2019-04-06 19:41:55 +02:00
|
|
|
gCurDecorationItems[gCurDecorationIndex] = DECOR_NONE;
|
|
|
|
sNumOwnedDecorationsInCurCategory = GetNumOwnedDecorationsInCategory(sCurDecorationCategory);
|
|
|
|
CondenseDecorationsInCategory(sCurDecorationCategory);
|
2017-10-23 02:13:31 +02:00
|
|
|
IdentifyOwnedDecorationsCurrentlyInUseInternal(taskId);
|
2017-10-23 00:55:07 +02:00
|
|
|
StringExpandPlaceholders(gStringVar4, gText_DecorationThrownAway);
|
2020-02-23 16:46:22 +01:00
|
|
|
DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection);
|
2017-10-23 00:55:07 +02:00
|
|
|
}
|