Skip to content

Commit d0874ff

Browse files
committed
More API simplication.
1 parent bb397f8 commit d0874ff

17 files changed

+50
-89
lines changed

SerialPrograms/Source/PokemonBDSP/Programs/PokemonBDSP_GameEntry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bool gamemenu_to_ingame(
3333
stream.log("Waiting to enter game...");
3434
int ret = wait_until(
3535
stream, context,
36-
std::chrono::milliseconds(enter_game_timeout * (1000 / TICKS_PER_SECOND)),
36+
enter_game_timeout,
3737
{{detector}}
3838
);
3939
if (ret == 0){

SerialPrograms/Source/PokemonBDSP/Programs/PokemonBDSP_GameEntry.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef PokemonAutomation_PokemonBDSP_GameEntry_H
88
#define PokemonAutomation_PokemonBDSP_GameEntry_H
99

10-
#include "CommonFramework/Tools/VideoStream.h"
1110
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
1211
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1312

@@ -19,16 +18,6 @@ namespace PokemonBDSP{
1918
using namespace std::chrono_literals;
2019

2120

22-
bool gamemenu_to_ingame(
23-
VideoStream& stream, ProControllerContext& context,
24-
Milliseconds mash_duration, Milliseconds enter_game_timeout
25-
);
26-
bool openedgame_to_ingame(
27-
ProgramEnvironment& env, VideoStream& stream, ProControllerContext& context,
28-
Milliseconds load_game_timeout,
29-
Milliseconds mash_duration, Milliseconds enter_game_timeout,
30-
Milliseconds post_wait_time = 1000ms
31-
);
3221
bool reset_game_from_home(
3322
ProgramEnvironment& env,
3423
ConsoleHandle& console, ProControllerContext& context,

SerialPrograms/Source/PokemonLA/Programs/Farming/PokemonLA_LeapGrinder.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1212
#include "CommonTools/Async/InferenceRoutines.h"
1313
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
14-
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1514
#include "Pokemon/Pokemon_Strings.h"
1615
#include "Pokemon/Pokemon_Notification.h"
1716
#include "Pokemon/Inference/Pokemon_NameReader.h"
@@ -316,10 +315,7 @@ void LeapGrinder::program(SingleSwitchProgramEnvironment& env, ProControllerCont
316315
e.send_notification(env, NOTIFICATION_ERROR_RECOVERABLE);
317316

318317
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
319-
fresh_from_reset = reset_game_from_home(
320-
env, env.console, context,
321-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
322-
);
318+
fresh_from_reset = reset_game_from_home(env, env.console, context);
323319
// Switch from items to pokemons
324320
pbf_press_button(context, BUTTON_X, 20, 30);
325321
}

SerialPrograms/Source/PokemonLA/Programs/Farming/PokemonLA_NuggetFarmerHighlands.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "CommonFramework/Notifications/ProgramNotifications.h"
99
#include "CommonFramework/ProgramStats/StatsTracking.h"
1010
#include "CommonTools/Async/InferenceRoutines.h"
11-
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1211
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1312
#include "Pokemon/Pokemon_Strings.h"
1413
#include "PokemonLA/PokemonLA_Settings.h"
@@ -239,10 +238,7 @@ void NuggetFarmerHighlands::program(SingleSwitchProgramEnvironment& env, ProCont
239238
e.send_notification(env, NOTIFICATION_ERROR_RECOVERABLE);
240239

241240
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
242-
fresh_from_reset = reset_game_from_home(
243-
env, env.console, context,
244-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
245-
);
241+
fresh_from_reset = reset_game_from_home(env, env.console, context);
246242
}
247243
}
248244

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_OutbreakFinder.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "Pokemon/Pokemon_Strings.h"
2020
#include "Pokemon/Resources/Pokemon_PokemonNames.h"
2121
#include "Pokemon/Inference/Pokemon_NameReader.h"
22-
#include "PokemonLA/PokemonLA_TravelLocations.h"
23-
#include "PokemonLA/Inference/Map/PokemonLA_MapDetector.h"
2422
#include "PokemonLA/Inference/Map/PokemonLA_SelectedRegionDetector.h"
2523
#include "PokemonLA/Inference/Map/PokemonLA_OutbreakReader.h"
2624
#include "PokemonLA/PokemonLA_Settings.h"
@@ -497,10 +495,7 @@ std::vector<std::string> OutbreakFinder::run_iteration(
497495
env.log("No target MMO sprite found. Reset game...");
498496
env.console.overlay().add_log("No target MMO");
499497
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
500-
fresh_from_reset = reset_game_from_home(
501-
env, env.console, context,
502-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
503-
);
498+
fresh_from_reset = reset_game_from_home(env, env.console, context);
504499
}
505500
}
506501

@@ -532,10 +527,7 @@ void OutbreakFinder::program(SingleSwitchProgramEnvironment& env, ProControllerC
532527
// so we reset the game now and skip the ongoing outbreaks
533528
env.log("Reset game and skip ongoing outbreaks");
534529
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
535-
fresh_from_reset = reset_game_from_home(
536-
env, env.console, context,
537-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
538-
);
530+
fresh_from_reset = reset_game_from_home(env, env.console, context);
539531

540532
// Go to region and return.
541533
bool inside_travel_map = false;

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_RamanasIslandCombee.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1212
#include "CommonTools/Async/InferenceRoutines.h"
1313
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
14-
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1514
#include "Pokemon/Pokemon_Strings.h"
1615
#include "Pokemon/Inference/Pokemon_NameReader.h"
1716
#include "PokemonLA/PokemonLA_Settings.h"
@@ -341,10 +340,7 @@ void RamanasCombeeFinder::program(SingleSwitchProgramEnvironment& env, ProContro
341340
e.send_notification(env, NOTIFICATION_ERROR_RECOVERABLE);
342341

343342
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
344-
fresh_from_reset = reset_game_from_home(
345-
env, env.console, context,
346-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
347-
);
343+
fresh_from_reset = reset_game_from_home(env, env.console, context);
348344
}
349345
}
350346

SerialPrograms/Source/PokemonLA/Programs/PokemonLA_GameEntry.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ bool reset_game_to_gamemenu(
3232
return openedgame_to_gamemenu(console, context, GameSettings::instance().START_GAME_WAIT1);
3333
}
3434

35+
// From the game menu screen (where "Press A" is displayed to enter the game),
36+
// mash A to enter the game and wait until the black screen is gone.
3537
bool gamemenu_to_ingame(
3638
VideoStream& stream, ProControllerContext& context,
3739
Milliseconds mash_duration, Milliseconds enter_game_timeout
@@ -43,7 +45,7 @@ bool gamemenu_to_ingame(
4345
stream.log("Waiting to enter game...");
4446
int ret = wait_until(
4547
stream, context,
46-
std::chrono::milliseconds(enter_game_timeout * (1000 / TICKS_PER_SECOND)),
48+
std::chrono::milliseconds(enter_game_timeout),
4749
{{detector}}
4850
);
4951
if (ret == 0){
@@ -58,15 +60,16 @@ bool gamemenu_to_ingame(
5860
bool reset_game_from_home(
5961
ProgramEnvironment& env,
6062
ConsoleHandle& console, ProControllerContext& context,
61-
bool tolerate_update_menu,
62-
uint16_t post_wait_time
63+
Milliseconds enter_game_mash,
64+
Milliseconds enter_game_timeout,
65+
Milliseconds post_wait_time
6366
){
6467
bool ok = true;
65-
ok &= reset_game_to_gamemenu(console, context, tolerate_update_menu);
68+
ok &= reset_game_to_gamemenu(console, context, true);
6669
ok &= gamemenu_to_ingame(
6770
console, context,
68-
GameSettings::instance().ENTER_GAME_MASH0,
69-
GameSettings::instance().ENTER_GAME_WAIT0
71+
enter_game_mash,
72+
enter_game_timeout
7073
);
7174
if (!ok){
7275
dump_image(console.logger(), env.program_info(), console.video(), "StartGame");
@@ -76,6 +79,18 @@ bool reset_game_from_home(
7679
context.wait_for_all_requests();
7780
return ok;
7881
}
82+
bool reset_game_from_home(
83+
ProgramEnvironment& env,
84+
ConsoleHandle& console, ProControllerContext& context,
85+
Milliseconds post_wait_time
86+
){
87+
return reset_game_from_home(
88+
env, console, context,
89+
GameSettings::instance().ENTER_GAME_MASH0,
90+
GameSettings::instance().ENTER_GAME_WAIT0,
91+
post_wait_time
92+
);
93+
}
7994

8095

8196

SerialPrograms/Source/PokemonLA/Programs/PokemonLA_GameEntry.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#ifndef PokemonAutomation_PokemonLA_GameEntry_H
88
#define PokemonAutomation_PokemonLA_GameEntry_H
99

10-
#include <stdint.h>
11-
#include "CommonFramework/Tools/VideoStream.h"
1210
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
1311
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1412

@@ -17,6 +15,7 @@ namespace PokemonAutomation{
1715
namespace NintendoSwitch{
1816
namespace PokemonLA{
1917

18+
using namespace std::chrono_literals;
2019

2120

2221
// From Switch Home menu, reset game and wait until the game menu screen (where
@@ -26,22 +25,21 @@ bool reset_game_to_gamemenu(
2625
bool tolerate_update_menu
2726
);
2827

29-
// From the game menu screen (where "Press A" is displayed to enter the game),
30-
// mash A to enter the game and wait until the black screen is gone.
31-
bool gamemenu_to_ingame(
32-
VideoStream& stream, ProControllerContext& context,
33-
Milliseconds mash_duration, Milliseconds enter_game_timeout
34-
);
35-
3628
// From Switch Home menu, start game and wait until the player character
3729
// appears in game.
3830
// post_wait_time: how many ticks to wait after the black screen
3931
// (shown when loading the map) is over.
4032
bool reset_game_from_home(
4133
ProgramEnvironment& env,
4234
ConsoleHandle& console, ProControllerContext& context,
43-
bool tolerate_update_menu,
44-
uint16_t post_wait_time = 125
35+
Milliseconds enter_game_mash,
36+
Milliseconds enter_game_timeout,
37+
Milliseconds post_wait_time
38+
);
39+
bool reset_game_from_home(
40+
ProgramEnvironment& env,
41+
ConsoleHandle& console, ProControllerContext& context,
42+
Milliseconds post_wait_time = 1000ms
4543
);
4644

4745

SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_BurmyFinder.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1414
#include "CommonTools/Async/InferenceRoutines.h"
1515
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
16-
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1716
#include "Pokemon/Pokemon_Strings.h"
1817
#include "Pokemon/Pokemon_Notification.h"
1918
#include "Pokemon/Inference/Pokemon_NameReader.h"
@@ -844,8 +843,7 @@ void BurmyFinder::program(SingleSwitchProgramEnvironment& env, ProControllerCont
844843

845844
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
846845
fresh_from_reset = reset_game_from_home(
847-
env, env.console, context,
848-
ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST
846+
env, env.console, context
849847
);
850848
}
851849
}

SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_CrobatFinder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "CommonFramework/ProgramStats/StatsTracking.h"
1010
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1111
#include "CommonTools/Async/InferenceRoutines.h"
12-
#include "NintendoSwitch/NintendoSwitch_Settings.h"
1312
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1413
#include "Pokemon/Pokemon_Strings.h"
1514
#include "PokemonLA/PokemonLA_Settings.h"
@@ -182,7 +181,7 @@ void CrobatFinder::run_iteration(SingleSwitchProgramEnvironment& env, ProControl
182181
env.console.log("No shiny detected, restarting the game!");
183182

184183
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
185-
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
184+
reset_game_from_home(env, env.console, context);
186185
}
187186

188187

@@ -202,7 +201,7 @@ void CrobatFinder::program(SingleSwitchProgramEnvironment& env, ProControllerCon
202201
e.send_notification(env, NOTIFICATION_ERROR_RECOVERABLE);
203202

204203
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
205-
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
204+
reset_game_from_home(env, env.console, context);
206205
}
207206
}
208207

0 commit comments

Comments
 (0)