mirror of
https://github.com/pret/pokefirered.git
synced 2026-09-08 09:25:28 -05:00
Merge 46820ff292 into df4449a27c
This commit is contained in:
@@ -3,6 +3,18 @@
|
||||
|
||||
#include "menu_helpers.h"
|
||||
|
||||
// windowIds
|
||||
#define BAG_WIN_ITEMS_ID 0 // central main list window
|
||||
#define BAG_WIN_MAIN_MSG_ID 1 // bottom MSG box
|
||||
#define BAG_WIN_TITLE_ID 2 // top left pocket title
|
||||
|
||||
// whichWindow
|
||||
#define BAG_WIN_CHOOSE_QUANTITY 0 // bottom right corner
|
||||
#define BAG_WIN_MONEY 2 // top left corner
|
||||
#define BAG_WIN_MSG_FULL 5 // full MSG box
|
||||
#define BAG_WIN_MSG 6 // MSG box width 14 (spares icon bottom left corner)
|
||||
#define BAG_WIN_CONTEXT 10 // context menu with 1 element
|
||||
|
||||
void InitBagWindows(void);
|
||||
void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx);
|
||||
void BagPrintTextOnWin1CenteredColor0(const u8 * str, u8 unused);
|
||||
|
||||
72
src/bag.c
72
src/bag.c
@@ -7,6 +7,7 @@
|
||||
#include "menu.h"
|
||||
#include "money.h"
|
||||
#include "strings.h"
|
||||
#include "bag.h"
|
||||
|
||||
static const u16 sBagWindowPalF[] = INCBIN_U16("graphics/item_menu/bag_window_pal.gbapal");
|
||||
|
||||
@@ -18,7 +19,7 @@ static const u8 sTextColors[][3] = {
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sDefaultBagWindowsStd[] = {
|
||||
{
|
||||
[BAG_WIN_ITEMS_ID] = { // central main list window
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
@@ -26,7 +27,8 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = {
|
||||
.height = 12,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x008a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box
|
||||
.bg = 0,
|
||||
.tilemapLeft = 5,
|
||||
.tilemapTop = 14,
|
||||
@@ -34,7 +36,8 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = {
|
||||
.height = 6,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x0162
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_TITLE_ID] = { // top left pocket title
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
@@ -46,7 +49,7 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = {
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
|
||||
{
|
||||
[BAG_WIN_ITEMS_ID] = { // central main list window
|
||||
.bg = 0,
|
||||
.tilemapLeft = 11,
|
||||
.tilemapTop = 1,
|
||||
@@ -54,7 +57,8 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
|
||||
.height = 12,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x008a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box
|
||||
.bg = 0,
|
||||
.tilemapLeft = 5,
|
||||
.tilemapTop = 14,
|
||||
@@ -62,7 +66,8 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
|
||||
.height = 6,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x0162
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_TITLE_ID] = { // top left pocket title
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
@@ -74,7 +79,7 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sWindowTemplates[] = {
|
||||
{
|
||||
[BAG_WIN_CHOOSE_QUANTITY] = { // bottom right corner
|
||||
.bg = 0,
|
||||
.tilemapLeft = 24,
|
||||
.tilemapTop = 15,
|
||||
@@ -82,7 +87,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x242
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_CHOOSE_QUANTITY + 1] = { // popup when buying or selling quantities
|
||||
.bg = 0,
|
||||
.tilemapLeft = 17,
|
||||
.tilemapTop = 9,
|
||||
@@ -90,7 +96,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x242
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MONEY] = { // top left corner
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 1,
|
||||
@@ -98,7 +105,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 3,
|
||||
.paletteNum = 12,
|
||||
.baseBlock = 0x272
|
||||
}, {
|
||||
},
|
||||
[3] = { // unused
|
||||
.bg = 0,
|
||||
.tilemapLeft = 23,
|
||||
.tilemapTop = 15,
|
||||
@@ -106,7 +114,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x28a
|
||||
}, {
|
||||
},
|
||||
[4] = { // unused
|
||||
.bg = 0,
|
||||
.tilemapLeft = 21,
|
||||
.tilemapTop = 9,
|
||||
@@ -114,7 +123,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x28a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MSG_FULL] = { // whole MSG box
|
||||
.bg = 0,
|
||||
.tilemapLeft = 2,
|
||||
.tilemapTop = 15,
|
||||
@@ -122,7 +132,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x2a2
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MSG] = { // MSG box width 14 (spares icon bottom left corner)
|
||||
.bg = 0,
|
||||
.tilemapLeft = 6,
|
||||
.tilemapTop = 15,
|
||||
@@ -130,7 +141,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 12,
|
||||
.baseBlock = 0x2a2
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MSG + 1] = { // MSG box width 15
|
||||
.bg = 0,
|
||||
.tilemapLeft = 6,
|
||||
.tilemapTop = 15,
|
||||
@@ -138,7 +150,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 12,
|
||||
.baseBlock = 0x2da
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MSG + 2] = { // MSG box width 16
|
||||
.bg = 0,
|
||||
.tilemapLeft = 6,
|
||||
.tilemapTop = 15,
|
||||
@@ -146,7 +159,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 12,
|
||||
.baseBlock = 0x316
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_MSG + 3] = { // MSG box width 23
|
||||
.bg = 0,
|
||||
.tilemapLeft = 6,
|
||||
.tilemapTop = 15,
|
||||
@@ -154,7 +168,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 12,
|
||||
.baseBlock = 0x356
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_CONTEXT] = { // context menu with 1 element
|
||||
.bg = 0,
|
||||
.tilemapLeft = 22,
|
||||
.tilemapTop = 17,
|
||||
@@ -162,7 +177,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 2,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x20a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_CONTEXT + 1] = { // context menu with 2 elements
|
||||
.bg = 0,
|
||||
.tilemapLeft = 22,
|
||||
.tilemapTop = 15,
|
||||
@@ -170,7 +186,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 4,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x20a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_CONTEXT + 2] = { // context menu with 3 elements
|
||||
.bg = 0,
|
||||
.tilemapLeft = 22,
|
||||
.tilemapTop = 13,
|
||||
@@ -178,7 +195,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
|
||||
.height = 6,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x20a
|
||||
}, {
|
||||
},
|
||||
[BAG_WIN_CONTEXT + 3] = { // context menu with 4 elements
|
||||
.bg = 0,
|
||||
.tilemapLeft = 22,
|
||||
.tilemapTop = 11,
|
||||
@@ -214,7 +232,7 @@ void InitBagWindows(void)
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
sOpenWindows[i] = 0xFF;
|
||||
sOpenWindows[i] = WINDOW_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +257,7 @@ void BagDrawDepositItemTextBox(void)
|
||||
|
||||
u8 ShowBagWindow(u8 whichWindow, u8 nItems)
|
||||
{
|
||||
if (sOpenWindows[whichWindow] == 0xFF)
|
||||
if (sOpenWindows[whichWindow] == WINDOW_NONE)
|
||||
{
|
||||
sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow + nItems]);
|
||||
if (whichWindow != 6)
|
||||
@@ -261,12 +279,12 @@ void HideBagWindow(u8 whichWindow)
|
||||
ClearWindowTilemap(sOpenWindows[whichWindow]);
|
||||
RemoveWindow(sOpenWindows[whichWindow]);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
sOpenWindows[whichWindow] = 0xFF;
|
||||
sOpenWindows[whichWindow] = WINDOW_NONE;
|
||||
}
|
||||
|
||||
u8 OpenBagWindow(u8 whichWindow)
|
||||
{
|
||||
if (sOpenWindows[whichWindow] == 0xFF)
|
||||
if (sOpenWindows[whichWindow] == WINDOW_NONE)
|
||||
{
|
||||
sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow]);
|
||||
}
|
||||
@@ -275,14 +293,14 @@ u8 OpenBagWindow(u8 whichWindow)
|
||||
|
||||
void CloseBagWindow(u8 whichWindow)
|
||||
{
|
||||
if (sOpenWindows[whichWindow] != 0xFF)
|
||||
if (sOpenWindows[whichWindow] != WINDOW_NONE)
|
||||
{
|
||||
ClearDialogWindowAndFrameToTransparent(sOpenWindows[whichWindow], FALSE);
|
||||
ClearWindowTilemap(sOpenWindows[whichWindow]);
|
||||
RemoveWindow(sOpenWindows[whichWindow]);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
sOpenWindows[whichWindow] = 0xFF;
|
||||
sOpenWindows[whichWindow] = WINDOW_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +321,7 @@ void BagCreateYesNoMenuTopRight(u8 taskId, const struct YesNoFuncTable * ptrs)
|
||||
|
||||
void BagPrintMoneyAmount(void)
|
||||
{
|
||||
PrintMoneyAmountInMoneyBoxWithBorder(ShowBagWindow(2, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money));
|
||||
PrintMoneyAmountInMoneyBoxWithBorder(ShowBagWindow(BAG_WIN_MONEY, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money));
|
||||
}
|
||||
|
||||
void BagDrawTextBoxOnWindow(u8 windowId)
|
||||
|
||||
140
src/item_menu.c
140
src/item_menu.c
@@ -735,7 +735,7 @@ static void bag_menu_print_cursor(u8 y, u8 colorIdx)
|
||||
}
|
||||
else
|
||||
{
|
||||
BagPrintTextOnWindow(0, FONT_NORMAL, gText_SelectorArrow2, 1, y, 0, 0, 0, colorIdx);
|
||||
BagPrintTextOnWindow(BAG_WIN_ITEMS_ID, FONT_NORMAL, gText_SelectorArrow2, 1, y, 0, 0, 0, colorIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ static void PrintItemDescriptionOnMessageWindow(s32 itemIndex)
|
||||
else
|
||||
description = gText_CloseBag;
|
||||
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
||||
BagPrintTextOnWindow(1, FONT_NORMAL, description, 0, 3, 2, 0, 0, 0);
|
||||
BagPrintTextOnWindow(BAG_WIN_MAIN_MSG_ID, FONT_NORMAL, description, 0, 3, 2, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void CreatePocketScrollArrowPair(void)
|
||||
@@ -1018,7 +1018,7 @@ static void All_CalculateNItemsAndMaxShowed(void)
|
||||
void DisplayItemMessageInBag(u8 taskId, u8 fontId, const u8 * string, TaskFunc followUpFunc)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
data[10] = OpenBagWindow(5);
|
||||
data[10] = OpenBagWindow(BAG_WIN_MSG_FULL);
|
||||
FillWindowPixelBuffer(data[10], PIXEL_FILL(1));
|
||||
DisplayMessageAndContinueTask(taskId, data[10], 0x06D, 0x0D, fontId, GetTextSpeedSetting(), string, followUpFunc);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
@@ -1226,7 +1226,7 @@ static void BeginMovingItemInPocket(u8 taskId, s16 itemIndex)
|
||||
StringCopy(gStringVar1, ItemId_GetName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])));
|
||||
StringExpandPlaceholders(gStringVar4, gOtherText_WhereShouldTheStrVar1BePlaced);
|
||||
FillWindowPixelBuffer(1, PIXEL_FILL(0));
|
||||
BagPrintTextOnWindow(1, FONT_NORMAL, gStringVar4, 0, 3, 2, 0, 0, 0);
|
||||
BagPrintTextOnWindow(BAG_WIN_MAIN_MSG_ID, FONT_NORMAL, gStringVar4, 0, 3, 2, 0, 0, 0);
|
||||
UpdateSwapLinePos(0, ListMenuGetYCoordForPrintingArrowCursor(data[0]));
|
||||
SetSwapLineInvisibility(FALSE);
|
||||
BagDestroyPocketSwitchArrowPair();
|
||||
@@ -1307,25 +1307,25 @@ static void AbortMovingItemInPocket(u8 taskId, u32 itemIndex)
|
||||
|
||||
static void InitQuantityToTossOrDeposit(u16 cursorPos, const u8 *str)
|
||||
{
|
||||
u8 r4;
|
||||
u8 r5 = ShowBagWindow(6, 2);
|
||||
u8 bagQuantityWinId;
|
||||
u8 bagMSGWinId = ShowBagWindow(BAG_WIN_MSG, 2);
|
||||
CopyItemName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, cursorPos), gStringVar1);
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
BagPrintTextOnWindow(r5, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
r4 = ShowBagWindow(0, 0);
|
||||
BagPrintTextOnWindow(bagMSGWinId, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
bagQuantityWinId = ShowBagWindow(BAG_WIN_CHOOSE_QUANTITY, 0);
|
||||
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 3);
|
||||
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
|
||||
BagPrintTextOnWindow(r4, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1);
|
||||
CreateArrowPair_QuantitySelect();
|
||||
}
|
||||
|
||||
static void UpdateQuantityToTossOrDeposit(s16 value, u8 ndigits)
|
||||
{
|
||||
u8 r6 = GetBagWindow(0);
|
||||
FillWindowPixelBuffer(r6, PIXEL_FILL(1));
|
||||
u8 bagQuantityWinId = GetBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
FillWindowPixelBuffer(bagQuantityWinId, PIXEL_FILL(1));
|
||||
ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEADING_ZEROS, ndigits);
|
||||
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
|
||||
BagPrintTextOnWindow(r6, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0, 1);
|
||||
}
|
||||
|
||||
// row of 0 is the bottom row in the list, up to LIST_TILES_HEIGHT at the top
|
||||
@@ -1337,8 +1337,8 @@ static void DrawItemListRow(u8 row)
|
||||
|
||||
static void OpenContextMenu(u8 taskId)
|
||||
{
|
||||
u8 r6;
|
||||
u8 r4;
|
||||
u8 bagContextWinId;
|
||||
u8 bagMSGWinId;
|
||||
switch (gBagMenuState.location)
|
||||
{
|
||||
case ITEMMENULOCATION_BATTLE:
|
||||
@@ -1416,9 +1416,9 @@ static void OpenContextMenu(u8 taskId)
|
||||
}
|
||||
}
|
||||
}
|
||||
r6 = ShowBagWindow(10, sContextMenuNumItems - 1);
|
||||
bagContextWinId = ShowBagWindow(BAG_WIN_CONTEXT, sContextMenuNumItems - 1);
|
||||
AddItemMenuActionTextPrinters(
|
||||
r6,
|
||||
bagContextWinId,
|
||||
FONT_NORMAL,
|
||||
GetMenuCursorDimensionByFont(FONT_NORMAL, 0),
|
||||
2,
|
||||
@@ -1428,11 +1428,11 @@ static void OpenContextMenu(u8 taskId)
|
||||
sItemMenuContextActions,
|
||||
sContextMenuItemsPtr
|
||||
);
|
||||
Menu_InitCursor(r6, FONT_NORMAL, 0, 2, GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_HEIGHT) + 2, sContextMenuNumItems, 0);
|
||||
r4 = ShowBagWindow(6, 0);
|
||||
Menu_InitCursor(bagContextWinId, FONT_NORMAL, 0, 2, GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_HEIGHT) + 2, sContextMenuNumItems, 0);
|
||||
bagMSGWinId = ShowBagWindow(BAG_WIN_MSG, 0);
|
||||
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
||||
StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected);
|
||||
BagPrintTextOnWindow(r4, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(bagMSGWinId, FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
}
|
||||
|
||||
static void Task_ItemContext_FieldOrBattle(u8 taskId)
|
||||
@@ -1467,8 +1467,8 @@ static void Task_ItemMenuAction_Use(u8 taskId)
|
||||
{
|
||||
if (ItemId_GetFieldFunc(gSpecialVar_ItemId) != NULL)
|
||||
{
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
@@ -1482,10 +1482,10 @@ static void Task_ItemMenuAction_Use(u8 taskId)
|
||||
static void Task_ItemMenuAction_Toss(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
ClearWindowTilemap(GetBagWindow(10));
|
||||
ClearWindowTilemap(GetBagWindow(6));
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
ClearWindowTilemap(GetBagWindow(BAG_WIN_CONTEXT));
|
||||
ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG));
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
data[8] = 1;
|
||||
if (data[2] == 1)
|
||||
@@ -1504,14 +1504,14 @@ static void Task_ConfirmTossItems(u8 taskId)
|
||||
s16 *data = gTasks[taskId].data;
|
||||
ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
StringExpandPlaceholders(gStringVar4, gText_ThrowAwayStrVar2OfThisItemQM);
|
||||
BagPrintTextOnWindow(ShowBagWindow(6, 1), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 1), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
BagCreateYesNoMenuBottomRight(taskId, &sYesNoMenu_Toss);
|
||||
}
|
||||
|
||||
static void Task_TossItem_No(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
bag_menu_print_cursor_(data[0], 1);
|
||||
@@ -1528,9 +1528,9 @@ static void Task_SelectQuantityToToss(u8 taskId)
|
||||
else if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ClearWindowTilemap(GetBagWindow(6));
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(0);
|
||||
ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG));
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
BagDestroyPocketScrollArrowPair();
|
||||
Task_ConfirmTossItems(taskId);
|
||||
@@ -1538,8 +1538,8 @@ static void Task_SelectQuantityToToss(u8 taskId)
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(0);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
@@ -1552,11 +1552,11 @@ static void Task_SelectQuantityToToss(u8 taskId)
|
||||
static void Task_TossItem_Yes(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
CopyItemName(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1]), gStringVar1);
|
||||
ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
StringExpandPlaceholders(gStringVar4, gText_ThrewAwayStrVar2StrVar1s);
|
||||
BagPrintTextOnWindow(ShowBagWindow(6, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
gTasks[taskId].func = Task_WaitAB_RedrawAndReturnToBag;
|
||||
}
|
||||
|
||||
@@ -1567,7 +1567,7 @@ static void Task_WaitAB_RedrawAndReturnToBag(u8 taskId)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
RemoveBagItem(gSpecialVar_ItemId, data[8]);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]);
|
||||
Pocket_CalculateNItemsAndMaxShowed(gBagMenuState.pocket);
|
||||
PocketCalculateInitialCursorPosAndItemsAbove(gBagMenuState.pocket);
|
||||
@@ -1601,8 +1601,8 @@ static void Task_ItemMenuAction_Give(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
u16 itemId = BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1]);
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
@@ -1648,7 +1648,7 @@ static void Task_WaitAButtonAndCloseContextMenu(u8 taskId)
|
||||
void Task_ReturnToBagFromContextMenu(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
CloseBagWindow(5);
|
||||
CloseBagWindow(BAG_WIN_MSG_FULL);
|
||||
DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]);
|
||||
Pocket_CalculateNItemsAndMaxShowed(gBagMenuState.pocket);
|
||||
PocketCalculateInitialCursorPosAndItemsAbove(gBagMenuState.pocket);
|
||||
@@ -1674,8 +1674,8 @@ static void Task_UnusedReturnToBag(u8 taskId)
|
||||
|
||||
static void Task_ItemMenuAction_Cancel(u8 taskId)
|
||||
{
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
@@ -1687,8 +1687,8 @@ static void Task_ItemMenuAction_BattleUse(u8 taskId)
|
||||
{
|
||||
if (ItemId_GetBattleFunc(gSpecialVar_ItemId) != NULL)
|
||||
{
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
@@ -1853,8 +1853,8 @@ static void Task_ShowSellYesNoMenu(u8 taskId)
|
||||
static void Task_SellItem_No(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
HideBagWindow(2);
|
||||
CloseBagWindow(5);
|
||||
HideBagWindow(BAG_WIN_MONEY);
|
||||
CloseBagWindow(BAG_WIN_MSG_FULL);
|
||||
PutWindowTilemap(2);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
@@ -1866,10 +1866,10 @@ static void Task_SellItem_No(u8 taskId)
|
||||
static void Task_InitSaleQuantitySelectInterface(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
u8 r4 = ShowBagWindow(0, 1);
|
||||
u8 bagQuantityWinId = ShowBagWindow(BAG_WIN_CHOOSE_QUANTITY, 1);
|
||||
ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
StringExpandPlaceholders(gStringVar4, gText_TimesStrVar1);
|
||||
BagPrintTextOnWindow(r4, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0xFF, 1);
|
||||
BagPrintTextOnWindow(bagQuantityWinId, FONT_SMALL, gStringVar4, 4, 10, 1, 0, 0xFF, 1);
|
||||
UpdateSalePriceDisplay(ItemId_GetPrice(BagGetItemIdByPocketPosition(gBagMenuState.pocket + 1, data[1])) / 2 * data[8]);
|
||||
BagPrintMoneyAmount();
|
||||
CreatePocketScrollArrowPair_SellQuantity();
|
||||
@@ -1878,7 +1878,7 @@ static void Task_InitSaleQuantitySelectInterface(u8 taskId)
|
||||
|
||||
static void UpdateSalePriceDisplay(s32 amount)
|
||||
{
|
||||
PrintMoneyAmount(GetBagWindow(0), 56, 10, amount, 0);
|
||||
PrintMoneyAmount(GetBagWindow(BAG_WIN_CHOOSE_QUANTITY), 56, 10, amount, 0);
|
||||
}
|
||||
|
||||
static void Task_SelectQuantityToSell(u8 taskId)
|
||||
@@ -1892,7 +1892,7 @@ static void Task_SelectQuantityToSell(u8 taskId)
|
||||
else if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(0);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
PutWindowTilemap(0);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
BagDestroyPocketScrollArrowPair();
|
||||
@@ -1901,9 +1901,9 @@ static void Task_SelectQuantityToSell(u8 taskId)
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(0);
|
||||
HideBagWindow(2);
|
||||
CloseBagWindow(5);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
HideBagWindow(BAG_WIN_MONEY);
|
||||
CloseBagWindow(BAG_WIN_MSG_FULL);
|
||||
PutWindowTilemap(2);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
@@ -1939,8 +1939,8 @@ static void Task_FinalizeSaleToShop(u8 taskId)
|
||||
Bag_BuildListMenuTemplate(gBagMenuState.pocket);
|
||||
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gBagMenuState.cursorPos[gBagMenuState.pocket], gBagMenuState.itemsAbove[gBagMenuState.pocket]);
|
||||
bag_menu_print_cursor_(data[0], 2);
|
||||
BagDrawTextBoxOnWindow(GetBagWindow(2));
|
||||
PrintMoneyAmountInMoneyBox(GetBagWindow(2), GetMoney(&gSaveBlock1Ptr->money), 0);
|
||||
BagDrawTextBoxOnWindow(GetBagWindow(BAG_WIN_MONEY));
|
||||
PrintMoneyAmountInMoneyBox(GetBagWindow(BAG_WIN_MONEY), GetMoney(&gSaveBlock1Ptr->money), 0);
|
||||
gTasks[taskId].func = Task_WaitPressAB_AfterSell;
|
||||
}
|
||||
|
||||
@@ -1949,7 +1949,7 @@ static void Task_WaitPressAB_AfterSell(u8 taskId)
|
||||
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(2);
|
||||
HideBagWindow(BAG_WIN_MONEY);
|
||||
PutWindowTilemap(2);
|
||||
sBagMenuDisplay->inhibitItemDescriptionPrint = FALSE;
|
||||
Task_ReturnToBagFromContextMenu(taskId);
|
||||
@@ -1981,9 +1981,9 @@ static void Task_SelectQuantityToDeposit(u8 taskId)
|
||||
else if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
ClearWindowTilemap(GetBagWindow(6));
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(0);
|
||||
ClearWindowTilemap(GetBagWindow(BAG_WIN_MSG));
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
BagDestroyPocketScrollArrowPair();
|
||||
Task_TryDoItemDeposit(taskId);
|
||||
@@ -1991,8 +1991,8 @@ static void Task_SelectQuantityToDeposit(u8 taskId)
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(0);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
HideBagWindow(BAG_WIN_CHOOSE_QUANTITY);
|
||||
PutWindowTilemap(1);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
bag_menu_print_cursor_(data[0], 1);
|
||||
@@ -2010,7 +2010,7 @@ static void Task_TryDoItemDeposit(u8 taskId)
|
||||
CopyItemName(gSpecialVar_ItemId, gStringVar1);
|
||||
ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
StringExpandPlaceholders(gStringVar4, gText_DepositedStrVar2StrVar1s);
|
||||
BagPrintTextOnWindow(ShowBagWindow(6, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
BagPrintTextOnWindow(ShowBagWindow(BAG_WIN_MSG, 3), FONT_NORMAL, gStringVar4, 0, 2, 1, 0, 0, 1);
|
||||
gTasks[taskId].func = Task_WaitAB_RedrawAndReturnToBag;
|
||||
}
|
||||
else
|
||||
@@ -2124,8 +2124,8 @@ static void Task_Bag_OldManTutorial(u8 taskId)
|
||||
break;
|
||||
case 408:
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
@@ -2230,8 +2230,8 @@ static void Task_Bag_TeachyTvRegister(u8 taskId)
|
||||
case 408:
|
||||
PlaySE(SE_SELECT);
|
||||
gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId;
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
DestroyListMenuTask(data[0], &gBagMenuState.cursorPos[gBagMenuState.pocket], &gBagMenuState.itemsAbove[gBagMenuState.pocket]);
|
||||
@@ -2298,8 +2298,8 @@ static void Task_Bag_TeachyTvCatching(u8 taskId)
|
||||
break;
|
||||
case 816:
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
@@ -2340,8 +2340,8 @@ static void Task_Bag_TeachyTvStatus(u8 taskId)
|
||||
break;
|
||||
case 306:
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
@@ -2381,8 +2381,8 @@ static void Task_Bag_TeachyTvTMs(u8 taskId)
|
||||
break;
|
||||
case 408:
|
||||
PlaySE(SE_SELECT);
|
||||
HideBagWindow(10);
|
||||
HideBagWindow(6);
|
||||
HideBagWindow(BAG_WIN_CONTEXT);
|
||||
HideBagWindow(BAG_WIN_MSG);
|
||||
PutWindowTilemap(0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(0, COPYWIN_MAP);
|
||||
|
||||
11
src/window.c
11
src/window.c
@@ -8,7 +8,7 @@ EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0};
|
||||
|
||||
static u8 GetNumActiveWindowsOnBg(u8 bgId);
|
||||
|
||||
static const struct WindowTemplate sDummyWindowTemplate = {0xFF, 0, 0, 0, 0, 0, 0};
|
||||
static const struct WindowTemplate sDummyWindowTemplate = {WINDOW_NONE, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
static void nullsub_8(void)
|
||||
{
|
||||
@@ -98,6 +98,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// returns windowId or WINDOW_NONE (0xFF)
|
||||
u16 AddWindow(const struct WindowTemplate *template)
|
||||
{
|
||||
u16 win;
|
||||
@@ -114,7 +115,7 @@ u16 AddWindow(const struct WindowTemplate *template)
|
||||
}
|
||||
|
||||
if (win == WINDOWS_MAX)
|
||||
return 0xFF;
|
||||
return WINDOW_NONE;
|
||||
|
||||
bgLayer = template->bg;
|
||||
allocatedBaseBlock = 0;
|
||||
@@ -124,7 +125,7 @@ u16 AddWindow(const struct WindowTemplate *template)
|
||||
allocatedBaseBlock = BgTileAllocOp(bgLayer, 0, template->width * template->height, BG_TILE_FIND_FREE_SPACE);
|
||||
|
||||
if (allocatedBaseBlock == -1)
|
||||
return 0xFF;
|
||||
return WINDOW_NONE;
|
||||
}
|
||||
|
||||
if (gWindowBgTilemapBuffers[bgLayer] == NULL)
|
||||
@@ -136,7 +137,7 @@ u16 AddWindow(const struct WindowTemplate *template)
|
||||
allocatedTilemapBuffer = Alloc(bgSize);
|
||||
|
||||
if (allocatedTilemapBuffer == NULL)
|
||||
return 0xFF;
|
||||
return WINDOW_NONE;
|
||||
|
||||
for (i = 0; i < bgSize; ++i)
|
||||
allocatedTilemapBuffer[i] = 0;
|
||||
@@ -155,7 +156,7 @@ u16 AddWindow(const struct WindowTemplate *template)
|
||||
Free(gWindowBgTilemapBuffers[bgLayer]);
|
||||
gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer;
|
||||
}
|
||||
return 0xFF;
|
||||
return WINDOW_NONE;
|
||||
}
|
||||
|
||||
gWindows[win].tileData = allocatedTilemapBuffer;
|
||||
|
||||
Reference in New Issue
Block a user