Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::optional<CollectedPokemonInfo>>& boxes_data
){
const size_t box_start = cursor.box * BOX_ROWS * BOX_COLS;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -421,7 +421,7 @@ std::string make_missing_living_dex_report(

BoxOrganizationScan scan_box_data(
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
const std::vector<SortingRule>& preferences, size_t num_boxes, bool read_shininess
Language language, const std::vector<SortingRule>& 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;
Expand Down Expand Up @@ -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);
Expand All @@ -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};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cstdint>
#include <optional>
#include <vector>
#include "CommonFramework/Language.h"
#include "CommonFramework/ProgramStats/StatsTracking.h"
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
#include "Pokemon/Pokemon_BoxCursor.h"
Expand Down Expand Up @@ -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<Pokemon::SortingRule>& preferences, size_t num_boxes,
Language language, const std::vector<Pokemon::SortingRule>& preferences, size_t num_boxes,
bool read_shininess = false
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -46,7 +46,20 @@ std::unique_ptr<StatsTracker> BoxSorter_Descriptor::make_stats() const{
}

BoxSorter::BoxSorter()
: NUM_BOXES(
: LANGUAGE(
"<b>Game Language:</b><br>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(
"<b>Number of Boxes to Sort:</b><br>Starting with the current box and continuing to the right.",
LockMode::LOCK_WHILE_RUNNING, 1, 1, MAX_BOXES
)
Expand All @@ -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);
Expand All @@ -76,7 +90,7 @@ void BoxSorter::program(SingleSwitchProgramEnvironment& env, ProControllerContex
}

auto& stats = env.current_stats<BoxSorter_Descriptor::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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -39,6 +40,7 @@ class BoxSorter : public SingleSwitchProgramInstance{


private:
OCR::LanguageOCROption LANGUAGE;
SimpleIntegerOption<uint16_t> NUM_BOXES;
Pokemon::BoxSortingTable SORT_TABLE;
BooleanCheckBoxOption DRY_RUN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -41,7 +41,20 @@ std::unique_ptr<StatsTracker> BoxSorterLivingDex_Descriptor::make_stats() const{
}

BoxSorterLivingDex::BoxSorterLivingDex()
: NUM_BOXES(
: LANGUAGE(
"<b>Game Language:</b><br>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(
"<b>Number of Boxes to Organize:</b><br>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
Expand All @@ -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);
Expand Down Expand Up @@ -96,7 +110,7 @@ void BoxSorterLivingDex::program(SingleSwitchProgramEnvironment& env, ProControl
const std::vector<SortingRule> preferences{{SortingRuleType::DexNo, false}};
auto& stats = env.current_stats<BoxSorterLivingDex_Descriptor::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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -43,6 +44,7 @@ class BoxSorterLivingDex : public SingleSwitchProgramInstance{
Condensed,
};

OCR::LanguageOCROption LANGUAGE;
SimpleIntegerOption<uint16_t> NUM_BOXES;
EnumDropdownOption<LivingDexTemplate> LIVING_DEX_TEMPLATE;
BooleanCheckBoxOption SHINY_DEX;
Expand Down
Loading