Skip to content

Commit 94a5d32

Browse files
committed
Finish the ConsoleHandle -> VideoStream reduction where appliable.
1 parent 8626e13 commit 94a5d32

File tree

124 files changed

+2441
-1940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2441
-1940
lines changed

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1313
#include "Pokemon/Pokemon_Strings.h"
1414
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
15-
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
15+
#include "PokemonSV/Inference/PokemonSV_MainMenuDetector.h"
1616
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
17+
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
18+
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
1719
#include "PokemonSV_AutoStory_Segment_00.h"
1820
#include "PokemonSV_AutoStory_Segment_01.h"
1921
#include "PokemonSV_AutoStory_Segment_02.h"
@@ -549,7 +551,7 @@ void AutoStory::value_changed(void* object){
549551

550552
void AutoStory::test_checkpoints(
551553
SingleSwitchProgramEnvironment& env,
552-
ConsoleHandle& console,
554+
VideoStream& stream,
553555
SwitchControllerContext& context,
554556
int start, int end,
555557
int loop, int start_loop, int end_loop
@@ -611,7 +613,7 @@ void AutoStory::test_checkpoints(
611613

612614
for (int checkpoint = start; checkpoint <= end; checkpoint++){
613615
if (checkpoint == 0){
614-
console.log("checkpoint_0");
616+
stream.log("checkpoint_0");
615617
checkpoint_list[checkpoint]();
616618
continue;
617619
}
@@ -629,26 +631,26 @@ void AutoStory::test_checkpoints(
629631
for (int i = 0; i < loop; i++){
630632
if (i > 0){
631633
try {
632-
reset_game(env.program_info(), console, context);
634+
reset_game(env.program_info(), stream, context);
633635
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
634636
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
635637
env.log("Wait 5 seconds.");
636638
context.wait_for(Milliseconds(5 * 1000));
637639
}catch(...){
638640
// try one more time
639-
reset_game(env.program_info(), console, context);
641+
reset_game(env.program_info(), stream, context);
640642
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
641643
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
642644
env.log("Wait 5 seconds.");
643645
context.wait_for(Milliseconds(5 * 1000));
644646

645647
}
646648
}
647-
console.log("checkpoint_" + number + ": loop " + std::to_string(i));
649+
stream.log("checkpoint_" + number + ": loop " + std::to_string(i));
648650
checkpoint_list[checkpoint]();
649651
}
650652
}else{
651-
console.log("checkpoint_" + number + ".");
653+
stream.log("checkpoint_" + number + ".");
652654
checkpoint_list[checkpoint]();
653655
}
654656

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef PokemonAutomation_PokemonSV_AutoStory_H
88
#define PokemonAutomation_PokemonSV_AutoStory_H
99

10-
#include <functional>
1110
#include "Common/Cpp/Options/StaticTextOption.h"
1211
#include "Common/Cpp/Options/SimpleIntegerOption.h"
1312
#include "Common/Cpp/Options/FloatingPointOption.h"
@@ -16,7 +15,6 @@
1615
#include "CommonTools/Options/StringSelectOption.h"
1716
#include "CommonTools/Options/LanguageOCROption.h"
1817
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
19-
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
2018
#include "PokemonSV_AutoStoryTools.h"
2119

2220
namespace PokemonAutomation{
@@ -46,7 +44,7 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
4644
// test each checkpoints "loop" number of times
4745
void test_checkpoints(
4846
SingleSwitchProgramEnvironment& env,
49-
ConsoleHandle& console,
47+
VideoStream& stream,
5048
SwitchControllerContext& context,
5149
int start, int end,
5250
int loop, int start_loop, int end_loop

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "CommonFramework/Exceptions/OperationFailedException.h"
1010
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1111
#include "CommonTools/OCR/OCR_NumberReader.h"
12-
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1312
#include "PokemonSV_MenuOption.h"
1413
#include "PokemonSV/Inference/PokemonSV_MenuOptionReader.h"
1514

@@ -24,14 +23,14 @@ namespace PokemonSV{
2423
MenuOption::~MenuOption() = default;
2524

2625
MenuOption::MenuOption(
27-
ConsoleHandle& console,
26+
VideoStream& stream,
2827
SwitchControllerContext& context,
2928
Language language
3029
)
31-
: m_console(console)
30+
: m_stream(stream)
3231
, m_context(context)
3332
, m_language(language)
34-
, m_overlays(console.overlay())
33+
, m_overlays(stream.overlay())
3534
, m_arrow(COLOR_CYAN, GradientArrowType::RIGHT, {0.02, 0.10, 0.05, 0.80})
3635
{
3736
// reader.make_overlays(m_overlays);
@@ -68,7 +67,7 @@ void MenuOption::set_target_option(const std::vector<MenuOptionToggleEnum>& targ
6867
OperationFailedException::fire(
6968
ErrorReport::SEND_ERROR_REPORT,
7069
"MenuOption::set_target_option(): Unable to set option to the correct toggle.",
71-
m_console
70+
m_stream
7271
);
7372

7473
}
@@ -80,7 +79,7 @@ int8_t MenuOption::get_selected_index(const ImageViewRGB32& screen) const {
8079
OperationFailedException::fire(
8180
ErrorReport::SEND_ERROR_REPORT,
8281
"MenuOption::get_selected_index(): Unable to find cursor.",
83-
m_console
82+
m_stream
8483
);
8584
}
8685

@@ -92,7 +91,7 @@ int8_t MenuOption::get_selected_index(const ImageViewRGB32& screen) const {
9291
OperationFailedException::fire(
9392
ErrorReport::SEND_ERROR_REPORT,
9493
"MenuOption::get_selected_index(): Invalid cursor slot.",
95-
m_console
94+
m_stream
9695
);
9796
}
9897
// cout << "selected index:" + std::to_string(selected_index) << endl;
@@ -103,7 +102,7 @@ int8_t MenuOption::get_selected_index(const ImageViewRGB32& screen) const {
103102
std::string MenuOption::read_option(const ImageViewRGB32& cropped) const{
104103
// cropped.save("test.png");
105104
const auto ocr_result = MenuOptionReader::instance().read_substring(
106-
m_console,
105+
m_stream.logger(),
107106
m_language,
108107
cropped, OCR::BLACK_TEXT_FILTERS()
109108
);
@@ -118,7 +117,7 @@ std::string MenuOption::read_option(const ImageViewRGB32& cropped) const{
118117
if (results.empty()){
119118
if (m_language == Language::German){
120119
// German Menu Option uses numbers for text speed settings, which string OCR has trouble with detecting.
121-
int16_t number = read_number(m_console, cropped);
120+
int16_t number = read_number(m_stream.logger(), cropped);
122121
switch (number){
123122
case 1:
124123
return "slow";
@@ -135,7 +134,7 @@ std::string MenuOption::read_option(const ImageViewRGB32& cropped) const{
135134
OperationFailedException::fire(
136135
ErrorReport::SEND_ERROR_REPORT,
137136
"MenuOption::read_option(): Unable to read item. Ambiguous or multiple results.",
138-
m_console
137+
m_stream
139138
);
140139
}
141140

@@ -157,7 +156,7 @@ int16_t MenuOption::read_number(
157156

158157
std::string MenuOption::read_option_item() const{
159158
m_context.wait_for_all_requests();
160-
VideoSnapshot screen = m_console.video().snapshot();
159+
VideoSnapshot screen = m_stream.video().snapshot();
161160

162161
ImageFloatBox selected_box = m_boxes_item[get_selected_index(screen)];
163162
ImageViewRGB32 cropped = extract_box_reference(screen, selected_box);
@@ -167,7 +166,7 @@ std::string MenuOption::read_option_item() const{
167166

168167
std::string MenuOption::read_option_toggle() const{
169168
m_context.wait_for_all_requests();
170-
VideoSnapshot screen = m_console.video().snapshot();
169+
VideoSnapshot screen = m_stream.video().snapshot();
171170

172171
ImageFloatBox selected_box = m_boxes_toggle[get_selected_index(screen)];
173172
ImageViewRGB32 cropped = extract_box_reference(screen, selected_box);

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#include <array>
1111
#include "CommonFramework/Language.h"
1212
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
13+
#include "CommonFramework/Tools/VideoStream.h"
1314
#include "NintendoSwitch/Controllers/NintendoSwitch_Controller.h"
1415
#include "PokemonSV/Inference/Dialogs/PokemonSV_GradientArrowDetector.h"
1516
#include "PokemonSV_MenuOptionDatabase.h"
1617

1718
namespace PokemonAutomation{
1819
class AsyncDispatcher;
1920
namespace NintendoSwitch{
20-
class ConsoleHandle;
2121
namespace PokemonSV{
2222

2323

@@ -26,7 +26,7 @@ class MenuOption{
2626
public:
2727
~MenuOption();
2828
MenuOption(
29-
ConsoleHandle& console, SwitchControllerContext& context,
29+
VideoStream& stream, SwitchControllerContext& context,
3030
Language language
3131
);
3232

@@ -64,7 +64,7 @@ class MenuOption{
6464

6565

6666
private:
67-
ConsoleHandle& m_console;
67+
VideoStream& m_stream;
6868
SwitchControllerContext& m_context;
6969
Language m_language;
7070
VideoOverlaySet m_overlays;

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace PokemonAutomation{
1313
class AsyncDispatcher;
1414
namespace NintendoSwitch{
15-
class ConsoleHandle;
1615
namespace PokemonSV{
1716

1817

SerialPrograms/Source/PokemonSV/Programs/Battles/PokemonSV_Battles.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace PokemonAutomation{
1515
struct ProgramInfo;
1616
namespace NintendoSwitch{
17-
class ConsoleHandle;
1817
namespace PokemonSV{
1918

2019

0 commit comments

Comments
 (0)