@rpgjs/client 5.0.0-alpha.3 → 5.0.0-alpha.30
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/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/{index19.js → Game/AnimationManager.js} +4 -3
- package/dist/Game/AnimationManager.js.map +1 -0
- package/dist/{index30.js → Game/Event.js} +2 -2
- package/dist/Game/Event.js.map +1 -0
- package/dist/Game/Map.d.ts +8 -1
- package/dist/Game/Map.js +54 -0
- package/dist/Game/Map.js.map +1 -0
- package/dist/Game/Object.d.ts +129 -0
- package/dist/Game/Object.js +218 -0
- package/dist/Game/Object.js.map +1 -0
- package/dist/{index29.js → Game/Player.js} +2 -2
- package/dist/Game/Player.js.map +1 -0
- package/dist/Gui/Gui.d.ts +177 -5
- package/dist/Gui/Gui.js +478 -0
- package/dist/Gui/Gui.js.map +1 -0
- package/dist/Gui/NotificationManager.d.ts +23 -0
- package/dist/Gui/NotificationManager.js +51 -0
- package/dist/Gui/NotificationManager.js.map +1 -0
- package/dist/Resource.d.ts +97 -0
- package/dist/Resource.js +114 -0
- package/dist/Resource.js.map +1 -0
- package/dist/RpgClient.d.ts +259 -59
- package/dist/RpgClientEngine.d.ts +632 -9
- package/dist/RpgClientEngine.js +1262 -0
- package/dist/RpgClientEngine.js.map +1 -0
- package/dist/Sound.d.ts +199 -0
- package/dist/Sound.js +97 -0
- package/dist/Sound.js.map +1 -0
- package/dist/components/animations/animation.ce.js +21 -0
- package/dist/components/animations/animation.ce.js.map +1 -0
- package/dist/{index23.js → components/animations/hit.ce.js} +3 -3
- package/dist/components/animations/hit.ce.js.map +1 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/animations/index.js +10 -0
- package/dist/components/animations/index.js.map +1 -0
- package/dist/components/character.ce.js +316 -0
- package/dist/components/character.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/dynamics/parse-value.js +54 -0
- package/dist/components/dynamics/parse-value.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +141 -0
- package/dist/components/dynamics/text.ce.js.map +1 -0
- package/dist/components/gui/box.ce.js +27 -0
- package/dist/components/gui/box.ce.js.map +1 -0
- package/dist/components/gui/dialogbox/index.ce.js +152 -0
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
- package/dist/components/gui/gameover.ce.js +141 -0
- package/dist/components/gui/gameover.ce.js.map +1 -0
- package/dist/components/gui/hud/hud.ce.js +35 -0
- package/dist/components/gui/hud/hud.ce.js.map +1 -0
- package/dist/components/gui/index.d.ts +15 -3
- package/dist/components/gui/menu/equip-menu.ce.js +349 -0
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/exit-menu.ce.js +35 -0
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/items-menu.ce.js +229 -0
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/main-menu.ce.js +205 -0
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/options-menu.ce.js +28 -0
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/skills-menu.ce.js +53 -0
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/gui/mobile/index.js +24 -0
- package/dist/components/gui/mobile/index.js.map +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +17 -0
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
- package/dist/components/gui/notification/notification.ce.js +38 -0
- package/dist/components/gui/notification/notification.ce.js.map +1 -0
- package/dist/components/gui/save-load.ce.js +242 -0
- package/dist/components/gui/save-load.ce.js.map +1 -0
- package/dist/components/gui/shop/shop.ce.js +322 -0
- package/dist/components/gui/shop/shop.ce.js.map +1 -0
- package/dist/components/gui/title-screen.ce.js +148 -0
- package/dist/components/gui/title-screen.ce.js.map +1 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/prebuilt/hp-bar.ce.js +106 -0
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
- package/dist/components/prebuilt/index.d.ts +19 -0
- package/dist/components/prebuilt/light-halo.ce.js +76 -0
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
- package/dist/components/scenes/canvas.ce.js +44 -0
- package/dist/components/scenes/canvas.ce.js.map +1 -0
- package/dist/components/scenes/draw-map.ce.js +34 -0
- package/dist/components/scenes/draw-map.ce.js.map +1 -0
- package/dist/{index13.js → components/scenes/event-layer.ce.js} +7 -6
- package/dist/components/scenes/event-layer.ce.js.map +1 -0
- package/dist/{index6.js → core/inject.js} +2 -2
- package/dist/core/inject.js.map +1 -0
- package/dist/core/setup.js +16 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +43 -4
- package/dist/module.js +175 -0
- package/dist/module.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@2.8.2/node_modules/@signe/di/dist/index.js +366 -0
- package/dist/node_modules/.pnpm/@signe_di@2.8.2/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/{index27.js → node_modules/.pnpm/@signe_reactive@2.8.2/node_modules/@signe/reactive/dist/index.js} +229 -11
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.2/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/{index20.js → node_modules/.pnpm/@signe_room@2.8.2/node_modules/@signe/room/dist/index.js} +308 -40
- package/dist/node_modules/.pnpm/@signe_room@2.8.2/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/{index26.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/chunk-7QVYU63E.js} +1 -1
- package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/{index21.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/client/index.js} +5 -5
- package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/{index17.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/index.js} +89 -12
- package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/{index33.js → node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js} +1 -1
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
- package/dist/{index31.js → node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js} +2 -2
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
- package/dist/{index32.js → node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js} +1 -1
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
- package/dist/{index34.js → node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js} +1 -1
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/animation.js +27 -0
- package/dist/presets/animation.js.map +1 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/faceset.js +24 -0
- package/dist/presets/faceset.js.map +1 -0
- package/dist/presets/icon.d.ts +20 -0
- package/dist/presets/icon.js +15 -0
- package/dist/presets/icon.js.map +1 -0
- package/dist/presets/index.d.ts +123 -0
- package/dist/presets/index.js +16 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/presets/lpc.js +95 -0
- package/dist/presets/lpc.js.map +1 -0
- package/dist/{index25.js → presets/rmspritesheet.js} +1 -1
- package/dist/presets/rmspritesheet.js.map +1 -0
- package/dist/{index16.js → services/AbstractSocket.js} +1 -1
- package/dist/services/AbstractSocket.js.map +1 -0
- package/dist/services/keyboardControls.d.ts +15 -0
- package/dist/services/keyboardControls.js +21 -0
- package/dist/services/keyboardControls.js.map +1 -0
- package/dist/services/loadMap.d.ts +123 -2
- package/dist/{index7.js → services/loadMap.js} +12 -4
- package/dist/services/loadMap.js.map +1 -0
- package/dist/services/mmorpg.d.ts +16 -4
- package/dist/services/mmorpg.js +84 -0
- package/dist/services/mmorpg.js.map +1 -0
- package/dist/services/save.d.ts +19 -0
- package/dist/services/save.js +69 -0
- package/dist/services/save.js.map +1 -0
- package/dist/services/standalone.d.ts +65 -3
- package/dist/services/standalone.js +170 -0
- package/dist/services/standalone.js.map +1 -0
- package/dist/utils/getEntityProp.d.ts +39 -0
- package/dist/utils/getEntityProp.js +54 -0
- package/dist/utils/getEntityProp.js.map +1 -0
- package/package.json +24 -18
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Map.ts +37 -2
- package/src/Game/Object.ts +296 -11
- package/src/Gui/Gui.ts +506 -18
- package/src/Gui/NotificationManager.ts +69 -0
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +264 -58
- package/src/RpgClientEngine.ts +1421 -44
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +406 -40
- package/src/components/dynamics/parse-value.ts +80 -0
- package/src/components/dynamics/text.ce +183 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +204 -187
- package/src/components/gui/gameover.ce +158 -0
- package/src/components/gui/hud/hud.ce +56 -0
- package/src/components/gui/index.ts +30 -4
- package/src/components/gui/menu/equip-menu.ce +410 -0
- package/src/components/gui/menu/exit-menu.ce +41 -0
- package/src/components/gui/menu/items-menu.ce +317 -0
- package/src/components/gui/menu/main-menu.ce +291 -0
- package/src/components/gui/menu/options-menu.ce +35 -0
- package/src/components/gui/menu/skills-menu.ce +83 -0
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/gui/notification/notification.ce +51 -0
- package/src/components/gui/save-load.ce +208 -0
- package/src/components/gui/shop/shop.ce +493 -0
- package/src/components/gui/title-screen.ce +163 -0
- package/src/components/index.ts +5 -1
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +24 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +19 -14
- package/src/components/scenes/draw-map.ce +21 -29
- package/src/components/scenes/event-layer.ce +10 -3
- package/src/components/scenes/transition.ce +60 -0
- package/src/core/setup.ts +2 -0
- package/src/index.ts +16 -2
- package/src/module.ts +145 -9
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/icon.ts +17 -0
- package/src/presets/index.ts +9 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/keyboardControls.ts +20 -0
- package/src/services/loadMap.ts +132 -3
- package/src/services/mmorpg.ts +39 -5
- package/src/services/save.ts +103 -0
- package/src/services/standalone.ts +107 -15
- package/src/utils/getEntityProp.ts +87 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +5 -3
- package/CHANGELOG.md +0 -9
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/dist/index10.js +0 -8
- package/dist/index10.js.map +0 -1
- package/dist/index11.js +0 -10
- package/dist/index11.js.map +0 -1
- package/dist/index12.js +0 -8
- package/dist/index12.js.map +0 -1
- package/dist/index13.js.map +0 -1
- package/dist/index14.js +0 -50
- package/dist/index14.js.map +0 -1
- package/dist/index15.js +0 -191
- package/dist/index15.js.map +0 -1
- package/dist/index16.js.map +0 -1
- package/dist/index17.js.map +0 -1
- package/dist/index18.js +0 -31
- package/dist/index18.js.map +0 -1
- package/dist/index19.js.map +0 -1
- package/dist/index2.js +0 -112
- package/dist/index2.js.map +0 -1
- package/dist/index20.js.map +0 -1
- package/dist/index21.js.map +0 -1
- package/dist/index22.js +0 -109
- package/dist/index22.js.map +0 -1
- package/dist/index23.js.map +0 -1
- package/dist/index24.js +0 -21
- package/dist/index24.js.map +0 -1
- package/dist/index25.js.map +0 -1
- package/dist/index26.js.map +0 -1
- package/dist/index27.js.map +0 -1
- package/dist/index28.js +0 -25
- package/dist/index28.js.map +0 -1
- package/dist/index29.js.map +0 -1
- package/dist/index3.js +0 -87
- package/dist/index3.js.map +0 -1
- package/dist/index30.js.map +0 -1
- package/dist/index31.js.map +0 -1
- package/dist/index32.js.map +0 -1
- package/dist/index33.js.map +0 -1
- package/dist/index34.js.map +0 -1
- package/dist/index35.js +0 -91
- package/dist/index35.js.map +0 -1
- package/dist/index36.js +0 -61
- package/dist/index36.js.map +0 -1
- package/dist/index37.js +0 -20
- package/dist/index37.js.map +0 -1
- package/dist/index38.js +0 -20
- package/dist/index38.js.map +0 -1
- package/dist/index4.js +0 -54
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -15
- package/dist/index5.js.map +0 -1
- package/dist/index6.js.map +0 -1
- package/dist/index7.js.map +0 -1
- package/dist/index8.js +0 -90
- package/dist/index8.js.map +0 -1
- package/dist/index9.js +0 -76
- package/dist/index9.js.map +0 -1
- package/src/components/gui/dialogbox/itemMenu.ce +0 -23
- package/src/components/gui/dialogbox/selection.ce +0 -67
- package/src/components/scenes/element-map.ce +0 -23
- /package/src/components/{effects → animations}/hit.ce +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<Text text={parseDynamicValue(component.value, object)} ...getComponentStyle(component) />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import { computed } from "canvasengine";
|
|
5
|
+
import { parseDynamicValue } from "./parse-value";
|
|
6
|
+
|
|
7
|
+
const { object } = defineProps();
|
|
8
|
+
const component = object._component;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parses a numeric style value that can be a number or a string
|
|
12
|
+
*
|
|
13
|
+
* If the value is a string, it may contain dynamic references like {hp}
|
|
14
|
+
* which need to be parsed using parseDynamicValue. If it's a number,
|
|
15
|
+
* it's returned as-is wrapped in a computed.
|
|
16
|
+
*
|
|
17
|
+
* @param value - Numeric value (number or string)
|
|
18
|
+
* @param object - Object to resolve dynamic references from
|
|
19
|
+
* @returns Computed signal with the numeric value
|
|
20
|
+
*/
|
|
21
|
+
const parseNumericStyleValue = (value, object) => {
|
|
22
|
+
if (value === undefined || value === null) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (typeof value === 'number') {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
// Check if it contains dynamic references
|
|
32
|
+
if (value.includes('{')) {
|
|
33
|
+
// Parse dynamic value and convert to number
|
|
34
|
+
const parsed = parseDynamicValue(value, object);
|
|
35
|
+
return computed(() => {
|
|
36
|
+
const str = parsed();
|
|
37
|
+
const num = parseFloat(str);
|
|
38
|
+
return isNaN(num) ? 0 : num;
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
// Simple string number, convert directly
|
|
42
|
+
const num = parseFloat(value);
|
|
43
|
+
return isNaN(num) ? undefined : num;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maps component style properties to Canvas Engine Text component props
|
|
52
|
+
*
|
|
53
|
+
* Converts TextComponentOptions from the server to the format expected
|
|
54
|
+
* by the Canvas Engine Text component. Supports all text styling properties
|
|
55
|
+
* including fill, fontSize, fontFamily, fontStyle, fontWeight, stroke,
|
|
56
|
+
* opacity, wordWrap, and align. Also supports dynamic values (number | string)
|
|
57
|
+
* for numeric properties like fontSize and opacity.
|
|
58
|
+
*
|
|
59
|
+
* @param component - Component definition with style property
|
|
60
|
+
* @returns Object with Text component props
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* // Component with style
|
|
65
|
+
* const component = {
|
|
66
|
+
* style: {
|
|
67
|
+
* fill: '#000000',
|
|
68
|
+
* fontSize: 20,
|
|
69
|
+
* fontFamily: 'Arial',
|
|
70
|
+
* fontWeight: 'bold'
|
|
71
|
+
* }
|
|
72
|
+
* };
|
|
73
|
+
*
|
|
74
|
+
* const props = getComponentStyle(component);
|
|
75
|
+
* // Returns: { color: '#000000', size: 20, fontFamily: 'Arial', style: { fontWeight: 'bold' } }
|
|
76
|
+
*
|
|
77
|
+
* // Component with dynamic fontSize
|
|
78
|
+
* const component2 = {
|
|
79
|
+
* style: {
|
|
80
|
+
* fill: '#000000',
|
|
81
|
+
* fontSize: '{hp}', // Will be resolved from object.hp
|
|
82
|
+
* opacity: '0.8'
|
|
83
|
+
* }
|
|
84
|
+
* };
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
const getComponentStyle = (component) => {
|
|
88
|
+
if (!component.style) {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const style = component.style;
|
|
93
|
+
const result = {};
|
|
94
|
+
|
|
95
|
+
// Map fill to color (shortcut property)
|
|
96
|
+
// fill can be a string (hex color) or a dynamic string
|
|
97
|
+
if (style.fill !== undefined) {
|
|
98
|
+
if (typeof style.fill === 'string' && style.fill.includes('{')) {
|
|
99
|
+
result.color = parseDynamicValue(style.fill, object);
|
|
100
|
+
} else {
|
|
101
|
+
result.color = style.fill;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Map fontSize to size (shortcut property)
|
|
106
|
+
// fontSize can be number or string (with dynamic references)
|
|
107
|
+
if (style.fontSize !== undefined) {
|
|
108
|
+
const fontSizeValue = parseNumericStyleValue(style.fontSize, object);
|
|
109
|
+
if (fontSizeValue !== undefined) {
|
|
110
|
+
result.size = fontSizeValue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Map fontFamily (shortcut property)
|
|
115
|
+
if (style.fontFamily !== undefined) {
|
|
116
|
+
if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {
|
|
117
|
+
result.fontFamily = parseDynamicValue(style.fontFamily, object);
|
|
118
|
+
} else {
|
|
119
|
+
result.fontFamily = style.fontFamily;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Build style object for PixiJS Text properties
|
|
124
|
+
const textStyle = {};
|
|
125
|
+
|
|
126
|
+
// Font style properties
|
|
127
|
+
if (style.fontStyle !== undefined) {
|
|
128
|
+
if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {
|
|
129
|
+
textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);
|
|
130
|
+
} else {
|
|
131
|
+
textStyle.fontStyle = style.fontStyle;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (style.fontWeight !== undefined) {
|
|
136
|
+
if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {
|
|
137
|
+
textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);
|
|
138
|
+
} else if (typeof style.fontWeight === 'number') {
|
|
139
|
+
textStyle.fontWeight = style.fontWeight;
|
|
140
|
+
} else {
|
|
141
|
+
textStyle.fontWeight = style.fontWeight;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Stroke properties
|
|
146
|
+
if (style.stroke !== undefined) {
|
|
147
|
+
if (typeof style.stroke === 'string' && style.stroke.includes('{')) {
|
|
148
|
+
textStyle.stroke = parseDynamicValue(style.stroke, object);
|
|
149
|
+
} else {
|
|
150
|
+
textStyle.stroke = style.stroke;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Opacity (can be number or string)
|
|
155
|
+
if (style.opacity !== undefined) {
|
|
156
|
+
const opacityValue = parseNumericStyleValue(style.opacity, object);
|
|
157
|
+
if (opacityValue !== undefined) {
|
|
158
|
+
textStyle.opacity = opacityValue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Word wrap
|
|
163
|
+
if (style.wordWrap !== undefined) {
|
|
164
|
+
textStyle.wordWrap = style.wordWrap;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Text alignment
|
|
168
|
+
if (style.align !== undefined) {
|
|
169
|
+
if (typeof style.align === 'string' && style.align.includes('{')) {
|
|
170
|
+
textStyle.align = parseDynamicValue(style.align, object);
|
|
171
|
+
} else {
|
|
172
|
+
textStyle.align = style.align;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Only add style prop if there are style properties
|
|
177
|
+
if (Object.keys(textStyle).length > 0) {
|
|
178
|
+
result.style = textStyle;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<Container positionType="absolute" top={top} left={left}>
|
|
2
|
+
<Container
|
|
3
|
+
anchor={[0.5, 0.5]}
|
|
4
|
+
>
|
|
5
|
+
<Rect width height color={_color} />
|
|
6
|
+
<Container attach={child}></Container>
|
|
7
|
+
</Container>
|
|
8
|
+
</Container>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { RpgClientEngine, inject } from "../../index";
|
|
12
|
+
|
|
13
|
+
const { width, height, children, color, top, left } = defineProps();
|
|
14
|
+
const engine = inject(RpgClientEngine)
|
|
15
|
+
const child = children[0]
|
|
16
|
+
const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || "#1a1a2e")
|
|
17
|
+
</script>
|
|
@@ -1,194 +1,211 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</
|
|
43
|
-
</
|
|
44
|
-
</
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
</Container>
|
|
1
|
+
<DOMContainer width="100%" height="100%" controls={dialogControls}>
|
|
2
|
+
<div
|
|
3
|
+
class="rpg-ui-dialog-container"
|
|
4
|
+
data-position={dialogPosition()}
|
|
5
|
+
data-full-width={isFullWidth() ? "true" : "false"}
|
|
6
|
+
data-has-face={hasFace() ? "true" : "false"}
|
|
7
|
+
>
|
|
8
|
+
<div class="rpg-ui-dialog rpg-anim-fade-in">
|
|
9
|
+
<div class="rpg-ui-dialog-body">
|
|
10
|
+
<div>
|
|
11
|
+
@if (speakerName()) {
|
|
12
|
+
<div class="rpg-ui-dialog-speaker">{speakerName()}</div>
|
|
13
|
+
}
|
|
14
|
+
<div class="rpg-ui-dialog-content">
|
|
15
|
+
{displayMessage()}
|
|
16
|
+
</div>
|
|
17
|
+
@if (hasChoices()) {
|
|
18
|
+
<Navigation tabindex={selectedItem} controls={controls}>
|
|
19
|
+
<div class="rpg-ui-dialog-choices">
|
|
20
|
+
@for ((choice,index) of choices) {
|
|
21
|
+
<div
|
|
22
|
+
class="rpg-ui-dialog-choice"
|
|
23
|
+
class={{active: selectedItem() === index}}
|
|
24
|
+
tabindex={index}
|
|
25
|
+
data-choice-index={index}
|
|
26
|
+
click={selectChoice(index)}
|
|
27
|
+
>{{ choice.text }}</div>
|
|
28
|
+
}
|
|
29
|
+
</div>
|
|
30
|
+
</Navigation>
|
|
31
|
+
}
|
|
32
|
+
</div>
|
|
33
|
+
@if (hasFace()) {
|
|
34
|
+
<div class="rpg-ui-dialog-face">
|
|
35
|
+
<DOMSprite sheet={faceSheet(face.id, face.expression)} />
|
|
36
|
+
</div>
|
|
37
|
+
}
|
|
38
|
+
</div>
|
|
39
|
+
@if (showIndicator) {
|
|
40
|
+
<div class="rpg-ui-dialog-indicator"></div>
|
|
41
|
+
}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</DOMContainer>
|
|
45
|
+
|
|
48
46
|
<script>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const typewriter = {
|
|
126
|
-
speed: 0.3,
|
|
127
|
-
skip: triggerSkip,
|
|
128
|
-
onComplete: () => {
|
|
129
|
-
isTextCompleted.set(true);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const textStyle = {
|
|
134
|
-
wordWrap: true,
|
|
135
|
-
wordWrapWidth: 700 - 256 - 80
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const face = signal({ x: 0, y: 0, width: 256, height: 256 });
|
|
139
|
-
|
|
140
|
-
mount((element) => {
|
|
141
|
-
const [dialogbox] = element.props.children
|
|
142
|
-
return () => {
|
|
143
|
-
dialogbox.directives.controls.onDestroy()
|
|
144
|
-
isDestroyed = true;
|
|
145
|
-
// Wait destroy is finished before start processing input
|
|
146
|
-
setTimeout(() => {
|
|
147
|
-
client.stopProcessingInput = false;
|
|
148
|
-
}, 500)
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
const controls = signal({
|
|
153
|
-
next: {
|
|
154
|
-
bind: keyboardControls.action,
|
|
155
|
-
keyDown(e) {
|
|
156
|
-
if (isDestroyed) return;
|
|
157
|
-
if (isChoiceDisplayed()) {
|
|
158
|
-
// If choices are displayed, do nothing (wait for selection)
|
|
159
|
-
return;
|
|
47
|
+
import { effect, signal, computed, createTabindexNavigator, mount } from "canvasengine";
|
|
48
|
+
import { inject } from "../../../core/inject";
|
|
49
|
+
import { RpgClientEngine } from "../../../RpgClientEngine";
|
|
50
|
+
import { delay } from "@rpgjs/common";
|
|
51
|
+
|
|
52
|
+
const engine = inject(RpgClientEngine);
|
|
53
|
+
const currentPlayer = engine.scene.currentPlayer
|
|
54
|
+
const keyboardControls = engine.globalConfig.keyboardControls;
|
|
55
|
+
|
|
56
|
+
engine.stopProcessingInput = true;
|
|
57
|
+
|
|
58
|
+
const selectedItem = signal(0)
|
|
59
|
+
let isDestroyed = false;
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
data,
|
|
63
|
+
onFinish,
|
|
64
|
+
onInteraction
|
|
65
|
+
} = defineProps();
|
|
66
|
+
|
|
67
|
+
const { message, choices, face, speaker, position, typewriterEffect, autoClose } = data();
|
|
68
|
+
const fullWidth = computed(() => data().fullWidth || false);
|
|
69
|
+
|
|
70
|
+
const resolveProp = (value) => typeof value === "function" ? value() : value;
|
|
71
|
+
|
|
72
|
+
const speakerName = computed(() => {
|
|
73
|
+
const value = resolveProp(speaker);
|
|
74
|
+
return value ? String(value) : "";
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const dialogPosition = computed(() => resolveProp(position) || "bottom");
|
|
78
|
+
const isFullWidth = computed(() => resolveProp(fullWidth) !== false);
|
|
79
|
+
const hasFace = computed(() => !!resolveProp(face));
|
|
80
|
+
|
|
81
|
+
const displayMessage = signal("");
|
|
82
|
+
const fullMessage = signal("");
|
|
83
|
+
const isTyping = signal(false);
|
|
84
|
+
let typewriterTimer = null;
|
|
85
|
+
let rootElement = null;
|
|
86
|
+
|
|
87
|
+
mount((element) => {
|
|
88
|
+
rootElement = element;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const startTypewriter = (text) => {
|
|
92
|
+
if (typewriterTimer) clearInterval(typewriterTimer);
|
|
93
|
+
displayMessage.set("");
|
|
94
|
+
if (!text) return;
|
|
95
|
+
let index = 0;
|
|
96
|
+
isTyping.set(true);
|
|
97
|
+
typewriterTimer = setInterval(() => {
|
|
98
|
+
index += 1;
|
|
99
|
+
displayMessage.set(text.slice(0, index));
|
|
100
|
+
if (index >= text.length) {
|
|
101
|
+
clearInterval(typewriterTimer);
|
|
102
|
+
typewriterTimer = null;
|
|
103
|
+
isTyping.set(false);
|
|
104
|
+
}
|
|
105
|
+
}, 20);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const finishTyping = () => {
|
|
109
|
+
if (typewriterTimer) clearInterval(typewriterTimer);
|
|
110
|
+
typewriterTimer = null;
|
|
111
|
+
displayMessage.set(fullMessage());
|
|
112
|
+
isTyping.set(false);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
effect(() => {
|
|
116
|
+
const text = resolveProp(message) || "";
|
|
117
|
+
fullMessage.set(text);
|
|
118
|
+
const useTypewriter = resolveProp(typewriterEffect) !== false;
|
|
119
|
+
if (!useTypewriter) {
|
|
120
|
+
finishTyping();
|
|
121
|
+
return;
|
|
160
122
|
}
|
|
123
|
+
startTypewriter(text);
|
|
124
|
+
});
|
|
125
|
+
|
|
161
126
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
127
|
+
const hasChoices = computed(() => choices.length > 0);
|
|
128
|
+
const showIndicator = computed(() => !hasChoices() && !isTyping());
|
|
129
|
+
const nav = createTabindexNavigator(selectedItem, { count: () => choices.length }, 'wrap');
|
|
130
|
+
|
|
131
|
+
function selectChoice(index) {
|
|
132
|
+
return function() {
|
|
133
|
+
selectedItem.set(index);
|
|
134
|
+
onSelect(index);
|
|
166
135
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function _onFinish(value) {
|
|
139
|
+
if (onFinish) onFinish(value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const onSelect = (index) => {
|
|
143
|
+
_onFinish(index);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const controls = signal({
|
|
147
|
+
up: {
|
|
148
|
+
repeat: true,
|
|
149
|
+
bind: keyboardControls.up,
|
|
150
|
+
throttle: 150,
|
|
151
|
+
keyDown() {
|
|
152
|
+
if (!hasChoices()) return;
|
|
153
|
+
nav.next(-1);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
down: {
|
|
157
|
+
repeat: true,
|
|
158
|
+
bind: keyboardControls.down,
|
|
159
|
+
throttle: 150,
|
|
160
|
+
keyDown() {
|
|
161
|
+
if (!hasChoices()) return;
|
|
162
|
+
nav.next(1);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
action: {
|
|
166
|
+
bind: keyboardControls.action,
|
|
167
|
+
keyDown() {
|
|
168
|
+
if (isTyping()) {
|
|
169
|
+
finishTyping();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!hasChoices()) return;
|
|
173
|
+
onSelect(selectedItem());
|
|
172
174
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
isTextCompleted.set(false);
|
|
177
|
-
if (isFinished && onFinish) {
|
|
178
|
-
onFinish();
|
|
179
|
-
}
|
|
175
|
+
},
|
|
176
|
+
gamepad: {
|
|
177
|
+
enabled: true
|
|
180
178
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const dialogControls = signal({
|
|
182
|
+
action: {
|
|
183
|
+
bind: keyboardControls.action,
|
|
184
|
+
keyDown() {
|
|
185
|
+
if (isTyping()) {
|
|
186
|
+
finishTyping();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (hasChoices()) return;
|
|
190
|
+
_onFinish();
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
const faceSheet = (graphicId, animationName) => {
|
|
196
|
+
return {
|
|
197
|
+
definition: engine.getSpriteSheet(graphicId),
|
|
198
|
+
playing: animationName,
|
|
199
|
+
};
|
|
192
200
|
}
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
|
|
202
|
+
mount((element) => {
|
|
203
|
+
return () => {
|
|
204
|
+
isDestroyed = true;
|
|
205
|
+
// Wait destroy is finished before start processing input
|
|
206
|
+
delay(() => {
|
|
207
|
+
engine.stopProcessingInput = false;
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
</script>
|