Skip to content

Commit 9ecd3db

Browse files
author
Gin
committed
Add overworld to box system routine
1 parent 98231ea commit 9ecd3db

File tree

6 files changed

+129
-6
lines changed

6 files changed

+129
-6
lines changed

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_AutoFossil.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "PokemonLZA/Inference/PokemonLZA_ButtonDetector.h"
1313
#include "PokemonLZA/Inference/PokemonLZA_SelectionArrowDetector.h"
1414
#include "PokemonLZA/Inference/PokemonLZA_DialogDetector.h"
15+
#include "PokemonLZA/Programs/PokemonLZA_MenuNavigation.h"
1516
#include "PokemonLZA_AutoFossil.h"
1617

1718
#include <sstream>
@@ -70,7 +71,9 @@ AutoFossil::AutoFossil(){}
7071

7172

7273
void AutoFossil::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
73-
AutoFossil_Descriptor::Stats& stats = env.current_stats<AutoFossil_Descriptor::Stats>();
74+
// AutoFossil_Descriptor::Stats& stats = env.current_stats<AutoFossil_Descriptor::Stats>();
75+
overworld_to_box_system(env.console, context);
76+
return;
7477

7578
// Example loop structure
7679
size_t num_fossils_to_revive = 3;

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1010
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1111
//#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
12+
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
13+
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
1214
#include "PokemonLZA/Inference/PokemonLZA_ButtonDetector.h"
1315
//#include "PokemonLZA/Inference/PokemonLZA_SelectionArrowDetector.h"
1416
//#include "PokemonLZA/Inference/PokemonLZA_DialogDetector.h"

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.h

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

10-
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
11-
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
12-
1310
namespace PokemonAutomation{
11+
12+
template <typename Type> class ControllerContext;
13+
1414
namespace NintendoSwitch{
15+
16+
class ConsoleHandle;
17+
class ProController;
18+
using ProControllerContext = ControllerContext<ProController>;
19+
1520
namespace PokemonLZA{
1621

1722

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* Menu Navigation
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
* Functions to navigate main menu
6+
*/
7+
8+
#include "CommonFramework/Exceptions/OperationFailedException.h"
9+
#include "CommonTools/Async/InferenceRoutines.h"
10+
// #include "CommonTools/VisualDetectors/BlackScreenDetector.h"
11+
// #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
12+
// #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
13+
// #include "PokemonLZA/Inference/PokemonLZA_ButtonDetector.h"
14+
// #include "PokemonLZA/Inference/PokemonLZA_SelectionArrowDetector.h"
15+
// #include "PokemonLZA/Inference/PokemonLZA_DialogDetector.h"
16+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
17+
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
18+
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
19+
#include "PokemonLZA/Inference/Boxes/PokemonLZA_BoxDetection.h"
20+
#include "PokemonLZA/Inference/PokemonLZA_MainMenuDetector.h"
21+
#include "PokemonLZA_MenuNavigation.h"
22+
23+
namespace PokemonAutomation{
24+
namespace NintendoSwitch{
25+
namespace PokemonLZA{
26+
27+
void overworld_to_main_menu(ConsoleHandle& console, ProControllerContext& context){
28+
MainMenuWatcher main_menu_watcher(COLOR_RED, &console.overlay());
29+
int ret = run_until<ProControllerContext>(
30+
console, context,
31+
[&](ProControllerContext& context){
32+
for(int i = 0; i < 5; i++){
33+
pbf_press_button(context, BUTTON_X, 100ms, 2s);
34+
}
35+
},
36+
{{main_menu_watcher}}
37+
);
38+
39+
if (ret < 0){
40+
OperationFailedException::fire(
41+
ErrorReport::SEND_ERROR_REPORT,
42+
"overworld_to_main_menu(): No main menu detected after pressing \"X\" 5 times.",
43+
console
44+
);
45+
}
46+
console.log("Entered main menu.");
47+
}
48+
49+
void overworld_to_box_system(ConsoleHandle& console, ProControllerContext& context){
50+
overworld_to_main_menu(console, context);
51+
BoxWatcher box_watcher(COLOR_RED, &console.overlay());
52+
int ret = run_until<ProControllerContext>(
53+
console, context,
54+
[&](ProControllerContext& context){
55+
for(int i = 0; i < 5; i++){
56+
pbf_press_button(context, BUTTON_A, 100ms, 2s);
57+
}
58+
},
59+
{{box_watcher}}
60+
);
61+
62+
if (ret < 0){
63+
OperationFailedException::fire(
64+
ErrorReport::SEND_ERROR_REPORT,
65+
"overworld_to_box_system(): No box system view detected after pressing \"A\" 5 times from main menu.",
66+
console
67+
);
68+
}
69+
console.log("Entered box system.");
70+
}
71+
72+
73+
}
74+
}
75+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Menu Navigation
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLZA_MenuNavigation_H
8+
#define PokemonAutomation_PokemonLZA_MenuNavigation_H
9+
10+
namespace PokemonAutomation{
11+
12+
template <typename Type> class ControllerContext;
13+
14+
namespace NintendoSwitch{
15+
16+
class ConsoleHandle;
17+
class ProController;
18+
using ProControllerContext = ControllerContext<ProController>;
19+
20+
namespace PokemonLZA{
21+
22+
// From overworld, press X to enter main menu
23+
void overworld_to_main_menu(
24+
ConsoleHandle& console, ProControllerContext& context
25+
);
26+
27+
// From overworld, press X to enter main menu, then A to enter box system
28+
void overworld_to_box_system(
29+
ConsoleHandle& console, ProControllerContext& context
30+
);
31+
32+
33+
}
34+
}
35+
}
36+
#endif

SerialPrograms/SourceFiles.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,18 +1571,20 @@ file(GLOB LIBRARY_SOURCES
15711571
Source/PokemonLZA/Programs/PokemonLZA_ClothingBuyer.h
15721572
Source/PokemonLZA/Programs/PokemonLZA_GameEntry.cpp
15731573
Source/PokemonLZA/Programs/PokemonLZA_GameEntry.h
1574+
Source/PokemonLZA/Programs/PokemonLZA_MenuNavigation.cpp
1575+
Source/PokemonLZA/Programs/PokemonLZA_MenuNavigation.h
15741576
Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.cpp
15751577
Source/PokemonLZA/Programs/PokemonLZA_RestaurantFarmer.h
15761578
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.cpp
15771579
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_BenchSit.h
15781580
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_OverworldReset.cpp
15791581
Source/PokemonLZA/Programs/PokemonLZA_ShinyHunt_OverworldReset.h
1580-
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_TestBoxCellInfo.cpp
1581-
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_TestBoxCellInfo.h
15821582
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.cpp
15831583
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.h
15841584
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.cpp
15851585
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.h
1586+
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_TestBoxCellInfo.cpp
1587+
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_TestBoxCellInfo.h
15861588
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp
15871589
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h
15881590
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.cpp

0 commit comments

Comments
 (0)