@rpgjs/vue 5.0.0-alpha.24 → 5.0.0-alpha.25
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/package.json +3 -3
- package/dist/VueGui.d.ts +0 -33
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -375
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -32
- package/dist/index3.js.map +0 -1
- package/dist/provider.d.ts +0 -101
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/vue",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.25",
|
|
4
4
|
"description": "Vue.js integration for RPGJS - Allows rendering Vue components over the game canvas",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"vue": "^3.2.25"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rpgjs/client": "5.0.0-alpha.
|
|
26
|
-
"@rpgjs/common": "5.0.0-alpha.
|
|
25
|
+
"@rpgjs/client": "5.0.0-alpha.25",
|
|
26
|
+
"@rpgjs/common": "5.0.0-alpha.25",
|
|
27
27
|
"rxjs": "^7.8.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/dist/VueGui.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Context } from '@rpgjs/client';
|
|
2
|
-
export declare const VueGuiToken = "VueGuiToken";
|
|
3
|
-
interface VueGuiOptions {
|
|
4
|
-
/** The HTML element where Vue components will be mounted */
|
|
5
|
-
mountElement?: HTMLElement | string;
|
|
6
|
-
/** Custom CSS selector for the mount element */
|
|
7
|
-
selector?: string;
|
|
8
|
-
/** Whether to create a new div element if none is found */
|
|
9
|
-
createIfNotFound?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare class VueGui {
|
|
12
|
-
private context;
|
|
13
|
-
private options;
|
|
14
|
-
private clientEngine;
|
|
15
|
-
private parentGui;
|
|
16
|
-
private app;
|
|
17
|
-
private vm;
|
|
18
|
-
private socket;
|
|
19
|
-
constructor(context: Context, options?: VueGuiOptions);
|
|
20
|
-
mount(): void;
|
|
21
|
-
private getMountElement;
|
|
22
|
-
private getInjectObject;
|
|
23
|
-
private createObjectsObservable;
|
|
24
|
-
private createCurrentPlayerObservable;
|
|
25
|
-
private createKeypressObservable;
|
|
26
|
-
private createSoundService;
|
|
27
|
-
private propagateEvent;
|
|
28
|
-
private tooltipPosition;
|
|
29
|
-
private tooltipFilter;
|
|
30
|
-
_setSceneReady(): void;
|
|
31
|
-
set gui(val: any);
|
|
32
|
-
}
|
|
33
|
-
export {};
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index2.js
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { createApp, createElementBlock, openBlock, createElementVNode, Fragment, renderList, createBlock, createCommentVNode, resolveDynamicComponent, normalizeProps, mergeProps, normalizeStyle } from 'vue';
|
|
2
|
-
import { isFunction } from '@rpgjs/common';
|
|
3
|
-
import { inject, RpgClientEngine, RpgGui } from '@rpgjs/client';
|
|
4
|
-
import { Observable } from 'rxjs';
|
|
5
|
-
|
|
6
|
-
const VueGuiToken = "VueGuiToken";
|
|
7
|
-
const _hoisted_1 = {
|
|
8
|
-
id: "tooltips",
|
|
9
|
-
style: { "position": "absolute", "top": "0", "left": "0" }
|
|
10
|
-
};
|
|
11
|
-
function render(_ctx, _cache) {
|
|
12
|
-
return openBlock(), createElementBlock(
|
|
13
|
-
"div",
|
|
14
|
-
{},
|
|
15
|
-
[
|
|
16
|
-
(openBlock(true), createElementBlock(
|
|
17
|
-
Fragment,
|
|
18
|
-
null,
|
|
19
|
-
renderList(_ctx.fixedGui, (ui) => {
|
|
20
|
-
return openBlock(), createElementBlock(
|
|
21
|
-
Fragment,
|
|
22
|
-
null,
|
|
23
|
-
[
|
|
24
|
-
ui.display ? (openBlock(), createBlock(
|
|
25
|
-
resolveDynamicComponent(ui.name),
|
|
26
|
-
normalizeProps(mergeProps({ key: 0, style: { pointerEvents: "auto" } }, ui.data)),
|
|
27
|
-
null,
|
|
28
|
-
16
|
|
29
|
-
/* FULL_PROPS */
|
|
30
|
-
)) : createCommentVNode("v-if", true)
|
|
31
|
-
],
|
|
32
|
-
64
|
|
33
|
-
/* STABLE_FRAGMENT */
|
|
34
|
-
);
|
|
35
|
-
}),
|
|
36
|
-
256
|
|
37
|
-
/* UNKEYED_FRAGMENT */
|
|
38
|
-
)),
|
|
39
|
-
createElementVNode("div", _hoisted_1, [
|
|
40
|
-
(openBlock(true), createElementBlock(
|
|
41
|
-
Fragment,
|
|
42
|
-
null,
|
|
43
|
-
renderList(_ctx.attachedGui, (ui) => {
|
|
44
|
-
return openBlock(), createElementBlock(
|
|
45
|
-
Fragment,
|
|
46
|
-
null,
|
|
47
|
-
[
|
|
48
|
-
ui.display ? (openBlock(true), createElementBlock(
|
|
49
|
-
Fragment,
|
|
50
|
-
{ key: 0 },
|
|
51
|
-
renderList(_ctx.tooltipFilter(_ctx.tooltips, ui), (tooltip) => {
|
|
52
|
-
return openBlock(), createElementBlock(
|
|
53
|
-
"div",
|
|
54
|
-
{
|
|
55
|
-
style: normalizeStyle(_ctx.tooltipPosition(tooltip.position))
|
|
56
|
-
},
|
|
57
|
-
[
|
|
58
|
-
(openBlock(), createBlock(
|
|
59
|
-
resolveDynamicComponent(ui.name),
|
|
60
|
-
mergeProps({ ...ui.data, spriteData: tooltip, style: { pointerEvents: "auto" } }, {
|
|
61
|
-
ref_for: true,
|
|
62
|
-
ref: ui.name
|
|
63
|
-
}),
|
|
64
|
-
null,
|
|
65
|
-
16
|
|
66
|
-
/* FULL_PROPS */
|
|
67
|
-
))
|
|
68
|
-
],
|
|
69
|
-
4
|
|
70
|
-
/* STYLE */
|
|
71
|
-
);
|
|
72
|
-
}),
|
|
73
|
-
256
|
|
74
|
-
/* UNKEYED_FRAGMENT */
|
|
75
|
-
)) : createCommentVNode("v-if", true)
|
|
76
|
-
],
|
|
77
|
-
64
|
|
78
|
-
/* STABLE_FRAGMENT */
|
|
79
|
-
);
|
|
80
|
-
}),
|
|
81
|
-
256
|
|
82
|
-
/* UNKEYED_FRAGMENT */
|
|
83
|
-
))
|
|
84
|
-
])
|
|
85
|
-
],
|
|
86
|
-
32
|
|
87
|
-
/* HYDRATE_EVENTS */
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
class VueGui {
|
|
91
|
-
constructor(context, options = {}) {
|
|
92
|
-
this.context = context;
|
|
93
|
-
this.options = options;
|
|
94
|
-
}
|
|
95
|
-
mount() {
|
|
96
|
-
this.clientEngine = inject(RpgClientEngine);
|
|
97
|
-
this.parentGui = inject(RpgGui);
|
|
98
|
-
this.parentGui._setVueGuiInstance(this);
|
|
99
|
-
const mountElement = this.getMountElement();
|
|
100
|
-
if (!mountElement) {
|
|
101
|
-
throw new Error("No mount element found for VueGui. Please provide a valid element or selector.");
|
|
102
|
-
}
|
|
103
|
-
const guiVue = this.parentGui.extraGuis;
|
|
104
|
-
const obj = {
|
|
105
|
-
render,
|
|
106
|
-
data() {
|
|
107
|
-
return {
|
|
108
|
-
gui: {},
|
|
109
|
-
tooltips: []
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
provide: () => {
|
|
113
|
-
return this.getInjectObject();
|
|
114
|
-
},
|
|
115
|
-
computed: {
|
|
116
|
-
fixedGui() {
|
|
117
|
-
return Object.values(this.gui).filter((gui) => !gui.attachToSprite);
|
|
118
|
-
},
|
|
119
|
-
attachedGui() {
|
|
120
|
-
return Object.values(this.gui).filter((gui) => gui.attachToSprite);
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
methods: {
|
|
124
|
-
tooltipPosition: this.tooltipPosition.bind(this),
|
|
125
|
-
tooltipFilter: this.tooltipFilter.bind(this)
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
this.app = createApp(obj);
|
|
129
|
-
for (let ui of guiVue) {
|
|
130
|
-
this.app.component(ui.name, ui.component);
|
|
131
|
-
}
|
|
132
|
-
this.app.directive("propagate", {
|
|
133
|
-
mounted: (el, binding) => {
|
|
134
|
-
el.eventListeners = {};
|
|
135
|
-
const mouseEvents = ["click", "mousedown", "mouseup", "mousemove", "wheel"];
|
|
136
|
-
mouseEvents.forEach((eventType) => {
|
|
137
|
-
const callback = (ev) => {
|
|
138
|
-
this.propagateEvent(ev);
|
|
139
|
-
};
|
|
140
|
-
el.eventListeners[eventType] = callback;
|
|
141
|
-
el.addEventListener(eventType, callback);
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
unmounted(el, binding) {
|
|
145
|
-
const mouseEvents = ["click", "mousedown", "mouseup", "mousemove", "wheel"];
|
|
146
|
-
mouseEvents.forEach((eventType) => {
|
|
147
|
-
const callback = el.eventListeners[eventType];
|
|
148
|
-
if (callback) {
|
|
149
|
-
el.removeEventListener(eventType, callback);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
this.vm = this.app.mount(mountElement);
|
|
155
|
-
this.parentGui._initializeVueComponents();
|
|
156
|
-
}
|
|
157
|
-
getMountElement() {
|
|
158
|
-
const { mountElement, selector, createIfNotFound = true } = this.options;
|
|
159
|
-
if (mountElement) {
|
|
160
|
-
if (typeof mountElement === "string") {
|
|
161
|
-
const element = document.querySelector(mountElement);
|
|
162
|
-
if (element) return element;
|
|
163
|
-
} else {
|
|
164
|
-
return mountElement;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (selector) {
|
|
168
|
-
const element = document.querySelector(selector);
|
|
169
|
-
if (element) return element;
|
|
170
|
-
}
|
|
171
|
-
const defaultElement = document.querySelector("#vue-gui-overlay");
|
|
172
|
-
if (defaultElement) return defaultElement;
|
|
173
|
-
if (createIfNotFound) {
|
|
174
|
-
const newElement = document.createElement("div");
|
|
175
|
-
newElement.id = "vue-gui-overlay";
|
|
176
|
-
newElement.style.position = "absolute";
|
|
177
|
-
newElement.style.top = "0";
|
|
178
|
-
newElement.style.left = "0";
|
|
179
|
-
newElement.style.width = "100%";
|
|
180
|
-
newElement.style.height = "100%";
|
|
181
|
-
newElement.style.pointerEvents = "none";
|
|
182
|
-
const gameContainer = document.querySelector("#rpg");
|
|
183
|
-
if (gameContainer) {
|
|
184
|
-
gameContainer.appendChild(newElement);
|
|
185
|
-
return newElement;
|
|
186
|
-
}
|
|
187
|
-
document.body.appendChild(newElement);
|
|
188
|
-
return newElement;
|
|
189
|
-
}
|
|
190
|
-
throw new Error("Could not find or create mount element for VueGui");
|
|
191
|
-
}
|
|
192
|
-
getInjectObject() {
|
|
193
|
-
return {
|
|
194
|
-
// Legacy injections (for backward compatibility)
|
|
195
|
-
engine: this.clientEngine,
|
|
196
|
-
socket: this.clientEngine.socket,
|
|
197
|
-
gui: this.parentGui,
|
|
198
|
-
// Standard RPGJS Vue injections
|
|
199
|
-
rpgEngine: this.clientEngine,
|
|
200
|
-
rpgSocket: () => this.clientEngine.socket,
|
|
201
|
-
rpgGui: this.parentGui,
|
|
202
|
-
rpgScene: () => this.clientEngine.scene,
|
|
203
|
-
rpgResource: {
|
|
204
|
-
spritesheets: this.clientEngine.spritesheets,
|
|
205
|
-
sounds: this.clientEngine.sounds
|
|
206
|
-
},
|
|
207
|
-
rpgObjects: this.createObjectsObservable(),
|
|
208
|
-
rpgCurrentPlayer: this.createCurrentPlayerObservable(),
|
|
209
|
-
rpgGuiClose: (name, data) => {
|
|
210
|
-
this.parentGui.guiClose(name, data);
|
|
211
|
-
},
|
|
212
|
-
rpgGuiInteraction: (guiId, name, data = {}) => {
|
|
213
|
-
this.parentGui.guiInteraction(guiId, name, data);
|
|
214
|
-
},
|
|
215
|
-
rpgKeypress: this.createKeypressObservable(),
|
|
216
|
-
rpgSound: this.createSoundService()
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
createObjectsObservable() {
|
|
220
|
-
const scene = this.clientEngine.scene;
|
|
221
|
-
if (!scene) return null;
|
|
222
|
-
return new Observable((observer) => {
|
|
223
|
-
const subscription1 = scene.players.observable.subscribe((players) => {
|
|
224
|
-
const objects = {};
|
|
225
|
-
for (const [id, player] of Object.entries(players)) {
|
|
226
|
-
objects[id] = {
|
|
227
|
-
object: player,
|
|
228
|
-
paramsChanged: player
|
|
229
|
-
// For simplicity, could be enhanced to track actual changes
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
observer.next(objects);
|
|
233
|
-
});
|
|
234
|
-
const subscription2 = scene.events.observable.subscribe((events) => {
|
|
235
|
-
const objects = {};
|
|
236
|
-
for (const [id, event] of Object.entries(events)) {
|
|
237
|
-
objects[id] = {
|
|
238
|
-
object: event,
|
|
239
|
-
paramsChanged: event
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
observer.next(objects);
|
|
243
|
-
});
|
|
244
|
-
return () => {
|
|
245
|
-
subscription1.unsubscribe();
|
|
246
|
-
subscription2.unsubscribe();
|
|
247
|
-
};
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
createCurrentPlayerObservable() {
|
|
251
|
-
const scene = this.clientEngine.scene;
|
|
252
|
-
if (!scene) return null;
|
|
253
|
-
return new Observable((observer) => {
|
|
254
|
-
const subscription = scene.currentPlayer.observable.subscribe((player) => {
|
|
255
|
-
if (player) {
|
|
256
|
-
observer.next({
|
|
257
|
-
object: player,
|
|
258
|
-
paramsChanged: player
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
return () => subscription.unsubscribe();
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
createKeypressObservable() {
|
|
266
|
-
return new Observable((observer) => {
|
|
267
|
-
const keyHandler = (event) => {
|
|
268
|
-
const keyMap = this.clientEngine.globalConfig?.keyboardControls || {
|
|
269
|
-
up: "up",
|
|
270
|
-
down: "down",
|
|
271
|
-
left: "left",
|
|
272
|
-
right: "right",
|
|
273
|
-
action: "space",
|
|
274
|
-
escape: "escape"
|
|
275
|
-
};
|
|
276
|
-
const inputName = event.key.toLowerCase();
|
|
277
|
-
let control = null;
|
|
278
|
-
for (const [actionName, keyName] of Object.entries(keyMap)) {
|
|
279
|
-
if (keyName === inputName || keyName === event.code.toLowerCase()) {
|
|
280
|
-
control = {
|
|
281
|
-
actionName,
|
|
282
|
-
options: {}
|
|
283
|
-
};
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (control) {
|
|
288
|
-
observer.next({
|
|
289
|
-
inputName,
|
|
290
|
-
control
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
document.addEventListener("keydown", keyHandler);
|
|
295
|
-
return () => {
|
|
296
|
-
document.removeEventListener("keydown", keyHandler);
|
|
297
|
-
};
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
createSoundService() {
|
|
301
|
-
return {
|
|
302
|
-
get: (id) => {
|
|
303
|
-
const sound = this.clientEngine.sounds.get(id);
|
|
304
|
-
return {
|
|
305
|
-
play: () => {
|
|
306
|
-
if (sound && sound.play) {
|
|
307
|
-
sound.play();
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
stop: () => {
|
|
311
|
-
if (sound && sound.stop) {
|
|
312
|
-
sound.stop();
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
pause: () => {
|
|
316
|
-
if (sound && sound.pause) {
|
|
317
|
-
sound.pause();
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
},
|
|
322
|
-
play: (id) => {
|
|
323
|
-
const sound = this.clientEngine.sounds.get(id);
|
|
324
|
-
if (sound && sound.play) {
|
|
325
|
-
sound.play();
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
propagateEvent(event) {
|
|
331
|
-
if (this.clientEngine.renderer) {
|
|
332
|
-
const canvas = document.querySelector("#rpg canvas");
|
|
333
|
-
if (canvas && canvas.getBoundingClientRect) {
|
|
334
|
-
const rect = canvas.getBoundingClientRect();
|
|
335
|
-
const mouseEvent = event;
|
|
336
|
-
const newEvent = new MouseEvent(event.type, {
|
|
337
|
-
bubbles: event.bubbles,
|
|
338
|
-
cancelable: event.cancelable,
|
|
339
|
-
clientX: mouseEvent.clientX - rect.left,
|
|
340
|
-
clientY: mouseEvent.clientY - rect.top,
|
|
341
|
-
button: mouseEvent.button,
|
|
342
|
-
buttons: mouseEvent.buttons
|
|
343
|
-
});
|
|
344
|
-
canvas.dispatchEvent(newEvent);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
tooltipPosition(position) {
|
|
349
|
-
return {
|
|
350
|
-
left: position.x + "px",
|
|
351
|
-
top: position.y + "px",
|
|
352
|
-
position: "absolute"
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
tooltipFilter(tooltips, ui) {
|
|
356
|
-
return tooltips.filter((tooltip) => {
|
|
357
|
-
return true;
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
_setSceneReady() {
|
|
361
|
-
if (this.clientEngine.scene) {
|
|
362
|
-
this.vm.tooltips = [];
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
set gui(val) {
|
|
366
|
-
for (let key in val) {
|
|
367
|
-
if (isFunction(val[key].component)) continue;
|
|
368
|
-
this.vm.gui[key] = val[key];
|
|
369
|
-
}
|
|
370
|
-
this.vm.gui = Object.assign({}, this.vm.gui);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
export { VueGui, VueGuiToken };
|
|
375
|
-
//# sourceMappingURL=index2.js.map
|
package/dist/index2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","sources":["../src/VueGui.ts"],"sourcesContent":["import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveDynamicComponent as _resolveDynamicComponent, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createBlock as _createBlock, mergeProps as _mergeProps, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode } from \"vue\"\nimport { App, ComponentPublicInstance, createApp } from 'vue'\nimport { isFunction, RpgCommonPlayer } from '@rpgjs/common'\nimport { RpgClientEngine, RpgGui, inject, Context } from '@rpgjs/client'\nimport { Observable } from 'rxjs'\n\nexport const VueGuiToken = \"VueGuiToken\"\n\ninterface VueInstance extends ComponentPublicInstance {\n gui: GuiList,\n tooltips: RpgCommonPlayer[]\n}\n\ninterface GuiOptions {\n data: any,\n attachToSprite: boolean\n display: boolean,\n name: string\n}\n\ninterface GuiList {\n [guiName: string]: GuiOptions\n}\n\ninterface VueGuiOptions {\n /** The HTML element where Vue components will be mounted */\n mountElement?: HTMLElement | string\n /** Custom CSS selector for the mount element */\n selector?: string\n /** Whether to create a new div element if none is found */\n createIfNotFound?: boolean\n}\n\nconst _hoisted_1 = {\n id: \"tooltips\",\n style: { \"position\": \"absolute\", \"top\": \"0\", \"left\": \"0\" }\n}\n\nfunction render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"div\", {}, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.fixedGui, (ui: any) => {\n return (_openBlock(), _createElementBlock(_Fragment, null, [\n (ui.display)\n ? (_openBlock(), _createBlock(_resolveDynamicComponent(ui.name), _normalizeProps(_mergeProps({ key: 0, style: { pointerEvents: 'auto' } }, ui.data)), null, 16 /* FULL_PROPS */))\n : _createCommentVNode(\"v-if\", true)\n ], 64 /* STABLE_FRAGMENT */))\n }), 256 /* UNKEYED_FRAGMENT */)),\n _createElementVNode(\"div\", _hoisted_1, [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.attachedGui, (ui: any) => {\n return (_openBlock(), _createElementBlock(_Fragment, null, [\n (ui.display)\n ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(_ctx.tooltipFilter(_ctx.tooltips, ui), (tooltip: any) => {\n return (_openBlock(), _createElementBlock(\"div\", {\n style: _normalizeStyle(_ctx.tooltipPosition(tooltip.position))\n }, [\n (_openBlock(), _createBlock(_resolveDynamicComponent(ui.name), _mergeProps({ ...ui.data, spriteData: tooltip, style: { pointerEvents: 'auto' } }, {\n ref_for: true,\n ref: ui.name\n }), null, 16 /* FULL_PROPS */))\n ], 4 /* STYLE */))\n }), 256 /* UNKEYED_FRAGMENT */))\n : _createCommentVNode(\"v-if\", true)\n ], 64 /* STABLE_FRAGMENT */))\n }), 256 /* UNKEYED_FRAGMENT */))\n ])\n ], 32 /* HYDRATE_EVENTS */))\n}\n\nexport class VueGui {\n private clientEngine: RpgClientEngine\n private parentGui: RpgGui\n private app: App\n private vm: VueInstance\n private socket\n\n constructor(private context: Context, private options: VueGuiOptions = {}) {\n \n }\n\n mount() {\n this.clientEngine = inject(RpgClientEngine)\n this.parentGui = inject(RpgGui)\n \n // Establish connection with RpgGui for Vue component management\n this.parentGui._setVueGuiInstance(this);\n \n // Get or create mount element\n const mountElement = this.getMountElement()\n if (!mountElement) {\n throw new Error('No mount element found for VueGui. Please provide a valid element or selector.')\n }\n\n // Get all GUI components from the parent GUI service\n const guiVue = this.parentGui.extraGuis\n\n const obj = {\n render,\n data() {\n return {\n gui: {},\n tooltips: []\n }\n },\n provide: () => {\n return this.getInjectObject()\n },\n computed: {\n fixedGui() {\n return Object.values(this.gui).filter((gui: any) => !gui.attachToSprite)\n },\n attachedGui() {\n return Object.values(this.gui).filter((gui: any) => gui.attachToSprite)\n }\n },\n methods: {\n tooltipPosition: this.tooltipPosition.bind(this),\n tooltipFilter: this.tooltipFilter.bind(this)\n }\n }\n\n this.app = createApp(obj)\n\n for (let ui of guiVue) {\n this.app.component(ui.name, ui.component)\n }\n\n // Add propagate directive for event handling\n this.app.directive('propagate', {\n mounted: (el, binding) => {\n el.eventListeners = {};\n const mouseEvents = ['click', 'mousedown', 'mouseup', 'mousemove', 'wheel'];\n mouseEvents.forEach(eventType => {\n const callback = (ev) => {\n // Propagate event to the game engine\n this.propagateEvent(ev);\n };\n el.eventListeners[eventType] = callback;\n el.addEventListener(eventType, callback);\n });\n },\n unmounted(el, binding) {\n const mouseEvents = ['click', 'mousedown', 'mouseup', 'mousemove', 'wheel'];\n mouseEvents.forEach(eventType => {\n const callback = el.eventListeners[eventType];\n if (callback) {\n el.removeEventListener(eventType, callback);\n }\n });\n }\n })\n\n this.vm = this.app.mount(mountElement) as VueInstance\n \n // Initialize Vue components after mounting\n this.parentGui._initializeVueComponents();\n }\n\n private getMountElement(): HTMLElement {\n const { mountElement, selector, createIfNotFound = true } = this.options\n\n // If mountElement is provided directly\n if (mountElement) {\n if (typeof mountElement === 'string') {\n const element = document.querySelector(mountElement) as HTMLElement\n if (element) return element\n } else {\n return mountElement\n }\n }\n\n // If selector is provided\n if (selector) {\n const element = document.querySelector(selector) as HTMLElement\n if (element) return element\n }\n\n // Default selector\n const defaultElement = document.querySelector('#vue-gui-overlay') as HTMLElement\n if (defaultElement) return defaultElement\n\n // Create element if not found and createIfNotFound is true\n if (createIfNotFound) {\n const newElement = document.createElement('div')\n newElement.id = 'vue-gui-overlay'\n newElement.style.position = 'absolute'\n newElement.style.top = '0'\n newElement.style.left = '0'\n newElement.style.width = '100%'\n newElement.style.height = '100%'\n newElement.style.pointerEvents = 'none' // Allow canvas events to pass through\n\n // Try to add to game container\n const gameContainer = document.querySelector('#rpg')\n if (gameContainer) {\n gameContainer.appendChild(newElement)\n return newElement\n }\n\n // Fallback to body\n document.body.appendChild(newElement)\n return newElement\n }\n\n throw new Error('Could not find or create mount element for VueGui')\n }\n\n private getInjectObject() {\n return {\n // Legacy injections (for backward compatibility)\n engine: this.clientEngine,\n socket: this.clientEngine.socket,\n gui: this.parentGui,\n\n // Standard RPGJS Vue injections\n rpgEngine: this.clientEngine,\n rpgSocket: () => this.clientEngine.socket,\n rpgGui: this.parentGui,\n rpgScene: () => this.clientEngine.scene,\n rpgResource: {\n spritesheets: this.clientEngine.spritesheets,\n sounds: this.clientEngine.sounds\n },\n rpgObjects: this.createObjectsObservable(),\n rpgCurrentPlayer: this.createCurrentPlayerObservable(),\n rpgGuiClose: (name: string, data?: any) => {\n this.parentGui.guiClose(name, data)\n },\n rpgGuiInteraction: (guiId: string, name: string, data: any = {}) => {\n this.parentGui.guiInteraction(guiId, name, data)\n },\n rpgKeypress: this.createKeypressObservable(),\n rpgSound: this.createSoundService()\n }\n }\n\n private createObjectsObservable() {\n // Combine players and events into a single observable\n const scene = this.clientEngine.scene\n if (!scene) return null\n\n // Create an observable that merges players and events\n return new Observable((observer) => {\n const subscription1 = scene.players.observable.subscribe((players) => {\n const objects = {}\n for (const [id, player] of Object.entries(players)) {\n objects[id] = {\n object: player,\n paramsChanged: player // For simplicity, could be enhanced to track actual changes\n }\n }\n observer.next(objects)\n })\n\n const subscription2 = scene.events.observable.subscribe((events) => {\n const objects = {}\n for (const [id, event] of Object.entries(events)) {\n objects[id] = {\n object: event,\n paramsChanged: event\n }\n }\n observer.next(objects)\n })\n\n return () => {\n subscription1.unsubscribe()\n subscription2.unsubscribe()\n }\n })\n }\n\n private createCurrentPlayerObservable() {\n const scene = this.clientEngine.scene\n if (!scene) return null\n\n return new Observable((observer) => {\n const subscription = scene.currentPlayer.observable.subscribe((player) => {\n if (player) {\n observer.next({\n object: player,\n paramsChanged: player\n })\n }\n })\n\n return () => subscription.unsubscribe()\n })\n }\n\n private createKeypressObservable() {\n return new Observable((observer) => {\n const keyHandler = (event: KeyboardEvent) => {\n // Map keyboard events to RPG controls\n const keyMap = this.clientEngine.globalConfig?.keyboardControls || {\n up: 'up',\n down: 'down', \n left: 'left',\n right: 'right',\n action: 'space',\n escape: 'escape'\n }\n\n const inputName = event.key.toLowerCase()\n let control: { actionName: string; options: any } | null = null\n\n // Find matching control\n for (const [actionName, keyName] of Object.entries(keyMap)) {\n if (keyName === inputName || keyName === event.code.toLowerCase()) {\n control = {\n actionName,\n options: {}\n }\n break\n }\n }\n\n if (control) {\n observer.next({\n inputName,\n control\n })\n }\n }\n\n document.addEventListener('keydown', keyHandler)\n \n return () => {\n document.removeEventListener('keydown', keyHandler)\n }\n })\n }\n\n private createSoundService() {\n return {\n get: (id: string) => {\n const sound = this.clientEngine.sounds.get(id)\n return {\n play: () => {\n if (sound && sound.play) {\n sound.play()\n }\n },\n stop: () => {\n if (sound && sound.stop) {\n sound.stop()\n }\n },\n pause: () => {\n if (sound && sound.pause) {\n sound.pause()\n }\n }\n }\n },\n play: (id: string) => {\n const sound = this.clientEngine.sounds.get(id)\n if (sound && sound.play) {\n sound.play()\n }\n }\n }\n }\n\n private propagateEvent(event: Event) {\n // Propagate mouse events to the canvas/engine\n // This allows interaction with the game through Vue components\n if (this.clientEngine.renderer) {\n // Find the actual canvas element in the DOM\n const canvas = document.querySelector('#rpg canvas') as HTMLCanvasElement;\n if (canvas && canvas.getBoundingClientRect) {\n const rect = canvas.getBoundingClientRect();\n const mouseEvent = event as MouseEvent\n \n // Create a new mouse event with adjusted coordinates\n const newEvent = new MouseEvent(event.type, {\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n clientX: mouseEvent.clientX - rect.left,\n clientY: mouseEvent.clientY - rect.top,\n button: mouseEvent.button,\n buttons: mouseEvent.buttons\n });\n canvas.dispatchEvent(newEvent);\n }\n }\n }\n\n private tooltipPosition(position: any) {\n return {\n left: position.x + 'px',\n top: position.y + 'px',\n position: 'absolute'\n }\n }\n\n private tooltipFilter(tooltips: any[], ui: any) {\n // Filter tooltips based on UI configuration\n return tooltips.filter(tooltip => {\n // Add filtering logic based on your requirements\n return true;\n });\n }\n\n _setSceneReady() {\n // Handle scene ready state for tooltips and other dynamic content\n if (this.clientEngine.scene) {\n // Subscribe to object changes for tooltips\n this.vm.tooltips = [];\n }\n }\n\n set gui(val: any) {\n for (let key in val) {\n // Ignore function components (they should only be handled by CanvasEngine)\n if (isFunction(val[key].component)) continue\n this.vm.gui[key] = val[key]\n }\n this.vm.gui = Object.assign({}, this.vm.gui)\n }\n}"],"names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","_resolveDynamicComponent","_normalizeProps","_mergeProps","_createCommentVNode","_createElementVNode","_normalizeStyle"],"mappings":";;;;;AAMO,MAAM,WAAA,GAAc;AA2B3B,MAAM,UAAA,GAAa;AAAA,EACf,EAAA,EAAI,UAAA;AAAA,EACJ,OAAO,EAAE,UAAA,EAAY,YAAY,KAAA,EAAO,GAAA,EAAK,QAAQ,GAAA;AACzD,CAAA;AAEA,SAAS,MAAA,CAAO,MAAM,MAAA,EAAQ;AAC1B,EAAA,OAAQA,WAAW,EAAGC,kBAAA;AAAA,IAAoB,KAAA;AAAA,IAAO,EAAC;AAAA,IAAG;AAAA,OAChDD,SAAA,CAAW,IAAI,CAAA,EAAGC,kBAAA;AAAA,QAAoBC,QAAA;AAAA,QAAW,IAAA;AAAA,QAAMC,UAAA,CAAY,IAAA,CAAK,QAAA,EAAU,CAAC,EAAA,KAAY;AAC5F,UAAA,OAAQH,WAAW,EAAGC,kBAAA;AAAA,YAAoBC,QAAA;AAAA,YAAW,IAAA;AAAA,YAAM;AAAA,cACtD,EAAA,CAAG,OAAA,IACGF,SAAA,EAAW,EAAGI,WAAA;AAAA,gBAAaC,uBAAA,CAAyB,GAAG,IAAI,CAAA;AAAA,gBAAGC,cAAA,CAAgBC,UAAA,CAAY,EAAE,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,EAAE,aAAA,EAAe,MAAA,EAAO,EAAE,EAAG,EAAA,CAAG,IAAI,CAAC,CAAA;AAAA,gBAAG,IAAA;AAAA,gBAAM;AAAA;AAAA,eAAmB,IAC7KC,kBAAA,CAAoB,MAAA,EAAQ,IAA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KACd;AAAA,EACJ;AAAA,EAEQ,aAAA,CAAc,UAAiB,EAAA,EAAS;AAE5C,IAAA,OAAO,QAAA,CAAS,OAAO,CAAA,OAAA,KAAW;AAE9B,MAAA,OAAO,IAAA;AAAA,IACX,CAAC,CAAA;AAAA,EACL;AAAA,EAEA,cAAA,GAAiB;AAEb,IAAA,IAAI,IAAA,CAAK,aAAa,KAAA,EAAO;AAEzB,MAAA,IAAA,CAAK,EAAA,CAAG,WAAW,EAAC;AAAA,IACxB;AAAA,EACJ;AAAA,EAEA,IAAI,IAAI,GAAA,EAAU;AACd,IAAA,KAAA,IAAS,OAAO,GAAA,EAAK;AAEjB,MAAA,IAAI,UAAA,CAAW,GAAA,CAAI,GAAG,CAAA,CAAE,SAAS,CAAA,EAAG;AACpC,MAAA,IAAA,CAAK,EAAA,CAAG,GAAA,CAAI,GAAG,CAAA,GAAI,IAAI,GAAG,CAAA;AAAA,IAC9B;AACA,IAAA,IAAA,CAAK,EAAA,CAAG,MAAM,MAAA,CAAO,MAAA,CAAO,EAAC,EAAG,IAAA,CAAK,GAAG,GAAG,CAAA;AAAA,EAC/C;AACJ;;;;"}
|
package/dist/index3.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { inject } from '@rpgjs/client';
|
|
2
|
-
import { VueGuiToken, VueGui } from './index2.js';
|
|
3
|
-
import { createModule } from '@rpgjs/common';
|
|
4
|
-
|
|
5
|
-
function provideVueGui(options = {}) {
|
|
6
|
-
return createModule("VueGui", [
|
|
7
|
-
{
|
|
8
|
-
client: {
|
|
9
|
-
engine: {
|
|
10
|
-
onStart() {
|
|
11
|
-
const vueGui = inject(VueGuiToken);
|
|
12
|
-
vueGui.mount();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
server: null
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
provide: VueGuiToken,
|
|
20
|
-
useFactory: (context) => {
|
|
21
|
-
if (context["side"] === "server") {
|
|
22
|
-
console.warn("VueGui is only available on client side");
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return new VueGui(context, options);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { provideVueGui };
|
|
32
|
-
//# sourceMappingURL=index3.js.map
|
package/dist/index3.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":["../src/provider.ts"],"sourcesContent":["import { Context, inject, RpgClient } from \"@rpgjs/client\"\nimport { VueGui, VueGuiToken } from \"./VueGui\"\nimport { createModule } from \"@rpgjs/common\"\n\ninterface VueGuiProviderOptions {\n /** The HTML element where Vue components will be mounted */\n mountElement?: HTMLElement | string\n /** Custom CSS selector for the mount element */\n selector?: string\n /** Whether to create a new div element if none is found */\n createIfNotFound?: boolean\n}\n\n/**\n * Creates a dependency injection configuration for Vue GUI overlay on the client side.\n * \n * This function allows you to render Vue.js components as overlays on top of the RPGJS game canvas.\n * It provides a seamless integration between Vue.js reactive components and the game engine,\n * allowing for rich user interfaces while maintaining game performance.\n * \n * The function sets up the necessary service providers for Vue GUI rendering, including:\n * - VueGuiToken: Provides the VueGui service with your custom mounting configuration\n * - Automatic component filtering: Separates Vue components from CanvasEngine components\n * - Event propagation: Ensures proper interaction between Vue components and game canvas\n * \n * **Design Concept:**\n * The function follows the provider pattern used throughout RPGJS, creating a modular way to inject\n * Vue GUI rendering capabilities into the client engine. It separates the concern of UI framework\n * (Vue.js) from game rendering (CanvasEngine), allowing developers to use modern web UI patterns\n * while leveraging the engine's performance.\n * \n * @param {VueGuiProviderOptions} options - Configuration options for Vue GUI mounting\n * @returns {Object} Dependency injection provider configuration\n * \n * @example\n * ```typescript\n * import { provideVueGui } from '@rpgjs/vue'\n * import { createModule } from '@rpgjs/common'\n * \n * // Basic usage with automatic element creation\n * export function provideVueUIModule() {\n * return createModule(\"VueUI\", [\n * provideVueGui({\n * selector: '#vue-gui-container',\n * createIfNotFound: true\n * })\n * ])\n * }\n * \n * // Advanced usage with custom mount element\n * export function provideCustomVueUI() {\n * return createModule(\"CustomVueUI\", [\n * provideVueGui({\n * mountElement: document.getElementById('my-ui-overlay'),\n * createIfNotFound: false\n * })\n * ])\n * }\n * \n * // Usage with CSS selector\n * export function provideModalVueUI() {\n * return createModule(\"ModalVueUI\", [\n * provideVueGui({\n * selector: '.modal-overlay',\n * createIfNotFound: true\n * })\n * ])\n * }\n * ```\n * \n * **Integration in your client:**\n * ```typescript\n * import { RpgClient } from '@rpgjs/client'\n * import { provideVueGui } from '@rpgjs/vue'\n * \n * @RpgClient({\n * providers: [\n * provideVueGui({\n * selector: '#vue-gui-overlay'\n * })\n * ],\n * gui: [\n * // Vue components will be automatically handled by VueGui\n * InventoryVueComponent,\n * // CanvasEngine components continue to work normally\n * DialogCanvasComponent\n * ]\n * })\n * export class MyRpgClient {}\n * ```\n * \n * **Available injections in Vue components:**\n * - `engine`: RpgClientEngine instance for game interactions\n * - `socket`: WebSocket connection for server communication\n * - `gui`: RpgGui instance for GUI management\n * \n * **Event propagation:**\n * Use the `v-propagate` directive in Vue components to ensure mouse/keyboard events\n * are properly forwarded to the game canvas when needed.\n * \n * @since 5.0.0\n * @see {@link VueGuiProviderOptions} for configuration options\n * @see {@link VueGui} for the main service class\n */\n\nexport function provideVueGui(options: VueGuiProviderOptions = {}) {\n return createModule('VueGui',[\n {\n client: {\n engine: {\n onStart() {\n const vueGui = inject<VueGui>(VueGuiToken);\n vueGui.mount()\n }\n }\n } as RpgClient,\n server: null\n },\n {\n provide: VueGuiToken,\n useFactory: (context: Context) => {\n // Only create VueGui on client side\n if (context['side'] === 'server') {\n console.warn('VueGui is only available on client side')\n return null\n }\n return new VueGui(context, options)\n },\n }\n ])\n}"],"names":[],"mappings":";;;;AAyGO,SAAS,aAAA,CAAc,OAAA,GAAiC,EAAC,EAAG;AAC/D,EAAA,OAAO,aAAa,QAAA,EAAS;AAAA,IACzB;AAAA,MACI,MAAA,EAAQ;AAAA,QACJ,MAAA,EAAQ;AAAA,UACJ,OAAA,GAAU;AACN,YAAA,MAAM,MAAA,GAAS,OAAe,WAAW,CAAA;AACzC,YAAA,MAAA,CAAO,KAAA,EAAM;AAAA,UACjB;AAAA;AACJ,OACJ;AAAA,MACA,MAAA,EAAQ;AAAA,KACZ;AAAA,IACA;AAAA,MACI,OAAA,EAAS,WAAA;AAAA,MACT,UAAA,EAAY,CAAC,OAAA,KAAqB;AAE9B,QAAA,IAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,QAAA,EAAU;AAC9B,UAAA,OAAA,CAAQ,KAAK,yCAAyC,CAAA;AACtD,UAAA,OAAO,IAAA;AAAA,QACX;AACA,QAAA,OAAO,IAAI,MAAA,CAAO,OAAA,EAAS,OAAO,CAAA;AAAA,MACtC;AAAA;AACJ,GACH,CAAA;AACL;;;;"}
|
package/dist/provider.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
interface VueGuiProviderOptions {
|
|
2
|
-
/** The HTML element where Vue components will be mounted */
|
|
3
|
-
mountElement?: HTMLElement | string;
|
|
4
|
-
/** Custom CSS selector for the mount element */
|
|
5
|
-
selector?: string;
|
|
6
|
-
/** Whether to create a new div element if none is found */
|
|
7
|
-
createIfNotFound?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Creates a dependency injection configuration for Vue GUI overlay on the client side.
|
|
11
|
-
*
|
|
12
|
-
* This function allows you to render Vue.js components as overlays on top of the RPGJS game canvas.
|
|
13
|
-
* It provides a seamless integration between Vue.js reactive components and the game engine,
|
|
14
|
-
* allowing for rich user interfaces while maintaining game performance.
|
|
15
|
-
*
|
|
16
|
-
* The function sets up the necessary service providers for Vue GUI rendering, including:
|
|
17
|
-
* - VueGuiToken: Provides the VueGui service with your custom mounting configuration
|
|
18
|
-
* - Automatic component filtering: Separates Vue components from CanvasEngine components
|
|
19
|
-
* - Event propagation: Ensures proper interaction between Vue components and game canvas
|
|
20
|
-
*
|
|
21
|
-
* **Design Concept:**
|
|
22
|
-
* The function follows the provider pattern used throughout RPGJS, creating a modular way to inject
|
|
23
|
-
* Vue GUI rendering capabilities into the client engine. It separates the concern of UI framework
|
|
24
|
-
* (Vue.js) from game rendering (CanvasEngine), allowing developers to use modern web UI patterns
|
|
25
|
-
* while leveraging the engine's performance.
|
|
26
|
-
*
|
|
27
|
-
* @param {VueGuiProviderOptions} options - Configuration options for Vue GUI mounting
|
|
28
|
-
* @returns {Object} Dependency injection provider configuration
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { provideVueGui } from '@rpgjs/vue'
|
|
33
|
-
* import { createModule } from '@rpgjs/common'
|
|
34
|
-
*
|
|
35
|
-
* // Basic usage with automatic element creation
|
|
36
|
-
* export function provideVueUIModule() {
|
|
37
|
-
* return createModule("VueUI", [
|
|
38
|
-
* provideVueGui({
|
|
39
|
-
* selector: '#vue-gui-container',
|
|
40
|
-
* createIfNotFound: true
|
|
41
|
-
* })
|
|
42
|
-
* ])
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* // Advanced usage with custom mount element
|
|
46
|
-
* export function provideCustomVueUI() {
|
|
47
|
-
* return createModule("CustomVueUI", [
|
|
48
|
-
* provideVueGui({
|
|
49
|
-
* mountElement: document.getElementById('my-ui-overlay'),
|
|
50
|
-
* createIfNotFound: false
|
|
51
|
-
* })
|
|
52
|
-
* ])
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* // Usage with CSS selector
|
|
56
|
-
* export function provideModalVueUI() {
|
|
57
|
-
* return createModule("ModalVueUI", [
|
|
58
|
-
* provideVueGui({
|
|
59
|
-
* selector: '.modal-overlay',
|
|
60
|
-
* createIfNotFound: true
|
|
61
|
-
* })
|
|
62
|
-
* ])
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* **Integration in your client:**
|
|
67
|
-
* ```typescript
|
|
68
|
-
* import { RpgClient } from '@rpgjs/client'
|
|
69
|
-
* import { provideVueGui } from '@rpgjs/vue'
|
|
70
|
-
*
|
|
71
|
-
* @RpgClient({
|
|
72
|
-
* providers: [
|
|
73
|
-
* provideVueGui({
|
|
74
|
-
* selector: '#vue-gui-overlay'
|
|
75
|
-
* })
|
|
76
|
-
* ],
|
|
77
|
-
* gui: [
|
|
78
|
-
* // Vue components will be automatically handled by VueGui
|
|
79
|
-
* InventoryVueComponent,
|
|
80
|
-
* // CanvasEngine components continue to work normally
|
|
81
|
-
* DialogCanvasComponent
|
|
82
|
-
* ]
|
|
83
|
-
* })
|
|
84
|
-
* export class MyRpgClient {}
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* **Available injections in Vue components:**
|
|
88
|
-
* - `engine`: RpgClientEngine instance for game interactions
|
|
89
|
-
* - `socket`: WebSocket connection for server communication
|
|
90
|
-
* - `gui`: RpgGui instance for GUI management
|
|
91
|
-
*
|
|
92
|
-
* **Event propagation:**
|
|
93
|
-
* Use the `v-propagate` directive in Vue components to ensure mouse/keyboard events
|
|
94
|
-
* are properly forwarded to the game canvas when needed.
|
|
95
|
-
*
|
|
96
|
-
* @since 5.0.0
|
|
97
|
-
* @see {@link VueGuiProviderOptions} for configuration options
|
|
98
|
-
* @see {@link VueGui} for the main service class
|
|
99
|
-
*/
|
|
100
|
-
export declare function provideVueGui(options?: VueGuiProviderOptions): any[];
|
|
101
|
-
export {};
|