Skip to content
Draft
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "Kernels/Waterfill/Kernels_Waterfill_Types.h"
#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/WaterfillUtilities.h"
#include "PokemonFRLG/PokemonFRLG_Settings.h"
#include "PokemonFRLG_PokedexRegisteredDetector.h"
Expand Down Expand Up @@ -38,17 +39,26 @@ class PokedexRegisteredMatcher : public ImageMatch::WaterfillTemplateMatcher{

PokedexRegisteredDetector::PokedexRegisteredDetector(
Color color,
VideoOverlay* overlay,
const ImageFloatBox& box
VideoOverlay* overlay
)
: m_color(color)
, m_overlay(overlay)
, m_box(box)
, m_box(0.85, 0.923, 0.082, 0.070)
, m_top_box(0.940865, 0.013942, 0.049519, 0.071394)
, m_header_box(0.037019, 0.147355, 0.928365, 0.015865)
, m_divider_box(0.016827, 0.560577, 0.961827, 0.002885)
, m_body_box(0.016827, 0.582577, 0.961827, 0.002885)
, m_bottom_box(0.007692, 0.912500, 0.688942, 0.075721)
{}

void PokedexRegisteredDetector::make_overlays(VideoOverlaySet& items) const{
const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX;
items.add(m_color, GAME_BOX.inner_to_outer(m_box));
items.add(m_color, GAME_BOX.inner_to_outer(m_box)); // White "A" button prompt
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); // Green RGB(189, 205, 0)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_header_box)); // White
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_divider_box)); // Brown RGB(136, 100, 38)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_body_box)); // Beige RGB(255, 245, 204)
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); // Green
}

bool PokedexRegisteredDetector::detect(const ImageViewRGB32& screen){
Expand Down Expand Up @@ -86,6 +96,30 @@ bool PokedexRegisteredDetector::detect(const ImageViewRGB32& screen){
}
);

if (!found){
m_last_detected_box.reset();

ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box);
ImageViewRGB32 header_image = extract_box_reference(game_screen, m_header_box);
ImageViewRGB32 divider_image = extract_box_reference(game_screen, m_divider_box);
ImageViewRGB32 body_image = extract_box_reference(game_screen, m_body_box);
ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box);

if (is_solid(top_image, { 0.480, 0.520, 0.000 }, 0.25, 20)
&& is_white(header_image)
&& is_solid(divider_image, { 0.496, 0.365, 0.139 }, 0.25, 20)
&& is_solid(body_image, { 0.362, 0.348, 0.290 }, 0.25, 20)
&& is_solid(bottom_image, { 0.480, 0.520, 0.000 }, 0.25, 20)
&& !is_white(top_image)
&& !is_white(divider_image)
&& !is_white(bottom_image)
){
return true;
}

return false;
}

if (m_overlay){
if (found){
m_last_detected_box.emplace(*m_overlay, GAME_BOX.inner_to_outer(m_last_detected), COLOR_GREEN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ namespace PokemonFRLG{

// Detects the white "A" button prompt that appears in the bottom right of the
// screen when a Pokémon is registered in the Pokédex.
// If that fails, detect the various colors of the Pokédex registration screen.
class PokedexRegisteredDetector : public StaticScreenDetector{
public:
PokedexRegisteredDetector(
Color color,
VideoOverlay* overlay,
const ImageFloatBox& box = ImageFloatBox(0.85, 0.923, 0.082, 0.070)
VideoOverlay* overlay
);

virtual void make_overlays(VideoOverlaySet& items) const override;
Expand All @@ -35,6 +35,11 @@ class PokedexRegisteredDetector : public StaticScreenDetector{
Color m_color;
VideoOverlay* m_overlay;
const ImageFloatBox m_box;
const ImageFloatBox m_top_box;
const ImageFloatBox m_header_box;
const ImageFloatBox m_divider_box;
const ImageFloatBox m_body_box;
const ImageFloatBox m_bottom_box;

ImageFloatBox m_last_detected;
std::optional<OverlayBoxScope> m_last_detected_box;
Expand All @@ -45,10 +50,9 @@ class PokedexRegisteredWatcher : public DetectorToFinder<PokedexRegisteredDetect
PokedexRegisteredWatcher(
Color color,
VideoOverlay* overlay,
const ImageFloatBox& box = ImageFloatBox(0.85, 0.923, 0.082, 0.070),
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(250)
)
: DetectorToFinder("PokedexRegisteredWatcher", hold_duration, color, overlay, box)
: DetectorToFinder("PokedexRegisteredWatcher", hold_duration, color, overlay)
{}
};

Expand Down
Loading
Loading