@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.10
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 +37 -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/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 +57 -2
- package/dist/RpgClientEngine.d.ts +61 -6
- package/dist/RpgClientEngine.js +122 -14
- 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 +406 -226
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/bar.ce.js +96 -0
- package/dist/components/dynamics/bar.ce.js.map +1 -0
- package/dist/components/dynamics/image.ce.js +23 -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 +83 -0
- package/dist/components/dynamics/shape.ce.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +33 -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 +53 -60
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +39 -63
- 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 +110 -164
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +6 -5
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +49 -67
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +72 -90
- 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 +70 -248
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +87 -125
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +42 -68
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- 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 +188 -0
- package/dist/components/player-components.ce.js.map +1 -0
- package/dist/components/prebuilt/hp-bar.ce.js +41 -44
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +35 -59
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +157 -21
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +19 -29
- 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 +1 -0
- package/dist/index.js +21 -20
- package/dist/module.js +4 -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/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.js +9 -4
- package/dist/services/mmorpg.js.map +1 -1
- package/dist/services/save.js.map +1 -1
- package/dist/services/save.spec.d.ts +1 -0
- package/dist/services/standalone.js +1 -1
- package/dist/services/standalone.js.map +1 -1
- 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/Gui/Gui.spec.ts +273 -0
- package/src/Gui/Gui.ts +105 -50
- package/src/Resource.ts +1 -2
- package/src/RpgClient.ts +63 -2
- package/src/RpgClientEngine.ts +173 -25
- package/src/components/character.ce +422 -15
- package/src/components/dynamics/bar.ce +87 -0
- package/src/components/dynamics/image.ce +20 -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 +89 -0
- package/src/components/dynamics/text.ce +34 -149
- package/src/components/gui/dialogbox/index.ce +15 -6
- 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 +221 -0
- package/src/components/scenes/canvas.ce +165 -6
- package/src/components/scenes/draw-map.ce +2 -15
- 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 +1 -0
- package/src/module.ts +5 -1
- package/src/services/loadMap.ts +2 -0
- package/src/services/mmorpg.ts +8 -2
- package/src/services/save.spec.ts +127 -0
- 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
|
@@ -8,274 +8,95 @@ import { PrebuiltGui } from "@rpgjs/common";
|
|
|
8
8
|
function component($$props) {
|
|
9
9
|
useProps($$props);
|
|
10
10
|
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
|
-
});
|
|
11
|
+
const engine = inject(RpgClientEngine);
|
|
12
|
+
const saveClient = inject(SaveClientService);
|
|
13
|
+
const gui = inject(RpgGui);
|
|
14
|
+
const keyboardControls = engine.globalConfig.keyboardControls;
|
|
15
|
+
const selectedSlot = signal(0);
|
|
16
|
+
const DEFAULT_SLOTS = 4;
|
|
17
|
+
const defaultSlots = () => Array.from({ length: DEFAULT_SLOTS }, () => null);
|
|
18
|
+
const localSlots = signal(defaultSlots());
|
|
19
|
+
const { data, onFinish } = defineProps();
|
|
20
|
+
const title = computed(() => data().mode === "save" ? "Save Game" : "Load Game");
|
|
21
|
+
const subtitle = computed(() => data().mode === "save" ? "Choose a slot to overwrite or create." : "Select a slot to load your progress.");
|
|
22
|
+
const slotsValue = computed(() => localSlots());
|
|
23
|
+
const displaySlots = computed(() => {
|
|
24
|
+
const slots = slotsValue();
|
|
25
|
+
const items = slots.map((slot, index) => ({
|
|
26
|
+
kind: "slot",
|
|
27
|
+
slot,
|
|
28
|
+
slotIndex: index,
|
|
29
|
+
label: `Slot ${index + 1}`,
|
|
30
|
+
readonly: false
|
|
31
|
+
}));
|
|
161
32
|
if (!data().showAutoSlot) return items;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return
|
|
33
|
+
const index = typeof data().autoSlotIndex === "number" ? data().autoSlotIndex : 0;
|
|
34
|
+
const autoSlot = slots[index] ?? null;
|
|
35
|
+
const readonly = data().mode === "save";
|
|
36
|
+
return [{
|
|
166
37
|
kind: "auto",
|
|
167
38
|
slot: autoSlot,
|
|
168
39
|
slotIndex: index,
|
|
169
40
|
label: data().autoSlotLabel || "Auto Save",
|
|
170
41
|
readonly
|
|
171
|
-
}
|
|
42
|
+
}, ...items];
|
|
172
43
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
} }, "wrap");
|
|
176
|
-
var canSelect = function(item) {
|
|
44
|
+
const nav = createTabindexNavigator(selectedSlot, { count: () => displaySlots().length }, "wrap");
|
|
45
|
+
const canSelect = (item) => {
|
|
177
46
|
if (item.readonly) return false;
|
|
178
47
|
if (data().mode === "load" && !item.slot) return false;
|
|
179
48
|
return true;
|
|
180
49
|
};
|
|
181
|
-
|
|
50
|
+
const normalizeSlotValue = (value) => {
|
|
182
51
|
if (!value) return null;
|
|
183
52
|
if (typeof value === "string") try {
|
|
184
53
|
return JSON.parse(value);
|
|
185
|
-
} catch
|
|
54
|
+
} catch {
|
|
186
55
|
return null;
|
|
187
56
|
}
|
|
188
57
|
return value;
|
|
189
58
|
};
|
|
190
|
-
|
|
59
|
+
const normalizeSlots = (list) => {
|
|
191
60
|
if (Array.isArray(list)) {
|
|
192
|
-
|
|
193
|
-
return Array.from({ length
|
|
194
|
-
return normalizeSlotValue(list[index]);
|
|
195
|
-
});
|
|
61
|
+
const length = Math.max(list.length, DEFAULT_SLOTS);
|
|
62
|
+
return Array.from({ length }, (_, index) => normalizeSlotValue(list[index]));
|
|
196
63
|
}
|
|
197
64
|
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);
|
|
65
|
+
const keys = Object.keys(list).filter((key) => /^\d+$/.test(key));
|
|
66
|
+
const indices = keys.map((key) => Number(key)).filter((index) => index >= 0);
|
|
67
|
+
const maxIndex = indices.length ? Math.max(...indices) : -1;
|
|
68
|
+
const length = Math.max(maxIndex + 1, DEFAULT_SLOTS);
|
|
69
|
+
const slots = Array.from({ length }, () => null);
|
|
70
|
+
keys.forEach((key) => {
|
|
71
|
+
const index = Number(key);
|
|
213
72
|
if (index < 0 || index >= length) return;
|
|
214
73
|
slots[index] = normalizeSlotValue(list[key]);
|
|
215
74
|
});
|
|
216
75
|
return slots;
|
|
217
76
|
};
|
|
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
|
-
});
|
|
77
|
+
const refreshSlots = async () => {
|
|
78
|
+
try {
|
|
79
|
+
const list = await saveClient.listSlots();
|
|
80
|
+
localSlots.set(normalizeSlots(list));
|
|
81
|
+
} catch (err) {
|
|
82
|
+
localSlots.set(defaultSlots());
|
|
83
|
+
}
|
|
243
84
|
};
|
|
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
|
-
});
|
|
85
|
+
const triggerSelect = async (displayIndex) => {
|
|
86
|
+
const item = displaySlots()[displayIndex];
|
|
87
|
+
if (!item) return;
|
|
88
|
+
if (!canSelect(item)) return;
|
|
89
|
+
const action = data().mode === "save" ? "save" : "load";
|
|
90
|
+
if (action === "save") {
|
|
91
|
+
await saveClient.saveSlot(item.slotIndex);
|
|
92
|
+
await refreshSlots();
|
|
93
|
+
}
|
|
94
|
+
if (action === "load") await saveClient.loadSlot(item.slotIndex);
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
if (onFinish) onFinish();
|
|
97
|
+
gui.hide(PrebuiltGui.Save);
|
|
98
|
+
gui.hide(PrebuiltGui.TitleScreen);
|
|
99
|
+
}, 50);
|
|
279
100
|
};
|
|
280
101
|
function selectSlot(index) {
|
|
281
102
|
return function() {
|
|
@@ -283,12 +104,12 @@ function component($$props) {
|
|
|
283
104
|
triggerSelect(index);
|
|
284
105
|
};
|
|
285
106
|
}
|
|
286
|
-
|
|
107
|
+
const controls = signal({
|
|
287
108
|
up: {
|
|
288
109
|
repeat: true,
|
|
289
110
|
bind: keyboardControls.up,
|
|
290
111
|
throttle: 150,
|
|
291
|
-
keyDown
|
|
112
|
+
keyDown() {
|
|
292
113
|
nav.next(-1);
|
|
293
114
|
}
|
|
294
115
|
},
|
|
@@ -296,26 +117,26 @@ function component($$props) {
|
|
|
296
117
|
repeat: true,
|
|
297
118
|
bind: keyboardControls.down,
|
|
298
119
|
throttle: 150,
|
|
299
|
-
keyDown
|
|
120
|
+
keyDown() {
|
|
300
121
|
nav.next(1);
|
|
301
122
|
}
|
|
302
123
|
},
|
|
303
124
|
action: {
|
|
304
125
|
bind: keyboardControls.action,
|
|
305
|
-
keyDown
|
|
126
|
+
keyDown() {
|
|
306
127
|
triggerSelect(selectedSlot());
|
|
307
128
|
}
|
|
308
129
|
},
|
|
309
130
|
escape: {
|
|
310
131
|
bind: keyboardControls.escape,
|
|
311
|
-
keyDown
|
|
132
|
+
keyDown() {
|
|
312
133
|
if (onFinish) onFinish();
|
|
313
134
|
gui.hide(PrebuiltGui.Save);
|
|
314
135
|
}
|
|
315
136
|
},
|
|
316
137
|
gamepad: { enabled: true }
|
|
317
138
|
});
|
|
318
|
-
mount(
|
|
139
|
+
mount((element) => {
|
|
319
140
|
refreshSlots();
|
|
320
141
|
});
|
|
321
142
|
return h(DOMContainer, {
|
|
@@ -383,7 +204,8 @@ function component($$props) {
|
|
|
383
204
|
textContent: "Empty Slot"
|
|
384
205
|
}))]))))]));
|
|
385
206
|
}
|
|
207
|
+
var __ce_component = component;
|
|
386
208
|
//#endregion
|
|
387
|
-
export {
|
|
209
|
+
export { __ce_component as default };
|
|
388
210
|
|
|
389
211
|
//# 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.esc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ACJ,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\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.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