@rpgjs/client 5.0.0-alpha.43 → 5.0.0-alpha.44

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.
Files changed (137) hide show
  1. package/dist/Game/AnimationManager.js +25 -24
  2. package/dist/Game/AnimationManager.js.map +1 -1
  3. package/dist/Game/Event.js +11 -10
  4. package/dist/Game/Event.js.map +1 -1
  5. package/dist/Game/Map.js +78 -94
  6. package/dist/Game/Map.js.map +1 -1
  7. package/dist/Game/Object.js +182 -216
  8. package/dist/Game/Object.js.map +1 -1
  9. package/dist/Game/Player.js +11 -10
  10. package/dist/Game/Player.js.map +1 -1
  11. package/dist/Gui/Gui.js +440 -473
  12. package/dist/Gui/Gui.js.map +1 -1
  13. package/dist/Gui/NotificationManager.js +48 -50
  14. package/dist/Gui/NotificationManager.js.map +1 -1
  15. package/dist/Resource.js +132 -113
  16. package/dist/Resource.js.map +1 -1
  17. package/dist/RpgClientEngine.js +1333 -1486
  18. package/dist/RpgClientEngine.js.map +1 -1
  19. package/dist/Sound.js +162 -92
  20. package/dist/Sound.js.map +1 -1
  21. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.js +9 -0
  22. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.js +6 -0
  23. package/dist/components/animations/animation.ce.js +22 -19
  24. package/dist/components/animations/animation.ce.js.map +1 -1
  25. package/dist/components/animations/hit.ce.js +67 -68
  26. package/dist/components/animations/hit.ce.js.map +1 -1
  27. package/dist/components/animations/index.js +9 -8
  28. package/dist/components/animations/index.js.map +1 -1
  29. package/dist/components/character.ce.js +390 -314
  30. package/dist/components/character.ce.js.map +1 -1
  31. package/dist/components/dynamics/parse-value.js +42 -52
  32. package/dist/components/dynamics/parse-value.js.map +1 -1
  33. package/dist/components/dynamics/text.ce.js +71 -139
  34. package/dist/components/dynamics/text.ce.js.map +1 -1
  35. package/dist/components/gui/box.ce.js +26 -25
  36. package/dist/components/gui/box.ce.js.map +1 -1
  37. package/dist/components/gui/dialogbox/index.ce.js +202 -149
  38. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  39. package/dist/components/gui/gameover.ce.js +190 -138
  40. package/dist/components/gui/gameover.ce.js.map +1 -1
  41. package/dist/components/gui/hud/hud.ce.js +90 -33
  42. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  43. package/dist/components/gui/index.js +14 -0
  44. package/dist/components/gui/menu/equip-menu.ce.js +478 -346
  45. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  46. package/dist/components/gui/menu/exit-menu.ce.js +52 -33
  47. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  48. package/dist/components/gui/menu/items-menu.ce.js +341 -226
  49. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  50. package/dist/components/gui/menu/main-menu.ce.js +414 -205
  51. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  52. package/dist/components/gui/menu/options-menu.ce.js +46 -26
  53. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  54. package/dist/components/gui/menu/skills-menu.ce.js +104 -50
  55. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  56. package/dist/components/gui/mobile/index.js +18 -21
  57. package/dist/components/gui/mobile/index.js.map +1 -1
  58. package/dist/components/gui/mobile/mobile.ce.js +76 -15
  59. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  60. package/dist/components/gui/notification/notification.ce.js +62 -36
  61. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  62. package/dist/components/gui/save-load.ce.js +386 -239
  63. package/dist/components/gui/save-load.ce.js.map +1 -1
  64. package/dist/components/gui/shop/shop.ce.js +649 -319
  65. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  66. package/dist/components/gui/title-screen.ce.js +187 -145
  67. package/dist/components/gui/title-screen.ce.js.map +1 -1
  68. package/dist/components/index.js +4 -0
  69. package/dist/components/prebuilt/hp-bar.ce.js +114 -104
  70. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  71. package/dist/components/prebuilt/index.js +2 -0
  72. package/dist/components/prebuilt/light-halo.ce.js +92 -74
  73. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  74. package/dist/components/scenes/canvas.ce.js +58 -42
  75. package/dist/components/scenes/canvas.ce.js.map +1 -1
  76. package/dist/components/scenes/draw-map.ce.js +87 -64
  77. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  78. package/dist/components/scenes/event-layer.ce.js +26 -16
  79. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  80. package/dist/core/inject.js +11 -10
  81. package/dist/core/inject.js.map +1 -1
  82. package/dist/core/setup.js +13 -13
  83. package/dist/core/setup.js.map +1 -1
  84. package/dist/index.js +44 -41
  85. package/dist/module.js +169 -168
  86. package/dist/module.js.map +1 -1
  87. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js +209 -298
  88. package/dist/node_modules/.pnpm/@signe_di@2.8.3/node_modules/@signe/di/dist/index.js.map +1 -1
  89. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +430 -507
  90. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -1
  91. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js +2062 -2571
  92. package/dist/node_modules/.pnpm/@signe_room@2.8.3/node_modules/@signe/room/dist/index.js.map +1 -1
  93. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +8 -3
  94. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -1
  95. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js +78 -101
  96. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/client/index.js.map +1 -1
  97. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js +264 -401
  98. package/dist/node_modules/.pnpm/@signe_sync@2.8.3/node_modules/@signe/sync/dist/index.js.map +1 -1
  99. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +9 -7
  100. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -1
  101. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +106 -165
  102. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  103. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +361 -461
  104. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  105. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  106. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3633 -4280
  107. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  108. package/dist/presets/animation.js +37 -25
  109. package/dist/presets/animation.js.map +1 -1
  110. package/dist/presets/faceset.js +49 -22
  111. package/dist/presets/faceset.js.map +1 -1
  112. package/dist/presets/icon.js +13 -13
  113. package/dist/presets/icon.js.map +1 -1
  114. package/dist/presets/index.js +15 -14
  115. package/dist/presets/index.js.map +1 -1
  116. package/dist/presets/lpc.js +96 -93
  117. package/dist/presets/lpc.js.map +1 -1
  118. package/dist/presets/rmspritesheet.js +40 -39
  119. package/dist/presets/rmspritesheet.js.map +1 -1
  120. package/dist/services/AbstractSocket.js +10 -8
  121. package/dist/services/AbstractSocket.js.map +1 -1
  122. package/dist/services/keyboardControls.js +20 -18
  123. package/dist/services/keyboardControls.js.map +1 -1
  124. package/dist/services/loadMap.js +120 -36
  125. package/dist/services/loadMap.js.map +1 -1
  126. package/dist/services/mmorpg.js +128 -136
  127. package/dist/services/mmorpg.js.map +1 -1
  128. package/dist/services/save.js +74 -66
  129. package/dist/services/save.js.map +1 -1
  130. package/dist/services/standalone.js +165 -167
  131. package/dist/services/standalone.js.map +1 -1
  132. package/dist/utils/getEntityProp.js +49 -51
  133. package/dist/utils/getEntityProp.js.map +1 -1
  134. package/package.json +8 -8
  135. package/src/components/character.ce +1 -1
  136. package/src/components/scenes/draw-map.ce +3 -1
  137. package/dist/index.js.map +0 -1
@@ -1,242 +1,389 @@
1
- import { useProps, useDefineProps, signal, computed, createTabindexNavigator, mount, h, DOMContainer, DOMElement, Navigation, loop, cond } from 'canvasengine';
2
- import { inject } from '../../core/inject.js';
3
- import { RpgClientEngine } from '../../RpgClientEngine.js';
4
- import { SaveClientService } from '../../services/save.js';
5
- import { PrebuiltGui } from '@rpgjs/common';
6
- import { RpgGui } from '../../Gui/Gui.js';
7
-
1
+ import { inject } from "../../core/inject.js";
2
+ import { SaveClientService } from "../../services/save.js";
3
+ import { RpgGui } from "../../Gui/Gui.js";
4
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
5
+ import { DOMContainer, DOMElement, Navigation, computed, cond, createTabindexNavigator, h, loop, mount, signal, useDefineProps, useProps } from "canvasengine";
6
+ import { PrebuiltGui } from "@rpgjs/common";
7
+ //#region src/components/gui/save-load.ce
8
8
  function component($$props) {
9
- useProps($$props);
10
- const defineProps = useDefineProps($$props);
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- var __generator = (this && this.__generator) || function (thisArg, body) {
21
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
22
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
- function verb(n) { return function (v) { return step([n, v]); }; }
24
- function step(op) {
25
- if (f) throw new TypeError("Generator is already executing.");
26
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
27
- 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;
28
- if (y = 0, t) op = [op[0] & 2, t.value];
29
- switch (op[0]) {
30
- case 0: case 1: t = op; break;
31
- case 4: _.label++; return { value: op[1], done: false };
32
- case 5: _.label++; y = op[1]; op = [0]; continue;
33
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
34
- default:
35
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
36
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
37
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
38
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
39
- if (t[2]) _.ops.pop();
40
- _.trys.pop(); continue;
41
- }
42
- op = body.call(thisArg, _);
43
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
44
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
45
- }
46
- };
47
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
- if (ar || !(i in from)) {
50
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
51
- ar[i] = from[i];
52
- }
53
- }
54
- return to.concat(ar || Array.prototype.slice.call(from));
55
- };
56
- var engine = inject(RpgClientEngine);
57
- var saveClient = inject(SaveClientService);
58
- var gui = inject(RpgGui);
59
- var keyboardControls = engine.globalConfig.keyboardControls;
60
- var selectedSlot = signal(0);
61
- var DEFAULT_SLOTS = 4;
62
- var defaultSlots = function () { return Array.from({ length: DEFAULT_SLOTS }, function () { return null; }); };
63
- var localSlots = signal(defaultSlots());
64
- var _a = defineProps(), data = _a.data, onFinish = _a.onFinish;
65
- var title = computed(function () { return data().mode === "save" ? "Save Game" : "Load Game"; });
66
- var subtitle = computed(function () { return data().mode === "save"
67
- ? "Choose a slot to overwrite or create."
68
- : "Select a slot to load your progress."; });
69
- var slotsValue = computed(function () { return localSlots(); });
70
- var displaySlots = computed(function () {
71
- var _a;
72
- var slots = slotsValue();
73
- var items = slots.map(function (slot, index) { return ({
74
- kind: "slot",
75
- slot: slot,
76
- slotIndex: index,
77
- label: "Slot ".concat(index + 1),
78
- readonly: false
79
- }); });
80
- if (!data().showAutoSlot)
81
- return items;
82
- var index = typeof data().autoSlotIndex === "number" ? data().autoSlotIndex : 0;
83
- var autoSlot = (_a = slots[index]) !== null && _a !== void 0 ? _a : null;
84
- var readonly = data().mode === "save";
85
- return __spreadArray([
86
- {
87
- kind: "auto",
88
- slot: autoSlot,
89
- slotIndex: index,
90
- label: data().autoSlotLabel || "Auto Save",
91
- readonly: readonly
92
- }
93
- ], items, true);
94
- });
95
- var nav = createTabindexNavigator(selectedSlot, { count: function () { return displaySlots().length; } }, "wrap");
96
- var canSelect = function (item) {
97
- if (item.readonly)
98
- return false;
99
- if (data().mode === "load" && !item.slot)
100
- return false;
101
- return true;
102
- };
103
- var normalizeSlotValue = function (value) {
104
- if (!value)
105
- return null;
106
- if (typeof value === "string") {
107
- try {
108
- return JSON.parse(value);
109
- }
110
- catch (_a) {
111
- return null;
112
- }
113
- }
114
- return value;
115
- };
116
- var normalizeSlots = function (list) {
117
- if (Array.isArray(list)) {
118
- var length_1 = Math.max(list.length, DEFAULT_SLOTS);
119
- return Array.from({ length: length_1 }, function (_, index) { return normalizeSlotValue(list[index]); });
120
- }
121
- if (!list || typeof list !== "object") {
122
- return defaultSlots();
123
- }
124
- var keys = Object.keys(list).filter(function (key) { return /^\d+$/.test(key); });
125
- var indices = keys.map(function (key) { return Number(key); }).filter(function (index) { return index >= 0; });
126
- var maxIndex = indices.length ? Math.max.apply(Math, indices) : -1;
127
- var length = Math.max(maxIndex + 1, DEFAULT_SLOTS);
128
- var slots = Array.from({ length: length }, function () { return null; });
129
- keys.forEach(function (key) {
130
- var index = Number(key);
131
- if (index < 0 || index >= length)
132
- return;
133
- slots[index] = normalizeSlotValue(list[key]);
134
- });
135
- return slots;
136
- };
137
- var refreshSlots = function () { return __awaiter(void 0, void 0, void 0, function () {
138
- var list;
139
- return __generator(this, function (_a) {
140
- switch (_a.label) {
141
- case 0:
142
- _a.trys.push([0, 2, , 3]);
143
- return [4 /*yield*/, saveClient.listSlots()];
144
- case 1:
145
- list = _a.sent();
146
- localSlots.set(normalizeSlots(list));
147
- return [3 /*break*/, 3];
148
- case 2:
149
- _a.sent();
150
- localSlots.set(defaultSlots());
151
- return [3 /*break*/, 3];
152
- case 3: return [2 /*return*/];
153
- }
154
- });
155
- }); };
156
- var triggerSelect = function (displayIndex) { return __awaiter(void 0, void 0, void 0, function () {
157
- var list, item, action;
158
- return __generator(this, function (_a) {
159
- switch (_a.label) {
160
- case 0:
161
- list = displaySlots();
162
- item = list[displayIndex];
163
- if (!item)
164
- return [2 /*return*/];
165
- if (!canSelect(item))
166
- return [2 /*return*/];
167
- action = data().mode === "save" ? "save" : "load";
168
- if (!(action === "save")) return [3 /*break*/, 3];
169
- return [4 /*yield*/, saveClient.saveSlot(item.slotIndex)];
170
- case 1:
171
- _a.sent();
172
- return [4 /*yield*/, refreshSlots()];
173
- case 2:
174
- _a.sent();
175
- _a.label = 3;
176
- case 3:
177
- if (!(action === "load")) return [3 /*break*/, 5];
178
- return [4 /*yield*/, saveClient.loadSlot(item.slotIndex)];
179
- case 4:
180
- _a.sent();
181
- _a.label = 5;
182
- case 5:
183
- setTimeout(function () {
184
- if (onFinish)
185
- onFinish();
186
- gui.hide(PrebuiltGui.Save);
187
- gui.hide(PrebuiltGui.TitleScreen);
188
- }, 50);
189
- return [2 /*return*/];
190
- }
191
- });
192
- }); };
193
- function selectSlot(index) {
194
- return function () {
195
- selectedSlot.set(index);
196
- triggerSelect(index);
197
- };
9
+ useProps($$props);
10
+ const defineProps = useDefineProps($$props);
11
+ var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
12
+ function adopt(value) {
13
+ return value instanceof P ? value : new P(function(resolve) {
14
+ resolve(value);
15
+ });
16
+ }
17
+ return new (P || (P = Promise))(function(resolve, reject) {
18
+ function fulfilled(value) {
19
+ try {
20
+ step(generator.next(value));
21
+ } catch (e) {
22
+ reject(e);
23
+ }
24
+ }
25
+ function rejected(value) {
26
+ try {
27
+ step(generator["throw"](value));
28
+ } catch (e) {
29
+ reject(e);
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
+ });
161
+ if (!data().showAutoSlot) return items;
162
+ var index = typeof data().autoSlotIndex === "number" ? data().autoSlotIndex : 0;
163
+ var autoSlot = (_a = slots[index]) !== null && _a !== void 0 ? _a : null;
164
+ var readonly = data().mode === "save";
165
+ return __spreadArray([{
166
+ kind: "auto",
167
+ slot: autoSlot,
168
+ slotIndex: index,
169
+ label: data().autoSlotLabel || "Auto Save",
170
+ readonly
171
+ }], items, true);
172
+ });
173
+ var nav = createTabindexNavigator(selectedSlot, { count: function() {
174
+ return displaySlots().length;
175
+ } }, "wrap");
176
+ var canSelect = function(item) {
177
+ if (item.readonly) return false;
178
+ if (data().mode === "load" && !item.slot) return false;
179
+ return true;
180
+ };
181
+ var normalizeSlotValue = function(value) {
182
+ if (!value) return null;
183
+ if (typeof value === "string") try {
184
+ return JSON.parse(value);
185
+ } catch (_a) {
186
+ return null;
187
+ }
188
+ return value;
189
+ };
190
+ var normalizeSlots = function(list) {
191
+ if (Array.isArray(list)) {
192
+ var length_1 = Math.max(list.length, DEFAULT_SLOTS);
193
+ return Array.from({ length: length_1 }, function(_, index) {
194
+ return normalizeSlotValue(list[index]);
195
+ });
196
+ }
197
+ if (!list || typeof list !== "object") return defaultSlots();
198
+ var keys = Object.keys(list).filter(function(key) {
199
+ return /^\d+$/.test(key);
200
+ });
201
+ var indices = keys.map(function(key) {
202
+ return Number(key);
203
+ }).filter(function(index) {
204
+ return index >= 0;
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);
213
+ if (index < 0 || index >= length) return;
214
+ slots[index] = normalizeSlotValue(list[key]);
215
+ });
216
+ return slots;
217
+ };
218
+ var refreshSlots = function() {
219
+ return __awaiter(void 0, void 0, void 0, function() {
220
+ var list;
221
+ return __generator(this, function(_a) {
222
+ switch (_a.label) {
223
+ case 0:
224
+ _a.trys.push([
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
+ });
243
+ };
244
+ var triggerSelect = function(displayIndex) {
245
+ return __awaiter(void 0, void 0, void 0, function() {
246
+ var list, item, action;
247
+ return __generator(this, function(_a) {
248
+ switch (_a.label) {
249
+ case 0:
250
+ list = displaySlots();
251
+ item = list[displayIndex];
252
+ if (!item) return [2];
253
+ if (!canSelect(item)) return [2];
254
+ action = data().mode === "save" ? "save" : "load";
255
+ if (!(action === "save")) return [3, 3];
256
+ return [4, saveClient.saveSlot(item.slotIndex)];
257
+ case 1:
258
+ _a.sent();
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
+ });
279
+ };
280
+ function selectSlot(index) {
281
+ return function() {
282
+ selectedSlot.set(index);
283
+ triggerSelect(index);
284
+ };
285
+ }
286
+ var controls = signal({
287
+ up: {
288
+ repeat: true,
289
+ bind: keyboardControls.up,
290
+ throttle: 150,
291
+ keyDown: function() {
292
+ nav.next(-1);
293
+ }
294
+ },
295
+ down: {
296
+ repeat: true,
297
+ bind: keyboardControls.down,
298
+ throttle: 150,
299
+ keyDown: function() {
300
+ nav.next(1);
301
+ }
302
+ },
303
+ action: {
304
+ bind: keyboardControls.action,
305
+ keyDown: function() {
306
+ triggerSelect(selectedSlot());
307
+ }
308
+ },
309
+ escape: {
310
+ bind: keyboardControls.escape,
311
+ keyDown: function() {
312
+ if (onFinish) onFinish();
313
+ gui.hide(PrebuiltGui.Save);
314
+ }
315
+ },
316
+ gamepad: { enabled: true }
317
+ });
318
+ mount(function(element) {
319
+ refreshSlots();
320
+ });
321
+ return h(DOMContainer, {
322
+ width: "100%",
323
+ height: "100%"
324
+ }, h(DOMElement, {
325
+ element: "div",
326
+ attrs: { class: "rpg-ui-save-load rpg-anim-fade-in" }
327
+ }, [h(DOMElement, {
328
+ element: "div",
329
+ attrs: { class: "rpg-ui-save-load-header" }
330
+ }, [h(DOMElement, {
331
+ element: "div",
332
+ attrs: { class: "rpg-ui-save-load-title" },
333
+ textContent: computed(() => title())
334
+ }), h(DOMElement, {
335
+ element: "div",
336
+ attrs: { class: "rpg-ui-save-load-subtitle" },
337
+ textContent: computed(() => subtitle())
338
+ })]), h(Navigation, {
339
+ tabindex: selectedSlot,
340
+ controls
341
+ }, h(DOMElement, {
342
+ element: "div",
343
+ attrs: { class: "rpg-ui-save-load-list" }
344
+ }, loop(displaySlots, (item, displayIndex) => h(DOMElement, {
345
+ element: "div",
346
+ attrs: {
347
+ class: ["rpg-ui-save-load-slot", computed(() => ({ active: selectedSlot() === displayIndex }))],
348
+ tabindex: displayIndex,
349
+ "data-slot-index": displayIndex,
350
+ click: selectSlot(displayIndex)
351
+ }
352
+ }, [h(DOMElement, {
353
+ element: "div",
354
+ attrs: { class: "rpg-ui-save-load-slot-index" },
355
+ textContent: item.label
356
+ }), cond(item.slot, () => h(DOMElement, {
357
+ element: "div",
358
+ attrs: { class: "rpg-ui-save-load-slot-meta" }
359
+ }, [
360
+ h(DOMElement, {
361
+ element: "div",
362
+ attrs: { class: "rpg-ui-save-load-slot-line" },
363
+ textContent: "Level: " + item.slot.level
364
+ }),
365
+ h(DOMElement, {
366
+ element: "div",
367
+ attrs: { class: "rpg-ui-save-load-slot-line" },
368
+ textContent: "Exp: " + item.slot.exp
369
+ }),
370
+ h(DOMElement, {
371
+ element: "div",
372
+ attrs: { class: "rpg-ui-save-load-slot-line" },
373
+ textContent: "Map: " + item.slot.map
374
+ }),
375
+ h(DOMElement, {
376
+ element: "div",
377
+ attrs: { class: "rpg-ui-save-load-slot-line" },
378
+ textContent: "Date: " + item.slot.date
379
+ })
380
+ ]), () => h(DOMElement, {
381
+ element: "div",
382
+ attrs: { class: "rpg-ui-save-load-slot-empty" },
383
+ textContent: "Empty Slot"
384
+ }))]))))]));
198
385
  }
199
- var controls = signal({
200
- up: {
201
- repeat: true,
202
- bind: keyboardControls.up,
203
- throttle: 150,
204
- keyDown: function () {
205
- nav.next(-1);
206
- }
207
- },
208
- down: {
209
- repeat: true,
210
- bind: keyboardControls.down,
211
- throttle: 150,
212
- keyDown: function () {
213
- nav.next(1);
214
- }
215
- },
216
- action: {
217
- bind: keyboardControls.action,
218
- keyDown: function () {
219
- triggerSelect(selectedSlot());
220
- }
221
- },
222
- escape: {
223
- bind: keyboardControls.escape,
224
- keyDown: function () {
225
- if (onFinish)
226
- onFinish();
227
- gui.hide(PrebuiltGui.Save);
228
- }
229
- },
230
- gamepad: {
231
- enabled: true
232
- }
233
- });
234
- mount(function (element) {
235
- refreshSlots();
236
- });
237
- let $this = h(DOMContainer, { width: '100%', height: '100%' }, h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load rpg-anim-fade-in' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-header' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-title' }, textContent: computed(() => title()) }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-subtitle' }, textContent: computed(() => subtitle()) })]), h(Navigation, { tabindex: selectedSlot, controls: controls }, h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-list' } }, loop(displaySlots, (item, displayIndex) => h(DOMElement, { element: "div", attrs: { class: ['rpg-ui-save-load-slot', computed(() => ({ active: selectedSlot() === displayIndex }))], tabindex: displayIndex, 'data-slot-index': displayIndex, click: selectSlot(displayIndex) } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-index' }, textContent: item.label }), cond(item.slot, () => h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-meta' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-line' }, textContent: 'Level: ' + item.slot.level ?? "-" }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-line' }, textContent: 'Exp: ' + item.slot.exp ?? "-" }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-line' }, textContent: 'Map: ' + item.slot.map ?? "-" }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-line' }, textContent: 'Date: ' + item.slot.date ?? "-" })]), () => h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-save-load-slot-empty' }, textContent: 'Empty Slot' }))]))))]));
238
- return $this
239
- }
240
-
386
+ //#endregion
241
387
  export { component as default };
242
- //# sourceMappingURL=save-load.ce.js.map
388
+
389
+ //# sourceMappingURL=save-load.ce.js.map