Skip to content

Commit f63222c

Browse files
committed
Use overworld to detect when you're done changing regions.
1 parent 0120bb7 commit f63222c

File tree

2 files changed

+52
-20
lines changed

2 files changed

+52
-20
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,17 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
265265
SwitchControllerContext context(scope, console.controller());
266266
VideoOverlaySet overlays(overlay);
267267

268-
ssf_press_button(context, BUTTON_A, 0, 1000, 0);
269-
pbf_move_left_joystick(context, 0, 0, 20, 0);
268+
269+
270+
271+
ImageRGB32 image("20250126-022538815397.png");
272+
MaxLairInternal::BattleMenuReader reader(overlay, Language::Korean);
273+
reader.read_opponent_in_summary(logger, image);
274+
275+
276+
277+
// ssf_press_button(context, BUTTON_A, 0, 1000, 0);
278+
// pbf_move_left_joystick(context, 0, 0, 20, 0);
270279

271280

272281

@@ -283,6 +292,9 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
283292

284293

285294

295+
296+
297+
286298
#if 0
287299
ImageRGB32 image("20250112-194339635973.png");
288300

SerialPrograms/Source/PokemonLA/Programs/PokemonLA_RegionNavigation.cpp

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#include "CommonTools/Async/InferenceRoutines.h"
1111
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1212
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
13+
#include "PokemonLA/Inference/Objects/PokemonLA_ButtonDetector.h"
14+
#include "PokemonLA/Inference/Objects/PokemonLA_ArcPhoneDetector.h"
1315
#include "PokemonLA/Inference/Map/PokemonLA_MapDetector.h"
1416
#include "PokemonLA/Inference/Map/PokemonLA_SelectedRegionDetector.h"
15-
#include "PokemonLA/Inference/Objects/PokemonLA_ButtonDetector.h"
1617
#include "PokemonLA/PokemonLA_Settings.h"
1718
#include "PokemonLA/PokemonLA_TravelLocations.h"
1819
#include "PokemonLA/Programs/PokemonLA_EscapeFromAttack.h"
@@ -172,26 +173,45 @@ void mash_A_to_change_region(
172173
context.wait_for(std::chrono::milliseconds(1000));
173174
#endif
174175

175-
stream.log("Waiting for end of loading screen...");
176-
BlackScreenOverWatcher black_screen1a(COLOR_RED, {0.20, 0.02, 0.60, 0.05});
177-
BlackScreenOverWatcher black_screen1b(COLOR_RED, {0.20, 0.93, 0.60, 0.05});
178-
int ret = run_until<SwitchControllerContext>(
179-
stream, context,
180-
[](SwitchControllerContext& context){
181-
pbf_mash_button(context, BUTTON_A, GameSettings::instance().LOAD_REGION_TIMEOUT);
182-
},
183-
{
184-
{black_screen1a},
185-
{black_screen1b},
176+
{
177+
stream.log("Waiting for end of loading screen...");
178+
BlackScreenOverWatcher black_screen1a(COLOR_RED, {0.20, 0.02, 0.60, 0.05});
179+
BlackScreenOverWatcher black_screen1b(COLOR_RED, {0.20, 0.93, 0.60, 0.05});
180+
int ret = run_until<SwitchControllerContext>(
181+
stream, context,
182+
[](SwitchControllerContext& context){
183+
pbf_mash_button(context, BUTTON_A, GameSettings::instance().LOAD_REGION_TIMEOUT);
184+
},
185+
{
186+
{black_screen1a},
187+
{black_screen1b},
188+
}
189+
);
190+
if (ret < 0){
191+
OperationFailedException::fire(
192+
ErrorReport::SEND_ERROR_REPORT,
193+
"Failed to load into region after timeout.",
194+
stream
195+
);
186196
}
187-
);
188-
if (ret < 0){
189-
OperationFailedException::fire(
190-
ErrorReport::SEND_ERROR_REPORT,
191-
"Failed to load into region after timeout.",
192-
stream
197+
}
198+
{
199+
stream.log("Waiting for overworld...");
200+
ArcPhoneDetector phone(stream.logger(), stream.overlay(), std::chrono::milliseconds(250), true);
201+
int ret = wait_until(
202+
stream, context,
203+
Milliseconds(GameSettings::instance().LOAD_REGION_TIMEOUT * 1000 / TICKS_PER_SECOND),
204+
{phone}
193205
);
206+
if (ret < 0){
207+
OperationFailedException::fire(
208+
ErrorReport::SEND_ERROR_REPORT,
209+
"Failed to load into region after timeout.",
210+
stream
211+
);
212+
}
194213
}
214+
195215
stream.log("Loaded into map...");
196216
context.wait_for(std::chrono::milliseconds((uint64_t)(GameSettings::instance().POST_WARP_DELAY * 1000)));
197217
}

0 commit comments

Comments
 (0)