From 266ba36d96a5a891ce7379dd3b47dfdb7a54774b Mon Sep 17 00:00:00 2001 From: Dalton-V Date: Thu, 12 Nov 2026 08:35:00 -0600 Subject: [PATCH] Support different game languages --- .../PokemonFRLG_BoxOrganization.cpp | 10 +++++----- .../PokemonFRLG_BoxOrganization.h | 3 ++- .../BoxOrganization/PokemonFRLG_BoxSorter.cpp | 20 ++++++++++++++++--- .../BoxOrganization/PokemonFRLG_BoxSorter.h | 2 ++ .../PokemonFRLG_BoxSorterLivingDex.cpp | 20 ++++++++++++++++--- .../PokemonFRLG_BoxSorterLivingDex.h | 2 ++ 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.cpp index 20854d4936..bfdbfab3f4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.cpp @@ -166,7 +166,7 @@ void open_summary_screen(SingleSwitchProgramEnvironment& env, ProControllerConte // Currently only reads shininess, but could be extended to read other summary information. void scan_box_summaries( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - const BoxSelectionModeDetector& selection_detector, BoxCursor& cursor, + Language language, const BoxSelectionModeDetector& selection_detector, BoxCursor& cursor, std::vector>& boxes_data ){ const size_t box_start = cursor.box * BOX_ROWS * BOX_COLS; @@ -194,7 +194,7 @@ void scan_box_summaries( auto& pokemon = *boxes_data[index]; const VideoSnapshot screen = env.console.video().snapshot(); PokemonFRLG_Stats current_stats; - reader.read_page1(env.logger(), Language::English, screen, current_stats); + reader.read_page1(env.logger(), language, screen, current_stats); if (current_stats.name != pokemon.name_slug || current_stats.level != pokemon.level){ std::ostringstream ss; ss << "Box Sorter: Summary species mismatch at " << BoxCursor(index) @@ -421,7 +421,7 @@ std::string make_missing_living_dex_report( BoxOrganizationScan scan_box_data( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - const std::vector& preferences, size_t num_boxes, bool read_shininess + Language language, const std::vector& preferences, size_t num_boxes, bool read_shininess ){ bool read_summary = read_shininess || std::any_of(preferences.begin(), preferences.end(), [](const SortingRule& rule){ return rule.sort_type == SortingRuleType::Shiny; @@ -496,7 +496,7 @@ BoxOrganizationScan scan_box_data( continue; } - const std::string name = cell_reader.read_name(env.logger(), Language::English, screen); + const std::string name = cell_reader.read_name(env.logger(), language, screen); const int level = cell_reader.read_level(env.logger(), screen); const auto& dex_numbers = SLUGS_TO_NATIONAL_DEX(); const auto dex = dex_numbers.find(name); @@ -521,7 +521,7 @@ BoxOrganizationScan scan_box_data( env.update_stats(); } if (read_summary){ - scan_box_summaries(env, context, selection_detector, cursor, boxes_data); + scan_box_summaries(env, context, language, selection_detector, cursor, boxes_data); } } return {std::move(boxes_data), cursor, scan_mode}; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.h index 27dc430f2e..b2401191e6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxOrganization.h @@ -11,6 +11,7 @@ #include #include #include +#include "CommonFramework/Language.h" #include "CommonFramework/ProgramStats/StatsTracking.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" #include "Pokemon/Pokemon_BoxCursor.h" @@ -77,7 +78,7 @@ struct BoxOrganizationScan{ // Detecting Shiny requires reading the summary screen, this is much slower than just reading the box data. BoxOrganizationScan scan_box_data( SingleSwitchProgramEnvironment& env, ProControllerContext& context, - const std::vector& preferences, size_t num_boxes, + Language language, const std::vector& preferences, size_t num_boxes, bool read_shininess = false ); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.cpp index fdf5b5f545..6c2f7edbf5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.cpp @@ -32,7 +32,7 @@ BoxSorter_Descriptor::BoxSorter_Descriptor() Pokemon::STRING_POKEMON + " FRLG", "Box Sorter", "Programs/PokemonFRLG/BoxSorter.html", "Sort boxes of " + STRING_POKEMON + ". Start in Move " + STRING_POKEMON + - " with an empty hand in the first box to sort. Uses English species names.", + " with an empty hand in the first box to sort.", PanelQualityStanding::OFFICIAL_BETA, ProgramControllerClass::StandardController_NoRestrictions, FeedbackType::REQUIRED, @@ -46,7 +46,20 @@ std::unique_ptr BoxSorter_Descriptor::make_stats() const{ } BoxSorter::BoxSorter() - : NUM_BOXES( + : LANGUAGE( + "Game Language:
Select the language of your game so the program can read " + STRING_POKEMON + " species names.", + { + Language::English, + Language::Japanese, + Language::Spanish, + Language::French, + Language::German, + Language::Italian, + }, + LockMode::LOCK_WHILE_RUNNING, + true + ) + , NUM_BOXES( "Number of Boxes to Sort:
Starting with the current box and continuing to the right.", LockMode::LOCK_WHILE_RUNNING, 1, 1, MAX_BOXES ) @@ -61,6 +74,7 @@ BoxSorter::BoxSorter() ) , NOTIFICATIONS({&NOTIFICATION_PROGRAM_FINISH, &NOTIFICATION_ERROR_FATAL}) { + PA_ADD_OPTION(LANGUAGE); PA_ADD_OPTION(NUM_BOXES); PA_ADD_OPTION(SORT_TABLE); PA_ADD_OPTION(DRY_RUN); @@ -76,7 +90,7 @@ void BoxSorter::program(SingleSwitchProgramEnvironment& env, ProControllerContex } auto& stats = env.current_stats(); - BoxOrganizationScan scan = scan_box_data(env, context, preferences, (uint16_t)NUM_BOXES); + BoxOrganizationScan scan = scan_box_data(env, context, LANGUAGE, preferences, (uint16_t)NUM_BOXES); const auto& boxes_data = scan.boxes_data; // Stable ordering avoids unnecessary moves for Pokemon with identical sort keys. diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.h index af5234576c..2e7882b466 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorter.h @@ -11,6 +11,7 @@ #include "Common/Cpp/Options/BooleanCheckBoxOption.h" #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "CommonTools/Options/LanguageOCROption.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" #include "Pokemon/Options/Pokemon_BoxSortingTable.h" @@ -39,6 +40,7 @@ class BoxSorter : public SingleSwitchProgramInstance{ private: + OCR::LanguageOCROption LANGUAGE; SimpleIntegerOption NUM_BOXES; Pokemon::BoxSortingTable SORT_TABLE; BooleanCheckBoxOption DRY_RUN; diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.cpp index ca0dd79326..aa48844633 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.cpp @@ -28,7 +28,7 @@ BoxSorterLivingDex_Descriptor::BoxSorterLivingDex_Descriptor() STRING_POKEMON + " FRLG", "Box Sorter Living Dex", "Programs/PokemonFRLG/BoxSorterLivingDex.html", "Arrange boxes of " + STRING_POKEMON + " into living dex order. Start in Move " + STRING_POKEMON + - " with an empty hand in the first box to organize. Uses English species names.", + " with an empty hand in the first box to organize.", PanelQualityStanding::OFFICIAL_BETA, ProgramControllerClass::StandardController_NoRestrictions, FeedbackType::REQUIRED, @@ -41,7 +41,20 @@ std::unique_ptr BoxSorterLivingDex_Descriptor::make_stats() const{ } BoxSorterLivingDex::BoxSorterLivingDex() - : NUM_BOXES( + : LANGUAGE( + "Game Language:
Select the language of your game so the program can read " + STRING_POKEMON + " species names.", + { + Language::English, + Language::Japanese, + Language::Spanish, + Language::French, + Language::German, + Language::Italian, + }, + LockMode::LOCK_WHILE_RUNNING, + true + ) + , NUM_BOXES( "Number of Boxes to Organize:
Starting with the current box and continuing to the right. " "Include room after the template for duplicates and other Pokemon.", LockMode::LOCK_WHILE_RUNNING, 8, 1, 14 @@ -63,6 +76,7 @@ BoxSorterLivingDex::BoxSorterLivingDex() ) , NOTIFICATIONS({&NOTIFICATION_PROGRAM_FINISH, &NOTIFICATION_ERROR_FATAL}) { + PA_ADD_OPTION(LANGUAGE); PA_ADD_OPTION(NUM_BOXES); PA_ADD_OPTION(LIVING_DEX_TEMPLATE); PA_ADD_OPTION(SHINY_DEX); @@ -96,7 +110,7 @@ void BoxSorterLivingDex::program(SingleSwitchProgramEnvironment& env, ProControl const std::vector preferences{{SortingRuleType::DexNo, false}}; auto& stats = env.current_stats(); const bool shiny_dex = SHINY_DEX; - BoxOrganizationScan scan = scan_box_data(env, context, preferences, (uint16_t)NUM_BOXES, shiny_dex); + BoxOrganizationScan scan = scan_box_data(env, context, LANGUAGE, preferences, (uint16_t)NUM_BOXES, shiny_dex); const auto boxes_sorted = make_living_dex_order( env.logger(), scan.boxes_data, living_dex_order, obey_gender_differences, shiny_dex ); diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.h index 91bc2c9902..d60b6b456f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.h +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/BoxOrganization/PokemonFRLG_BoxSorterLivingDex.h @@ -12,6 +12,7 @@ #include "Common/Cpp/Options/EnumDropdownOption.h" #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "CommonTools/Options/LanguageOCROption.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" namespace PokemonAutomation{ class Logger; } @@ -43,6 +44,7 @@ class BoxSorterLivingDex : public SingleSwitchProgramInstance{ Condensed, }; + OCR::LanguageOCROption LANGUAGE; SimpleIntegerOption NUM_BOXES; EnumDropdownOption LIVING_DEX_TEMPLATE; BooleanCheckBoxOption SHINY_DEX;