Skip to content

Commit 8322437

Browse files
committed
MysteryGift: add option for OBTAINING_METHOD. e.g. via Code vs via Internet
1 parent ec31863 commit 8322437

File tree

2 files changed

+70
-16
lines changed

2 files changed

+70
-16
lines changed

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.cpp

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ClaimMysteryGift_Descriptor::ClaimMysteryGift_Descriptor()
5858

5959

6060
ClaimMysteryGift::~ClaimMysteryGift(){
61+
OBTAINING_METHOD.remove_listener(*this);
6162
STARTING_POINT.remove_listener(*this);
6263
}
6364

@@ -72,17 +73,28 @@ ClaimMysteryGift::ClaimMysteryGift()
7273
"<b>Starting point:",
7374
{
7475
{StartingPoint::NEW_GAME, "new-game", "New Game: Start after you have selected your username and character appearance"},
75-
{StartingPoint::IN_MYSTERY_GIFT, "in-mystery-gift", "Start in Mystery Gift window, with cursor on the “1” key."},
76+
{StartingPoint::IN_MYSTERY_GIFT_CODE_WINDOW, "in-mystery-gift-code-window", "Start in Mystery Gift code window, with cursor on the “1” key."},
7677
{StartingPoint::DONE_TUTORIAL, "done-tutorial", "Start in game. But with all menus closed. Tutorial must be completed. You need to be outside, where you can use Pokeportal."},
7778
},
7879
LockMode::LOCK_WHILE_RUNNING,
7980
StartingPoint::NEW_GAME
8081
)
82+
, OBTAINING_METHOD(
83+
"<b>Method for obtaining mystery gift:",
84+
{
85+
{ObtainingMethod::VIA_INTERNET_ALL, "via-internet-all", "Via Internet: Get all mystery gifts from the \"Via internet\" screen."},
86+
{ObtainingMethod::VIA_INTERNET_ONE, "via-internet-one", "Via Internet: Get only the top mystery gift from the \"Via internet\" screen."},
87+
{ObtainingMethod::VIA_CODE, "via-code", "Via Code: Get the mystery gift based on the code entered below."},
88+
},
89+
LockMode::LOCK_WHILE_RUNNING,
90+
ObtainingMethod::VIA_INTERNET_ALL
91+
)
8192
, MYSTERY_GIFT_NOTE{
82-
"Ensure you are logged into a Nintendo account. This account does NOT need to have a subscription to Nintendo Switch Online.<br>"
83-
"In the keyboard section below, you only need to adjust the option for Swtich 0. Ignore the options for the other Switches.<br>"
84-
"Refer to the documentation on github for more details."
93+
"Ensure you are logged into a Nintendo account. This account does NOT need to have a subscription to Nintendo Switch Online."
8594
}
95+
, MULTISWITCH_NOTE{
96+
"In the keyboard section below, you only need to adjust the option for Swtich 0. Ignore the options for the other Switches."
97+
}
8698
, CODE(
8799
"<b>Mystery Gift Code:</b><br>Mystery Gift code. (not case sensitive)<br>"
88100
"(Box is big so it's easy to land your mouse on.)",
@@ -101,8 +113,10 @@ ClaimMysteryGift::ClaimMysteryGift()
101113
{
102114

103115
PA_ADD_OPTION(LANGUAGE);
104-
PA_ADD_OPTION(STARTING_POINT);
105116
PA_ADD_OPTION(MYSTERY_GIFT_NOTE);
117+
PA_ADD_OPTION(STARTING_POINT);
118+
PA_ADD_OPTION(OBTAINING_METHOD);
119+
PA_ADD_OPTION(MULTISWITCH_NOTE);
106120
PA_ADD_OPTION(CODE);
107121
PA_ADD_OPTION(SETTINGS);
108122
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
@@ -111,12 +125,28 @@ ClaimMysteryGift::ClaimMysteryGift()
111125

112126
ClaimMysteryGift::on_config_value_changed(this);
113127

128+
OBTAINING_METHOD.add_listener(*this);
114129
STARTING_POINT.add_listener(*this);
115130
}
116131

117132
void ClaimMysteryGift::on_config_value_changed(void* object){
133+
if (STARTING_POINT == StartingPoint::IN_MYSTERY_GIFT_CODE_WINDOW){
134+
OBTAINING_METHOD.set_visibility(ConfigOptionState::HIDDEN);
135+
}else{
136+
OBTAINING_METHOD.set_visibility(ConfigOptionState::ENABLED);
137+
}
118138

119139

140+
if (OBTAINING_METHOD == ObtainingMethod::VIA_CODE){
141+
MULTISWITCH_NOTE.set_visibility(ConfigOptionState::ENABLED);
142+
CODE.set_visibility(ConfigOptionState::ENABLED);
143+
SETTINGS.set_visibility(ConfigOptionState::ENABLED);
144+
}else{
145+
MULTISWITCH_NOTE.set_visibility(ConfigOptionState::HIDDEN);
146+
CODE.set_visibility(ConfigOptionState::HIDDEN);
147+
SETTINGS.set_visibility(ConfigOptionState::HIDDEN);
148+
}
149+
120150
}
121151

122152
void ClaimMysteryGift::enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
@@ -138,7 +168,7 @@ void ClaimMysteryGift::enter_mystery_gift_code(SingleSwitchProgramEnvironment& e
138168

139169
}
140170

141-
void ClaimMysteryGift::enter_mystery_gift_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index){
171+
void ClaimMysteryGift::enter_mystery_gift_code_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index){
142172
env.console.log("Save game, then try to enter the mystery gift window.", COLOR_YELLOW);
143173
save_game_from_menu_or_overworld(env.program_info(), env.console, context, false);
144174

@@ -154,7 +184,7 @@ void ClaimMysteryGift::enter_mystery_gift_window(SingleSwitchProgramEnvironment&
154184
try {
155185
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG});
156186
}catch(OperationFailedException&){
157-
env.console.log("enter_mystery_gift_window: Failed to detect the dialog that leads to the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW);
187+
env.console.log("enter_mystery_gift_code_window: Failed to detect the dialog that leads to the Mystery Gift code window. Reset game and re-try.", COLOR_YELLOW);
158188
reset_game(env.program_info(), env.console, context);
159189
continue;
160190
}
@@ -199,7 +229,7 @@ void ClaimMysteryGift::enter_mystery_gift_window(SingleSwitchProgramEnvironment&
199229
{key1_selected}
200230
);
201231
if (ret < 0){ // failed to detect Key 1 being highlighted. Reset game and re-try
202-
env.console.log("enter_mystery_gift_window: Failed to detect the Mystery Gift window. Reset game and re-try.", COLOR_YELLOW);
232+
env.console.log("enter_mystery_gift_code_window: Failed to detect the Mystery Gift code window. Reset game and re-try.", COLOR_YELLOW);
203233
reset_game(env.program_info(), env.console, context);
204234
continue;
205235
}
@@ -210,7 +240,7 @@ void ClaimMysteryGift::enter_mystery_gift_window(SingleSwitchProgramEnvironment&
210240

211241
OperationFailedException::fire(
212242
ErrorReport::SEND_ERROR_REPORT,
213-
"enter_mystery_gift_window(): Failed to reach Mystery Gift screen after several attempts.",
243+
"enter_mystery_gift_code_window(): Failed to reach Mystery Gift code window after several attempts.",
214244
env.console
215245
);
216246
}
@@ -241,13 +271,29 @@ void ClaimMysteryGift::program(SingleSwitchProgramEnvironment& env, ProControlle
241271
if (STARTING_POINT == StartingPoint::NEW_GAME){
242272
run_autostory_until_pokeportal_unlocked(env, context);
243273
env.console.log("Done Autostory portion. Pokeportal should now be unlocked.");
244-
enter_mystery_gift_window(env, context, 2);
245-
enter_mystery_gift_code(env, context);
246-
}else if(STARTING_POINT == StartingPoint::IN_MYSTERY_GIFT){
274+
if (OBTAINING_METHOD == ObtainingMethod::VIA_CODE){
275+
enter_mystery_gift_code_window(env, context, 2);
276+
enter_mystery_gift_code(env, context);
277+
}else if(OBTAINING_METHOD == ObtainingMethod::VIA_INTERNET_ALL){
278+
279+
}else if(OBTAINING_METHOD == ObtainingMethod::VIA_INTERNET_ONE){
280+
281+
}
282+
283+
}else if(STARTING_POINT == StartingPoint::IN_MYSTERY_GIFT_CODE_WINDOW){
284+
// only claim the mystery gift via code. not via internet
247285
enter_mystery_gift_code(env, context);
286+
248287
}else if (STARTING_POINT == StartingPoint::DONE_TUTORIAL){
249-
enter_mystery_gift_window(env, context, 3);
250-
enter_mystery_gift_code(env, context);
288+
289+
if (OBTAINING_METHOD == ObtainingMethod::VIA_CODE){
290+
enter_mystery_gift_code_window(env, context, 3);
291+
enter_mystery_gift_code(env, context);
292+
}else if(OBTAINING_METHOD == ObtainingMethod::VIA_INTERNET_ALL){
293+
294+
}else if(OBTAINING_METHOD == ObtainingMethod::VIA_INTERNET_ONE){
295+
296+
}
251297
}else{
252298
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Unknown STARTING_POINT.");
253299
}

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_ClaimMysteryGift.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ClaimMysteryGift : public SingleSwitchProgramInstance, public ConfigOption
4040
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
4141

4242
void run_autostory_until_pokeportal_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
43-
void enter_mystery_gift_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index);
43+
void enter_mystery_gift_code_window(SingleSwitchProgramEnvironment& env, ProControllerContext& context, int menu_index);
4444
void enter_mystery_gift_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
4545

4646
private:
@@ -54,12 +54,20 @@ class ClaimMysteryGift : public SingleSwitchProgramInstance, public ConfigOption
5454

5555
enum class StartingPoint{
5656
NEW_GAME,
57-
IN_MYSTERY_GIFT,
57+
IN_MYSTERY_GIFT_CODE_WINDOW,
5858
DONE_TUTORIAL,
5959
};
6060

61+
enum class ObtainingMethod{
62+
VIA_INTERNET_ALL,
63+
VIA_INTERNET_ONE,
64+
VIA_CODE,
65+
};
66+
6167
EnumDropdownOption<StartingPoint> STARTING_POINT;
68+
EnumDropdownOption<ObtainingMethod> OBTAINING_METHOD;
6269
StaticTextOption MYSTERY_GIFT_NOTE;
70+
StaticTextOption MULTISWITCH_NOTE;
6371
TextEditOption CODE;
6472
FastCodeEntrySettingsOption SETTINGS;
6573

0 commit comments

Comments
 (0)