Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/bag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
72 changes: 45 additions & 27 deletions src/bag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -18,23 +19,25 @@ static const u8 sTextColors[][3] = {
};

static const struct WindowTemplate sDefaultBagWindowsStd[] = {
{
[BAG_WIN_ITEMS_ID] = { // central main list window
.bg = 0,
.tilemapLeft = 11,
.tilemapTop = 1,
.width = 18,
.height = 12,
.paletteNum = 15,
.baseBlock = 0x008a
}, {
},
[BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box
.bg = 0,
.tilemapLeft = 5,
.tilemapTop = 14,
.width = 25,
.height = 6,
.paletteNum = 15,
.baseBlock = 0x0162
}, {
},
[BAG_WIN_TITLE_ID] = { // top left pocket title
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
Expand All @@ -46,23 +49,25 @@ static const struct WindowTemplate sDefaultBagWindowsStd[] = {
};

static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
{
[BAG_WIN_ITEMS_ID] = { // central main list window
.bg = 0,
.tilemapLeft = 11,
.tilemapTop = 1,
.width = 18,
.height = 12,
.paletteNum = 15,
.baseBlock = 0x008a
}, {
},
[BAG_WIN_MAIN_MSG_ID] = { // bottom MSG box
.bg = 0,
.tilemapLeft = 5,
.tilemapTop = 14,
.width = 25,
.height = 6,
.paletteNum = 15,
.baseBlock = 0x0162
}, {
},
[BAG_WIN_TITLE_ID] = { // top left pocket title
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
Expand All @@ -74,111 +79,124 @@ static const struct WindowTemplate sDefaultBagWindowsDeposit[] = {
};

static const struct WindowTemplate sWindowTemplates[] = {
{
[BAG_WIN_CHOOSE_QUANTITY] = { // bottom right corner
.bg = 0,
.tilemapLeft = 24,
.tilemapTop = 15,
.width = 5,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x242
}, {
},
[BAG_WIN_CHOOSE_QUANTITY + 1] = { // popup when buying or selling quantities
.bg = 0,
.tilemapLeft = 17,
.tilemapTop = 9,
.width = 12,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x242
}, {
},
[BAG_WIN_MONEY] = { // top left corner
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = 8,
.height = 3,
.paletteNum = 12,
.baseBlock = 0x272
}, {
},
[3] = { // unused
.bg = 0,
.tilemapLeft = 23,
.tilemapTop = 15,
.width = 6,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x28a
}, {
},
[4] = { // unused
.bg = 0,
.tilemapLeft = 21,
.tilemapTop = 9,
.width = 6,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x28a
}, {
},
[BAG_WIN_MSG_FULL] = { // whole MSG box
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 26,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x2a2
}, {
},
[BAG_WIN_MSG] = { // MSG box width 14 (spares icon bottom left corner)
.bg = 0,
.tilemapLeft = 6,
.tilemapTop = 15,
.width = 14,
.height = 4,
.paletteNum = 12,
.baseBlock = 0x2a2
}, {
},
[BAG_WIN_MSG + 1] = { // MSG box width 15
.bg = 0,
.tilemapLeft = 6,
.tilemapTop = 15,
.width = 15,
.height = 4,
.paletteNum = 12,
.baseBlock = 0x2da
}, {
},
[BAG_WIN_MSG + 2] = { // MSG box width 16
.bg = 0,
.tilemapLeft = 6,
.tilemapTop = 15,
.width = 16,
.height = 4,
.paletteNum = 12,
.baseBlock = 0x316
}, {
},
[BAG_WIN_MSG + 3] = { // MSG box width 23
.bg = 0,
.tilemapLeft = 6,
.tilemapTop = 15,
.width = 23,
.height = 4,
.paletteNum = 12,
.baseBlock = 0x356
}, {
},
[BAG_WIN_CONTEXT] = { // context menu with 1 element
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 17,
.width = 7,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x20a
}, {
},
[BAG_WIN_CONTEXT + 1] = { // context menu with 2 elements
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 15,
.width = 7,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x20a
}, {
},
[BAG_WIN_CONTEXT + 2] = { // context menu with 3 elements
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 13,
.width = 7,
.height = 6,
.paletteNum = 15,
.baseBlock = 0x20a
}, {
},
[BAG_WIN_CONTEXT + 3] = { // context menu with 4 elements
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 11,
Expand Down Expand Up @@ -214,7 +232,7 @@ void InitBagWindows(void)
ScheduleBgCopyTilemapToVram(0);
for (i = 0; i < 11; i++)
{
sOpenWindows[i] = 0xFF;
sOpenWindows[i] = WINDOW_NONE;
}
}

Expand All @@ -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)
Expand All @@ -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]);
}
Expand All @@ -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;
}
}

Expand All @@ -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)
Expand Down
Loading