|
4 | 4 | * |
5 | 5 | */ |
6 | 6 |
|
7 | | - #include "CommonTools/Async/InferenceRoutines.h" |
| 7 | +#include "CommonTools/Async/InferenceRoutines.h" |
| 8 | +#include "CommonFramework/Exceptions/OperationFailedException.h" |
8 | 9 | #include "CommonFramework/GlobalSettingsPanel.h" |
9 | 10 | #include "CommonFramework/Notifications/ProgramNotifications.h" |
10 | 11 | #include "CommonFramework/VideoPipeline/VideoFeed.h" |
@@ -148,15 +149,20 @@ void ClaimMysteryGift::claim_mystery_gift(SingleSwitchProgramEnvironment& env, P |
148 | 149 | pbf_press_dpad(context, DPAD_DOWN, 20, 105); |
149 | 150 | pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); |
150 | 151 | pbf_press_button(context, BUTTON_A, 20, 10 * TICKS_PER_SECOND); |
151 | | - clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG}); |
| 152 | + try { |
| 153 | + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG}); |
| 154 | + }catch(OperationFailedException&){ |
| 155 | + env.console.log("claim_mystery_gift: Failed to detect the dialog that leads to the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW); |
| 156 | + reset_game(env.program_info(), env.console, context); |
| 157 | + continue; |
| 158 | + } |
152 | 159 |
|
153 | 160 | context.wait_for_all_requests(); |
154 | 161 | context.wait_for(Milliseconds(300)); |
155 | 162 | // we expect to be within Mystery Gift window, with the keyboard visible and "1" being highlighted |
156 | | - // |
157 | | - |
| 163 | + |
| 164 | + // check whether this is Switch 1 or 2. |
158 | 165 | ConsoleType console_type = env.console.state().console_type(); |
159 | | - |
160 | 166 | if (console_type == ConsoleType::Unknown){ |
161 | 167 | env.console.log("Unknown Switch type. Try to detect."); |
162 | 168 | console_type = detect_console_type_from_in_game(env.console, context); |
|
0 commit comments