@safe-engine/pixi 1.0.2 → 7.0.2
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/.github/workflows/npm-publish.yml +35 -0
- package/README.md +4 -4
- package/dist/app.d.ts +3 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +41 -81
- package/dist/components/GUIComponent.d.ts +15 -14
- package/dist/components/GUIComponent.d.ts.map +1 -1
- package/dist/components/GUIComponent.js +68 -138
- package/dist/components/NodeComp.d.ts +6 -5
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +223 -305
- package/dist/components/RenderComponent.d.ts +8 -7
- package/dist/components/RenderComponent.d.ts.map +1 -1
- package/dist/components/RenderComponent.js +25 -56
- package/dist/core/Color.js +1 -1
- package/dist/core/LoadingBar.d.ts +9 -1
- package/dist/core/LoadingBar.d.ts.map +1 -1
- package/dist/core/LoadingBar.js +50 -46
- package/dist/core/Size.js +3 -6
- package/dist/core/Vec2.d.ts +20 -0
- package/dist/core/Vec2.d.ts.map +1 -0
- package/dist/core/Vec2.js +70 -0
- package/dist/helper/html-text-parser.js +34 -34
- package/dist/helper/utils.d.ts +1 -1
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +20 -24
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -18
- package/dist/systems/GUISystem.d.ts +2 -2
- package/dist/systems/GUISystem.d.ts.map +1 -1
- package/dist/systems/GUISystem.js +39 -40
- package/dist/systems/RenderSystem.d.ts +0 -1
- package/dist/systems/RenderSystem.d.ts.map +1 -1
- package/dist/systems/RenderSystem.js +24 -35
- package/package.json +5 -4
- package/src/app.ts +53 -0
- package/src/components/GUIComponent.ts +141 -0
- package/src/components/NodeComp.ts +416 -0
- package/src/components/RenderComponent.ts +66 -0
- package/src/core/Color.ts +3 -0
- package/src/core/LoadingBar.ts +63 -0
- package/src/core/Size.ts +21 -0
- package/src/helper/html-text-parser.ts +364 -0
- package/src/index.ts +7 -0
- package/src/systems/GUISystem.ts +80 -0
- package/src/systems/RenderSystem.ts +70 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Publish NPM Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
workflow_dispatch: # Allows you to run this workflow manually
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm run build
|
|
21
|
+
|
|
22
|
+
publish-npm:
|
|
23
|
+
needs: build
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-node@v3
|
|
28
|
+
with:
|
|
29
|
+
node-version: 20
|
|
30
|
+
registry-url: https://registry.npmjs.org/
|
|
31
|
+
- run: npm ci
|
|
32
|
+
- run: npm run build
|
|
33
|
+
- run: npm publish
|
|
34
|
+
env:
|
|
35
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Guide
|
|
2
|
-
- components must be in `tsx` extension
|
|
3
|
-
- `$ref` bind with current class property as string
|
|
4
|
-
- every property start with `$` will reference to current class property as string
|
|
1
|
+
# Guide
|
|
2
|
+
- components must be in `tsx` extension
|
|
3
|
+
- `$ref` bind with current class property as string
|
|
4
|
+
- every property start with `$` will reference to current class property as string
|
package/dist/app.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Constructor, System } from 'entityx-ts';
|
|
1
2
|
import { Application } from 'pixi.js';
|
|
2
|
-
export declare const app: Application<import("pixi.js").
|
|
3
|
+
export declare const app: Application<import("pixi.js").ICanvas>;
|
|
3
4
|
export declare function setupResolution(designedResolution?: {
|
|
4
5
|
width: number;
|
|
5
6
|
height: number;
|
|
6
7
|
}): void;
|
|
7
8
|
export declare function addGameCanvasTo(id?: string): Promise<void>;
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function startGameWithSystems(systemsList: Constructor<System>[]): void;
|
|
9
10
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAKrC,eAAO,MAAM,GAAG,wCAKd,CAAA;AAEF,wBAAgB,eAAe,CAAC,kBAAkB;;;CAA+B,QAGhF;AAED,wBAAsB,eAAe,CAAC,EAAE,SAAS,iBAUhD;AAYD,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,QAWtE"}
|
package/dist/app.js
CHANGED
|
@@ -8,95 +8,55 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.app = void 0;
|
|
40
13
|
exports.setupResolution = setupResolution;
|
|
41
14
|
exports.addGameCanvasTo = addGameCanvasTo;
|
|
42
|
-
exports.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
exports.startGameWithSystems = startGameWithSystems;
|
|
16
|
+
const core_1 = require("@safe-engine/core");
|
|
17
|
+
const pixi_js_1 = require("pixi.js");
|
|
18
|
+
const pixi_action_ease_1 = require("pixi-action-ease");
|
|
19
|
+
const NodeComp_1 = require("./components/NodeComp");
|
|
20
|
+
exports.app = new pixi_js_1.Application({
|
|
21
|
+
width: 1080,
|
|
22
|
+
height: 1920,
|
|
23
|
+
antialias: true,
|
|
24
|
+
resolution: window.devicePixelRatio,
|
|
25
|
+
});
|
|
26
|
+
function setupResolution(designedResolution = { width: 720, height: 1280 }) {
|
|
27
|
+
const { width, height } = designedResolution;
|
|
52
28
|
exports.app.renderer.resize(width, height);
|
|
53
|
-
// app.stage.position.y = app.renderer.height / app.renderer.resolution
|
|
54
|
-
// app.stage.scale.y = -1
|
|
55
29
|
}
|
|
56
30
|
function addGameCanvasTo() {
|
|
57
|
-
return __awaiter(this, arguments, void 0, function (id) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
case 0: return [4 /*yield*/, exports.app.init({
|
|
63
|
-
antialias: true,
|
|
64
|
-
resolution: window.devicePixelRatio,
|
|
65
|
-
eventFeatures: {
|
|
66
|
-
move: true,
|
|
67
|
-
/** disables the global move events which can be very expensive in large scenes */
|
|
68
|
-
globalMove: false,
|
|
69
|
-
click: true,
|
|
70
|
-
wheel: false,
|
|
71
|
-
},
|
|
72
|
-
})
|
|
73
|
-
// app.ticker.speed = 0.5
|
|
74
|
-
// Listen for frame updates
|
|
75
|
-
];
|
|
76
|
-
case 1:
|
|
77
|
-
_a.sent();
|
|
78
|
-
// app.ticker.speed = 0.5
|
|
79
|
-
// Listen for frame updates
|
|
80
|
-
exports.app.ticker.add(function () {
|
|
81
|
-
var dt = exports.app.ticker.deltaMS * 0.001;
|
|
82
|
-
pixi_action_ease_1.actionManager.update(dt);
|
|
83
|
-
gworld_1.GameWorld.Instance.update(dt);
|
|
84
|
-
});
|
|
85
|
-
Object.assign(exports.app.canvas.style, {
|
|
86
|
-
width: "".concat(window.innerWidth, "px"),
|
|
87
|
-
// height: `${window.innerHeight}px`,
|
|
88
|
-
overflow: 'hidden',
|
|
89
|
-
});
|
|
90
|
-
gameDiv = document.getElementById(id);
|
|
91
|
-
gameDiv.appendChild(exports.app.canvas);
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
}
|
|
31
|
+
return __awaiter(this, arguments, void 0, function* (id = 'game') {
|
|
32
|
+
Object.assign(exports.app.view.style, {
|
|
33
|
+
width: `${window.innerWidth}px`,
|
|
34
|
+
// height: `${window.innerHeight}px`,
|
|
35
|
+
overflow: 'hidden',
|
|
94
36
|
});
|
|
37
|
+
const gameDiv = document.getElementById(id);
|
|
38
|
+
gameDiv.appendChild(exports.app.view);
|
|
39
|
+
core_1.GameWorld.Instance.setup(NodeComp_1.NodeComp, exports.app.stage);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function startGameLoop(world) {
|
|
43
|
+
// Listen for frame updates
|
|
44
|
+
exports.app.ticker.add(() => {
|
|
45
|
+
const dt = exports.app.ticker.deltaMS * 0.001;
|
|
46
|
+
pixi_action_ease_1.actionManager.update(dt);
|
|
47
|
+
world.update(dt);
|
|
95
48
|
});
|
|
49
|
+
// app.ticker.speed = 0.5
|
|
96
50
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
51
|
+
function startGameWithSystems(systemsList) {
|
|
52
|
+
const world = core_1.GameWorld.Instance;
|
|
53
|
+
systemsList.forEach(system => {
|
|
54
|
+
world.systems.add(system);
|
|
55
|
+
const sys = world.systemsMap[system.name];
|
|
56
|
+
if (sys.update) {
|
|
57
|
+
world.listUpdate.push(system);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
world.systems.configure();
|
|
61
|
+
startGameLoop(world);
|
|
102
62
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentX, NoRenderComponentX } from '@safe-engine/core';
|
|
2
|
+
import { Container, Point, Text } from 'pixi.js';
|
|
2
3
|
import { Color4B } from '../core/Color';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { LoadingBar, LoadingBarMode, ProgressTimer } from '../core/LoadingBar';
|
|
5
|
+
import { NodeComp } from './NodeComp';
|
|
5
6
|
export declare const FillType: {
|
|
6
7
|
HORIZONTAL: number;
|
|
7
8
|
VERTICAL: number;
|
|
@@ -9,7 +10,7 @@ export declare const FillType: {
|
|
|
9
10
|
};
|
|
10
11
|
type Keys = keyof typeof FillType;
|
|
11
12
|
type Values = (typeof FillType)[Keys];
|
|
12
|
-
export declare class ButtonComp extends NoRenderComponentX {
|
|
13
|
+
export declare class ButtonComp extends NoRenderComponentX<NodeComp> {
|
|
13
14
|
normalImage: string;
|
|
14
15
|
selectedImage: string;
|
|
15
16
|
disableImage: string;
|
|
@@ -18,52 +19,52 @@ export declare class ButtonComp extends NoRenderComponentX {
|
|
|
18
19
|
setOnPress(cb: (target: ButtonComp) => void): void;
|
|
19
20
|
set enabled(val: any);
|
|
20
21
|
}
|
|
21
|
-
export declare class ProgressBarComp extends NoRenderComponentX {
|
|
22
|
+
export declare class ProgressBarComp extends NoRenderComponentX<NodeComp<LoadingBar>> {
|
|
22
23
|
mode: LoadingBarMode;
|
|
23
24
|
private _progress;
|
|
24
25
|
isReverse: boolean;
|
|
25
26
|
get progress(): number;
|
|
26
27
|
set progress(val: number);
|
|
27
28
|
}
|
|
28
|
-
export declare class LabelComp extends ComponentX {
|
|
29
|
+
export declare class LabelComp extends ComponentX<NodeComp<Text>> {
|
|
29
30
|
font: string;
|
|
30
31
|
string: string;
|
|
31
32
|
size: number;
|
|
32
33
|
getString(): string;
|
|
33
34
|
setString(val: string): void;
|
|
34
|
-
getSize(): number;
|
|
35
|
+
getSize(): string | number;
|
|
35
36
|
setSize(val: any): void;
|
|
36
37
|
getFont(): string;
|
|
37
38
|
setFont(val: string): void;
|
|
38
39
|
}
|
|
39
|
-
export declare class ScrollView extends ComponentX {
|
|
40
|
+
export declare class ScrollView extends ComponentX<NodeComp<Container>> {
|
|
40
41
|
width: number;
|
|
41
42
|
height: number;
|
|
42
43
|
}
|
|
43
|
-
export declare class BlockInputEventsComp extends NoRenderComponentX {
|
|
44
|
+
export declare class BlockInputEventsComp extends NoRenderComponentX<NodeComp<Container>> {
|
|
44
45
|
}
|
|
45
|
-
export declare class ProgressTimerComp extends ComponentX {
|
|
46
|
+
export declare class ProgressTimerComp extends ComponentX<NodeComp<ProgressTimer>> {
|
|
46
47
|
spriteFrame: string;
|
|
47
48
|
fillType: Values;
|
|
48
49
|
fillRange: number;
|
|
49
50
|
fillCenter: Point;
|
|
50
51
|
isReverse: boolean;
|
|
51
|
-
getFillRange():
|
|
52
|
+
getFillRange(): number;
|
|
52
53
|
setFillStart(val: number): void;
|
|
53
54
|
setFillRange(val: number): void;
|
|
54
55
|
}
|
|
55
|
-
export declare class RichTextComp extends ComponentX {
|
|
56
|
+
export declare class RichTextComp extends ComponentX<NodeComp<Text>> {
|
|
56
57
|
protected font: string;
|
|
57
58
|
protected string: string;
|
|
58
59
|
protected size: number;
|
|
59
60
|
getString(): string;
|
|
60
61
|
setString(val: string): void;
|
|
61
62
|
}
|
|
62
|
-
export declare class LabelOutlineComp extends NoRenderComponentX {
|
|
63
|
+
export declare class LabelOutlineComp extends NoRenderComponentX<NodeComp> {
|
|
63
64
|
color: typeof Color4B;
|
|
64
65
|
width: number;
|
|
65
66
|
}
|
|
66
|
-
export declare class LabelShadowComp extends NoRenderComponentX {
|
|
67
|
+
export declare class LabelShadowComp extends NoRenderComponentX<NodeComp> {
|
|
67
68
|
color: typeof Color4B;
|
|
68
69
|
blur: number;
|
|
69
70
|
offset: Point;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GUIComponent.d.ts","sourceRoot":"","sources":["../../src/components/GUIComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,
|
|
1
|
+
{"version":3,"file":"GUIComponent.d.ts","sourceRoot":"","sources":["../../src/components/GUIComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAU,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,eAAO,MAAM,QAAQ;;;;CAIpB,CAAA;AACD,KAAK,IAAI,GAAG,MAAM,OAAO,QAAQ,CAAA;AACjC,KAAK,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;AAErC,qBAAa,UAAW,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAC1D,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;IAErC,UAAU,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;IAI3C,IAAI,OAAO,CAAC,GAAG,KAAA,EAEd;CACF;AAED,qBAAa,eAAgB,SAAQ,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC3E,IAAI,iBAAqB;IACzB,OAAO,CAAC,SAAS,CAAQ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B,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAChE,KAAK,EAAE,OAAO,OAAO,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,eAAgB,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAC/D,KAAK,EAAE,OAAO,OAAO,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,KAAK,CAAA;CACd"}
|
|
@@ -1,178 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.LabelShadowComp = exports.LabelOutlineComp = exports.RichTextComp = exports.ProgressTimerComp = exports.BlockInputEventsComp = exports.ScrollView = exports.LabelComp = exports.ProgressBarComp = exports.ButtonComp = exports.FillType = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var _htmlTextParser = new html_text_parser_1.HtmlTextParser();
|
|
4
|
+
const core_1 = require("@safe-engine/core");
|
|
5
|
+
const pixi_js_1 = require("pixi.js");
|
|
6
|
+
const LoadingBar_1 = require("../core/LoadingBar");
|
|
7
|
+
// const _htmlTextParser = new HtmlTextParser()
|
|
24
8
|
exports.FillType = {
|
|
25
9
|
HORIZONTAL: 0,
|
|
26
10
|
VERTICAL: 1,
|
|
27
11
|
RADIAL: 2,
|
|
28
12
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function ButtonComp() {
|
|
32
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
33
|
-
}
|
|
34
|
-
ButtonComp.prototype.setOnPress = function (cb) {
|
|
13
|
+
class ButtonComp extends core_1.NoRenderComponentX {
|
|
14
|
+
setOnPress(cb) {
|
|
35
15
|
this.onPress = cb;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
enumerable: false,
|
|
42
|
-
configurable: true
|
|
43
|
-
});
|
|
44
|
-
return ButtonComp;
|
|
45
|
-
}(decorator_1.NoRenderComponentX));
|
|
16
|
+
}
|
|
17
|
+
set enabled(val) {
|
|
18
|
+
this.node.instance.interactive = val;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
46
21
|
exports.ButtonComp = ButtonComp;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.node.instance.progress = val;
|
|
61
|
-
},
|
|
62
|
-
enumerable: false,
|
|
63
|
-
configurable: true
|
|
64
|
-
});
|
|
65
|
-
return ProgressBarComp;
|
|
66
|
-
}(decorator_1.NoRenderComponentX));
|
|
22
|
+
class ProgressBarComp extends core_1.NoRenderComponentX {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.mode = LoadingBar_1.LoadingBarMode.BAR;
|
|
26
|
+
}
|
|
27
|
+
get progress() {
|
|
28
|
+
return this._progress;
|
|
29
|
+
}
|
|
30
|
+
set progress(val) {
|
|
31
|
+
this._progress = val;
|
|
32
|
+
this.node.instance.progress = val;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
67
35
|
exports.ProgressBarComp = ProgressBarComp;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
LabelComp.prototype.getString = function () {
|
|
36
|
+
class LabelComp extends core_1.ComponentX {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.size = 64;
|
|
40
|
+
}
|
|
41
|
+
getString() {
|
|
76
42
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
77
43
|
return this.node.instance.text;
|
|
78
44
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
45
|
+
}
|
|
46
|
+
setString(val) {
|
|
81
47
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
82
48
|
this.node.instance.text = val;
|
|
83
49
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
50
|
+
}
|
|
51
|
+
getSize() {
|
|
86
52
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
87
53
|
return this.node.instance.style.fontSize;
|
|
88
54
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
55
|
+
}
|
|
56
|
+
setSize(val) {
|
|
91
57
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
92
58
|
this.node.instance.style.fontSize = val;
|
|
93
59
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
60
|
+
}
|
|
61
|
+
getFont() {
|
|
96
62
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
97
63
|
return this.node.instance.style.fontFamily;
|
|
98
64
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
65
|
+
}
|
|
66
|
+
setFont(val) {
|
|
101
67
|
// console.log('set font', val, Assets.get(val))
|
|
102
68
|
if (this.node.instance instanceof pixi_js_1.Text) {
|
|
103
69
|
if (pixi_js_1.Assets.get(val))
|
|
104
70
|
this.node.instance.style.fontFamily = pixi_js_1.Assets.get(val).family;
|
|
105
71
|
}
|
|
106
|
-
};
|
|
107
|
-
return LabelComp;
|
|
108
|
-
}(decorator_1.ComponentX));
|
|
109
|
-
exports.LabelComp = LabelComp;
|
|
110
|
-
var ScrollView = /** @class */ (function (_super) {
|
|
111
|
-
__extends(ScrollView, _super);
|
|
112
|
-
function ScrollView() {
|
|
113
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
114
72
|
}
|
|
115
|
-
|
|
116
|
-
|
|
73
|
+
}
|
|
74
|
+
exports.LabelComp = LabelComp;
|
|
75
|
+
class ScrollView extends core_1.ComponentX {
|
|
76
|
+
}
|
|
117
77
|
exports.ScrollView = ScrollView;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
function BlockInputEventsComp() {
|
|
121
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
122
|
-
}
|
|
123
|
-
return BlockInputEventsComp;
|
|
124
|
-
}(decorator_1.NoRenderComponentX));
|
|
78
|
+
class BlockInputEventsComp extends core_1.NoRenderComponentX {
|
|
79
|
+
}
|
|
125
80
|
exports.BlockInputEventsComp = BlockInputEventsComp;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
ProgressTimerComp.prototype.setFillStart = function (val) {
|
|
137
|
-
// if (this.node.instance instanceof cc.ProgressTimer) {
|
|
138
|
-
// this.node.instance.setMidpoint(Vec2(val, val))
|
|
139
|
-
// }
|
|
140
|
-
};
|
|
141
|
-
ProgressTimerComp.prototype.setFillRange = function (val) {
|
|
142
|
-
// if (this.node.instance instanceof cc.ProgressTimer) {
|
|
143
|
-
// this.node.instance.setPercentage(val * 100)
|
|
144
|
-
// }
|
|
145
|
-
};
|
|
146
|
-
return ProgressTimerComp;
|
|
147
|
-
}(decorator_1.ComponentX));
|
|
148
|
-
exports.ProgressTimerComp = ProgressTimerComp;
|
|
149
|
-
var RichTextComp = /** @class */ (function (_super) {
|
|
150
|
-
__extends(RichTextComp, _super);
|
|
151
|
-
function RichTextComp() {
|
|
152
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
81
|
+
class ProgressTimerComp extends core_1.ComponentX {
|
|
82
|
+
getFillRange() {
|
|
83
|
+
return this.node.instance.progress;
|
|
84
|
+
}
|
|
85
|
+
setFillStart(val) {
|
|
86
|
+
this.node.instance.fillCenter.x = val;
|
|
87
|
+
}
|
|
88
|
+
setFillRange(val) {
|
|
89
|
+
// console.log('setFillRange', this.node.instance);
|
|
90
|
+
this.node.instance.progress = val;
|
|
153
91
|
}
|
|
154
|
-
|
|
92
|
+
}
|
|
93
|
+
exports.ProgressTimerComp = ProgressTimerComp;
|
|
94
|
+
class RichTextComp extends core_1.ComponentX {
|
|
95
|
+
getString() {
|
|
155
96
|
return this.string;
|
|
156
|
-
}
|
|
157
|
-
|
|
97
|
+
}
|
|
98
|
+
setString(val) {
|
|
158
99
|
this.string = val;
|
|
159
|
-
};
|
|
160
|
-
return RichTextComp;
|
|
161
|
-
}(decorator_1.ComponentX));
|
|
162
|
-
exports.RichTextComp = RichTextComp;
|
|
163
|
-
var LabelOutlineComp = /** @class */ (function (_super) {
|
|
164
|
-
__extends(LabelOutlineComp, _super);
|
|
165
|
-
function LabelOutlineComp() {
|
|
166
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
167
100
|
}
|
|
168
|
-
|
|
169
|
-
|
|
101
|
+
}
|
|
102
|
+
exports.RichTextComp = RichTextComp;
|
|
103
|
+
class LabelOutlineComp extends core_1.NoRenderComponentX {
|
|
104
|
+
}
|
|
170
105
|
exports.LabelOutlineComp = LabelOutlineComp;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
function LabelShadowComp() {
|
|
174
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
175
|
-
}
|
|
176
|
-
return LabelShadowComp;
|
|
177
|
-
}(decorator_1.NoRenderComponentX));
|
|
106
|
+
class LabelShadowComp extends core_1.NoRenderComponentX {
|
|
107
|
+
}
|
|
178
108
|
exports.LabelShadowComp = LabelShadowComp;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseNode, ComponentType, EnhancedComponent } from '@safe-engine/core';
|
|
1
2
|
import { Constructor, Entity } from 'entityx-ts';
|
|
2
3
|
import { Color, ColorSource, Container, Point } from 'pixi.js';
|
|
3
4
|
import { Action, Animation } from 'pixi-action-ease';
|
|
4
|
-
import { ComponentType, EnhancedComponent } from './EnhancedComponent';
|
|
5
5
|
import { Size } from '../core/Size';
|
|
6
6
|
export type EventCallbackType = (...args: any[]) => void;
|
|
7
7
|
export interface EventMap {
|
|
@@ -10,9 +10,9 @@ export interface EventMap {
|
|
|
10
10
|
type TouchEVentCallback = (target: {
|
|
11
11
|
location: Point;
|
|
12
12
|
}) => void;
|
|
13
|
-
export declare class NodeComp {
|
|
13
|
+
export declare class NodeComp<C extends Container = Container> implements BaseNode<C> {
|
|
14
14
|
entity: Entity;
|
|
15
|
-
instance:
|
|
15
|
+
instance: C;
|
|
16
16
|
events: EventMap;
|
|
17
17
|
data: {
|
|
18
18
|
[key: string]: any;
|
|
@@ -31,7 +31,7 @@ export declare class NodeComp {
|
|
|
31
31
|
setOnTouchMove(cb: TouchEVentCallback): void;
|
|
32
32
|
setOnTouchEnd(cb: TouchEVentCallback): void;
|
|
33
33
|
setOnTouchCancel(cb: TouchEVentCallback): void;
|
|
34
|
-
constructor(instance:
|
|
34
|
+
constructor(instance: C, entity: Entity);
|
|
35
35
|
get uuid(): number;
|
|
36
36
|
get position(): Point;
|
|
37
37
|
set position(val: Point);
|
|
@@ -47,6 +47,7 @@ export declare class NodeComp {
|
|
|
47
47
|
get anchorX(): number;
|
|
48
48
|
set anchorX(val: number);
|
|
49
49
|
get anchorY(): number;
|
|
50
|
+
ß: any;
|
|
50
51
|
set anchorY(val: number);
|
|
51
52
|
/** rotation is in radians */
|
|
52
53
|
get rotation(): number;
|
|
@@ -96,7 +97,7 @@ export declare class NodeComp {
|
|
|
96
97
|
on(name: string, callback: EventCallbackType, target?: any): void;
|
|
97
98
|
off(name: string): void;
|
|
98
99
|
emit(name: string, ...params: any): void;
|
|
99
|
-
resolveComponent(component: EnhancedComponent): void;
|
|
100
|
+
resolveComponent(component: EnhancedComponent<NodeComp>): void;
|
|
100
101
|
getData<T>(key: string): T;
|
|
101
102
|
setData<T>(key: string, val: T): void;
|
|
102
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/components/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAU,MAAM,SAAS,CAAA;AACtE,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,OAAA,KAAK,IAAI,CAAA;AACjD,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAA;CACnC;AAED,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,KAAK,IAAI,CAAA;AAE/D,qBAAa,QAAQ,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAC3E,MAAM,EAAE,M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