rpg-engine 0.20.0 → 0.22.0
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/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.d.ts +3 -0
- package/dist/adventures/source.js +11 -49
- package/dist/campaign/create-campaign.d.ts +1 -1
- package/dist/campaign/create-campaign.js +3 -2
- package/dist/campaign/find-campaign.d.ts +2 -0
- package/dist/campaign/find-campaign.js +2 -0
- package/dist/campaign/host-files.js +4 -1
- package/dist/campaign/index.d.ts +3 -2
- package/dist/campaign/index.js +3 -2
- package/dist/campaign/port.d.ts +6 -0
- package/dist/campaign/port.js +24 -0
- package/dist/campaign/settings.d.ts +17 -0
- package/dist/campaign/settings.js +26 -3
- package/dist/cli/cli.js +15 -0
- package/dist/commands/book.d.ts +16 -35
- package/dist/commands/book.js +86 -62
- package/dist/commands/config/config.js +16 -2
- package/dist/commands/config/dashboard.d.ts +6 -2
- package/dist/commands/config/dashboard.js +45 -8
- package/dist/commands/config/shown.js +4 -0
- package/dist/commands/config/words.d.ts +3 -1
- package/dist/commands/config/words.js +29 -2
- package/dist/commands/image.d.ts +5 -0
- package/dist/commands/image.js +6 -3
- package/dist/commands/mode.d.ts +1 -1
- package/dist/commands/package/data.d.ts +35 -0
- package/dist/commands/package/data.js +144 -0
- package/dist/commands/package/here.d.ts +7 -2
- package/dist/commands/package/here.js +23 -11
- package/dist/commands/package/install.js +14 -15
- package/dist/commands/package/language.d.ts +15 -0
- package/dist/commands/package/language.js +109 -0
- package/dist/commands/package/package.js +20 -10
- package/dist/commands/package/result.d.ts +19 -0
- package/dist/commands/package/theme.d.ts +13 -0
- package/dist/commands/package/theme.js +67 -0
- package/dist/commands/package/uninstall.d.ts +4 -1
- package/dist/commands/package/uninstall.js +29 -9
- package/dist/commands/scene/close.d.ts +1 -1
- package/dist/commands/scene/close.js +15 -8
- package/dist/commands/scene/scene.js +6 -1
- package/dist/commands/shared/books/adventures.d.ts +1 -4
- package/dist/commands/shared/books/adventures.js +3 -32
- package/dist/commands/shared/books/words.js +3 -2
- package/dist/commands/shared/campaign/book.d.ts +21 -8
- package/dist/commands/shared/campaign/book.js +65 -42
- package/dist/commands/shared/campaign/git.d.ts +25 -0
- package/dist/commands/shared/campaign/git.js +104 -0
- package/dist/commands/shared/campaign/saves.js +7 -3
- package/dist/commands/shared/campaign/world.js +2 -1
- package/dist/commands/shared/packages/catalog.d.ts +3 -3
- package/dist/commands/shared/packages/catalog.js +118 -43
- package/dist/commands/shared/packages/unpacked.d.ts +50 -0
- package/dist/commands/shared/packages/unpacked.js +146 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +8 -4
- package/dist/core/archive.d.ts +13 -0
- package/dist/core/archive.js +76 -0
- package/dist/core/context.d.ts +4 -0
- package/dist/core/context.js +1 -0
- package/dist/core/store.d.ts +5 -1
- package/dist/core/store.js +15 -2
- package/dist/core/version.d.ts +2 -0
- package/dist/core/version.js +5 -0
- package/dist/dashboard/api.js +24 -1
- package/dist/dashboard/app.js +7 -2
- package/dist/dashboard/guide/ar.md +11 -9
- package/dist/dashboard/guide/cs.md +11 -9
- package/dist/dashboard/guide/da.md +12 -10
- package/dist/dashboard/guide/de.md +13 -11
- package/dist/dashboard/guide/el.md +11 -9
- package/dist/dashboard/guide/en.md +10 -8
- package/dist/dashboard/guide/es.md +11 -9
- package/dist/dashboard/guide/fi.md +11 -9
- package/dist/dashboard/guide/fr.md +11 -9
- package/dist/dashboard/guide/he.md +11 -9
- package/dist/dashboard/guide/hi.md +11 -9
- package/dist/dashboard/guide/hu.md +11 -9
- package/dist/dashboard/guide/is.md +11 -9
- package/dist/dashboard/guide/it.md +11 -9
- package/dist/dashboard/guide/ja.md +12 -10
- package/dist/dashboard/guide/ko.md +11 -9
- package/dist/dashboard/guide/nb.md +12 -10
- package/dist/dashboard/guide/nl.md +11 -9
- package/dist/dashboard/guide/pl.md +11 -9
- package/dist/dashboard/guide/pt.md +11 -9
- package/dist/dashboard/guide/ro.md +11 -9
- package/dist/dashboard/guide/ru.md +12 -10
- package/dist/dashboard/guide/sv.md +11 -9
- package/dist/dashboard/guide/tr.md +11 -9
- package/dist/dashboard/guide/uk.md +12 -10
- package/dist/dashboard/guide/zh.md +11 -9
- package/dist/dashboard/i18n/ar.json +58 -5
- package/dist/dashboard/i18n/cs.json +58 -5
- package/dist/dashboard/i18n/da.json +58 -5
- package/dist/dashboard/i18n/de.json +58 -5
- package/dist/dashboard/i18n/el.json +58 -5
- package/dist/dashboard/i18n/es.json +58 -5
- package/dist/dashboard/i18n/fi.json +58 -5
- package/dist/dashboard/i18n/fr.json +58 -5
- package/dist/dashboard/i18n/he.json +58 -5
- package/dist/dashboard/i18n/hi.json +58 -5
- package/dist/dashboard/i18n/hu.json +58 -5
- package/dist/dashboard/i18n/is.json +58 -5
- package/dist/dashboard/i18n/it.json +58 -5
- package/dist/dashboard/i18n/ja.json +58 -5
- package/dist/dashboard/i18n/ko.json +58 -5
- package/dist/dashboard/i18n/nb.json +58 -5
- package/dist/dashboard/i18n/nl.json +58 -5
- package/dist/dashboard/i18n/pl.json +58 -5
- package/dist/dashboard/i18n/pt.json +58 -5
- package/dist/dashboard/i18n/ro.json +58 -5
- package/dist/dashboard/i18n/ru.json +58 -5
- package/dist/dashboard/i18n/sv.json +58 -5
- package/dist/dashboard/i18n/tr.json +58 -5
- package/dist/dashboard/i18n/uk.json +58 -5
- package/dist/dashboard/i18n/zh.json +58 -5
- package/dist/dashboard/journal/book.js +3 -2
- package/dist/dashboard/journal/journal.js +8 -5
- package/dist/dashboard/kit.js +1 -1
- package/dist/dashboard/packages/catalog.js +31 -14
- package/dist/dashboard/packages/engine.js +46 -2
- package/dist/dashboard/packages/installed.js +13 -0
- package/dist/dashboard/packages/outcomes.js +21 -0
- package/dist/dashboard/packages/packages.js +41 -18
- package/dist/dashboard/packages/rows.js +3 -1
- package/dist/dashboard/parts/icons.js +3 -0
- package/dist/dashboard/parts/labels.js +7 -0
- package/dist/dashboard/parts/picture.js +89 -0
- package/dist/dashboard/parts/refusals.js +8 -1
- package/dist/dashboard/parts/widgets.js +2 -1
- package/dist/dashboard/play/scene.js +8 -5
- package/dist/dashboard/settings/settings.js +55 -18
- package/dist/dashboard/sheet/party.js +5 -2
- package/dist/dashboard/sheet/sheet.js +2 -1
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/shell/system-style.js +132 -15
- package/dist/dashboard/shell/tooltip.js +224 -0
- package/dist/dashboard/style.css +497 -193
- package/dist/dashboard/world/lore.js +4 -3
- package/dist/dashboard/world/place-card.js +2 -1
- package/dist/git/git.d.ts +12 -0
- package/dist/git/git.js +175 -0
- package/dist/git/ignore.d.ts +2 -0
- package/dist/git/ignore.js +16 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +2 -0
- package/dist/importer/index.d.ts +1 -1
- package/dist/importer/index.js +1 -1
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/pack.d.ts +4 -1
- package/dist/languages/pack.js +18 -6
- package/dist/packages/engine.d.ts +7 -0
- package/dist/packages/engine.js +32 -1
- package/dist/packages/index.d.ts +1 -1
- package/dist/packages/index.js +1 -1
- package/dist/server/bell-listener.d.ts +2 -1
- package/dist/server/bell-listener.js +10 -41
- package/dist/server/dashboard/engine.d.ts +18 -0
- package/dist/server/dashboard/engine.js +31 -0
- package/dist/server/dashboard/files.d.ts +11 -3
- package/dist/server/dashboard/files.js +66 -17
- package/dist/server/dashboard/index.d.ts +18 -2
- package/dist/server/dashboard/index.js +62 -23
- package/dist/server/dashboard/news.d.ts +3 -2
- package/dist/server/dashboard/news.js +19 -5
- package/dist/server/dashboard/pictures.d.ts +7 -0
- package/dist/server/dashboard/pictures.js +62 -0
- package/dist/server/dashboard/ports.d.ts +17 -2
- package/dist/server/dashboard/ports.js +60 -4
- package/dist/server/dashboard/writes.d.ts +5 -3
- package/dist/server/dashboard/writes.js +45 -14
- package/dist/server/mcp.d.ts +3 -2
- package/dist/server/mcp.js +55 -11
- package/dist/testing/index.js +1 -0
- package/dist/themes/css.d.ts +1 -1
- package/dist/themes/css.js +101 -2
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +4 -2
- package/dist/themes/installed.d.ts +14 -0
- package/dist/themes/installed.js +28 -0
- package/dist/themes/theme.d.ts +38 -0
- package/dist/themes/theme.js +192 -13
- package/instructions/core.md +4 -3
- package/instructions/dashboard-guide.md +2 -1
- package/instructions/mentor-hints.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/party.md +1 -1
- package/instructions/play.md +2 -2
- package/package.json +1 -1
- package/systems/free/instructions/outcomes-told.md +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
// RPG Engine itself on the Packages page: its card, how a new chat takes the version installed, and what a package's latest needs of it
|
|
3
|
-
|
|
2
|
+
// RPG Engine itself on the Packages page: its card, how a new chat takes the version installed, and what a package's latest needs of it; and the page's
|
|
3
|
+
// notice of a newer one (T-219).
|
|
4
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
5
|
+
import { sectionAddress } from "../address.js";
|
|
6
|
+
import { readEngine } from "../api.js";
|
|
4
7
|
import { CardHead } from "../parts/card.js";
|
|
5
8
|
import { Icon, iconPath } from "../parts/icons.js";
|
|
6
9
|
import { t } from "../text.js";
|
|
@@ -9,6 +12,38 @@ import { PackageRow, SaidNote, UpdateButton, VersionMeta, WorkNote } from "./row
|
|
|
9
12
|
export const engineName = "RPG Engine";
|
|
10
13
|
// Where the engine installed from this page is kept while the chat goes on with the one before it: in this tab, through a reload.
|
|
11
14
|
const updatedKey = "rpg-engine-updated";
|
|
15
|
+
// The newer version whose notice the player hid, on this browser: the next one is said again.
|
|
16
|
+
const hiddenKey = "rpg-engine-newer-hidden";
|
|
17
|
+
/**
|
|
18
|
+
* The page's notice of a newer RPG Engine on npm (T-219), as the server knows it today, read once as the page opens and never waited for; with the way to
|
|
19
|
+
* the Packages page, where its card updates it, and a cross that hides it until a newer one. None on that page, for a development link, or once installed.
|
|
20
|
+
*/
|
|
21
|
+
export function useEngineNotice(section) {
|
|
22
|
+
const [newer, setNewer] = useState();
|
|
23
|
+
const [hidden, setHidden] = useState(hiddenVersion);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
void readEngine().then((read) => setNewer(read?.update === true && read.install !== "link" ? read.latest : undefined), () => undefined);
|
|
26
|
+
}, []);
|
|
27
|
+
if (newer === undefined || newer === hidden || newer === keptUpdate()?.to || section === "packages") {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const hide = () => {
|
|
31
|
+
try {
|
|
32
|
+
localStorage.setItem(hiddenKey, newer);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Hidden while the page is open.
|
|
36
|
+
}
|
|
37
|
+
setHidden(newer);
|
|
38
|
+
};
|
|
39
|
+
return [{
|
|
40
|
+
kind: "info",
|
|
41
|
+
key: "engine-newer",
|
|
42
|
+
text: t("RPG Engine {version} is out.", { version: newer }),
|
|
43
|
+
link: { href: sectionAddress("packages"), text: t("Update it in Packages") },
|
|
44
|
+
hide: { label: t("Hide until the next version"), onHide: hide },
|
|
45
|
+
}];
|
|
46
|
+
}
|
|
12
47
|
/** The engine installed from this page in this tab, if any. */
|
|
13
48
|
export function keptUpdate() {
|
|
14
49
|
try {
|
|
@@ -85,3 +120,12 @@ function RestartNote({ updated }) {
|
|
|
85
120
|
: [t("Close this chat."), t("Start a new chat in the campaign, as you always do."), t("Reload this page.")];
|
|
86
121
|
return (_jsxs("div", { ref: note, class: "package-said package-restart", role: "status", tabIndex: -1, children: [_jsx("p", { children: `✓ ${t("RPG Engine {version} is installed.", { version: updated.to })}` }), _jsx("p", { children: t("The master goes on with {version} in this chat. To play with {next}:", { version: updated.from, next: updated.to }) }), _jsx("ol", { children: steps.map((step) => _jsx("li", { children: step }, step)) })] }));
|
|
87
122
|
}
|
|
123
|
+
/** The newer version whose notice the player hid, if any. */
|
|
124
|
+
function hiddenVersion() {
|
|
125
|
+
try {
|
|
126
|
+
return localStorage.getItem(hiddenKey) ?? undefined;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -41,6 +41,19 @@ export function MissingRow({ name, state, onInstall }) {
|
|
|
41
41
|
const shown = phraseLabel(name.replace(/^@[^/]+\//, ""));
|
|
42
42
|
return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: shown, about: _jsx("span", { class: "package-red", children: t("Missing on this computer: the master does not use it until you install it.") }), actions: _jsxs("button", { type: "button", class: "button package-button", "aria-label": t("Install {name}", { name: shown }), "aria-disabled": state.busy, onClick: () => !state.busy && onInstall(), children: [_jsx(Icon, { name: "download" }), t("Install")] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* A theme installed on this computer (D-574): its name, its version and GitHub's newer one, and whether this page shows it now; one that fails a check, in red
|
|
46
|
+
* with why, which Settings does not offer.
|
|
47
|
+
*/
|
|
48
|
+
export function ThemeRow({ theme, newer, needs, shown, fresh, state, onUpdate, onUninstall }) {
|
|
49
|
+
const name = _jsx("bdi", { children: theme.name });
|
|
50
|
+
const problems = theme.problems ?? [];
|
|
51
|
+
const uninstall = _jsx(UninstallButton, { name: theme.name, busy: state.busy, onClick: onUninstall });
|
|
52
|
+
if (problems.length > 0) {
|
|
53
|
+
return (_jsxs(PackageRow, { tile: "alert", tone: "broken", name: name, about: _jsx("span", { class: "package-red", children: t("It does not pass the page's checks: Settings does not offer it.") }), meta: _jsxs(_Fragment, { children: [theme.version !== undefined && `${theme.version} · `, _jsx("bdi", { class: "package-why", children: problems[0] })] }), row: `theme:${theme.id}`, fresh: fresh, actions: uninstall, children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
54
|
+
}
|
|
55
|
+
return (_jsxs(PackageRow, { tile: "theme", name: name, meta: (theme.version !== undefined || newer !== undefined || shown) && (_jsxs(_Fragment, { children: [_jsx(VersionMeta, { version: theme.version, newer: newer }), shown && `${theme.version !== undefined || newer !== undefined ? " · " : ""}${t("the style of this page")}`] })), needs: needs, row: `theme:${theme.id}`, fresh: fresh, actions: _jsxs(_Fragment, { children: [newer !== undefined && _jsx(UpdateButton, { name: theme.name, version: newer, busy: state.busy, onClick: onUpdate }), uninstall] }), children: [_jsx(WorkNote, { work: state.work }), _jsx(SaidNote, { said: state.said })] }));
|
|
56
|
+
}
|
|
44
57
|
/** A language package: its name, whose it is, its version and npm's newer one, and whether this page is written in it. */
|
|
45
58
|
export function LanguageRow({ language, newer, needs, fresh, state, onUpdate, onUninstall }) {
|
|
46
59
|
const page = pageLanguage().toLowerCase().split("-")[0] === language.code.toLowerCase().split("-")[0];
|
|
@@ -14,6 +14,23 @@ export function failure(at, action, name, outcome) {
|
|
|
14
14
|
}
|
|
15
15
|
return { at, problem: true, text: action === "add" ? t("Nothing was added.") : t("Nothing changed."), why: outcome.error };
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Why RPG Engine was not updated (T-219), in the page's words: the no, another package's work; where no window for the yes opens or npm failed, with the
|
|
19
|
+
* command that updates it from a terminal.
|
|
20
|
+
*/
|
|
21
|
+
export function engineFailure(outcome) {
|
|
22
|
+
const command = "npm install -g rpg-engine";
|
|
23
|
+
if (outcome.code === "declined") {
|
|
24
|
+
return { text: t("You said no: nothing changed.") };
|
|
25
|
+
}
|
|
26
|
+
if (outcome.code === "busy") {
|
|
27
|
+
return { text: t("One package at a time: wait for the one under way, then try again.") };
|
|
28
|
+
}
|
|
29
|
+
if (outcome.code === "no-window") {
|
|
30
|
+
return { text: t("No window for your yes opens on this computer: update RPG Engine from a terminal."), command };
|
|
31
|
+
}
|
|
32
|
+
return { text: t("RPG Engine was not updated."), why: outcome.error, ...(outcome.code === "engine-failed" ? { command } : {}) };
|
|
33
|
+
}
|
|
17
34
|
/** What an addition did, by the kind the engine recognized. */
|
|
18
35
|
export function addedText(kind) {
|
|
19
36
|
const texts = {
|
|
@@ -21,6 +38,7 @@ export function addedText(kind) {
|
|
|
21
38
|
extension: t("The extension is in the campaign: it counts from now on."),
|
|
22
39
|
system: t("The game system is on this computer, for a new campaign."),
|
|
23
40
|
language: t("The language is on this computer, for every campaign."),
|
|
41
|
+
theme: t("The theme is on this computer, for every campaign: choose it in Settings, under Game style."),
|
|
24
42
|
};
|
|
25
43
|
return kind === undefined ? t("Done.") : texts[kind];
|
|
26
44
|
}
|
|
@@ -35,6 +53,9 @@ export function doneText(action, name) {
|
|
|
35
53
|
}
|
|
36
54
|
/** What uninstalling does, by kind. */
|
|
37
55
|
export function uninstallText(what) {
|
|
56
|
+
if (what === "theme") {
|
|
57
|
+
return _jsx("p", { children: t("It goes off this computer: where you chose it, the page goes back to the game's style, or its own.") });
|
|
58
|
+
}
|
|
38
59
|
if (what === "system") {
|
|
39
60
|
return _jsx("p", { children: t("It goes off this computer: a new campaign can no longer choose it. This campaign does not change.") });
|
|
40
61
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
// The Packages section (D-485, D-486, D-488), in three tabs: Installed first, what is here by kind: the game system, with the pages of it the campaign changed
|
|
3
|
-
// under the one it plays (D-564), the campaign's adventures with its own export last, the extensions with whether the campaign uses each, the
|
|
4
|
-
// tab counts the updates and marks what the campaign lacks. Then Add: one card to add a package: the catalog of what npm and GitHub offer first, always open,
|
|
3
|
+
// under the one it plays (D-564), the campaign's adventures with its own export last, the extensions with whether the campaign uses each, the themes and the
|
|
4
|
+
// languages of every campaign (D-574); its tab counts the updates and marks what the campaign lacks. Then Add: one card to add a package: the catalog of what npm and GitHub offer first, always open,
|
|
5
5
|
// then a link, an npm name, a folder or a file. Then Library: the folders of the player's books for this campaign alone (D-491 (13)). One work at a time; one
|
|
6
6
|
// not ours with code, or a folder added to the library, waits for the player's yes in a window of their computer, said in every tab.
|
|
7
7
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
@@ -12,14 +12,15 @@ import { Icon, iconPath } from "../parts/icons.js";
|
|
|
12
12
|
import { phraseLabel } from "../parts/labels.js";
|
|
13
13
|
import { Confirm } from "../settings/saves.js";
|
|
14
14
|
import { PageHead } from "../shell/pages.js";
|
|
15
|
+
import { shownInstalledTheme } from "../shell/system-style.js";
|
|
15
16
|
import { PageTabs } from "../shell/tabs.js";
|
|
16
17
|
import { t } from "../text.js";
|
|
17
|
-
import { AddField, CatalogList, entryOf, entryTitle, newerOf, updateCount } from "./catalog.js";
|
|
18
|
+
import { AddField, CatalogList, entryOf, entryTitle, languageEntryOf, newerOf, newerVersion, themeEntryOf, updateCount } from "./catalog.js";
|
|
18
19
|
import { ChangedPages } from "./changes.js";
|
|
19
20
|
import { EngineCard, engineName, focusEngine, keepUpdate, keptUpdate, NeedsEngine } from "./engine.js";
|
|
20
|
-
import { AdventureRow, ExtensionRow, LanguageRow, languageTitle, MissingRow, SystemRow } from "./installed.js";
|
|
21
|
+
import { AdventureRow, ExtensionRow, LanguageRow, languageTitle, MissingRow, SystemRow, ThemeRow } from "./installed.js";
|
|
21
22
|
import { libraryReading, LibraryTab } from "./library.js";
|
|
22
|
-
import { addedText, doneText, failure, uninstallText } from "./outcomes.js";
|
|
23
|
+
import { addedText, doneText, engineFailure, failure, uninstallText } from "./outcomes.js";
|
|
23
24
|
import { CardSaid, SaidNote, WorkNote } from "./rows.js";
|
|
24
25
|
import { ShareCampaign } from "./share.js";
|
|
25
26
|
/**
|
|
@@ -174,13 +175,7 @@ export function PackagesPage({ version, tab, item, layers = [], sceneOpen = fals
|
|
|
174
175
|
setUpdated({ ...done, now: true });
|
|
175
176
|
}
|
|
176
177
|
else {
|
|
177
|
-
setSaid({
|
|
178
|
-
at: "engine",
|
|
179
|
-
problem: true,
|
|
180
|
-
...(outcome.code === "busy"
|
|
181
|
-
? { text: t("One package at a time: wait for the one under way, then try again.") }
|
|
182
|
-
: { text: t("RPG Engine was not updated."), why: outcome.error }),
|
|
183
|
-
});
|
|
178
|
+
setSaid({ at: "engine", problem: true, ...engineFailure(outcome) });
|
|
184
179
|
askEngine();
|
|
185
180
|
}
|
|
186
181
|
read();
|
|
@@ -188,6 +183,10 @@ export function PackagesPage({ version, tab, item, layers = [], sceneOpen = fals
|
|
|
188
183
|
const add = (at, source) => run(at, "add", source, () => addSource(source), addedText);
|
|
189
184
|
const addTheFile = (file) => run("add", "add", file.name, () => addFile(file), addedText);
|
|
190
185
|
const change = (at, action, name, label, after) => run(at, action, name, () => changePackage(action, name), () => doneText(action, label), after);
|
|
186
|
+
// One of data alone from GitHub, a theme or a language, is updated by adding it again from its link, in the place of the one here; npm's by npm.
|
|
187
|
+
const update = (at, name, label, entry) => entry !== undefined && /^https?:\/\//i.test(entry.source)
|
|
188
|
+
? run(at, "update", entry.source, () => addSource(entry.source), () => doneText("update", label))
|
|
189
|
+
: change(at, "update", name, label);
|
|
191
190
|
const addToLibrary = (path) => run("library", "library", path, () => changeLibrary("add", path), () => t("The folder is on this computer and in this campaign: its books are read now, then the master searches them."));
|
|
192
191
|
// One the computer has not leaves the list once taken out: what came of it is said under the field.
|
|
193
192
|
const useInCampaign = (path, use, away) => run(`library:${path}`, "library", path, () => changeLibrary(use ? "add" : "remove", path), () => (use ? t("In this campaign: the master searches its books.") : away ? t("{name} is out of the campaign.", { name: path }) : t("Off in this campaign: it stays on this computer.")), away && !use ? "library" : undefined);
|
|
@@ -206,6 +205,8 @@ export function PackagesPage({ version, tab, item, layers = [], sceneOpen = fals
|
|
|
206
205
|
const systems = view?.systems ?? [];
|
|
207
206
|
const adventures = view?.adventures ?? [];
|
|
208
207
|
const languages = view?.languages ?? [];
|
|
208
|
+
const themes = view?.themes ?? [];
|
|
209
|
+
const themeShown = shownInstalledTheme();
|
|
209
210
|
// The engine npm has that this page may install: one more update on the Installed tab, and the way for a package that needs it.
|
|
210
211
|
const engineNew = engine.read?.update === true && engine.read.install === "global" && updated === undefined ? engine.read.latest : undefined;
|
|
211
212
|
const updates = (view === undefined ? 0 : updateCount(view, catalog.read)) + (engineNew === undefined ? 0 : 1);
|
|
@@ -218,9 +219,21 @@ export function PackagesPage({ version, tab, item, layers = [], sceneOpen = fals
|
|
|
218
219
|
{ key: "installed", name: t("Installed"), label: [t("Installed"), ...marksText(updates, missing)].join(", "), marks: _jsx(TabMarks, { updates: updates, missing: missing }) },
|
|
219
220
|
{ key: "add", name: t("Add") },
|
|
220
221
|
{ key: "library", name: t("Library"), label: [t("Library"), ...marksText(0, away)].join(", "), marks: _jsx(TabMarks, { updates: 0, missing: away }) },
|
|
221
|
-
] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), needs: (entry) => needs(entry.newer), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void
|
|
222
|
+
] }), view !== undefined && (_jsxs("div", { class: "package-panel", id: "packages-panel", role: "tabpanel", "aria-label": shownTab === "add" ? t("Add") : shownTab === "library" ? t("Library") : t("Installed"), children: [elsewhere !== undefined && _jsx(WorkNote, { work: elsewhere, whose: workTitle(elsewhere, catalog.read) }), saidElsewhere !== undefined && _jsx(SaidNote, { said: saidElsewhere }), shownTab === "library" && (_jsx(LibraryTab, { view: library, problem: libraryProblem, state: rowState, onAdd: (path) => void addToLibrary(path), onUse: (path, use, away) => void useInCampaign(path, use, away), onForget: (path, name) => setAsking({ kind: "library", path, name }) })), shownTab === "add" && (_jsx("section", { class: "card", "aria-label": t("Add"), children: _jsxs("div", { class: "card-body package-body", children: [_jsx(CatalogList, { catalog: catalog, view: view, state: (entry) => rowState(`catalog:${entry.source}`), needs: (entry) => needs(entry.newer), onAdd: (entry) => void add(`catalog:${entry.source}`, entry.source), onUpdate: (entry) => void update(`catalog:${entry.source}`, entry.source, entryTitle(entry), entry), onRetry: () => askCatalog(true) }), _jsx(AddField, { state: rowState("add"), onAdd: (source) => void add("add", source), onFile: (file) => void addTheFile(file) })] }) })), shownTab === "installed" && (_jsxs(_Fragment, { children: [!engine.hidden && _jsx(EngineCard, { engine: engine.read, updated: updated, newer: engineNew, state: rowState("engine"), onUpdate: () => void updateTheEngine() }), _jsxs("section", { class: "card", "aria-labelledby": "packages-systems", children: [_jsx(CardHead, { icon: iconPath("dice"), title: _jsx("h3", { id: "packages-systems", tabIndex: -1, children: t("Game system") }) }), _jsxs("div", { class: "card-body package-body", children: [_jsx("ul", { class: "package-list", children: systems.map((system) => (_jsx(SystemRow, { system: system, newer: system.package === undefined ? undefined : newerOf(system.package, "system", catalog.read), needs: system.package === undefined ? null : needs(entryOf(system.package, "system", catalog.read)?.newer), changes: system.used ? _jsx(ChangedPages, { layers: layers, sceneOpen: sceneOpen, open: item, onChanged: onChanged }) : undefined, fresh: fresh.includes(`system:${system.name}`), state: rowState(`system:${system.name}`), onUpdate: (target) => void change(`system:${system.name}`, "update", target, system.name), onUninstall: (target) => setAsking({ kind: "uninstall", what: "system", name: system.name, target, at: `system:${system.name}` }) }, system.name))) }), _jsx(CardSaid, { said: said, at: "systems" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-adventures", children: [_jsx(CardHead, { icon: iconPath("world"), title: _jsx("h3", { id: "packages-adventures", tabIndex: -1, children: t("Adventures") }), ...(adventures.length === 0 ? {} : { note: String(adventures.length) }) }), _jsxs("div", { class: "card-body package-body", children: [adventures.length === 0 && _jsx("p", { class: "package-note", children: t("None yet: add one in Add, from the catalog, a .zip or a link.") }), adventures.length > 0 && (_jsx("ul", { class: "package-list", children: adventures.map((adventure) => (_jsx(AdventureRow, { adventure: adventure, fresh: fresh.includes(`adventure:${adventure.title}`), state: rowState(`adventure:${adventure.title}`), onTakeOut: () => setAsking({ kind: "adventure", title: adventure.title }) }, adventure.title))) })), _jsx(CardSaid, { said: said, at: "adventures" }), _jsx(ShareCampaign, {})] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-extensions", children: [_jsx(CardHead, { icon: iconPath("packages"), title: _jsx("h3", { id: "packages-extensions", tabIndex: -1, children: t("Extensions") }), ...(view.installed.length + view.missing.length === 0 ? {} : { note: t("{count} in use", { count: usedCount(view) }) }) }), _jsxs("div", { class: "card-body package-body", children: [view.installed.length + view.missing.length === 0 && _jsx("p", { class: "package-note", children: t("None: an extension adds rules and tools to the game; you find them in Add, in the catalog.") }), view.installed.length + view.missing.length > 0 && (_jsxs("ul", { class: "package-list", children: [view.installed.map((extension) => (_jsx(ExtensionRow, { extension: extension, newer: newerOf(extension.package, "extension", catalog.read), needs: needs(entryOf(extension.package, "extension", catalog.read)?.newer), fresh: fresh.includes(`extension:${extension.package}`), state: rowState(`extension:${extension.package}`), onUse: (use) => void (use
|
|
222
223
|
? add(`extension:${extension.package}`, extension.package)
|
|
223
|
-
: change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-
|
|
224
|
+
: change(`extension:${extension.package}`, "remove", extension.package, phraseLabel(extension.name))), onUpdate: () => void change(`extension:${extension.package}`, "update", extension.package, phraseLabel(extension.name)), onUninstall: () => setAsking({ kind: "uninstall", what: "extension", name: phraseLabel(extension.name), target: extension.package, at: `extension:${extension.package}` }) }, extension.package))), view.missing.map((name) => _jsx(MissingRow, { name: name, state: rowState(`extension:${name}`), onInstall: () => void add(`extension:${name}`, name) }, name))] })), _jsx(CardSaid, { said: said, at: "extensions" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-themes", children: [_jsx(CardHead, { icon: iconPath("theme"), title: _jsx("h3", { id: "packages-themes", tabIndex: -1, children: t("Themes") }), ...(themes.length === 0 ? {} : { note: String(themes.length) }) }), _jsxs("div", { class: "card-body package-body", children: [themes.length === 0 && _jsx("p", { class: "package-note", children: t("None: a theme changes the page's colours, faces and pictures, in every campaign; you find them in Add, in the catalog.") }), themes.length > 0 && (_jsxs(_Fragment, { children: [_jsx("ul", { class: "package-list", children: themes.map((theme) => {
|
|
225
|
+
const entry = themeEntryOf(theme, catalog.read);
|
|
226
|
+
return (_jsx(ThemeRow, { theme: theme, newer: newerVersion(entry), needs: needs(entry?.newer), shown: theme.id === themeShown, fresh: fresh.includes(`theme:${theme.id}`), state: rowState(`theme:${theme.id}`), onUpdate: () => void update(`theme:${theme.id}`, theme.id, theme.name, entry), onUninstall: () => setAsking({ kind: "uninstall", what: "theme", name: theme.name, target: `theme:${theme.id}`, at: `theme:${theme.id}` }) }, theme.id));
|
|
227
|
+
}) }), _jsx("p", { class: "package-note", children: t("You choose one in Settings, under Game style.") })] })), _jsx(CardSaid, { said: said, at: "themes" })] })] }), _jsxs("section", { class: "card", "aria-labelledby": "packages-languages", children: [_jsx(CardHead, { icon: iconPath("language"), title: _jsx("h3", { id: "packages-languages", tabIndex: -1, children: t("Languages") }) }), _jsxs("div", { class: "card-body package-body", children: [languages.length === 0 && _jsx("p", { class: "package-note", children: t("None. The dashboard has its own languages; a language package takes the place of one with a translation made by hand.") }), languages.length > 0 && (_jsx("ul", { class: "package-list", children: languages.map((language) => {
|
|
228
|
+
const entry = languageEntryOf(language, catalog.read);
|
|
229
|
+
return (_jsx(LanguageRow, { language: language, newer: newerVersion(entry), needs: needs(entry?.newer), fresh: fresh.includes(`language:${language.code}`), state: rowState(`language:${language.code}`), onUpdate: () => void update(`language:${language.code}`, language.package, languageTitle(language), entry), onUninstall: () => setAsking({
|
|
230
|
+
kind: "uninstall",
|
|
231
|
+
what: "language",
|
|
232
|
+
name: languageTitle(language),
|
|
233
|
+
target: language.unpacked === true ? `language:${language.code}` : language.package,
|
|
234
|
+
at: `language:${language.code}`,
|
|
235
|
+
}) }, language.package));
|
|
236
|
+
}) })), _jsx(CardSaid, { said: said, at: "languages" })] })] })] }))] })), asking?.kind === "adventure" && (_jsxs(Confirm, { title: t("Take {name} out of the campaign?", { name: asking.title }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("Its places, people and pages leave the world. To have it again, add it once more.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take out") })] })] })), asking?.kind === "library" && (_jsxs(Confirm, { title: t("Take {path} off this computer?", { path: asking.name }), onClose: () => setAsking(undefined), children: [_jsx("p", { children: t("No campaign searches it any more, and the text RPG Engine read of its books is deleted. The books stay where they are.") }), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Take off") })] })] })), asking?.kind === "uninstall" && (_jsxs(Confirm, { title: t("Uninstall {name} from this computer?", { name: asking.name }), onClose: () => setAsking(undefined), children: [uninstallText(asking.what), _jsxs("div", { class: "confirm-buttons", children: [_jsx("button", { type: "button", class: "button", autoFocus: true, onClick: () => setAsking(undefined), children: t("Cancel") }), _jsx("button", { type: "button", class: "button danger final", onClick: () => confirmed(asking), children: t("Uninstall") })] })] }))] }));
|
|
224
237
|
}
|
|
225
238
|
/** On the Installed tab, what asks for the player: the updates npm has, with their count, and a mark when the campaign lists what this computer lacks. */
|
|
226
239
|
function TabMarks({ updates, missing }) {
|
|
@@ -240,6 +253,7 @@ function rowKeys(view) {
|
|
|
240
253
|
...(view.systems ?? []).map((one) => `system:${one.name}`),
|
|
241
254
|
...(view.adventures ?? []).map((one) => `adventure:${one.title}`),
|
|
242
255
|
...view.installed.map((one) => `extension:${one.package}`),
|
|
256
|
+
...(view.themes ?? []).map((one) => `theme:${one.id}`),
|
|
243
257
|
...(view.languages ?? []).map((one) => `language:${one.code}`),
|
|
244
258
|
];
|
|
245
259
|
}
|
|
@@ -253,7 +267,13 @@ function tabOf(at) {
|
|
|
253
267
|
return at === "add" || at.startsWith("catalog:") ? "add" : at === "library" || at.startsWith("library:") ? "library" : "installed";
|
|
254
268
|
}
|
|
255
269
|
// The card of each kind among the installed, by its heading's id.
|
|
256
|
-
const cardOf = {
|
|
270
|
+
const cardOf = {
|
|
271
|
+
system: "packages-systems",
|
|
272
|
+
adventure: "packages-adventures",
|
|
273
|
+
extension: "packages-extensions",
|
|
274
|
+
theme: "packages-themes",
|
|
275
|
+
language: "packages-languages",
|
|
276
|
+
};
|
|
257
277
|
/** How many extensions the campaign uses, those this computer lacks among them. */
|
|
258
278
|
function usedCount(view) {
|
|
259
279
|
return view.installed.filter((one) => !("broken" in one) && one.used).length + view.missing.length;
|
|
@@ -266,6 +286,7 @@ function workPlace(work, view, catalog) {
|
|
|
266
286
|
const adventure = view.adventures?.find((one) => same(one.title));
|
|
267
287
|
const system = view.systems?.find((one) => same(one.name, one.package));
|
|
268
288
|
const language = view.languages?.find((one) => same(one.code, one.package));
|
|
289
|
+
const theme = view.themes?.find((one) => same(one.id, one.name));
|
|
269
290
|
const entry = catalog?.entries.find((one) => same(one.source));
|
|
270
291
|
if (work.action === "library" || work.action === "engine") {
|
|
271
292
|
return work.action;
|
|
@@ -281,7 +302,9 @@ function workPlace(work, view, catalog) {
|
|
|
281
302
|
? `system:${system.name}`
|
|
282
303
|
: language !== undefined
|
|
283
304
|
? `language:${language.code}`
|
|
284
|
-
:
|
|
285
|
-
? `
|
|
286
|
-
:
|
|
305
|
+
: theme !== undefined
|
|
306
|
+
? `theme:${theme.id}`
|
|
307
|
+
: entry !== undefined
|
|
308
|
+
? `catalog:${entry.source}`
|
|
309
|
+
: "add";
|
|
287
310
|
}
|
|
@@ -47,7 +47,9 @@ export function WorkNote({ work, whose }) {
|
|
|
47
47
|
if (work.phase === "yes") {
|
|
48
48
|
return (_jsxs("div", { class: "package-window", role: "status", children: [_jsx(Icon, { name: "window" }), _jsxs("span", { children: [named, _jsx("strong", { children: t("Answer in the window of your computer.") }), " ", work.action === "library"
|
|
49
49
|
? t("It asks whether RPG Engine may read the documents of that folder. Can't see it? It is behind the browser.")
|
|
50
|
-
:
|
|
50
|
+
: work.action === "engine"
|
|
51
|
+
? t("It asks whether to update RPG Engine on this computer. Can't see it? It is behind the browser.")
|
|
52
|
+
: t("It asks whether code that RPG Engine did not publish may run here. Can't see it? It is behind the browser.")] })] }));
|
|
51
53
|
}
|
|
52
54
|
return (_jsxs("div", { class: "package-progress", role: "status", children: [_jsx("span", { class: "package-bar", "aria-hidden": "true" }), _jsxs("span", { children: [named, _jsx("strong", { children: workingText(work.action) }), " ", t("You can go to another page: it goes on by itself.")] })] }));
|
|
53
55
|
}
|
|
@@ -92,9 +92,12 @@ const iconPaths = {
|
|
|
92
92
|
// The Packages page (D-486): a file to add, the catalog's search, a language, the window of the computer where the yes is given, more rows.
|
|
93
93
|
file: "M6 3h8l4 4v14H6Z M14 3v4h4 M9 13h6 M9 16.5h6",
|
|
94
94
|
folder: "M3 5h6.5l2 2.5H21V20H3Z",
|
|
95
|
+
picture: "M3.5 5h17v14h-17Z M3.5 16l5-5 4.5 4.5 3-3 4.5 4.5 M15.5 7a1.5 1.5 0 1 0 0 3a1.5 1.5 0 1 0 0-3Z",
|
|
95
96
|
library: "M4 6h3.5v14.5H4Z M9 3.5h3.5v17H9Z M9 7.5h3.5 M16.5 20.5l3.3-.9-3.4-12.5-3.3.9Z",
|
|
96
97
|
search: "M10.5 4a6.5 6.5 0 1 0 0 13a6.5 6.5 0 1 0 0-13Z M15.5 15.5 20 20",
|
|
97
98
|
language: "M4 5h9 M8.5 3v2 M6 5c.5 3 2.8 5.5 6 7 M11 5c-.6 3-2.5 5.6-5.5 7.3 M12.5 21l4-9 4 9 M14 17.5h5",
|
|
99
|
+
// A painter's palette: a theme, the page's colours and faces (D-574).
|
|
100
|
+
theme: "M12 3a9 9 0 1 0 0 18c1 0 1.7-.8 1.7-1.7 0-.4-.2-.8-.4-1.1-.3-.3-.4-.7-.4-1.1 0-.9.8-1.7 1.7-1.7h2.1a5.3 5.3 0 0 0 5.3-5.3C22 6.6 17.5 3 12 3Z M7.5 12h.01 M9 8h.01 M13.5 7h.01 M17 10h.01",
|
|
98
101
|
window: "M3 5h18v14H3Z M3 9h18 M6 7h.01 M8.5 7h.01",
|
|
99
102
|
more: "M6 9l6 6 6-6",
|
|
100
103
|
// A thing in a list of bonds, as attuned: two rings linked.
|
|
@@ -236,6 +236,9 @@ export function settingLabel(name) {
|
|
|
236
236
|
veils: t("Veils"),
|
|
237
237
|
orders: t("Standing orders"),
|
|
238
238
|
language: t("Language"),
|
|
239
|
+
git: t("Git"),
|
|
240
|
+
"git-saves": t("Saves in the repository"),
|
|
241
|
+
"git-sessions": t("Chats in the repository"),
|
|
239
242
|
companions: t("Companions"),
|
|
240
243
|
preparation: t("Preparation"),
|
|
241
244
|
length: t("Length"),
|
|
@@ -329,6 +332,10 @@ export function valueLabel(value) {
|
|
|
329
332
|
master: t("The master"),
|
|
330
333
|
important: t("Main characters"),
|
|
331
334
|
always: t("Everyone"),
|
|
335
|
+
commit: t("Commit"),
|
|
336
|
+
push: t("Commit and push"),
|
|
337
|
+
out: t("Left out"),
|
|
338
|
+
in: t("Included"),
|
|
332
339
|
"behind the screen": t("Behind the screen"),
|
|
333
340
|
"in view": t("In view"),
|
|
334
341
|
stops: t("Stops"),
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "preact/hooks";
|
|
3
|
+
import { givePicture } from "../api.js";
|
|
4
|
+
import { t } from "../text.js";
|
|
5
|
+
import { Icon } from "./icons.js";
|
|
6
|
+
// What the game takes, as image takes it: the browser's chooser shows these first.
|
|
7
|
+
const pictureTypes = "image/png,image/jpeg,image/webp,image/svg+xml";
|
|
8
|
+
// How long a picture stays darkened, at most, waiting for the new one to reach the page.
|
|
9
|
+
const longestWait = 8000;
|
|
10
|
+
/** A page's picture as a coin, with the control that gives it one of the player's own on its rim, across from the pip of its side. */
|
|
11
|
+
export function PictureSpot({ page, has = true, children, class: extra }) {
|
|
12
|
+
return (_jsxs("span", { class: extra === undefined ? "picture-spot" : `picture-spot ${extra}`, children: [children, _jsx(PictureButton, { page: page, has: has, icon: true, rim: true })] }));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The control that gives `page` a picture of the player's own: "Change the picture…", or "Add a picture…" while it shows none; as words, or as an icon over a
|
|
16
|
+
* picture's corner, its tip towards the picture's start, or on a coin's rim, its tip over it. In a list's row it is on its thumb's rim, no stop of Tab, and no
|
|
17
|
+
* button on touch, as the page it opens has one.
|
|
18
|
+
*/
|
|
19
|
+
export function PictureButton({ page, has, icon = false, rim = false, row = false }) {
|
|
20
|
+
const own = useRef(null);
|
|
21
|
+
const input = useRef(null);
|
|
22
|
+
const [sending, setSending] = useState(false);
|
|
23
|
+
const [problem, setProblem] = useState();
|
|
24
|
+
const [said, setSaid] = useState("");
|
|
25
|
+
const words = has ? t("Change the picture…") : t("Add a picture…");
|
|
26
|
+
const named = has ? t("Change the picture: {page}", { page }) : t("Add a picture: {page}", { page });
|
|
27
|
+
const send = async (file) => {
|
|
28
|
+
if (file === undefined) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const host = own.current?.parentElement ?? null;
|
|
32
|
+
const before = shownPicture(host);
|
|
33
|
+
setSending(true);
|
|
34
|
+
setProblem(undefined);
|
|
35
|
+
setSaid("");
|
|
36
|
+
const refused = await givePicture(page, file);
|
|
37
|
+
if (input.current !== null) {
|
|
38
|
+
input.current.value = "";
|
|
39
|
+
}
|
|
40
|
+
if (refused !== undefined) {
|
|
41
|
+
setSending(false);
|
|
42
|
+
setProblem(refused);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setSaid(t("{page} has your picture now.", { page }));
|
|
46
|
+
// Over a picture, it stays darkened until the new one is on the page, and clears into it.
|
|
47
|
+
if (icon && host !== null) {
|
|
48
|
+
await newPicture(host, before);
|
|
49
|
+
}
|
|
50
|
+
setSending(false);
|
|
51
|
+
};
|
|
52
|
+
const choose = (event) => {
|
|
53
|
+
// Over a picture that opens something, the click is the control's alone.
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
if (!sending) {
|
|
57
|
+
input.current?.click();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const classes = ["picture-give", icon ? "icon" : "", sending ? "sending" : "", problem === undefined ? "" : "refused"].filter((name) => name !== "");
|
|
61
|
+
return (_jsxs("span", { ref: own, class: classes.join(" "), children: [_jsx("input", { ref: input, type: "file", accept: pictureTypes, hidden: true, tabIndex: -1, onChange: (event) => void send(event.currentTarget.files?.[0]) }), _jsxs("button", { type: "button", class: icon ? (rim || row ? "icon-button" : "icon-button tip-left") : "button package-button", "aria-label": named, "data-tip": icon ? (sending ? t("Sending…") : words) : undefined, "aria-busy": sending, "aria-disabled": sending ? "true" : undefined, tabIndex: row ? -1 : undefined, onClick: choose, children: [icon ? _jsx("span", { class: "picture-plate", children: sending ? _jsx(Waiting, {}) : _jsx(Icon, { name: "picture" }) }) : sending ? _jsx(Waiting, {}) : _jsx(Icon, { name: "picture" }), !icon && (sending ? t("Sending…") : words)] }), problem !== undefined && _jsx("span", { class: "picture-problem", role: "alert", children: problem }), _jsx("span", { class: "visually-hidden", role: "status", children: said })] }));
|
|
62
|
+
}
|
|
63
|
+
/** The ring that turns while the picture is sent, in place of the icon. */
|
|
64
|
+
function Waiting() {
|
|
65
|
+
return _jsx("span", { class: "picture-wait", "aria-hidden": "true" });
|
|
66
|
+
}
|
|
67
|
+
/** The address of the picture a host shows now, or "" for none. */
|
|
68
|
+
function shownPicture(host) {
|
|
69
|
+
return host?.querySelector("img")?.src ?? "";
|
|
70
|
+
}
|
|
71
|
+
/** Settles once the host shows a picture other than `before`, loaded, or after the longest wait, if the page does not change. */
|
|
72
|
+
function newPicture(host, before) {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
const done = () => {
|
|
75
|
+
watch.disconnect();
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
resolve();
|
|
78
|
+
};
|
|
79
|
+
const watch = new MutationObserver(() => {
|
|
80
|
+
const image = host.querySelector("img");
|
|
81
|
+
if (image !== null && image.src !== before) {
|
|
82
|
+
watch.disconnect();
|
|
83
|
+
void image.decode().catch(() => undefined).then(done);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const timer = setTimeout(done, longestWait);
|
|
87
|
+
watch.observe(host, { subtree: true, childList: true, attributes: true, attributeFilter: ["src"] });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -24,7 +24,9 @@ const phrases = {
|
|
|
24
24
|
"system-taken": (values) => t("There is already a game system called {system} on this computer: {name} would take its name.", values),
|
|
25
25
|
"system-unread": (values) => t("{name} was installed, but it does not read as a game system: uninstall it.", values),
|
|
26
26
|
"language-code": (values) => t("{name} says it is a language, but brings code: a language is texts only.", values),
|
|
27
|
-
|
|
27
|
+
// npm's language taken off again, or one of data alone never written: either way, it is not on this computer.
|
|
28
|
+
"language-refused": (values) => t("{name} cannot be used, and is not on this computer: {why}", values),
|
|
29
|
+
"theme-refused": (values) => t("{name} is no theme the page can use: {why}", values),
|
|
28
30
|
"language-kept": (values) => t("{name} cannot be used, and version {version} stays: {why}", values),
|
|
29
31
|
"not-used": (values) => t("This campaign does not use {name}.", values),
|
|
30
32
|
"system-played": (values) => t("This campaign plays {name}: it stays on this computer.", values),
|
|
@@ -45,6 +47,7 @@ const phrases = {
|
|
|
45
47
|
"archive-link": (values) => t("{name} holds {entry}, which is not a plain file: it is refused whole.", values),
|
|
46
48
|
"archive-accents": (values) => t("{name} names files with accents in another encoding: make the zip again with 7-Zip.", values),
|
|
47
49
|
"not-adventure": (values) => t("{name} is not an adventure: it has no adventure.yaml at its top. A document is imported by the master.", values),
|
|
50
|
+
"not-package": (values) => t("{name} is no package: it has no adventure.yaml, theme.yaml or language.yaml at its top. A document is imported by the master.", values),
|
|
48
51
|
"adventure-file": (values) => t("{name} holds {file}, which an adventure may not hold: it is refused whole.", values),
|
|
49
52
|
"not-a-name": (values) => t("{name} is not the name of an npm package.", values),
|
|
50
53
|
"folder-characters": (values) => t("The folder {name} has characters npm cannot take: move it to another path.", values),
|
|
@@ -62,4 +65,8 @@ const phrases = {
|
|
|
62
65
|
"scene-open": () => t("It can be put back once the scene being played is over."),
|
|
63
66
|
"file-big": (values) => t("The file is more than {size} MB: no package is that big.", values),
|
|
64
67
|
"file-kind": (values) => t("{name} is neither a .zip nor a .tgz.", values),
|
|
68
|
+
"picture-big": (values) => t("The picture is more than {size} MB: make it smaller.", values),
|
|
69
|
+
"not-picture": (values) => t("{name} is not a PNG, JPEG, WebP or SVG picture.", values),
|
|
70
|
+
"no-page": (values) => t("Your character knows no page called {page}: reload the page.", values),
|
|
71
|
+
"system-page": (values) => t("{page} comes from the game system, with its own picture.", values),
|
|
65
72
|
};
|
|
@@ -74,10 +74,11 @@ function Items({ items, field, fields }) {
|
|
|
74
74
|
/** Someone's effects as tags, each with its end; past `most`, how many more. */
|
|
75
75
|
export function Effects({ effects, most }) {
|
|
76
76
|
const shown = most === undefined ? effects : effects.slice(0, most);
|
|
77
|
+
const others = effects.slice(shown.length).map((effect) => effectLabel(effect)).join(", ");
|
|
77
78
|
// Where few fit (`most`), one with a drawing is its icon alone, its words in its tooltip and for a screen reader (D-516); else its icon before its words.
|
|
78
79
|
return effects.length === 0 ? null : (_jsxs("span", { class: "effects", children: [shown.map((effect) => effect.icon !== undefined && most !== undefined
|
|
79
80
|
? (_jsx("span", { class: "effect icon-only", role: "img", "aria-label": effectLabel(effect), "data-tip": effectLabel(effect), children: _jsx(EffectIcon, { path: effect.icon }) }, effect.text))
|
|
80
|
-
: (_jsxs("span", { class: effect.icon === undefined ? "effect" : "effect with-icon", title: effectLabel(effect), children: [effect.icon !== undefined && _jsx(EffectIcon, { path: effect.icon }), effectName(effect.name), effect.end && most === undefined ? _jsx("span", { class: "end", children: `· ${effectEndLabel(effect.end)}` }) : null, effect.burns && most === undefined ? _jsx("span", { class: "end", children: `· ${burnsLabel(effect.name, effect.burns)}` }) : null] }, effect.text))), effects.length > shown.length && _jsx("span", { class: "effect more", dir: "ltr", "
|
|
81
|
+
: (_jsxs("span", { class: effect.icon === undefined ? "effect" : "effect with-icon", title: effectLabel(effect), children: [effect.icon !== undefined && _jsx(EffectIcon, { path: effect.icon }), effectName(effect.name), effect.end && most === undefined ? _jsx("span", { class: "end", children: `· ${effectEndLabel(effect.end)}` }) : null, effect.burns && most === undefined ? _jsx("span", { class: "end", children: `· ${burnsLabel(effect.name, effect.burns)}` }) : null] }, effect.text))), effects.length > shown.length && _jsx("span", { class: "effect more", dir: "ltr", role: "img", "aria-label": others, "data-tip": others, children: `+${numberText(effects.length - shown.length)}` })] }));
|
|
81
82
|
}
|
|
82
83
|
/** The drawing of an effect, a path on a grid of 24 stroked as the page's icons. */
|
|
83
84
|
function EffectIcon({ path }) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
-
// The Scene section (D-309, VIEW-6, D-444): where the party is, its picture with the places around it, its name, what holds there and its text; the open
|
|
3
|
-
// scene and who is in it; outside a scene who is there of those the character knows; the map. While the scene goes by turns, the turns first.
|
|
4
2
|
import { useContext, useEffect, useRef, useState } from "preact/hooks";
|
|
5
3
|
import { TalkName } from "../acts/names.js";
|
|
6
4
|
import { sectionAddress } from "../address.js";
|
|
@@ -10,6 +8,7 @@ import { cardIcons, Icon } from "../parts/icons.js";
|
|
|
10
8
|
import { phraseLabel, sceneTypeLabel, strangerLabel } from "../parts/labels.js";
|
|
11
9
|
import { biomeLabel, biomes } from "../parts/map-symbols.js";
|
|
12
10
|
import { InlineText, knowersOf, Markdown } from "../parts/markdown.js";
|
|
11
|
+
import { PictureButton, PictureSpot } from "../parts/picture.js";
|
|
13
12
|
import { downTint, personState, StatusPip } from "../parts/status.js";
|
|
14
13
|
import { PlaceMap } from "../place/view.js";
|
|
15
14
|
import { sideOf, Token } from "../sheet/party.js";
|
|
@@ -108,8 +107,8 @@ function PlaceBand({ place, fold }) {
|
|
|
108
107
|
const link = placeLinks(place);
|
|
109
108
|
const caption = (_jsxs("div", { class: "place-caption", children: [place.within.length > 0 && (_jsx("ol", { class: "place-path", "aria-label": t("Within"), children: place.within.map((name) => _jsx("li", { children: name }, name)) })), _jsx("h2", { id: "place-name", children: place.name }), place.around.length > 0 && (_jsx("ul", { class: "place-env", "aria-label": t("Around"), children: place.around.map((item) => _jsx(Surrounding, { item: item, name: place.name, link: link }, `${"effect" in item ? item.effect : item.name} ${item.place ?? ""}`)) })), fold && text !== "" && _jsx(DescriptionToggle, { open: fold.open, controls: "place-band-text", onToggle: fold.onToggle })] }));
|
|
110
109
|
return place.image === undefined
|
|
111
|
-
? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers })] }))
|
|
112
|
-
: (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }) }))] }));
|
|
110
|
+
? (_jsxs("header", { class: "place-band compact", children: [_jsxs("div", { class: "place-shot", children: [_jsx(PictureSpot, { page: place.name, has: false, class: "place-disc-spot", children: _jsx("div", { class: "place-disc", children: _jsx(Icon, { name: "house" }) }) }), caption] }), text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers })] }))
|
|
111
|
+
: (_jsxs("header", { class: fold === undefined ? "place-band over" : `place-band over folding${fold.open ? "" : " low"}`, children: [_jsxs("div", { class: "place-shot picture-host", children: [_jsx("figure", { class: "place-image", children: _jsx("img", { src: `/images/${encodeURIComponent(place.image.file)}?v=${place.image.version}`, alt: "" }) }), caption, _jsx(PictureButton, { page: place.name, has: true, icon: true })] }), fold === undefined && text !== "" && _jsx(PlaceAbout, { text: text, link: link, knowers: knowers }), fold?.open === true && text !== "" && (_jsx("div", { class: "place-about", id: "place-band-text", children: _jsx("div", { class: "place-about-text", children: _jsx(Markdown, { text: text, link: link, secretKnowers: knowers }) }) }))] }));
|
|
113
112
|
}
|
|
114
113
|
/**
|
|
115
114
|
* One thing that holds there: an entry of the environment as its name and value, as light dim, the biome and the terrain the engine reads in the page's language;
|
|
@@ -157,7 +156,7 @@ function People({ people }) {
|
|
|
157
156
|
};
|
|
158
157
|
return (_jsx("ul", { class: "present", children: people.map((person, index) => (_jsxs("li", { class: person.role === "other" && index > 0 && people[index - 1].role !== "other" ? "after-party" : undefined, children: [person.stranger && person.image === undefined
|
|
159
158
|
? (_jsxs("span", { class: ["token stranger", letterOf(person.name) === undefined ? "" : "numbered", person.hostile === true ? "hostile" : ""].filter((name) => name !== "").join(" "), "aria-hidden": "true", children: [letterOf(person.name) ?? _jsx(Icon, { name: "stranger" }), _jsx(StatusPip, { status: { ...person, party: false } })] }))
|
|
160
|
-
: (_jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status: statusOf(person), dying: downTint(statusOf(person)), number: person.stranger ? letterOf(person.name) : undefined })), person.role === "pc"
|
|
159
|
+
: (_jsx(PersonPicture, { person: person, children: _jsx(Token, { member: { name: person.name, role: person.role, ...(person.image === undefined ? {} : { image: person.image }), ...(person.icon === undefined ? {} : { icon: person.icon }) }, hostile: person.hostile === true, side: sideOf(person.role), status: statusOf(person), dying: downTint(statusOf(person)), number: person.stranger ? letterOf(person.name) : undefined }) })), person.role === "pc"
|
|
161
160
|
? _jsx(PersonName, { person: person })
|
|
162
161
|
: (_jsx(TalkName, { name: person.stranger ? strangerLabel(person.name) : person.name, children: _jsx(PersonName, { person: person }) }))] }, `${person.name} ${index}`))) }));
|
|
163
162
|
}
|
|
@@ -169,3 +168,7 @@ function PersonName({ person }) {
|
|
|
169
168
|
function letterOf(name) {
|
|
170
169
|
return /^creature ([A-Z])$/.exec(name)?.[1];
|
|
171
170
|
}
|
|
171
|
+
/** Someone's token with the control for a picture of the player's own, but a stranger's: what stands for them is no page the player sees. */
|
|
172
|
+
function PersonPicture({ person, children }) {
|
|
173
|
+
return person.stranger === true ? _jsx(_Fragment, { children: children }) : _jsx(PictureSpot, { page: person.name, has: person.image !== undefined, children: children });
|
|
174
|
+
}
|