@kurot/cli 1.1.0 → 1.1.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/CHANGELOG.md +34 -0
- package/LICENSE +21 -0
- package/README.md +40 -9
- package/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +3 -0
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/clean.d.ts +3 -0
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +3 -0
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +3 -0
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +5 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/core/components/discover-components.d.ts +16 -0
- package/dist/core/components/discover-components.d.ts.map +1 -0
- package/dist/core/components/discover-components.js +191 -0
- package/dist/core/components/discover-components.js.map +1 -0
- package/dist/core/config.d.ts +45 -17
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +16 -6
- package/dist/core/config.js.map +1 -1
- package/dist/core/dev-server.d.ts +5 -5
- package/dist/core/dev-server.d.ts.map +1 -1
- package/dist/core/dev-server.js +97 -25
- package/dist/core/dev-server.js.map +1 -1
- package/dist/core/diagnostics/output.d.ts +31 -0
- package/dist/core/diagnostics/output.d.ts.map +1 -1
- package/dist/core/diagnostics/output.js +13 -0
- package/dist/core/diagnostics/output.js.map +1 -1
- package/dist/core/diagnostics/types.d.ts +15 -0
- package/dist/core/diagnostics/types.d.ts.map +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/exml/ast.d.ts +27 -0
- package/dist/core/exml/ast.d.ts.map +1 -1
- package/dist/core/exml/codegen.d.ts +6 -7
- package/dist/core/exml/codegen.d.ts.map +1 -1
- package/dist/core/exml/codegen.js +57 -87
- package/dist/core/exml/codegen.js.map +1 -1
- package/dist/core/exml/exml-diagnostics.d.ts +2 -1
- package/dist/core/exml/exml-diagnostics.d.ts.map +1 -1
- package/dist/core/exml/exml-diagnostics.js +2 -2
- package/dist/core/exml/exml-diagnostics.js.map +1 -1
- package/dist/core/exml/exml-parser.d.ts +11 -11
- package/dist/core/exml/exml-parser.d.ts.map +1 -1
- package/dist/core/exml/exml-parser.js +90 -178
- package/dist/core/exml/exml-parser.js.map +1 -1
- package/dist/core/exml/index.d.ts +13 -13
- package/dist/core/exml/index.d.ts.map +1 -1
- package/dist/core/exml/index.js +12 -13
- package/dist/core/exml/index.js.map +1 -1
- package/dist/core/exml/registry.d.ts +39 -33
- package/dist/core/exml/registry.d.ts.map +1 -1
- package/dist/core/exml/registry.js +56 -43
- package/dist/core/exml/registry.js.map +1 -1
- package/dist/core/exml/skin-module-builder.d.ts +14 -0
- package/dist/core/exml/skin-module-builder.d.ts.map +1 -1
- package/dist/core/exml/skin-module-builder.js +8 -2
- package/dist/core/exml/skin-module-builder.js.map +1 -1
- package/dist/core/exml/xml-parser.d.ts +36 -26
- package/dist/core/exml/xml-parser.d.ts.map +1 -1
- package/dist/core/exml/xml-parser.js +133 -144
- package/dist/core/exml/xml-parser.js.map +1 -1
- package/dist/core/namespace-external-plugin.d.ts +5 -5
- package/dist/core/namespace-external-plugin.js +5 -5
- package/dist/core/pipeline.d.ts +59 -39
- package/dist/core/pipeline.d.ts.map +1 -1
- package/dist/core/pipeline.js +6 -1
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/plugins/clean-output.d.ts +3 -0
- package/dist/core/plugins/clean-output.d.ts.map +1 -1
- package/dist/core/plugins/clean-output.js +3 -1
- package/dist/core/plugins/clean-output.js.map +1 -1
- package/dist/core/plugins/compile-custom-namespaces.d.ts +6 -1
- package/dist/core/plugins/compile-custom-namespaces.d.ts.map +1 -1
- package/dist/core/plugins/compile-custom-namespaces.js +74 -11
- package/dist/core/plugins/compile-custom-namespaces.js.map +1 -1
- package/dist/core/plugins/compile-engine.d.ts +2 -4
- package/dist/core/plugins/compile-engine.d.ts.map +1 -1
- package/dist/core/plugins/compile-engine.js +5 -5
- package/dist/core/plugins/compile-engine.js.map +1 -1
- package/dist/core/plugins/compile-exml.d.ts.map +1 -1
- package/dist/core/plugins/compile-exml.js +18 -3
- package/dist/core/plugins/compile-exml.js.map +1 -1
- package/dist/core/plugins/compile-source.d.ts +1 -1
- package/dist/core/plugins/compile-source.d.ts.map +1 -1
- package/dist/core/plugins/compile-source.js +10 -8
- package/dist/core/plugins/compile-source.js.map +1 -1
- package/dist/core/plugins/component-catalog.d.ts +6 -0
- package/dist/core/plugins/component-catalog.d.ts.map +1 -0
- package/dist/core/plugins/component-catalog.js +30 -0
- package/dist/core/plugins/component-catalog.js.map +1 -0
- package/dist/core/plugins/copy-assets.d.ts +1 -2
- package/dist/core/plugins/copy-assets.d.ts.map +1 -1
- package/dist/core/plugins/copy-assets.js +1 -3
- package/dist/core/plugins/copy-assets.js.map +1 -1
- package/dist/core/plugins/generate-html.d.ts.map +1 -1
- package/dist/core/plugins/generate-html.js +1 -1
- package/dist/core/plugins/generate-html.js.map +1 -1
- package/dist/core/plugins/index.d.ts +1 -0
- package/dist/core/plugins/index.d.ts.map +1 -1
- package/dist/core/plugins/index.js +3 -0
- package/dist/core/plugins/index.js.map +1 -1
- package/dist/core/project.d.ts +85 -6
- package/dist/core/project.d.ts.map +1 -1
- package/dist/core/project.js +53 -8
- package/dist/core/project.js.map +1 -1
- package/dist/core/template.d.ts +8 -1
- package/dist/core/template.d.ts.map +1 -1
- package/dist/core/template.js +18 -8
- package/dist/core/template.js.map +1 -1
- package/dist/define.d.ts +1 -1
- package/dist/define.d.ts.map +1 -1
- package/dist/utils/fs.d.ts +15 -0
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +15 -0
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/logger.d.ts +7 -3
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +7 -3
- package/dist/utils/logger.js.map +1 -1
- package/package.json +18 -8
- package/templates/empty/src/Main.ts +6 -6
- package/templates/empty/tsconfig.json +3 -0
- package/templates/game/kurot.config.ts +5 -0
- package/templates/game/src/AssetAdapter.ts +25 -0
- package/templates/game/src/LifecycleHandler.ts +39 -0
- package/templates/game/src/Main.ts +85 -78
- package/templates/game/src/Preloader.ts +112 -0
- package/templates/game/tsconfig.json +3 -0
- package/templates/game/src/LoadingUI.ts +0 -27
- /package/templates/game/resource/skins/{ButtonSkin.exml → eui/ButtonSkin.exml} +0 -0
- /package/templates/game/resource/skins/{CheckBoxSkin.exml → eui/CheckBoxSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ComboBoxSkin.exml → eui/ComboBoxSkin.exml} +0 -0
- /package/templates/game/resource/skins/{GroupSkin.exml → eui/GroupSkin.exml} +0 -0
- /package/templates/game/resource/skins/{HScrollBarSkin.exml → eui/HScrollBarSkin.exml} +0 -0
- /package/templates/game/resource/skins/{HSliderSkin.exml → eui/HSliderSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ImageSkin.exml → eui/ImageSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ItemRendererSkin.exml → eui/ItemRendererSkin.exml} +0 -0
- /package/templates/game/resource/skins/{LabelSkin.exml → eui/LabelSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ListSkin.exml → eui/ListSkin.exml} +0 -0
- /package/templates/game/resource/skins/{PanelSkin.exml → eui/PanelSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ProgressBarSkin.exml → eui/ProgressBarSkin.exml} +0 -0
- /package/templates/game/resource/skins/{RadioButtonSkin.exml → eui/RadioButtonSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ScrollerSkin.exml → eui/ScrollerSkin.exml} +0 -0
- /package/templates/game/resource/skins/{TabBarSkin.exml → eui/TabBarSkin.exml} +0 -0
- /package/templates/game/resource/skins/{TextInputSkin.exml → eui/TextInputSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ToggleButtonSkin.exml → eui/ToggleButtonSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ToggleSwitchSkin.exml → eui/ToggleSwitchSkin.exml} +0 -0
- /package/templates/game/resource/skins/{VScrollBarSkin.exml → eui/VScrollBarSkin.exml} +0 -0
- /package/templates/game/resource/skins/{VSliderSkin.exml → eui/VSliderSkin.exml} +0 -0
- /package/templates/game/resource/skins/{ViewStackSkin.exml → eui/ViewStackSkin.exml} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Event, type Stage } from '@kurot/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Manages application-specific foreground and background behavior.
|
|
5
|
+
*
|
|
6
|
+
* Kurot pauses and resumes its ticker automatically. Add project-level
|
|
7
|
+
* behavior such as music, network, or worker handling to this class.
|
|
8
|
+
*/
|
|
9
|
+
export class LifecycleHandler {
|
|
10
|
+
|
|
11
|
+
private static _stage?: Stage;
|
|
12
|
+
|
|
13
|
+
static init(stage: Stage): void {
|
|
14
|
+
if (this._stage === stage) return;
|
|
15
|
+
|
|
16
|
+
this.clear();
|
|
17
|
+
this._stage = stage;
|
|
18
|
+
this._stage.addEventListener(Event.DEACTIVATE, this.onPause);
|
|
19
|
+
this._stage.addEventListener(Event.ACTIVATE, this.onResume);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static clear(): void {
|
|
23
|
+
if (!this._stage) return;
|
|
24
|
+
|
|
25
|
+
this._stage.removeEventListener(Event.DEACTIVATE, this.onPause);
|
|
26
|
+
this._stage.removeEventListener(Event.ACTIVATE, this.onResume);
|
|
27
|
+
this._stage = undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static onPause = (): void => {
|
|
31
|
+
// Add application-specific background behavior here.
|
|
32
|
+
console.log('paused');
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
private static onResume = (): void => {
|
|
36
|
+
// Add application-specific foreground behavior here.
|
|
37
|
+
console.log('resumed');
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -1,138 +1,145 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Kurot
|
|
2
|
+
* Kurot game project template.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* 通过 Shape、TextField 等基础显示对象构建游戏场景。
|
|
4
|
+
* Builds a responsive interface with @kurot/ui and plays tween animations with @kurot/game.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
6
|
+
* Lifecycle: constructor → ADDED_TO_STAGE → $onAddToStage → runGame → load → createGameScene → startAnimation
|
|
8
7
|
*/
|
|
9
|
-
import { createPlayer,
|
|
10
|
-
import { Button,
|
|
8
|
+
import { createPlayer, Event, resource } from '@kurot/core';
|
|
9
|
+
import { Button, Label, Rect, Theme, UILayer, setAssetAdapter } from '@kurot/ui';
|
|
11
10
|
import { Tween } from '@kurot/game';
|
|
12
|
-
import {
|
|
11
|
+
import { AssetAdapter } from '@/AssetAdapter';
|
|
12
|
+
import { LifecycleHandler } from '@/LifecycleHandler';
|
|
13
|
+
import { Preloader } from '@/Preloader';
|
|
13
14
|
|
|
14
15
|
class Main extends UILayer {
|
|
16
|
+
private readonly _preloader = new Preloader();
|
|
17
|
+
|
|
15
18
|
createChildren(): void {
|
|
16
19
|
super.createChildren();
|
|
17
20
|
|
|
18
21
|
const stage = this.stage;
|
|
19
22
|
if (!stage) return;
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
setAssetAdapter(new AssetAdapter());
|
|
25
|
+
LifecycleHandler.init(stage);
|
|
26
|
+
|
|
27
|
+
void this.runGame().catch(error => {
|
|
28
|
+
console.error('[Main] Unable to start game:', error);
|
|
23
29
|
});
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
private async runGame(
|
|
27
|
-
await this.
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
this.createGameScene(
|
|
32
|
+
private async runGame(): Promise<void> {
|
|
33
|
+
await this.createPreloader();
|
|
34
|
+
await this.load();
|
|
35
|
+
this._preloader.destroy();
|
|
36
|
+
this.createGameScene();
|
|
31
37
|
this.startAnimation();
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
private installResourceAssetAdapter(): void {
|
|
39
|
-
const fallback = new DefaultAssetAdapter();
|
|
40
|
-
setAssetAdapter({
|
|
41
|
-
getAsset: (source, callback) => {
|
|
42
|
-
const texture = resource.get<Texture>(source);
|
|
43
|
-
if (texture) {
|
|
44
|
-
callback(texture, source);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
fallback.getAsset(source, callback);
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
}
|
|
40
|
+
private async load(): Promise<void> {
|
|
41
|
+
await this.updatePreloader('Loading resource configuration...', 1, 2);
|
|
42
|
+
await resource.loadConfig('resource/default.res.json', 'resource/');
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
stage.addChild(loadingView);
|
|
44
|
+
await this.updatePreloader('Loading theme...', 2, 2);
|
|
45
|
+
await this.loadTheme();
|
|
55
46
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
// 资源配置文件不存在时静默跳过(纯代码项目无需资源配置)
|
|
47
|
+
if (resource.hasGroup('preload')) {
|
|
48
|
+
this._preloader.updateText('Loading resources...');
|
|
49
|
+
await resource.loadGroup('preload', 0, (loaded, total) => {
|
|
50
|
+
this._preloader.onProgress(loaded, total);
|
|
51
|
+
});
|
|
65
52
|
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private async createPreloader(): Promise<void> {
|
|
56
|
+
await this._preloader.init();
|
|
57
|
+
this.addChild(this._preloader);
|
|
58
|
+
}
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
private async updatePreloader(message: string, current: number, total: number): Promise<void> {
|
|
61
|
+
this._preloader.updateText(message);
|
|
62
|
+
this._preloader.updateProgress(current, total);
|
|
63
|
+
await this.wait(0.1);
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
private async loadTheme(): Promise<void> {
|
|
71
|
-
//
|
|
67
|
+
// Load the theme and its default UI skin mappings.
|
|
72
68
|
const theme = new Theme('resource/default.thm.json');
|
|
73
69
|
await new Promise<void>(resolve => theme.addEventListener(Event.COMPLETE, () => resolve()));
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
private
|
|
72
|
+
private wait(timeout: number): Promise<void> {
|
|
73
|
+
return new Promise<void>(resolve => {
|
|
74
|
+
setTimeout(resolve, timeout * 1000);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private textfield!: Label;
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* Create the game scene.
|
|
80
82
|
*
|
|
81
|
-
*
|
|
83
|
+
* Build a responsive view with EUI components and constraint-based layout.
|
|
82
84
|
*/
|
|
83
|
-
private createGameScene(
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
sky.
|
|
90
|
-
sky.
|
|
91
|
-
sky.graphics.endFill();
|
|
85
|
+
private createGameScene(): void {
|
|
86
|
+
// Responsive background
|
|
87
|
+
const sky = new Rect();
|
|
88
|
+
sky.left = 0;
|
|
89
|
+
sky.right = 0;
|
|
90
|
+
sky.top = 0;
|
|
91
|
+
sky.bottom = 0;
|
|
92
|
+
sky.fillColor = 0x2d3436;
|
|
92
93
|
this.addChild(sky);
|
|
93
94
|
|
|
94
|
-
//
|
|
95
|
-
const topMask = new
|
|
96
|
-
topMask.
|
|
97
|
-
topMask.
|
|
98
|
-
topMask.
|
|
99
|
-
topMask.
|
|
95
|
+
// Translucent header
|
|
96
|
+
const topMask = new Rect();
|
|
97
|
+
topMask.left = 0;
|
|
98
|
+
topMask.right = 0;
|
|
99
|
+
topMask.top = 33;
|
|
100
|
+
topMask.height = 172;
|
|
101
|
+
topMask.fillColor = 0x000000;
|
|
102
|
+
topMask.fillAlpha = 0.5;
|
|
100
103
|
this.addChild(topMask);
|
|
101
104
|
|
|
102
|
-
//
|
|
103
|
-
const colorLabel = new
|
|
105
|
+
// Title
|
|
106
|
+
const colorLabel = new Label();
|
|
104
107
|
colorLabel.textColor = 0xffffff;
|
|
105
|
-
colorLabel.
|
|
108
|
+
colorLabel.left = 0;
|
|
109
|
+
colorLabel.right = 0;
|
|
110
|
+
colorLabel.top = 80;
|
|
111
|
+
colorLabel.height = 48;
|
|
106
112
|
colorLabel.textAlign = 'center';
|
|
113
|
+
colorLabel.verticalAlign = 'middle';
|
|
107
114
|
colorLabel.text = 'Hello Kurot';
|
|
108
115
|
colorLabel.size = 36;
|
|
109
|
-
colorLabel.x = 0;
|
|
110
|
-
colorLabel.y = 80;
|
|
111
116
|
this.addChild(colorLabel);
|
|
112
117
|
|
|
113
|
-
//
|
|
114
|
-
const textfield = new
|
|
118
|
+
// Animated description
|
|
119
|
+
const textfield = new Label();
|
|
115
120
|
this.addChild(textfield);
|
|
116
121
|
textfield.alpha = 0;
|
|
117
|
-
textfield.
|
|
122
|
+
textfield.left = 0;
|
|
123
|
+
textfield.right = 0;
|
|
124
|
+
textfield.top = 135;
|
|
125
|
+
textfield.height = 36;
|
|
118
126
|
textfield.textAlign = 'center';
|
|
127
|
+
textfield.verticalAlign = 'middle';
|
|
119
128
|
textfield.size = 24;
|
|
120
129
|
textfield.textColor = 0xffffff;
|
|
121
|
-
textfield.x = 0;
|
|
122
|
-
textfield.y = 135;
|
|
123
130
|
this.textfield = textfield;
|
|
124
131
|
|
|
125
|
-
// UI
|
|
132
|
+
// UI button using the default theme
|
|
126
133
|
const button = new Button();
|
|
127
134
|
button.label = 'Click Me';
|
|
128
|
-
button.
|
|
129
|
-
button.
|
|
135
|
+
button.horizontalCenter = 0;
|
|
136
|
+
button.top = 200;
|
|
130
137
|
button.width = 200;
|
|
131
138
|
this.addChild(button);
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
/**
|
|
135
|
-
*
|
|
142
|
+
* Play a looping text fade animation.
|
|
136
143
|
*/
|
|
137
144
|
private startAnimation(): void {
|
|
138
145
|
const texts = ['Open-source, Free, Multi-platform', 'Push Game Forward', 'HTML5 Game Engine'];
|
|
@@ -153,7 +160,7 @@ class Main extends UILayer {
|
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
|
|
156
|
-
// ──
|
|
163
|
+
// ── Bootstrap ─────────────────────────────────────────────────────────────
|
|
157
164
|
const app = createPlayer({
|
|
158
165
|
canvas: document.getElementById('gameCanvas') as HTMLCanvasElement,
|
|
159
166
|
contentWidth: 640,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Group, Label, Rect, UILayer } from '@kurot/ui';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Displays project startup and resource-loading progress.
|
|
5
|
+
*/
|
|
6
|
+
export class Preloader extends UILayer {
|
|
7
|
+
|
|
8
|
+
private readonly _background = new Rect();
|
|
9
|
+
private readonly _title = new Label();
|
|
10
|
+
private readonly _tip = new Label();
|
|
11
|
+
private readonly _progress = new Group();
|
|
12
|
+
private readonly _track = new Rect();
|
|
13
|
+
private readonly _thumb = new Rect();
|
|
14
|
+
private readonly _thumbMask = new Rect();
|
|
15
|
+
|
|
16
|
+
init(): Promise<void> {
|
|
17
|
+
this.createBackground();
|
|
18
|
+
this.createTitle();
|
|
19
|
+
this.createProgress();
|
|
20
|
+
this.createTip();
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
onProgress(current: number, total: number): void {
|
|
25
|
+
if (total <= 0) return;
|
|
26
|
+
const width = this.getMaskMaxWidth();
|
|
27
|
+
this._thumbMask.width = width * 0.7 + width * 0.3 * (current / total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
updateProgress(current: number, total: number): void {
|
|
31
|
+
if (total <= 0) return;
|
|
32
|
+
this._thumbMask.width = this.getMaskMaxWidth() * 0.7 * current / total;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateText(text: string): void {
|
|
36
|
+
this._tip.text = text;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
destroy(): void {
|
|
40
|
+
if (this.parent) {
|
|
41
|
+
this.parent.removeChild(this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private createBackground(): void {
|
|
46
|
+
this.addChild(this._background);
|
|
47
|
+
this._background.left = 0;
|
|
48
|
+
this._background.right = 0;
|
|
49
|
+
this._background.top = 0;
|
|
50
|
+
this._background.bottom = 0;
|
|
51
|
+
this._background.fillColor = 0x2d3436;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private createTitle(): void {
|
|
55
|
+
this.addChild(this._title);
|
|
56
|
+
this._title.text = 'KUROT';
|
|
57
|
+
this._title.size = 48;
|
|
58
|
+
this._title.bold = true;
|
|
59
|
+
this._title.width = 400;
|
|
60
|
+
this._title.height = 64;
|
|
61
|
+
this._title.textAlign = 'center';
|
|
62
|
+
this._title.verticalAlign = 'middle';
|
|
63
|
+
this._title.horizontalCenter = 0;
|
|
64
|
+
this._title.verticalCenter = -80;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private createProgress(): void {
|
|
68
|
+
this.addChild(this._progress);
|
|
69
|
+
this._progress.width = 520;
|
|
70
|
+
this._progress.height = 24;
|
|
71
|
+
this._progress.horizontalCenter = 0;
|
|
72
|
+
this._progress.verticalCenter = 10;
|
|
73
|
+
|
|
74
|
+
this._progress.addChild(this._track);
|
|
75
|
+
this._track.left = 0;
|
|
76
|
+
this._track.right = 0;
|
|
77
|
+
this._track.top = 0;
|
|
78
|
+
this._track.bottom = 0;
|
|
79
|
+
this._track.fillColor = 0xffffff;
|
|
80
|
+
|
|
81
|
+
this._progress.addChild(this._thumb);
|
|
82
|
+
this._thumb.left = 4;
|
|
83
|
+
this._thumb.right = 4;
|
|
84
|
+
this._thumb.top = 4;
|
|
85
|
+
this._thumb.bottom = 4;
|
|
86
|
+
this._thumb.fillColor = 0x00a8ff;
|
|
87
|
+
|
|
88
|
+
this._progress.addChild(this._thumbMask);
|
|
89
|
+
this._thumbMask.left = 4;
|
|
90
|
+
this._thumbMask.top = 4;
|
|
91
|
+
this._thumbMask.bottom = 4;
|
|
92
|
+
this._thumbMask.width = 0;
|
|
93
|
+
this._thumb.mask = this._thumbMask;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private createTip(): void {
|
|
97
|
+
this.addChild(this._tip);
|
|
98
|
+
this._tip.text = 'Starting...';
|
|
99
|
+
this._tip.size = 20;
|
|
100
|
+
this._tip.width = 520;
|
|
101
|
+
this._tip.height = 40;
|
|
102
|
+
this._tip.textAlign = 'center';
|
|
103
|
+
this._tip.verticalAlign = 'middle';
|
|
104
|
+
this._tip.horizontalCenter = 0;
|
|
105
|
+
this._tip.verticalCenter = 60;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private getMaskMaxWidth(): number {
|
|
109
|
+
const inset = Number(this._thumbMask.left) || 0;
|
|
110
|
+
return this._progress.width - inset * 2;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 资源加载进度界面
|
|
3
|
-
*
|
|
4
|
-
* 在资源加载期间显示 "Loading...current/total" 文本。
|
|
5
|
-
* 对应 Egret 的 LoadingUI。
|
|
6
|
-
*/
|
|
7
|
-
import { Sprite, TextField } from '@kurot/core';
|
|
8
|
-
|
|
9
|
-
class LoadingUI extends Sprite {
|
|
10
|
-
private textField: TextField;
|
|
11
|
-
|
|
12
|
-
public constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.textField = new TextField();
|
|
15
|
-
this.addChild(this.textField);
|
|
16
|
-
this.textField.y = 300;
|
|
17
|
-
this.textField.width = 480;
|
|
18
|
-
this.textField.height = 100;
|
|
19
|
-
this.textField.textAlign = 'center';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public onProgress(current: number, total: number): void {
|
|
23
|
-
this.textField.text = `Loading...${current}/${total}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { LoadingUI };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|