@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.11
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/CHANGELOG.md +49 -0
- package/LICENSE +19 -0
- package/dist/Game/AnimationManager.d.ts +1 -1
- package/dist/Game/AnimationManager.js +18 -9
- package/dist/Game/AnimationManager.js.map +1 -1
- package/dist/Game/AnimationManager.spec.d.ts +1 -0
- package/dist/Game/Event.js.map +1 -1
- package/dist/Game/Map.d.ts +9 -1
- package/dist/Game/Map.js +63 -5
- package/dist/Game/Map.js.map +1 -1
- package/dist/Game/Object.d.ts +47 -15
- package/dist/Game/Object.js +82 -38
- package/dist/Game/Object.js.map +1 -1
- package/dist/Game/Player.js.map +1 -1
- package/dist/Game/ProjectileManager.d.ts +89 -0
- package/dist/Game/ProjectileManager.js +179 -0
- package/dist/Game/ProjectileManager.js.map +1 -0
- package/dist/Game/ProjectileManager.spec.d.ts +1 -0
- package/dist/Gui/Gui.d.ts +17 -4
- package/dist/Gui/Gui.js +78 -48
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/Gui.spec.d.ts +1 -0
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/Resource.js +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/RpgClient.d.ts +110 -15
- package/dist/RpgClientEngine.d.ts +86 -10
- package/dist/RpgClientEngine.js +306 -49
- package/dist/RpgClientEngine.js.map +1 -1
- package/dist/Sound.js.map +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorateMetadata.js +1 -1
- package/dist/components/animations/animation.ce.js +4 -5
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +19 -25
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/animations/index.js +4 -4
- package/dist/components/animations/index.js.map +1 -1
- package/dist/components/character.ce.js +422 -240
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +97 -0
- package/dist/components/dynamics/bar.ce.js.map +1 -0
- package/dist/components/dynamics/image.ce.js +24 -0
- package/dist/components/dynamics/image.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +3 -0
- package/dist/components/dynamics/parse-value.js +54 -35
- package/dist/components/dynamics/parse-value.js.map +1 -1
- package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
- package/dist/components/dynamics/shape-utils.d.ts +16 -0
- package/dist/components/dynamics/shape-utils.js +73 -0
- package/dist/components/dynamics/shape-utils.js.map +1 -0
- package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
- package/dist/components/dynamics/shape.ce.js +84 -0
- package/dist/components/dynamics/shape.ce.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +34 -56
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +6 -8
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +56 -62
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +42 -65
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +21 -30
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +112 -165
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +8 -6
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +52 -69
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +75 -92
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +5 -4
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +12 -17
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/index.js +2 -2
- package/dist/components/gui/mobile/index.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +5 -4
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +22 -24
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +72 -249
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +90 -127
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +45 -70
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1 -0
- package/dist/components/player-components-utils.d.ts +67 -0
- package/dist/components/player-components-utils.js +162 -0
- package/dist/components/player-components-utils.js.map +1 -0
- package/dist/components/player-components-utils.spec.d.ts +1 -0
- package/dist/components/player-components.ce.js +189 -0
- package/dist/components/player-components.ce.js.map +1 -0
- package/dist/components/prebuilt/hp-bar.ce.js +42 -44
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +36 -59
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +165 -21
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +25 -32
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +9 -8
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/inject.js +1 -1
- package/dist/core/inject.js.map +1 -1
- package/dist/core/setup.js +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/decorators/spritesheet.d.ts +1 -0
- package/dist/decorators/spritesheet.js +11 -0
- package/dist/decorators/spritesheet.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -21
- package/dist/module.js +15 -1
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.0.1}/node_modules/@signe/di/dist/index.js +7 -117
- package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
- package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
- package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.0.1}/node_modules/@signe/sync/dist/index.js +57 -141
- package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
- package/dist/presets/animation.js.map +1 -1
- package/dist/presets/faceset.js.map +1 -1
- package/dist/presets/icon.js.map +1 -1
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/lpc.js.map +1 -1
- package/dist/presets/rmspritesheet.js.map +1 -1
- package/dist/services/AbstractSocket.js.map +1 -1
- package/dist/services/actionInput.d.ts +12 -0
- package/dist/services/actionInput.js +27 -0
- package/dist/services/actionInput.js.map +1 -0
- package/dist/services/actionInput.spec.d.ts +1 -0
- package/dist/services/keyboardControls.js.map +1 -1
- package/dist/services/loadMap.d.ts +6 -0
- package/dist/services/loadMap.js +1 -1
- package/dist/services/loadMap.js.map +1 -1
- package/dist/services/mmorpg-connection.d.ts +5 -0
- package/dist/services/mmorpg-connection.js +50 -0
- package/dist/services/mmorpg-connection.js.map +1 -0
- package/dist/services/mmorpg-connection.spec.d.ts +1 -0
- package/dist/services/mmorpg.d.ts +10 -4
- package/dist/services/mmorpg.js +56 -33
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/pointerContext.d.ts +11 -0
- package/dist/services/pointerContext.js +48 -0
- package/dist/services/pointerContext.js.map +1 -0
- package/dist/services/pointerContext.spec.d.ts +1 -0
- package/dist/services/save.js.map +1 -1
- package/dist/services/save.spec.d.ts +1 -0
- package/dist/services/standalone-message.d.ts +1 -0
- package/dist/services/standalone-message.js +9 -0
- package/dist/services/standalone-message.js.map +1 -0
- package/dist/services/standalone.js +4 -3
- package/dist/services/standalone.js.map +1 -1
- package/dist/services/standalone.spec.d.ts +1 -0
- package/dist/utils/getEntityProp.js +4 -3
- package/dist/utils/getEntityProp.js.map +1 -1
- package/dist/utils/getEntityProp.spec.d.ts +1 -0
- package/dist/utils/readPropValue.d.ts +2 -0
- package/dist/utils/readPropValue.js +13 -0
- package/dist/utils/readPropValue.js.map +1 -0
- package/package.json +13 -14
- package/src/Game/AnimationManager.spec.ts +30 -0
- package/src/Game/AnimationManager.ts +22 -10
- package/src/Game/Map.ts +91 -2
- package/src/Game/Object.ts +148 -69
- package/src/Game/ProjectileManager.spec.ts +338 -0
- package/src/Game/ProjectileManager.ts +324 -0
- package/src/Gui/Gui.spec.ts +273 -0
- package/src/Gui/Gui.ts +105 -50
- package/src/Resource.ts +1 -2
- package/src/RpgClient.ts +125 -17
- package/src/RpgClientEngine.ts +457 -87
- package/src/components/character.ce +441 -32
- package/src/components/dynamics/bar.ce +88 -0
- package/src/components/dynamics/image.ce +21 -0
- package/src/components/dynamics/parse-value.spec.ts +83 -0
- package/src/components/dynamics/parse-value.ts +111 -37
- package/src/components/dynamics/shape-utils.spec.ts +46 -0
- package/src/components/dynamics/shape-utils.ts +61 -0
- package/src/components/dynamics/shape.ce +90 -0
- package/src/components/dynamics/text.ce +35 -149
- package/src/components/gui/dialogbox/index.ce +18 -8
- package/src/components/gui/gameover.ce +2 -1
- package/src/components/gui/menu/equip-menu.ce +2 -1
- package/src/components/gui/menu/exit-menu.ce +2 -1
- package/src/components/gui/menu/items-menu.ce +3 -2
- package/src/components/gui/menu/main-menu.ce +2 -1
- package/src/components/gui/save-load.ce +2 -1
- package/src/components/gui/shop/shop.ce +3 -2
- package/src/components/gui/title-screen.ce +2 -1
- package/src/components/index.ts +2 -1
- package/src/components/player-components-utils.spec.ts +109 -0
- package/src/components/player-components-utils.ts +205 -0
- package/src/components/player-components.ce +222 -0
- package/src/components/prebuilt/hp-bar.ce +4 -3
- package/src/components/prebuilt/light-halo.ce +2 -2
- package/src/components/scenes/canvas.ce +175 -8
- package/src/components/scenes/draw-map.ce +18 -17
- package/src/components/scenes/event-layer.ce +1 -2
- package/src/core/setup.ts +2 -2
- package/src/decorators/spritesheet.ts +8 -0
- package/src/index.ts +4 -0
- package/src/module.ts +18 -1
- package/src/services/actionInput.spec.ts +101 -0
- package/src/services/actionInput.ts +53 -0
- package/src/services/loadMap.ts +2 -0
- package/src/services/mmorpg-connection.spec.ts +99 -0
- package/src/services/mmorpg-connection.ts +69 -0
- package/src/services/mmorpg.ts +68 -36
- package/src/services/pointerContext.spec.ts +36 -0
- package/src/services/pointerContext.ts +84 -0
- package/src/services/save.spec.ts +127 -0
- package/src/services/standalone-message.ts +7 -0
- package/src/services/standalone.spec.ts +34 -0
- package/src/services/standalone.ts +3 -2
- package/src/utils/getEntityProp.spec.ts +96 -0
- package/src/utils/getEntityProp.ts +4 -3
- package/src/utils/readPropValue.ts +16 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject } from "../../core/inject.js";
|
|
2
|
+
import { getKeyboardControlBind } from "../../services/actionInput.js";
|
|
2
3
|
import { SaveClientService } from "../../services/save.js";
|
|
3
4
|
import { RpgGui } from "../../Gui/Gui.js";
|
|
4
5
|
import { RpgClientEngine } from "../../RpgClientEngine.js";
|
|
@@ -8,274 +9,95 @@ import { PrebuiltGui } from "@rpgjs/common";
|
|
|
8
9
|
function component($$props) {
|
|
9
10
|
useProps($$props);
|
|
10
11
|
const defineProps = useDefineProps($$props);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function step(result) {
|
|
33
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
34
|
-
}
|
|
35
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
39
|
-
var _ = {
|
|
40
|
-
label: 0,
|
|
41
|
-
sent: function() {
|
|
42
|
-
if (t[0] & 1) throw t[1];
|
|
43
|
-
return t[1];
|
|
44
|
-
},
|
|
45
|
-
trys: [],
|
|
46
|
-
ops: []
|
|
47
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
48
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
49
|
-
return this;
|
|
50
|
-
}), g;
|
|
51
|
-
function verb(n) {
|
|
52
|
-
return function(v) {
|
|
53
|
-
return step([n, v]);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
59
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0:
|
|
63
|
-
case 1:
|
|
64
|
-
t = op;
|
|
65
|
-
break;
|
|
66
|
-
case 4:
|
|
67
|
-
_.label++;
|
|
68
|
-
return {
|
|
69
|
-
value: op[1],
|
|
70
|
-
done: false
|
|
71
|
-
};
|
|
72
|
-
case 5:
|
|
73
|
-
_.label++;
|
|
74
|
-
y = op[1];
|
|
75
|
-
op = [0];
|
|
76
|
-
continue;
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [6, e];
|
|
107
|
-
y = 0;
|
|
108
|
-
} finally {
|
|
109
|
-
f = t = 0;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] & 5) throw op[1];
|
|
112
|
-
return {
|
|
113
|
-
value: op[0] ? op[1] : void 0,
|
|
114
|
-
done: true
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var __spreadArray = this && this.__spreadArray || function(to, from, pack) {
|
|
119
|
-
if (pack || arguments.length === 2) {
|
|
120
|
-
for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
|
|
121
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
122
|
-
ar[i] = from[i];
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
126
|
-
};
|
|
127
|
-
var engine = inject(RpgClientEngine);
|
|
128
|
-
var saveClient = inject(SaveClientService);
|
|
129
|
-
var gui = inject(RpgGui);
|
|
130
|
-
var keyboardControls = engine.globalConfig.keyboardControls;
|
|
131
|
-
var selectedSlot = signal(0);
|
|
132
|
-
var DEFAULT_SLOTS = 4;
|
|
133
|
-
var defaultSlots = function() {
|
|
134
|
-
return Array.from({ length: DEFAULT_SLOTS }, function() {
|
|
135
|
-
return null;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
var localSlots = signal(defaultSlots());
|
|
139
|
-
var _a = defineProps(), data = _a.data, onFinish = _a.onFinish;
|
|
140
|
-
var title = computed(function() {
|
|
141
|
-
return data().mode === "save" ? "Save Game" : "Load Game";
|
|
142
|
-
});
|
|
143
|
-
var subtitle = computed(function() {
|
|
144
|
-
return data().mode === "save" ? "Choose a slot to overwrite or create." : "Select a slot to load your progress.";
|
|
145
|
-
});
|
|
146
|
-
var slotsValue = computed(function() {
|
|
147
|
-
return localSlots();
|
|
148
|
-
});
|
|
149
|
-
var displaySlots = computed(function() {
|
|
150
|
-
var _a;
|
|
151
|
-
var slots = slotsValue();
|
|
152
|
-
var items = slots.map(function(slot, index) {
|
|
153
|
-
return {
|
|
154
|
-
kind: "slot",
|
|
155
|
-
slot,
|
|
156
|
-
slotIndex: index,
|
|
157
|
-
label: "Slot ".concat(index + 1),
|
|
158
|
-
readonly: false
|
|
159
|
-
};
|
|
160
|
-
});
|
|
12
|
+
const engine = inject(RpgClientEngine);
|
|
13
|
+
const saveClient = inject(SaveClientService);
|
|
14
|
+
const gui = inject(RpgGui);
|
|
15
|
+
const keyboardControls = engine.globalConfig.keyboardControls;
|
|
16
|
+
const selectedSlot = signal(0);
|
|
17
|
+
const DEFAULT_SLOTS = 4;
|
|
18
|
+
const defaultSlots = () => Array.from({ length: DEFAULT_SLOTS }, () => null);
|
|
19
|
+
const localSlots = signal(defaultSlots());
|
|
20
|
+
const { data, onFinish } = defineProps();
|
|
21
|
+
const title = computed(() => data().mode === "save" ? "Save Game" : "Load Game");
|
|
22
|
+
const subtitle = computed(() => data().mode === "save" ? "Choose a slot to overwrite or create." : "Select a slot to load your progress.");
|
|
23
|
+
const slotsValue = computed(() => localSlots());
|
|
24
|
+
const displaySlots = computed(() => {
|
|
25
|
+
const slots = slotsValue();
|
|
26
|
+
const items = slots.map((slot, index) => ({
|
|
27
|
+
kind: "slot",
|
|
28
|
+
slot,
|
|
29
|
+
slotIndex: index,
|
|
30
|
+
label: `Slot ${index + 1}`,
|
|
31
|
+
readonly: false
|
|
32
|
+
}));
|
|
161
33
|
if (!data().showAutoSlot) return items;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return
|
|
34
|
+
const index = typeof data().autoSlotIndex === "number" ? data().autoSlotIndex : 0;
|
|
35
|
+
const autoSlot = slots[index] ?? null;
|
|
36
|
+
const readonly = data().mode === "save";
|
|
37
|
+
return [{
|
|
166
38
|
kind: "auto",
|
|
167
39
|
slot: autoSlot,
|
|
168
40
|
slotIndex: index,
|
|
169
41
|
label: data().autoSlotLabel || "Auto Save",
|
|
170
42
|
readonly
|
|
171
|
-
}
|
|
43
|
+
}, ...items];
|
|
172
44
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
} }, "wrap");
|
|
176
|
-
var canSelect = function(item) {
|
|
45
|
+
const nav = createTabindexNavigator(selectedSlot, { count: () => displaySlots().length }, "wrap");
|
|
46
|
+
const canSelect = (item) => {
|
|
177
47
|
if (item.readonly) return false;
|
|
178
48
|
if (data().mode === "load" && !item.slot) return false;
|
|
179
49
|
return true;
|
|
180
50
|
};
|
|
181
|
-
|
|
51
|
+
const normalizeSlotValue = (value) => {
|
|
182
52
|
if (!value) return null;
|
|
183
53
|
if (typeof value === "string") try {
|
|
184
54
|
return JSON.parse(value);
|
|
185
|
-
} catch
|
|
55
|
+
} catch {
|
|
186
56
|
return null;
|
|
187
57
|
}
|
|
188
58
|
return value;
|
|
189
59
|
};
|
|
190
|
-
|
|
60
|
+
const normalizeSlots = (list) => {
|
|
191
61
|
if (Array.isArray(list)) {
|
|
192
|
-
|
|
193
|
-
return Array.from({ length
|
|
194
|
-
return normalizeSlotValue(list[index]);
|
|
195
|
-
});
|
|
62
|
+
const length = Math.max(list.length, DEFAULT_SLOTS);
|
|
63
|
+
return Array.from({ length }, (_, index) => normalizeSlotValue(list[index]));
|
|
196
64
|
}
|
|
197
65
|
if (!list || typeof list !== "object") return defaultSlots();
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
var maxIndex = indices.length ? Math.max.apply(Math, indices) : -1;
|
|
207
|
-
var length = Math.max(maxIndex + 1, DEFAULT_SLOTS);
|
|
208
|
-
var slots = Array.from({ length }, function() {
|
|
209
|
-
return null;
|
|
210
|
-
});
|
|
211
|
-
keys.forEach(function(key) {
|
|
212
|
-
var index = Number(key);
|
|
66
|
+
const keys = Object.keys(list).filter((key) => /^\d+$/.test(key));
|
|
67
|
+
const indices = keys.map((key) => Number(key)).filter((index) => index >= 0);
|
|
68
|
+
const maxIndex = indices.length ? Math.max(...indices) : -1;
|
|
69
|
+
const length = Math.max(maxIndex + 1, DEFAULT_SLOTS);
|
|
70
|
+
const slots = Array.from({ length }, () => null);
|
|
71
|
+
keys.forEach((key) => {
|
|
72
|
+
const index = Number(key);
|
|
213
73
|
if (index < 0 || index >= length) return;
|
|
214
74
|
slots[index] = normalizeSlotValue(list[key]);
|
|
215
75
|
});
|
|
216
76
|
return slots;
|
|
217
77
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
0,
|
|
226
|
-
2,
|
|
227
|
-
,
|
|
228
|
-
3
|
|
229
|
-
]);
|
|
230
|
-
return [4, saveClient.listSlots()];
|
|
231
|
-
case 1:
|
|
232
|
-
list = _a.sent();
|
|
233
|
-
localSlots.set(normalizeSlots(list));
|
|
234
|
-
return [3, 3];
|
|
235
|
-
case 2:
|
|
236
|
-
_a.sent();
|
|
237
|
-
localSlots.set(defaultSlots());
|
|
238
|
-
return [3, 3];
|
|
239
|
-
case 3: return [2];
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
});
|
|
78
|
+
const refreshSlots = async () => {
|
|
79
|
+
try {
|
|
80
|
+
const list = await saveClient.listSlots();
|
|
81
|
+
localSlots.set(normalizeSlots(list));
|
|
82
|
+
} catch (err) {
|
|
83
|
+
localSlots.set(defaultSlots());
|
|
84
|
+
}
|
|
243
85
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
return [4, refreshSlots()];
|
|
260
|
-
case 2:
|
|
261
|
-
_a.sent();
|
|
262
|
-
_a.label = 3;
|
|
263
|
-
case 3:
|
|
264
|
-
if (!(action === "load")) return [3, 5];
|
|
265
|
-
return [4, saveClient.loadSlot(item.slotIndex)];
|
|
266
|
-
case 4:
|
|
267
|
-
_a.sent();
|
|
268
|
-
_a.label = 5;
|
|
269
|
-
case 5:
|
|
270
|
-
setTimeout(function() {
|
|
271
|
-
if (onFinish) onFinish();
|
|
272
|
-
gui.hide(PrebuiltGui.Save);
|
|
273
|
-
gui.hide(PrebuiltGui.TitleScreen);
|
|
274
|
-
}, 50);
|
|
275
|
-
return [2];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
});
|
|
86
|
+
const triggerSelect = async (displayIndex) => {
|
|
87
|
+
const item = displaySlots()[displayIndex];
|
|
88
|
+
if (!item) return;
|
|
89
|
+
if (!canSelect(item)) return;
|
|
90
|
+
const action = data().mode === "save" ? "save" : "load";
|
|
91
|
+
if (action === "save") {
|
|
92
|
+
await saveClient.saveSlot(item.slotIndex);
|
|
93
|
+
await refreshSlots();
|
|
94
|
+
}
|
|
95
|
+
if (action === "load") await saveClient.loadSlot(item.slotIndex);
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
if (onFinish) onFinish();
|
|
98
|
+
gui.hide(PrebuiltGui.Save);
|
|
99
|
+
gui.hide(PrebuiltGui.TitleScreen);
|
|
100
|
+
}, 50);
|
|
279
101
|
};
|
|
280
102
|
function selectSlot(index) {
|
|
281
103
|
return function() {
|
|
@@ -283,12 +105,12 @@ function component($$props) {
|
|
|
283
105
|
triggerSelect(index);
|
|
284
106
|
};
|
|
285
107
|
}
|
|
286
|
-
|
|
108
|
+
const controls = signal({
|
|
287
109
|
up: {
|
|
288
110
|
repeat: true,
|
|
289
111
|
bind: keyboardControls.up,
|
|
290
112
|
throttle: 150,
|
|
291
|
-
keyDown
|
|
113
|
+
keyDown() {
|
|
292
114
|
nav.next(-1);
|
|
293
115
|
}
|
|
294
116
|
},
|
|
@@ -296,26 +118,26 @@ function component($$props) {
|
|
|
296
118
|
repeat: true,
|
|
297
119
|
bind: keyboardControls.down,
|
|
298
120
|
throttle: 150,
|
|
299
|
-
keyDown
|
|
121
|
+
keyDown() {
|
|
300
122
|
nav.next(1);
|
|
301
123
|
}
|
|
302
124
|
},
|
|
303
125
|
action: {
|
|
304
|
-
bind: keyboardControls.action,
|
|
305
|
-
keyDown
|
|
126
|
+
bind: getKeyboardControlBind(keyboardControls.action),
|
|
127
|
+
keyDown() {
|
|
306
128
|
triggerSelect(selectedSlot());
|
|
307
129
|
}
|
|
308
130
|
},
|
|
309
131
|
escape: {
|
|
310
132
|
bind: keyboardControls.escape,
|
|
311
|
-
keyDown
|
|
133
|
+
keyDown() {
|
|
312
134
|
if (onFinish) onFinish();
|
|
313
135
|
gui.hide(PrebuiltGui.Save);
|
|
314
136
|
}
|
|
315
137
|
},
|
|
316
138
|
gamepad: { enabled: true }
|
|
317
139
|
});
|
|
318
|
-
mount(
|
|
140
|
+
mount((element) => {
|
|
319
141
|
refreshSlots();
|
|
320
142
|
});
|
|
321
143
|
return h(DOMContainer, {
|
|
@@ -383,7 +205,8 @@ function component($$props) {
|
|
|
383
205
|
textContent: "Empty Slot"
|
|
384
206
|
}))]))))]));
|
|
385
207
|
}
|
|
208
|
+
var __ce_component = component;
|
|
386
209
|
//#endregion
|
|
387
|
-
export {
|
|
210
|
+
export { __ce_component as default };
|
|
388
211
|
|
|
389
212
|
//# sourceMappingURL=save-load.ce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-load.ce.js","names":[],"sources":["../../../src/components/gui/save-load.ce"],"sourcesContent":["<DOMContainer width=\"100%\" height=\"100%\">\n <div class=\"rpg-ui-save-load rpg-anim-fade-in\">\n <div class=\"rpg-ui-save-load-header\">\n <div class=\"rpg-ui-save-load-title\">{title()}</div>\n <div class=\"rpg-ui-save-load-subtitle\">{subtitle()}</div>\n </div>\n <Navigation tabindex={selectedSlot} controls={controls}>\n <div class=\"rpg-ui-save-load-list\">\n @for ((item,displayIndex) of displaySlots) {\n <div\n class=\"rpg-ui-save-load-slot\"\n class={{active: selectedSlot() === displayIndex}}\n tabindex={displayIndex}\n data-slot-index={displayIndex}\n click={selectSlot(displayIndex)}\n >\n <div class=\"rpg-ui-save-load-slot-index\">{item.label}</div>\n @if (item.slot) {\n <div class=\"rpg-ui-save-load-slot-meta\">\n <div class=\"rpg-ui-save-load-slot-line\">Level: {item.slot.level ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Exp: {item.slot.exp ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Map: {item.slot.map ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Date: {item.slot.date ?? \"-\"}</div>\n </div>\n }\n @else {\n <div class=\"rpg-ui-save-load-slot-empty\">Empty Slot</div>\n }\n </div>\n }\n </div>\n </Navigation>\n </div>\n</DOMContainer>\n\n<script>\n import { signal, computed, effect, createTabindexNavigator, mount } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { SaveClientService } from \"../../services/save\";\n import { PrebuiltGui } from \"@rpgjs/common\";\n import { RpgGui } from \"../../Gui/Gui\";\n\n const engine = inject(RpgClientEngine);\n const saveClient = inject(SaveClientService);\n const gui = inject(RpgGui);\n const keyboardControls = engine.globalConfig.keyboardControls;\n\n const selectedSlot = signal(0);\n const DEFAULT_SLOTS = 4;\n const defaultSlots = () => Array.from({ length: DEFAULT_SLOTS }, () => null);\n const localSlots = signal(defaultSlots());\n\n const { data, onFinish } = defineProps();\n\n const title = computed(() => data().mode === \"save\" ? \"Save Game\" : \"Load Game\");\n const subtitle = computed(() => data().mode === \"save\"\n ? \"Choose a slot to overwrite or create.\"\n : \"Select a slot to load your progress.\"\n );\n\n const slotsValue = computed(() => localSlots());\n const displaySlots = computed(() => {\n const slots = slotsValue();\n const items = slots.map((slot, index) => ({\n kind: \"slot\",\n slot,\n slotIndex: index,\n label: `Slot ${index + 1}`,\n readonly: false\n }));\n if (!data().showAutoSlot) return items;\n const index = typeof data().autoSlotIndex === \"number\" ? data().autoSlotIndex : 0;\n const autoSlot = slots[index] ?? null;\n const readonly = data().mode === \"save\";\n return [\n {\n kind: \"auto\",\n slot: autoSlot,\n slotIndex: index,\n label: data().autoSlotLabel || \"Auto Save\",\n readonly\n },\n ...items\n ];\n });\n const nav = createTabindexNavigator(selectedSlot, { count: () => displaySlots().length }, \"wrap\");\n\n const canSelect = (item) => {\n if (item.readonly) return false;\n if (data().mode === \"load\" && !item.slot) return false;\n return true;\n };\n\n const normalizeSlotValue = (value) => {\n if (!value) return null;\n if (typeof value === \"string\") {\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n }\n return value;\n };\n\n const normalizeSlots = (list) => {\n if (Array.isArray(list)) {\n const length = Math.max(list.length, DEFAULT_SLOTS);\n return Array.from({ length }, (_, index) => normalizeSlotValue(list[index]));\n }\n if (!list || typeof list !== \"object\") {\n return defaultSlots();\n }\n const keys = Object.keys(list).filter((key) => /^\\d+$/.test(key));\n const indices = keys.map((key) => Number(key)).filter((index) => index >= 0);\n const maxIndex = indices.length ? Math.max(...indices) : -1;\n const length = Math.max(maxIndex + 1, DEFAULT_SLOTS);\n const slots = Array.from({ length }, () => null);\n keys.forEach((key) => {\n const index = Number(key);\n if (index < 0 || index >= length) return;\n slots[index] = normalizeSlotValue(list[key]);\n });\n return slots;\n };\n\n const hasProvidedSlots = (list) => {\n if (Array.isArray(list)) return list.length > 0;\n return !!(list && typeof list === \"object\" && Object.keys(list).length > 0);\n };\n\n const refreshSlots = async () => {\n try {\n const list = await saveClient.listSlots();\n localSlots.set(normalizeSlots(list));\n } catch (err) {\n localSlots.set(defaultSlots());\n }\n };\n\n const triggerSelect = async (displayIndex) => {\n const list = displaySlots();\n const item = list[displayIndex];\n if (!item) return;\n if (!canSelect(item)) return;\n const action = data().mode === \"save\" ? \"save\" : \"load\";\n if (action === \"save\") {\n await saveClient.saveSlot(item.slotIndex);\n await refreshSlots();\n }\n if (action === \"load\") {\n await saveClient.loadSlot(item.slotIndex);\n }\n setTimeout(() => {\n if (onFinish) onFinish();\n gui.hide(PrebuiltGui.Save);\n gui.hide(PrebuiltGui.TitleScreen);\n }, 50);\n\n };\n\n function selectSlot(index) {\n return function() {\n selectedSlot.set(index);\n triggerSelect(index);\n }\n }\n\n const controls = signal({\n up: {\n repeat: true,\n bind: keyboardControls.up,\n throttle: 150,\n keyDown() {\n nav.next(-1);\n }\n },\n down: {\n repeat: true,\n bind: keyboardControls.down,\n throttle: 150,\n keyDown() {\n nav.next(1);\n }\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n triggerSelect(selectedSlot());\n }\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (onFinish) onFinish();\n gui.hide(PrebuiltGui.Save);\n }\n },\n gamepad: {\n enabled: true\n }\n });\n\n mount((element) => {\n refreshSlots();\n });\n</script>\n"],"mappings":";;;;;;;AAaM,SAAuB,UAAW,SAAC;AAClB,UAAQ,QAAA;CACvB,MAAM,cAAM,eAAA,QAAA;CACZ,IAAI,YAAa,QAAI,KAAO,aAAgB,SAAM,SAAa,YAAW,GAAA,WAAA;EAC9E,SAAS,MAAM,OAAM;AAAG,UAAM,iBAAM,IAAA,QAAA,IAAA,EAAA,SAAA,SAAA;AAAA,YAAA,MAAA;KAAA;;AACpC,SAAO,KAAK,MAAM,IAAI,UAAO,SAAa,SAAM,QAAU;GACtD,SAAS,UAAU,OAAM;AAAG,QAAC;AAAK,UAAK,UAAS,KAAK,MAAK,CAAA;aAAc,GAAA;AAAK,YAAK,EAAA;;;GAClF,SAAS,SAAS,OAAO;AAAA,QAAI;AAAA,UAAO,UAAY,SAAS,MAAM,CAAC;aAAW,GAAA;AAAK,YAAO,EAAE;;;GACzF,SAAS,KAAK,QAAQ;AAAE,WAAK,OAAO,QAAO,OAAU,MAAK,GAAI,MAAM,OAAO,MAAK,CAAA,KAAO,WAAS,SAAA;;AAChG,SAAM,YAAY,UAAU,MAAM,SAAS,cAAc,EAAC,CAAA,EAAI,MAAM,CAAC;IACvE;;CAEN,IAAI,cAAe,QAAM,KAAK,eAAA,SAAA,SAAA,MAAA;EAC1B,IAAI,I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AAA;AACN,UAAQ,CAAC,KACD,QAAE,CAAA,EAAA;AACN,UAAI,CAAA,UAAQ,KAAA,CAChB,QAAA,CAAA,EAAA;AACH,eAAA,MAAA,CAAA,SAAA,SAAA,SAAA;AACK,UAAA,EAAA,WAAA,QAAA,QAAA,CAAA,GAAA,EAAA;AACF,aAAQ,CAAI,GAAA,WAAA,SAAA,KAAA,UAAA,CAAA;KACZ,KAAK;AACL,SAAA,MAAa;AACb,aAAU,CAAA,GAAA,cAAA,CAAA;KACV,KAAI;AACJ,SAAA,MAAA;AACH,SAAA,QAAA;KACD,KAAQ;AACA,UAAE,EAAA,WAAA,QAAuB,QAAA,CAAA,GAAA,EAAA;AAC7B,aAAU,CAAA,GAAA,WAAA,SAAA,KAAA,UAAA,CAAA;KACV,KAAI;AACJ,SAAA,MAAA;AACH,SAAA,QAAA;KACD,KAAQ;AACA,iBAAE,WAAiB;AACf,WAAE,SACF,WAAU;AACV,WAAI,KAAC,YAAgB,KAAC;AAC9B,WAAA,KAAA,YAAA,YAAA;SACH,GAAA;AACO,aAAC,CAAA,EAAA;;KAEX;IACJ;;;AAEE,SAAO,WAAY;AACf,gBAAa,IAAC,MAAA;AAChB,iBAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"save-load.ce.js","names":[],"sources":["../../../src/components/gui/save-load.ce"],"sourcesContent":["<DOMContainer width=\"100%\" height=\"100%\">\n <div class=\"rpg-ui-save-load rpg-anim-fade-in\">\n <div class=\"rpg-ui-save-load-header\">\n <div class=\"rpg-ui-save-load-title\">{title()}</div>\n <div class=\"rpg-ui-save-load-subtitle\">{subtitle()}</div>\n </div>\n <Navigation tabindex={selectedSlot} controls={controls}>\n <div class=\"rpg-ui-save-load-list\">\n @for ((item,displayIndex) of displaySlots) {\n <div\n class=\"rpg-ui-save-load-slot\"\n class={{active: selectedSlot() === displayIndex}}\n tabindex={displayIndex}\n data-slot-index={displayIndex}\n click={selectSlot(displayIndex)}\n >\n <div class=\"rpg-ui-save-load-slot-index\">{item.label}</div>\n @if (item.slot) {\n <div class=\"rpg-ui-save-load-slot-meta\">\n <div class=\"rpg-ui-save-load-slot-line\">Level: {item.slot.level ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Exp: {item.slot.exp ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Map: {item.slot.map ?? \"-\"}</div>\n <div class=\"rpg-ui-save-load-slot-line\">Date: {item.slot.date ?? \"-\"}</div>\n </div>\n }\n @else {\n <div class=\"rpg-ui-save-load-slot-empty\">Empty Slot</div>\n }\n </div>\n }\n </div>\n </Navigation>\n </div>\n</DOMContainer>\n\n<script>\n import { signal, computed, effect, createTabindexNavigator, mount } from \"canvasengine\";\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { SaveClientService } from \"../../services/save\";\n import { PrebuiltGui } from \"@rpgjs/common\";\n import { RpgGui } from \"../../Gui/Gui\";\n import { getKeyboardControlBind } from \"../../services/actionInput\";\n\n const engine = inject(RpgClientEngine);\n const saveClient = inject(SaveClientService);\n const gui = inject(RpgGui);\n const keyboardControls = engine.globalConfig.keyboardControls;\n\n const selectedSlot = signal(0);\n const DEFAULT_SLOTS = 4;\n const defaultSlots = () => Array.from({ length: DEFAULT_SLOTS }, () => null);\n const localSlots = signal(defaultSlots());\n\n const { data, onFinish } = defineProps();\n\n const title = computed(() => data().mode === \"save\" ? \"Save Game\" : \"Load Game\");\n const subtitle = computed(() => data().mode === \"save\"\n ? \"Choose a slot to overwrite or create.\"\n : \"Select a slot to load your progress.\"\n );\n\n const slotsValue = computed(() => localSlots());\n const displaySlots = computed(() => {\n const slots = slotsValue();\n const items = slots.map((slot, index) => ({\n kind: \"slot\",\n slot,\n slotIndex: index,\n label: `Slot ${index + 1}`,\n readonly: false\n }));\n if (!data().showAutoSlot) return items;\n const index = typeof data().autoSlotIndex === \"number\" ? data().autoSlotIndex : 0;\n const autoSlot = slots[index] ?? null;\n const readonly = data().mode === \"save\";\n return [\n {\n kind: \"auto\",\n slot: autoSlot,\n slotIndex: index,\n label: data().autoSlotLabel || \"Auto Save\",\n readonly\n },\n ...items\n ];\n });\n const nav = createTabindexNavigator(selectedSlot, { count: () => displaySlots().length }, \"wrap\");\n\n const canSelect = (item) => {\n if (item.readonly) return false;\n if (data().mode === \"load\" && !item.slot) return false;\n return true;\n };\n\n const normalizeSlotValue = (value) => {\n if (!value) return null;\n if (typeof value === \"string\") {\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n }\n return value;\n };\n\n const normalizeSlots = (list) => {\n if (Array.isArray(list)) {\n const length = Math.max(list.length, DEFAULT_SLOTS);\n return Array.from({ length }, (_, index) => normalizeSlotValue(list[index]));\n }\n if (!list || typeof list !== \"object\") {\n return defaultSlots();\n }\n const keys = Object.keys(list).filter((key) => /^\\d+$/.test(key));\n const indices = keys.map((key) => Number(key)).filter((index) => index >= 0);\n const maxIndex = indices.length ? Math.max(...indices) : -1;\n const length = Math.max(maxIndex + 1, DEFAULT_SLOTS);\n const slots = Array.from({ length }, () => null);\n keys.forEach((key) => {\n const index = Number(key);\n if (index < 0 || index >= length) return;\n slots[index] = normalizeSlotValue(list[key]);\n });\n return slots;\n };\n\n const hasProvidedSlots = (list) => {\n if (Array.isArray(list)) return list.length > 0;\n return !!(list && typeof list === \"object\" && Object.keys(list).length > 0);\n };\n\n const refreshSlots = async () => {\n try {\n const list = await saveClient.listSlots();\n localSlots.set(normalizeSlots(list));\n } catch (err) {\n localSlots.set(defaultSlots());\n }\n };\n\n const triggerSelect = async (displayIndex) => {\n const list = displaySlots();\n const item = list[displayIndex];\n if (!item) return;\n if (!canSelect(item)) return;\n const action = data().mode === \"save\" ? \"save\" : \"load\";\n if (action === \"save\") {\n await saveClient.saveSlot(item.slotIndex);\n await refreshSlots();\n }\n if (action === \"load\") {\n await saveClient.loadSlot(item.slotIndex);\n }\n setTimeout(() => {\n if (onFinish) onFinish();\n gui.hide(PrebuiltGui.Save);\n gui.hide(PrebuiltGui.TitleScreen);\n }, 50);\n\n };\n\n function selectSlot(index) {\n return function() {\n selectedSlot.set(index);\n triggerSelect(index);\n }\n }\n\n const controls = signal({\n up: {\n repeat: true,\n bind: keyboardControls.up,\n throttle: 150,\n keyDown() {\n nav.next(-1);\n }\n },\n down: {\n repeat: true,\n bind: keyboardControls.down,\n throttle: 150,\n keyDown() {\n nav.next(1);\n }\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n triggerSelect(selectedSlot());\n }\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (onFinish) onFinish();\n gui.hide(PrebuiltGui.Save);\n }\n },\n gamepad: {\n enabled: true\n }\n });\n\n mount((element) => {\n refreshSlots();\n });\n</script>\n"],"mappings":";;;;;;;;AAcM,SAAS,UAAS,SAAO;CACX,SAAA,OAAA;CACZ,MAAM,cAAc,eAAe,OAAK;CACxC,MAAM,SAAS,OAAM,eAAW;CACxC,MAAM,aAAa,OAAO,iBAAiB;CAC3C,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,mBAAmB,OAAO,aAAY;CAC5C,MAAM,eAAe,OAAO,CAAC;CAC7B,MAAM,gBAAgB;CACtB,MAAM,qBAAqB,MAAM,KAAA,EAAA,QAAA,cAAA,SAAA,IAAA;CACjC,MAAM,aAAa,OAAK,aAAA,CAAA;CACxB,MAAM,EAAE,MAAM,aAAW,YAAK;CAC9B,MAAM,QAAQ,eAAe,KAAI,EAAA,SAAW,SAAQ,cAAgB,WAAW;CAC/E,MAAM,WAAW,eAAO,KAAA,EAAA,SAAA,SAClB,0CACA,sCAAU;CAChB,MAAM,aAAW,eAAA,WAAA,CAAA;CACjB,MAAM,eAAc,eAAA;EAChB,MAAK,QAAA,WAAA;EACP,MAAA,QAAY,MAAA,KAAA,MAAA,WAAA;;GAEP;GACH,WAAe;GACf,OAAS,QAAS,QAAS;GAC3B,UAAS;EACT,EAAA;EACA,IAAA,CAAA,KAAS,EAAA,cACT,OAAS;EACT,MAAM,QAA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