-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathPokemonFRLG_PartyHeldItemDetector.h
More file actions
83 lines (68 loc) · 2.11 KB
/
PokemonFRLG_PartyHeldItemDetector.h
File metadata and controls
83 lines (68 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Party Held Item Detector
*
* From: https://github.com/PokemonAutomation/
*
*/
#ifndef PokemonAutomation_PokemonFRLG_PartyHeldItemDetector_H
#define PokemonAutomation_PokemonFRLG_PartyHeldItemDetector_H
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/VisualDetector.h"
namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{
enum class PartyHeldItemSlot{
SLOT_1,
SLOT_2,
SLOT_3,
SLOT_4,
SLOT_5,
SLOT_6
};
class PartyHeldItemDetector : public StaticScreenDetector{
public:
PartyHeldItemDetector(
Color color,
VideoOverlay* overlay,
const ImageFloatBox& box
);
PartyHeldItemDetector(
Color color,
VideoOverlay* overlay,
PartyHeldItemSlot slot
);
static ImageFloatBox box_for_slot(PartyHeldItemSlot slot);
const ImageFloatBox& last_detected() const { return m_last_detected; }
virtual void make_overlays(VideoOverlaySet& items) const override;
// This is not const so that detectors can save/cache state.
virtual bool detect(const ImageViewRGB32& screen) override;
private:
friend class PartyHeldItemWatcher;
const Color m_color;
VideoOverlay* m_overlay;
const ImageFloatBox m_box;
ImageFloatBox m_last_detected;
std::optional<OverlayBoxScope> m_last_detected_box;
};
class PartyHeldItemWatcher : public DetectorToFinder<PartyHeldItemDetector>{
public:
PartyHeldItemWatcher(
Color color,
VideoOverlay* overlay,
const ImageFloatBox& box,
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(250)
)
: DetectorToFinder("PartyHeldItemWatcher", hold_duration, color, overlay, box)
{}
PartyHeldItemWatcher(
Color color,
VideoOverlay* overlay,
PartyHeldItemSlot slot,
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(250)
)
: DetectorToFinder("PartyHeldItemWatcher", hold_duration, color, overlay, box_for_slot(slot))
{}
};
}
}
}
#endif