@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.3
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/LICENSE +19 -0
- package/dist/Game/Map.js +2 -2
- package/dist/Game/Object.js.map +1 -1
- package/dist/Gui/Gui.js.map +1 -1
- package/dist/Gui/NotificationManager.js.map +1 -1
- package/dist/RpgClientEngine.js +2 -1
- 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.127.0}/helpers/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.127.0}/helpers/decorateMetadata.js +1 -1
- package/dist/components/animations/animation.ce.js +2 -4
- package/dist/components/animations/animation.ce.js.map +1 -1
- package/dist/components/animations/hit.ce.js +17 -24
- package/dist/components/animations/hit.ce.js.map +1 -1
- package/dist/components/character.ce.js +75 -222
- package/dist/components/character.ce.js.map +1 -1
- package/dist/components/dynamics/text.ce.js +14 -25
- package/dist/components/dynamics/text.ce.js.map +1 -1
- package/dist/components/gui/box.ce.js +4 -7
- package/dist/components/gui/box.ce.js.map +1 -1
- package/dist/components/gui/dialogbox/index.ce.js +37 -54
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
- package/dist/components/gui/gameover.ce.js +36 -61
- package/dist/components/gui/gameover.ce.js.map +1 -1
- package/dist/components/gui/hud/hud.ce.js +18 -28
- package/dist/components/gui/hud/hud.ce.js.map +1 -1
- package/dist/components/gui/menu/equip-menu.ce.js +108 -163
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/exit-menu.ce.js +4 -4
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/items-menu.ce.js +47 -66
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/main-menu.ce.js +58 -77
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/options-menu.ce.js +3 -3
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
- package/dist/components/gui/menu/skills-menu.ce.js +10 -16
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
- package/dist/components/gui/mobile/mobile.ce.js +3 -3
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
- package/dist/components/gui/notification/notification.ce.js +13 -19
- package/dist/components/gui/notification/notification.ce.js.map +1 -1
- package/dist/components/gui/save-load.ce.js +68 -247
- package/dist/components/gui/save-load.ce.js.map +1 -1
- package/dist/components/gui/shop/shop.ce.js +84 -123
- package/dist/components/gui/shop/shop.ce.js.map +1 -1
- package/dist/components/gui/title-screen.ce.js +38 -65
- package/dist/components/gui/title-screen.ce.js.map +1 -1
- package/dist/components/prebuilt/hp-bar.ce.js +39 -43
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
- package/dist/components/prebuilt/light-halo.ce.js +33 -58
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
- package/dist/components/scenes/canvas.ce.js +11 -19
- package/dist/components/scenes/canvas.ce.js.map +1 -1
- package/dist/components/scenes/draw-map.ce.js +20 -25
- package/dist/components/scenes/draw-map.ce.js.map +1 -1
- package/dist/components/scenes/event-layer.ce.js +4 -4
- package/dist/components/scenes/event-layer.ce.js.map +1 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.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/services/keyboardControls.js.map +1 -1
- package/dist/services/mmorpg.js +2 -1
- package/dist/services/mmorpg.js.map +1 -1
- package/package.json +7 -8
- 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
|
@@ -8,139 +8,19 @@ import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "
|
|
|
8
8
|
//#region src/components/character.ce
|
|
9
9
|
function component($$props) {
|
|
10
10
|
useProps($$props);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
s = arguments[i];
|
|
16
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
17
|
-
}
|
|
18
|
-
return t;
|
|
19
|
-
};
|
|
20
|
-
return __assign.apply(this, arguments);
|
|
21
|
-
};
|
|
22
|
-
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
23
|
-
function adopt(value) {
|
|
24
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
25
|
-
resolve(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
29
|
-
function fulfilled(value) {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.next(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function rejected(value) {
|
|
37
|
-
try {
|
|
38
|
-
step(generator["throw"](value));
|
|
39
|
-
} catch (e) {
|
|
40
|
-
reject(e);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function step(result) {
|
|
44
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
45
|
-
}
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
50
|
-
var _ = {
|
|
51
|
-
label: 0,
|
|
52
|
-
sent: function() {
|
|
53
|
-
if (t[0] & 1) throw t[1];
|
|
54
|
-
return t[1];
|
|
55
|
-
},
|
|
56
|
-
trys: [],
|
|
57
|
-
ops: []
|
|
58
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
59
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
60
|
-
return this;
|
|
61
|
-
}), g;
|
|
62
|
-
function verb(n) {
|
|
63
|
-
return function(v) {
|
|
64
|
-
return step([n, v]);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function step(op) {
|
|
68
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
69
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
70
|
-
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;
|
|
71
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
72
|
-
switch (op[0]) {
|
|
73
|
-
case 0:
|
|
74
|
-
case 1:
|
|
75
|
-
t = op;
|
|
76
|
-
break;
|
|
77
|
-
case 4:
|
|
78
|
-
_.label++;
|
|
79
|
-
return {
|
|
80
|
-
value: op[1],
|
|
81
|
-
done: false
|
|
82
|
-
};
|
|
83
|
-
case 5:
|
|
84
|
-
_.label++;
|
|
85
|
-
y = op[1];
|
|
86
|
-
op = [0];
|
|
87
|
-
continue;
|
|
88
|
-
case 7:
|
|
89
|
-
op = _.ops.pop();
|
|
90
|
-
_.trys.pop();
|
|
91
|
-
continue;
|
|
92
|
-
default:
|
|
93
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
94
|
-
_ = 0;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
98
|
-
_.label = op[1];
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
102
|
-
_.label = t[1];
|
|
103
|
-
t = op;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
if (t && _.label < t[2]) {
|
|
107
|
-
_.label = t[2];
|
|
108
|
-
_.ops.push(op);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
if (t[2]) _.ops.pop();
|
|
112
|
-
_.trys.pop();
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
op = body.call(thisArg, _);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
op = [6, e];
|
|
118
|
-
y = 0;
|
|
119
|
-
} finally {
|
|
120
|
-
f = t = 0;
|
|
121
|
-
}
|
|
122
|
-
if (op[0] & 5) throw op[1];
|
|
123
|
-
return {
|
|
124
|
-
value: op[0] ? op[1] : void 0,
|
|
125
|
-
done: true
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var _a = defineProps(), object = _a.object, id = _a.id;
|
|
130
|
-
var client = inject(RpgClientEngine);
|
|
131
|
-
var hooks = inject(ModulesToken);
|
|
132
|
-
var guiService = inject(RpgGui);
|
|
11
|
+
const { object, id } = useDefineProps($$props)();
|
|
12
|
+
const client = inject(RpgClientEngine);
|
|
13
|
+
const hooks = inject(ModulesToken);
|
|
14
|
+
const guiService = inject(RpgGui);
|
|
133
15
|
client.spritesheets;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var propsValue;
|
|
143
|
-
var dependenciesFn;
|
|
16
|
+
const playerId = client.playerId;
|
|
17
|
+
const componentsBehind = client.spriteComponentsBehind;
|
|
18
|
+
const componentsInFront = client.spriteComponentsInFront;
|
|
19
|
+
const isMe = computed(() => id() === playerId);
|
|
20
|
+
const normalizeComponent = (comp) => {
|
|
21
|
+
let componentRef;
|
|
22
|
+
let propsValue;
|
|
23
|
+
let dependenciesFn;
|
|
144
24
|
if (typeof comp === "function" || comp && typeof comp === "object" && !comp.component) {
|
|
145
25
|
componentRef = comp;
|
|
146
26
|
propsValue = void 0;
|
|
@@ -160,36 +40,33 @@ function component($$props) {
|
|
|
160
40
|
dependencies: dependenciesFn ? dependenciesFn(object) : []
|
|
161
41
|
};
|
|
162
42
|
};
|
|
163
|
-
|
|
164
|
-
return components.map(
|
|
165
|
-
return normalizeComponent(comp);
|
|
166
|
-
});
|
|
43
|
+
const normalizeComponents = (components) => {
|
|
44
|
+
return components.map((comp) => normalizeComponent(comp));
|
|
167
45
|
};
|
|
168
|
-
|
|
46
|
+
const normalizedComponentsBehind = computed(() => {
|
|
169
47
|
return normalizeComponents(componentsBehind());
|
|
170
48
|
});
|
|
171
|
-
|
|
49
|
+
const normalizedComponentsInFront = computed(() => {
|
|
172
50
|
return normalizeComponents(componentsInFront());
|
|
173
51
|
});
|
|
174
|
-
|
|
175
|
-
|
|
52
|
+
const shouldFollowCamera = computed(() => {
|
|
53
|
+
const cameraTargetId = client.cameraFollowTargetId();
|
|
176
54
|
if (cameraTargetId !== null) return id() === cameraTargetId;
|
|
177
55
|
return isMe();
|
|
178
56
|
});
|
|
179
|
-
|
|
57
|
+
const attachedGuis = computed(() => {
|
|
180
58
|
return guiService.getAttachedGuis();
|
|
181
59
|
});
|
|
182
|
-
|
|
60
|
+
const shouldDisplayAttachedGui = computed(() => {
|
|
183
61
|
return guiService.shouldDisplayAttachedGui(id());
|
|
184
|
-
})
|
|
185
|
-
object
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
on(flashTrigger, function(data) {
|
|
62
|
+
});
|
|
63
|
+
const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = object;
|
|
64
|
+
const flashType = signal("alpha");
|
|
65
|
+
const flashDuration = signal(300);
|
|
66
|
+
const flashCycles = signal(1);
|
|
67
|
+
const flashAlpha = signal(.3);
|
|
68
|
+
const flashTint = signal(16777215);
|
|
69
|
+
on(flashTrigger, (data) => {
|
|
193
70
|
if (data && typeof data === "object") {
|
|
194
71
|
if (data.type !== void 0) flashType.set(data.type);
|
|
195
72
|
if (data.duration !== void 0) flashDuration.set(data.duration);
|
|
@@ -198,109 +75,97 @@ function component($$props) {
|
|
|
198
75
|
if (data.tint !== void 0) flashTint.set(data.tint);
|
|
199
76
|
}
|
|
200
77
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return isMe() && object.canMove();
|
|
214
|
-
};
|
|
215
|
-
var keyboardControls = client.globalConfig.keyboardControls;
|
|
216
|
-
var visible = computed(function() {
|
|
78
|
+
const flashConfig = computed(() => ({
|
|
79
|
+
trigger: flashTrigger,
|
|
80
|
+
type: flashType(),
|
|
81
|
+
duration: flashDuration(),
|
|
82
|
+
cycles: flashCycles(),
|
|
83
|
+
alpha: flashAlpha(),
|
|
84
|
+
tint: flashTint()
|
|
85
|
+
}));
|
|
86
|
+
const particleSettings = client.particleSettings;
|
|
87
|
+
const canControls = () => isMe() && object.canMove();
|
|
88
|
+
const keyboardControls = client.globalConfig.keyboardControls;
|
|
89
|
+
const visible = computed(() => {
|
|
217
90
|
if (object.isEvent()) return true;
|
|
218
91
|
return isConnected();
|
|
219
92
|
});
|
|
220
|
-
|
|
93
|
+
const controls = signal({
|
|
221
94
|
down: {
|
|
222
95
|
repeat: true,
|
|
223
96
|
bind: keyboardControls.down,
|
|
224
|
-
keyDown
|
|
97
|
+
keyDown() {
|
|
225
98
|
if (canControls()) client.processInput({ input: Direction.Down });
|
|
226
99
|
}
|
|
227
100
|
},
|
|
228
101
|
up: {
|
|
229
102
|
repeat: true,
|
|
230
103
|
bind: keyboardControls.up,
|
|
231
|
-
keyDown
|
|
104
|
+
keyDown() {
|
|
232
105
|
if (canControls()) client.processInput({ input: Direction.Up });
|
|
233
106
|
}
|
|
234
107
|
},
|
|
235
108
|
left: {
|
|
236
109
|
repeat: true,
|
|
237
110
|
bind: keyboardControls.left,
|
|
238
|
-
keyDown
|
|
111
|
+
keyDown() {
|
|
239
112
|
if (canControls()) client.processInput({ input: Direction.Left });
|
|
240
113
|
}
|
|
241
114
|
},
|
|
242
115
|
right: {
|
|
243
116
|
repeat: true,
|
|
244
117
|
bind: keyboardControls.right,
|
|
245
|
-
keyDown
|
|
118
|
+
keyDown() {
|
|
246
119
|
if (canControls()) client.processInput({ input: Direction.Right });
|
|
247
120
|
}
|
|
248
121
|
},
|
|
249
122
|
action: {
|
|
250
123
|
bind: keyboardControls.action,
|
|
251
|
-
keyDown
|
|
124
|
+
keyDown() {
|
|
252
125
|
if (canControls()) client.processAction({ action: "action" });
|
|
253
126
|
}
|
|
254
127
|
},
|
|
255
128
|
escape: {
|
|
256
129
|
bind: keyboardControls.escape,
|
|
257
|
-
keyDown
|
|
130
|
+
keyDown() {
|
|
258
131
|
if (canControls()) client.processAction({ action: "escape" });
|
|
259
132
|
}
|
|
260
133
|
},
|
|
261
134
|
gamepad: { enabled: true }
|
|
262
135
|
});
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
136
|
+
const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
|
|
137
|
+
const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
|
|
138
|
+
const z = computed(() => {
|
|
266
139
|
return object.y() + object.z();
|
|
267
140
|
});
|
|
268
|
-
|
|
269
|
-
|
|
141
|
+
const realAnimationName = signal(animationName());
|
|
142
|
+
const xSubscription = x.observable.subscribe((value) => {
|
|
270
143
|
smoothX.set(value);
|
|
271
144
|
});
|
|
272
|
-
|
|
145
|
+
const ySubscription = y.observable.subscribe((value) => {
|
|
273
146
|
smoothY.set(value);
|
|
274
147
|
});
|
|
275
|
-
|
|
148
|
+
const sheet = (graphicObject) => {
|
|
276
149
|
return {
|
|
277
150
|
definition: graphicObject,
|
|
278
151
|
playing: realAnimationName(),
|
|
279
152
|
params: { direction: direction() },
|
|
280
|
-
onFinish
|
|
281
|
-
animationCurrentIndex.update(
|
|
282
|
-
return index + 1;
|
|
283
|
-
});
|
|
153
|
+
onFinish() {
|
|
154
|
+
animationCurrentIndex.update((index) => index + 1);
|
|
284
155
|
}
|
|
285
156
|
};
|
|
286
157
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
|
|
158
|
+
const movementAnimations = ["walk", "stand"];
|
|
159
|
+
const epsilon = 0;
|
|
160
|
+
const stateX$ = smoothX.animatedState.observable;
|
|
161
|
+
const stateY$ = smoothY.animatedState.observable;
|
|
162
|
+
const animationName$ = animationName.observable;
|
|
163
|
+
const moving$ = combineLatest([stateX$, stateY$]).pipe(map(([sx, sy]) => {
|
|
164
|
+
const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
|
|
165
|
+
const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
|
|
296
166
|
return !xFinished || !yFinished;
|
|
297
167
|
}), startWith(false));
|
|
298
|
-
|
|
299
|
-
return _a[0] !== _a[1];
|
|
300
|
-
})), moving$]).subscribe(function(_a) {
|
|
301
|
-
var _b = _a[0];
|
|
302
|
-
_b[0];
|
|
303
|
-
var curr = _b[1], isMoving = _a[1];
|
|
168
|
+
const animationMovementSubscription = combineLatest([animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr)), moving$]).subscribe(([[prev, curr], isMoving]) => {
|
|
304
169
|
if (curr == "stand" && !isMoving) realAnimationName.set(curr);
|
|
305
170
|
else if (curr == "walk" && isMoving) realAnimationName.set(curr);
|
|
306
171
|
else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
|
|
@@ -310,37 +175,25 @@ function component($$props) {
|
|
|
310
175
|
}
|
|
311
176
|
}
|
|
312
177
|
});
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
xSubscription.unsubscribe();
|
|
320
|
-
ySubscription.unsubscribe();
|
|
321
|
-
return [4, lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object))];
|
|
322
|
-
case 1:
|
|
323
|
-
_a.sent();
|
|
324
|
-
return [4, lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object))];
|
|
325
|
-
case 2:
|
|
326
|
-
_a.sent();
|
|
327
|
-
return [2];
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
});
|
|
178
|
+
const onBeforeDestroy = async () => {
|
|
179
|
+
animationMovementSubscription.unsubscribe();
|
|
180
|
+
xSubscription.unsubscribe();
|
|
181
|
+
ySubscription.unsubscribe();
|
|
182
|
+
await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object));
|
|
183
|
+
await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object));
|
|
331
184
|
};
|
|
332
|
-
mount(
|
|
185
|
+
mount((element) => {
|
|
333
186
|
hooks.callHooks("client-sprite-onAdd", object).subscribe();
|
|
334
187
|
hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
|
|
335
188
|
if (isMe()) client.setKeyboardControls(element.directives.controls);
|
|
336
189
|
});
|
|
337
|
-
|
|
190
|
+
const onAttachedGuiFinish = (gui, data) => {
|
|
338
191
|
guiService.guiClose(gui.name, data);
|
|
339
192
|
};
|
|
340
|
-
|
|
193
|
+
const onAttachedGuiInteraction = (gui, name, data) => {
|
|
341
194
|
guiService.guiInteraction(gui.name, name, data);
|
|
342
195
|
};
|
|
343
|
-
tick(
|
|
196
|
+
tick(() => {
|
|
344
197
|
hooks.callHooks("client-sprite-onUpdate").subscribe();
|
|
345
198
|
});
|
|
346
199
|
return h(Container, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object ...compConfig.props />\n </Container>\n } \n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n flash={flashConfig}\n />\n }\n </Container>\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object ...compConfig.props />\n </Container>\n }\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={object} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n\n const { object, id } = defineProps();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(object) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(object) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = object;\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const visible = computed(() => {\n if (object.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n });\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return object.y() + object.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\n });\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const onBeforeDestroy = async () => {\n animationMovementSubscription.unsubscribe();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", object)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, object))\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onAdd\", object).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, object).subscribe()\n if (isMe()) client.setKeyboardControls(element.directives.controls)\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>"],"mappings":";;;;;;;;AAcM,SAAoB,UAAA,SAAA;AACnB,UAAA,QAAA;CACH,MAAA,cAAA,eAAA,QAAA;CACA,IAAA,WAAS,QAAA,KAAA,YAAA,WAAA;AACV,aAAK,OAAc,UAAA,SAAA,GAAA;AACjB,QAAA,IAAU,GAAA,IAAA,GAAY,IAAE,UAAW,QAAA,IAAa,GAAA,KAAA;AAC9C,QAAA,UAAW;AACZ,SAAS,IAAA,KAAA,EAAA,KAAA,OAAA,UAAA,eAAA,KAAA,GAAA,EAAA,CACb,GAAA,KAAA,EAAA;;AAEM,UAAC;;AAEL,SAAK,SAAW,MAAC,MAAW,UAAE;;CAElC,IAAI,YAAO,QAAc,KAAE,aAAe,SAAA,SAAA,YAAA,GAAA,WAAA;EACtC,SAAM,MAAA,OAAA;AAAA,UAAyB,iBAAiB,IAAE,QAAI,IAAA,EAAA,SAAA,SAAA;AAAA,YAAA,MAAA;KAAA;;AACtD,SAAO,KAAC,MAAA,IAAA,UAAA,SAAA,SAAA,QAAA;GACJ,SAAS,UAAA,OAAA;AAAA,QAAA;AAAA,UAAA,UAAA,KAAA,MAAA,CAAA;aAAA,GAAA;AAAA,YAAA,EAAA;;;GACb,SAAA,SAAA,OAAA;AAAA,QAAA;AAAA,UAAA,UAAA,SAAA,MAAA,CAAA;aAA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AA;EAAA;EAAA;EAAA,EAAA;EAAA,KAAA,6BAAA,eAAA,EAAA,WAAA,MAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;GAAA,CAAA,CAAA,CAAA;EAAA,EAAA,UAAA;GAAA,MAAA;GAAA,UAAA;GAAA,QAAA;GAAA,MAAA;GAAA,CAAA;EAAA,EAAA,WAAA,MAAA,KAAA,kBAAA,eAAA,EAAA,QAAA;GAAA,OAAA,eAAA,MAAA,WAAA,CAAA;GAAA;GAAA;GAAA;GAAA,OAAA;GAAA,CAAA,CAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,cAAA,EAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;GAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,MAAA;GAAA,cAAA,YAAA;GAAA;GAAA,WAAA,SAAA;AACN,wBAAiB,aAAO,KAAc;;GACzC,gBAAA,MAAA,SAAA;AACF,6BAAA,aAAA,MAAA,KAAA;;GACM,CAAA,CAAA,CAAA,CAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object ...compConfig.props />\n </Container>\n } \n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n flash={flashConfig}\n />\n }\n </Container>\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object ...compConfig.props />\n </Container>\n }\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={object} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n\n const { object, id } = defineProps();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(object) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(object) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = object;\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const visible = computed(() => {\n if (object.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n gamepad: {\n enabled: true\n }\n });\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n return object.y() + object.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\n });\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const onBeforeDestroy = async () => {\n animationMovementSubscription.unsubscribe();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", object)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, object))\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onAdd\", object).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, object).subscribe()\n if (isMe()) client.setKeyboardControls(element.directives.controls)\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>"],"mappings":";;;;;;;;AAcM,SAAoB,UAAA,SAAA;AACnB,UAAA,QAAA;CAEH,MAAS,EAAA,QAAA,OADT,eAAA,QACS,EAAA;CACb,MAAM,SAAE,OAAc,gBAAA;CACtB,MAAK,QAAS,OAAC,aAAc;CAC7B,MAAM,aAAY,OAAA,OAAU;AACb,QAAA;CACf,MAAE,WAAA,OAAA;CACF,MAAM,mBAAiB,OAAA;CACvB,MAAK,oBAAI,OAAwB;CACjC,MAAM,OAAC,eAAS,IAAA,KAAA,SAAA;CAChB,MAAM,sBAAe,SAAa;EAC9B,IAAI;EACJ,IAAI;EACJ,IAAI;AAEJ,MAAI,OAAA,SAAS,cAAA,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;AACb,kBAAA;AACF,gBAAA,KAAA;AACA,oBAAS,KAAA;aAGA,QAAQ,OAAQ,SAAO,YAAe,KAAC,WAAe;;AAGzD,gBAAa,KAAK,UAAG,KAAA,IAAa,KAAQ,QAAA,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qBAAA;;;GAIF;CACF,MAAI,kBAAK,YAAA;AACL,gCAAU,aAAA;AACV,gBAAc,aAAA;AACd,gBAAA,aAAqB;AACrB,QAAA,cAAoB,MAAA,UAAA,2BAAA,OAAA,CAAA;AACpB,QAAA,cAAa,MAAA,UAAA,kCAAA,OAAA,UAAA,OAAA,CAAA;;AAEjB,QAAI,YAAM;AACN,QAAA,UAAW,uBAAA,OAAA,CAAA,WAAA;AACX,QAAA,UAAe,+BAAA,OAAA,UAAA,OAAA,CAAA,WAAA;AACf,MAAA,MAAA,CACE,QAAM,oBAAA,QAAA,WAAA,SAAA;;CAEZ,MAAI,uBAAA,KAAA,SAAA;AACA,aAAO,SAAa,IAAC,MAAQ,KAAI;;CAErC,MAAI,4BAAA,KAAA,MAAA,SAAA;AACF,aAAM,eAAoB,IAAM,MAAI,MAAQ,KAAK;;AAEnD,YAAQ;AACN,QAAM,UAAY,yBAAY,CAAA,WAAA;GAC9B;AAMG,QAAA,EAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAJD,wBAAA,aAAA,KAAA;;GACO,gBAAU,MAAW,SAAO;AAC7B,6BAAwB,aAAS,MAAW,KAAA;;GAClD,CAAA,CAAA,CAAA,CAAA;EAAA,CACgB"}
|
|
@@ -3,48 +3,37 @@ import { Text, computed, h, useDefineProps, useProps } from "canvasengine";
|
|
|
3
3
|
//#region src/components/dynamics/text.ce
|
|
4
4
|
function component($$props) {
|
|
5
5
|
useProps($$props);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
-
s = arguments[i];
|
|
11
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var object = defineProps().object;
|
|
18
|
-
var component = object._component;
|
|
19
|
-
var parseNumericStyleValue = function(value, object) {
|
|
6
|
+
const { object } = useDefineProps($$props)();
|
|
7
|
+
const component = object._component;
|
|
8
|
+
const parseNumericStyleValue = (value, object) => {
|
|
20
9
|
if (value === void 0 || value === null) return;
|
|
21
10
|
if (typeof value === "number") return value;
|
|
22
11
|
if (typeof value === "string") if (value.includes("{")) {
|
|
23
|
-
|
|
24
|
-
return computed(
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
const parsed = parseDynamicValue(value, object);
|
|
13
|
+
return computed(() => {
|
|
14
|
+
const str = parsed();
|
|
15
|
+
const num = parseFloat(str);
|
|
27
16
|
return isNaN(num) ? 0 : num;
|
|
28
17
|
});
|
|
29
18
|
} else {
|
|
30
|
-
|
|
19
|
+
const num = parseFloat(value);
|
|
31
20
|
return isNaN(num) ? void 0 : num;
|
|
32
21
|
}
|
|
33
22
|
return value;
|
|
34
23
|
};
|
|
35
|
-
|
|
24
|
+
const getComponentStyle = (component) => {
|
|
36
25
|
if (!component.style) return {};
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const style = component.style;
|
|
27
|
+
const result = {};
|
|
39
28
|
if (style.fill !== void 0) if (typeof style.fill === "string" && style.fill.includes("{")) result.color = parseDynamicValue(style.fill, object);
|
|
40
29
|
else result.color = style.fill;
|
|
41
30
|
if (style.fontSize !== void 0) {
|
|
42
|
-
|
|
31
|
+
const fontSizeValue = parseNumericStyleValue(style.fontSize, object);
|
|
43
32
|
if (fontSizeValue !== void 0) result.size = fontSizeValue;
|
|
44
33
|
}
|
|
45
34
|
if (style.fontFamily !== void 0) if (typeof style.fontFamily === "string" && style.fontFamily.includes("{")) result.fontFamily = parseDynamicValue(style.fontFamily, object);
|
|
46
35
|
else result.fontFamily = style.fontFamily;
|
|
47
|
-
|
|
36
|
+
const textStyle = {};
|
|
48
37
|
if (style.fontStyle !== void 0) if (typeof style.fontStyle === "string" && style.fontStyle.includes("{")) textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);
|
|
49
38
|
else textStyle.fontStyle = style.fontStyle;
|
|
50
39
|
if (style.fontWeight !== void 0) if (typeof style.fontWeight === "string" && style.fontWeight.includes("{")) textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);
|
|
@@ -53,7 +42,7 @@ function component($$props) {
|
|
|
53
42
|
if (style.stroke !== void 0) if (typeof style.stroke === "string" && style.stroke.includes("{")) textStyle.stroke = parseDynamicValue(style.stroke, object);
|
|
54
43
|
else textStyle.stroke = style.stroke;
|
|
55
44
|
if (style.opacity !== void 0) {
|
|
56
|
-
|
|
45
|
+
const opacityValue = parseNumericStyleValue(style.opacity, object);
|
|
57
46
|
if (opacityValue !== void 0) textStyle.opacity = opacityValue;
|
|
58
47
|
}
|
|
59
48
|
if (style.wordWrap !== void 0) textStyle.wordWrap = style.wordWrap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.ce.js","names":[],"sources":["../../../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={parseDynamicValue(component.value, object)} ...getComponentStyle(component) />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { parseDynamicValue } from \"./parse-value\";\n\nconst { object } = defineProps();\nconst component = object._component;\n\n/**\n * Parses a numeric style value that can be a number or a string\n * \n * If the value is a string, it may contain dynamic references like {hp}\n * which need to be parsed using parseDynamicValue. If it's a number,\n * it's returned as-is wrapped in a computed.\n * \n * @param value - Numeric value (number or string)\n * @param object - Object to resolve dynamic references from\n * @returns Computed signal with the numeric value\n */\nconst parseNumericStyleValue = (value, object) => {\n if (value === undefined || value === null) {\n return undefined;\n }\n \n if (typeof value === 'number') {\n return value;\n }\n \n if (typeof value === 'string') {\n // Check if it contains dynamic references\n if (value.includes('{')) {\n // Parse dynamic value and convert to number\n const parsed = parseDynamicValue(value, object);\n return computed(() => {\n const str = parsed();\n const num = parseFloat(str);\n return isNaN(num) ? 0 : num;\n });\n } else {\n // Simple string number, convert directly\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n }\n }\n \n return value;\n};\n\n/**\n * Maps component style properties to Canvas Engine Text component props\n * \n * Converts TextComponentOptions from the server to the format expected\n * by the Canvas Engine Text component. Supports all text styling properties\n * including fill, fontSize, fontFamily, fontStyle, fontWeight, stroke,\n * opacity, wordWrap, and align. Also supports dynamic values (number | string)\n * for numeric properties like fontSize and opacity.\n * \n * @param component - Component definition with style property\n * @returns Object with Text component props\n * \n * @example\n * ```ts\n * // Component with style\n * const component = {\n * style: {\n * fill: '#000000',\n * fontSize: 20,\n * fontFamily: 'Arial',\n * fontWeight: 'bold'\n * }\n * };\n * \n * const props = getComponentStyle(component);\n * // Returns: { color: '#000000', size: 20, fontFamily: 'Arial', style: { fontWeight: 'bold' } }\n * \n * // Component with dynamic fontSize\n * const component2 = {\n * style: {\n * fill: '#000000',\n * fontSize: '{hp}', // Will be resolved from object.hp\n * opacity: '0.8'\n * }\n * };\n * ```\n */\nconst getComponentStyle = (component) => {\n if (!component.style) {\n return {};\n }\n\n const style = component.style;\n const result = {};\n\n // Map fill to color (shortcut property)\n // fill can be a string (hex color) or a dynamic string\n if (style.fill !== undefined) {\n if (typeof style.fill === 'string' && style.fill.includes('{')) {\n result.color = parseDynamicValue(style.fill, object);\n } else {\n result.color = style.fill;\n }\n }\n\n // Map fontSize to size (shortcut property)\n // fontSize can be number or string (with dynamic references)\n if (style.fontSize !== undefined) {\n const fontSizeValue = parseNumericStyleValue(style.fontSize, object);\n if (fontSizeValue !== undefined) {\n result.size = fontSizeValue;\n }\n }\n\n // Map fontFamily (shortcut property)\n if (style.fontFamily !== undefined) {\n if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {\n result.fontFamily = parseDynamicValue(style.fontFamily, object);\n } else {\n result.fontFamily = style.fontFamily;\n }\n }\n\n // Build style object for PixiJS Text properties\n const textStyle = {};\n\n // Font style properties\n if (style.fontStyle !== undefined) {\n if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {\n textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);\n } else {\n textStyle.fontStyle = style.fontStyle;\n }\n }\n\n if (style.fontWeight !== undefined) {\n if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {\n textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);\n } else if (typeof style.fontWeight === 'number') {\n textStyle.fontWeight = style.fontWeight;\n } else {\n textStyle.fontWeight = style.fontWeight;\n }\n }\n\n // Stroke properties\n if (style.stroke !== undefined) {\n if (typeof style.stroke === 'string' && style.stroke.includes('{')) {\n textStyle.stroke = parseDynamicValue(style.stroke, object);\n } else {\n textStyle.stroke = style.stroke;\n }\n }\n\n // Opacity (can be number or string)\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n // Word wrap\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n // Text alignment\n if (style.align !== undefined) {\n if (typeof style.align === 'string' && style.align.includes('{')) {\n textStyle.align = parseDynamicValue(style.align, object);\n } else {\n textStyle.align = style.align;\n }\n }\n\n // Only add style prop if there are style properties\n if (Object.keys(textStyle).length > 0) {\n result.style = textStyle;\n }\n\n return result;\n}\n</script>"],"mappings":";;;AAOM,SAAmB,UAAU,SAAA;;
|
|
1
|
+
{"version":3,"file":"text.ce.js","names":[],"sources":["../../../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={parseDynamicValue(component.value, object)} ...getComponentStyle(component) />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { parseDynamicValue } from \"./parse-value\";\n\nconst { object } = defineProps();\nconst component = object._component;\n\n/**\n * Parses a numeric style value that can be a number or a string\n * \n * If the value is a string, it may contain dynamic references like {hp}\n * which need to be parsed using parseDynamicValue. If it's a number,\n * it's returned as-is wrapped in a computed.\n * \n * @param value - Numeric value (number or string)\n * @param object - Object to resolve dynamic references from\n * @returns Computed signal with the numeric value\n */\nconst parseNumericStyleValue = (value, object) => {\n if (value === undefined || value === null) {\n return undefined;\n }\n \n if (typeof value === 'number') {\n return value;\n }\n \n if (typeof value === 'string') {\n // Check if it contains dynamic references\n if (value.includes('{')) {\n // Parse dynamic value and convert to number\n const parsed = parseDynamicValue(value, object);\n return computed(() => {\n const str = parsed();\n const num = parseFloat(str);\n return isNaN(num) ? 0 : num;\n });\n } else {\n // Simple string number, convert directly\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n }\n }\n \n return value;\n};\n\n/**\n * Maps component style properties to Canvas Engine Text component props\n * \n * Converts TextComponentOptions from the server to the format expected\n * by the Canvas Engine Text component. Supports all text styling properties\n * including fill, fontSize, fontFamily, fontStyle, fontWeight, stroke,\n * opacity, wordWrap, and align. Also supports dynamic values (number | string)\n * for numeric properties like fontSize and opacity.\n * \n * @param component - Component definition with style property\n * @returns Object with Text component props\n * \n * @example\n * ```ts\n * // Component with style\n * const component = {\n * style: {\n * fill: '#000000',\n * fontSize: 20,\n * fontFamily: 'Arial',\n * fontWeight: 'bold'\n * }\n * };\n * \n * const props = getComponentStyle(component);\n * // Returns: { color: '#000000', size: 20, fontFamily: 'Arial', style: { fontWeight: 'bold' } }\n * \n * // Component with dynamic fontSize\n * const component2 = {\n * style: {\n * fill: '#000000',\n * fontSize: '{hp}', // Will be resolved from object.hp\n * opacity: '0.8'\n * }\n * };\n * ```\n */\nconst getComponentStyle = (component) => {\n if (!component.style) {\n return {};\n }\n\n const style = component.style;\n const result = {};\n\n // Map fill to color (shortcut property)\n // fill can be a string (hex color) or a dynamic string\n if (style.fill !== undefined) {\n if (typeof style.fill === 'string' && style.fill.includes('{')) {\n result.color = parseDynamicValue(style.fill, object);\n } else {\n result.color = style.fill;\n }\n }\n\n // Map fontSize to size (shortcut property)\n // fontSize can be number or string (with dynamic references)\n if (style.fontSize !== undefined) {\n const fontSizeValue = parseNumericStyleValue(style.fontSize, object);\n if (fontSizeValue !== undefined) {\n result.size = fontSizeValue;\n }\n }\n\n // Map fontFamily (shortcut property)\n if (style.fontFamily !== undefined) {\n if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {\n result.fontFamily = parseDynamicValue(style.fontFamily, object);\n } else {\n result.fontFamily = style.fontFamily;\n }\n }\n\n // Build style object for PixiJS Text properties\n const textStyle = {};\n\n // Font style properties\n if (style.fontStyle !== undefined) {\n if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {\n textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);\n } else {\n textStyle.fontStyle = style.fontStyle;\n }\n }\n\n if (style.fontWeight !== undefined) {\n if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {\n textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);\n } else if (typeof style.fontWeight === 'number') {\n textStyle.fontWeight = style.fontWeight;\n } else {\n textStyle.fontWeight = style.fontWeight;\n }\n }\n\n // Stroke properties\n if (style.stroke !== undefined) {\n if (typeof style.stroke === 'string' && style.stroke.includes('{')) {\n textStyle.stroke = parseDynamicValue(style.stroke, object);\n } else {\n textStyle.stroke = style.stroke;\n }\n }\n\n // Opacity (can be number or string)\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n // Word wrap\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n // Text alignment\n if (style.align !== undefined) {\n if (typeof style.align === 'string' && style.align.includes('{')) {\n textStyle.align = parseDynamicValue(style.align, object);\n } else {\n textStyle.align = style.align;\n }\n }\n\n // Only add style prop if there are style properties\n if (Object.keys(textStyle).length > 0) {\n result.style = textStyle;\n }\n\n return result;\n}\n</script>"],"mappings":";;;AAOM,SAAmB,UAAU,SAAA;;CAGhC,MAAS,EAAA,WADV,eAAA,QACmC,EAAG;CACxC,MAAE,YAAA,OAAA;CACF,MAAM,0BAA0B,OAAI,WAAQ;AACzC,MAAK,UAAS,KAAA,KAAU,UAAM,KACzB;AAEJ,MAAA,OAAW,UAAU,SACrB,QAAM;AAER,MAAA,OA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,WAAc,KAAA,EAClB,KAAK,OAAO,MAAE,WAAY,YAAY,MAAQ,OAAA,SAAA,IAAA,CAC7C,WAAc,SAAC,kBAAW,MAAA,QAAA,OAAA;MAGxB,WAAK,SAAA,MAAA;;GAKR,MAAI,eAAkB,uBAAiB,MAAA,SAAA,OAAA;AACvC,OAAA,iBAAsB,KAAA,EACrB,WAAc,UAAK;;AAIvB,MAAI,MAAA,aAAA,KAAA,EACJ,WAAA,WAAA,MAAA;AAGA,MAAI,MAAM,UAAU,KAAA,EAChB,KAAI,OAAO,MAAM,UAAU,YAAY,MAAK,MAAM,SAAU,IAAC,CACzD,WAAO,QAAW,kBAAE,MAAkB,OAAM,OAAY;MAG5D,WAAA,QAAA,MAAA;AAIJ,MAAA,OAAM,KAAU,UAAI,CAAA,SAAA,EAAA,QAAA,QAAA;AAGpB,SAAI;;AAGA,QADI,EAAU,MAAA;EAAA,MAAY,eAAiB,kBAAkB,UAAO,OAAA,OAAA,CAAA;EAAA,GAAA,kBAAA,UAAA;EAAA,CAC7D"}
|
|
@@ -5,13 +5,10 @@ import { Container, Rect, computed, h, useDefineProps, useProps } from "canvasen
|
|
|
5
5
|
//#region src/components/gui/box.ce
|
|
6
6
|
function component($$props) {
|
|
7
7
|
useProps($$props);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _a;
|
|
13
|
-
return ((_a = engine.globalConfig.gui) === null || _a === void 0 ? void 0 : _a.windowColor) || (color === null || color === void 0 ? void 0 : color()) || "#1a1a2e";
|
|
14
|
-
});
|
|
8
|
+
const { width, height, children, color, top, left } = useDefineProps($$props)();
|
|
9
|
+
const engine = inject(RpgClientEngine);
|
|
10
|
+
const child = children[0];
|
|
11
|
+
const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || "#1a1a2e");
|
|
15
12
|
return h(Container, {
|
|
16
13
|
positionType: "absolute",
|
|
17
14
|
top,
|