@rpgjs/client 4.2.2 → 5.0.0-alpha.0
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/EffectManager.d.ts +5 -0
- package/dist/Game/Event.d.ts +4 -0
- package/dist/Game/Map.d.ts +7 -0
- package/dist/Game/Player.d.ts +4 -0
- package/dist/Gui/Gui.d.ts +23 -0
- package/{lib → dist}/RpgClient.d.ts +9 -6
- package/dist/RpgClientEngine.d.ts +43 -0
- package/dist/components/effects/index.d.ts +4 -0
- package/dist/components/gui/index.d.ts +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/core/inject.d.ts +5 -0
- package/dist/core/setup.d.ts +6 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index10.js +8 -0
- package/dist/index10.js.map +1 -0
- package/dist/index11.js +10 -0
- package/dist/index11.js.map +1 -0
- package/dist/index12.js +8 -0
- package/dist/index12.js.map +1 -0
- package/dist/index13.js +17 -0
- package/dist/index13.js.map +1 -0
- package/dist/index14.js +50 -0
- package/dist/index14.js.map +1 -0
- package/dist/index15.js +191 -0
- package/dist/index15.js.map +1 -0
- package/dist/index16.js +9 -0
- package/dist/index16.js.map +1 -0
- package/dist/index17.js +387 -0
- package/dist/index17.js.map +1 -0
- package/dist/index18.js +31 -0
- package/dist/index18.js.map +1 -0
- package/dist/index19.js +24 -0
- package/dist/index19.js.map +1 -0
- package/dist/index2.js +112 -0
- package/dist/index2.js.map +1 -0
- package/dist/index20.js +2421 -0
- package/dist/index20.js.map +1 -0
- package/dist/index21.js +114 -0
- package/dist/index21.js.map +1 -0
- package/dist/index22.js +109 -0
- package/dist/index22.js.map +1 -0
- package/dist/index23.js +71 -0
- package/dist/index23.js.map +1 -0
- package/dist/index24.js +21 -0
- package/dist/index24.js.map +1 -0
- package/dist/index25.js +41 -0
- package/dist/index25.js.map +1 -0
- package/dist/index26.js +5 -0
- package/dist/index26.js.map +1 -0
- package/dist/index27.js +322 -0
- package/dist/index27.js.map +1 -0
- package/dist/index28.js +25 -0
- package/dist/index28.js.map +1 -0
- package/dist/index29.js +11 -0
- package/dist/index29.js.map +1 -0
- package/dist/index3.js +87 -0
- package/dist/index3.js.map +1 -0
- package/dist/index30.js +11 -0
- package/dist/index30.js.map +1 -0
- package/dist/index31.js +174 -0
- package/dist/index31.js.map +1 -0
- package/dist/index32.js +501 -0
- package/dist/index32.js.map +1 -0
- package/dist/index33.js +12 -0
- package/dist/index33.js.map +1 -0
- package/dist/index34.js +4403 -0
- package/dist/index34.js.map +1 -0
- package/dist/index35.js +91 -0
- package/dist/index35.js.map +1 -0
- package/dist/index36.js +61 -0
- package/dist/index36.js.map +1 -0
- package/dist/index37.js +20 -0
- package/dist/index37.js.map +1 -0
- package/dist/index38.js +20 -0
- package/dist/index38.js.map +1 -0
- package/dist/index4.js +54 -0
- package/dist/index4.js.map +1 -0
- package/dist/index5.js +15 -0
- package/dist/index5.js.map +1 -0
- package/dist/index6.js +17 -0
- package/dist/index6.js.map +1 -0
- package/dist/index7.js +31 -0
- package/dist/index7.js.map +1 -0
- package/dist/index8.js +90 -0
- package/dist/index8.js.map +1 -0
- package/dist/index9.js +76 -0
- package/dist/index9.js.map +1 -0
- package/dist/module.d.ts +14 -0
- package/dist/presets/index.d.ts +22 -0
- package/{lib/Presets/AnimationSpritesheet.d.ts → dist/presets/rmspritesheet.d.ts} +6 -2
- package/dist/services/AbstractSocket.d.ts +15 -0
- package/dist/services/loadMap.d.ts +14 -0
- package/dist/services/mmorpg.d.ts +32 -0
- package/dist/services/standalone.d.ts +34 -0
- package/package.json +25 -42
- package/src/Game/EffectManager.ts +20 -0
- package/src/Game/Event.ts +5 -0
- package/src/Game/Map.ts +10 -0
- package/src/Game/Object.ts +16 -0
- package/src/Game/Player.ts +5 -0
- package/src/Gui/Gui.ts +80 -534
- package/src/RpgClient.ts +9 -5
- package/src/RpgClientEngine.ts +135 -815
- package/src/components/character.ce +104 -0
- package/src/components/effects/animation.ce +19 -0
- package/src/components/effects/hit.ce +87 -0
- package/src/components/effects/index.ts +7 -0
- package/src/components/gui/dialogbox/index.ce +194 -0
- package/src/components/gui/dialogbox/itemMenu.ce +23 -0
- package/src/components/gui/dialogbox/selection.ce +67 -0
- package/src/components/gui/index.ts +5 -0
- package/src/components/index.ts +3 -0
- package/src/components/scenes/canvas.ce +51 -0
- package/src/components/scenes/draw-map.ce +56 -0
- package/src/components/scenes/element-map.ce +23 -0
- package/src/components/scenes/event-layer.ce +20 -0
- package/src/core/inject.ts +17 -0
- package/src/core/setup.ts +18 -0
- package/src/index.ts +13 -29
- package/src/module.ts +93 -0
- package/src/presets/index.ts +5 -0
- package/src/{Presets/AnimationSpritesheet.ts → presets/rmspritesheet.ts} +4 -5
- package/src/services/AbstractSocket.ts +14 -0
- package/src/services/loadMap.ts +33 -0
- package/src/services/mmorpg.ts +64 -0
- package/src/services/standalone.ts +101 -0
- package/src/types/canvas-engine.d.ts +26 -0
- package/tsconfig.json +8 -3
- package/vite.config.ts +34 -0
- package/CHANGELOG.md +0 -177
- package/LICENSE +0 -19
- package/browser/React-f6f9b1de.js +0 -157
- package/browser/index-e74a289f.js +0 -44225
- package/browser/manifest.json +0 -21
- package/browser/rpg.client.js +0 -40
- package/browser/rpg.client.umd.cjs +0 -44414
- package/lib/Components/AbstractComponent.d.ts +0 -32
- package/lib/Components/AbstractComponent.js +0 -93
- package/lib/Components/AbstractComponent.js.map +0 -1
- package/lib/Components/BarComponent.d.ts +0 -21
- package/lib/Components/BarComponent.js +0 -169
- package/lib/Components/BarComponent.js.map +0 -1
- package/lib/Components/Component.d.ts +0 -124
- package/lib/Components/Component.js +0 -425
- package/lib/Components/Component.js.map +0 -1
- package/lib/Components/DebugComponent.d.ts +0 -11
- package/lib/Components/DebugComponent.js +0 -32
- package/lib/Components/DebugComponent.js.map +0 -1
- package/lib/Components/ImageComponent.d.ts +0 -11
- package/lib/Components/ImageComponent.js +0 -30
- package/lib/Components/ImageComponent.js.map +0 -1
- package/lib/Components/ShapeComponent.d.ts +0 -11
- package/lib/Components/ShapeComponent.js +0 -57
- package/lib/Components/ShapeComponent.js.map +0 -1
- package/lib/Components/TextComponent.d.ts +0 -11
- package/lib/Components/TextComponent.js +0 -35
- package/lib/Components/TextComponent.js.map +0 -1
- package/lib/Components/TileComponent.d.ts +0 -10
- package/lib/Components/TileComponent.js +0 -40
- package/lib/Components/TileComponent.js.map +0 -1
- package/lib/Effects/Animation.d.ts +0 -55
- package/lib/Effects/Animation.js +0 -233
- package/lib/Effects/Animation.js.map +0 -1
- package/lib/Effects/AnimationCharacter.d.ts +0 -7
- package/lib/Effects/AnimationCharacter.js +0 -9
- package/lib/Effects/AnimationCharacter.js.map +0 -1
- package/lib/Effects/Spinner.d.ts +0 -7
- package/lib/Effects/Spinner.js +0 -18
- package/lib/Effects/Spinner.js.map +0 -1
- package/lib/Effects/Timeline.d.ts +0 -151
- package/lib/Effects/Timeline.js +0 -369
- package/lib/Effects/Timeline.js.map +0 -1
- package/lib/Effects/TransitionScene.d.ts +0 -18
- package/lib/Effects/TransitionScene.js +0 -50
- package/lib/Effects/TransitionScene.js.map +0 -1
- package/lib/GameEngine.d.ts +0 -68
- package/lib/GameEngine.js +0 -254
- package/lib/GameEngine.js.map +0 -1
- package/lib/Gui/Gui.d.ts +0 -110
- package/lib/Gui/Gui.js +0 -490
- package/lib/Gui/Gui.js.map +0 -1
- package/lib/Gui/React.d.ts +0 -15
- package/lib/Gui/React.js +0 -113
- package/lib/Gui/React.js.map +0 -1
- package/lib/Gui/Vue.d.ts +0 -13
- package/lib/Gui/Vue.js +0 -114
- package/lib/Gui/Vue.js.map +0 -1
- package/lib/Interfaces/Character.d.ts +0 -6
- package/lib/Interfaces/Character.js +0 -2
- package/lib/Interfaces/Character.js.map +0 -1
- package/lib/Interfaces/Scene.d.ts +0 -10
- package/lib/Interfaces/Scene.js +0 -2
- package/lib/Interfaces/Scene.js.map +0 -1
- package/lib/KeyboardControls.d.ts +0 -367
- package/lib/KeyboardControls.js +0 -714
- package/lib/KeyboardControls.js.map +0 -1
- package/lib/Logger.d.ts +0 -1
- package/lib/Logger.js +0 -4
- package/lib/Logger.js.map +0 -1
- package/lib/Presets/AnimationSpritesheet.js +0 -39
- package/lib/Presets/AnimationSpritesheet.js.map +0 -1
- package/lib/Presets/Scene.d.ts +0 -3
- package/lib/Presets/Scene.js +0 -5
- package/lib/Presets/Scene.js.map +0 -1
- package/lib/Renderer.d.ts +0 -62
- package/lib/Renderer.js +0 -300
- package/lib/Renderer.js.map +0 -1
- package/lib/Resources.d.ts +0 -22
- package/lib/Resources.js +0 -38
- package/lib/Resources.js.map +0 -1
- package/lib/RpgClient.js +0 -2
- package/lib/RpgClient.js.map +0 -1
- package/lib/RpgClientEngine.d.ts +0 -257
- package/lib/RpgClientEngine.js +0 -674
- package/lib/RpgClientEngine.js.map +0 -1
- package/lib/Scene/EventLayer.d.ts +0 -4
- package/lib/Scene/EventLayer.js +0 -8
- package/lib/Scene/EventLayer.js.map +0 -1
- package/lib/Scene/Map.d.ts +0 -109
- package/lib/Scene/Map.js +0 -319
- package/lib/Scene/Map.js.map +0 -1
- package/lib/Scene/Scene.d.ts +0 -184
- package/lib/Scene/Scene.js +0 -250
- package/lib/Scene/Scene.js.map +0 -1
- package/lib/Scene/SceneData.d.ts +0 -4
- package/lib/Scene/SceneData.js +0 -8
- package/lib/Scene/SceneData.js.map +0 -1
- package/lib/Sound/RpgSound.d.ts +0 -11
- package/lib/Sound/RpgSound.js +0 -46
- package/lib/Sound/RpgSound.js.map +0 -1
- package/lib/Sound/Sound.d.ts +0 -78
- package/lib/Sound/Sound.js +0 -12
- package/lib/Sound/Sound.js.map +0 -1
- package/lib/Sound/Sounds.d.ts +0 -2
- package/lib/Sound/Sounds.js +0 -6
- package/lib/Sound/Sounds.js.map +0 -1
- package/lib/Sprite/Character.d.ts +0 -18
- package/lib/Sprite/Character.js +0 -131
- package/lib/Sprite/Character.js.map +0 -1
- package/lib/Sprite/Player.d.ts +0 -3
- package/lib/Sprite/Player.js +0 -4
- package/lib/Sprite/Player.js.map +0 -1
- package/lib/Sprite/Spritesheet.d.ts +0 -365
- package/lib/Sprite/Spritesheet.js +0 -13
- package/lib/Sprite/Spritesheet.js.map +0 -1
- package/lib/Sprite/Spritesheets.d.ts +0 -3
- package/lib/Sprite/Spritesheets.js +0 -6
- package/lib/Sprite/Spritesheets.js.map +0 -1
- package/lib/Tilemap/CommonLayer.d.ts +0 -10
- package/lib/Tilemap/CommonLayer.js +0 -17
- package/lib/Tilemap/CommonLayer.js.map +0 -1
- package/lib/Tilemap/ImageLayer.d.ts +0 -4
- package/lib/Tilemap/ImageLayer.js +0 -16
- package/lib/Tilemap/ImageLayer.js.map +0 -1
- package/lib/Tilemap/Tile.d.ts +0 -21
- package/lib/Tilemap/Tile.js +0 -67
- package/lib/Tilemap/Tile.js.map +0 -1
- package/lib/Tilemap/TileLayer.d.ts +0 -13
- package/lib/Tilemap/TileLayer.js +0 -122
- package/lib/Tilemap/TileLayer.js.map +0 -1
- package/lib/Tilemap/TileSet.d.ts +0 -7
- package/lib/Tilemap/TileSet.js +0 -24
- package/lib/Tilemap/TileSet.js.map +0 -1
- package/lib/Tilemap/index.d.ts +0 -28
- package/lib/Tilemap/index.js +0 -151
- package/lib/Tilemap/index.js.map +0 -1
- package/lib/clientEntryPoint.d.ts +0 -89
- package/lib/clientEntryPoint.js +0 -48
- package/lib/clientEntryPoint.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.js +0 -27
- package/lib/index.js.map +0 -1
- package/lib/inject.d.ts +0 -23
- package/lib/inject.js +0 -30
- package/lib/inject.js.map +0 -1
- package/rpg.toml +0 -14
- package/src/Components/AbstractComponent.ts +0 -120
- package/src/Components/BarComponent.ts +0 -181
- package/src/Components/Component.ts +0 -515
- package/src/Components/DebugComponent.ts +0 -36
- package/src/Components/ImageComponent.ts +0 -30
- package/src/Components/ShapeComponent.ts +0 -64
- package/src/Components/TextComponent.ts +0 -33
- package/src/Components/TileComponent.ts +0 -43
- package/src/Effects/Animation.ts +0 -310
- package/src/Effects/AnimationCharacter.ts +0 -7
- package/src/Effects/Spinner.ts +0 -19
- package/src/Effects/Timeline.ts +0 -378
- package/src/Effects/TransitionScene.ts +0 -59
- package/src/GameEngine.ts +0 -289
- package/src/Gui/React.ts +0 -145
- package/src/Gui/Vue.ts +0 -154
- package/src/Interfaces/Character.ts +0 -7
- package/src/Interfaces/Scene.ts +0 -9
- package/src/KeyboardControls.ts +0 -748
- package/src/Logger.ts +0 -3
- package/src/Presets/Scene.ts +0 -3
- package/src/Renderer.ts +0 -334
- package/src/Resources.ts +0 -39
- package/src/Scene/EventLayer.ts +0 -9
- package/src/Scene/Map.ts +0 -402
- package/src/Scene/Scene.ts +0 -305
- package/src/Scene/SceneData.ts +0 -13
- package/src/Sound/RpgSound.ts +0 -50
- package/src/Sound/Sound.ts +0 -91
- package/src/Sound/Sounds.ts +0 -7
- package/src/Sprite/Character.ts +0 -157
- package/src/Sprite/Player.ts +0 -3
- package/src/Sprite/Spritesheet.ts +0 -392
- package/src/Sprite/Spritesheets.ts +0 -8
- package/src/Tilemap/CommonLayer.ts +0 -20
- package/src/Tilemap/ImageLayer.ts +0 -20
- package/src/Tilemap/Tile.ts +0 -80
- package/src/Tilemap/TileLayer.ts +0 -142
- package/src/Tilemap/TileSet.ts +0 -40
- package/src/Tilemap/index.ts +0 -175
- package/src/clientEntryPoint.ts +0 -150
- package/src/inject.ts +0 -34
- package/src/types/howler.d.ts +0 -73
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
import { Direction, HookClient, RpgCommonPlayer, RpgPlugin, RpgShape, Utils } from "@rpgjs/common"
|
|
2
|
-
import { ComponentObject, LayoutObject, LayoutOptions, LayoutPositionEnum, PlayerType, PositionXY } from "@rpgjs/types"
|
|
3
|
-
import { Subject, Subscription, map, filter, tap, distinctUntilChanged, takeUntil, finalize } from "rxjs"
|
|
4
|
-
import { log } from "../Logger"
|
|
5
|
-
import { Scene } from "../Scene/Scene"
|
|
6
|
-
import { RpgSprite } from "../Sprite/Player"
|
|
7
|
-
import { AbstractComponent } from "./AbstractComponent"
|
|
8
|
-
import { BarComponent } from "./BarComponent"
|
|
9
|
-
import { ShapeComponent } from "./ShapeComponent"
|
|
10
|
-
import { DebugComponent } from "./DebugComponent"
|
|
11
|
-
import { ImageComponent } from "./ImageComponent"
|
|
12
|
-
import { TextComponent } from "./TextComponent"
|
|
13
|
-
import { TileComponent } from "./TileComponent"
|
|
14
|
-
import { Container, Sprite } from "pixi.js"
|
|
15
|
-
|
|
16
|
-
type SpriteInfo = {
|
|
17
|
-
width: number,
|
|
18
|
-
height: number,
|
|
19
|
-
x: number,
|
|
20
|
-
y: number,
|
|
21
|
-
anchor: { x: number, y: number },
|
|
22
|
-
spriteWidth: number
|
|
23
|
-
spriteHeight: number
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IComponent {
|
|
27
|
-
id: string,
|
|
28
|
-
value: any
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const layoutObject = {
|
|
32
|
-
lines: []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const layoutTypes: LayoutPositionEnum[] = ['top', 'bottom', 'left', 'right']
|
|
36
|
-
|
|
37
|
-
export class RpgComponent<T = any> extends Container {
|
|
38
|
-
/** @internal */
|
|
39
|
-
tilesOverlay: any
|
|
40
|
-
/** @internal */
|
|
41
|
-
h: number = 1
|
|
42
|
-
/** @internal */
|
|
43
|
-
w: number = 1
|
|
44
|
-
|
|
45
|
-
animationIsPlaying: boolean = false
|
|
46
|
-
|
|
47
|
-
protected _x: number = 0
|
|
48
|
-
protected _y: number = 0
|
|
49
|
-
private _rotation: number = 0
|
|
50
|
-
protected teleported: number = 0
|
|
51
|
-
protected map: string = ''
|
|
52
|
-
protected z: number = 0
|
|
53
|
-
protected fixed: boolean = false
|
|
54
|
-
private components: LayoutObject<any> = {
|
|
55
|
-
top: layoutObject,
|
|
56
|
-
bottom: layoutObject,
|
|
57
|
-
left: layoutObject,
|
|
58
|
-
right: layoutObject,
|
|
59
|
-
center: layoutObject
|
|
60
|
-
}
|
|
61
|
-
private direction: number = 0
|
|
62
|
-
private container: Container = new Container()
|
|
63
|
-
|
|
64
|
-
private containersLayout: {
|
|
65
|
-
[key in LayoutPositionEnum]: Container
|
|
66
|
-
} = {} as any
|
|
67
|
-
|
|
68
|
-
private subscriptionGraphic: Subscription
|
|
69
|
-
private layoutNotifierClear: { [key in LayoutPositionEnum]: Subject<void> } = {
|
|
70
|
-
top: new Subject(),
|
|
71
|
-
bottom: new Subject(),
|
|
72
|
-
left: new Subject(),
|
|
73
|
-
right: new Subject(),
|
|
74
|
-
center: new Subject()
|
|
75
|
-
}
|
|
76
|
-
private registerComponents: Map<string, any> = new Map()
|
|
77
|
-
private dragMode?: {
|
|
78
|
-
data: any,
|
|
79
|
-
dragging: boolean
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
readonly game = this.scene.game
|
|
83
|
-
readonly id: string = this.data.id
|
|
84
|
-
|
|
85
|
-
constructor(private data: RpgCommonPlayer | RpgShape, private scene: Scene) {
|
|
86
|
-
super()
|
|
87
|
-
this.setPosition(false)
|
|
88
|
-
this.registerComponents.set(RpgSprite.id, RpgSprite)
|
|
89
|
-
this.registerComponents.set(TextComponent.id, TextComponent)
|
|
90
|
-
this.registerComponents.set(ShapeComponent.id, ShapeComponent)
|
|
91
|
-
this.registerComponents.set(TileComponent.id, TileComponent)
|
|
92
|
-
this.registerComponents.set(ImageComponent.id, ImageComponent)
|
|
93
|
-
this.registerComponents.set(BarComponent.id, BarComponent)
|
|
94
|
-
this.registerComponents.set(DebugComponent.id, DebugComponent)
|
|
95
|
-
|
|
96
|
-
this.addChild(this.container)
|
|
97
|
-
|
|
98
|
-
for (let layout of [...layoutTypes, 'center']) {
|
|
99
|
-
this.containersLayout[layout] = new Container()
|
|
100
|
-
this.container.addChild(this.containersLayout[layout])
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
RpgPlugin.emit(HookClient.AddSprite, this)
|
|
104
|
-
RpgPlugin.emit(HookClient.SceneAddSprite, [this.scene, this], true)
|
|
105
|
-
|
|
106
|
-
this.game.listenObject(data.id)
|
|
107
|
-
.pipe(
|
|
108
|
-
takeUntil(this.game.getDeleteNotifier(data.id)),
|
|
109
|
-
map(object => object?.paramsChanged),
|
|
110
|
-
tap(() => {
|
|
111
|
-
RpgPlugin.emit(HookClient.ChangesSprite, [this, this.logic?.['paramsChanged'], this.logic?.['prevParamsChanged']], true)
|
|
112
|
-
}),
|
|
113
|
-
filter(object => {
|
|
114
|
-
return this.logic?.['componentChanged']
|
|
115
|
-
})
|
|
116
|
-
)
|
|
117
|
-
.subscribe((val) => {
|
|
118
|
-
if (this.logic) {
|
|
119
|
-
this.updateComponents(this.logic?.['componentChanged'])
|
|
120
|
-
this.logic['componentChanged'] = undefined
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* the direction of the sprite
|
|
128
|
-
*
|
|
129
|
-
* @prop {Direction} dir
|
|
130
|
-
* @readonly
|
|
131
|
-
* @memberof RpgSprite
|
|
132
|
-
* */
|
|
133
|
-
get dir(): Direction {
|
|
134
|
-
return this.direction
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* To know if the sprite is a player
|
|
139
|
-
*
|
|
140
|
-
* @prop {boolean} isPlayer
|
|
141
|
-
* @readonly
|
|
142
|
-
* @memberof RpgSprite
|
|
143
|
-
* */
|
|
144
|
-
get isPlayer(): boolean {
|
|
145
|
-
return this.data.type == PlayerType.Player
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* To know if the sprite is an event
|
|
150
|
-
*
|
|
151
|
-
* @prop {boolean} isEvent
|
|
152
|
-
* @readonly
|
|
153
|
-
* @memberof RpgSprite
|
|
154
|
-
* */
|
|
155
|
-
get isEvent(): boolean {
|
|
156
|
-
return this.data.type == PlayerType.Event
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* To know if the sprite is a shape
|
|
161
|
-
*
|
|
162
|
-
* @prop {boolean} isShape
|
|
163
|
-
* @since 3.0.0-rc
|
|
164
|
-
* @readonly
|
|
165
|
-
* @memberof RpgSprite
|
|
166
|
-
* */
|
|
167
|
-
get isShape(): boolean {
|
|
168
|
-
return Utils.isInstanceOf(this.data, RpgShape)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* To know if the sprite is the sprite controlled by the player
|
|
173
|
-
*
|
|
174
|
-
* @prop {boolean} isCurrentPlayer
|
|
175
|
-
* @readonly
|
|
176
|
-
* @memberof RpgSprite
|
|
177
|
-
* */
|
|
178
|
-
get isCurrentPlayer(): boolean {
|
|
179
|
-
return this.data.id === this.scene.game.playerId
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Retrieves the logic of the sprite
|
|
184
|
-
*
|
|
185
|
-
* @prop {RpgSpriteLogic} logic
|
|
186
|
-
* @readonly
|
|
187
|
-
* @since 3.0.0-beta.4
|
|
188
|
-
* @memberof RpgSprite
|
|
189
|
-
* */
|
|
190
|
-
get logic(): RpgCommonPlayer | RpgShape | null {
|
|
191
|
-
return this.scene.game.world.getAll(this.data.id)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
get guiDisplay(): boolean {
|
|
195
|
-
return (this.logic as RpgCommonPlayer).guiDisplay
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
set guiDisplay(val: boolean) {
|
|
199
|
-
(this.logic as RpgCommonPlayer).guiDisplay = val
|
|
200
|
-
this.game.setObject(this.logic?.id, {
|
|
201
|
-
object: this.logic,
|
|
202
|
-
paramsChanged: {
|
|
203
|
-
guiDisplay: val
|
|
204
|
-
}
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
setPosition(smooth: boolean = true) {
|
|
209
|
-
if (this.isShape) {
|
|
210
|
-
const { width, height, x, y } = this.data as RpgShape
|
|
211
|
-
this.w = width
|
|
212
|
-
this.h = height
|
|
213
|
-
this._x = Math.floor(x)
|
|
214
|
-
this._y = Math.floor(y)
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
const { position, direction } = this.data as RpgCommonPlayer
|
|
218
|
-
this._x = position?.x ?? 0
|
|
219
|
-
this._y = position?.y ?? 0
|
|
220
|
-
this.z = position?.z ?? 0
|
|
221
|
-
this.direction = direction
|
|
222
|
-
}
|
|
223
|
-
this._rotation = this.data['rotation'] ?? 0
|
|
224
|
-
if (!smooth) {
|
|
225
|
-
this.x = this._x
|
|
226
|
-
this.y = this._y
|
|
227
|
-
this.angle = this._rotation
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// TODO
|
|
232
|
-
/*drag() {
|
|
233
|
-
this.interactive = true
|
|
234
|
-
const filter = new filters.ColorMatrixFilter();
|
|
235
|
-
|
|
236
|
-
const onDragEnd = () => {
|
|
237
|
-
if (!this.dragMode) return
|
|
238
|
-
this.dragMode.dragging = false
|
|
239
|
-
this.dragMode.data = null
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
this
|
|
243
|
-
.on('pointerdown', (event) => {
|
|
244
|
-
this.dragMode = {
|
|
245
|
-
data: event.data,
|
|
246
|
-
dragging: true
|
|
247
|
-
}
|
|
248
|
-
})
|
|
249
|
-
.on('pointerup', onDragEnd)
|
|
250
|
-
.on('pointerupoutside', onDragEnd)
|
|
251
|
-
.on('pointermove', () => {
|
|
252
|
-
if (!this.dragMode) return
|
|
253
|
-
const { dragging, data } = this.dragMode
|
|
254
|
-
if (dragging) {
|
|
255
|
-
const newPosition = data.getLocalPosition(this.parent)
|
|
256
|
-
this.x = newPosition.x
|
|
257
|
-
this.y = newPosition.y
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
}*/
|
|
261
|
-
|
|
262
|
-
update(obj: any, objChanged: any, time: number, deltaRatio: number): { moving: boolean } {
|
|
263
|
-
if (this.dragMode?.dragging) return { moving: true }
|
|
264
|
-
|
|
265
|
-
const { speed, teleported, map, fixed } = obj
|
|
266
|
-
this.data = obj
|
|
267
|
-
this.setPosition()
|
|
268
|
-
const renderSpeed = speed * deltaRatio
|
|
269
|
-
if (this._rotation != this.angle) {
|
|
270
|
-
this.angle += Math.min(renderSpeed, this._rotation - this.angle)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
let moving = obj.moving ?? false
|
|
274
|
-
|
|
275
|
-
if (!fixed) {
|
|
276
|
-
if (teleported != this.teleported || map != this.map) {
|
|
277
|
-
this.x = this._x
|
|
278
|
-
this.y = this._y
|
|
279
|
-
this.teleported = teleported
|
|
280
|
-
this.map = map
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
this.parent.parent.zIndex = this._y
|
|
284
|
-
|
|
285
|
-
obj.posX = this._x
|
|
286
|
-
obj.posY = this._y
|
|
287
|
-
|
|
288
|
-
if (this._x > this.x) {
|
|
289
|
-
this.x += Math.min(renderSpeed, this._x - this.x)
|
|
290
|
-
moving = true
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (this._x < this.x) {
|
|
294
|
-
this.x -= Math.min(renderSpeed, this.x - this._x)
|
|
295
|
-
moving = true
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (this._y > this.y) {
|
|
299
|
-
this.y += Math.min(renderSpeed, this._y - this.y)
|
|
300
|
-
moving = true
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (this._y < this.y) {
|
|
304
|
-
this.y -= Math.min(renderSpeed, this.y - this._y)
|
|
305
|
-
moving = true
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
this.callMethodInComponents('update', [obj, { moving }, deltaRatio])
|
|
310
|
-
this.onUpdate(obj)
|
|
311
|
-
|
|
312
|
-
return {
|
|
313
|
-
moving
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
showAnimation(graphic: string | string[], animationName: string) {
|
|
318
|
-
return this.callMethodInComponents('showAnimation', [graphic, animationName])
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Recover the position according to the graphic
|
|
323
|
-
* Normally, the position is that of the hitbox but, we retrieve the top left corner of the graphic
|
|
324
|
-
*
|
|
325
|
-
* You can also pass the `middle` value as first parameter to retrieve the positions from the middle of the sprite
|
|
326
|
-
*
|
|
327
|
-
* @title Get Positions of Graphic
|
|
328
|
-
* @method sprite.getPositionsOfGraphic(align)
|
|
329
|
-
* @param {string} [align] middle
|
|
330
|
-
* @returns { x: number, y: number }
|
|
331
|
-
* @memberof RpgSprite
|
|
332
|
-
*/
|
|
333
|
-
getPositionsOfGraphic(align: string): PositionXY {
|
|
334
|
-
let sprite: RpgSprite | undefined
|
|
335
|
-
// if no component (no graphic for example)
|
|
336
|
-
if (this.components.center?.lines.length !== 0) {
|
|
337
|
-
sprite = this.containersLayout.center.getChildAt(0) as RpgSprite
|
|
338
|
-
}
|
|
339
|
-
const isMiddle = align == 'middle'
|
|
340
|
-
return {
|
|
341
|
-
x: this.x - this.w * (sprite?.anchor.x ?? 1) + (isMiddle ? this.w / 2 : 0),
|
|
342
|
-
y: this.y - this.h * (sprite?.anchor.y ?? 1) + (isMiddle ? this.h / 2 : 0)
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Get the container by position (center, left, right, top, bottom)
|
|
348
|
-
*
|
|
349
|
-
* @param {LayoutPositionEnum} [position=center]
|
|
350
|
-
* @returns {PIXI.Container}
|
|
351
|
-
*
|
|
352
|
-
* */
|
|
353
|
-
getLayoutContainer(position: LayoutPositionEnum = 'center'): Container {
|
|
354
|
-
return this.containersLayout[position]
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Get Current Scene. Scene is a map, battle, menu, etc.
|
|
359
|
-
* @returns {T}
|
|
360
|
-
*/
|
|
361
|
-
getScene<T>(): T {
|
|
362
|
-
return this.scene as any
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Hooks
|
|
366
|
-
onInit() { }
|
|
367
|
-
onUpdate(obj) { }
|
|
368
|
-
onMove() { }
|
|
369
|
-
onChanges(data, old) { }
|
|
370
|
-
|
|
371
|
-
private callMethodInComponents(name: string, params: unknown[]) {
|
|
372
|
-
for (let component of this.getLayoutContainer().children) {
|
|
373
|
-
if (component[name]) component[name](...params)
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
private createGrid(position: LayoutPositionEnum, gridArray: any, options: LayoutOptions, sprite: SpriteInfo): Container {
|
|
378
|
-
const gridContainer = new Sprite();
|
|
379
|
-
const { height, spriteWidth, spriteHeight } = sprite
|
|
380
|
-
const width = options.width ?? spriteWidth ?? sprite.width
|
|
381
|
-
const gridHeight = options.height ?? 20
|
|
382
|
-
const hitBoxWidth = this.logic?.hitbox.w ?? 0
|
|
383
|
-
const middleWidth = hitBoxWidth / 2 - width / 2
|
|
384
|
-
const posX = gridContainer.x + (options.marginLeft ?? 0) - (options.marginRight ?? 0)
|
|
385
|
-
const posY = gridContainer.y + (this.logic?.hitbox.h ?? 0) + (options.marginTop ?? 0) - (options.marginBottom ?? 0)
|
|
386
|
-
|
|
387
|
-
switch (position) {
|
|
388
|
-
case 'top':
|
|
389
|
-
gridContainer.x = posX + middleWidth
|
|
390
|
-
gridContainer.y = posY - spriteHeight
|
|
391
|
-
gridContainer.y -= (gridArray.length * gridHeight)
|
|
392
|
-
break;
|
|
393
|
-
case 'bottom':
|
|
394
|
-
gridContainer.x = posX + middleWidth
|
|
395
|
-
gridContainer.y = posY
|
|
396
|
-
break;
|
|
397
|
-
case 'left':
|
|
398
|
-
gridContainer.x = posX - width - (hitBoxWidth < spriteWidth ? hitBoxWidth / 2 : 0)
|
|
399
|
-
gridContainer.y = posY - spriteHeight
|
|
400
|
-
break;
|
|
401
|
-
case 'right':
|
|
402
|
-
gridContainer.x = posX + width + (hitBoxWidth > spriteWidth ? hitBoxWidth / 2 : 0)
|
|
403
|
-
gridContainer.y = posY - spriteHeight
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
for (let y = 0; y < gridArray.length; y++) {
|
|
407
|
-
const columns = gridArray[y].col.length;
|
|
408
|
-
const cellWidth = (width / columns);
|
|
409
|
-
for (let x = 0; x < columns; x++) {
|
|
410
|
-
const params: ComponentObject<any> = gridArray[y].col[x];
|
|
411
|
-
const component = this.applyComponent(params)
|
|
412
|
-
component.onRender$
|
|
413
|
-
.pipe(
|
|
414
|
-
takeUntil(this.layoutNotifierClear[position]),
|
|
415
|
-
finalize(() => {
|
|
416
|
-
component.onRemove()
|
|
417
|
-
})
|
|
418
|
-
)
|
|
419
|
-
.subscribe(() => {
|
|
420
|
-
component.x = Math.round((x * cellWidth) + (cellWidth / 2) - (component.width / 2))
|
|
421
|
-
component.y = Math.round((y * gridHeight) + (gridHeight / 2) - (component.height / 2))
|
|
422
|
-
})
|
|
423
|
-
component.onInit({
|
|
424
|
-
width: cellWidth,
|
|
425
|
-
height: gridHeight
|
|
426
|
-
})
|
|
427
|
-
gridContainer.addChild(component)
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return gridContainer
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
private applyComponent(component: ComponentObject<any>): AbstractComponent<any, any> {
|
|
435
|
-
const compClass = this.registerComponents.get(component.id)
|
|
436
|
-
if (!compClass) {
|
|
437
|
-
throw log(`Impossible to find ${component.id} component`)
|
|
438
|
-
}
|
|
439
|
-
return new compClass(this, component.value)
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
private createComponentCenter(components: LayoutObject<any>) {
|
|
443
|
-
const lines = components.center?.lines || []
|
|
444
|
-
|
|
445
|
-
this.getLayoutContainer().removeChildren()
|
|
446
|
-
|
|
447
|
-
for (let { col } of lines) {
|
|
448
|
-
for (let component of col) {
|
|
449
|
-
const instance = this.applyComponent(component)
|
|
450
|
-
if (instance.onInit) instance.onInit({
|
|
451
|
-
width: this.logic?.width ?? this.width,
|
|
452
|
-
height: this.logic?.height ?? this.height
|
|
453
|
-
})
|
|
454
|
-
this.getLayoutContainer().addChild(instance)
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
this.components = components
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
private refreshComponents(components: LayoutObject<any>, sprite: SpriteInfo) {
|
|
462
|
-
for (let type of layoutTypes) {
|
|
463
|
-
const layout = components[type]
|
|
464
|
-
if (layout?.lines) {
|
|
465
|
-
const layoutContainer = this.getLayoutContainer(type)
|
|
466
|
-
layoutContainer.removeChildren()
|
|
467
|
-
this.layoutNotifierClear[type].next()
|
|
468
|
-
layoutContainer.addChild(this.createGrid(type, layout.lines, layout, sprite))
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
private updateComponents(components: LayoutObject<any>) {
|
|
474
|
-
const graphicChanged: boolean = !!components.center?.lines
|
|
475
|
-
|
|
476
|
-
if (graphicChanged) {
|
|
477
|
-
this.createComponentCenter(components)
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (this.subscriptionGraphic) this.subscriptionGraphic.unsubscribe()
|
|
481
|
-
|
|
482
|
-
const child = this.getLayoutContainer().children[0]
|
|
483
|
-
|
|
484
|
-
if (child instanceof RpgSprite) {
|
|
485
|
-
this.subscriptionGraphic = (child as RpgSprite).animationSprite()
|
|
486
|
-
.pipe(
|
|
487
|
-
takeUntil(this.game.getDeleteNotifier(this.id)),
|
|
488
|
-
filter((sprite: any) => sprite),
|
|
489
|
-
distinctUntilChanged((p: any, q: any) =>
|
|
490
|
-
p.width === q.width &&
|
|
491
|
-
p.height === q.height &&
|
|
492
|
-
p.anchor.x === q.anchor.x &&
|
|
493
|
-
p.anchor.y === q.anchor.y),
|
|
494
|
-
)
|
|
495
|
-
.subscribe((sprite) => {
|
|
496
|
-
this.refreshComponents(components, sprite)
|
|
497
|
-
})
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
this.refreshComponents(components, {
|
|
501
|
-
width: this.data.width,
|
|
502
|
-
height: this.data.height,
|
|
503
|
-
anchor: {
|
|
504
|
-
x: 0,
|
|
505
|
-
y: 0
|
|
506
|
-
},
|
|
507
|
-
x: 0,
|
|
508
|
-
y: 0,
|
|
509
|
-
spriteHeight: this.data.height,
|
|
510
|
-
spriteWidth: this.data.width
|
|
511
|
-
})
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Utils } from "@rpgjs/common"
|
|
2
|
-
import { AbstractComponent, CellInfo } from "./AbstractComponent"
|
|
3
|
-
import { DebugComponentObject } from "@rpgjs/types"
|
|
4
|
-
import { Graphics } from "pixi.js"
|
|
5
|
-
|
|
6
|
-
export class DebugComponent extends AbstractComponent<DebugComponentObject, Graphics> {
|
|
7
|
-
static readonly id: string = 'debug'
|
|
8
|
-
color: string = '#ff0000'
|
|
9
|
-
cacheParams: string[] = ['map', 'position.x', 'position.y']
|
|
10
|
-
private container: Graphics = new Graphics()
|
|
11
|
-
|
|
12
|
-
onInit(cell: CellInfo) {
|
|
13
|
-
this.addChild(this.container)
|
|
14
|
-
this.updateRender(this.component.logic)
|
|
15
|
-
this.eventMode = 'static'
|
|
16
|
-
this.on('pointerdown', () => {
|
|
17
|
-
console.log(this.component.logic)
|
|
18
|
-
})
|
|
19
|
-
super.onInit(cell)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
updateRender(object: any) {
|
|
23
|
-
const hitbox = object.hitbox
|
|
24
|
-
const { pos, w, h } = hitbox
|
|
25
|
-
this.container.clear()
|
|
26
|
-
const { value: color, alpha } = Utils.hexaToNumber(this.color)
|
|
27
|
-
this.container.beginFill(color, alpha)
|
|
28
|
-
this.container.drawRect(
|
|
29
|
-
0,
|
|
30
|
-
0,
|
|
31
|
-
w,
|
|
32
|
-
h
|
|
33
|
-
);
|
|
34
|
-
this.container.endFill()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Container, Sprite } from "pixi.js"
|
|
2
|
-
import { ImageComponentObject } from "@rpgjs/types"
|
|
3
|
-
import { SceneMap } from "../Scene/Map"
|
|
4
|
-
import { AbstractComponent, CellInfo } from "./AbstractComponent"
|
|
5
|
-
|
|
6
|
-
export class ImageComponent extends AbstractComponent<ImageComponentObject, Container> {
|
|
7
|
-
static readonly id: string = 'image'
|
|
8
|
-
cacheParams: string[] = []
|
|
9
|
-
source: string = ''
|
|
10
|
-
|
|
11
|
-
onInit(cell: CellInfo) {
|
|
12
|
-
super.onInit(cell)
|
|
13
|
-
this.setImage()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private setImage() {
|
|
17
|
-
if (typeof this.value == 'string') {
|
|
18
|
-
this.source = this.value
|
|
19
|
-
} else {
|
|
20
|
-
this.source = this.value.source
|
|
21
|
-
}
|
|
22
|
-
this.updateRender({})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
updateRender(object: any) {
|
|
26
|
-
this.removeChildren()
|
|
27
|
-
const engine = this.component.getScene<SceneMap>().game.clientEngine
|
|
28
|
-
this.addChild(Sprite.from(engine.getResourceUrl(this.source)))
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Utils } from "@rpgjs/common"
|
|
2
|
-
import { AbstractComponent, CellInfo } from "./AbstractComponent"
|
|
3
|
-
import { ShapeComponentObject } from "@rpgjs/types"
|
|
4
|
-
import { Graphics } from "pixi.js"
|
|
5
|
-
|
|
6
|
-
export class ShapeComponent extends AbstractComponent<ShapeComponentObject, Graphics> {
|
|
7
|
-
static readonly id: string = 'shape'
|
|
8
|
-
private type: ShapeComponentObject['value']['type'] = this.value.type
|
|
9
|
-
private container: Graphics = new Graphics()
|
|
10
|
-
cacheParams: string[] = []
|
|
11
|
-
|
|
12
|
-
onInit(cell: CellInfo) {
|
|
13
|
-
this.cell = cell
|
|
14
|
-
this.updateRender(this.component.logic)
|
|
15
|
-
this.addChild(this.container)
|
|
16
|
-
super.onInit(cell)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
updateRender(object: any) {
|
|
20
|
-
const value = this.value as any
|
|
21
|
-
const height = this.getValue(object, value.height) ?? this.cell?.height ?? 0
|
|
22
|
-
const width = this.getValue(object, value.width) ?? this.cell?.width ?? 0
|
|
23
|
-
|
|
24
|
-
this.container.clear()
|
|
25
|
-
const { value: color, alpha } = Utils.hexaToNumber(this.value.fill)
|
|
26
|
-
this.container.beginFill(color, alpha)
|
|
27
|
-
|
|
28
|
-
if (value.line) {
|
|
29
|
-
const { value: color, alpha } = Utils.hexaToNumber(value.line.color ?? this.value.fill)
|
|
30
|
-
this.container.lineStyle(
|
|
31
|
-
this.getValue(object, value.line.width) ?? 1,
|
|
32
|
-
color,
|
|
33
|
-
this.getValue(object, value.line.alpha) ?? alpha
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
switch (this.type) {
|
|
38
|
-
case 'circle':
|
|
39
|
-
this.container.drawCircle(0, 0, this.getValue(object, value.radius))
|
|
40
|
-
break;
|
|
41
|
-
case 'ellipse':
|
|
42
|
-
this.container.drawEllipse(0, 0, width, height)
|
|
43
|
-
break;
|
|
44
|
-
case 'line':
|
|
45
|
-
if (!value.line) {
|
|
46
|
-
this.container.lineStyle(1, color, alpha)
|
|
47
|
-
}
|
|
48
|
-
this.container.moveTo(this.getValue(object, value.x1), this.getValue(object, value.y1))
|
|
49
|
-
this.container.lineTo(this.getValue(object, value.x2), this.getValue(object, value.y2))
|
|
50
|
-
break;
|
|
51
|
-
case 'polygon':
|
|
52
|
-
this.container.drawPolygon(value.points)
|
|
53
|
-
break;
|
|
54
|
-
case 'rounded-rect':
|
|
55
|
-
this.container.drawRoundedRect(0, 0, width, height, value.radius)
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
this.container.drawRect(0, 0, width, height)
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.container.endFill()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TextComponentObject } from "@rpgjs/types"
|
|
2
|
-
import { Graphics, Text } from "pixi.js"
|
|
3
|
-
import { AbstractComponent } from "./AbstractComponent"
|
|
4
|
-
|
|
5
|
-
export class TextComponent extends AbstractComponent<TextComponentObject, Text> {
|
|
6
|
-
static readonly id: string = 'text'
|
|
7
|
-
cacheParams: string[] = []
|
|
8
|
-
private container: Text = new Text('')
|
|
9
|
-
private originValue: string = ''
|
|
10
|
-
|
|
11
|
-
onInit(cell: Graphics) {
|
|
12
|
-
if (typeof this.value == 'string') {
|
|
13
|
-
this.container.text = this.value
|
|
14
|
-
} else if (this.value.style) {
|
|
15
|
-
this.container.style = this.value.style
|
|
16
|
-
this.container.text = this.value.text
|
|
17
|
-
}
|
|
18
|
-
this.container.style = {
|
|
19
|
-
...this.container.style,
|
|
20
|
-
wordWrapWidth: cell.width
|
|
21
|
-
}
|
|
22
|
-
this.parseTextAndCache(this.container.text)
|
|
23
|
-
this.originValue = this.container.text
|
|
24
|
-
// first render for replace variable and remove {}
|
|
25
|
-
this.updateRender(this.component.logic)
|
|
26
|
-
this.addChild(this.container)
|
|
27
|
-
super.onInit(cell)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
updateRender(object: any) {
|
|
31
|
-
this.container.text = this.replaceText(object, this.originValue)
|
|
32
|
-
}
|
|
33
|
-
}
|