Skip to content

Commit e3dcad1

Browse files
kichithewolfGin890
authored andcommitted
light blue dialog and blue arrow
1 parent b859ffc commit e3dcad1

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ class DialogTealArrowMatcher : public ImageMatch::WaterfillTemplateMatcher{
105105
}
106106
};
107107

108+
class DialogBlueArrowMatcher : public ImageMatch::WaterfillTemplateMatcher{
109+
public:
110+
DialogBlueArrowMatcher()
111+
: WaterfillTemplateMatcher(
112+
"PokemonLZA/DialogBox/DialogBoxBlueArrow-Template.png",
113+
Color(0xff005460), Color(0xff6BBEC9), 50
114+
)
115+
{
116+
m_aspect_ratio_lower = 0.9;
117+
m_aspect_ratio_upper = 1.1;
118+
m_area_ratio_lower = 0.8;
119+
m_area_ratio_upper = 1.1;
120+
}
121+
122+
static const ImageMatch::WaterfillTemplateMatcher& instance() {
123+
static DialogBlueArrowMatcher matcher;
124+
return matcher;
125+
}
126+
};
127+
108128

109129
namespace {
110130

@@ -143,6 +163,33 @@ bool detect_white_arrow(const ImageViewRGB32& screen, PokemonAutomation::ImageFl
143163
return found;
144164
}
145165

166+
bool detect_blue_arrow(const ImageViewRGB32& screen, PokemonAutomation::ImageFloatBox& found_box){
167+
double screen_rel_size = (screen.height() / 1080.0);
168+
double screen_rel_size_2 = screen_rel_size * screen_rel_size;
169+
170+
double min_area_1080p = 150.0;
171+
double rmsd_threshold = 120.0;
172+
size_t min_area = size_t(screen_rel_size_2 * min_area_1080p);
173+
174+
const std::vector<std::pair<uint32_t, uint32_t>> FILTERS = {
175+
{0x005460, 0xff7FC0C9},
176+
};
177+
178+
bool found = match_template_by_waterfill(
179+
screen.size(),
180+
extract_box_reference(screen, DIALOG_ARROW_BOX),
181+
DialogBlueArrowMatcher::instance(),
182+
FILTERS,
183+
{min_area, SIZE_MAX},
184+
rmsd_threshold,
185+
[&](Kernels::Waterfill::WaterfillObject& object) -> bool {
186+
found_box = translate_to_parent(screen, DIALOG_ARROW_BOX, object);
187+
return true;
188+
}
189+
);
190+
return found;
191+
}
192+
146193
} // end anonymous namespace
147194

148195

@@ -486,6 +533,43 @@ bool TransparentBattleDialogDetector::detect(const ImageViewRGB32& screen){
486533
}
487534

488535

536+
LightBlueDialogDetector::LightBlueDialogDetector(Color color, VideoOverlay* overlay)
537+
: m_color(color)
538+
, m_overlay(overlay)
539+
, m_corner(0.765093, 0.933594, 0.006586, 0.013672)
540+
{}
541+
void LightBlueDialogDetector::make_overlays(VideoOverlaySet& items) const{
542+
items.add(m_color, m_corner);
543+
items.add(m_color, DIALOG_ARROW_BOX);
544+
}
545+
bool LightBlueDialogDetector::detect(const ImageViewRGB32& screen){
546+
do{
547+
if (is_solid(
548+
extract_box_reference(screen, m_corner),
549+
{0.108317, 0.462282, 0.429400},
550+
0.25
551+
)){
552+
break;
553+
}
554+
m_last_detected_box_scope.reset();
555+
// cout << "not solid" << endl;
556+
return false;
557+
}while (false);
558+
559+
const bool found = detect_blue_arrow(screen, m_last_detected_box);
560+
561+
if (m_overlay){
562+
if (found){
563+
m_last_detected_box_scope.emplace(*m_overlay, m_last_detected_box, COLOR_GREEN);
564+
}else{
565+
m_last_detected_box_scope.reset();
566+
}
567+
}
568+
569+
return found;
570+
}
571+
572+
489573

490574
}
491575
}

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,37 @@ class TransparentBattleDialogWatcher : public DetectorToFinder<TransparentBattle
206206
};
207207

208208

209+
// Light blue dialog box for holograms
210+
class LightBlueDialogDetector : public StaticScreenDetector{
211+
public:
212+
LightBlueDialogDetector(Color color = COLOR_RED, VideoOverlay* overlay = nullptr);
213+
214+
virtual void make_overlays(VideoOverlaySet& items) const override;
215+
216+
// This is not const so that detectors can save/cache state.
217+
virtual bool detect(const ImageViewRGB32& screen) override;
218+
219+
private:
220+
friend class LightBlueDialogWatcher;
221+
222+
const Color m_color;
223+
VideoOverlay* m_overlay;
224+
const ImageFloatBox m_corner;
225+
226+
ImageFloatBox m_last_detected_box;
227+
std::optional<OverlayBoxScope> m_last_detected_box_scope;
228+
};
229+
class LightBlueDialogWatcher : public DetectorToFinder<LightBlueDialogDetector>{
230+
public:
231+
LightBlueDialogWatcher(
232+
Color color = COLOR_RED,
233+
VideoOverlay* overlay = nullptr,
234+
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(250)
235+
)
236+
: DetectorToFinder("BlueDialogWatcher", hold_duration, color, overlay)
237+
{}
238+
};
239+
209240

210241
}
211242
}

0 commit comments

Comments
 (0)