Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/engine/JsonSerialisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ export class JsonSerialisation {
choice.originalThreadIndex = parseInt(jObj["originalThreadIndex"]);
choice.pathStringOnChoice = jObj["targetPath"].toString();
choice.tags = this.JArrayToTags(jObj);
choice.isInvisibleDefault = !!jObj["isInvisibleDefault"];
return choice;
}

Expand All @@ -605,6 +606,7 @@ export class JsonSerialisation {
writer.WriteProperty("originalChoicePath", choice.sourcePath);
writer.WriteIntProperty("originalThreadIndex", choice.originalThreadIndex);
writer.WriteProperty("targetPath", choice.pathStringOnChoice);
writer.WriteProperty("isInvisibleDefault", choice.isInvisibleDefault);
this.WriteChoiceTags(writer, choice);
writer.WriteObjectEnd();
}
Expand Down
17 changes: 17 additions & 0 deletions src/tests/specs/ink/Choices.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,21 @@ describe("Choices", () => {
"I did have one interesting fact about bricklaying, if you don't mind me spending taking a fair bit of time to lay the groundwork for it."
);
});

// TestFallbackChoicesHiddenAfterLoad
it("tests fallback choices remain hidden after load", () => {
compileStory("default_choices");
context.story.Continue();

expect(context.story.currentChoices.length).toBe(2);
expect(context.story.currentChoices[0].text).toBe("Choice 1");
expect(context.story.currentChoices[1].text).toBe("Choice 2");

const savedState = context.story.state.ToJson();
context.story.state.LoadJson(savedState);

expect(context.story.currentChoices.length).toBe(2);
expect(context.story.currentChoices[0].text).toBe("Choice 1");
expect(context.story.currentChoices[1].text).toBe("Choice 2");
});
});