diff --git a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp index 9b284b201..ee93a8f46 100644 --- a/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp +++ b/SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp @@ -132,8 +132,8 @@ bool BattleDialogDetector::detect(const ImageViewRGB32& screen){ ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); - if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }) - && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }) + if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) + && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) ){ return true; } @@ -162,10 +162,10 @@ bool BattleMenuDetector::detect(const ImageViewRGB32& screen){ ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); - if (is_solid(menu_top_image, { 0.335, 0.332, 0.335 }) //253, 251, 254 white - && is_solid(menu_right_image, { 0.335, 0.332, 0.335 }) - && is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }) //40, 81, 106 teal - && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }) + if (is_white(menu_top_image) + && is_white(menu_right_image) + && is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) //40, 81, 106 teal + && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) ){ return true; } @@ -203,8 +203,8 @@ bool AdvanceBattleDialogDetector::detect(const ImageViewRGB32& screen){ ImageViewRGB32 dialog_top_image = extract_box_reference(screen, m_dialog_top_box); ImageViewRGB32 dialog_right_image = extract_box_reference(screen, m_dialog_right_box); - if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }) - && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }) + if (is_solid(dialog_top_image, { 0.176, 0.357, 0.467 }, 0.25, 20) + && is_solid(dialog_right_image, { 0.176, 0.357, 0.467 }, 0.25, 20) && (stats.average.r > stats.average.b + 180) && (stats.average.r > stats.average.g + 180) ) diff --git a/SerialPrograms/Source/Tests/PokemonFRLG_Tests.cpp b/SerialPrograms/Source/Tests/PokemonFRLG_Tests.cpp index c1a2469d4..53394053f 100644 --- a/SerialPrograms/Source/Tests/PokemonFRLG_Tests.cpp +++ b/SerialPrograms/Source/Tests/PokemonFRLG_Tests.cpp @@ -51,4 +51,12 @@ int test_pokemonFRLG_SelectionDialogDetector(const ImageViewRGB32& image, bool t return 0; } +int test_pokemonFRLG_AdvanceBattleDialogDetector(const ImageViewRGB32& image, bool target){ + auto overlay = DummyVideoOverlay(); + AdvanceBattleDialogDetector detector(COLOR_RED); + bool result = detector.detect(image); + TEST_RESULT_EQUAL(result, target); + return 0; +} + } diff --git a/SerialPrograms/Source/Tests/PokemonFRLG_Tests.h b/SerialPrograms/Source/Tests/PokemonFRLG_Tests.h index a023c5961..a6e1437e5 100644 --- a/SerialPrograms/Source/Tests/PokemonFRLG_Tests.h +++ b/SerialPrograms/Source/Tests/PokemonFRLG_Tests.h @@ -23,6 +23,8 @@ int test_pokemonFRLG_ShinySymbolDetector(const ImageViewRGB32& image, bool targe int test_pokemonFRLG_SelectionDialogDetector(const ImageViewRGB32& image, bool target); +int test_pokemonFRLG_AdvanceBattleDialogDetector(const ImageViewRGB32& image, bool target); + } #endif diff --git a/SerialPrograms/Source/Tests/TestMap.cpp b/SerialPrograms/Source/Tests/TestMap.cpp index add3aab95..cb54cb012 100644 --- a/SerialPrograms/Source/Tests/TestMap.cpp +++ b/SerialPrograms/Source/Tests/TestMap.cpp @@ -312,6 +312,7 @@ const std::map TEST_MAP = { {"PokemonFRLG_AdvanceWhiteDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_AdvanceWhiteDialogDetector, _1)}, {"PokemonFRLG_ShinySymbolDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_ShinySymbolDetector, _1)}, {"PokemonFRLG_SelectionDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_SelectionDialogDetector, _1)}, + {"PokemonFRLG_AdvanceBattleDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_AdvanceBattleDialogDetector, _1)}, }; TestFunction find_test_function(const std::string& test_space, const std::string& test_name){