From 4af1044439d46afdd5da98f7e4b41fafc4b246f8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 29 Sep 2022 13:11:38 -0400 Subject: [PATCH] Use window constants in region_map --- include/region_map.h | 3 ++- src/region_map.c | 47 ++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/region_map.h b/include/region_map.h index 85793badcb..9f0b110a65 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -21,7 +21,8 @@ enum { MAPSECTYPE_ROUTE, MAPSECTYPE_CITY_CANFLY, MAPSECTYPE_CITY_CANTFLY, - MAPSECTYPE_BATTLE_FRONTIER + MAPSECTYPE_BATTLE_FRONTIER, + NUM_MAPSEC_TYPES }; struct RegionMap { diff --git a/src/region_map.c b/src/region_map.c index 8157f8a4e7..ba7dcf106f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -53,7 +53,12 @@ enum { TAG_FLY_ICON, }; -// Static type declarations +// Window IDs for the fly map +enum { + WIN_MAPSEC_NAME, + WIN_MAPSEC_NAME_TALL, // For fly destinations with subtitles (just Ever Grande) + WIN_FLY_TO_WHERE, +}; struct MultiNameFlyDest { @@ -386,7 +391,7 @@ static const struct BgTemplate sFlyMapBgTemplates[] = static const struct WindowTemplate sFlyMapWindowTemplates[] = { - { + [WIN_MAPSEC_NAME] = { .bg = 0, .tilemapLeft = 17, .tilemapTop = 17, @@ -395,7 +400,7 @@ static const struct WindowTemplate sFlyMapWindowTemplates[] = .paletteNum = 15, .baseBlock = 0x01 }, - { + [WIN_MAPSEC_NAME_TALL] = { .bg = 0, .tilemapLeft = 17, .tilemapTop = 15, @@ -404,7 +409,7 @@ static const struct WindowTemplate sFlyMapWindowTemplates[] = .paletteNum = 15, .baseBlock = 0x19 }, - { + [WIN_FLY_TO_WHERE] = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 18, @@ -1404,7 +1409,7 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag) } LoadSpriteSheet(&sheet); LoadSpritePalette(&palette); - spriteId = CreateSprite(&template, 0x38, 0x48, 0); + spriteId = CreateSprite(&template, 56, 72, 0); if (spriteId != MAX_SPRITES) { sRegionMap->cursorSprite = &gSprites[spriteId]; @@ -1713,9 +1718,9 @@ void CB2_OpenFlyMap(void) break; case 7: LoadPalette(sRegionMapFramePal, 0x10, sizeof(sRegionMapFramePal)); - PutWindowTilemap(2); - FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized(2, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL); + PutWindowTilemap(WIN_FLY_TO_WHERE); + FillWindowPixelBuffer(WIN_FLY_TO_WHERE, PIXEL_FILL(0)); + AddTextPrinterParameterized(WIN_FLY_TO_WHERE, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); gMain.state++; break; @@ -1768,7 +1773,7 @@ static void DrawFlyDestTextWindow(void) bool32 namePrinted; const u8 *name; - if (sFlyMap->regionMap.mapSecType > MAPSECTYPE_NONE && sFlyMap->regionMap.mapSecType <= MAPSECTYPE_BATTLE_FRONTIER) + if (sFlyMap->regionMap.mapSecType > MAPSECTYPE_NONE && sFlyMap->regionMap.mapSecType < NUM_MAPSEC_TYPES) { namePrinted = FALSE; for (i = 0; i < ARRAY_COUNT(sMultiNameFlyDestinations); i++) @@ -1779,11 +1784,11 @@ static void DrawFlyDestTextWindow(void) { StringLength(sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]); namePrinted = TRUE; - ClearStdWindowAndFrameToTransparent(0, FALSE); - DrawStdFrameWithCustomTileAndPalette(1, FALSE, 101, 13); - AddTextPrinterParameterized(1, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); + ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME, FALSE); + DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME_TALL, FALSE, 101, 13); + AddTextPrinterParameterized(WIN_MAPSEC_NAME_TALL, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); name = sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]; - AddTextPrinterParameterized(1, FONT_NORMAL, name, GetStringRightAlignXOffset(FONT_NORMAL, name, 96), 17, 0, NULL); + AddTextPrinterParameterized(WIN_MAPSEC_NAME_TALL, FONT_NORMAL, name, GetStringRightAlignXOffset(FONT_NORMAL, name, 96), 17, 0, NULL); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = TRUE; } @@ -1794,15 +1799,15 @@ static void DrawFlyDestTextWindow(void) { if (sDrawFlyDestTextWindow == TRUE) { - ClearStdWindowAndFrameToTransparent(1, FALSE); - DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13); + ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME_TALL, FALSE); + DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 101, 13); } else { // Window is already drawn, just empty it - FillWindowPixelBuffer(0, PIXEL_FILL(1)); + FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1)); } - AddTextPrinterParameterized(0, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_MAPSEC_NAME, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = FALSE; } @@ -1812,11 +1817,11 @@ static void DrawFlyDestTextWindow(void) // Selection is on MAPSECTYPE_NONE, draw empty fly destination text window if (sDrawFlyDestTextWindow == TRUE) { - ClearStdWindowAndFrameToTransparent(1, FALSE); - DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13); + ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME_TALL, FALSE); + DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 101, 13); } - FillWindowPixelBuffer(0, PIXEL_FILL(1)); - CopyWindowToVram(0, COPYWIN_GFX); + FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1)); + CopyWindowToVram(WIN_MAPSEC_NAME, COPYWIN_GFX); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = FALSE; }