From 9446ad112ac661b0a7024c5533af3195ec05e04b Mon Sep 17 00:00:00 2001 From: TheXaman <48356183+TheXaman@users.noreply.github.com> Date: Mon, 3 Jan 2022 16:48:50 +0100 Subject: [PATCH] added the ability to directly open evolutions from the EVO page --- graphics/pokedex/HGSS_tilemap_evo_screen.bin | Bin 1344 -> 1344 bytes .../pokedex/HGSS_tilemap_evo_screen_PE.bin | Bin 1344 -> 1344 bytes .../pokedex/HGSS_tilemap_forms_screen.bin | Bin 1344 -> 1344 bytes graphics/pokedex/HGSS_tileset_menu2.png | Bin 847 -> 838 bytes include/reset_rtc_screen.h | 3 + include/strings.h | 2 + src/pokedex.c | 167 +++++++++++++++--- src/reset_rtc_screen.c | 4 +- src/strings.c | 6 +- 9 files changed, 153 insertions(+), 29 deletions(-) mode change 100644 => 100755 graphics/pokedex/HGSS_tilemap_evo_screen.bin mode change 100644 => 100755 graphics/pokedex/HGSS_tilemap_evo_screen_PE.bin mode change 100644 => 100755 graphics/pokedex/HGSS_tilemap_forms_screen.bin diff --git a/graphics/pokedex/HGSS_tilemap_evo_screen.bin b/graphics/pokedex/HGSS_tilemap_evo_screen.bin old mode 100644 new mode 100755 index bf66d4046358737f3f19cd5a674edb9f041274ba..0533b53843342e23d6a1c6b989561a1c6adc2e53 GIT binary patch delta 158 zcmX@Wb%1L^$HZkK6W8&85!=RHrz>% delta 154 zcmX@Wb%1L^2cz}Gg_08|NNn77in-pK!JEMgh+(7;m`#ZEWdH#`27e$Xj|3aQz%ZGU K)qJu5D;og8b{i7_ diff --git a/graphics/pokedex/HGSS_tilemap_evo_screen_PE.bin b/graphics/pokedex/HGSS_tilemap_evo_screen_PE.bin old mode 100644 new mode 100755 index 321af9d70703f440edfa4eb84ebd3aa9bd76cc80..42403380711f43d4f82b5b0074e9217069d925e3 GIT binary patch delta 194 zcmX@Wb%1L^$HZkK6W8&85!=LFx8&Uz@WRcT8P77+dop+tfZhx~489D0K!{5EGk`z< gLm)#C5aK3-8A2FB8Nz@Nodjy1%*tv#S%8%d0H!k~NB{r; delta 182 zcmX@Wb%1L^2cz}Gg_08|NKD*yYjPhW8#cUo2jdB*`VfXt6d1-3&fvq~4TOY9Uj`6} gWQbyj20|Da!w}2h&)^4ygh`Q delta 165 zcmX@Wb%1L_10!buLm(IiO+LtIxOo@j0jBz31`r5g2t|Qm4B-qB4BkM9pY&ny1?!Jw gh+>EaLKqpt5X<1t;0J^RNG1lq$&9S_lLc7W0H`V*pa1{> diff --git a/graphics/pokedex/HGSS_tileset_menu2.png b/graphics/pokedex/HGSS_tileset_menu2.png index 7c271984cbc2a7dba805a4509f726ded6387e6bb..0c8d85aaabe6628fde2f40ee946bccf1ed53ec69 100644 GIT binary patch delta 665 zcmV;K0%rZs2F3=EDhlQS0}mTEPRz|;ku;NkYDq*vRCt`VltGT8Fc3w31#4#3oFPJU zgIu81$~rqFPJmdkoSXorj>!UL$c3gHp+x5Tg90$?gKh2Bb7Qj5e z2k6G4Xz1|Vvy0R!BucCZ7`ZaA^k z007Pc@NM00sC}$i|1!W-bI^N^aTnz>C#`QACT;|ATvTs1G;FqhqHI{y@TGu z+neF$H{*SPT9->h`iiOz(O2vG5I?ha3>~MJCukIP%rB4swO;ol1N7kmGr;!t`Kw=| zz@I4vnDnh00jJ3y5SzRJic<Ii_?`lTI&bBJzRz%>I* z-v{Kne;xoXKB@i!$gNu*?cggwYF#zj^MHS;z74%FFl#sf00000?Yy6FiHmhmmvWr2GA;#n-V|=RscX3Mq0q3IKc)$rmefTwl4Q14UEhL-`Vnj^jE6gO7RIH9zL0-|pafE7^#{fs}J%-9W5GNh7o85O|J z?ZDBB07QsRMTSiF4L}S>-JYtMo-rc6Gfr{h_N=4_!pNjSR+ z$F*cO=Oq{8um-G5^SPbd1$bY7WBjgT@EB9|FPqy3{3rm&m@(+SeXtH@SA z2e@S$74T&M*L#4o0USAbD9ZYL`~+SA*536ifZX26#}xknwqX_qXi54Ft^fc407*qo IM6N<$g6F(8CIA2c diff --git a/include/reset_rtc_screen.h b/include/reset_rtc_screen.h index 5807dec992..f8904063b7 100644 --- a/include/reset_rtc_screen.h +++ b/include/reset_rtc_screen.h @@ -1,6 +1,9 @@ #ifndef GUARD_RESET_RTC_SCREEN_H #define GUARD_RESET_RTC_SCREEN_H +extern const struct SpritePalette sSpritePalette_Arrow; +extern const struct SpriteTemplate sSpriteTemplate_Arrow; + void CB2_InitResetRtcScreen(void); #endif // GUARD_RESET_RTC_SCREEN_H diff --git a/include/strings.h b/include/strings.h index 92625d29bb..ac83efbb85 100644 --- a/include/strings.h +++ b/include/strings.h @@ -603,6 +603,8 @@ extern const u8 gText_Stats_eggGroup_UNDISCOVERED[]; extern const u8 gText_Dex_SEEN[]; extern const u8 gText_Dex_OWN[]; +extern const u8 gText_EVO_Buttons[]; +extern const u8 gText_EVO_Buttons_Decapped[]; extern const u8 gText_EVO_Buttons_PE[]; extern const u8 gText_EVO_Buttons_Decapped_PE[]; extern const u8 gText_EVO_Name[]; diff --git a/src/pokedex.c b/src/pokedex.c index a31a79066f..adc6b465af 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -29,6 +29,7 @@ #ifdef POKEMON_EXPANSION #include "region_map.h" #endif +#include "reset_rtc_screen.h" #include "scanline_effect.h" #include "shop.h" #include "sound.h" @@ -218,6 +219,17 @@ struct PokemonStats u16 abilityHidden; }; +struct EvoScreenData +{ + bool8 fromEvoPage; + u8 numAllEvolutions; + u16 targetSpecies[10]; + u8 numSeen; + bool8 seen[10]; + u8 menuPos; + u8 arrowSpriteId; +}; + struct PokedexView { struct PokedexListItem pokedexList[NATIONAL_DEX_COUNT + 1]; @@ -246,6 +258,7 @@ struct PokedexView u8 numTutorMoves; //HGSS_Ui u8 numPreEvolutions; //HGSS_Ui struct PokemonStats sPokemonStats; //HGSS_Ui + struct EvoScreenData sEvoScreenData; //HGSS_Ui u16 selectedMonSpriteId; u16 pokeBallRotationStep; u16 pokeBallRotationBackup; @@ -1219,7 +1232,7 @@ static const struct WindowTemplate sInfoScreen_WindowTemplates[] = .bg = 2, .tilemapLeft = 0, .tilemapTop = 18, - .width = 12, + .width = 20, .height = 2, .paletteNum = 15, .baseBlock = 641, @@ -2066,6 +2079,7 @@ static void CB2_Pokedex(void) void Task_OpenPokedexMainPage(u8 taskId) { sPokedexView->isSearchResults = FALSE; + sPokedexView->sEvoScreenData.fromEvoPage = FALSE; if (LoadPokedexListPage(PAGE_MAIN)) gTasks[taskId].func = Task_HandlePokedexInput; } @@ -3143,6 +3157,9 @@ static bool8 TryDoInfoScreenScroll(void) u16 nextPokemon; u16 selectedPokemon = sPokedexView->selectedPokemon; + if (sPokedexView->sEvoScreenData.fromEvoPage) + return FALSE; + if (JOY_NEW(DPAD_UP) && selectedPokemon) { nextPokemon = selectedPokemon; @@ -7534,29 +7551,64 @@ static void DestroySplitIcon(void) //PokedexPlus HGSS_Ui Evolution Page static const u8 sEvoFormsPageNavigationTextColor[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY}; -static void EvoFormsPage_PrintAToggleUpdownEvos(void) +static void EvoFormsPage_PrintNavigationButtons(void) { - u8 x = 9; + u8 x = 6; u8 y = 0; - if (sPokedexView->selectedScreen == EVO_SCREEN) - { + #ifdef POKEMON_EXPANSION + if (sPokedexView->selectedScreen == EVO_SCREEN) + { + if (!HGSS_DECAPPED) + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons_PE); + else + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons_Decapped_PE); + } + else if (sPokedexView->selectedScreen == FORMS_SCREEN) + { + if (!HGSS_DECAPPED) + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x, y, sStatsPageNavigationTextColor, 0, gText_FORMS_Buttons_PE); + else + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x, y, sStatsPageNavigationTextColor, 0, gText_FORMS_Buttons_Decapped_PE); + } + #else if (!HGSS_DECAPPED) - AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons_PE); + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons); else - AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons_Decapped_PE); - } - else if (sPokedexView->selectedScreen == FORMS_SCREEN) - { - if (!HGSS_DECAPPED) - AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x, y, sStatsPageNavigationTextColor, 0, gText_FORMS_Buttons_PE); - else - AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x, y, sStatsPageNavigationTextColor, 0, gText_FORMS_Buttons_Decapped_PE); - } + AddTextPrinterParameterized3(WIN_NAVIGATION_BUTTONS, 0, x+9, y, sStatsPageNavigationTextColor, 0, gText_EVO_Buttons_Decapped); + #endif // DrawKeypadIcon(WIN_NAVIGATION_BUTTONS, 10, 5, 0); //(u8 windowId, u8 keypadIconId, u16 x, u16 y) PutWindowTilemap(WIN_NAVIGATION_BUTTONS); CopyWindowToVram(WIN_NAVIGATION_BUTTONS, 3); } +static void ResetEvoScreenDataStruct(void) +{ + u8 i; + sPokedexView->sEvoScreenData.numAllEvolutions = 0; + sPokedexView->sEvoScreenData.numSeen = 0; + sPokedexView->sEvoScreenData.menuPos = 0; + for (i = 0; i < 10; i++) + { + sPokedexView->sEvoScreenData.targetSpecies[i] = 0; + sPokedexView->sEvoScreenData.seen[i] = 0; + } + +} +static void GetSeenFlagTargetSpecies(void) +{ + u8 i; + u16 species; + for (i = 0; i < sPokedexView->sEvoScreenData.numAllEvolutions; i++) + { + species = sPokedexView->sEvoScreenData.targetSpecies[i]; + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_SEEN)) + { + sPokedexView->sEvoScreenData.seen[i] = TRUE; + sPokedexView->sEvoScreenData.numSeen += 1; + } + + } +} static void Task_LoadEvolutionScreen(u8 taskId) { switch (gMain.state) @@ -7601,17 +7653,17 @@ static void Task_LoadEvolutionScreen(u8 taskId) if (gTasks[taskId].data[1] == 0) { sPokedexView->selectedScreen = EVO_SCREEN; + ResetEvoScreenDataStruct(); //Icon FreeMonIconPalettes(); //Free space for new pallete LoadMonIconPalette(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); //Loads pallete for current mon PrintPreEvolutions(taskId, NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); - #ifndef POKEMON_EXPANSION + #ifdef POKEMON_EXPANSION + gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18 + 32*sPokedexView->numPreEvolutions, 31, 4, 0); //Create pokemon sprite + #else gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18 + 32*sPokedexView->numPreEvolutions, 31, 4, 0, TRUE); //Create pokemon sprite #endif - #ifdef POKEMON_EXPANSION - gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18 + 32*sPokedexView->numPreEvolutions, 31, 4, 0); //Create pokemon sprite - EvoFormsPage_PrintAToggleUpdownEvos(); //HGSS_Ui Navigation buttons - #endif + EvoFormsPage_PrintNavigationButtons(); //HGSS_Ui Navigation buttons gSprites[gTasks[taskId].data[4]].oam.priority = 0; } gMain.state++; @@ -7620,6 +7672,13 @@ static void Task_LoadEvolutionScreen(u8 taskId) //Print evo info and icons gTasks[taskId].data[3] = 0; PrintEvolutionTargetSpeciesAndMethod(taskId, NationalPokedexNumToSpecies(sPokedexListItem->dexNum), 0, sPokedexView->numPreEvolutions); + LoadSpritePalette(&sSpritePalette_Arrow); + GetSeenFlagTargetSpecies(); + if (sPokedexView->sEvoScreenData.numAllEvolutions != 0 && sPokedexView->sEvoScreenData.numSeen != 0) + { + sPokedexView->sEvoScreenData.arrowSpriteId = CreateSprite(&sSpriteTemplate_Arrow, 7, 58, 0); + gSprites[sPokedexView->sEvoScreenData.arrowSpriteId].animNum = 2; + } gMain.state++; break; case 5: @@ -7667,7 +7726,7 @@ static void Task_HandleEvolutionScreenInput(u8 taskId) { //Switch to forms screen, Pokemon Expansion only (rhh) #ifdef POKEMON_EXPANSION - if (JOY_NEW(A_BUTTON)) + if (JOY_NEW(START_BUTTON)) { sPokedexView->selectedScreen = FORMS_SCREEN; BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); @@ -7677,6 +7736,52 @@ static void Task_HandleEvolutionScreenInput(u8 taskId) } #endif + if (sPokedexView->sEvoScreenData.numAllEvolutions != 0 && sPokedexView->sEvoScreenData.numSeen != 0) + { + u8 i; + u8 base_y = 58; + u8 base_y_offset = 9; + u8 pos = sPokedexView->sEvoScreenData.menuPos; + u8 max = sPokedexView->sEvoScreenData.numAllEvolutions; + if (JOY_NEW(DPAD_DOWN)) + { + while (TRUE) + { + pos += 1; + if (pos >= max) + pos = 0; + + if (sPokedexView->sEvoScreenData.seen[pos] == TRUE) + break; + } + gSprites[sPokedexView->sEvoScreenData.arrowSpriteId].y = base_y + base_y_offset * pos; + sPokedexView->sEvoScreenData.menuPos = pos; + } + else if (JOY_NEW(DPAD_UP)) + { + if (sPokedexView->sEvoScreenData.menuPos == 0) + sPokedexView->sEvoScreenData.menuPos = sPokedexView->sEvoScreenData.numAllEvolutions - 1; + else + sPokedexView->sEvoScreenData.menuPos -= 1; + + gSprites[sPokedexView->sEvoScreenData.arrowSpriteId].y = base_y + base_y_offset * sPokedexView->sEvoScreenData.menuPos; + } + + if (JOY_NEW(A_BUTTON)) + { + u16 targetSpecies = sPokedexView->sEvoScreenData.targetSpecies[sPokedexView->sEvoScreenData.menuPos]; + u16 dexNum = SpeciesToNationalPokedexNum(targetSpecies); + sPokedexListItem->dexNum = dexNum; + sPokedexListItem->seen = GetSetPokedexFlag(dexNum, FLAG_GET_SEEN); + sPokedexListItem->owned = GetSetPokedexFlag(dexNum, FLAG_GET_CAUGHT); + + sPokedexView->sEvoScreenData.fromEvoPage = TRUE; + PlaySE(SE_PIN); + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); + gTasks[taskId].func = Task_LoadInfoScreenWaitForFade; + } + } + //Exit to overview if (JOY_NEW(B_BUTTON)) { @@ -7792,7 +7897,7 @@ static u8 PrintPreEvolutions(u8 taskId, u16 species) u16 i; u16 j; - u8 base_x = 13; + u8 base_x = 13+8; u8 base_x_offset = 54; u8 base_y = 51; u8 base_y_offset = 9; @@ -7843,10 +7948,21 @@ static u8 PrintPreEvolutions(u8 taskId, u16 species) HandlePreEvolutionSpeciesPrint(taskId, preEvolutionOne, species, base_x, base_y, base_y_offset, numPreEvolutions - 1); } + if (preEvolutionTwo != 0) + { + sPokedexView->sEvoScreenData.targetSpecies[0] = preEvolutionTwo; + sPokedexView->sEvoScreenData.targetSpecies[1] = preEvolutionOne; + } + else if (preEvolutionOne != 0) + { + sPokedexView->sEvoScreenData.targetSpecies[0] = preEvolutionOne; + } + //vertical line FillWindowPixelRect(0, PIXEL_FILL(5), 33 + 32*numPreEvolutions, 18, 1, 32); //PIXEL_FILL(15) for black sPokedexView->numPreEvolutions = numPreEvolutions; + sPokedexView->sEvoScreenData.numAllEvolutions += numPreEvolutions; return numPreEvolutions; } @@ -7864,7 +7980,7 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, u16 item; bool8 left = TRUE; - u8 base_x = 13; + u8 base_x = 13+8; u8 base_x_offset = 54; u8 base_y = 51; u8 base_y_offset = 9; @@ -7905,7 +8021,7 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, if (times == 0 && depth == 0) { StringExpandPlaceholders(gStringVar4, gText_EVO_NONE); - PrintInfoScreenTextSmall(gStringVar4, base_x-7, base_y + base_y_offset*depth_i); + PrintInfoScreenTextSmall(gStringVar4, base_x-7-7, base_y + base_y_offset*depth_i); } //If there are evolutions find out which and print them 1 by 1 @@ -7916,6 +8032,7 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, previousTargetSpecies = targetSpecies; targetSpecies = gEvolutionTable[species][i].targetSpecies; + sPokedexView->sEvoScreenData.targetSpecies[sPokedexView->sEvoScreenData.numAllEvolutions++] = targetSpecies; #ifdef TX_DIFFICULTY_CHALLENGES_USED if (gSaveBlock1Ptr->txRandEvolutions && targetSpecies != SPECIES_NONE) //tx_difficulty_challenges targetSpecies = GetSpeciesRandomSeeded(targetSpecies, TX_RANDOM_OFFSET_EVOLUTION, TRUE, !gSaveBlock1Ptr->txRandChaos); @@ -8370,7 +8487,7 @@ static void Task_LoadFormsScreen(u8 taskId) gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18, 31, 4, 0); //Create pokemon sprite gSprites[gTasks[taskId].data[4]].oam.priority = 0; } - EvoFormsPage_PrintAToggleUpdownEvos(); //HGSS_Ui Navigation buttons + EvoFormsPage_PrintNavigationButtons(); //HGSS_Ui Navigation buttons gMain.state++; break; case 4: diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index 25e3a73302..34c388969d 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -181,7 +181,7 @@ static const struct SpriteFrameImage sPicTable_Arrow[] = obj_frame_tiles(sArrowRight_Gfx) }; -static const struct SpritePalette sSpritePalette_Arrow = +const struct SpritePalette sSpritePalette_Arrow = { sArrow_Pal, PALTAG_ARROW }; @@ -217,7 +217,7 @@ static const union AnimCmd *const sAnims_Arrow[] = [ARROW_RIGHT] = sAnim_Arrow_Right, }; -static const struct SpriteTemplate sSpriteTemplate_Arrow = +const struct SpriteTemplate sSpriteTemplate_Arrow = { .tileTag = TAG_NONE, .paletteTag = PALTAG_ARROW, diff --git a/src/strings.c b/src/strings.c index caba16cb28..43e1054611 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1890,8 +1890,10 @@ const u8 gText_Stats_eggGroup_UNDISCOVERED[]= _("---"); const u8 gText_Dex_SEEN[] = _("SEEN"); const u8 gText_Dex_OWN[] = _("OWN"); -const u8 gText_EVO_Buttons_PE[] = _("{A_BUTTON}FORMS"); -const u8 gText_EVO_Buttons_Decapped_PE[] = _("{A_BUTTON}Forms"); +const u8 gText_EVO_Buttons[] = _("{DPAD_UPDOWN}EVOs {A_BUTTON}CHECK"); +const u8 gText_EVO_Buttons_Decapped[] = _("{DPAD_UPDOWN}Evos {A_BUTTON}Check"); +const u8 gText_EVO_Buttons_PE[] = _("{DPAD_UPDOWN}EVOs {A_BUTTON}CHECK {START_BUTTON}FORMS"); +const u8 gText_EVO_Buttons_Decapped_PE[] = _("{DPAD_UPDOWN}Evos {A_BUTTON}Check {START_BUTTON}Froms"); const u8 gText_EVO_Name[] = _("{STR_VAR_3}:"); const u8 gText_EVO_PreEvo[] = _("{STR_VAR_1} evolves from {STR_VAR_2}"); const u8 gText_EVO_FRIENDSHIP[] = _("LvlUp, high friendship");