Use window constants in union_room_chat

This commit is contained in:
GriffinR
2022-09-29 13:20:35 -04:00
parent 4af1044439
commit 81defb5986
+52 -42
View File
@@ -116,6 +116,13 @@ enum {
// Shared by all above // Shared by all above
#define PALTAG_INTERFACE 0 #define PALTAG_INTERFACE 0
enum {
WIN_CHAT_HISTORY,
WIN_TEXT_ENTRY,
WIN_KEYBOARD,
WIN_SWAP_MENU,
};
struct UnionRoomChat struct UnionRoomChat
{ {
u32 filler1; u32 filler1;
@@ -560,7 +567,7 @@ static const struct BgTemplate sBgTemplates[] = {
}; };
static const struct WindowTemplate sWinTemplates[] = { static const struct WindowTemplate sWinTemplates[] = {
{ [WIN_CHAT_HISTORY] = {
.bg = 3, .bg = 3,
.tilemapLeft = 8, .tilemapLeft = 8,
.tilemapTop = 1, .tilemapTop = 1,
@@ -568,7 +575,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 19, .height = 19,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x0001, .baseBlock = 0x0001,
}, { },
[WIN_TEXT_ENTRY] = {
.bg = 1, .bg = 1,
.tilemapLeft = 9, .tilemapLeft = 9,
.tilemapTop = 18, .tilemapTop = 18,
@@ -576,7 +584,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 2, .height = 2,
.paletteNum = 12, .paletteNum = 12,
.baseBlock = 0x007a, .baseBlock = 0x007a,
}, { },
[WIN_KEYBOARD] = {
.bg = 1, .bg = 1,
.tilemapLeft = 0, .tilemapLeft = 0,
.tilemapTop = 2, .tilemapTop = 2,
@@ -584,7 +593,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 15, .height = 15,
.paletteNum = 7, .paletteNum = 7,
.baseBlock = 0x0020, .baseBlock = 0x0020,
}, { },
[WIN_SWAP_MENU] = {
.bg = 0, .bg = 0,
.tilemapLeft = 1, .tilemapLeft = 1,
.tilemapTop = 2, .tilemapTop = 2,
@@ -2280,7 +2290,7 @@ static bool32 Display_ShowKeyboardSwapMenu(u8 *state)
{ {
case 0: case 0:
ShowKeyboardSwapMenu(); ShowKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL); CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break; break;
case 1: case 1:
return IsDma3ManagerBusyWithBgCopy(); return IsDma3ManagerBusyWithBgCopy();
@@ -2296,7 +2306,7 @@ static bool32 Display_HideKeyboardSwapMenu(u8 *state)
{ {
case 0: case 0:
HideKeyboardSwapMenu(); HideKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL); CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break; break;
case 1: case 1:
return IsDma3ManagerBusyWithBgCopy(); return IsDma3ManagerBusyWithBgCopy();
@@ -2316,7 +2326,7 @@ static bool32 Display_SwitchPages(u8 *state)
return TRUE; return TRUE;
PrintCurrentKeyboardPage(); PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX); CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
break; break;
case 1: case 1:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@@ -2393,7 +2403,7 @@ static bool32 Display_UpdateMessageBuffer(u8 *state)
FillTextEntryWindow(x, width, 0); FillTextEntryWindow(x, width, 0);
str = GetMessageEntryBuffer(); str = GetMessageEntryBuffer();
DrawTextEntryMessage(0, str, 3, 1, 2); DrawTextEntryMessage(0, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX); CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break; break;
case 1: case 1:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
@@ -2422,7 +2432,7 @@ static bool32 Display_AskRegisterText(u8 *state)
length = StringLength_Multibyte(str); length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(6)); FillTextEntryWindow(x, length, PIXEL_FILL(6));
DrawTextEntryMessage(x, str, 0, 4, 5); DrawTextEntryMessage(x, str, 0, 4, 5);
CopyWindowToVram(1, COPYWIN_GFX); CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break; break;
case 1: case 1:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
@@ -2463,7 +2473,7 @@ static bool32 Display_CancelRegister(u8 *state)
length = StringLength_Multibyte(str); length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(0)); FillTextEntryWindow(x, length, PIXEL_FILL(0));
DrawTextEntryMessage(x, str, 3, 1, 2); DrawTextEntryMessage(x, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX); CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break; break;
case 1: case 1:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
@@ -2501,7 +2511,7 @@ static bool32 Display_ReturnToKeyboard(u8 *state)
{ {
case 0: case 0:
PrintCurrentKeyboardPage(); PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX); CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
(*state)++; (*state)++;
break; break;
case 1: case 1:
@@ -2527,7 +2537,7 @@ static bool32 Display_ScrollChat(u8 *state)
str = GetLastReceivedMessage(); str = GetLastReceivedMessage();
colorIdx = GetReceivedPlayerIndex(); colorIdx = GetReceivedPlayerIndex();
PrintChatMessage(row, str, colorIdx); PrintChatMessage(row, str, colorIdx);
CopyWindowToVram(0, COPYWIN_GFX); CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
break; break;
case 1: case 1:
if (IsDma3ManagerBusyWithBgCopy()) if (IsDma3ManagerBusyWithBgCopy())
@@ -2546,8 +2556,8 @@ static bool32 Display_ScrollChat(u8 *state)
} }
// fall through // fall through
case 2: case 2:
ScrollWindow(0, 0, 5, PIXEL_FILL(1)); ScrollWindow(WIN_CHAT_HISTORY, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_GFX); CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
sDisplay->scrollCount++; sDisplay->scrollCount++;
(*state)++; (*state)++;
// fall through // fall through
@@ -2864,7 +2874,7 @@ static void DestroyStdMessageWindow(void)
static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue) static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue)
{ {
FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14); FillWindowPixelRect(WIN_TEXT_ENTRY, fillValue, x * 8, 1, width * 8, 14);
} }
static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor) static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor)
@@ -2881,7 +2891,7 @@ static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shad
strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING; strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
strBuffer[2] = 8; strBuffer[2] = 8;
StringCopy(&strBuffer[3], str); StringCopy(&strBuffer[3], str);
AddTextPrinterParameterized3(1, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer); AddTextPrinterParameterized3(WIN_TEXT_ENTRY, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer);
} }
static void PrintCurrentKeyboardPage(void) static void PrintCurrentKeyboardPage(void)
@@ -2894,7 +2904,7 @@ static void PrintCurrentKeyboardPage(void)
u8 str[45]; u8 str[45];
u8 *str2; u8 *str2;
FillWindowPixelBuffer(2, PIXEL_FILL(15)); FillWindowPixelBuffer(WIN_KEYBOARD, PIXEL_FILL(15));
page = GetCurrentKeyboardPage(); page = GetCurrentKeyboardPage();
color[0] = TEXT_COLOR_TRANSPARENT; color[0] = TEXT_COLOR_TRANSPARENT;
color[1] = TEXT_DYNAMIC_COLOR_5; color[1] = TEXT_DYNAMIC_COLOR_5;
@@ -2916,7 +2926,7 @@ static void PrintCurrentKeyboardPage(void)
return; return;
StringCopy(&str[3], sUnionRoomKeyboardText[page][i]); StringCopy(&str[3], sUnionRoomKeyboardText[page][i]);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
} }
} }
else else
@@ -2927,7 +2937,7 @@ static void PrintCurrentKeyboardPage(void)
str2 = GetRegisteredTextByRow(i); str2 = GetRegisteredTextByRow(i);
if (GetStringWidth(FONT_SMALL, str2, 0) <= 40) if (GetStringWidth(FONT_SMALL, str2, 0) <= 40)
{ {
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2); AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2);
} }
else else
{ {
@@ -2938,8 +2948,8 @@ static void PrintCurrentKeyboardPage(void)
StringCopyN_Multibyte(str, str2, length); StringCopyN_Multibyte(str, str2, length);
} while (GetStringWidth(FONT_SMALL, str, 0) > 35); } while (GetStringWidth(FONT_SMALL, str, 0) > 35);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(2, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis); AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis);
} }
} }
} }
@@ -2989,17 +2999,17 @@ static bool32 SlideKeyboardPageIn(void)
static void ShowKeyboardSwapMenu(void) static void ShowKeyboardSwapMenu(void)
{ {
FillWindowPixelBuffer(3, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
DrawTextBorderOuter(3, 1, 13); DrawTextBorderOuter(WIN_SWAP_MENU, 1, 13);
PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts); PrintMenuActionTextsAtPos(WIN_SWAP_MENU, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts);
InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage()); InitMenuNormal(WIN_SWAP_MENU, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(3); PutWindowTilemap(WIN_SWAP_MENU);
} }
static void HideKeyboardSwapMenu(void) static void HideKeyboardSwapMenu(void)
{ {
ClearStdWindowAndFrameToTransparent(3, FALSE); ClearStdWindowAndFrameToTransparent(WIN_SWAP_MENU, FALSE);
ClearWindowTilemap(3); ClearWindowTilemap(WIN_SWAP_MENU);
} }
static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx) static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
@@ -3009,8 +3019,8 @@ static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
color[0] = TEXT_COLOR_WHITE; color[0] = TEXT_COLOR_WHITE;
color[1] = colorIdx * 2 + 2; color[1] = colorIdx * 2 + 2;
color[2] = colorIdx * 2 + 3; color[2] = colorIdx * 2 + 3;
FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15); FillWindowPixelRect(WIN_CHAT_HISTORY, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(0, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str); AddTextPrinterParameterized3(WIN_CHAT_HISTORY, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str);
} }
static void ResetGpuBgState(void) static void ResetGpuBgState(void)
@@ -3087,16 +3097,16 @@ static void LoadChatUnkPalette(void)
static void LoadChatMessagesWindow(void) static void LoadChatMessagesWindow(void)
{ {
LoadPalette(sUnk_Palette2, 0xF0, sizeof(sUnk_Palette2)); LoadPalette(sUnk_Palette2, 0xF0, sizeof(sUnk_Palette2));
PutWindowTilemap(0); PutWindowTilemap(WIN_CHAT_HISTORY);
FillWindowPixelBuffer(0, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_CHAT_HISTORY, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_FULL); CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_FULL);
} }
static void LoadKeyboardWindow(void) static void LoadKeyboardWindow(void)
{ {
PutWindowTilemap(2); PutWindowTilemap(WIN_KEYBOARD);
PrintCurrentKeyboardPage(); PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_FULL); CopyWindowToVram(WIN_KEYBOARD, COPYWIN_FULL);
} }
static void LoadTextEntryWindow(void) static void LoadTextEntryWindow(void)
@@ -3107,18 +3117,18 @@ static void LoadTextEntryWindow(void)
unused[1] = 0xFF; unused[1] = 0xFF;
for (i = 0; i < MAX_MESSAGE_LENGTH; i++) for (i = 0; i < MAX_MESSAGE_LENGTH; i++)
BlitBitmapToWindow(1, sDisplay->unk2128, i * 8, 0, 8, 16); BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->unk2128, i * 8, 0, 8, 16);
FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0));
PutWindowTilemap(1); PutWindowTilemap(WIN_TEXT_ENTRY);
CopyWindowToVram(1, COPYWIN_FULL); CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_FULL);
} }
static void LoadKeyboardSwapWindow(void) static void LoadKeyboardSwapWindow(void)
{ {
FillWindowPixelBuffer(3, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
LoadUserWindowBorderGfx(3, 1, 0xD0); LoadUserWindowBorderGfx(WIN_SWAP_MENU, 1, 0xD0);
LoadUserWindowBorderGfx_(3, 0xA, 0x20); LoadUserWindowBorderGfx_(WIN_SWAP_MENU, 0xA, 0x20);
LoadPalette(gStandardMenuPalette, 0xE0, 0x20); LoadPalette(gStandardMenuPalette, 0xE0, 0x20);
} }