@vforsh/phaser-dev-ui 0.1.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/README.md +198 -0
- package/dist/DebugBadge.d.ts +62 -0
- package/dist/DebugBadge.d.ts.map +1 -0
- package/dist/DebugBadge.js +206 -0
- package/dist/DebugBadge.js.map +1 -0
- package/dist/DebugButton.d.ts +94 -0
- package/dist/DebugButton.d.ts.map +1 -0
- package/dist/DebugButton.js +311 -0
- package/dist/DebugButton.js.map +1 -0
- package/dist/DebugColumnContainer.d.ts +38 -0
- package/dist/DebugColumnContainer.d.ts.map +1 -0
- package/dist/DebugColumnContainer.js +69 -0
- package/dist/DebugColumnContainer.js.map +1 -0
- package/dist/DebugGridContainer.d.ts +44 -0
- package/dist/DebugGridContainer.d.ts.map +1 -0
- package/dist/DebugGridContainer.js +64 -0
- package/dist/DebugGridContainer.js.map +1 -0
- package/dist/DebugLabel.d.ts +33 -0
- package/dist/DebugLabel.d.ts.map +1 -0
- package/dist/DebugLabel.js +37 -0
- package/dist/DebugLabel.js.map +1 -0
- package/dist/DebugPanel.d.ts +67 -0
- package/dist/DebugPanel.d.ts.map +1 -0
- package/dist/DebugPanel.js +138 -0
- package/dist/DebugPanel.js.map +1 -0
- package/dist/DebugProgressBar.d.ts +47 -0
- package/dist/DebugProgressBar.d.ts.map +1 -0
- package/dist/DebugProgressBar.js +129 -0
- package/dist/DebugProgressBar.js.map +1 -0
- package/dist/DebugRowContainer.d.ts +40 -0
- package/dist/DebugRowContainer.d.ts.map +1 -0
- package/dist/DebugRowContainer.js +91 -0
- package/dist/DebugRowContainer.js.map +1 -0
- package/dist/DebugScrollContainer.d.ts +138 -0
- package/dist/DebugScrollContainer.d.ts.map +1 -0
- package/dist/DebugScrollContainer.js +413 -0
- package/dist/DebugScrollContainer.js.map +1 -0
- package/dist/DebugSwitchButton.d.ts +111 -0
- package/dist/DebugSwitchButton.d.ts.map +1 -0
- package/dist/DebugSwitchButton.js +317 -0
- package/dist/DebugSwitchButton.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +31 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +62 -0
- package/dist/utils.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { HexColor, Position, Size } from "./types.js";
|
|
2
|
+
export interface CreateDebugPanelOptions {
|
|
3
|
+
/** Panel width (default: 400) */
|
|
4
|
+
width?: number;
|
|
5
|
+
/** Panel height (default: 400) */
|
|
6
|
+
height?: number;
|
|
7
|
+
/** Corner radius (default: 10) */
|
|
8
|
+
cornerRadius?: number;
|
|
9
|
+
/** Background fill color (default: "#000000") */
|
|
10
|
+
fillColor?: HexColor;
|
|
11
|
+
/** Stroke/border color (default: "#a3a3a3") */
|
|
12
|
+
strokeColor?: HexColor;
|
|
13
|
+
/** Stroke thickness (default: 4) */
|
|
14
|
+
strokeThickness?: number;
|
|
15
|
+
/** Shadow color (default: "#00000032") */
|
|
16
|
+
shadowColor?: HexColor;
|
|
17
|
+
/** Shadow Y offset in pixels (default: 4) */
|
|
18
|
+
shadowOffsetY?: number;
|
|
19
|
+
/** Position (optional) */
|
|
20
|
+
position?: Position;
|
|
21
|
+
/** Block pointer events from passing through (default: false) */
|
|
22
|
+
blockInputEvents?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A rectangular debug panel rendered with Phaser Graphics.
|
|
26
|
+
*
|
|
27
|
+
* All rendering is code-only — no sprites or assets required.
|
|
28
|
+
* Supports background fill, stroke border, drop shadow, and rounded corners.
|
|
29
|
+
* Chainable API for styling.
|
|
30
|
+
*/
|
|
31
|
+
export declare class DebugPanel extends Phaser.GameObjects.Container {
|
|
32
|
+
private _bg;
|
|
33
|
+
private _shadow;
|
|
34
|
+
private _width;
|
|
35
|
+
private _height;
|
|
36
|
+
private _cornerRadius;
|
|
37
|
+
private _fillColor;
|
|
38
|
+
private _strokeColor;
|
|
39
|
+
private _strokeThickness;
|
|
40
|
+
private _shadowColor;
|
|
41
|
+
private _shadowOffsetY;
|
|
42
|
+
private _shadowVisible;
|
|
43
|
+
private _hitArea;
|
|
44
|
+
constructor(scene: Phaser.Scene, options?: CreateDebugPanelOptions);
|
|
45
|
+
setBgColor(color: HexColor): this;
|
|
46
|
+
setStrokeColor(color: HexColor): this;
|
|
47
|
+
setStrokeThickness(thickness: number): this;
|
|
48
|
+
setShadowColor(color: HexColor): this;
|
|
49
|
+
setShadowVisible(visible: boolean): this;
|
|
50
|
+
setCornerRadius(radius: number): this;
|
|
51
|
+
setPanelSize(width: number, height: number): this;
|
|
52
|
+
setStyle(options: {
|
|
53
|
+
size?: Size;
|
|
54
|
+
bgColor?: HexColor;
|
|
55
|
+
strokeColor?: HexColor;
|
|
56
|
+
strokeThickness?: number;
|
|
57
|
+
shadowColor?: HexColor;
|
|
58
|
+
shadowVisible?: boolean;
|
|
59
|
+
cornerRadius?: number;
|
|
60
|
+
}): this;
|
|
61
|
+
getPanelWidth(): number;
|
|
62
|
+
getPanelHeight(): number;
|
|
63
|
+
private redraw;
|
|
64
|
+
}
|
|
65
|
+
/** Factory function — mirrors the Cocos `createDebugPanel()` API. */
|
|
66
|
+
export declare function createDebugPanel(scene: Phaser.Scene, options?: CreateDebugPanelOptions): DebugPanel;
|
|
67
|
+
//# sourceMappingURL=DebugPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugPanel.d.ts","sourceRoot":"","sources":["../src/DebugPanel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAG1D,MAAM,WAAW,uBAAuB;IAC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,GAAG,IAAI;IAMrC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMxC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMrC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAWjD,QAAQ,CAAC,OAAO,EAAE;QACjB,IAAI,CAAC,EAAE,IAAI,CAAA;QACX,OAAO,CAAC,EAAE,QAAQ,CAAA;QAClB,WAAW,CAAC,EAAE,QAAQ,CAAA;QACtB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,WAAW,CAAC,EAAE,QAAQ,CAAA;QACtB,aAAa,CAAC,EAAE,OAAO,CAAA;QACvB,YAAY,CAAC,EAAE,MAAM,CAAA;KACrB,GAAG,IAAI;IAYR,aAAa,IAAI,MAAM;IAIvB,cAAc,IAAI,MAAM;IAMxB,OAAO,CAAC,MAAM;CAwBd;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAEvG"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { hexToColorAlpha } from "./utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* A rectangular debug panel rendered with Phaser Graphics.
|
|
4
|
+
*
|
|
5
|
+
* All rendering is code-only — no sprites or assets required.
|
|
6
|
+
* Supports background fill, stroke border, drop shadow, and rounded corners.
|
|
7
|
+
* Chainable API for styling.
|
|
8
|
+
*/
|
|
9
|
+
export class DebugPanel extends Phaser.GameObjects.Container {
|
|
10
|
+
_bg;
|
|
11
|
+
_shadow;
|
|
12
|
+
_width;
|
|
13
|
+
_height;
|
|
14
|
+
_cornerRadius;
|
|
15
|
+
_fillColor;
|
|
16
|
+
_strokeColor;
|
|
17
|
+
_strokeThickness;
|
|
18
|
+
_shadowColor;
|
|
19
|
+
_shadowOffsetY;
|
|
20
|
+
_shadowVisible = true;
|
|
21
|
+
_hitArea = null;
|
|
22
|
+
constructor(scene, options = {}) {
|
|
23
|
+
const { width = 400, height = 400, cornerRadius = 10, fillColor = "#000000", strokeColor = "#a3a3a3", strokeThickness = 4, shadowColor = "#00000032", shadowOffsetY = 4, position, blockInputEvents = false, } = options;
|
|
24
|
+
super(scene, position?.x ?? 0, position?.y ?? 0);
|
|
25
|
+
this._width = width;
|
|
26
|
+
this._height = height;
|
|
27
|
+
this._cornerRadius = cornerRadius;
|
|
28
|
+
this._fillColor = fillColor;
|
|
29
|
+
this._strokeColor = strokeColor;
|
|
30
|
+
this._strokeThickness = strokeThickness;
|
|
31
|
+
this._shadowColor = shadowColor;
|
|
32
|
+
this._shadowOffsetY = shadowOffsetY;
|
|
33
|
+
this.setSize(width, height);
|
|
34
|
+
this._shadow = scene.add.graphics();
|
|
35
|
+
this._bg = scene.add.graphics();
|
|
36
|
+
this.add([this._shadow, this._bg]);
|
|
37
|
+
if (blockInputEvents) {
|
|
38
|
+
this._hitArea = scene.add.rectangle(0, 0, width, height, 0x000000, 0);
|
|
39
|
+
this._hitArea.setInteractive();
|
|
40
|
+
this.add(this._hitArea);
|
|
41
|
+
this.sendToBack(this._hitArea);
|
|
42
|
+
}
|
|
43
|
+
this.redraw();
|
|
44
|
+
scene.add.existing(this);
|
|
45
|
+
}
|
|
46
|
+
// -- Chainable setters --
|
|
47
|
+
setBgColor(color) {
|
|
48
|
+
this._fillColor = color;
|
|
49
|
+
this.redraw();
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
setStrokeColor(color) {
|
|
53
|
+
this._strokeColor = color;
|
|
54
|
+
this.redraw();
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
setStrokeThickness(thickness) {
|
|
58
|
+
this._strokeThickness = thickness;
|
|
59
|
+
this.redraw();
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
setShadowColor(color) {
|
|
63
|
+
this._shadowColor = color;
|
|
64
|
+
this.redraw();
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
setShadowVisible(visible) {
|
|
68
|
+
this._shadowVisible = visible;
|
|
69
|
+
this._shadow.setVisible(visible);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
setCornerRadius(radius) {
|
|
73
|
+
this._cornerRadius = radius;
|
|
74
|
+
this.redraw();
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
setPanelSize(width, height) {
|
|
78
|
+
this._width = width;
|
|
79
|
+
this._height = height;
|
|
80
|
+
this.setSize(width, height);
|
|
81
|
+
if (this._hitArea) {
|
|
82
|
+
this._hitArea.setSize(width, height);
|
|
83
|
+
}
|
|
84
|
+
this.redraw();
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
setStyle(options) {
|
|
88
|
+
if (options.size)
|
|
89
|
+
this.setPanelSize(options.size.width, options.size.height);
|
|
90
|
+
if (options.bgColor)
|
|
91
|
+
this._fillColor = options.bgColor;
|
|
92
|
+
if (options.strokeColor)
|
|
93
|
+
this._strokeColor = options.strokeColor;
|
|
94
|
+
if (options.strokeThickness !== undefined)
|
|
95
|
+
this._strokeThickness = options.strokeThickness;
|
|
96
|
+
if (options.shadowColor)
|
|
97
|
+
this._shadowColor = options.shadowColor;
|
|
98
|
+
if (options.shadowVisible !== undefined)
|
|
99
|
+
this.setShadowVisible(options.shadowVisible);
|
|
100
|
+
if (options.cornerRadius !== undefined)
|
|
101
|
+
this._cornerRadius = options.cornerRadius;
|
|
102
|
+
this.redraw();
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
getPanelWidth() {
|
|
106
|
+
return this._width;
|
|
107
|
+
}
|
|
108
|
+
getPanelHeight() {
|
|
109
|
+
return this._height;
|
|
110
|
+
}
|
|
111
|
+
// -- Internal --
|
|
112
|
+
redraw() {
|
|
113
|
+
const halfW = this._width / 2;
|
|
114
|
+
const halfH = this._height / 2;
|
|
115
|
+
// Shadow
|
|
116
|
+
this._shadow.clear();
|
|
117
|
+
if (this._shadowVisible) {
|
|
118
|
+
const sc = hexToColorAlpha(this._shadowColor);
|
|
119
|
+
this._shadow.fillStyle(sc.color, sc.alpha);
|
|
120
|
+
this._shadow.fillRoundedRect(-halfW, -halfH + this._shadowOffsetY, this._width, this._height, this._cornerRadius);
|
|
121
|
+
}
|
|
122
|
+
// Background
|
|
123
|
+
this._bg.clear();
|
|
124
|
+
const fc = hexToColorAlpha(this._fillColor);
|
|
125
|
+
this._bg.fillStyle(fc.color, fc.alpha);
|
|
126
|
+
this._bg.fillRoundedRect(-halfW, -halfH, this._width, this._height, this._cornerRadius);
|
|
127
|
+
if (this._strokeThickness > 0) {
|
|
128
|
+
const sc = hexToColorAlpha(this._strokeColor);
|
|
129
|
+
this._bg.lineStyle(this._strokeThickness, sc.color, sc.alpha);
|
|
130
|
+
this._bg.strokeRoundedRect(-halfW, -halfH, this._width, this._height, this._cornerRadius);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Factory function — mirrors the Cocos `createDebugPanel()` API. */
|
|
135
|
+
export function createDebugPanel(scene, options = {}) {
|
|
136
|
+
return new DebugPanel(scene, options);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=DebugPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugPanel.js","sourceRoot":"","sources":["../src/DebugPanel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAyB5C;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAC,SAAS;IACnD,GAAG,CAA6B;IAChC,OAAO,CAA6B;IACpC,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,aAAa,CAAQ;IACrB,UAAU,CAAU;IACpB,YAAY,CAAU;IACtB,gBAAgB,CAAQ;IACxB,YAAY,CAAU;IACtB,cAAc,CAAQ;IACtB,cAAc,GAAG,IAAI,CAAA;IACrB,QAA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KAAK,CAAC,CAAA;YAC7D,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;QAC1F,CAAC;IACF,CAAC;CACD;AAED,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,KAAmB,EAAE,UAAmC,EAAE;IAC1F,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { HexColor, Position } from "./types.js";
|
|
2
|
+
export interface DebugProgressBarStyleOptions {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
trackColor?: HexColor;
|
|
6
|
+
fillColor?: HexColor;
|
|
7
|
+
cornerRadius?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateDebugProgressBarOptions extends DebugProgressBarStyleOptions {
|
|
10
|
+
/** Progress value, 0–1 (default: 0). */
|
|
11
|
+
value?: number;
|
|
12
|
+
/** Position (optional). */
|
|
13
|
+
position?: Position;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A horizontal progress bar for debug HUD.
|
|
17
|
+
*
|
|
18
|
+
* Displays a normalized 0–1 value as a filled track.
|
|
19
|
+
* Supports rounded corners and configurable track/fill colors.
|
|
20
|
+
* Chainable API.
|
|
21
|
+
*/
|
|
22
|
+
export declare class DebugProgressBar extends Phaser.GameObjects.Container {
|
|
23
|
+
private _track;
|
|
24
|
+
private _fill;
|
|
25
|
+
private _fillMaskGraphics;
|
|
26
|
+
private _fillMask;
|
|
27
|
+
private _width;
|
|
28
|
+
private _height;
|
|
29
|
+
private _trackColor;
|
|
30
|
+
private _fillColor;
|
|
31
|
+
private _cornerRadius;
|
|
32
|
+
private _value;
|
|
33
|
+
constructor(scene: Phaser.Scene, options?: CreateDebugProgressBarOptions);
|
|
34
|
+
setValue(value: number): this;
|
|
35
|
+
getValue(): number;
|
|
36
|
+
setFillColor(color: HexColor): this;
|
|
37
|
+
setTrackColor(color: HexColor): this;
|
|
38
|
+
setCornerRadius(radius: number): this;
|
|
39
|
+
setBarSize(width: number, height: number): this;
|
|
40
|
+
destroy(fromScene?: boolean): void;
|
|
41
|
+
setStyle(options: DebugProgressBarStyleOptions): this;
|
|
42
|
+
private redraw;
|
|
43
|
+
private redrawTrack;
|
|
44
|
+
private redrawFill;
|
|
45
|
+
}
|
|
46
|
+
export declare function createDebugProgressBar(scene: Phaser.Scene, options?: CreateDebugProgressBarOptions): DebugProgressBar;
|
|
47
|
+
//# sourceMappingURL=DebugProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugProgressBar.d.ts","sourceRoot":"","sources":["../src/DebugProgressBar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGpD,MAAM,WAAW,4BAA4B;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,QAAQ,CAAA;IACrB,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,6BAA8B,SAAQ,4BAA4B;IAClF,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,MAAM,CAAC,WAAW,CAAC,SAAS;IACjE,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,MAAM,CAAQ;gBAEV,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAE,6BAAkC;IAqC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7B,QAAQ,IAAI,MAAM;IAIlB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAMnC,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAMpC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMrC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQtC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI;IAM3C,QAAQ,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI;IAYrD,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,UAAU;CAuBlB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAE,6BAAkC,GAAG,gBAAgB,CAEzH"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { hexToColorAlpha } from "./utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* A horizontal progress bar for debug HUD.
|
|
4
|
+
*
|
|
5
|
+
* Displays a normalized 0–1 value as a filled track.
|
|
6
|
+
* Supports rounded corners and configurable track/fill colors.
|
|
7
|
+
* Chainable API.
|
|
8
|
+
*/
|
|
9
|
+
export class DebugProgressBar extends Phaser.GameObjects.Container {
|
|
10
|
+
_track;
|
|
11
|
+
_fill;
|
|
12
|
+
_fillMaskGraphics;
|
|
13
|
+
_fillMask;
|
|
14
|
+
_width;
|
|
15
|
+
_height;
|
|
16
|
+
_trackColor;
|
|
17
|
+
_fillColor;
|
|
18
|
+
_cornerRadius;
|
|
19
|
+
_value;
|
|
20
|
+
constructor(scene, options = {}) {
|
|
21
|
+
const { width = 200, height = 8, trackColor = "#333333", fillColor = "#4caf50", cornerRadius, value = 0, position, } = options;
|
|
22
|
+
super(scene, position?.x ?? 0, position?.y ?? 0);
|
|
23
|
+
this._width = width;
|
|
24
|
+
this._height = height;
|
|
25
|
+
this._trackColor = trackColor;
|
|
26
|
+
this._fillColor = fillColor;
|
|
27
|
+
this._cornerRadius = cornerRadius ?? height / 2;
|
|
28
|
+
this._value = Math.max(0, Math.min(1, value));
|
|
29
|
+
this.setSize(width, height);
|
|
30
|
+
this._track = scene.add.graphics();
|
|
31
|
+
this._fill = scene.add.graphics();
|
|
32
|
+
// Mask graphics lives outside the container so GeometryMask
|
|
33
|
+
// coordinates match the fill's world position.
|
|
34
|
+
this._fillMaskGraphics = scene.add.graphics();
|
|
35
|
+
this._fillMaskGraphics.setVisible(false);
|
|
36
|
+
this._fillMask = this._fillMaskGraphics.createGeometryMask();
|
|
37
|
+
this._fill.setMask(this._fillMask);
|
|
38
|
+
this.add([this._track, this._fill]);
|
|
39
|
+
this.redraw();
|
|
40
|
+
scene.add.existing(this);
|
|
41
|
+
}
|
|
42
|
+
setValue(value) {
|
|
43
|
+
this._value = Math.max(0, Math.min(1, value));
|
|
44
|
+
this.redrawFill();
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
getValue() {
|
|
48
|
+
return this._value;
|
|
49
|
+
}
|
|
50
|
+
setFillColor(color) {
|
|
51
|
+
this._fillColor = color;
|
|
52
|
+
this.redrawFill();
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
setTrackColor(color) {
|
|
56
|
+
this._trackColor = color;
|
|
57
|
+
this.redrawTrack();
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
setCornerRadius(radius) {
|
|
61
|
+
this._cornerRadius = Math.max(0, radius);
|
|
62
|
+
this.redraw();
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
setBarSize(width, height) {
|
|
66
|
+
this._width = width;
|
|
67
|
+
this._height = height;
|
|
68
|
+
this.setSize(width, height);
|
|
69
|
+
this.redraw();
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
destroy(fromScene) {
|
|
73
|
+
this._fill.clearMask(true);
|
|
74
|
+
this._fillMaskGraphics.destroy();
|
|
75
|
+
super.destroy(fromScene);
|
|
76
|
+
}
|
|
77
|
+
setStyle(options) {
|
|
78
|
+
if (options.trackColor)
|
|
79
|
+
this._trackColor = options.trackColor;
|
|
80
|
+
if (options.fillColor)
|
|
81
|
+
this._fillColor = options.fillColor;
|
|
82
|
+
if (options.cornerRadius !== undefined)
|
|
83
|
+
this._cornerRadius = Math.max(0, options.cornerRadius);
|
|
84
|
+
if (options.width !== undefined || options.height !== undefined) {
|
|
85
|
+
this._width = options.width ?? this._width;
|
|
86
|
+
this._height = options.height ?? this._height;
|
|
87
|
+
}
|
|
88
|
+
this.redraw();
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
redraw() {
|
|
92
|
+
this.setSize(this._width, this._height);
|
|
93
|
+
this.redrawTrack();
|
|
94
|
+
this.redrawFill();
|
|
95
|
+
}
|
|
96
|
+
redrawTrack() {
|
|
97
|
+
const halfW = this._width / 2;
|
|
98
|
+
const halfH = this._height / 2;
|
|
99
|
+
const radius = Math.min(this._cornerRadius, halfH);
|
|
100
|
+
const c = hexToColorAlpha(this._trackColor);
|
|
101
|
+
this._track.clear();
|
|
102
|
+
this._track.fillStyle(c.color, c.alpha);
|
|
103
|
+
this._track.fillRoundedRect(-halfW, -halfH, this._width, this._height, radius);
|
|
104
|
+
}
|
|
105
|
+
redrawFill() {
|
|
106
|
+
const halfW = this._width / 2;
|
|
107
|
+
const halfH = this._height / 2;
|
|
108
|
+
const fillWidth = this._width * this._value;
|
|
109
|
+
const radius = Math.min(this._cornerRadius, halfH);
|
|
110
|
+
const c = hexToColorAlpha(this._fillColor);
|
|
111
|
+
this._fill.clear();
|
|
112
|
+
this._fillMaskGraphics.clear();
|
|
113
|
+
if (fillWidth <= 0)
|
|
114
|
+
return;
|
|
115
|
+
// Draw full-width rounded rect for correct corner shapes
|
|
116
|
+
this._fill.fillStyle(c.color, c.alpha);
|
|
117
|
+
this._fill.fillRoundedRect(-halfW, -halfH, this._width, this._height, radius);
|
|
118
|
+
// Mask lives outside the container — draw in world coordinates
|
|
119
|
+
const wt = this.getWorldTransformMatrix();
|
|
120
|
+
const worldX = wt.tx;
|
|
121
|
+
const worldY = wt.ty;
|
|
122
|
+
this._fillMaskGraphics.fillStyle(0xffffff, 1);
|
|
123
|
+
this._fillMaskGraphics.fillRect(worldX - halfW, worldY - halfH, fillWidth, this._height);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function createDebugProgressBar(scene, options = {}) {
|
|
127
|
+
return new DebugProgressBar(scene, options);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=DebugProgressBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugProgressBar.js","sourceRoot":"","sources":["../src/DebugProgressBar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAiB5C;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,CAAC,SAAS;IACzD,MAAM,CAA6B;IACnC,KAAK,CAA6B;IAClC,iBAAiB,CAA6B;IAC9C,SAAS,CAAmC;IAC5C,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,WAAW,CAAU;IACrB,UAAU,CAAU;IACpB,aAAa,CAAQ;IACrB,MAAM,CAAQ;IAEtB,YAAY,KAAmB,EAAE,UAAyC,EAAE;QAC3E,MAAM,EACL,KAAK,GAAG,GAAG,EACX,MAAM,GAAG,CAAC,EACV,UAAU,GAAG,SAAS,EACtB,SAAS,GAAG,SAAS,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7C,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACzF,CAAC;CACD;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAmB,EAAE,UAAyC,EAAE;IACtG,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Position } from "./types.js";
|
|
2
|
+
export interface CreateRowContainerOptions {
|
|
3
|
+
/** Horizontal spacing between children (default: 0). */
|
|
4
|
+
spacingX?: number;
|
|
5
|
+
/** Padding (default: 0 all sides). */
|
|
6
|
+
paddingLeft?: number;
|
|
7
|
+
paddingRight?: number;
|
|
8
|
+
paddingTop?: number;
|
|
9
|
+
paddingBottom?: number;
|
|
10
|
+
/** Direction (default: "left-to-right"). */
|
|
11
|
+
direction?: "left-to-right" | "right-to-left";
|
|
12
|
+
/** Position (optional). */
|
|
13
|
+
position?: Position;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A horizontal layout container that arranges children in a row.
|
|
17
|
+
*
|
|
18
|
+
* After adding children via `addItem()`, call `layout()` to position them.
|
|
19
|
+
* Items are spaced by `spacingX` with configurable padding.
|
|
20
|
+
* Children must have a measurable width (use `getBounds().width` or `displayWidth`).
|
|
21
|
+
*/
|
|
22
|
+
export declare class DebugRowContainer extends Phaser.GameObjects.Container {
|
|
23
|
+
private _spacingX;
|
|
24
|
+
private _paddingLeft;
|
|
25
|
+
private _paddingRight;
|
|
26
|
+
private _paddingTop;
|
|
27
|
+
private _paddingBottom;
|
|
28
|
+
private _direction;
|
|
29
|
+
constructor(scene: Phaser.Scene, options?: CreateRowContainerOptions);
|
|
30
|
+
addItem(child: Phaser.GameObjects.GameObject): this;
|
|
31
|
+
addItems(children: Phaser.GameObjects.GameObject[]): this;
|
|
32
|
+
setSpacingX(spacing: number): this;
|
|
33
|
+
/** Reposition children according to current spacing/padding. */
|
|
34
|
+
layout(): this;
|
|
35
|
+
/** Total width of laid-out children + padding. */
|
|
36
|
+
getContentWidth(): number;
|
|
37
|
+
private getItemSize;
|
|
38
|
+
}
|
|
39
|
+
export declare function createRowContainer(scene: Phaser.Scene, options?: CreateRowContainerOptions): DebugRowContainer;
|
|
40
|
+
//# sourceMappingURL=DebugRowContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugRowContainer.d.ts","sourceRoot":"","sources":["../src/DebugRowContainer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,WAAW,yBAAyB;IACzC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,eAAe,GAAG,eAAe,CAAA;IAC7C,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,MAAM,CAAC,WAAW,CAAC,SAAS;IAClE,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,UAAU,CAAmC;gBAEzC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAE,yBAA8B;IAuBxE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,GAAG,IAAI;IAKnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAI;IAKzD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKlC,gEAAgE;IAChE,MAAM,IAAI,IAAI;IAkBd,kDAAkD;IAClD,eAAe,IAAI,MAAM;IAYzB,OAAO,CAAC,WAAW;CAsBnB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,GAAE,yBAA8B,GAAG,iBAAiB,CAElH"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A horizontal layout container that arranges children in a row.
|
|
3
|
+
*
|
|
4
|
+
* After adding children via `addItem()`, call `layout()` to position them.
|
|
5
|
+
* Items are spaced by `spacingX` with configurable padding.
|
|
6
|
+
* Children must have a measurable width (use `getBounds().width` or `displayWidth`).
|
|
7
|
+
*/
|
|
8
|
+
export class DebugRowContainer extends Phaser.GameObjects.Container {
|
|
9
|
+
_spacingX;
|
|
10
|
+
_paddingLeft;
|
|
11
|
+
_paddingRight;
|
|
12
|
+
_paddingTop;
|
|
13
|
+
_paddingBottom;
|
|
14
|
+
_direction;
|
|
15
|
+
constructor(scene, options = {}) {
|
|
16
|
+
const { spacingX = 0, paddingLeft = 0, paddingRight = 0, paddingTop = 0, paddingBottom = 0, direction = "left-to-right", position, } = options;
|
|
17
|
+
super(scene, position?.x ?? 0, position?.y ?? 0);
|
|
18
|
+
this._spacingX = spacingX;
|
|
19
|
+
this._paddingLeft = paddingLeft;
|
|
20
|
+
this._paddingRight = paddingRight;
|
|
21
|
+
this._paddingTop = paddingTop;
|
|
22
|
+
this._paddingBottom = paddingBottom;
|
|
23
|
+
this._direction = direction;
|
|
24
|
+
scene.add.existing(this);
|
|
25
|
+
}
|
|
26
|
+
addItem(child) {
|
|
27
|
+
this.add(child);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
addItems(children) {
|
|
31
|
+
for (const child of children)
|
|
32
|
+
this.add(child);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
setSpacingX(spacing) {
|
|
36
|
+
this._spacingX = spacing;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** Reposition children according to current spacing/padding. */
|
|
40
|
+
layout() {
|
|
41
|
+
const items = this.list;
|
|
42
|
+
let cursor = this._paddingLeft;
|
|
43
|
+
const ordered = this._direction === "right-to-left" ? [...items].reverse() : items;
|
|
44
|
+
for (const item of ordered) {
|
|
45
|
+
const go = item;
|
|
46
|
+
if (!go.setPosition)
|
|
47
|
+
continue;
|
|
48
|
+
const size = this.getItemSize(item);
|
|
49
|
+
go.setPosition(cursor + size.width / 2, this._paddingTop + size.height / 2);
|
|
50
|
+
cursor += size.width + this._spacingX;
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
/** Total width of laid-out children + padding. */
|
|
55
|
+
getContentWidth() {
|
|
56
|
+
const items = this.list;
|
|
57
|
+
let total = this._paddingLeft + this._paddingRight;
|
|
58
|
+
for (let i = 0; i < items.length; i++) {
|
|
59
|
+
const item = items[i];
|
|
60
|
+
if (!item)
|
|
61
|
+
continue;
|
|
62
|
+
total += this.getItemSize(item).width;
|
|
63
|
+
if (i < items.length - 1)
|
|
64
|
+
total += this._spacingX;
|
|
65
|
+
}
|
|
66
|
+
return total;
|
|
67
|
+
}
|
|
68
|
+
getItemSize(item) {
|
|
69
|
+
const withDisplay = item;
|
|
70
|
+
const widthFromDisplay = typeof withDisplay.displayWidth === "number" ? withDisplay.displayWidth : 0;
|
|
71
|
+
const heightFromDisplay = typeof withDisplay.displayHeight === "number" ? withDisplay.displayHeight : 0;
|
|
72
|
+
if (widthFromDisplay > 0 || heightFromDisplay > 0) {
|
|
73
|
+
return { width: Math.max(0, widthFromDisplay), height: Math.max(0, heightFromDisplay) };
|
|
74
|
+
}
|
|
75
|
+
const withSize = item;
|
|
76
|
+
const widthFromSize = typeof withSize.width === "number" ? withSize.width : 0;
|
|
77
|
+
const heightFromSize = typeof withSize.height === "number" ? withSize.height : 0;
|
|
78
|
+
if (widthFromSize > 0 || heightFromSize > 0) {
|
|
79
|
+
return { width: Math.max(0, widthFromSize), height: Math.max(0, heightFromSize) };
|
|
80
|
+
}
|
|
81
|
+
if ("getBounds" in item && typeof item.getBounds === "function") {
|
|
82
|
+
const bounds = item.getBounds();
|
|
83
|
+
return { width: Math.max(0, bounds.width), height: Math.max(0, bounds.height) };
|
|
84
|
+
}
|
|
85
|
+
return { width: 0, height: 0 };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function createRowContainer(scene, options = {}) {
|
|
89
|
+
return new DebugRowContainer(scene, options);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=DebugRowContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugRowContainer.js","sourceRoot":"","sources":["../src/DebugRowContainer.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,CAAC,SAAS;IAC1D,SAAS,CAAQ;IACjB,YAAY,CAAQ;IACpB,aAAa,CAAQ;IACrB,WAAW,CAAQ;IACnB,cAAc,CAAQ;IACtB,UAAU,CAAmC;IAErD,YAAY,KAAmB,EAAE,UAAqC,EAAE;QACvE,MAAM,EACL,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,CAAC,EAChB,UAAU,GAAG,CAAC,EACd,aAAa,GAAG,CAAC,EACjB,SAAS,GAAG,eAAe,EAC3B,QAAQ,GACR,GAAG,OAAO,CAAA;QAEX,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,WAAW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