@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.
Files changed (90) hide show
  1. package/dist/Game/Map.d.ts +4 -0
  2. package/dist/Gui/Gui.d.ts +128 -5
  3. package/dist/RpgClient.d.ts +35 -5
  4. package/dist/RpgClientEngine.d.ts +3 -0
  5. package/dist/components/gui/index.d.ts +3 -3
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +7 -5
  8. package/dist/index.js.map +1 -1
  9. package/dist/index10.js +150 -4
  10. package/dist/index10.js.map +1 -1
  11. package/dist/index11.js +20 -7
  12. package/dist/index11.js.map +1 -1
  13. package/dist/index12.js +6 -8
  14. package/dist/index12.js.map +1 -1
  15. package/dist/index13.js +11 -14
  16. package/dist/index13.js.map +1 -1
  17. package/dist/index14.js +8 -100
  18. package/dist/index14.js.map +1 -1
  19. package/dist/index15.js +141 -35
  20. package/dist/index15.js.map +1 -1
  21. package/dist/index16.js +42 -0
  22. package/dist/index16.js.map +1 -1
  23. package/dist/index17.js +48 -7
  24. package/dist/index17.js.map +1 -1
  25. package/dist/index18.js +5 -383
  26. package/dist/index18.js.map +1 -1
  27. package/dist/index19.js +384 -28
  28. package/dist/index19.js.map +1 -1
  29. package/dist/index2.js +32 -13
  30. package/dist/index2.js.map +1 -1
  31. package/dist/index20.js +31 -17
  32. package/dist/index20.js.map +1 -1
  33. package/dist/index21.js +17 -2413
  34. package/dist/index21.js.map +1 -1
  35. package/dist/index22.js +2587 -88
  36. package/dist/index22.js.map +1 -1
  37. package/dist/index23.js +108 -103
  38. package/dist/index23.js.map +1 -1
  39. package/dist/index29.js +22 -3
  40. package/dist/index29.js.map +1 -1
  41. package/dist/index3.js +2 -2
  42. package/dist/index30.js +1 -318
  43. package/dist/index30.js.map +1 -1
  44. package/dist/index31.js +332 -24
  45. package/dist/index31.js.map +1 -1
  46. package/dist/index32.js +24 -8
  47. package/dist/index32.js.map +1 -1
  48. package/dist/index33.js +4 -4
  49. package/dist/index33.js.map +1 -1
  50. package/dist/index34.js +8 -9
  51. package/dist/index34.js.map +1 -1
  52. package/dist/index35.js +9 -4400
  53. package/dist/index35.js.map +1 -1
  54. package/dist/index36.js +4394 -307
  55. package/dist/index36.js.map +1 -1
  56. package/dist/index37.js +307 -165
  57. package/dist/index37.js.map +1 -1
  58. package/dist/index38.js +162 -489
  59. package/dist/index38.js.map +1 -1
  60. package/dist/index39.js +496 -56
  61. package/dist/index39.js.map +1 -1
  62. package/dist/index4.js +2 -2
  63. package/dist/index40.js +67 -10
  64. package/dist/index40.js.map +1 -1
  65. package/dist/index41.js +16 -78
  66. package/dist/index41.js.map +1 -1
  67. package/dist/index42.js +96 -0
  68. package/dist/index42.js.map +1 -0
  69. package/dist/index9.js +228 -14
  70. package/dist/index9.js.map +1 -1
  71. package/dist/presets/faceset.d.ts +30 -0
  72. package/dist/presets/index.d.ts +1 -0
  73. package/dist/services/mmorpg.d.ts +1 -1
  74. package/dist/services/standalone.d.ts +1 -1
  75. package/package.json +7 -5
  76. package/src/Game/AnimationManager.ts +1 -0
  77. package/src/Game/Map.ts +9 -1
  78. package/src/Game/Object.ts +28 -6
  79. package/src/Gui/Gui.ts +300 -17
  80. package/src/RpgClient.ts +36 -5
  81. package/src/RpgClientEngine.ts +32 -9
  82. package/src/components/character.ce +11 -9
  83. package/src/components/gui/box.ce +17 -0
  84. package/src/components/gui/dialogbox/index.ce +74 -35
  85. package/src/components/gui/dialogbox/selection.ce +16 -1
  86. package/src/components/gui/index.ts +3 -4
  87. package/src/components/scenes/event-layer.ce +6 -0
  88. package/src/index.ts +3 -1
  89. package/src/presets/faceset.ts +60 -0
  90. 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={700}
6
+ width={widthBox}
7
7
  height
8
8
  controls
9
- positionType="absolute"
10
- bottom={10}
9
+ ...positionBox()
11
10
  >
12
- <Rect width={700} height={250} color="#1a1a2e" />
13
- <Rect
14
- x={0}
15
- y={0}
16
- width={700}
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={700}
18
+ width={widthBox}
27
19
  height
28
20
  alpha={contentOpacity}
29
21
  >
30
- <Container flexDirection="column">
31
- <Text
32
- text
33
- color="#fff"
34
- fontSize={18}
35
- margin={40}
36
- typewriter
37
- style={textStyle}
38
- />
39
- @if (visibleSelection) {
40
- <Selection selectedIndex={0} items={choices} onSelect />
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(250);
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: 700 - 256 - 80
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
  });
@@ -1,5 +1,4 @@
1
- import Dialogbox from "./dialogbox/index.ce";
1
+ import DialogboxComponent from "./dialogbox/index.ce";
2
+ import BoxComponent from "./box.ce";
2
3
 
3
- export const PrebuiltGui = {
4
- Dialogbox
5
- }
4
+ export { DialogboxComponent, BoxComponent }
@@ -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
+
@@ -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
  }