@rpgjs/client 5.0.0-alpha.8 → 5.0.0-beta.1
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/Game/AnimationManager.js +26 -0
- package/dist/Game/AnimationManager.js.map +1 -0
- package/dist/Game/Event.d.ts +1 -1
- package/dist/Game/Event.js +12 -0
- package/dist/Game/Event.js.map +1 -0
- package/dist/Game/Map.d.ts +23 -2
- package/dist/Game/Map.js +80 -0
- package/dist/Game/Map.js.map +1 -0
- package/dist/Game/Object.d.ts +157 -0
- package/dist/Game/Object.js +211 -0
- package/dist/Game/Object.js.map +1 -0
- package/dist/Game/Player.d.ts +1 -1
- package/dist/Game/Player.js +12 -0
- package/dist/Game/Player.js.map +1 -0
- package/dist/Gui/Gui.d.ts +177 -5
- package/dist/Gui/Gui.js +445 -0
- package/dist/Gui/Gui.js.map +1 -0
- package/dist/Gui/NotificationManager.d.ts +23 -0
- package/dist/Gui/NotificationManager.js +49 -0
- package/dist/Gui/NotificationManager.js.map +1 -0
- package/dist/Resource.d.ts +97 -0
- package/dist/Resource.js +133 -0
- package/dist/Resource.js.map +1 -0
- package/dist/RpgClient.d.ts +290 -58
- package/dist/RpgClientEngine.d.ts +649 -9
- package/dist/RpgClientEngine.js +1334 -0
- package/dist/RpgClientEngine.js.map +1 -0
- package/dist/Sound.d.ts +199 -0
- package/dist/Sound.js +167 -0
- package/dist/Sound.js.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +24 -0
- package/dist/components/animations/animation.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js +70 -0
- 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 +11 -0
- package/dist/components/animations/index.js.map +1 -0
- package/dist/components/character.ce.js +392 -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 +44 -0
- package/dist/components/dynamics/parse-value.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +73 -0
- package/dist/components/dynamics/text.ce.js.map +1 -0
- package/dist/components/gui/box.ce.js +28 -0
- package/dist/components/gui/box.ce.js.map +1 -0
- package/dist/components/gui/dialogbox/index.ce.js +205 -0
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
- package/dist/components/gui/gameover.ce.js +193 -0
- package/dist/components/gui/gameover.ce.js.map +1 -0
- package/dist/components/gui/hud/hud.ce.js +92 -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/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +481 -0
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/exit-menu.ce.js +54 -0
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/items-menu.ce.js +344 -0
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/main-menu.ce.js +417 -0
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/options-menu.ce.js +48 -0
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/skills-menu.ce.js +107 -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 +21 -0
- package/dist/components/gui/mobile/index.js.map +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +78 -0
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
- package/dist/components/gui/notification/notification.ce.js +64 -0
- package/dist/components/gui/notification/notification.ce.js.map +1 -0
- package/dist/components/gui/save-load.ce.js +389 -0
- package/dist/components/gui/save-load.ce.js.map +1 -0
- package/dist/components/gui/shop/shop.ce.js +652 -0
- package/dist/components/gui/shop/shop.ce.js.map +1 -0
- package/dist/components/gui/title-screen.ce.js +190 -0
- package/dist/components/gui/title-screen.ce.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/prebuilt/hp-bar.ce.js +116 -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/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +94 -0
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
- package/dist/components/scenes/canvas.ce.js +60 -0
- package/dist/components/scenes/canvas.ce.js.map +1 -0
- package/dist/components/scenes/draw-map.ce.js +89 -0
- package/dist/components/scenes/draw-map.ce.js.map +1 -0
- package/dist/components/scenes/event-layer.ce.js +28 -0
- package/dist/components/scenes/event-layer.ce.js.map +1 -0
- package/dist/core/inject.js +18 -0
- 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 +44 -14
- package/dist/module.d.ts +43 -4
- package/dist/module.js +176 -0
- package/dist/module.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js +277 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +457 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +463 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +2191 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +10 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +91 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js +325 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +14 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
- 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 +39 -0
- package/dist/presets/animation.js.map +1 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/faceset.js +51 -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 +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/presets/lpc.js +98 -0
- package/dist/presets/lpc.js.map +1 -0
- package/dist/presets/rmspritesheet.js +42 -0
- package/dist/presets/rmspritesheet.js.map +1 -0
- package/dist/services/AbstractSocket.d.ts +9 -5
- package/dist/services/AbstractSocket.js +11 -0
- package/dist/services/AbstractSocket.js.map +1 -0
- package/dist/services/keyboardControls.d.ts +15 -0
- package/dist/services/keyboardControls.js +23 -0
- package/dist/services/keyboardControls.js.map +1 -0
- package/dist/services/loadMap.js +123 -0
- package/dist/services/loadMap.js.map +1 -0
- package/dist/services/mmorpg.d.ts +21 -9
- package/dist/services/mmorpg.js +131 -0
- package/dist/services/mmorpg.js.map +1 -0
- package/dist/services/save.d.ts +19 -0
- package/dist/services/save.js +77 -0
- package/dist/services/save.js.map +1 -0
- package/dist/services/standalone.d.ts +67 -7
- package/dist/services/standalone.js +168 -0
- package/dist/services/standalone.js.map +1 -0
- package/dist/utils/getEntityProp.d.ts +39 -0
- package/dist/utils/getEntityProp.js +52 -0
- package/dist/utils/getEntityProp.js.map +1 -0
- package/package.json +13 -9
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Event.ts +1 -1
- package/src/Game/Map.ts +95 -3
- package/src/Game/Object.ts +330 -14
- package/src/Game/Player.ts +1 -1
- package/src/Gui/Gui.ts +506 -18
- package/src/Gui/NotificationManager.ts +69 -0
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +300 -58
- package/src/RpgClientEngine.ts +1707 -48
- 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 +61 -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 +294 -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 +3 -0
- 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 +20 -15
- package/src/components/scenes/draw-map.ce +60 -13
- package/src/components/scenes/event-layer.ce +9 -2
- package/src/components/scenes/transition.ce +60 -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/AbstractSocket.ts +10 -2
- package/src/services/keyboardControls.ts +20 -0
- package/src/services/loadMap.ts +1 -1
- package/src/services/mmorpg.ts +100 -12
- package/src/services/save.ts +103 -0
- package/src/services/standalone.ts +110 -18
- package/src/utils/getEntityProp.ts +87 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +4 -2
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/dist/index.js.map +0 -1
- 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 +0 -17
- package/dist/index13.js.map +0 -1
- package/dist/index14.js +0 -91
- package/dist/index14.js.map +0 -1
- package/dist/index15.js +0 -50
- package/dist/index15.js.map +0 -1
- package/dist/index16.js +0 -191
- package/dist/index16.js.map +0 -1
- package/dist/index17.js +0 -9
- package/dist/index17.js.map +0 -1
- package/dist/index18.js +0 -387
- package/dist/index18.js.map +0 -1
- package/dist/index19.js +0 -31
- package/dist/index19.js.map +0 -1
- package/dist/index2.js +0 -112
- package/dist/index2.js.map +0 -1
- package/dist/index20.js +0 -24
- package/dist/index20.js.map +0 -1
- package/dist/index21.js +0 -2421
- package/dist/index21.js.map +0 -1
- package/dist/index22.js +0 -114
- package/dist/index22.js.map +0 -1
- package/dist/index23.js +0 -109
- package/dist/index23.js.map +0 -1
- package/dist/index24.js +0 -71
- package/dist/index24.js.map +0 -1
- package/dist/index25.js +0 -21
- package/dist/index25.js.map +0 -1
- package/dist/index26.js +0 -41
- package/dist/index26.js.map +0 -1
- package/dist/index27.js +0 -5
- package/dist/index27.js.map +0 -1
- package/dist/index28.js +0 -322
- package/dist/index28.js.map +0 -1
- package/dist/index29.js +0 -27
- package/dist/index29.js.map +0 -1
- package/dist/index3.js +0 -87
- package/dist/index3.js.map +0 -1
- package/dist/index30.js +0 -11
- package/dist/index30.js.map +0 -1
- package/dist/index31.js +0 -11
- package/dist/index31.js.map +0 -1
- package/dist/index32.js +0 -12
- package/dist/index32.js.map +0 -1
- package/dist/index33.js +0 -4403
- package/dist/index33.js.map +0 -1
- package/dist/index34.js +0 -316
- package/dist/index34.js.map +0 -1
- package/dist/index35.js +0 -174
- package/dist/index35.js.map +0 -1
- package/dist/index36.js +0 -501
- package/dist/index36.js.map +0 -1
- package/dist/index37.js +0 -61
- package/dist/index37.js.map +0 -1
- package/dist/index38.js +0 -20
- package/dist/index38.js.map +0 -1
- package/dist/index39.js +0 -20
- package/dist/index39.js.map +0 -1
- package/dist/index4.js +0 -67
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -16
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -17
- package/dist/index6.js.map +0 -1
- package/dist/index7.js +0 -39
- 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/{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>
|