Skip to content

Commit 774b243

Browse files
committed
Fix Item Printer incorrect material selection menu detection.
1 parent d67081c commit 774b243

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Main Menu Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonTools/Images/SolidColorTest.h"
8+
#include "PokemonSV_ItemPrinterMenuDetector.h"
9+
10+
namespace PokemonAutomation{
11+
namespace NintendoSwitch{
12+
namespace PokemonSV{
13+
14+
15+
ItemPrinterMenuDetector::ItemPrinterMenuDetector(Color color)
16+
: m_color(color)
17+
, m_bottom(0.05, 0.945, 0.50, 0.04)
18+
, m_buttons(color, WhiteButton::ButtonX, {0.63, 0.93, 0.17, 0.06})
19+
{}
20+
21+
void ItemPrinterMenuDetector::make_overlays(VideoOverlaySet& items) const{
22+
items.add(m_color, m_bottom);
23+
m_buttons.make_overlays(items);
24+
}
25+
bool ItemPrinterMenuDetector::detect(const ImageViewRGB32& screen) const{
26+
ImageViewRGB32 bottom = extract_box_reference(screen, m_bottom);
27+
ImageStats bottom_stats = image_stats(bottom);
28+
if (!is_solid(bottom_stats, {0, 0.318898, 0.681102})){
29+
return false;
30+
}
31+
if (!m_buttons.detect(screen)){
32+
return false;
33+
}
34+
return true;
35+
}
36+
37+
38+
}
39+
}
40+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Main Menu Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonSV_ItemPrinterMenuDetector_H
8+
#define PokemonAutomation_PokemonSV_ItemPrinterMenuDetector_H
9+
10+
#include "CommonTools/VisualDetector.h"
11+
#include "PokemonSV/Inference/PokemonSV_WhiteButtonDetector.h"
12+
13+
namespace PokemonAutomation{
14+
namespace NintendoSwitch{
15+
namespace PokemonSV{
16+
17+
18+
19+
class ItemPrinterMenuDetector : public StaticScreenDetector{
20+
public:
21+
ItemPrinterMenuDetector(Color color);
22+
23+
virtual void make_overlays(VideoOverlaySet& items) const override;
24+
virtual bool detect(const ImageViewRGB32& screen) const override;
25+
26+
27+
private:
28+
Color m_color;
29+
ImageFloatBox m_bottom;
30+
WhiteButtonWatcher m_buttons;
31+
};
32+
class ItemPrinterMenuWatcher : public DetectorToFinder<ItemPrinterMenuDetector>{
33+
public:
34+
ItemPrinterMenuWatcher(Color color)
35+
: DetectorToFinder("ItemPrinterMenuWatcher", std::chrono::milliseconds(250), color)
36+
{}
37+
};
38+
39+
40+
41+
42+
}
43+
}
44+
}
45+
#endif

SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "PokemonSV/Inference/PokemonSV_WhiteButtonDetector.h"
2626
#include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h"
2727
#include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h"
28+
#include "PokemonSV/Inference/ItemPrinter/PokemonSV_ItemPrinterMenuDetector.h"
2829
#include "PokemonSV/Inference/ItemPrinter/PokemonSV_ItemPrinterMaterialDetector.h"
2930
#include "PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h"
3031
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
@@ -953,7 +954,7 @@ uint32_t ItemPrinterRNG::check_num_happiny_dust(
953954
AdvanceDialogWatcher dialog(COLOR_RED);
954955
PromptDialogWatcher prompt(COLOR_GREEN);
955956
DateChangeWatcher date_reader;
956-
WhiteButtonWatcher material(COLOR_GREEN, WhiteButton::ButtonX, {0.63, 0.93, 0.17, 0.06});
957+
ItemPrinterMenuWatcher material(COLOR_GREEN);
957958
int ret = wait_until(
958959
env.console, context, std::chrono::seconds(120),
959960
{

0 commit comments

Comments
 (0)