mirror of
https://github.com/pret/pokefirered.git
synced 2026-09-30 12:59:43 -05:00
remove buy_menu_helpers
This commit is contained in:
@@ -12,13 +12,4 @@ void CreateDecorationShop2Menu(const u16 *);
|
||||
u8 GetMartFontId(void);
|
||||
void RecordItemTransaction(u16 itemId, u16 quantity, u8 logEventId);
|
||||
|
||||
// buy_menu_helper
|
||||
void BuyMenuInitWindows(bool32 isSellingTM);
|
||||
void BuyMenuDrawMoneyBox(void);
|
||||
void BuyMenuPrint(u8 windowId, u8 font, const u8 *text, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 color);
|
||||
void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback);
|
||||
void BuyMenuQuantityBoxNormalBorder(u8 windowId, bool8 copyToVram);
|
||||
void BuyMenuQuantityBoxThinBorder(u8 windowId, bool8 copyToVram);
|
||||
void BuyMenuConfirmPurchase(u8 taskId, const struct YesNoFuncTable *yesNo);
|
||||
|
||||
#endif // GUARD_SHOP_H
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
#include "window.h"
|
||||
#include "text_window.h"
|
||||
#include "money.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "menu.h"
|
||||
#include "shop.h"
|
||||
#include "palette.h"
|
||||
|
||||
static const struct WindowTemplate sShopBuyMenuWindowTemplatesNormal[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 8,
|
||||
.height = 3,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x27,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 11,
|
||||
.width = 13,
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x3F,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x59,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 17,
|
||||
.tilemapTop = 9,
|
||||
.width = 12,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
.width = 17,
|
||||
.height = 12,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xF1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 5,
|
||||
.tilemapTop = 14,
|
||||
.width = 25,
|
||||
.height = 6,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x1BD,
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE,
|
||||
};
|
||||
|
||||
// firered uses different layout when selling TMs
|
||||
static const struct WindowTemplate sShopBuyMenuWindowTemplatesTM[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 8,
|
||||
.height = 3,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x27,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 11,
|
||||
.width = 13,
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x3F,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x59,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 17,
|
||||
.tilemapTop = 9,
|
||||
.width = 12,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
.width = 17,
|
||||
.height = 10,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xF1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 12,
|
||||
.tilemapTop = 12,
|
||||
.width = 18,
|
||||
.height = 8,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x19B,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 14,
|
||||
.width = 10,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x22B,
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE,
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sShopBuyMenuYesNoWindowTemplate =
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 21,
|
||||
.tilemapTop = 9,
|
||||
.width = 6,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
};
|
||||
|
||||
static const u8 sShopBuyMenuTextColors[][3] =
|
||||
{
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 2}
|
||||
};
|
||||
|
||||
void BuyMenuInitWindows(bool32 isSellingTM)
|
||||
{
|
||||
if (isSellingTM != TRUE)
|
||||
InitWindows(sShopBuyMenuWindowTemplatesNormal);
|
||||
else
|
||||
InitWindows(sShopBuyMenuWindowTemplatesTM);
|
||||
DeactivateAllTextPrinters();
|
||||
LoadUserWindowBorderGfx(0, 0x1, BG_PLTT_ID(13));
|
||||
LoadMessageBoxGfx(0, 0x13, BG_PLTT_ID(14));
|
||||
LoadStdWindowGfx(0, 0xA, BG_PLTT_ID(15));
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(4);
|
||||
PutWindowTilemap(5);
|
||||
if (isSellingTM == TRUE)
|
||||
PutWindowTilemap(6);
|
||||
}
|
||||
|
||||
void BuyMenuDrawMoneyBox(void)
|
||||
{
|
||||
PrintMoneyAmountInMoneyBoxWithBorder(0, 0xA, 0xF, GetMoney(&gSaveBlock1Ptr->money));
|
||||
}
|
||||
|
||||
void BuyMenuPrint(u8 windowId, u8 font, const u8 *text, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 color)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, font, x, y, letterSpacing, lineSpacing, sShopBuyMenuTextColors[color], speed, text);
|
||||
}
|
||||
|
||||
void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback)
|
||||
{
|
||||
DisplayMessageAndContinueTask(taskId, 2, 0x13, 0xE, GetMartFontId(), GetPlayerTextSpeedDelay(), text, callback);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
}
|
||||
|
||||
void BuyMenuQuantityBoxNormalBorder(u8 windowId, bool8 copyToVram)
|
||||
{
|
||||
DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0x1, 13);
|
||||
}
|
||||
|
||||
void BuyMenuQuantityBoxThinBorder(u8 windowId, bool8 copyToVram)
|
||||
{
|
||||
DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0xA, 15);
|
||||
}
|
||||
|
||||
void BuyMenuConfirmPurchase(u8 taskId, const struct YesNoFuncTable *yesNo)
|
||||
{
|
||||
CreateYesNoMenuWithCallbacks(taskId, &sShopBuyMenuYesNoWindowTemplate, FONT_NORMAL, 0, 2, 1, 13, yesNo);
|
||||
}
|
||||
232
src/shop.c
232
src/shop.c
@@ -25,6 +25,7 @@
|
||||
#include "money.h"
|
||||
#include "quest_log.h"
|
||||
#include "script.h"
|
||||
#include "text_window.h"
|
||||
#include "constants/field_weather.h"
|
||||
#include "constants/game_stat.h"
|
||||
#include "constants/item_menu.h"
|
||||
@@ -137,6 +138,12 @@ static void Task_ExitBuyMenu(u8 taskId);
|
||||
static void DebugFunc_PrintPurchaseDetails(u8 taskId);
|
||||
static void DebugFunc_PrintShopMenuHistoryBeforeClearMaybe(void);
|
||||
static void RecordTransactionForQuestLog(void);
|
||||
static void BuyMenuInitWindows(bool32 isSellingTM);
|
||||
static void BuyMenuPrint(u8 windowId, u8 font, const u8 *text, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 color);
|
||||
static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback);
|
||||
static void BuyMenuQuantityBoxNormalBorder(u8 windowId, bool8 copyToVram);
|
||||
static void BuyMenuQuantityBoxThinBorder(u8 windowId, bool8 copyToVram);
|
||||
static void BuyMenuConfirmPurchase(u8 taskId, const struct YesNoFuncTable *yesNo);
|
||||
|
||||
static const struct MenuAction sShopMenuActions_BuySellQuit[] =
|
||||
{
|
||||
@@ -202,6 +209,152 @@ static const struct BgTemplate sShopBuyMenuBgTemplates[4] =
|
||||
}
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sShopBuyMenuWindowTemplatesNormal[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 8,
|
||||
.height = 3,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x27,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 11,
|
||||
.width = 13,
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x3F,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x59,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 17,
|
||||
.tilemapTop = 9,
|
||||
.width = 12,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
.width = 17,
|
||||
.height = 12,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xF1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 5,
|
||||
.tilemapTop = 14,
|
||||
.width = 25,
|
||||
.height = 6,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x1BD,
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE,
|
||||
};
|
||||
|
||||
// firered uses different layout when selling TMs
|
||||
static const struct WindowTemplate sShopBuyMenuWindowTemplatesTM[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
.width = 8,
|
||||
.height = 3,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x27,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 11,
|
||||
.width = 13,
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x3F,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
.width = 26,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x59,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 17,
|
||||
.tilemapTop = 9,
|
||||
.width = 12,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
.width = 17,
|
||||
.height = 10,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xF1,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 12,
|
||||
.tilemapTop = 12,
|
||||
.width = 18,
|
||||
.height = 8,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x19B,
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 14,
|
||||
.width = 10,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0x22B,
|
||||
},
|
||||
DUMMY_WIN_TEMPLATE,
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sShopBuyMenuYesNoWindowTemplate =
|
||||
{
|
||||
.bg = 0,
|
||||
.tilemapLeft = 21,
|
||||
.tilemapTop = 9,
|
||||
.width = 6,
|
||||
.height = 4,
|
||||
.paletteNum = 14,
|
||||
.baseBlock = 0xC1,
|
||||
};
|
||||
|
||||
static const u8 sShopBuyMenuTextColors[][3] =
|
||||
{
|
||||
{0, 1, 2},
|
||||
{0, 2, 3},
|
||||
{0, 3, 2}
|
||||
};
|
||||
|
||||
// Functions
|
||||
static u8 CreateShopMenu(u8 martType)
|
||||
{
|
||||
@@ -470,6 +623,67 @@ static void BuyMenuDecompressBgGraphics(void)
|
||||
Free(pal);
|
||||
}
|
||||
|
||||
static void BuyMenuInitWindows(bool32 isSellingTM)
|
||||
{
|
||||
if (isSellingTM != TRUE)
|
||||
InitWindows(sShopBuyMenuWindowTemplatesNormal);
|
||||
else
|
||||
InitWindows(sShopBuyMenuWindowTemplatesTM);
|
||||
DeactivateAllTextPrinters();
|
||||
LoadUserWindowBorderGfx(0, 0x1, BG_PLTT_ID(13));
|
||||
LoadMessageBoxGfx(0, 0x13, BG_PLTT_ID(14));
|
||||
LoadStdWindowGfx(0, 0xA, BG_PLTT_ID(15));
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(4);
|
||||
PutWindowTilemap(5);
|
||||
if (isSellingTM == TRUE)
|
||||
PutWindowTilemap(6);
|
||||
}
|
||||
|
||||
static void BuyMenuPrint(u8 windowId, u8 font, const u8 *text, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 color)
|
||||
{
|
||||
AddTextPrinterParameterized4(windowId, font, x, y, letterSpacing, lineSpacing, sShopBuyMenuTextColors[color], speed, text);
|
||||
}
|
||||
|
||||
static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback)
|
||||
{
|
||||
DisplayMessageAndContinueTask(taskId, 2, 0x13, 0xE, GetMartFontId(), GetPlayerTextSpeedDelay(), text, callback);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
}
|
||||
|
||||
static void BuyMenuDrawGraphics(void)
|
||||
{
|
||||
BuyMenuDrawMapView();
|
||||
BuyMenuCopyTilemapData();
|
||||
PrintMoneyAmountInMoneyBoxWithBorder(0, 0xA, 0xF, GetMoney(&gSaveBlock1Ptr->money));
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
ScheduleBgCopyTilemapToVram(1);
|
||||
ScheduleBgCopyTilemapToVram(2);
|
||||
ScheduleBgCopyTilemapToVram(3);
|
||||
}
|
||||
|
||||
static void BuyMenuDrawMapView(void)
|
||||
{
|
||||
BuyMenuCollectObjectEventData();
|
||||
BuyMenuDrawObjectEvents();
|
||||
BuyMenuDrawMapBg();
|
||||
}
|
||||
|
||||
static void BuyMenuQuantityBoxNormalBorder(u8 windowId, bool8 copyToVram)
|
||||
{
|
||||
DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0x1, 13);
|
||||
}
|
||||
|
||||
static void BuyMenuQuantityBoxThinBorder(u8 windowId, bool8 copyToVram)
|
||||
{
|
||||
DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, 0xA, 15);
|
||||
}
|
||||
|
||||
static void BuyMenuConfirmPurchase(u8 taskId, const struct YesNoFuncTable *yesNo)
|
||||
{
|
||||
CreateYesNoMenuWithCallbacks(taskId, &sShopBuyMenuYesNoWindowTemplate, FONT_NORMAL, 0, 2, 1, 13, yesNo);
|
||||
}
|
||||
|
||||
static void RecolorItemDescriptionBox(bool32 a0)
|
||||
{
|
||||
u8 paletteNum;
|
||||
@@ -487,17 +701,6 @@ static void RecolorItemDescriptionBox(bool32 a0)
|
||||
ScheduleBgCopyTilemapToVram(1);
|
||||
}
|
||||
|
||||
static void BuyMenuDrawGraphics(void)
|
||||
{
|
||||
BuyMenuDrawMapView();
|
||||
BuyMenuCopyTilemapData();
|
||||
BuyMenuDrawMoneyBox();
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
ScheduleBgCopyTilemapToVram(1);
|
||||
ScheduleBgCopyTilemapToVram(2);
|
||||
ScheduleBgCopyTilemapToVram(3);
|
||||
}
|
||||
|
||||
bool8 BuyMenuBuildListMenuTemplate(void)
|
||||
{
|
||||
u16 i, v;
|
||||
@@ -706,13 +909,6 @@ static void BuyMenuRemoveScrollIndicatorArrows(void)
|
||||
sShopData.unk16_11 = 0x1F;
|
||||
}
|
||||
|
||||
static void BuyMenuDrawMapView(void)
|
||||
{
|
||||
BuyMenuCollectObjectEventData();
|
||||
BuyMenuDrawObjectEvents();
|
||||
BuyMenuDrawMapBg();
|
||||
}
|
||||
|
||||
static void BuyMenuDrawMapBg(void)
|
||||
{
|
||||
s16 i, j, x, y;
|
||||
|
||||
Reference in New Issue
Block a user