@rohal12/spindle 0.16.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +2 -2
- package/src/action-registry.ts +2 -1
- package/src/components/Passage.tsx +69 -4
- package/src/components/PassageDialog.tsx +69 -0
- package/src/components/StoryInterface.tsx +2 -2
- package/src/components/macros/Button.tsx +33 -46
- package/src/components/macros/Checkbox.tsx +32 -35
- package/src/components/macros/Computed.tsx +49 -54
- package/src/components/macros/Cycle.tsx +43 -53
- package/src/components/macros/Dialog.tsx +40 -0
- package/src/components/macros/Do.tsx +15 -21
- package/src/components/macros/For.tsx +57 -75
- package/src/components/macros/Goto.tsx +18 -22
- package/src/components/macros/If.tsx +39 -53
- package/src/components/macros/Include.tsx +30 -46
- package/src/components/macros/Listbox.tsx +38 -48
- package/src/components/macros/MacroError.tsx +18 -0
- package/src/components/macros/MacroLink.tsx +38 -53
- package/src/components/macros/MenubarButtons.tsx +158 -0
- package/src/components/macros/Meter.tsx +35 -52
- package/src/components/macros/Numberbox.tsx +30 -47
- package/src/components/macros/PassageDisplay.tsx +37 -30
- package/src/components/macros/Print.tsx +19 -36
- package/src/components/macros/Radiobutton.tsx +33 -38
- package/src/components/macros/Repeat.tsx +49 -54
- package/src/components/macros/SaveManager.tsx +400 -0
- package/src/components/macros/Set.tsx +19 -24
- package/src/components/{SettingsDialog.tsx → macros/SettingsControls.tsx} +18 -36
- package/src/components/macros/Span.tsx +8 -0
- package/src/components/macros/Stop.tsx +11 -12
- package/src/components/macros/StoryTitle.tsx +16 -16
- package/src/components/macros/Switch.tsx +41 -59
- package/src/components/macros/Textarea.tsx +26 -45
- package/src/components/macros/Textbox.tsx +27 -44
- package/src/components/macros/Timed.tsx +54 -55
- package/src/components/macros/Type.tsx +61 -62
- package/src/components/macros/Unset.tsx +21 -22
- package/src/components/macros/Widget.tsx +11 -15
- package/src/components/macros/option-utils.ts +13 -0
- package/src/define-macro.ts +154 -0
- package/src/expression.ts +10 -8
- package/src/index.tsx +7 -0
- package/src/macros/register-builtins.ts +5 -7
- package/src/markup/ast.ts +11 -16
- package/src/markup/render.tsx +0 -13
- package/src/saves/save-manager.ts +43 -0
- package/src/saves/types.ts +9 -2
- package/src/store.ts +283 -52
- package/src/story-api.ts +33 -12
- package/src/styles.css +37 -68
- package/src/components/PassageLink.tsx +0 -49
- package/src/components/SaveLoadDialog.tsx +0 -408
- package/src/components/macros/Back.tsx +0 -32
- package/src/components/macros/Forward.tsx +0 -34
- package/src/components/macros/QuickLoad.tsx +0 -42
- package/src/components/macros/QuickSave.tsx +0 -30
- package/src/components/macros/Restart.tsx +0 -35
- package/src/components/macros/Saves.tsx +0 -24
- package/src/components/macros/SettingsButton.tsx +0 -28
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useStoryStore } from '../../store';
|
|
2
|
-
import { useAction } from '../../hooks/use-action';
|
|
3
|
-
import { registerMacro } from '../../registry';
|
|
4
|
-
import type { MacroProps } from '../../registry';
|
|
5
|
-
|
|
6
|
-
export function QuickLoad({ className, id }: MacroProps) {
|
|
7
|
-
const load = useStoryStore((s) => s.load);
|
|
8
|
-
const hasSave = useStoryStore((s) => s.hasSave);
|
|
9
|
-
// Subscribe to saveVersion so we re-render when a save is created
|
|
10
|
-
useStoryStore((s) => s.saveVersion);
|
|
11
|
-
const cls = className ? `menubar-button ${className}` : 'menubar-button';
|
|
12
|
-
const disabled = !hasSave();
|
|
13
|
-
|
|
14
|
-
const handleClick = () => {
|
|
15
|
-
if (confirm('Load saved game? Current progress will be lost.')) {
|
|
16
|
-
load();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
useAction({
|
|
21
|
-
type: 'load',
|
|
22
|
-
key: 'quickload',
|
|
23
|
-
authorId: id,
|
|
24
|
-
label: 'QuickLoad',
|
|
25
|
-
disabled,
|
|
26
|
-
perform: () => load(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<button
|
|
31
|
-
id={id}
|
|
32
|
-
class={cls}
|
|
33
|
-
title="Quick Load (F9)"
|
|
34
|
-
disabled={disabled}
|
|
35
|
-
onClick={handleClick}
|
|
36
|
-
>
|
|
37
|
-
QuickLoad
|
|
38
|
-
</button>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
registerMacro('quickload', QuickLoad);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useStoryStore } from '../../store';
|
|
2
|
-
import { useAction } from '../../hooks/use-action';
|
|
3
|
-
import { registerMacro } from '../../registry';
|
|
4
|
-
import type { MacroProps } from '../../registry';
|
|
5
|
-
|
|
6
|
-
export function QuickSave({ className, id }: MacroProps) {
|
|
7
|
-
const save = useStoryStore((s) => s.save);
|
|
8
|
-
const cls = className ? `menubar-button ${className}` : 'menubar-button';
|
|
9
|
-
|
|
10
|
-
useAction({
|
|
11
|
-
type: 'save',
|
|
12
|
-
key: 'quicksave',
|
|
13
|
-
authorId: id,
|
|
14
|
-
label: 'QuickSave',
|
|
15
|
-
perform: () => save(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<button
|
|
20
|
-
id={id}
|
|
21
|
-
class={cls}
|
|
22
|
-
title="Quick Save (F6)"
|
|
23
|
-
onClick={() => save()}
|
|
24
|
-
>
|
|
25
|
-
QuickSave
|
|
26
|
-
</button>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
registerMacro('quicksave', QuickSave);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useStoryStore } from '../../store';
|
|
2
|
-
import { useAction } from '../../hooks/use-action';
|
|
3
|
-
import { registerMacro } from '../../registry';
|
|
4
|
-
import type { MacroProps } from '../../registry';
|
|
5
|
-
|
|
6
|
-
export function Restart({ className, id }: MacroProps) {
|
|
7
|
-
const restart = useStoryStore((s) => s.restart);
|
|
8
|
-
const cls = className ? `menubar-button ${className}` : 'menubar-button';
|
|
9
|
-
|
|
10
|
-
const handleClick = () => {
|
|
11
|
-
if (confirm('Restart the story? All progress will be lost.')) {
|
|
12
|
-
restart();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
useAction({
|
|
17
|
-
type: 'restart',
|
|
18
|
-
key: 'restart',
|
|
19
|
-
authorId: id,
|
|
20
|
-
label: 'Restart',
|
|
21
|
-
perform: () => restart(),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<button
|
|
26
|
-
id={id}
|
|
27
|
-
class={cls}
|
|
28
|
-
onClick={handleClick}
|
|
29
|
-
>
|
|
30
|
-
↺ Restart
|
|
31
|
-
</button>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
registerMacro('restart', Restart);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
2
|
-
import { SaveLoadDialog } from '../SaveLoadDialog';
|
|
3
|
-
import { registerMacro } from '../../registry';
|
|
4
|
-
import type { MacroProps } from '../../registry';
|
|
5
|
-
|
|
6
|
-
export function Saves({ className, id }: MacroProps) {
|
|
7
|
-
const [open, setOpen] = useState(false);
|
|
8
|
-
const cls = className ? `menubar-button ${className}` : 'menubar-button';
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<>
|
|
12
|
-
<button
|
|
13
|
-
id={id}
|
|
14
|
-
class={cls}
|
|
15
|
-
onClick={() => setOpen(true)}
|
|
16
|
-
>
|
|
17
|
-
Saves
|
|
18
|
-
</button>
|
|
19
|
-
{open && <SaveLoadDialog onClose={() => setOpen(false)} />}
|
|
20
|
-
</>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
registerMacro('saves', Saves);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
2
|
-
import { settings } from '../../settings';
|
|
3
|
-
import { SettingsDialog } from '../SettingsDialog';
|
|
4
|
-
import { registerMacro } from '../../registry';
|
|
5
|
-
import type { MacroProps } from '../../registry';
|
|
6
|
-
|
|
7
|
-
export function SettingsButton({ className, id }: MacroProps) {
|
|
8
|
-
const [open, setOpen] = useState(false);
|
|
9
|
-
|
|
10
|
-
if (!settings.hasAny()) return null;
|
|
11
|
-
|
|
12
|
-
const cls = className ? `menubar-button ${className}` : 'menubar-button';
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<button
|
|
17
|
-
id={id}
|
|
18
|
-
class={cls}
|
|
19
|
-
onClick={() => setOpen(true)}
|
|
20
|
-
>
|
|
21
|
-
⚙ Settings
|
|
22
|
-
</button>
|
|
23
|
-
{open && <SettingsDialog onClose={() => setOpen(false)} />}
|
|
24
|
-
</>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
registerMacro('settings', SettingsButton);
|