summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2022-02-27 13:58:48 -0500
committerGriffinR <griffin.g.richards@gmail.com>2022-02-27 13:58:48 -0500
commit3d0663fe811cdd01010b391b88423f91387f89e1 (patch)
treef40dbc74fb973689eda32ec377936f78e636b99e
parent36e5d5e759d32e4987ffbbac70f84978e1893d16 (diff)
Additional trader clean up
-rw-r--r--src/decoration_inventory.c2
-rw-r--r--src/trader.c34
2 files changed, 23 insertions, 13 deletions
diff --git a/src/decoration_inventory.c b/src/decoration_inventory.c
index af1071b1b..c84ee69a4 100644
--- a/src/decoration_inventory.c
+++ b/src/decoration_inventory.c
@@ -33,7 +33,7 @@ static void ClearDecorationInventory(u8 category)
void ClearDecorationInventories(void)
{
u8 category;
- for (category = 0; category < 8; category++)
+ for (category = 0; category < DECORCAT_COUNT; category++)
ClearDecorationInventory(category);
}
diff --git a/src/trader.c b/src/trader.c
index b89ad6043..040ee695b 100644
--- a/src/trader.c
+++ b/src/trader.c
@@ -53,12 +53,22 @@ void Trader_ResetFlag(void)
trader->alreadyTraded = FALSE;
}
+#define tWindowId data[3]
+
void CreateAvailableDecorationsMenu(u8 taskId)
{
u8 i;
s16 * data = gTasks[taskId].data;
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
- struct WindowTemplate windowTemplate = {0, 1, 1, 10, 10, 15, 1};
+ struct WindowTemplate windowTemplate = {
+ .bg = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 1,
+ .width = 10,
+ .height = 10,
+ .paletteNum = 15,
+ .baseBlock = 1
+ };
s32 windowWidth = GetStringWidth(FONT_NORMAL, gText_Exit, 0);
s32 fiveMarksWidth = GetStringWidth(FONT_NORMAL, gText_FiveMarks, 0);
for (i = 0; i < NUM_TRADER_ITEMS; i++)
@@ -72,17 +82,17 @@ void CreateAvailableDecorationsMenu(u8 taskId)
windowWidth = curWidth;
}
windowTemplate.width = ConvertPixelWidthToTileWidth(windowWidth);
- data[3] = AddWindow(&windowTemplate);
- DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14);
+ tWindowId = AddWindow(&windowTemplate);
+ DrawStdFrameWithCustomTileAndPalette(tWindowId, FALSE, 0x214, 14);
for (i = 0; i < NUM_TRADER_ITEMS; i++)
{
if (trader->decorations[i] > NUM_DECORATIONS)
- AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_FiveMarks, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
+ AddTextPrinterParameterized(tWindowId, FONT_NORMAL, gText_FiveMarks, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
else
- AddTextPrinterParameterized(data[3], FONT_NORMAL, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
+ AddTextPrinterParameterized(tWindowId, FONT_NORMAL, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
}
- AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_Exit, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
- InitMenuInUpperLeftCornerNormal(data[3], NUM_TRADER_ITEMS + 1, 0);
+ AddTextPrinterParameterized(tWindowId, FONT_NORMAL, gText_Exit, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
+ InitMenuInUpperLeftCornerNormal(tWindowId, NUM_TRADER_ITEMS + 1, 0);
ScheduleBgCopyTilemapToVram(0);
}
@@ -94,9 +104,9 @@ void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId)
else
gSpecialVar_0x8004 = decorationId;
- ClearStdWindowAndFrameToTransparent(data[3], FALSE);
- ClearWindowTilemap(data[3]);
- RemoveWindow(data[3]);
+ ClearStdWindowAndFrameToTransparent(tWindowId, FALSE);
+ ClearWindowTilemap(tWindowId);
+ RemoveWindow(tWindowId);
ScheduleBgCopyTilemapToVram(0);
DestroyTask(taskId);
EnableBothScriptContexts();
@@ -112,7 +122,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId)
case MENU_NOTHING_CHOSEN:
break;
case MENU_B_PRESSED:
- case NUM_TRADER_ITEMS:
+ case NUM_TRADER_ITEMS: // EXIT
PlaySE(SE_SELECT);
Task_BufferDecorSelectionAndCloseWindow(taskId, 0);
break;
@@ -136,7 +146,7 @@ void DoesPlayerHaveNoDecorations(void)
{
u8 i;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < DECORCAT_COUNT; i++)
{
if (GetNumOwnedDecorationsInCategory(i))
{