@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,349 +1,481 @@
1
- import { useProps, useDefineProps, signal, computed, effect, createTabindexNavigator, h, DOMContainer, DOMElement, DOMSprite, cond, loop, Navigation } from 'canvasengine';
2
- import { inject } from '../../../core/inject.js';
3
- import { RpgClientEngine } from '../../../RpgClientEngine.js';
4
-
1
+ import { inject } from "../../../core/inject.js";
2
+ import { RpgClientEngine } from "../../../RpgClientEngine.js";
3
+ import { DOMContainer, DOMElement, DOMSprite, Navigation, computed, cond, createTabindexNavigator, effect, h, loop, signal, useDefineProps, useProps } from "canvasengine";
4
+ //#region src/components/gui/menu/equip-menu.ce
5
5
  function component($$props) {
6
- useProps($$props);
7
- const defineProps = useDefineProps($$props);
8
- var __assign = (this && this.__assign) || function () {
9
- __assign = Object.assign || function(t) {
10
- for (var s, i = 1, n = arguments.length; i < n; i++) {
11
- s = arguments[i];
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13
- t[p] = s[p];
14
- }
15
- return t;
16
- };
17
- return __assign.apply(this, arguments);
18
- };
19
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21
- if (ar || !(i in from)) {
22
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
23
- ar[i] = from[i];
24
- }
25
- }
26
- return to.concat(ar || Array.prototype.slice.call(from));
27
- };
28
- var engine = inject(RpgClientEngine);
29
- var keyboardControls = engine.globalConfig.keyboardControls;
30
- var currentPlayer = engine.scene.currentPlayer;
31
- var selectedTab = signal(0);
32
- var selectedItem = signal(0);
33
- var _a = defineProps(), data = _a.data, onInteraction = _a.onInteraction, onBack = _a.onBack;
34
- var equips = computed(function () { var _a; return (_a = data().equips) !== null && _a !== void 0 ? _a : data().items; });
35
- var slots = computed(function () { return data().slots; });
36
- var defaultSlots = [
37
- { id: "weapon", label: "Weapon", types: ["weapon"] },
38
- { id: "armor", label: "Armor", types: ["armor"] }
39
- ];
40
- var resolveProp = function (value) { return typeof value === "function" ? value() : value; };
41
- var safeEquips = computed(function () {
42
- var list = resolveProp(equips);
43
- return Array.isArray(list) ? list : [];
44
- });
45
- var slotList = computed(function () {
46
- var list = resolveProp(slots);
47
- if (Array.isArray(list) && list.length)
48
- return list;
49
- return defaultSlots;
50
- });
51
- var currentSlot = computed(function () { return slotList()[selectedTab()]; });
52
- var equippedIds = computed(function () {
53
- var _a, _b;
54
- var equipped = ((_b = (_a = currentPlayer()).equipments) === null || _b === void 0 ? void 0 : _b.call(_a)) || [];
55
- return new Set(equipped.map(function (it) { var _a, _b, _c; return (_c = (_b = (_a = it === null || it === void 0 ? void 0 : it.id) === null || _a === void 0 ? void 0 : _a.call(it)) !== null && _b !== void 0 ? _b : it === null || it === void 0 ? void 0 : it.id) !== null && _c !== void 0 ? _c : it === null || it === void 0 ? void 0 : it.name; }));
56
- });
57
- var equippedOverrides = signal({});
58
- effect(function () {
59
- var next = {};
60
- safeEquips().forEach(function (item) {
61
- if ((item === null || item === void 0 ? void 0 : item.id) && typeof item.equipped === "boolean") {
62
- next[item.id] = item.equipped;
63
- }
64
- });
65
- equippedOverrides.set(next);
66
- });
67
- var itemEquipped = function (item) {
68
- if (!item)
69
- return false;
70
- var overrides = equippedOverrides();
71
- if (Object.prototype.hasOwnProperty.call(overrides, item.id)) {
72
- return overrides[item.id];
73
- }
74
- if (typeof item.equipped === "boolean")
75
- return item.equipped;
76
- return equippedIds().has(item.id);
77
- };
78
- var slotTypes = function (slot) {
79
- if (!slot)
80
- return [];
81
- if (Array.isArray(slot.types))
82
- return slot.types;
83
- if (slot.type)
84
- return [slot.type];
85
- if (slot.id)
86
- return [slot.id];
87
- return [];
88
- };
89
- var slotItems = computed(function () {
90
- var slot = currentSlot();
91
- if (!slot)
92
- return [];
93
- var types = new Set(slotTypes(slot));
94
- return safeEquips().filter(function (item) { return item && types.has(item.type); });
95
- });
96
- var currentEquippedItem = computed(function () {
97
- var list = slotItems();
98
- return list.find(function (item) { return itemEquipped(item); }) || null;
99
- });
100
- var listEntries = computed(function () {
101
- var items = slotItems().map(function (item) { return (__assign(__assign({}, item), { kind: "item", tag: itemEquipped(item) ? "Equipped" : "" })); });
102
- var equipped = currentEquippedItem();
103
- if (!equipped)
104
- return items;
105
- return __spreadArray([
106
- {
107
- id: "__unequip__",
108
- name: "Unequip",
109
- description: "Remove the current equipment",
110
- kind: "unequip",
111
- tag: ""
112
- }
113
- ], items, true);
114
- });
115
- var currentEntry = computed(function () { return listEntries()[selectedItem()]; });
116
- var detailsItem = computed(function () {
117
- var entry = currentEntry();
118
- if ((entry === null || entry === void 0 ? void 0 : entry.kind) === "item")
119
- return entry;
120
- return currentEquippedItem();
121
- });
122
- var equippedText = computed(function () {
123
- var slot = currentSlot();
124
- if (!slot)
125
- return "";
126
- var equipped = currentEquippedItem();
127
- return equipped ? "".concat(slot.label, ": ").concat(equipped.name) : "".concat(slot.label, ": Empty");
128
- });
129
- computed(function () { return listEntries().length === 0; });
130
- var nav = createTabindexNavigator(selectedItem, { count: function () { return listEntries().length; } }, "wrap");
131
- var playerParams = computed(function () {
132
- var _a, _b;
133
- var menuData = data();
134
- if (menuData === null || menuData === void 0 ? void 0 : menuData.playerStats)
135
- return menuData.playerStats;
136
- if (menuData === null || menuData === void 0 ? void 0 : menuData.playerParams)
137
- return menuData.playerParams;
138
- return ((_b = (_a = currentPlayer()) === null || _a === void 0 ? void 0 : _a._param) === null || _b === void 0 ? void 0 : _b.call(_a)) || {};
139
- });
140
- var statOrder = ["atk", "def", "pdef", "sdef", "str", "dex", "int", "agi", "maxHp", "maxSp"];
141
- var statLabels = {
142
- atk: "ATK",
143
- def: "DEF",
144
- pdef: "PDEF",
145
- sdef: "SDEF",
146
- str: "STR",
147
- dex: "DEX",
148
- int: "INT",
149
- agi: "AGI",
150
- maxHp: "MAX HP",
151
- maxSp: "MAX SP"
152
- };
153
- var getItemStats = function (item) {
154
- if (!item)
155
- return {};
156
- var stats = item.stats || item.params || {};
157
- if (Object.keys(stats).length)
158
- return stats;
159
- var keys = ["atk", "def", "pdef", "sdef", "str", "dex", "int", "agi", "maxHp", "maxSp"];
160
- var direct = {};
161
- keys.forEach(function (key) {
162
- if (item[key] !== undefined)
163
- direct[key] = item[key];
164
- });
165
- return direct;
166
- };
167
- var buildStatsList = function (deltaStats) {
168
- var params = playerParams() || {};
169
- var orderedKeys = statOrder.filter(function (key) { return deltaStats[key] !== undefined; });
170
- var extraKeys = Object.keys(deltaStats).filter(function (key) { return !statOrder.includes(key); });
171
- var keys = orderedKeys.concat(extraKeys);
172
- var list = [];
173
- for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
174
- var key = keys_1[_i];
175
- var delta = deltaStats[key];
176
- if (delta === undefined || delta === 0)
177
- continue;
178
- var current = params[key];
179
- if (current === undefined && key === "def")
180
- current = params.pdef;
181
- var next = current !== undefined ? current + delta : undefined;
182
- list.push({
183
- key: key,
184
- label: statLabels[key] || key.toUpperCase(),
185
- delta: delta,
186
- current: current,
187
- next: next
188
- });
189
- }
190
- return list;
191
- };
192
- var displayStats = computed(function () {
193
- var entry = currentEntry();
194
- var equipped = currentEquippedItem();
195
- if (!entry)
196
- return [];
197
- if (entry.kind === "unequip") {
198
- if (!equipped)
199
- return [];
200
- var stats_1 = getItemStats(equipped);
201
- var delta_1 = {};
202
- Object.keys(stats_1).forEach(function (key) {
203
- delta_1[key] = -stats_1[key];
204
- });
205
- return buildStatsList(delta_1);
206
- }
207
- if (entry.kind === "item") {
208
- var equippedStats_1 = getItemStats(equipped);
209
- var nextStats_1 = getItemStats(entry);
210
- var delta_2 = {};
211
- var keys = new Set(__spreadArray(__spreadArray([], Object.keys(nextStats_1), true), Object.keys(equippedStats_1), true));
212
- keys.forEach(function (key) {
213
- delta_2[key] = (nextStats_1[key] || 0) - (equippedStats_1[key] || 0);
214
- });
215
- return buildStatsList(delta_2);
216
- }
217
- return [];
218
- });
219
- var applyEquipState = function (slot, itemId, equip) {
220
- var types = slotTypes(slot);
221
- var next = __assign({}, equippedOverrides());
222
- if (types.length) {
223
- safeEquips().forEach(function (item) {
224
- if (!item)
225
- return;
226
- if (types.includes(item.type)) {
227
- next[item.id] = false;
228
- }
229
- });
230
- }
231
- if (itemId) {
232
- next[itemId] = equip;
233
- }
234
- equippedOverrides.set(next);
235
- };
236
- var commitSelection = function (index) {
237
- var entry = listEntries()[index];
238
- if (!entry)
239
- return;
240
- if (entry.kind === "unequip") {
241
- var equipped = currentEquippedItem();
242
- if (equipped && onInteraction) {
243
- onInteraction("equipItem", { id: equipped.id, equip: false });
244
- }
245
- applyEquipState(currentSlot(), equipped === null || equipped === void 0 ? void 0 : equipped.id, false);
246
- return;
247
- }
248
- if (entry.kind === "item" && onInteraction) {
249
- if (!itemEquipped(entry)) {
250
- onInteraction("equipItem", { id: entry.id, equip: true });
251
- }
252
- applyEquipState(currentSlot(), entry.id, true);
253
- }
254
- };
255
- function selectTab(index) {
256
- return function () {
257
- selectedTab.set(index);
258
- selectedItem.set(0);
259
- };
260
- }
261
- function selectItem(index) {
262
- return function () {
263
- selectedItem.set(index);
264
- commitSelection(index);
265
- };
6
+ useProps($$props);
7
+ const defineProps = useDefineProps($$props);
8
+ var __assign = this && this.__assign || function() {
9
+ __assign = Object.assign || function(t) {
10
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
11
+ s = arguments[i];
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
13
+ }
14
+ return t;
15
+ };
16
+ return __assign.apply(this, arguments);
17
+ };
18
+ var __spreadArray = this && this.__spreadArray || function(to, from, pack) {
19
+ if (pack || arguments.length === 2) {
20
+ for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var engine = inject(RpgClientEngine);
28
+ var keyboardControls = engine.globalConfig.keyboardControls;
29
+ var currentPlayer = engine.scene.currentPlayer;
30
+ var selectedTab = signal(0);
31
+ var selectedItem = signal(0);
32
+ var _a = defineProps(), data = _a.data, onInteraction = _a.onInteraction, onBack = _a.onBack;
33
+ var equips = computed(function() {
34
+ var _a;
35
+ return (_a = data().equips) !== null && _a !== void 0 ? _a : data().items;
36
+ });
37
+ var slots = computed(function() {
38
+ return data().slots;
39
+ });
40
+ var defaultSlots = [{
41
+ id: "weapon",
42
+ label: "Weapon",
43
+ types: ["weapon"]
44
+ }, {
45
+ id: "armor",
46
+ label: "Armor",
47
+ types: ["armor"]
48
+ }];
49
+ var resolveProp = function(value) {
50
+ return typeof value === "function" ? value() : value;
51
+ };
52
+ var safeEquips = computed(function() {
53
+ var list = resolveProp(equips);
54
+ return Array.isArray(list) ? list : [];
55
+ });
56
+ var slotList = computed(function() {
57
+ var list = resolveProp(slots);
58
+ if (Array.isArray(list) && list.length) return list;
59
+ return defaultSlots;
60
+ });
61
+ var currentSlot = computed(function() {
62
+ return slotList()[selectedTab()];
63
+ });
64
+ var equippedIds = computed(function() {
65
+ var _a, _b;
66
+ var equipped = ((_b = (_a = currentPlayer()).equipments) === null || _b === void 0 ? void 0 : _b.call(_a)) || [];
67
+ return new Set(equipped.map(function(it) {
68
+ var _a, _b, _c;
69
+ return (_c = (_b = (_a = it === null || it === void 0 ? void 0 : it.id) === null || _a === void 0 ? void 0 : _a.call(it)) !== null && _b !== void 0 ? _b : it === null || it === void 0 ? void 0 : it.id) !== null && _c !== void 0 ? _c : it === null || it === void 0 ? void 0 : it.name;
70
+ }));
71
+ });
72
+ var equippedOverrides = signal({});
73
+ effect(function() {
74
+ var next = {};
75
+ safeEquips().forEach(function(item) {
76
+ if ((item === null || item === void 0 ? void 0 : item.id) && typeof item.equipped === "boolean") next[item.id] = item.equipped;
77
+ });
78
+ equippedOverrides.set(next);
79
+ });
80
+ var itemEquipped = function(item) {
81
+ if (!item) return false;
82
+ var overrides = equippedOverrides();
83
+ if (Object.prototype.hasOwnProperty.call(overrides, item.id)) return overrides[item.id];
84
+ if (typeof item.equipped === "boolean") return item.equipped;
85
+ return equippedIds().has(item.id);
86
+ };
87
+ var slotTypes = function(slot) {
88
+ if (!slot) return [];
89
+ if (Array.isArray(slot.types)) return slot.types;
90
+ if (slot.type) return [slot.type];
91
+ if (slot.id) return [slot.id];
92
+ return [];
93
+ };
94
+ var slotItems = computed(function() {
95
+ var slot = currentSlot();
96
+ if (!slot) return [];
97
+ var types = new Set(slotTypes(slot));
98
+ return safeEquips().filter(function(item) {
99
+ return item && types.has(item.type);
100
+ });
101
+ });
102
+ var currentEquippedItem = computed(function() {
103
+ return slotItems().find(function(item) {
104
+ return itemEquipped(item);
105
+ }) || null;
106
+ });
107
+ var listEntries = computed(function() {
108
+ var items = slotItems().map(function(item) {
109
+ return __assign(__assign({}, item), {
110
+ kind: "item",
111
+ tag: itemEquipped(item) ? "Equipped" : ""
112
+ });
113
+ });
114
+ if (!currentEquippedItem()) return items;
115
+ return __spreadArray([{
116
+ id: "__unequip__",
117
+ name: "Unequip",
118
+ description: "Remove the current equipment",
119
+ kind: "unequip",
120
+ tag: ""
121
+ }], items, true);
122
+ });
123
+ var currentEntry = computed(function() {
124
+ return listEntries()[selectedItem()];
125
+ });
126
+ var detailsItem = computed(function() {
127
+ var entry = currentEntry();
128
+ if ((entry === null || entry === void 0 ? void 0 : entry.kind) === "item") return entry;
129
+ return currentEquippedItem();
130
+ });
131
+ var equippedText = computed(function() {
132
+ var slot = currentSlot();
133
+ if (!slot) return "";
134
+ var equipped = currentEquippedItem();
135
+ return equipped ? "".concat(slot.label, ": ").concat(equipped.name) : "".concat(slot.label, ": Empty");
136
+ });
137
+ computed(function() {
138
+ return listEntries().length === 0;
139
+ });
140
+ var nav = createTabindexNavigator(selectedItem, { count: function() {
141
+ return listEntries().length;
142
+ } }, "wrap");
143
+ var playerParams = computed(function() {
144
+ var _a, _b;
145
+ var menuData = data();
146
+ if (menuData === null || menuData === void 0 ? void 0 : menuData.playerStats) return menuData.playerStats;
147
+ if (menuData === null || menuData === void 0 ? void 0 : menuData.playerParams) return menuData.playerParams;
148
+ return ((_b = (_a = currentPlayer()) === null || _a === void 0 ? void 0 : _a._param) === null || _b === void 0 ? void 0 : _b.call(_a)) || {};
149
+ });
150
+ var statOrder = [
151
+ "atk",
152
+ "def",
153
+ "pdef",
154
+ "sdef",
155
+ "str",
156
+ "dex",
157
+ "int",
158
+ "agi",
159
+ "maxHp",
160
+ "maxSp"
161
+ ];
162
+ var statLabels = {
163
+ atk: "ATK",
164
+ def: "DEF",
165
+ pdef: "PDEF",
166
+ sdef: "SDEF",
167
+ str: "STR",
168
+ dex: "DEX",
169
+ int: "INT",
170
+ agi: "AGI",
171
+ maxHp: "MAX HP",
172
+ maxSp: "MAX SP"
173
+ };
174
+ var getItemStats = function(item) {
175
+ if (!item) return {};
176
+ var stats = item.stats || item.params || {};
177
+ if (Object.keys(stats).length) return stats;
178
+ var keys = [
179
+ "atk",
180
+ "def",
181
+ "pdef",
182
+ "sdef",
183
+ "str",
184
+ "dex",
185
+ "int",
186
+ "agi",
187
+ "maxHp",
188
+ "maxSp"
189
+ ];
190
+ var direct = {};
191
+ keys.forEach(function(key) {
192
+ if (item[key] !== void 0) direct[key] = item[key];
193
+ });
194
+ return direct;
195
+ };
196
+ var buildStatsList = function(deltaStats) {
197
+ var params = playerParams() || {};
198
+ var orderedKeys = statOrder.filter(function(key) {
199
+ return deltaStats[key] !== void 0;
200
+ });
201
+ var extraKeys = Object.keys(deltaStats).filter(function(key) {
202
+ return !statOrder.includes(key);
203
+ });
204
+ var keys = orderedKeys.concat(extraKeys);
205
+ var list = [];
206
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
207
+ var key = keys_1[_i];
208
+ var delta = deltaStats[key];
209
+ if (delta === void 0 || delta === 0) continue;
210
+ var current = params[key];
211
+ if (current === void 0 && key === "def") current = params.pdef;
212
+ var next = current !== void 0 ? current + delta : void 0;
213
+ list.push({
214
+ key,
215
+ label: statLabels[key] || key.toUpperCase(),
216
+ delta,
217
+ current,
218
+ next
219
+ });
220
+ }
221
+ return list;
222
+ };
223
+ var displayStats = computed(function() {
224
+ var entry = currentEntry();
225
+ var equipped = currentEquippedItem();
226
+ if (!entry) return [];
227
+ if (entry.kind === "unequip") {
228
+ if (!equipped) return [];
229
+ var stats_1 = getItemStats(equipped);
230
+ var delta_1 = {};
231
+ Object.keys(stats_1).forEach(function(key) {
232
+ delta_1[key] = -stats_1[key];
233
+ });
234
+ return buildStatsList(delta_1);
235
+ }
236
+ if (entry.kind === "item") {
237
+ var equippedStats_1 = getItemStats(equipped);
238
+ var nextStats_1 = getItemStats(entry);
239
+ var delta_2 = {};
240
+ new Set(__spreadArray(__spreadArray([], Object.keys(nextStats_1), true), Object.keys(equippedStats_1), true)).forEach(function(key) {
241
+ delta_2[key] = (nextStats_1[key] || 0) - (equippedStats_1[key] || 0);
242
+ });
243
+ return buildStatsList(delta_2);
244
+ }
245
+ return [];
246
+ });
247
+ var applyEquipState = function(slot, itemId, equip) {
248
+ var types = slotTypes(slot);
249
+ var next = __assign({}, equippedOverrides());
250
+ if (types.length) safeEquips().forEach(function(item) {
251
+ if (!item) return;
252
+ if (types.includes(item.type)) next[item.id] = false;
253
+ });
254
+ if (itemId) next[itemId] = equip;
255
+ equippedOverrides.set(next);
256
+ };
257
+ var commitSelection = function(index) {
258
+ var entry = listEntries()[index];
259
+ if (!entry) return;
260
+ if (entry.kind === "unequip") {
261
+ var equipped = currentEquippedItem();
262
+ if (equipped && onInteraction) onInteraction("equipItem", {
263
+ id: equipped.id,
264
+ equip: false
265
+ });
266
+ applyEquipState(currentSlot(), equipped === null || equipped === void 0 ? void 0 : equipped.id, false);
267
+ return;
268
+ }
269
+ if (entry.kind === "item" && onInteraction) {
270
+ if (!itemEquipped(entry)) onInteraction("equipItem", {
271
+ id: entry.id,
272
+ equip: true
273
+ });
274
+ applyEquipState(currentSlot(), entry.id, true);
275
+ }
276
+ };
277
+ function selectTab(index) {
278
+ return function() {
279
+ selectedTab.set(index);
280
+ selectedItem.set(0);
281
+ };
282
+ }
283
+ function selectItem(index) {
284
+ return function() {
285
+ selectedItem.set(index);
286
+ commitSelection(index);
287
+ };
288
+ }
289
+ var iconSheet = function(iconId) {
290
+ return { definition: engine.getSpriteSheet(iconId) };
291
+ };
292
+ var controls = signal({
293
+ up: {
294
+ repeat: true,
295
+ bind: keyboardControls.up,
296
+ throttle: 150,
297
+ keyDown: function() {
298
+ if (!listEntries().length) return;
299
+ nav.next(-1);
300
+ }
301
+ },
302
+ left: {
303
+ repeat: true,
304
+ bind: keyboardControls.left,
305
+ throttle: 150,
306
+ keyDown: function() {
307
+ var tabs = slotList();
308
+ if (!tabs.length) return;
309
+ selectedTab.update(function(value) {
310
+ return (value - 1 + tabs.length) % tabs.length;
311
+ });
312
+ selectedItem.set(0);
313
+ }
314
+ },
315
+ right: {
316
+ repeat: true,
317
+ bind: keyboardControls.right,
318
+ throttle: 150,
319
+ keyDown: function() {
320
+ var tabs = slotList();
321
+ if (!tabs.length) return;
322
+ selectedTab.update(function(value) {
323
+ return (value + 1) % tabs.length;
324
+ });
325
+ selectedItem.set(0);
326
+ }
327
+ },
328
+ down: {
329
+ repeat: true,
330
+ bind: keyboardControls.down,
331
+ throttle: 150,
332
+ keyDown: function() {
333
+ if (!listEntries().length) return;
334
+ nav.next(1);
335
+ }
336
+ },
337
+ action: {
338
+ bind: keyboardControls.action,
339
+ keyDown: function() {
340
+ if (!listEntries().length) return;
341
+ commitSelection(selectedItem());
342
+ }
343
+ },
344
+ escape: {
345
+ bind: keyboardControls.escape,
346
+ keyDown: function() {
347
+ if (onBack) onBack();
348
+ }
349
+ },
350
+ gamepad: { enabled: true }
351
+ });
352
+ effect(function() {
353
+ var count = listEntries().length;
354
+ if (!count) {
355
+ selectedItem.set(0);
356
+ return;
357
+ }
358
+ if (selectedItem() >= count) selectedItem.set(count - 1);
359
+ });
360
+ return h(DOMContainer, {
361
+ width: "100%",
362
+ height: "100%"
363
+ }, h(DOMElement, {
364
+ element: "div",
365
+ attrs: { class: "rpg-ui-menu-panel rpg-ui-panel" }
366
+ }, [h(DOMElement, {
367
+ element: "div",
368
+ attrs: { class: "rpg-ui-menu-panel-header" },
369
+ textContent: "Equip"
370
+ }), h(DOMElement, {
371
+ element: "div",
372
+ attrs: { class: "rpg-ui-menu-panel-body rpg-ui-menu-panel-body-stacked" }
373
+ }, [h(DOMElement, { element: "div" }, h(DOMElement, {
374
+ element: "div",
375
+ attrs: { class: "rpg-ui-menu-panel-details rpg-ui-panel" }
376
+ }, h(DOMElement, {
377
+ element: "div",
378
+ attrs: { class: "rpg-ui-menu-panel-hero" }
379
+ }, [h(DOMElement, {
380
+ element: "div",
381
+ attrs: { class: "rpg-ui-menu-panel-hero-icon" }
382
+ }, h(DOMSprite, {
383
+ sheet: computed(() => iconSheet(detailsItem()?.icon)),
384
+ playing: "default",
385
+ width: "48px",
386
+ height: "48px",
387
+ objectFit: "contain"
388
+ })), h(DOMElement, { element: "div" }, [
389
+ h(DOMElement, {
390
+ element: "div",
391
+ attrs: { class: "rpg-ui-menu-panel-details-title" },
392
+ textContent: computed(() => detailsItem()?.name || currentSlot()?.label || "Equip")
393
+ }),
394
+ h(DOMElement, {
395
+ element: "div",
396
+ attrs: { class: "rpg-ui-menu-panel-details-desc" },
397
+ textContent: computed(() => detailsItem()?.description || "")
398
+ }),
399
+ cond(computed(() => displayStats().length > 0), () => h(DOMElement, {
400
+ element: "div",
401
+ attrs: { class: "rpg-ui-equip-stats" }
402
+ }, loop(displayStats, (stat, index) => h(DOMElement, {
403
+ element: "div",
404
+ attrs: { class: ["rpg-ui-equip-stat", {
405
+ positive: stat.delta > 0,
406
+ negative: stat.delta < 0
407
+ }] }
408
+ }, [
409
+ h(DOMElement, {
410
+ element: "div",
411
+ attrs: { class: "rpg-ui-equip-stat-key" },
412
+ textContent: stat.label
413
+ }),
414
+ h(DOMElement, {
415
+ element: "div",
416
+ attrs: { class: "rpg-ui-equip-stat-value" },
417
+ textContent: stat.delta > 0 ? "+" : "" + stat.delta
418
+ }),
419
+ cond(stat.current, () => h(DOMElement, {
420
+ element: "div",
421
+ attrs: { class: "rpg-ui-equip-stat-current" },
422
+ textContent: stat.current + " -> " + stat.next
423
+ }))
424
+ ])))),
425
+ h(DOMElement, {
426
+ element: "div",
427
+ attrs: { class: "rpg-ui-menu-panel-details-meta" }
428
+ }, h(DOMElement, {
429
+ element: "span",
430
+ textContent: computed(() => equippedText())
431
+ }))
432
+ ])]))), h(DOMElement, {
433
+ element: "div",
434
+ attrs: { class: "rpg-ui-menu-panel-list rpg-ui-menu rpg-ui-menu-panel-list-full" }
435
+ }, [h(DOMElement, {
436
+ element: "div",
437
+ attrs: { class: "rpg-ui-menu-tabs" }
438
+ }, loop(slotList, (tab, tabIndex) => h(DOMElement, {
439
+ element: "div",
440
+ attrs: {
441
+ class: ["rpg-ui-menu-tab", computed(() => ({ active: selectedTab() === tabIndex }))],
442
+ tabindex: tabIndex,
443
+ click: selectTab(tabIndex)
444
+ },
445
+ textContent: tab.label
446
+ }))), h(Navigation, {
447
+ tabindex: selectedItem,
448
+ controls
449
+ }, loop(listEntries, (entry, index) => h(DOMElement, {
450
+ element: "div",
451
+ attrs: {
452
+ class: "rpg-ui-menu-item rpg-ui-menu-row",
453
+ "data-selected": computed(() => selectedItem() === index ? "true" : "false"),
454
+ tabindex: index,
455
+ click: selectItem(index)
456
+ }
457
+ }, [h(DOMElement, {
458
+ element: "div",
459
+ attrs: { class: "rpg-ui-menu-row-main" }
460
+ }, [h(DOMElement, {
461
+ element: "div",
462
+ attrs: { class: "rpg-ui-menu-row-icon" }
463
+ }, cond(entry?.icon, () => h(DOMSprite, {
464
+ sheet: computed(() => iconSheet(entry.icon)),
465
+ playing: "default",
466
+ width: "28px",
467
+ height: "28px",
468
+ objectFit: "contain"
469
+ }))), h(DOMElement, {
470
+ element: "span",
471
+ textContent: entry.name
472
+ })]), h(DOMElement, {
473
+ element: "span",
474
+ attrs: { class: "rpg-ui-menu-row-end" },
475
+ textContent: entry.tag || ""
476
+ })])))])])]));
266
477
  }
267
- var iconSheet = function (iconId) { return ({
268
- definition: engine.getSpriteSheet(iconId)
269
- }); };
270
- var controls = signal({
271
- up: {
272
- repeat: true,
273
- bind: keyboardControls.up,
274
- throttle: 150,
275
- keyDown: function () {
276
- if (!listEntries().length)
277
- return;
278
- nav.next(-1);
279
- }
280
- },
281
- left: {
282
- repeat: true,
283
- bind: keyboardControls.left,
284
- throttle: 150,
285
- keyDown: function () {
286
- var tabs = slotList();
287
- if (!tabs.length)
288
- return;
289
- selectedTab.update(function (value) { return (value - 1 + tabs.length) % tabs.length; });
290
- selectedItem.set(0);
291
- }
292
- },
293
- right: {
294
- repeat: true,
295
- bind: keyboardControls.right,
296
- throttle: 150,
297
- keyDown: function () {
298
- var tabs = slotList();
299
- if (!tabs.length)
300
- return;
301
- selectedTab.update(function (value) { return (value + 1) % tabs.length; });
302
- selectedItem.set(0);
303
- }
304
- },
305
- down: {
306
- repeat: true,
307
- bind: keyboardControls.down,
308
- throttle: 150,
309
- keyDown: function () {
310
- if (!listEntries().length)
311
- return;
312
- nav.next(1);
313
- }
314
- },
315
- action: {
316
- bind: keyboardControls.action,
317
- keyDown: function () {
318
- if (!listEntries().length)
319
- return;
320
- commitSelection(selectedItem());
321
- }
322
- },
323
- escape: {
324
- bind: keyboardControls.escape,
325
- keyDown: function () {
326
- if (onBack)
327
- onBack();
328
- }
329
- },
330
- gamepad: {
331
- enabled: true
332
- }
333
- });
334
- effect(function () {
335
- var count = listEntries().length;
336
- if (!count) {
337
- selectedItem.set(0);
338
- return;
339
- }
340
- if (selectedItem() >= count) {
341
- selectedItem.set(count - 1);
342
- }
343
- });
344
- let $this = h(DOMContainer, { width: '100%', height: '100%' }, h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel rpg-ui-panel' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-header' }, textContent: 'Equip' }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-body rpg-ui-menu-panel-body-stacked' } }, [h(DOMElement, { element: "div" }, h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-details rpg-ui-panel' } }, h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-hero' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-hero-icon' } }, h(DOMSprite, { sheet: computed(() => iconSheet(detailsItem()?.icon)), playing: 'default', width: '48px', height: '48px', objectFit: 'contain' })), h(DOMElement, { element: "div" }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-details-title' }, textContent: computed(() => detailsItem()?.name || currentSlot()?.label || "Equip") }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-details-desc' }, textContent: computed(() => detailsItem()?.description || "") }), cond(computed(() => displayStats().length > 0), () => h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-equip-stats' } }, loop(displayStats, (stat, index) => h(DOMElement, { element: "div", attrs: { class: ['rpg-ui-equip-stat', { positive: stat.delta > 0, negative: stat.delta < 0 }] } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-equip-stat-key' }, textContent: stat.label }), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-equip-stat-value' }, textContent: stat.delta > 0 ? "+" : "" + stat.delta }), cond(stat.current, () => h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-equip-stat-current' }, textContent: stat.current + ' -> ' + stat.next }))])))), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-details-meta' } }, h(DOMElement, { element: "span", textContent: computed(() => equippedText()) }))])]))), h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-panel-list rpg-ui-menu rpg-ui-menu-panel-list-full' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-tabs' } }, loop(slotList, (tab, tabIndex) => h(DOMElement, { element: "div", attrs: { class: ['rpg-ui-menu-tab', computed(() => ({ active: selectedTab() === tabIndex }))], tabindex: tabIndex, click: selectTab(tabIndex) }, textContent: tab.label }))), h(Navigation, { tabindex: selectedItem, controls: controls }, loop(listEntries, (entry, index) => h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-item rpg-ui-menu-row', 'data-selected': computed(() => selectedItem() === index ? "true" : "false"), tabindex: index, click: selectItem(index) } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-row-main' } }, [h(DOMElement, { element: "div", attrs: { class: 'rpg-ui-menu-row-icon' } }, cond(entry?.icon, () => h(DOMSprite, { sheet: computed(() => iconSheet(entry.icon)), playing: 'default', width: '28px', height: '28px', objectFit: 'contain' }))), h(DOMElement, { element: "span", textContent: entry.name })]), h(DOMElement, { element: "span", attrs: { class: 'rpg-ui-menu-row-end' }, textContent: entry.tag || "" })])))])])]));
345
- return $this
346
- }
347
-
478
+ //#endregion
348
479
  export { component as default };
349
- //# sourceMappingURL=equip-menu.ce.js.map
480
+
481
+ //# sourceMappingURL=equip-menu.ce.js.map