Skip to content

Commit

Permalink
feat: feature to disable saves (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
liana-p committed Dec 23, 2023
1 parent 23de698 commit 12ce422
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docs/features/save-and-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,14 @@ The only viable solution for saving without risk of game updates breaking past s
This means some dialogue will be replayed when a user reloads if they were halfway through a label, but it's only because the save was made at a point in time.

:::

## Disabling saves

```yaml
saves:
disabled: true
```

Setting the `disabled` option to true in the saves config will remove the continue/load button, and remove the warning about erasing save slots when clicking on new game.

The game will still be saving in the background, but the player won't be able to load the save.
11 changes: 8 additions & 3 deletions packages/narrat/src/components/StartMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ function buttonClicked(button: StartMenuButtonProps) {
}
}
async function newGameButton() {
if (hasSave.value && getCommonConfig().saves.mode === 'manual') {
if (
hasSave.value &&
getCommonConfig().saves.mode === 'manual' &&
!getCommonConfig().saves.disabled
) {
startingGame.value = true;
} else {
confirmStartGame();
Expand Down Expand Up @@ -236,7 +240,8 @@ onMounted(() => {
});
function setupButtons() {
if (continueSlot.value) {
const savesDisabled = getCommonConfig().saves.disabled;
if (continueSlot.value && !savesDisabled) {
buttons.value.push(
extendButtonWithConfig({
id: 'continue',
Expand All @@ -254,7 +259,7 @@ function setupButtons() {
}),
);
}
if (hasSave.value) {
if (hasSave.value && !savesDisabled) {
buttons.value.push(
extendButtonWithConfig({
id: 'load-game',
Expand Down
1 change: 1 addition & 0 deletions packages/narrat/src/config/common-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const SavesConfigSchema = Type.Object({
mode: Type.String(),
slots: Type.Number(),
runOnReload: Type.Optional(Type.String()),
disabled: Type.Optional(Type.Boolean()),
});
export type SavesConfig = Static<typeof SavesConfigSchema>;

Expand Down
2 changes: 2 additions & 0 deletions packages/narrat/src/examples/default/config/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ saves:
mode: manual
slots: 10
runOnReload: 'test_label_reload'
# disabled: true

hudStats:
money:
icon: img/ui/money.webp
Expand Down

1 comment on commit 12ce422

@vercel
Copy link

@vercel vercel bot commented on 12ce422 Dec 23, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

narrat-editor-demo – ./packages/narrat-editor

narrat-editor-demo-git-main-nialna.vercel.app
narrat-editor-demo-nialna.vercel.app
demo.narrat.dev
narrat-editor-demo.vercel.app

Please sign in to comment.