Skip to content

AutoStory: shared start/end checkpoint range options, used by SV - #572

Draft
dayfine wants to merge 4 commits into
mainfrom
autostory/story-range-options-sv
Draft

dayfine wants to merge 4 commits into
mainfrom
autostory/story-range-options-sv

Conversation

@dayfine

@dayfine dayfine commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Base: main (fork main contains upstream main e961bf4); the diff shows only this change.

AutoStory programs each build their own start/end checkpoint dropdowns; this adds Pokemon::StoryRangeOptions (in Pokemon/AutoStory/Options), a shared pair of dropdowns over one checkpoint list with a start-after-end check, so BDSP, FRLG and PLZA can share it. SV's tutorial and main-story checkpoint pairs now use it: the dropdowns are added under their old keys (START_CHECKPOINT_TUTORIAL etc.) with their old labels, defaults and lock modes, so SV users see the same panel and saved settings still load. The AutoStory unit test suites now register through one add_tests_AutoStory(). SV's segment dropdowns and its start/end error messages are unchanged. Tested by the new Pokemon::StoryRangeOptions unit tests (indexes, validity, labels) on Fork Draft CI; nothing on a console.

StoryRangeOptions holds the start and end checkpoint dropdowns over one
story list and checks the start does not come after the end. SV's
tutorial and main-story checkpoint pairs now use it, adding the dropdowns
under their old keys and with their old labels, defaults and lock modes,
so saved settings still load.

@dayfine dayfine left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing: we should try to run SV autostory with this

Comment thread SerialPrograms/cmake/SourceFiles.cmake Outdated
Source/Pokemon/Options/Pokemon_NameSelectWidget.h
Source/Pokemon/Options/Pokemon_StatsHuntFilter.cpp
Source/Pokemon/Options/Pokemon_StatsHuntFilter.h
Source/Pokemon/Options/Pokemon_StoryRangeOptions.cpp

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an practice to put game / program options under their subdirectories?

if so, we could put this under AutoStory/Options?

@dayfine dayfine Nov 15, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: options live in an Options/ folder of the module that owns them (CommonFramework/Options, each game's Options/, and PokemonSwSh/MaxLair/Options for one feature). Moved to Pokemon/AutoStory/Options in fd8c614.

OCR::add_tests(ret);
Kernels::add_tests(ret);
Pokemon::add_tests_AutoStorySelect(ret);
Pokemon::add_tests_StoryRangeOptions(ret);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the answer to above is yes, then let's do the add_tests_AutoStoryTests header for collecting autostory tests to avoid keep editing this file

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Pokemon/AutoStory/Pokemon_AutoStory_Tests.h with add_tests_AutoStory(), which registers the AutoStorySelect and StoryRangeOptions suites; the runner now calls only that. The PLZA PRs above register their AutoStory suites there too.

std::move(labels.start),
checkpoints,
LockMode::LOCK_WHILE_RUNNING,
0

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give parameter comment to 0

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: /default_index=/0.

std::move(labels.end),
checkpoints,
end_lock,
checkpoints.size() == 0 ? 0 : checkpoints.size() - 1

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: /default_index=/ on the end too.

// The checkpoints chosen, by index in the database, both inclusive.
size_t start_index() const;
size_t end_index() const;
// "The start checkpoint comes after the end checkpoint." if it does.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is bad -- it should just check if the selected options is valid, or just remove it

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now: "Checks that the start checkpoint does not come after the end."

// entries. `end_lock`: UNLOCK_WHILE_RUNNING for a program that reads
// the end after each checkpoint, so the end can be moved during a run.
StoryRangeOptions(
std::string label, const StringSelectDatabase& checkpoints,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a string_view?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, changed to std::string_view by value; it is converted to std::string for GroupOption.

namespace Pokemon{


// A program shows the group, or adds START_CHECKPOINT and END_CHECKPOINT

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is bad

The options in autostory programs to describe the range of checkpoints to run?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with your wording: the options in an AutoStory program that pick the range of checkpoints to run.

ENDPOINT_TUTORIAL.remove_listener(*this);
STARTPOINT_MAINSTORY.remove_listener(*this);
ENDPOINT_MAINSTORY.remove_listener(*this);
TUTORIAL_CHECKPOINTS.START_CHECKPOINT.remove_listener(*this);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need these now?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't needed: the dropdowns are members of AutoStory and die with it, and the old START/END_CHECKPOINT dropdowns never removed their listeners either. Removed.

return story_index(
main_story,
main_story ? START_CHECKPOINT_MAINSTORY.index() : START_CHECKPOINT_TUTORIAL.index(),
STORY_SECTION == StorySection::MAIN_STORY,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one needs a parameter comment - same below

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for both story_index calls: /main_story=/, /index_in_section=/, /first_main_story_index=/.

…ests_AutoStory collects the AutoStory suites
… line, comments); SV drops unneeded remove_listener calls
dayfine added a commit that referenced this pull request Nov 15, 2026
Brings the reviewed slice chain (#572-#582) into the long-lived branch.
Where both sides add the same file, plza/autostory's later version is kept
and the slices' review fixes are applied on top: StoryRangeOptions moves to
Pokemon/AutoStory/Options with #572's review fixes, SV takes the slices'
version, the shared Outcome and Pose functions move to their own .cpp files,
and add_tests_AutoStory() also registers the slices' new suites
(StoryBackend, CheckpointAttempts, ScreenMachine, PLZA AutoStoryDialogDetector).
The slices' PLZA AutoStoryGame tests are left out: they are written against
the slices' smaller game API (make_plza_story_game_without_console(),
unverified autosaves), which this branch has not adopted; its
AutoStoryEngine tests cover the same game.
The nine AutoStoryScreenEvents frames missing from CommandLineTests #18 are
skipped as pending a recapture.

// A stand-in for a story checkpoint: only its name is read.
struct NamedCheckpoint{
std::string label;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need both name and label here?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make_story_select_database() labels each entry with list[i]->name(), a member function as on the real checkpoint classes, so the stand-in needs name(); label is just the string it returns. They hold the same value, but neither can go: the template needs the function and the function needs somewhere to keep the string. Pokemon_AutoStorySelect_Tests.cpp uses the same stand-in.


// The main story's dropdowns: entries 2..4 of the list, slugged 2..4.
const StringSelectDatabase& main_story_database(){
static const StringSelectDatabase database = make_story_select_database(story_list(), 2, story_list().size());

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter comments here

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 0758e5c: /*first=*/2, /*last=*/story_list().size().

std::string end_checkpoint_description();

// The checkpoint range of the chosen story section.
const Pokemon::StoryRangeOptions& checkpoint_range() const;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be public?

@dayfine dayfine Nov 16, 2026 •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already private: it sits under the private: that opens with on_config_value_changed() (line 65), and only AutoStory.cpp calls it, from get_start_checkpoint_index() and get_end_checkpoint_index().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant