@automataframework/shell 0.0.1-preview.17.sha-d17daef → 0.0.1-preview.18.sha-2a1944d
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/features/formats/formats.d.ts +8 -0
- package/dist/features/host/host.d.ts +39 -12
- package/dist/features/remap/pad.d.ts +13 -0
- package/dist/features/remap/remap.d.ts +16 -0
- package/dist/features/saves-screen/saves-screen.d.ts +18 -0
- package/dist/features/settings/settings.d.ts +35 -7
- package/dist/features/touch-controls/layout.d.ts +21 -0
- package/dist/index.js +1853 -249
- package/messages/en.json +28 -1
- package/messages/es.json +28 -1
- package/package.json +3 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/** The settings a slider, steps or switch may change. Each is a key of `Settings`. */
|
|
3
|
+
export declare const settingNames: readonly ['language', 'master', 'music', 'effects', 'mute', 'textSize', 'contrast', 'motion', 'frameCounter'];
|
|
2
4
|
/** The `screen` content kind. Formats may change. */
|
|
3
5
|
export declare const screenSchema: z.ZodObject<{
|
|
4
6
|
format: z.ZodLiteral<1>;
|
|
@@ -8,6 +10,7 @@ export declare const screenSchema: z.ZodObject<{
|
|
|
8
10
|
above: z.ZodOptional<z.ZodString>;
|
|
9
11
|
layout: z.ZodOptional<z.ZodEnum<{
|
|
10
12
|
card: "card";
|
|
13
|
+
panel: "panel";
|
|
11
14
|
splash: "splash";
|
|
12
15
|
}>>;
|
|
13
16
|
back: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -82,7 +85,12 @@ export declare const screenSchema: z.ZodObject<{
|
|
|
82
85
|
credits: "credits";
|
|
83
86
|
languages: "languages";
|
|
84
87
|
saves: "saves";
|
|
88
|
+
touch: "touch";
|
|
85
89
|
}>;
|
|
90
|
+
details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
shows: z.ZodString;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
86
94
|
}, z.core.$strip>], "type">>;
|
|
87
95
|
}, z.core.$loose>;
|
|
88
96
|
/** The `hud` content kind. Formats may change. */
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import type { Readable } from 'svelte/store';
|
|
1
|
+
import type { Readable, Writable } from 'svelte/store';
|
|
2
2
|
import type { Credits, Screen } from '../formats/formats.ts';
|
|
3
3
|
import type { Look } from '../theme/default.ts';
|
|
4
|
-
import type { SettingName, Settings } from '../settings/settings.ts';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
slot: string;
|
|
8
|
-
empty: boolean;
|
|
9
|
-
savedAt: number;
|
|
10
|
-
};
|
|
11
|
-
/** One row of the controls list: what it does, and the key that does it. */
|
|
4
|
+
import type { SettingName, Settings, TouchPlace } from '../settings/settings.ts';
|
|
5
|
+
import type { SaveRow } from '../saves-screen/saves-screen.ts';
|
|
6
|
+
/** One row of the controls list: what it does, and the key that does it now. */
|
|
12
7
|
type ControlRow = {
|
|
13
8
|
id: string;
|
|
14
9
|
label: string;
|
|
10
|
+
kind: 'button' | 'stick';
|
|
15
11
|
key: string;
|
|
12
|
+
pad: string;
|
|
13
|
+
canTap: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** One on-screen control: the action it does, and where it sits. */
|
|
16
|
+
type TouchControl = {
|
|
17
|
+
action: string;
|
|
18
|
+
label: string;
|
|
19
|
+
kind: 'button' | 'stick';
|
|
20
|
+
place: TouchPlace;
|
|
16
21
|
};
|
|
17
22
|
/** Everything a screen's parts need from the game around them. Handed down with Svelte's context under `host`. */
|
|
18
23
|
export type Host = {
|
|
@@ -27,10 +32,32 @@ export type Host = {
|
|
|
27
32
|
/** The width of the stage, in px: under 600 the card is a sheet. */
|
|
28
33
|
stageWidth: Readable<number>;
|
|
29
34
|
setStageWidth(width: number): void;
|
|
30
|
-
/** Keys were used (or, with `false`, a finger or mouse): a screen takes focus only for
|
|
35
|
+
/** Keys or a pad were used (or, with `false`, a finger or mouse): a screen takes focus only for those. */
|
|
31
36
|
noteKeyboard(on?: boolean): void;
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
/** One plain sentence about what just happened (a save brought in, a controller gone), or empty. */
|
|
38
|
+
notice: Readable<string>;
|
|
39
|
+
/** Changes whenever a save is written or brought in, so the saves list draws again. */
|
|
40
|
+
savesChanged: Readable<number>;
|
|
41
|
+
/** The four save slots, each with what the saved game holds at `paths`. */
|
|
42
|
+
saves(paths: string[]): SaveRow[];
|
|
43
|
+
controls: Readable<ControlRow[]>;
|
|
44
|
+
/** True once a pad has been used on the screens (and until a key is pressed): the key caps show pad buttons. */
|
|
45
|
+
usingPad: Readable<boolean>;
|
|
46
|
+
/** The action waiting for its new key ("Press a key…"), or null. */
|
|
47
|
+
capturing: Readable<string | null>;
|
|
48
|
+
capture(action: string | null): void;
|
|
49
|
+
/** True when the actions that may be tapped instead of held are set to tap. */
|
|
50
|
+
tapping: Readable<boolean>;
|
|
51
|
+
setTapping(on: boolean): void;
|
|
52
|
+
/** The on-screen controls, where they sit now. */
|
|
53
|
+
touchControls: Readable<TouchControl[]>;
|
|
54
|
+
/** Which on-screen control the move-and-resize panel works on. */
|
|
55
|
+
touchPick: Writable<number>;
|
|
56
|
+
moveTouch(index: number, x: number, y: number): void;
|
|
57
|
+
resizeTouch(index: number, by: number): void;
|
|
58
|
+
resetTouch(): void;
|
|
59
|
+
/** Hands an on-screen control's push to the game: a button held or let go, a stick's direction. */
|
|
60
|
+
touchInput(action: string, value: boolean | [number, number]): void;
|
|
34
61
|
credits(): Credits | undefined;
|
|
35
62
|
assetUrl(id: string): string | undefined;
|
|
36
63
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What a pad press means on a screen. */
|
|
2
|
+
export type PadCommand = 'up' | 'down' | 'left' | 'right' | 'press' | 'back' | 'start';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the first pad for the screens: each press counts once, when it starts, and the left stick counts as the d-pad.
|
|
5
|
+
* `poll` is called once a frame. While the game is being remapped, `poll` also says which button went down, so it can be
|
|
6
|
+
* given to an action.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createPadReader(pads: () => (Gamepad | null)[]): {
|
|
9
|
+
poll(): {
|
|
10
|
+
commands: PadCommand[];
|
|
11
|
+
button: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Action, Bindings } from '@automataframework/core';
|
|
2
|
+
/** A key's code as a person reads it on a key cap: `KeyJ` is "J", `Digit1` is "1", `ArrowUp` is "↑". */
|
|
3
|
+
export declare function keyName(code: string): string;
|
|
4
|
+
/** A pad input as a person reads it: `button:0` is "Pad 1". */
|
|
5
|
+
export declare const padName: (id: string) => string;
|
|
6
|
+
/** True when `code` may be given to an action. */
|
|
7
|
+
export declare const canTake: (code: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* One player's bindings with `action` on `code` alone. Another action of the same player that had `code` loses it, so
|
|
10
|
+
* one key never does two things.
|
|
11
|
+
*/
|
|
12
|
+
export declare function bindKey(all: Bindings[], player: number, action: string, code: string): Bindings[];
|
|
13
|
+
/** One player's bindings with `action` on the pad input `input` alone, taken from any other action that had it. */
|
|
14
|
+
export declare function bindPad(all: Bindings[], player: number, action: string, input: string): Bindings[];
|
|
15
|
+
/** Every player's bindings with each action that may be tapped set to tap (or to hold). */
|
|
16
|
+
export declare function setTap(all: Bindings[], actions: Action[], on: boolean): Bindings[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One row of the saves list: the slot, whether it is empty, when it was saved, and what its details read. */
|
|
2
|
+
export type SaveRow = {
|
|
3
|
+
slot: string;
|
|
4
|
+
empty: boolean;
|
|
5
|
+
savedAt: number;
|
|
6
|
+
values: string[];
|
|
7
|
+
};
|
|
8
|
+
/** The order the saves screen shows: every save, the newest first, then the empty slots in slot order. */
|
|
9
|
+
export declare function savesInOrder(rows: SaveRow[]): SaveRow[];
|
|
10
|
+
/** When a save was made, in plain words: "Today 14:05" today, the date and time on any other day. */
|
|
11
|
+
export declare function savedWhen(at: number, now: number, language: string, today: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The slot a save brought in goes to: the first empty one of Save 1 to 3, or, when all three are full, the one saved
|
|
14
|
+
* longest ago. The autosave slot is the game's own and is never written by hand.
|
|
15
|
+
*/
|
|
16
|
+
export declare function importSlot(rows: SaveRow[]): string;
|
|
17
|
+
/** The name a saved copy gets on the device: the game, the slot and the day, such as `my-game-save-1-2026-11-27.json`. */
|
|
18
|
+
export declare function exportName(gameId: string, slot: string, at: number): string;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { KeyValue } from '@automataframework/core';
|
|
1
|
+
import type { Bindings, KeyValue } from '@automataframework/core';
|
|
2
|
+
/** Where one on-screen control sits: its middle as a share of the stage (0 to 1 across, 0 to 1 down), and its size. */
|
|
3
|
+
export type TouchPlace = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
size: number;
|
|
7
|
+
};
|
|
2
8
|
/** What a player can change. Each `setting` a screen file names is one of these keys. */
|
|
3
9
|
export type Settings = {
|
|
4
10
|
language: string;
|
|
@@ -6,19 +12,41 @@ export type Settings = {
|
|
|
6
12
|
music: number;
|
|
7
13
|
effects: number;
|
|
8
14
|
mute: boolean;
|
|
9
|
-
textSize:
|
|
10
|
-
contrast:
|
|
11
|
-
motion:
|
|
15
|
+
textSize: 0 | 1 | 2 | 3;
|
|
16
|
+
contrast: 0 | 1 | 2;
|
|
17
|
+
motion: 0 | 1 | 2;
|
|
18
|
+
bindings: Bindings[];
|
|
19
|
+
touch: TouchPlace[];
|
|
12
20
|
frameCounter: boolean;
|
|
13
21
|
};
|
|
14
22
|
export type SettingName = keyof Settings;
|
|
23
|
+
/** What the device asks for on a first visit. The browser's own by default; a test hands in its own. */
|
|
24
|
+
export type Asks = {
|
|
25
|
+
languages: readonly string[];
|
|
26
|
+
lessMotion: boolean;
|
|
27
|
+
moreContrast: boolean;
|
|
28
|
+
fontPx: number;
|
|
29
|
+
};
|
|
30
|
+
/** The on-screen controls' sizes, from the smallest. Level 1 is the size the controls file draws. */
|
|
31
|
+
export declare const touchSizes: readonly [0.75, 1, 1.25, 1.5];
|
|
32
|
+
/** The browser's own answers: language, `prefers-reduced-motion`, `prefers-contrast` and the page's font size. */
|
|
33
|
+
export declare function browserAsks(): Asks;
|
|
15
34
|
/**
|
|
16
|
-
* The player's settings, kept in the browser under `automata:<game id>:settings`. A first visit
|
|
17
|
-
*
|
|
35
|
+
* The player's settings, kept in the browser under `automata:<game id>:settings`. A first visit follows the device: the
|
|
36
|
+
* language it asks for (when the game has it), Less motion at level 2 when it asks for less motion, More contrast at
|
|
37
|
+
* level 1 when it asks for more, and Bigger text at level 1 over 16 px and level 2 over 20 px. `bindings` start as the
|
|
38
|
+
* controls file's own, one per player.
|
|
18
39
|
*/
|
|
19
|
-
export declare function createSettings(store: KeyValue, gameId: string, languages: string[],
|
|
40
|
+
export declare function createSettings(store: KeyValue, gameId: string, languages: string[], asks: Asks, bindings?: Bindings[]): {
|
|
20
41
|
all: () => Settings;
|
|
21
42
|
get: <K extends SettingName>(name: K) => Settings[K];
|
|
22
43
|
set<K extends SettingName>(name: K, value: Settings[K]): void;
|
|
44
|
+
/** The controls file's own bindings again. */
|
|
45
|
+
defaultBindings: () => Bindings[];
|
|
23
46
|
subscribe(listener: (settings: Settings) => void): () => void;
|
|
24
47
|
};
|
|
48
|
+
/** The classes and numbers the levels put on the shell root. Every part reads these; none has a branch of its own. */
|
|
49
|
+
export declare function levelStyle(settings: Pick<Settings, 'textSize' | 'contrast' | 'motion'>): {
|
|
50
|
+
classes: string;
|
|
51
|
+
vars: string;
|
|
52
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Action } from '@automataframework/core';
|
|
2
|
+
import { type TouchPlace } from '../settings/settings.ts';
|
|
3
|
+
/** A stick and a button, in px across, at size level 1. Both stay over 44 px at the smallest size. */
|
|
4
|
+
export declare const stickPx = 104;
|
|
5
|
+
export declare const buttonPx = 80;
|
|
6
|
+
/** One push of a move button: this share of the stage. */
|
|
7
|
+
export declare const nudge = 0.04;
|
|
8
|
+
/** The actions that get an on-screen control: the first stick and the first four buttons in the controls file. */
|
|
9
|
+
export declare function touchActions(actions: Action[]): Action[];
|
|
10
|
+
/** Where the controls sit at first: the stick low on the left, the buttons in a curve low on the right. */
|
|
11
|
+
export declare function firstPlaces(actions: Action[]): TouchPlace[];
|
|
12
|
+
/** The places kept in settings when there is one for each control, else the first places. */
|
|
13
|
+
export declare function placesFor(actions: Action[], kept: TouchPlace[]): TouchPlace[];
|
|
14
|
+
/** A place moved to `x`, `y` (shares of the stage), kept on the stage. */
|
|
15
|
+
export declare const moved: (place: TouchPlace, x: number, y: number) => TouchPlace;
|
|
16
|
+
/** A place one size bigger (`by` 1) or smaller (`by` -1), never past the ends. */
|
|
17
|
+
export declare function resized(place: TouchPlace, by: number): TouchPlace;
|
|
18
|
+
/** The size's level, 0 for the smallest, for its name. */
|
|
19
|
+
export declare const sizeLevel: (place: TouchPlace) => number;
|
|
20
|
+
/** A stick's push from where a finger is: `dx`, `dy` from the stick's middle, as a share of its radius, at most 1 long. */
|
|
21
|
+
export declare function stickPush(dx: number, dy: number, radius: number): [number, number];
|