Skip to content

Commit caa0a59

Browse files
author
Gin
committed
better overlay log
1 parent a56384c commit caa0a59

File tree

3 files changed

+49
-13
lines changed

3 files changed

+49
-13
lines changed

SerialPrograms/Source/Pokemon/Pokemon_Strings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const std::string STRING_POKEMON = "Pok\u00e9mon";
1515
const std::string STRING_POKEDEX = "Pok\u00e9dex";
1616
const std::string STRING_POKEJOB = "Pok\u00e9 Job";
1717

18+
const std::string UNICODE_MALE = "\u2642";
19+
const std::string UNICODE_FEMALE = "\u2640";
20+
const std::string UNICODE_GENDERLESS = "\u26b2";
21+
const std::string UNICODE_ALPHA = "\u03B1";
22+
1823

1924

2025
}

SerialPrograms/Source/Pokemon/Pokemon_Strings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ extern const std::string STRING_POKEMON;
1818
extern const std::string STRING_POKEDEX;
1919
extern const std::string STRING_POKEJOB;
2020

21+
extern const std::string UNICODE_MALE;
22+
extern const std::string UNICODE_FEMALE;
23+
extern const std::string UNICODE_GENDERLESS;
24+
extern const std::string UNICODE_ALPHA;
25+
2126

2227
}
2328
}

SerialPrograms/Source/PokemonHome/Programs/PokemonHome_BoxSorting.cpp

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ namespace PokemonHome{
5454
using namespace Pokemon;
5555

5656

57+
5758
const size_t MAX_BOXES = 200;
5859
const size_t MAX_COLUMNS = 6;
5960
const size_t MAX_ROWS = 5;
@@ -274,6 +275,29 @@ std::ostream& operator<<(std::ostream& os, const std::optional<Pokemon>& pokemon
274275
return os;
275276
}
276277

278+
std::string create_overlay_log(const Pokemon& pokemon){
279+
const std::string& species_slug = NATIONAL_DEX_SLUGS()[pokemon.national_dex_number-1];
280+
const std::string& display_name = get_pokemon_name(species_slug).display_name();
281+
std::string overlay_log = display_name;
282+
if(pokemon.gender == StatsHuntGenderFilter::Male){
283+
overlay_log += " " + UNICODE_MALE;
284+
} else if (pokemon.gender == StatsHuntGenderFilter::Female){
285+
overlay_log += " " + UNICODE_FEMALE;
286+
} else{
287+
overlay_log += " " + UNICODE_GENDERLESS;
288+
}
289+
if (pokemon.shiny){
290+
overlay_log += " *";
291+
}
292+
if (pokemon.gmax){
293+
overlay_log += " G";
294+
}
295+
if (pokemon.alpha){
296+
overlay_log += " " + UNICODE_ALPHA;
297+
}
298+
return overlay_log;
299+
}
300+
277301
// Move the red cursor to the first slot of the box
278302
// If the cursor is not add the first slot, move the cursor to the left and up one row at a time until it is at the first slot.
279303
bool go_to_first_slot(SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint16_t VIDEO_DELAY){
@@ -488,6 +512,8 @@ void BoxSorting::program(SingleSwitchProgramEnvironment& env, ProControllerConte
488512
ImageFloatBox select_check(0.495, 0.0045, 0.01, 0.005); // square color to check which mode is active
489513
ImageFloatBox national_dex_number_box(0.448, 0.245, 0.049, 0.04); //pokemon national dex number pos
490514
ImageFloatBox shiny_symbol_box(0.702, 0.09, 0.04, 0.06); // shiny symbol pos
515+
// TODO: gmax symbol is at the same location as Tera type symbol! Need better detection to tell apart
516+
// gmax symbol and tera types
491517
ImageFloatBox gmax_symbol_box(0.463, 0.09, 0.04, 0.06); // gmax symbol pos
492518
ImageFloatBox origin_symbol_box(0.623, 0.095, 0.033, 0.05); // origin symbol pos
493519
ImageFloatBox pokemon_box(0.69, 0.18, 0.28, 0.46); // pokemon render pos
@@ -628,9 +654,10 @@ void BoxSorting::program(SingleSwitchProgramEnvironment& env, ProControllerConte
628654
pbf_press_button(context, BUTTON_A, 10, VIDEO_DELAY+150);
629655
context.wait_for_all_requests();
630656

631-
box_render.add(COLOR_RED, national_dex_number_box);
657+
box_render.add(COLOR_WHITE, national_dex_number_box);
632658
box_render.add(COLOR_BLUE, shiny_symbol_box);
633-
box_render.add(COLOR_GREEN, gmax_symbol_box);
659+
box_render.add(COLOR_RED, gmax_symbol_box);
660+
box_render.add(COLOR_RED, alpha_box);
634661
box_render.add(COLOR_DARKGREEN, origin_symbol_box);
635662
box_render.add(COLOR_DARK_BLUE, pokemon_box);
636663
box_render.add(COLOR_RED, level_box);
@@ -647,46 +674,45 @@ void BoxSorting::program(SingleSwitchProgramEnvironment& env, ProControllerConte
647674
continue;
648675
}
649676

677+
auto cur_pokemon_info = boxes_data[global_idx];
650678
screen = env.console.video().snapshot();
651679

652680
const int national_dex_number = OCR::read_number_waterfill(env.console, extract_box_reference(screen, national_dex_number_box), 0xff808080, 0xffffffff);
653681
if (national_dex_number <= 0 || national_dex_number > 1025) { // Current last pokemon is pecharunt
654682
dump_image(env.console, ProgramInfo(), "ReadSummary_national_dex_number", screen);
655683
}
656-
boxes_data[global_idx]->national_dex_number = (uint16_t)national_dex_number;
684+
cur_pokemon_info->national_dex_number = (uint16_t)national_dex_number;
657685

658686
const int shiny_stddev_value = (int)image_stddev(extract_box_reference(screen, shiny_symbol_box)).sum();
659687
const bool is_shiny = shiny_stddev_value > 30;
660-
boxes_data[global_idx]->shiny = is_shiny;
688+
cur_pokemon_info->shiny = is_shiny;
661689
env.console.log("Shiny detection stddev:" + std::to_string(shiny_stddev_value) + " is shiny:" + std::to_string(is_shiny));
662690

663691
const int gmax_stddev_value = (int)image_stddev(extract_box_reference(screen, gmax_symbol_box)).sum();
664692
const bool is_gmax = gmax_stddev_value > 30;
665-
boxes_data[global_idx]->gmax = is_gmax;
693+
cur_pokemon_info->gmax = is_gmax;
666694
env.console.log("Gmax detection stddev:" + std::to_string(gmax_stddev_value) + " is gmax:" + std::to_string(is_gmax));
667695

668696
const int alpha_stddev_value = (int)image_stddev(extract_box_reference(screen, alpha_box)).sum();
669697
const bool is_alpha = alpha_stddev_value > 40;
670-
boxes_data[global_idx]->alpha = is_alpha;
698+
cur_pokemon_info->alpha = is_alpha;
671699
env.console.log("Alpha detection stddev:" + std::to_string(alpha_stddev_value) + " is alpha:" + std::to_string(is_alpha));
672700

673701
BallReader ball_reader(env.console);
674-
boxes_data[global_idx]->ball_slug = ball_reader.read_ball(screen);
702+
cur_pokemon_info->ball_slug = ball_reader.read_ball(screen);
675703

676704
BoxGenderDetector::make_overlays(box_render);
677705
const StatsHuntGenderFilter gender = BoxGenderDetector::detect(screen);
678706
env.console.log("Gender: " + gender_to_string(gender), COLOR_GREEN);
679-
boxes_data[global_idx]->gender = gender;
707+
cur_pokemon_info->gender = gender;
680708

681709
const int ot_id = OCR::read_number_waterfill(env.console, extract_box_reference(screen, ot_id_box), 0xff808080, 0xffffffff);
682710
if (ot_id < 0 || ot_id > 999'999) {
683711
dump_image(env.console, ProgramInfo(), "ReadSummary_OT", screen);
684712
}
685-
boxes_data[global_idx]->ot_id = ot_id;
686-
687-
const std::string& species_slug = NATIONAL_DEX_SLUGS()[national_dex_number-1];
688-
const std::string& display_name = get_pokemon_name(species_slug).display_name();
689-
env.add_overlay_log("Read " + display_name);
713+
cur_pokemon_info->ot_id = ot_id;
714+
715+
env.add_overlay_log("Read " + create_overlay_log(*cur_pokemon_info));
690716

691717
// NOTE edit when adding new struct members (detections go here likely)
692718

0 commit comments

Comments
 (0)