@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.
Files changed (275) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/{index19.js → Game/AnimationManager.js} +4 -3
  3. package/dist/Game/AnimationManager.js.map +1 -0
  4. package/dist/{index30.js → Game/Event.js} +2 -2
  5. package/dist/Game/Event.js.map +1 -0
  6. package/dist/Game/Map.d.ts +8 -1
  7. package/dist/Game/Map.js +54 -0
  8. package/dist/Game/Map.js.map +1 -0
  9. package/dist/Game/Object.d.ts +129 -0
  10. package/dist/Game/Object.js +218 -0
  11. package/dist/Game/Object.js.map +1 -0
  12. package/dist/{index29.js → Game/Player.js} +2 -2
  13. package/dist/Game/Player.js.map +1 -0
  14. package/dist/Gui/Gui.d.ts +177 -5
  15. package/dist/Gui/Gui.js +478 -0
  16. package/dist/Gui/Gui.js.map +1 -0
  17. package/dist/Gui/NotificationManager.d.ts +23 -0
  18. package/dist/Gui/NotificationManager.js +51 -0
  19. package/dist/Gui/NotificationManager.js.map +1 -0
  20. package/dist/Resource.d.ts +97 -0
  21. package/dist/Resource.js +114 -0
  22. package/dist/Resource.js.map +1 -0
  23. package/dist/RpgClient.d.ts +259 -59
  24. package/dist/RpgClientEngine.d.ts +632 -9
  25. package/dist/RpgClientEngine.js +1262 -0
  26. package/dist/RpgClientEngine.js.map +1 -0
  27. package/dist/Sound.d.ts +199 -0
  28. package/dist/Sound.js +97 -0
  29. package/dist/Sound.js.map +1 -0
  30. package/dist/components/animations/animation.ce.js +21 -0
  31. package/dist/components/animations/animation.ce.js.map +1 -0
  32. package/dist/{index23.js → components/animations/hit.ce.js} +3 -3
  33. package/dist/components/animations/hit.ce.js.map +1 -0
  34. package/dist/components/animations/index.d.ts +4 -0
  35. package/dist/components/animations/index.js +10 -0
  36. package/dist/components/animations/index.js.map +1 -0
  37. package/dist/components/character.ce.js +316 -0
  38. package/dist/components/character.ce.js.map +1 -0
  39. package/dist/components/dynamics/parse-value.d.ts +1 -0
  40. package/dist/components/dynamics/parse-value.js +54 -0
  41. package/dist/components/dynamics/parse-value.js.map +1 -0
  42. package/dist/components/dynamics/text.ce.js +141 -0
  43. package/dist/components/dynamics/text.ce.js.map +1 -0
  44. package/dist/components/gui/box.ce.js +27 -0
  45. package/dist/components/gui/box.ce.js.map +1 -0
  46. package/dist/components/gui/dialogbox/index.ce.js +152 -0
  47. package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
  48. package/dist/components/gui/gameover.ce.js +141 -0
  49. package/dist/components/gui/gameover.ce.js.map +1 -0
  50. package/dist/components/gui/hud/hud.ce.js +35 -0
  51. package/dist/components/gui/hud/hud.ce.js.map +1 -0
  52. package/dist/components/gui/index.d.ts +15 -3
  53. package/dist/components/gui/menu/equip-menu.ce.js +349 -0
  54. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
  55. package/dist/components/gui/menu/exit-menu.ce.js +35 -0
  56. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
  57. package/dist/components/gui/menu/items-menu.ce.js +229 -0
  58. package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
  59. package/dist/components/gui/menu/main-menu.ce.js +205 -0
  60. package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
  61. package/dist/components/gui/menu/options-menu.ce.js +28 -0
  62. package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
  63. package/dist/components/gui/menu/skills-menu.ce.js +53 -0
  64. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
  65. package/dist/components/gui/mobile/index.d.ts +8 -0
  66. package/dist/components/gui/mobile/index.js +24 -0
  67. package/dist/components/gui/mobile/index.js.map +1 -0
  68. package/dist/components/gui/mobile/mobile.ce.js +17 -0
  69. package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
  70. package/dist/components/gui/notification/notification.ce.js +38 -0
  71. package/dist/components/gui/notification/notification.ce.js.map +1 -0
  72. package/dist/components/gui/save-load.ce.js +242 -0
  73. package/dist/components/gui/save-load.ce.js.map +1 -0
  74. package/dist/components/gui/shop/shop.ce.js +322 -0
  75. package/dist/components/gui/shop/shop.ce.js.map +1 -0
  76. package/dist/components/gui/title-screen.ce.js +148 -0
  77. package/dist/components/gui/title-screen.ce.js.map +1 -0
  78. package/dist/components/index.d.ts +3 -1
  79. package/dist/components/prebuilt/hp-bar.ce.js +106 -0
  80. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
  81. package/dist/components/prebuilt/index.d.ts +19 -0
  82. package/dist/components/prebuilt/light-halo.ce.js +76 -0
  83. package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
  84. package/dist/components/scenes/canvas.ce.js +44 -0
  85. package/dist/components/scenes/canvas.ce.js.map +1 -0
  86. package/dist/components/scenes/draw-map.ce.js +34 -0
  87. package/dist/components/scenes/draw-map.ce.js.map +1 -0
  88. package/dist/{index13.js → components/scenes/event-layer.ce.js} +7 -6
  89. package/dist/components/scenes/event-layer.ce.js.map +1 -0
  90. package/dist/{index6.js → core/inject.js} +2 -2
  91. package/dist/core/inject.js.map +1 -0
  92. package/dist/core/setup.js +16 -0
  93. package/dist/core/setup.js.map +1 -0
  94. package/dist/index.d.ts +15 -1
  95. package/dist/index.js +40 -12
  96. package/dist/index.js.map +1 -1
  97. package/dist/module.d.ts +43 -4
  98. package/dist/module.js +175 -0
  99. package/dist/module.js.map +1 -0
  100. package/dist/node_modules/.pnpm/@signe_di@2.8.2/node_modules/@signe/di/dist/index.js +366 -0
  101. package/dist/node_modules/.pnpm/@signe_di@2.8.2/node_modules/@signe/di/dist/index.js.map +1 -0
  102. package/dist/{index27.js → node_modules/.pnpm/@signe_reactive@2.8.2/node_modules/@signe/reactive/dist/index.js} +229 -11
  103. package/dist/node_modules/.pnpm/@signe_reactive@2.8.2/node_modules/@signe/reactive/dist/index.js.map +1 -0
  104. package/dist/{index20.js → node_modules/.pnpm/@signe_room@2.8.2/node_modules/@signe/room/dist/index.js} +308 -40
  105. package/dist/node_modules/.pnpm/@signe_room@2.8.2/node_modules/@signe/room/dist/index.js.map +1 -0
  106. package/dist/{index26.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/chunk-7QVYU63E.js} +1 -1
  107. package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
  108. package/dist/{index21.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/client/index.js} +5 -5
  109. package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  110. package/dist/{index17.js → node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/index.js} +89 -12
  111. package/dist/node_modules/.pnpm/@signe_sync@2.8.2/node_modules/@signe/sync/dist/index.js.map +1 -0
  112. package/dist/{index33.js → node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js} +1 -1
  113. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
  114. package/dist/{index31.js → node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js} +2 -2
  115. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
  116. package/dist/{index32.js → node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js} +1 -1
  117. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
  118. package/dist/{index34.js → node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js} +1 -1
  119. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
  120. package/dist/presets/animation.d.ts +31 -0
  121. package/dist/presets/animation.js +27 -0
  122. package/dist/presets/animation.js.map +1 -0
  123. package/dist/presets/faceset.d.ts +30 -0
  124. package/dist/presets/faceset.js +24 -0
  125. package/dist/presets/faceset.js.map +1 -0
  126. package/dist/presets/icon.d.ts +20 -0
  127. package/dist/presets/icon.js +15 -0
  128. package/dist/presets/icon.js.map +1 -0
  129. package/dist/presets/index.d.ts +123 -0
  130. package/dist/presets/index.js +16 -0
  131. package/dist/presets/index.js.map +1 -0
  132. package/dist/presets/lpc.d.ts +89 -0
  133. package/dist/presets/lpc.js +95 -0
  134. package/dist/presets/lpc.js.map +1 -0
  135. package/dist/{index25.js → presets/rmspritesheet.js} +1 -1
  136. package/dist/presets/rmspritesheet.js.map +1 -0
  137. package/dist/{index16.js → services/AbstractSocket.js} +1 -1
  138. package/dist/services/AbstractSocket.js.map +1 -0
  139. package/dist/services/keyboardControls.d.ts +15 -0
  140. package/dist/services/keyboardControls.js +21 -0
  141. package/dist/services/keyboardControls.js.map +1 -0
  142. package/dist/services/loadMap.d.ts +123 -2
  143. package/dist/{index7.js → services/loadMap.js} +12 -4
  144. package/dist/services/loadMap.js.map +1 -0
  145. package/dist/services/mmorpg.d.ts +16 -4
  146. package/dist/services/mmorpg.js +84 -0
  147. package/dist/services/mmorpg.js.map +1 -0
  148. package/dist/services/save.d.ts +19 -0
  149. package/dist/services/save.js +69 -0
  150. package/dist/services/save.js.map +1 -0
  151. package/dist/services/standalone.d.ts +65 -3
  152. package/dist/services/standalone.js +170 -0
  153. package/dist/services/standalone.js.map +1 -0
  154. package/dist/utils/getEntityProp.d.ts +39 -0
  155. package/dist/utils/getEntityProp.js +54 -0
  156. package/dist/utils/getEntityProp.js.map +1 -0
  157. package/package.json +24 -18
  158. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  159. package/src/Game/Map.ts +37 -2
  160. package/src/Game/Object.ts +296 -11
  161. package/src/Gui/Gui.ts +506 -18
  162. package/src/Gui/NotificationManager.ts +69 -0
  163. package/src/Resource.ts +150 -0
  164. package/src/RpgClient.ts +264 -58
  165. package/src/RpgClientEngine.ts +1421 -44
  166. package/src/Sound.ts +253 -0
  167. package/src/components/{effects → animations}/animation.ce +3 -6
  168. package/src/components/{effects → animations}/index.ts +1 -1
  169. package/src/components/character.ce +406 -40
  170. package/src/components/dynamics/parse-value.ts +80 -0
  171. package/src/components/dynamics/text.ce +183 -0
  172. package/src/components/gui/box.ce +17 -0
  173. package/src/components/gui/dialogbox/index.ce +204 -187
  174. package/src/components/gui/gameover.ce +158 -0
  175. package/src/components/gui/hud/hud.ce +56 -0
  176. package/src/components/gui/index.ts +30 -4
  177. package/src/components/gui/menu/equip-menu.ce +410 -0
  178. package/src/components/gui/menu/exit-menu.ce +41 -0
  179. package/src/components/gui/menu/items-menu.ce +317 -0
  180. package/src/components/gui/menu/main-menu.ce +291 -0
  181. package/src/components/gui/menu/options-menu.ce +35 -0
  182. package/src/components/gui/menu/skills-menu.ce +83 -0
  183. package/src/components/gui/mobile/index.ts +24 -0
  184. package/src/components/gui/mobile/mobile.ce +80 -0
  185. package/src/components/gui/notification/notification.ce +51 -0
  186. package/src/components/gui/save-load.ce +208 -0
  187. package/src/components/gui/shop/shop.ce +493 -0
  188. package/src/components/gui/title-screen.ce +163 -0
  189. package/src/components/index.ts +5 -1
  190. package/src/components/prebuilt/hp-bar.ce +255 -0
  191. package/src/components/prebuilt/index.ts +24 -0
  192. package/src/components/prebuilt/light-halo.ce +148 -0
  193. package/src/components/scenes/canvas.ce +19 -14
  194. package/src/components/scenes/draw-map.ce +21 -29
  195. package/src/components/scenes/event-layer.ce +10 -3
  196. package/src/components/scenes/transition.ce +60 -0
  197. package/src/core/setup.ts +2 -0
  198. package/src/index.ts +16 -2
  199. package/src/module.ts +145 -9
  200. package/src/presets/animation.ts +46 -0
  201. package/src/presets/faceset.ts +60 -0
  202. package/src/presets/icon.ts +17 -0
  203. package/src/presets/index.ts +9 -1
  204. package/src/presets/lpc.ts +108 -0
  205. package/src/services/keyboardControls.ts +20 -0
  206. package/src/services/loadMap.ts +132 -3
  207. package/src/services/mmorpg.ts +39 -5
  208. package/src/services/save.ts +103 -0
  209. package/src/services/standalone.ts +107 -15
  210. package/src/utils/getEntityProp.ts +87 -0
  211. package/tsconfig.json +1 -1
  212. package/vite.config.ts +5 -3
  213. package/CHANGELOG.md +0 -9
  214. package/dist/Game/EffectManager.d.ts +0 -5
  215. package/dist/components/effects/index.d.ts +0 -4
  216. package/dist/index10.js +0 -8
  217. package/dist/index10.js.map +0 -1
  218. package/dist/index11.js +0 -10
  219. package/dist/index11.js.map +0 -1
  220. package/dist/index12.js +0 -8
  221. package/dist/index12.js.map +0 -1
  222. package/dist/index13.js.map +0 -1
  223. package/dist/index14.js +0 -50
  224. package/dist/index14.js.map +0 -1
  225. package/dist/index15.js +0 -191
  226. package/dist/index15.js.map +0 -1
  227. package/dist/index16.js.map +0 -1
  228. package/dist/index17.js.map +0 -1
  229. package/dist/index18.js +0 -31
  230. package/dist/index18.js.map +0 -1
  231. package/dist/index19.js.map +0 -1
  232. package/dist/index2.js +0 -112
  233. package/dist/index2.js.map +0 -1
  234. package/dist/index20.js.map +0 -1
  235. package/dist/index21.js.map +0 -1
  236. package/dist/index22.js +0 -109
  237. package/dist/index22.js.map +0 -1
  238. package/dist/index23.js.map +0 -1
  239. package/dist/index24.js +0 -21
  240. package/dist/index24.js.map +0 -1
  241. package/dist/index25.js.map +0 -1
  242. package/dist/index26.js.map +0 -1
  243. package/dist/index27.js.map +0 -1
  244. package/dist/index28.js +0 -25
  245. package/dist/index28.js.map +0 -1
  246. package/dist/index29.js.map +0 -1
  247. package/dist/index3.js +0 -87
  248. package/dist/index3.js.map +0 -1
  249. package/dist/index30.js.map +0 -1
  250. package/dist/index31.js.map +0 -1
  251. package/dist/index32.js.map +0 -1
  252. package/dist/index33.js.map +0 -1
  253. package/dist/index34.js.map +0 -1
  254. package/dist/index35.js +0 -91
  255. package/dist/index35.js.map +0 -1
  256. package/dist/index36.js +0 -61
  257. package/dist/index36.js.map +0 -1
  258. package/dist/index37.js +0 -20
  259. package/dist/index37.js.map +0 -1
  260. package/dist/index38.js +0 -20
  261. package/dist/index38.js.map +0 -1
  262. package/dist/index4.js +0 -54
  263. package/dist/index4.js.map +0 -1
  264. package/dist/index5.js +0 -15
  265. package/dist/index5.js.map +0 -1
  266. package/dist/index6.js.map +0 -1
  267. package/dist/index7.js.map +0 -1
  268. package/dist/index8.js +0 -90
  269. package/dist/index8.js.map +0 -1
  270. package/dist/index9.js +0 -76
  271. package/dist/index9.js.map +0 -1
  272. package/src/components/gui/dialogbox/itemMenu.ce +0 -23
  273. package/src/components/gui/dialogbox/selection.ce +0 -67
  274. package/src/components/scenes/element-map.ce +0 -23
  275. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1,83 @@
1
+ <DOMContainer width="100%" height="100%">
2
+ <div class="rpg-ui-menu-panel rpg-ui-panel">
3
+ <div class="rpg-ui-menu-panel-header">Skills</div>
4
+ <div class="rpg-ui-menu-panel-body rpg-ui-menu-panel-body-stacked">
5
+ <div class="rpg-ui-menu-panel-details rpg-ui-panel">
6
+ @if (currentSkill) {
7
+ <div class="rpg-ui-menu-panel-hero">
8
+ <div class="rpg-ui-menu-panel-hero-icon">✨</div>
9
+ <div>
10
+ <div class="rpg-ui-menu-panel-details-title">{currentSkill()?.name}</div>
11
+ <div class="rpg-ui-menu-panel-details-desc">{currentSkill()?.description || ""}</div>
12
+ </div>
13
+ </div>
14
+ }
15
+ </div>
16
+ <div class="rpg-ui-menu-panel-list rpg-ui-menu rpg-ui-menu-panel-list-full">
17
+ <Navigation tabindex={selectedSkill} controls={controls}>
18
+ @for ((skill,index) of skills) {
19
+ <div
20
+ class="rpg-ui-menu-item rpg-ui-menu-row"
21
+ data-selected={selectedSkill() === index ? "true" : "false"}
22
+ tabindex={index}
23
+ click={selectSkill(index)}
24
+ >
25
+ <span>{skill.name}</span>
26
+ <span class="rpg-ui-menu-row-end">SP {skill.spCost ?? 0}</span>
27
+ </div>
28
+ }
29
+ </Navigation>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </DOMContainer>
34
+
35
+ <script>
36
+ import { signal, computed, createTabindexNavigator } from "canvasengine";
37
+ import { inject } from "../../../core/inject";
38
+ import { RpgClientEngine } from "../../../RpgClientEngine";
39
+
40
+ const engine = inject(RpgClientEngine);
41
+ const keyboardControls = engine.globalConfig.keyboardControls;
42
+
43
+ const selectedSkill = signal(0);
44
+ const { data, onBack } = defineProps();
45
+ const skills = computed(() => data().skills);
46
+
47
+ const nav = createTabindexNavigator(selectedSkill, { count: () => skills().length }, "wrap");
48
+ const currentSkill = computed(() => skills()[selectedSkill()]);
49
+
50
+ function selectSkill(index) {
51
+ return function() {
52
+ selectedSkill.set(index);
53
+ }
54
+ }
55
+
56
+ const controls = signal({
57
+ up: {
58
+ repeat: true,
59
+ bind: keyboardControls.up,
60
+ throttle: 150,
61
+ keyDown() {
62
+ nav.next(-1);
63
+ }
64
+ },
65
+ down: {
66
+ repeat: true,
67
+ bind: keyboardControls.down,
68
+ throttle: 150,
69
+ keyDown() {
70
+ nav.next(1);
71
+ }
72
+ },
73
+ escape: {
74
+ bind: keyboardControls.escape,
75
+ keyDown() {
76
+ if (onBack) onBack();
77
+ }
78
+ },
79
+ gamepad: {
80
+ enabled: true
81
+ }
82
+ });
83
+ </script>
@@ -0,0 +1,24 @@
1
+ import { inject } from "../../../core/inject";
2
+ import { RpgClientEngine } from "../../../RpgClientEngine";
3
+ import MobileGui from "./mobile.ce";
4
+ import { signal } from "canvasengine";
5
+
6
+ function isMobile() {
7
+ return /Android|iPhone|iPad|iPod|Windows Phone|webOS|BlackBerry/i.test(navigator.userAgent);
8
+ }
9
+
10
+ export const withMobile = () => (
11
+ {
12
+ gui: [
13
+ {
14
+ id: 'mobile-gui',
15
+ component: MobileGui,
16
+ autoDisplay: true,
17
+ dependencies: () => {
18
+ const engine = inject(RpgClientEngine);
19
+ return [signal(isMobile() ||undefined), engine.controlsReady]
20
+ }
21
+ }
22
+ ]
23
+ }
24
+ )
@@ -0,0 +1,80 @@
1
+ <Container justifyContent="space-between" alignItems="flex-end" width="100%" height="100%">
2
+ <!-- Gamepad buttons A and B (left side) -->
3
+ <Container justifyContent="flex-start" alignItems="flex-end" gap={20}>
4
+ <Container display="flex" direction="column" gap={20} margin={50}>
5
+ <!-- Button B (top) -->
6
+
7
+ <!-- Button A (bottom) -->
8
+ <Button
9
+ text="A"
10
+ shape="circle"
11
+ width={70}
12
+ height={70}
13
+ controls={controlsInstance}
14
+ controlName="action"
15
+ style={{
16
+ backgroundColor: {
17
+ normal: "#2ecc71",
18
+ hover: "#27ae60",
19
+ pressed: "#229954",
20
+ disabled: "#7f8c8d"
21
+ },
22
+ text: {
23
+ fontSize: 24,
24
+ fontFamily: "Arial Bold",
25
+ color: "#ffffff"
26
+ }
27
+ }}
28
+ />
29
+
30
+ <Button
31
+ text="B"
32
+ shape="circle"
33
+ width={70}
34
+ height={70}
35
+ controls={controlsInstance}
36
+ controlName="back"
37
+ style={{
38
+ backgroundColor: {
39
+ normal: "#e74c3c",
40
+ hover: "#c0392b",
41
+ pressed: "#a93226",
42
+ disabled: "#7f8c8d"
43
+ },
44
+ text: {
45
+ fontSize: 24,
46
+ fontFamily: "Arial Bold",
47
+ color: "#ffffff"
48
+ }
49
+ }}
50
+ />
51
+
52
+ </Container>
53
+ </Container>
54
+
55
+ <Container margin={100} alignItems="flex-end">
56
+ <Container>
57
+ <Joystick
58
+ controls={controlsInstance}
59
+ outerColor="#34495e"
60
+ innerColor="#3498db"
61
+ />
62
+ </Container>
63
+ </Container>
64
+ </Container>
65
+
66
+ <script>
67
+ import { signal, mount } from 'canvasengine'
68
+ import { Button } from 'canvasengine'
69
+ import { inject } from '../../../core/inject'
70
+ import { RpgClientEngine } from '../../../RpgClientEngine'
71
+ import { Direction } from '@rpgjs/common'
72
+
73
+
74
+ const controlsInstance = signal(null)
75
+
76
+ mount((element) => {
77
+ const control = inject('KeyboardControls')
78
+ controlsInstance.set(control)
79
+ })
80
+ </script>
@@ -0,0 +1,51 @@
1
+ <DOMContainer width="100%" height="100%" zIndex={100} class="notification">
2
+ <div class="rpg-ui-notifications">
3
+ @for ((notif,index) of notifications) {
4
+ <div
5
+ class="rpg-ui-notification"
6
+ data-type={notif.type || "info"}
7
+ style={notificationStyle(notif)}
8
+ >
9
+ @if (notif.icon) {
10
+ <div class="rpg-ui-notification-icon">
11
+ <DOMSprite sheet={iconSheet(notif.icon)} />
12
+ </div>
13
+ }
14
+ <div class="rpg-ui-notification-message">{notif.message}</div>
15
+ </div>
16
+ }
17
+ </div>
18
+ </DOMContainer>
19
+
20
+ <style>
21
+ .notification {
22
+ pointer-events: none !important;
23
+ }
24
+ </style>
25
+
26
+ <script>
27
+ import { effect, computed } from "canvasengine";
28
+ import { inject } from "../../../core/inject";
29
+ import { RpgClientEngine } from "../../../RpgClientEngine";
30
+
31
+ const engine = inject(RpgClientEngine);
32
+ const notifications = computed(() => engine.notificationManager.stack());
33
+
34
+ const iconSheet = (iconId) => ({
35
+ definition: engine.getSpriteSheet(iconId),
36
+ playing: "default"
37
+ });
38
+
39
+ effect(() => {
40
+ const list = notifications();
41
+ const rowHeight = 68;
42
+ list.forEach((notif, index) => {
43
+ notif.layoutY.set(index * rowHeight);
44
+ });
45
+ });
46
+
47
+ const notificationStyle = (notif) => ({
48
+ opacity: notif.opacity(),
49
+ transform: `translateY(${notif.layoutY() + notif.offset()}px)`
50
+ });
51
+ </script>
@@ -0,0 +1,208 @@
1
+ <DOMContainer width="100%" height="100%">
2
+ <div class="rpg-ui-save-load rpg-anim-fade-in">
3
+ <div class="rpg-ui-save-load-header">
4
+ <div class="rpg-ui-save-load-title">{title()}</div>
5
+ <div class="rpg-ui-save-load-subtitle">{subtitle()}</div>
6
+ </div>
7
+ <Navigation tabindex={selectedSlot} controls={controls}>
8
+ <div class="rpg-ui-save-load-list">
9
+ @for ((item,displayIndex) of displaySlots) {
10
+ <div
11
+ class="rpg-ui-save-load-slot"
12
+ class={{active: selectedSlot() === displayIndex}}
13
+ tabindex={displayIndex}
14
+ data-slot-index={displayIndex}
15
+ click={selectSlot(displayIndex)}
16
+ >
17
+ <div class="rpg-ui-save-load-slot-index">{item.label}</div>
18
+ @if (item.slot) {
19
+ <div class="rpg-ui-save-load-slot-meta">
20
+ <div class="rpg-ui-save-load-slot-line">Level: {item.slot.level ?? "-"}</div>
21
+ <div class="rpg-ui-save-load-slot-line">Exp: {item.slot.exp ?? "-"}</div>
22
+ <div class="rpg-ui-save-load-slot-line">Map: {item.slot.map ?? "-"}</div>
23
+ <div class="rpg-ui-save-load-slot-line">Date: {item.slot.date ?? "-"}</div>
24
+ </div>
25
+ }
26
+ @else {
27
+ <div class="rpg-ui-save-load-slot-empty">Empty Slot</div>
28
+ }
29
+ </div>
30
+ }
31
+ </div>
32
+ </Navigation>
33
+ </div>
34
+ </DOMContainer>
35
+
36
+ <script>
37
+ import { signal, computed, effect, createTabindexNavigator, mount } from "canvasengine";
38
+ import { inject } from "../../core/inject";
39
+ import { RpgClientEngine } from "../../RpgClientEngine";
40
+ import { SaveClientService } from "../../services/save";
41
+ import { PrebuiltGui } from "@rpgjs/common";
42
+ import { RpgGui } from "../../Gui/Gui";
43
+
44
+ const engine = inject(RpgClientEngine);
45
+ const saveClient = inject(SaveClientService);
46
+ const gui = inject(RpgGui);
47
+ const keyboardControls = engine.globalConfig.keyboardControls;
48
+
49
+ const selectedSlot = signal(0);
50
+ const DEFAULT_SLOTS = 4;
51
+ const defaultSlots = () => Array.from({ length: DEFAULT_SLOTS }, () => null);
52
+ const localSlots = signal(defaultSlots());
53
+
54
+ const { data, onFinish } = defineProps();
55
+
56
+ const title = computed(() => data().mode === "save" ? "Save Game" : "Load Game");
57
+ const subtitle = computed(() => data().mode === "save"
58
+ ? "Choose a slot to overwrite or create."
59
+ : "Select a slot to load your progress."
60
+ );
61
+
62
+ const slotsValue = computed(() => localSlots());
63
+ const displaySlots = computed(() => {
64
+ const slots = slotsValue();
65
+ const items = slots.map((slot, index) => ({
66
+ kind: "slot",
67
+ slot,
68
+ slotIndex: index,
69
+ label: `Slot ${index + 1}`,
70
+ readonly: false
71
+ }));
72
+ if (!data().showAutoSlot) return items;
73
+ const index = typeof data().autoSlotIndex === "number" ? data().autoSlotIndex : 0;
74
+ const autoSlot = slots[index] ?? null;
75
+ const readonly = data().mode === "save";
76
+ return [
77
+ {
78
+ kind: "auto",
79
+ slot: autoSlot,
80
+ slotIndex: index,
81
+ label: data().autoSlotLabel || "Auto Save",
82
+ readonly
83
+ },
84
+ ...items
85
+ ];
86
+ });
87
+ const nav = createTabindexNavigator(selectedSlot, { count: () => displaySlots().length }, "wrap");
88
+
89
+ const canSelect = (item) => {
90
+ if (item.readonly) return false;
91
+ if (data().mode === "load" && !item.slot) return false;
92
+ return true;
93
+ };
94
+
95
+ const normalizeSlotValue = (value) => {
96
+ if (!value) return null;
97
+ if (typeof value === "string") {
98
+ try {
99
+ return JSON.parse(value);
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ return value;
105
+ };
106
+
107
+ const normalizeSlots = (list) => {
108
+ if (Array.isArray(list)) {
109
+ const length = Math.max(list.length, DEFAULT_SLOTS);
110
+ return Array.from({ length }, (_, index) => normalizeSlotValue(list[index]));
111
+ }
112
+ if (!list || typeof list !== "object") {
113
+ return defaultSlots();
114
+ }
115
+ const keys = Object.keys(list).filter((key) => /^\d+$/.test(key));
116
+ const indices = keys.map((key) => Number(key)).filter((index) => index >= 0);
117
+ const maxIndex = indices.length ? Math.max(...indices) : -1;
118
+ const length = Math.max(maxIndex + 1, DEFAULT_SLOTS);
119
+ const slots = Array.from({ length }, () => null);
120
+ keys.forEach((key) => {
121
+ const index = Number(key);
122
+ if (index < 0 || index >= length) return;
123
+ slots[index] = normalizeSlotValue(list[key]);
124
+ });
125
+ return slots;
126
+ };
127
+
128
+ const hasProvidedSlots = (list) => {
129
+ if (Array.isArray(list)) return list.length > 0;
130
+ return !!(list && typeof list === "object" && Object.keys(list).length > 0);
131
+ };
132
+
133
+ const refreshSlots = async () => {
134
+ try {
135
+ const list = await saveClient.listSlots();
136
+ localSlots.set(normalizeSlots(list));
137
+ } catch (err) {
138
+ localSlots.set(defaultSlots());
139
+ }
140
+ };
141
+
142
+ const triggerSelect = async (displayIndex) => {
143
+ const list = displaySlots();
144
+ const item = list[displayIndex];
145
+ if (!item) return;
146
+ if (!canSelect(item)) return;
147
+ const action = data().mode === "save" ? "save" : "load";
148
+ if (action === "save") {
149
+ await saveClient.saveSlot(item.slotIndex);
150
+ await refreshSlots();
151
+ }
152
+ if (action === "load") {
153
+ await saveClient.loadSlot(item.slotIndex);
154
+ }
155
+ setTimeout(() => {
156
+ if (onFinish) onFinish();
157
+ gui.hide(PrebuiltGui.Save);
158
+ gui.hide(PrebuiltGui.TitleScreen);
159
+ }, 50);
160
+
161
+ };
162
+
163
+ function selectSlot(index) {
164
+ return function() {
165
+ selectedSlot.set(index);
166
+ triggerSelect(index);
167
+ }
168
+ }
169
+
170
+ const controls = signal({
171
+ up: {
172
+ repeat: true,
173
+ bind: keyboardControls.up,
174
+ throttle: 150,
175
+ keyDown() {
176
+ nav.next(-1);
177
+ }
178
+ },
179
+ down: {
180
+ repeat: true,
181
+ bind: keyboardControls.down,
182
+ throttle: 150,
183
+ keyDown() {
184
+ nav.next(1);
185
+ }
186
+ },
187
+ action: {
188
+ bind: keyboardControls.action,
189
+ keyDown() {
190
+ triggerSelect(selectedSlot());
191
+ }
192
+ },
193
+ escape: {
194
+ bind: keyboardControls.escape,
195
+ keyDown() {
196
+ if (onFinish) onFinish();
197
+ gui.hide(PrebuiltGui.Save);
198
+ }
199
+ },
200
+ gamepad: {
201
+ enabled: true
202
+ }
203
+ });
204
+
205
+ mount((element) => {
206
+ refreshSlots();
207
+ });
208
+ </script>