From 0f71be05a98af355607f2d35cef99e652222b1cd Mon Sep 17 00:00:00 2001 From: Ken Bynell Date: Sun, 17 Nov 2024 18:54:08 -0600 Subject: [PATCH 1/4] clean copy from fly-from-pokenav --- include/config/overworld.h | 9 +++--- include/overworld.h | 2 ++ include/pokenav.h | 4 +++ include/region_map.h | 5 ++++ src/field_effect.c | 9 ++++-- src/pokenav_main_menu.c | 26 ++++++++-------- src/pokenav_region_map.c | 55 ++++++++++++++++++++++++++++++++-- src/region_map.c | 61 +++++++++++++++++++++++++------------- 8 files changed, 129 insertions(+), 42 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 464024025ba9..2527745f0476 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -81,10 +81,11 @@ // Overworld flags // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. -#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. -#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. -#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. -#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. +#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. +#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. +#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. +#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. +#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. #define BATTLE_PYRAMID_RANDOM_ENCOUNTERS FALSE // If set to TRUE, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) diff --git a/include/overworld.h b/include/overworld.h index 28a4aa9277b7..5db74c71f8b1 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -26,6 +26,8 @@ #define SKIP_OBJECT_EVENT_LOAD 1 +extern EWRAM_DATA bool8 gSkipShowMonAnim; + struct InitialPlayerAvatarState { u8 transitionFlags; diff --git a/include/pokenav.h b/include/pokenav.h index 174c338e270f..5c238a6c5407 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -171,6 +171,8 @@ enum HELPBAR_NONE, HELPBAR_MAP_ZOOMED_OUT, HELPBAR_MAP_ZOOMED_IN, + HELPBAR_MAP_ZOOMED_OUT_CANFLY, + HELPBAR_MAP_ZOOMED_IN_CANFLY, HELPBAR_CONDITION_MON_LIST, HELPBAR_CONDITION_MON_STATUS, HELPBAR_CONDITION_MARKINGS, @@ -295,6 +297,7 @@ enum POKENAV_MAP_FUNC_ZOOM_OUT, POKENAV_MAP_FUNC_ZOOM_IN, POKENAV_MAP_FUNC_EXIT, + POKENAV_MAP_FUNC_FLY }; // Modes for PokenavFadeScreen @@ -438,6 +441,7 @@ void CreateRegionMapLoopedTask(s32); bool32 IsRegionMapLoopedTaskActive(void); void FreeRegionMapSubstruct1(void); void FreeRegionMapSubstruct2(void); +void UpdateRegionMapHelpBarText(void); // pokenav_conditions.c u32 PokenavCallback_Init_ConditionGraph_Party(void); diff --git a/include/region_map.h b/include/region_map.h index 9f0b110a658f..08277651dec5 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -14,6 +14,7 @@ enum MAP_INPUT_MOVE_END, MAP_INPUT_A_BUTTON, MAP_INPUT_B_BUTTON, + MAP_INPUT_R_BUTTON }; enum { @@ -115,6 +116,10 @@ void TrySetPlayerIconBlink(void); void BlendRegionMap(u16 color, u32 coeff); void SetRegionMapDataForZoom(void); +//Pokenav Fly funcs +u32 FilterFlyDestination(struct RegionMap* regionMap); +void SetFlyDestination(struct RegionMap* regionMap); + extern const struct RegionMapLocation gRegionMapEntries[]; #endif //GUARD_REGION_MAP_H diff --git a/src/field_effect.c b/src/field_effect.c index 898f19c291fe..a76c922ba4e4 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,6 +1,7 @@ #include "global.h" #include "data.h" #include "decompress.h" +#include "event_data.h" #include "event_object_movement.h" #include "field_camera.h" #include "field_control_avatar.h" @@ -28,9 +29,10 @@ #include "trainer_pokemon_sprites.h" #include "trig.h" #include "util.h" -#include "constants/field_effects.h" #include "constants/event_objects.h" #include "constants/event_object_movement.h" +#include "constants/field_effects.h" +#include "constants/flags.h" #include "constants/metatile_behaviors.h" #include "constants/rgb.h" #include "constants/songs.h" @@ -39,6 +41,7 @@ #define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))} EWRAM_DATA s32 gFieldEffectArguments[8] = {0}; +EWRAM_DATA bool8 gSkipShowMonAnim = FALSE; // Static type declarations @@ -3226,7 +3229,8 @@ static void FlyOutFieldEffect_ShowMon(struct Task *task) { task->tState++; gFieldEffectArguments[0] = task->tMonId; - FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); + if (!gSkipShowMonAnim) + FieldEffectStart(FLDEFF_FIELD_MOVE_SHOW_MON_INIT); } } @@ -3475,6 +3479,7 @@ static void StartFlyBirdReturnToBall(u8 spriteId) u8 FldEff_FlyIn(void) { CreateTask(Task_FlyIn, 254); + gSkipShowMonAnim = FALSE; // Clears this define so flying via the party menu keeps the show mon animation return 0; } diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index dfd656833de3..4c4777e5d523 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -86,18 +86,20 @@ static const struct WindowTemplate sHelpBarWindowTemplate[] = static const u8 *const sHelpBarTexts[HELPBAR_COUNT] = { - [HELPBAR_NONE] = COMPOUND_STRING("{CLEAR 0x80}"), - [HELPBAR_MAP_ZOOMED_OUT] = COMPOUND_STRING("{A_BUTTON}ZOOM {B_BUTTON}CANCEL"), - [HELPBAR_MAP_ZOOMED_IN] = COMPOUND_STRING("{A_BUTTON}FULL {B_BUTTON}CANCEL"), - [HELPBAR_CONDITION_MON_LIST] = COMPOUND_STRING("{A_BUTTON}CONDITION {B_BUTTON}CANCEL"), - [HELPBAR_CONDITION_MON_STATUS] = COMPOUND_STRING("{A_BUTTON}MARKINGS {B_BUTTON}CANCEL"), - [HELPBAR_CONDITION_MARKINGS] = COMPOUND_STRING("{A_BUTTON}SELECT MARK {B_BUTTON}CANCEL"), - [HELPBAR_MC_TRAINER_LIST] = COMPOUND_STRING("{A_BUTTON}MENU {B_BUTTON}CANCEL"), - [HELPBAR_MC_CALL_MENU] = COMPOUND_STRING("{A_BUTTON}OK {B_BUTTON}CANCEL"), - [HELPBAR_MC_CHECK_PAGE] = COMPOUND_STRING("{B_BUTTON}CANCEL"), - [HELPBAR_RIBBONS_MON_LIST] = COMPOUND_STRING("{A_BUTTON}RIBBONS {B_BUTTON}CANCEL"), - [HELPBAR_RIBBONS_LIST] = COMPOUND_STRING("{A_BUTTON}CHECK {B_BUTTON}CANCEL"), - [HELPBAR_RIBBONS_CHECK] = COMPOUND_STRING("{B_BUTTON}CANCEL"), + [HELPBAR_NONE] = COMPOUND_STRING("{CLEAR 0x80}"), + [HELPBAR_MAP_ZOOMED_OUT] = COMPOUND_STRING("{A_BUTTON}ZOOM {B_BUTTON}CANCEL"), + [HELPBAR_MAP_ZOOMED_IN] = COMPOUND_STRING("{A_BUTTON}FULL {B_BUTTON}CANCEL"), + [HELPBAR_MAP_ZOOMED_OUT_CANFLY] = COMPOUND_STRING("{A_BUTTON}ZOOM {B_BUTTON}CANCEL {R_BUTTON}FLY"), + [HELPBAR_MAP_ZOOMED_IN_CANFLY] = COMPOUND_STRING("{A_BUTTON}FULL {B_BUTTON}CANCEL {R_BUTTON}FLY"), + [HELPBAR_CONDITION_MON_LIST] = COMPOUND_STRING("{A_BUTTON}CONDITION {B_BUTTON}CANCEL"), + [HELPBAR_CONDITION_MON_STATUS] = COMPOUND_STRING("{A_BUTTON}MARKINGS {B_BUTTON}CANCEL"), + [HELPBAR_CONDITION_MARKINGS] = COMPOUND_STRING("{A_BUTTON}SELECT MARK {B_BUTTON}CANCEL"), + [HELPBAR_MC_TRAINER_LIST] = COMPOUND_STRING("{A_BUTTON}MENU {B_BUTTON}CANCEL"), + [HELPBAR_MC_CALL_MENU] = COMPOUND_STRING("{A_BUTTON}OK {B_BUTTON}CANCEL"), + [HELPBAR_MC_CHECK_PAGE] = COMPOUND_STRING("{B_BUTTON}CANCEL"), + [HELPBAR_RIBBONS_MON_LIST] = COMPOUND_STRING("{A_BUTTON}RIBBONS {B_BUTTON}CANCEL"), + [HELPBAR_RIBBONS_LIST] = COMPOUND_STRING("{A_BUTTON}CHECK {B_BUTTON}CANCEL"), + [HELPBAR_RIBBONS_CHECK] = COMPOUND_STRING("{B_BUTTON}CANCEL"), }; static const u8 sHelpBarTextColors[3] = diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index f81ff4296639..eec2e5ea4562 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -2,8 +2,11 @@ #include "bg.h" #include "decompress.h" #include "landmark.h" +#include "event_data.h" +#include "field_effect.h" #include "main.h" #include "menu.h" +#include "overworld.h" #include "palette.h" #include "pokenav.h" #include "region_map.h" @@ -73,6 +76,7 @@ static u32 LoopedTask_UpdateInfoAfterCursorMove(s32); static u32 LoopedTask_RegionMapZoomOut(s32); static u32 LoopedTask_RegionMapZoomIn(s32); static u32 LoopedTask_ExitRegionMap(s32); +static u32 LoopedTask_TreatAsPokeNavFlyMap(s32); extern const u16 gRegionMapCityZoomTiles_Pal[]; extern const u32 gRegionMapCityZoomText_Gfx[]; @@ -119,7 +123,8 @@ static const LoopedTask sRegionMapLoopTaskFuncs[] = [POKENAV_MAP_FUNC_CURSOR_MOVED] = LoopedTask_UpdateInfoAfterCursorMove, [POKENAV_MAP_FUNC_ZOOM_OUT] = LoopedTask_RegionMapZoomOut, [POKENAV_MAP_FUNC_ZOOM_IN] = LoopedTask_RegionMapZoomIn, - [POKENAV_MAP_FUNC_EXIT] = LoopedTask_ExitRegionMap + [POKENAV_MAP_FUNC_EXIT] = LoopedTask_ExitRegionMap, + [POKENAV_MAP_FUNC_FLY] = LoopedTask_TreatAsPokeNavFlyMap, }; static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] = @@ -204,6 +209,8 @@ u32 GetRegionMapCallback(void) static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) { + struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); + switch (DoRegionMapInputCallback()) { case MAP_INPUT_MOVE_END: @@ -215,6 +222,9 @@ static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) case MAP_INPUT_B_BUTTON: state->callback = GetExitRegionMapMenuId; return POKENAV_MAP_FUNC_EXIT; + case MAP_INPUT_R_BUTTON: + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) + return POKENAV_MAP_FUNC_FLY; } return POKENAV_MAP_FUNC_NONE; @@ -365,6 +375,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState) else menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_IN; + UpdateRegionMapHelpBarText(); LoadLeftHeaderGfxForIndex(menuGfxId); ShowLeftHeaderGfx(menuGfxId, TRUE, TRUE); PokenavFadeScreen(POKENAV_FADE_FROM_BLACK); @@ -385,6 +396,7 @@ static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState) { case 0: UpdateMapSecInfoWindow(state); + UpdateRegionMapHelpBarText(); return LT_INC_AND_PAUSE; case 1: if (IsDma3ManagerBusyWithBgCopy_(state)) @@ -408,7 +420,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState) if (UpdateRegionMapZoom() || IsChangeBgYForZoomActive()) return LT_PAUSE; - PrintHelpBarText(HELPBAR_MAP_ZOOMED_OUT); + UpdateRegionMapHelpBarText(); return LT_INC_AND_PAUSE; case 2: if (WaitForHelpBar()) @@ -441,7 +453,7 @@ static u32 LoopedTask_RegionMapZoomIn(s32 taskState) if (UpdateRegionMapZoom() || IsChangeBgYForZoomActive()) return LT_PAUSE; - PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN); + UpdateRegionMapHelpBarText(); return LT_INC_AND_PAUSE; case 3: if (WaitForHelpBar()) @@ -482,6 +494,23 @@ static u32 LoopedTask_ExitRegionMap(s32 taskState) return LT_FINISH; } +static u32 LoopedTask_TreatAsPokeNavFlyMap(s32 taskState) +{ + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); + SetFlyDestination(regionMap); + gSkipShowMonAnim = TRUE; + ReturnToFieldFromFlyMapSelect(); + + return LT_FINISH; + } + + return LT_FINISH; +} + static void LoadCityZoomViewGfx(void) { int i; @@ -740,3 +769,23 @@ static void SetCityZoomTextInvisibility(bool32 invisible) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) state->cityZoomTextSprites[i]->invisible = invisible; } + +void UpdateRegionMapHelpBarText(void) +{ + struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); + + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) + { + if (IsRegionMapZoomed()) + PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN_CANFLY); + else + PrintHelpBarText(HELPBAR_MAP_ZOOMED_OUT_CANFLY); + } + else + { + if (IsRegionMapZoomed()) + PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN); + else + PrintHelpBarText(HELPBAR_MAP_ZOOMED_OUT); + } +} diff --git a/src/region_map.c b/src/region_map.c index 92771c822073..0b2796e72b73 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -680,6 +680,10 @@ static u8 ProcessRegionMapInput_Full(void) { input = MAP_INPUT_B_BUTTON; } + else if (JOY_NEW(R_BUTTON)) + { + input = MAP_INPUT_R_BUTTON; + } if (input == MAP_INPUT_MOVE_START) { sRegionMap->cursorMovementFrameCounter = 4; @@ -759,6 +763,10 @@ static u8 ProcessRegionMapInput_Zoomed(void) { input = MAP_INPUT_B_BUTTON; } + else if (JOY_NEW(R_BUTTON)) + { + input = MAP_INPUT_R_BUTTON; + } if (input == MAP_INPUT_MOVE_START) { sRegionMap->inputCallback = MoveRegionMapCursor_Zoomed; @@ -1992,27 +2000,9 @@ static void CB_ExitFlyMap(void) FreeRegionMapIconResources(); if (sFlyMap->choseFlyLocation) { - switch (sFlyMap->regionMap.mapSecId) - { - case MAPSEC_SOUTHERN_ISLAND: - SetWarpDestinationToHealLocation(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); - break; - case MAPSEC_BATTLE_FRONTIER: - SetWarpDestinationToHealLocation(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); - break; - case MAPSEC_LITTLEROOT_TOWN: - SetWarpDestinationToHealLocation(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE : HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE); - break; - case MAPSEC_EVER_GRANDE_CITY: - SetWarpDestinationToHealLocation(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE : HEAL_LOCATION_EVER_GRANDE_CITY); - break; - default: - if (sMapHealLocations[sFlyMap->regionMap.mapSecId][2] != HEAL_LOCATION_NONE) - SetWarpDestinationToHealLocation(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]); - else - SetWarpDestinationToMapWarp(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], WARP_ID_NONE); - break; - } + struct RegionMap* tempRegionMap = &sFlyMap->regionMap; + + SetFlyDestination(tempRegionMap); ReturnToFieldFromFlyMapSelect(); } else @@ -2025,3 +2015,32 @@ static void CB_ExitFlyMap(void) break; } } + +u32 FilterFlyDestination(struct RegionMap* regionMap) +{ + switch (regionMap->mapSecId) + { + case MAPSEC_SOUTHERN_ISLAND: + return HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR; + case MAPSEC_BATTLE_FRONTIER: + return HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST; + case MAPSEC_LITTLEROOT_TOWN: + return (gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE : HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE); + case MAPSEC_EVER_GRANDE_CITY: + return (FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && regionMap->posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE : HEAL_LOCATION_EVER_GRANDE_CITY); + default: + if (sMapHealLocations[regionMap->mapSecId][2] != HEAL_LOCATION_NONE) + return sMapHealLocations[regionMap->mapSecId][2]; + else + return WARP_ID_NONE; + } +} + +void SetFlyDestination(struct RegionMap* regionMap) +{ + u8 flyDestination = FilterFlyDestination(regionMap); + if (flyDestination != WARP_ID_NONE) + SetWarpDestinationToHealLocation(flyDestination); + else + SetWarpDestinationToMapWarp(sMapHealLocations[regionMap->mapSecId][0], sMapHealLocations[regionMap->mapSecId][1], WARP_ID_NONE); +} From 2616150e9b898692431758ea786cb0c8ad19127b Mon Sep 17 00:00:00 2001 From: Ken Bynell Date: Sun, 17 Nov 2024 19:41:48 -0600 Subject: [PATCH 2/4] code comment edited to describe function better --- src/field_effect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field_effect.c b/src/field_effect.c index a76c922ba4e4..a546f33117fa 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -3479,7 +3479,7 @@ static void StartFlyBirdReturnToBall(u8 spriteId) u8 FldEff_FlyIn(void) { CreateTask(Task_FlyIn, 254); - gSkipShowMonAnim = FALSE; // Clears this define so flying via the party menu keeps the show mon animation + gSkipShowMonAnim = FALSE; // Clears this variable so flying via the party menu keeps the show mon animation return 0; } From 991aeff28cd3c01345814ee328aec379784795cb Mon Sep 17 00:00:00 2001 From: Ken Bynell Date: Thu, 19 Dec 2024 13:34:53 -0600 Subject: [PATCH 3/4] addressed hedara's comments --- include/config/overworld.h | 10 +++++----- src/pokenav_region_map.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 2527745f0476..62d9895c90b3 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -81,11 +81,11 @@ // Overworld flags // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. -#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. -#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. -#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. -#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. -#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. +#define OW_FLAG_PAUSE_TIME 0 // If this flag is set and OW_USE_FAKE_RTC is enabled, seconds on the in-game clock will not advance. +#define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. +#define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. +#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. +#define OW_FLAG_POKE_RIDER 0 // If this flag is set, the player will be able to use fly from the Pokenav Region Map section by pressing 'R' on a city/location they have been to. #define BATTLE_PYRAMID_RANDOM_ENCOUNTERS FALSE // If set to TRUE, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index eec2e5ea4562..c66787c8cd31 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -223,7 +223,7 @@ static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) state->callback = GetExitRegionMapMenuId; return POKENAV_MAP_FUNC_EXIT; case MAP_INPUT_R_BUTTON: - if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) return POKENAV_MAP_FUNC_FLY; } @@ -774,7 +774,7 @@ void UpdateRegionMapHelpBarText(void) { struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); - if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER) + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) { if (IsRegionMapZoomed()) PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN_CANFLY); From 9c1eed36fda7fe6319ea3ea79ca1b743b8624be5 Mon Sep 17 00:00:00 2001 From: Ken Bynell Date: Thu, 19 Dec 2024 20:45:02 -0600 Subject: [PATCH 4/4] added fly prompt in the town map and cleaned up some formatting in pokenav_region_map.c --- src/field_region_map.c | 46 ++++++++++++++++++++++++++++++++++++---- src/pokenav_region_map.c | 6 ++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/field_region_map.c b/src/field_region_map.c index 73fc14582b0d..b38c5ecce827 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -1,17 +1,21 @@ #include "global.h" #include "bg.h" +#include "field_effect.h" #include "gpu_regs.h" #include "international_string_util.h" #include "main.h" #include "malloc.h" #include "menu.h" +#include "overworld.h" #include "palette.h" #include "region_map.h" +#include "sound.h" #include "strings.h" #include "text.h" #include "text_window.h" #include "window.h" #include "constants/rgb.h" +#include "constants/songs.h" /* * This is the type of map shown when interacting with the metatiles for @@ -45,6 +49,12 @@ static void VBCB_FieldUpdateRegionMap(void); static void MCB2_FieldUpdateRegionMap(void); static void FieldUpdateRegionMap(void); static void PrintRegionMapSecName(void); +static void PrintTitleWindowText(void); + +static const u8* const FlyPromptText = COMPOUND_STRING("{R_BUTTON}FLY"); + +u8 hoennOffset; +u8 flyOffset; static const struct BgTemplate sFieldRegionMapBgTemplates[] = { { @@ -66,7 +76,7 @@ static const struct BgTemplate sFieldRegionMapBgTemplates[] = { } }; -static const struct WindowTemplate sFieldRegionMapWindowTemplates[] = +const struct WindowTemplate sFieldRegionMapWindowTemplates[] = { [WIN_MAPSEC_NAME] = { .bg = 0, @@ -139,7 +149,8 @@ static void MCB2_FieldUpdateRegionMap(void) static void FieldUpdateRegionMap(void) { - u8 offset; + hoennOffset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); + flyOffset = GetStringCenterAlignXOffset(FONT_NORMAL, FlyPromptText, 0x38); switch (sFieldRegionMapHandler->state) { @@ -151,8 +162,8 @@ static void FieldUpdateRegionMap(void) break; case 1: DrawStdFrameWithCustomTileAndPalette(WIN_TITLE, FALSE, 0x27, 0xd); - offset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); - AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL); + FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(1)); + PrintTitleWindowText(); ScheduleBgCopyTilemapToVram(0); DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 0x27, 0xd); PrintRegionMapSecName(); @@ -176,11 +187,21 @@ static void FieldUpdateRegionMap(void) { case MAP_INPUT_MOVE_END: PrintRegionMapSecName(); + PrintTitleWindowText(); break; case MAP_INPUT_A_BUTTON: case MAP_INPUT_B_BUTTON: sFieldRegionMapHandler->state++; break; + case MAP_INPUT_R_BUTTON: + if (sFieldRegionMapHandler->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY && + OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) + { + PlaySE(SE_SELECT); + SetFlyDestination(&sFieldRegionMapHandler->regionMap); + gSkipShowMonAnim = TRUE; + ReturnToFieldFromFlyMapSelect(); + } } break; case 5: @@ -213,3 +234,20 @@ static void PrintRegionMapSecName(void) CopyWindowToVram(WIN_MAPSEC_NAME, COPYWIN_FULL); } } + +static void PrintTitleWindowText(void) +{ + FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(1)); + + if (sFieldRegionMapHandler->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY && + OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) + { + AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, FlyPromptText, flyOffset, 1, 0, NULL); + ScheduleBgCopyTilemapToVram(WIN_TITLE); + } + else + { + AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, gText_Hoenn, hoennOffset, 1, 0, NULL); + CopyWindowToVram(WIN_TITLE, COPYWIN_FULL); + } +} \ No newline at end of file diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index c66787c8cd31..fafa4303044c 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -223,7 +223,8 @@ static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state) state->callback = GetExitRegionMapMenuId; return POKENAV_MAP_FUNC_EXIT; case MAP_INPUT_R_BUTTON: - if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && + Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) return POKENAV_MAP_FUNC_FLY; } @@ -774,7 +775,8 @@ void UpdateRegionMapHelpBarText(void) { struct RegionMap* regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); - if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) + if (regionMap->mapSecType == MAPSECTYPE_CITY_CANFLY && OW_FLAG_POKE_RIDER && + Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE) { if (IsRegionMapZoomed()) PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN_CANFLY);