Additional trader clean up
This commit is contained in:
@@ -33,7 +33,7 @@ static void ClearDecorationInventory(u8 category)
|
|||||||
void ClearDecorationInventories(void)
|
void ClearDecorationInventories(void)
|
||||||
{
|
{
|
||||||
u8 category;
|
u8 category;
|
||||||
for (category = 0; category < 8; category++)
|
for (category = 0; category < DECORCAT_COUNT; category++)
|
||||||
ClearDecorationInventory(category);
|
ClearDecorationInventory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-12
@@ -53,12 +53,22 @@ void Trader_ResetFlag(void)
|
|||||||
trader->alreadyTraded = FALSE;
|
trader->alreadyTraded = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define tWindowId data[3]
|
||||||
|
|
||||||
void CreateAvailableDecorationsMenu(u8 taskId)
|
void CreateAvailableDecorationsMenu(u8 taskId)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
s16 * data = gTasks[taskId].data;
|
s16 * data = gTasks[taskId].data;
|
||||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
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 windowWidth = GetStringWidth(FONT_NORMAL, gText_Exit, 0);
|
||||||
s32 fiveMarksWidth = GetStringWidth(FONT_NORMAL, gText_FiveMarks, 0);
|
s32 fiveMarksWidth = GetStringWidth(FONT_NORMAL, gText_FiveMarks, 0);
|
||||||
for (i = 0; i < NUM_TRADER_ITEMS; i++)
|
for (i = 0; i < NUM_TRADER_ITEMS; i++)
|
||||||
@@ -72,17 +82,17 @@ void CreateAvailableDecorationsMenu(u8 taskId)
|
|||||||
windowWidth = curWidth;
|
windowWidth = curWidth;
|
||||||
}
|
}
|
||||||
windowTemplate.width = ConvertPixelWidthToTileWidth(windowWidth);
|
windowTemplate.width = ConvertPixelWidthToTileWidth(windowWidth);
|
||||||
data[3] = AddWindow(&windowTemplate);
|
tWindowId = AddWindow(&windowTemplate);
|
||||||
DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14);
|
DrawStdFrameWithCustomTileAndPalette(tWindowId, FALSE, 0x214, 14);
|
||||||
for (i = 0; i < NUM_TRADER_ITEMS; i++)
|
for (i = 0; i < NUM_TRADER_ITEMS; i++)
|
||||||
{
|
{
|
||||||
if (trader->decorations[i] > NUM_DECORATIONS)
|
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
|
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);
|
AddTextPrinterParameterized(tWindowId, FONT_NORMAL, gText_Exit, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL);
|
||||||
InitMenuInUpperLeftCornerNormal(data[3], NUM_TRADER_ITEMS + 1, 0);
|
InitMenuInUpperLeftCornerNormal(tWindowId, NUM_TRADER_ITEMS + 1, 0);
|
||||||
ScheduleBgCopyTilemapToVram(0);
|
ScheduleBgCopyTilemapToVram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,9 +104,9 @@ void Task_BufferDecorSelectionAndCloseWindow(u8 taskId, u8 decorationId)
|
|||||||
else
|
else
|
||||||
gSpecialVar_0x8004 = decorationId;
|
gSpecialVar_0x8004 = decorationId;
|
||||||
|
|
||||||
ClearStdWindowAndFrameToTransparent(data[3], FALSE);
|
ClearStdWindowAndFrameToTransparent(tWindowId, FALSE);
|
||||||
ClearWindowTilemap(data[3]);
|
ClearWindowTilemap(tWindowId);
|
||||||
RemoveWindow(data[3]);
|
RemoveWindow(tWindowId);
|
||||||
ScheduleBgCopyTilemapToVram(0);
|
ScheduleBgCopyTilemapToVram(0);
|
||||||
DestroyTask(taskId);
|
DestroyTask(taskId);
|
||||||
EnableBothScriptContexts();
|
EnableBothScriptContexts();
|
||||||
@@ -112,7 +122,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId)
|
|||||||
case MENU_NOTHING_CHOSEN:
|
case MENU_NOTHING_CHOSEN:
|
||||||
break;
|
break;
|
||||||
case MENU_B_PRESSED:
|
case MENU_B_PRESSED:
|
||||||
case NUM_TRADER_ITEMS:
|
case NUM_TRADER_ITEMS: // EXIT
|
||||||
PlaySE(SE_SELECT);
|
PlaySE(SE_SELECT);
|
||||||
Task_BufferDecorSelectionAndCloseWindow(taskId, 0);
|
Task_BufferDecorSelectionAndCloseWindow(taskId, 0);
|
||||||
break;
|
break;
|
||||||
@@ -136,7 +146,7 @@ void DoesPlayerHaveNoDecorations(void)
|
|||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < DECORCAT_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (GetNumOwnedDecorationsInCategory(i))
|
if (GetNumOwnedDecorationsInCategory(i))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user