Skip to content

Commit 6c35cbb

Browse files
committed
Autostory: fix change_settings_prior_to_autostory(). Fix ability to change ending segment while program runs.
1 parent d6dac64 commit 6c35cbb

File tree

3 files changed

+72
-20
lines changed

3 files changed

+72
-20
lines changed

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ AutoStory::AutoStory()
187187
, STARTPOINT_TUTORIAL(
188188
"<b>Start Point:</b><br>Program will start with this segment.",
189189
TUTORIAL_SEGMENTS_SELECT_DATABASE(),
190-
LockMode::UNLOCK_WHILE_RUNNING,
190+
LockMode::LOCK_WHILE_RUNNING,
191191
"0"
192192
)
193193
, ENDPOINT_TUTORIAL(
@@ -679,26 +679,39 @@ std::string AutoStory::end_segment_description(){
679679
return ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->end_text();
680680
}
681681

682+
size_t AutoStory::get_start_segment_index(){
683+
size_t start = 0;
682684

683-
void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
684-
AutoStoryOptions options{
685-
LANGUAGE,
686-
STARTERCHOICE,
687-
NOTIFICATION_STATUS_UPDATE
688-
};
685+
if (STORY_SECTION == StorySection::TUTORIAL){
686+
start = STARTPOINT_TUTORIAL.index();
687+
}else if (STORY_SECTION == StorySection::MAIN_STORY){
688+
start = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + STARTPOINT_MAINSTORY.index();
689+
}
690+
691+
return start;
692+
}
689693

690-
size_t start = STARTPOINT_TUTORIAL.index();
691-
size_t end = ENDPOINT_TUTORIAL.index();
694+
size_t AutoStory::get_end_segment_index(){
695+
size_t end = 0;
692696

693697
if (STORY_SECTION == StorySection::TUTORIAL){
694-
start = STARTPOINT_TUTORIAL.index();
695698
end = ENDPOINT_TUTORIAL.index();
696699
}else if (STORY_SECTION == StorySection::MAIN_STORY){
697-
start = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + STARTPOINT_MAINSTORY.index();
698700
end = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + ENDPOINT_MAINSTORY.index();
699701
}
702+
703+
return end;
704+
}
705+
706+
707+
void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
708+
AutoStoryOptions options{
709+
LANGUAGE,
710+
STARTERCHOICE,
711+
NOTIFICATION_STATUS_UPDATE
712+
};
700713

701-
for (size_t segment_index = start; segment_index <= end; segment_index++){
714+
for (size_t segment_index = get_start_segment_index(); segment_index <= get_end_segment_index(); segment_index++){
702715
ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options);
703716
}
704717
}
@@ -777,7 +790,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex
777790

778791
// Set settings. to ensure autosave is off.
779792
if (CHANGE_SETTINGS){
780-
change_settings_prior_to_autostory(env, context, STARTPOINT_TUTORIAL.index(), LANGUAGE);
793+
change_settings_prior_to_autostory(env, context, get_start_segment_index(), LANGUAGE);
781794
}
782795

783796
run_autostory(env, context);

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
5050
int loop, int start_loop, int end_loop
5151
);
5252

53+
size_t get_start_segment_index();
54+
size_t get_end_segment_index();
55+
5356
void run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
5457

5558
private:

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,29 +583,65 @@ void change_settings_prior_to_autostory(
583583
size_t current_segment_num,
584584
Language language
585585
){
586-
if (current_segment_num == 0){ // can't change settings in the intro cutscene
587-
return;
588-
}
589586

590587
// get index of `Options` in the Main Menu, which depends on where you are in Autostory
591588
int8_t options_index;
592589
switch(current_segment_num){
593590
case 0:
591+
return; // can't change settings in the intro cutscene
592+
case 1:
593+
// after Intro cutscene done, in room
594+
// Menu
595+
// - Options
596+
// - Save
594597
options_index = 0;
595598
break;
596-
case 1:
599+
case 2:
600+
// Menu
601+
// - Bag --> unlocked after picked up bag/hat in room. Segment 01, checkpoint 02
602+
// - Options
603+
// - Save
597604
options_index = 1;
598605
break;
606+
case 3:
607+
case 4:
608+
case 5:
609+
case 6:
610+
// Menu
611+
// - Bag
612+
// - Boxes --> unlocked after battling Nemona and receiving Pokedex app. Segment 02, checkpoint 04
613+
// - Options
614+
// - Save
615+
options_index = 2;
616+
break;
617+
case 7:
618+
case 8:
619+
case 9:
620+
// Menu
621+
// - Bag
622+
// - Boxes
623+
// - Poke Portal --> unlocked after arriving at Los Platos and talking to Nemona. Segment 06, checkpoint 11
624+
// - Options
625+
// - Save
626+
options_index = 3;
627+
break;
599628
default:
600-
options_index = 2;
629+
// Menu
630+
// - Bag
631+
// - Boxes
632+
// - Picnic --> unlocked after finishing tutorial. Segment 09, checkpoint 20
633+
// - Poke Portal
634+
// - Options
635+
// - Save
636+
options_index = 4;
601637
break;
602638
}
603639

604-
bool has_minimap = current_segment_num > 1; // the minimap only shows up in segment 2 and beyond
640+
bool has_minimap = current_segment_num >= 2; // the minimap only shows up in segment 2 and beyond
605641

606642
enter_menu_from_overworld(env.program_info(), env.console, context, options_index, MenuSide::RIGHT, has_minimap);
607643
change_settings(env, context, language);
608-
if(has_minimap){
644+
if(!has_minimap){
609645
pbf_mash_button(context, BUTTON_B, 2 * TICKS_PER_SECOND);
610646
}else{
611647
press_Bs_to_back_to_overworld(env.program_info(), env.console, context);

0 commit comments

Comments
 (0)