@rpgjs/client 5.0.0-alpha.10 → 5.0.0-alpha.12
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/Map.d.ts +4 -0
- package/dist/Gui/Gui.d.ts +128 -5
- package/dist/RpgClient.d.ts +35 -5
- package/dist/RpgClientEngine.d.ts +3 -0
- package/dist/components/gui/index.d.ts +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index10.js +150 -4
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +20 -7
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +6 -8
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +11 -14
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +8 -100
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +141 -35
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +42 -0
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +48 -7
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +5 -383
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +384 -28
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +32 -13
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +31 -17
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +17 -2413
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +2587 -88
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +108 -103
- package/dist/index23.js.map +1 -1
- package/dist/index29.js +22 -3
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +2 -2
- package/dist/index30.js +1 -318
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +332 -24
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +24 -8
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +4 -4
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +8 -9
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +9 -4400
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +4394 -307
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +307 -165
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +162 -489
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +496 -56
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +2 -2
- package/dist/index40.js +67 -10
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +16 -78
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +96 -0
- package/dist/index42.js.map +1 -0
- package/dist/index9.js +228 -14
- package/dist/index9.js.map +1 -1
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +7 -5
- package/src/Game/AnimationManager.ts +1 -0
- package/src/Game/Map.ts +9 -1
- package/src/Game/Object.ts +28 -6
- package/src/Gui/Gui.ts +300 -17
- package/src/RpgClient.ts +36 -5
- package/src/RpgClientEngine.ts +32 -9
- package/src/components/character.ce +11 -9
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +74 -35
- package/src/components/gui/dialogbox/selection.ce +16 -1
- package/src/components/gui/index.ts +3 -4
- package/src/components/scenes/event-layer.ce +6 -0
- package/src/index.ts +3 -1
- package/src/presets/faceset.ts +60 -0
- package/src/presets/index.ts +3 -1
|
@@ -3,41 +3,38 @@
|
|
|
3
3
|
ref="dialogbox"
|
|
4
4
|
scale={{ x: scaleX }}
|
|
5
5
|
anchor={[0.5, 0.5]}
|
|
6
|
-
width={
|
|
6
|
+
width={widthBox}
|
|
7
7
|
height
|
|
8
8
|
controls
|
|
9
|
-
|
|
10
|
-
bottom={10}
|
|
9
|
+
...positionBox()
|
|
11
10
|
>
|
|
12
|
-
<Rect
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
height
|
|
18
|
-
color="#1a1a2e"
|
|
19
|
-
alpha={0.9}
|
|
20
|
-
borderRadius={10}
|
|
21
|
-
border
|
|
22
|
-
shadow
|
|
23
|
-
/>
|
|
11
|
+
<Rect
|
|
12
|
+
width={widthBox}
|
|
13
|
+
height
|
|
14
|
+
color={@dialogboxStyles.@backgroundColor}
|
|
15
|
+
alpha={@dialogboxStyles.@backgroundOpacity} />
|
|
24
16
|
<Container
|
|
25
17
|
flexDirection="row"
|
|
26
|
-
width={
|
|
18
|
+
width={widthBox}
|
|
27
19
|
height
|
|
28
20
|
alpha={contentOpacity}
|
|
29
21
|
>
|
|
30
|
-
<Container flexDirection="
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
<Container flexDirection="row">
|
|
23
|
+
<Container flexDirection="column">
|
|
24
|
+
<Text
|
|
25
|
+
text
|
|
26
|
+
color="#fff"
|
|
27
|
+
fontSize={18}
|
|
28
|
+
margin
|
|
29
|
+
typewriter
|
|
30
|
+
style={textStyle}
|
|
31
|
+
/>
|
|
32
|
+
@if (visibleSelection) {
|
|
33
|
+
<Selection selectedIndex={0} items={choices} onSelect />
|
|
34
|
+
}
|
|
35
|
+
</Container>
|
|
36
|
+
@if (face) {
|
|
37
|
+
<Sprite sheet={@faceSheet(@face.@id, @face.@expression)} />
|
|
41
38
|
}
|
|
42
39
|
</Container>
|
|
43
40
|
</Container>
|
|
@@ -59,22 +56,37 @@
|
|
|
59
56
|
|
|
60
57
|
import { inject } from "../../../core/inject";
|
|
61
58
|
import { RpgClientEngine } from "../../../RpgClientEngine";
|
|
59
|
+
import BoxComponent from "../box.ce";
|
|
62
60
|
|
|
63
61
|
const {
|
|
64
62
|
message,
|
|
65
63
|
choices: _choices,
|
|
66
64
|
onFinish,
|
|
67
|
-
onInteraction
|
|
65
|
+
onInteraction,
|
|
66
|
+
face,
|
|
67
|
+
position,
|
|
68
|
+
typewriterEffect,
|
|
69
|
+
autoClose
|
|
68
70
|
} = defineProps();
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
const client = inject(RpgClientEngine);
|
|
71
73
|
const keyboardControls = client.globalConfig.keyboardControls;
|
|
72
74
|
|
|
75
|
+
const dialogboxStyles = client.globalConfig.box.styles ?? {
|
|
76
|
+
backgroundColor: "#1a1a2e",
|
|
77
|
+
backgroundOpacity: 0.9,
|
|
78
|
+
}
|
|
79
|
+
const dialogBoxTypewriterSound = client.globalConfig?.box?.sounds?.typewriter
|
|
80
|
+
|
|
81
|
+
const spritesheets = client.spritesheets;
|
|
82
|
+
const sounds = client.sounds;
|
|
83
|
+
|
|
73
84
|
client.stopProcessingInput = true;
|
|
74
85
|
let isDestroyed = false;
|
|
75
86
|
|
|
76
87
|
const texts = [message()]
|
|
77
|
-
const height = signal(
|
|
88
|
+
const height = signal(256);
|
|
89
|
+
const margin = signal(40);
|
|
78
90
|
const isTextCompleted = signal(false);
|
|
79
91
|
|
|
80
92
|
const drawSpeaker = (g) => {
|
|
@@ -100,6 +112,20 @@
|
|
|
100
112
|
duration: 500,
|
|
101
113
|
});
|
|
102
114
|
|
|
115
|
+
const positionBox = computed(() => {
|
|
116
|
+
if (position() === 'bottom') {
|
|
117
|
+
return { positionType: 'absolute', bottom: 10 };
|
|
118
|
+
}
|
|
119
|
+
else if (position() === 'top') {
|
|
120
|
+
return { positionType: 'absolute', top: 10 };
|
|
121
|
+
}
|
|
122
|
+
return {};
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const widthBox = computed(() => {
|
|
126
|
+
return 700;
|
|
127
|
+
});
|
|
128
|
+
|
|
103
129
|
scaleX.set(1);
|
|
104
130
|
contentOpacity.set(1);
|
|
105
131
|
|
|
@@ -112,6 +138,13 @@
|
|
|
112
138
|
return typeof current === "string" ? current : current.text;
|
|
113
139
|
});
|
|
114
140
|
|
|
141
|
+
const faceSheet = (graphicId, animationName) => {
|
|
142
|
+
return {
|
|
143
|
+
definition: spritesheets.get(graphicId),
|
|
144
|
+
playing: animationName,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
115
148
|
const choices = computed(() => {
|
|
116
149
|
//const current = currentText();
|
|
117
150
|
//return typeof current === "string" ? null : current.choices;
|
|
@@ -122,21 +155,27 @@
|
|
|
122
155
|
|
|
123
156
|
const triggerSkip = trigger();
|
|
124
157
|
|
|
125
|
-
const typewriter = {
|
|
158
|
+
const typewriter = typewriterEffect() ? {
|
|
126
159
|
speed: 0.3,
|
|
127
160
|
skip: triggerSkip,
|
|
161
|
+
sound: {
|
|
162
|
+
src: sounds.get(dialogBoxTypewriterSound)?.src
|
|
163
|
+
},
|
|
128
164
|
onComplete: () => {
|
|
129
165
|
isTextCompleted.set(true);
|
|
166
|
+
if (autoClose()) {
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
onFinish();
|
|
169
|
+
}, 1000);
|
|
170
|
+
}
|
|
130
171
|
}
|
|
131
|
-
}
|
|
172
|
+
} : null;
|
|
132
173
|
|
|
133
174
|
const textStyle = {
|
|
134
175
|
wordWrap: true,
|
|
135
|
-
wordWrapWidth:
|
|
176
|
+
wordWrapWidth: widthBox() - margin() * 2 - (face ? 256 : 0)
|
|
136
177
|
}
|
|
137
178
|
|
|
138
|
-
const face = signal({ x: 0, y: 0, width: 256, height: 256 });
|
|
139
|
-
|
|
140
179
|
mount((element) => {
|
|
141
180
|
const [dialogbox] = element.props.children
|
|
142
181
|
return () => {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</Container>
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
|
-
import { signal, computed, mount } from "canvasengine";
|
|
8
|
+
import { signal, computed, mount, Howl } from "canvasengine";
|
|
9
9
|
import ItemMenu from "./itemMenu.ce";
|
|
10
10
|
import { RpgClientEngine } from "../../../RpgClientEngine";
|
|
11
11
|
import { inject } from "../../../core/inject";
|
|
@@ -19,6 +19,18 @@
|
|
|
19
19
|
|
|
20
20
|
const client = inject(RpgClientEngine);
|
|
21
21
|
const keyboardControls = client.globalConfig.keyboardControls;
|
|
22
|
+
const sounds = client.sounds;
|
|
23
|
+
const dialogBoxCursorSound = client.globalConfig?.box?.sounds?.cursorMove
|
|
24
|
+
const dialogBoxCursorSelectSound = client.globalConfig?.box?.sounds?.cursorSelect
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const playDialogBoxSound = (soundId) => {
|
|
28
|
+
if (!soundId) return;
|
|
29
|
+
const sound = new Howl.Howl({
|
|
30
|
+
src: [sounds.get(soundId)?.src]
|
|
31
|
+
})
|
|
32
|
+
sound.play()
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
const selected = (index) => {
|
|
24
36
|
return computed(() => {
|
|
@@ -36,6 +48,7 @@
|
|
|
36
48
|
down: {
|
|
37
49
|
bind: keyboardControls.down,
|
|
38
50
|
keyDown() {
|
|
51
|
+
playDialogBoxSound(dialogBoxCursorSound);
|
|
39
52
|
selectedIndex.update((currentIndex) => {
|
|
40
53
|
if (wrapAround) {
|
|
41
54
|
return (currentIndex + 1) % items().length;
|
|
@@ -48,6 +61,7 @@
|
|
|
48
61
|
up: {
|
|
49
62
|
bind: keyboardControls.up,
|
|
50
63
|
keyDown() {
|
|
64
|
+
playDialogBoxSound(dialogBoxCursorSound);
|
|
51
65
|
selectedIndex.update((currentIndex) => {
|
|
52
66
|
if (wrapAround) {
|
|
53
67
|
return (currentIndex - 1 + items().length) % items().length;
|
|
@@ -61,6 +75,7 @@
|
|
|
61
75
|
bind: keyboardControls.action,
|
|
62
76
|
keyDown() {
|
|
63
77
|
onSelect?.(selectedIndex());
|
|
78
|
+
playDialogBoxSound(dialogBoxCursorSelectSound);
|
|
64
79
|
},
|
|
65
80
|
},
|
|
66
81
|
});
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
@for ((player,id) of players) {
|
|
7
7
|
<Character id={id} object={player} />
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
@for (child of children) {
|
|
11
|
+
<child />
|
|
12
|
+
}
|
|
9
13
|
</Container>
|
|
10
14
|
|
|
11
15
|
<script>
|
|
@@ -15,6 +19,8 @@
|
|
|
15
19
|
import Character from "../character.ce";
|
|
16
20
|
|
|
17
21
|
const engine = inject(RpgClientEngine);
|
|
22
|
+
const { children } = defineProps()
|
|
23
|
+
|
|
18
24
|
const players = engine.sceneMap.players
|
|
19
25
|
const events = engine.sceneMap.events
|
|
20
26
|
</script>
|
package/src/index.ts
CHANGED
|
@@ -10,4 +10,6 @@ export * from "./Gui/Gui";
|
|
|
10
10
|
export * from "./components/gui";
|
|
11
11
|
export * from "./components/animations";
|
|
12
12
|
export * from "./presets";
|
|
13
|
-
export * from "./components";
|
|
13
|
+
export * from "./components";
|
|
14
|
+
export * from "./components/gui";
|
|
15
|
+
export { Context } from "@signe/di";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a faceset preset for character expressions
|
|
3
|
+
*
|
|
4
|
+
* This preset allows you to define multiple facial expressions for a character,
|
|
5
|
+
* where each expression corresponds to a specific frame position (frameX, frameY)
|
|
6
|
+
* within a single faceset texture. Each expression is defined by its position
|
|
7
|
+
* in the faceset grid.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Object containing the faceset configuration
|
|
10
|
+
* @param framesWidth - Number of frames horizontally in the faceset texture
|
|
11
|
+
* @param framesHeight - Number of frames vertically in the faceset texture
|
|
12
|
+
* @param expressions - Object mapping expression names to their frame positions as tuples [frameX, frameY]
|
|
13
|
+
* @returns Faceset configuration with animations for each expression
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const faceset = FacesetPreset({
|
|
18
|
+
* id: "facesetId",
|
|
19
|
+
* image: "faceset.png",
|
|
20
|
+
* width: 1024,
|
|
21
|
+
* height: 1024,
|
|
22
|
+
* }, 4, 2, {
|
|
23
|
+
* happy: [0, 0],
|
|
24
|
+
* sad: [1, 0],
|
|
25
|
+
* angry: [2, 0],
|
|
26
|
+
* surprised: [3, 0]
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const FacesetPreset = (
|
|
31
|
+
options: any,
|
|
32
|
+
framesWidth: number,
|
|
33
|
+
framesHeight: number,
|
|
34
|
+
expressions: Record<string, [number, number]>,
|
|
35
|
+
) => {
|
|
36
|
+
|
|
37
|
+
const textures: Record<string, any> = {};
|
|
38
|
+
|
|
39
|
+
// Create texture configuration for each expression
|
|
40
|
+
Object.keys(expressions).forEach((expressionName) => {
|
|
41
|
+
const [frameX, frameY] = expressions[expressionName];
|
|
42
|
+
textures[expressionName] = {
|
|
43
|
+
animations: () => [
|
|
44
|
+
[{
|
|
45
|
+
time: 0,
|
|
46
|
+
frameX: frameX,
|
|
47
|
+
frameY: frameY
|
|
48
|
+
}]
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
...options,
|
|
55
|
+
framesWidth,
|
|
56
|
+
framesHeight,
|
|
57
|
+
textures
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
package/src/presets/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AnimationSpritesheetPreset } from "./animation";
|
|
2
2
|
import { LPCSpritesheetPreset } from "./lpc";
|
|
3
3
|
import { RMSpritesheet } from "./rmspritesheet";
|
|
4
|
+
import { FacesetPreset } from "./faceset";
|
|
4
5
|
|
|
5
6
|
export const Presets = {
|
|
6
7
|
RMSpritesheet,
|
|
7
8
|
LPCSpritesheetPreset,
|
|
8
|
-
AnimationSpritesheetPreset
|
|
9
|
+
AnimationSpritesheetPreset,
|
|
10
|
+
FacesetPreset
|
|
9
11
|
}
|