@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.
Files changed (158) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +21 -0
  3. package/README.md +40 -9
  4. package/dist/commands/build.d.ts +3 -0
  5. package/dist/commands/build.d.ts.map +1 -1
  6. package/dist/commands/build.js +3 -0
  7. package/dist/commands/build.js.map +1 -1
  8. package/dist/commands/clean.d.ts +3 -0
  9. package/dist/commands/clean.d.ts.map +1 -1
  10. package/dist/commands/clean.js +3 -0
  11. package/dist/commands/clean.js.map +1 -1
  12. package/dist/commands/create.d.ts +3 -0
  13. package/dist/commands/create.d.ts.map +1 -1
  14. package/dist/commands/create.js +3 -0
  15. package/dist/commands/create.js.map +1 -1
  16. package/dist/commands/dev.d.ts +3 -0
  17. package/dist/commands/dev.d.ts.map +1 -1
  18. package/dist/commands/dev.js +5 -1
  19. package/dist/commands/dev.js.map +1 -1
  20. package/dist/core/components/discover-components.d.ts +16 -0
  21. package/dist/core/components/discover-components.d.ts.map +1 -0
  22. package/dist/core/components/discover-components.js +191 -0
  23. package/dist/core/components/discover-components.js.map +1 -0
  24. package/dist/core/config.d.ts +45 -17
  25. package/dist/core/config.d.ts.map +1 -1
  26. package/dist/core/config.js +16 -6
  27. package/dist/core/config.js.map +1 -1
  28. package/dist/core/dev-server.d.ts +5 -5
  29. package/dist/core/dev-server.d.ts.map +1 -1
  30. package/dist/core/dev-server.js +97 -25
  31. package/dist/core/dev-server.js.map +1 -1
  32. package/dist/core/diagnostics/output.d.ts +31 -0
  33. package/dist/core/diagnostics/output.d.ts.map +1 -1
  34. package/dist/core/diagnostics/output.js +13 -0
  35. package/dist/core/diagnostics/output.js.map +1 -1
  36. package/dist/core/diagnostics/types.d.ts +15 -0
  37. package/dist/core/diagnostics/types.d.ts.map +1 -1
  38. package/dist/core/errors.d.ts.map +1 -1
  39. package/dist/core/errors.js.map +1 -1
  40. package/dist/core/exml/ast.d.ts +27 -0
  41. package/dist/core/exml/ast.d.ts.map +1 -1
  42. package/dist/core/exml/codegen.d.ts +6 -7
  43. package/dist/core/exml/codegen.d.ts.map +1 -1
  44. package/dist/core/exml/codegen.js +57 -87
  45. package/dist/core/exml/codegen.js.map +1 -1
  46. package/dist/core/exml/exml-diagnostics.d.ts +2 -1
  47. package/dist/core/exml/exml-diagnostics.d.ts.map +1 -1
  48. package/dist/core/exml/exml-diagnostics.js +2 -2
  49. package/dist/core/exml/exml-diagnostics.js.map +1 -1
  50. package/dist/core/exml/exml-parser.d.ts +11 -11
  51. package/dist/core/exml/exml-parser.d.ts.map +1 -1
  52. package/dist/core/exml/exml-parser.js +90 -178
  53. package/dist/core/exml/exml-parser.js.map +1 -1
  54. package/dist/core/exml/index.d.ts +13 -13
  55. package/dist/core/exml/index.d.ts.map +1 -1
  56. package/dist/core/exml/index.js +12 -13
  57. package/dist/core/exml/index.js.map +1 -1
  58. package/dist/core/exml/registry.d.ts +39 -33
  59. package/dist/core/exml/registry.d.ts.map +1 -1
  60. package/dist/core/exml/registry.js +56 -43
  61. package/dist/core/exml/registry.js.map +1 -1
  62. package/dist/core/exml/skin-module-builder.d.ts +14 -0
  63. package/dist/core/exml/skin-module-builder.d.ts.map +1 -1
  64. package/dist/core/exml/skin-module-builder.js +8 -2
  65. package/dist/core/exml/skin-module-builder.js.map +1 -1
  66. package/dist/core/exml/xml-parser.d.ts +36 -26
  67. package/dist/core/exml/xml-parser.d.ts.map +1 -1
  68. package/dist/core/exml/xml-parser.js +133 -144
  69. package/dist/core/exml/xml-parser.js.map +1 -1
  70. package/dist/core/namespace-external-plugin.d.ts +5 -5
  71. package/dist/core/namespace-external-plugin.js +5 -5
  72. package/dist/core/pipeline.d.ts +59 -39
  73. package/dist/core/pipeline.d.ts.map +1 -1
  74. package/dist/core/pipeline.js +6 -1
  75. package/dist/core/pipeline.js.map +1 -1
  76. package/dist/core/plugins/clean-output.d.ts +3 -0
  77. package/dist/core/plugins/clean-output.d.ts.map +1 -1
  78. package/dist/core/plugins/clean-output.js +3 -1
  79. package/dist/core/plugins/clean-output.js.map +1 -1
  80. package/dist/core/plugins/compile-custom-namespaces.d.ts +6 -1
  81. package/dist/core/plugins/compile-custom-namespaces.d.ts.map +1 -1
  82. package/dist/core/plugins/compile-custom-namespaces.js +74 -11
  83. package/dist/core/plugins/compile-custom-namespaces.js.map +1 -1
  84. package/dist/core/plugins/compile-engine.d.ts +2 -4
  85. package/dist/core/plugins/compile-engine.d.ts.map +1 -1
  86. package/dist/core/plugins/compile-engine.js +5 -5
  87. package/dist/core/plugins/compile-engine.js.map +1 -1
  88. package/dist/core/plugins/compile-exml.d.ts.map +1 -1
  89. package/dist/core/plugins/compile-exml.js +18 -3
  90. package/dist/core/plugins/compile-exml.js.map +1 -1
  91. package/dist/core/plugins/compile-source.d.ts +1 -1
  92. package/dist/core/plugins/compile-source.d.ts.map +1 -1
  93. package/dist/core/plugins/compile-source.js +10 -8
  94. package/dist/core/plugins/compile-source.js.map +1 -1
  95. package/dist/core/plugins/component-catalog.d.ts +6 -0
  96. package/dist/core/plugins/component-catalog.d.ts.map +1 -0
  97. package/dist/core/plugins/component-catalog.js +30 -0
  98. package/dist/core/plugins/component-catalog.js.map +1 -0
  99. package/dist/core/plugins/copy-assets.d.ts +1 -2
  100. package/dist/core/plugins/copy-assets.d.ts.map +1 -1
  101. package/dist/core/plugins/copy-assets.js +1 -3
  102. package/dist/core/plugins/copy-assets.js.map +1 -1
  103. package/dist/core/plugins/generate-html.d.ts.map +1 -1
  104. package/dist/core/plugins/generate-html.js +1 -1
  105. package/dist/core/plugins/generate-html.js.map +1 -1
  106. package/dist/core/plugins/index.d.ts +1 -0
  107. package/dist/core/plugins/index.d.ts.map +1 -1
  108. package/dist/core/plugins/index.js +3 -0
  109. package/dist/core/plugins/index.js.map +1 -1
  110. package/dist/core/project.d.ts +85 -6
  111. package/dist/core/project.d.ts.map +1 -1
  112. package/dist/core/project.js +53 -8
  113. package/dist/core/project.js.map +1 -1
  114. package/dist/core/template.d.ts +8 -1
  115. package/dist/core/template.d.ts.map +1 -1
  116. package/dist/core/template.js +18 -8
  117. package/dist/core/template.js.map +1 -1
  118. package/dist/define.d.ts +1 -1
  119. package/dist/define.d.ts.map +1 -1
  120. package/dist/utils/fs.d.ts +15 -0
  121. package/dist/utils/fs.d.ts.map +1 -1
  122. package/dist/utils/fs.js +15 -0
  123. package/dist/utils/fs.js.map +1 -1
  124. package/dist/utils/logger.d.ts +7 -3
  125. package/dist/utils/logger.d.ts.map +1 -1
  126. package/dist/utils/logger.js +7 -3
  127. package/dist/utils/logger.js.map +1 -1
  128. package/package.json +18 -8
  129. package/templates/empty/src/Main.ts +6 -6
  130. package/templates/empty/tsconfig.json +3 -0
  131. package/templates/game/kurot.config.ts +5 -0
  132. package/templates/game/src/AssetAdapter.ts +25 -0
  133. package/templates/game/src/LifecycleHandler.ts +39 -0
  134. package/templates/game/src/Main.ts +85 -78
  135. package/templates/game/src/Preloader.ts +112 -0
  136. package/templates/game/tsconfig.json +3 -0
  137. package/templates/game/src/LoadingUI.ts +0 -27
  138. /package/templates/game/resource/skins/{ButtonSkin.exml → eui/ButtonSkin.exml} +0 -0
  139. /package/templates/game/resource/skins/{CheckBoxSkin.exml → eui/CheckBoxSkin.exml} +0 -0
  140. /package/templates/game/resource/skins/{ComboBoxSkin.exml → eui/ComboBoxSkin.exml} +0 -0
  141. /package/templates/game/resource/skins/{GroupSkin.exml → eui/GroupSkin.exml} +0 -0
  142. /package/templates/game/resource/skins/{HScrollBarSkin.exml → eui/HScrollBarSkin.exml} +0 -0
  143. /package/templates/game/resource/skins/{HSliderSkin.exml → eui/HSliderSkin.exml} +0 -0
  144. /package/templates/game/resource/skins/{ImageSkin.exml → eui/ImageSkin.exml} +0 -0
  145. /package/templates/game/resource/skins/{ItemRendererSkin.exml → eui/ItemRendererSkin.exml} +0 -0
  146. /package/templates/game/resource/skins/{LabelSkin.exml → eui/LabelSkin.exml} +0 -0
  147. /package/templates/game/resource/skins/{ListSkin.exml → eui/ListSkin.exml} +0 -0
  148. /package/templates/game/resource/skins/{PanelSkin.exml → eui/PanelSkin.exml} +0 -0
  149. /package/templates/game/resource/skins/{ProgressBarSkin.exml → eui/ProgressBarSkin.exml} +0 -0
  150. /package/templates/game/resource/skins/{RadioButtonSkin.exml → eui/RadioButtonSkin.exml} +0 -0
  151. /package/templates/game/resource/skins/{ScrollerSkin.exml → eui/ScrollerSkin.exml} +0 -0
  152. /package/templates/game/resource/skins/{TabBarSkin.exml → eui/TabBarSkin.exml} +0 -0
  153. /package/templates/game/resource/skins/{TextInputSkin.exml → eui/TextInputSkin.exml} +0 -0
  154. /package/templates/game/resource/skins/{ToggleButtonSkin.exml → eui/ToggleButtonSkin.exml} +0 -0
  155. /package/templates/game/resource/skins/{ToggleSwitchSkin.exml → eui/ToggleSwitchSkin.exml} +0 -0
  156. /package/templates/game/resource/skins/{VScrollBarSkin.exml → eui/VScrollBarSkin.exml} +0 -0
  157. /package/templates/game/resource/skins/{VSliderSkin.exml → eui/VSliderSkin.exml} +0 -0
  158. /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
- * 使用 @kurot/core 进行 Canvas 绘制 + @kurot/game 补间动画。
5
- * 通过 Shape、TextField 等基础显示对象构建游戏场景。
4
+ * Builds a responsive interface with @kurot/ui and plays tween animations with @kurot/game.
6
5
  *
7
- * 生命周期:constructor → ADDED_TO_STAGE → $onAddToStage → runGame → loadResource → createGameScene → startAnimation
6
+ * Lifecycle: constructor → ADDED_TO_STAGE → $onAddToStage → runGame → load → createGameScene → startAnimation
8
7
  */
9
- import { createPlayer, TextField, Shape, Event, Stage, Texture, resource } from '@kurot/core';
10
- import { Button, DefaultAssetAdapter, Theme, UILayer, setAssetAdapter } from '@kurot/ui';
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 { LoadingUI } from './LoadingUI';
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
- this.runGame(stage).catch(e => {
22
- console.log(e);
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(stage: Stage): Promise<void> {
27
- await this.loadResource(stage);
28
- this.installResourceAssetAdapter();
29
- await this.loadTheme();
30
- this.createGameScene(stage);
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
- * 让 EXML 中的 source="button_up_png" 优先解析为预加载图集的子纹理,
36
- * 普通 URL 图片仍交给默认适配器加载。
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
- private async loadResource(stage: Stage): Promise<void> {
53
- const loadingView = new LoadingUI();
54
- stage.addChild(loadingView);
44
+ await this.updatePreloader('Loading theme...', 2, 2);
45
+ await this.loadTheme();
55
46
 
56
- try {
57
- await resource.loadConfig('resource/default.res.json', 'resource/');
58
- if (resource.hasGroup('preload')) {
59
- await resource.loadGroup('preload', 0, (loaded, total) => {
60
- loadingView.onProgress(loaded, total);
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
- stage.removeChild(loadingView);
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
- // 加载主题(UI 组件默认皮肤映射)
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 textfield!: TextField;
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
- * 使用 Shape(矢量绘制)和 TextField(文本)等基础显示对象搭建画面。
83
+ * Build a responsive view with EUI components and constraint-based layout.
82
84
  */
83
- private createGameScene(stage: Stage): void {
84
- const stageW = stage.stageWidth;
85
- const stageH = stage.stageHeight;
86
-
87
- // 背景色块
88
- const sky = new Shape();
89
- sky.graphics.beginFill(0x2d3436, 1);
90
- sky.graphics.drawRect(0, 0, stageW, stageH);
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 Shape();
96
- topMask.graphics.beginFill(0x000000, 0.5);
97
- topMask.graphics.drawRect(0, 0, stageW, 172);
98
- topMask.graphics.endFill();
99
- topMask.y = 33;
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 TextField();
105
+ // Title
106
+ const colorLabel = new Label();
104
107
  colorLabel.textColor = 0xffffff;
105
- colorLabel.width = stageW;
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 TextField();
118
+ // Animated description
119
+ const textfield = new Label();
115
120
  this.addChild(textfield);
116
121
  textfield.alpha = 0;
117
- textfield.width = stageW;
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.x = (stageW - 200) / 2;
129
- button.y = 200;
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
+ }
@@ -3,6 +3,9 @@
3
3
  "target": "ES2022",
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "bundler",
6
+ "paths": {
7
+ "@/*": ["./src/*"]
8
+ },
6
9
  "strict": true,
7
10
  "skipLibCheck": true,
8
11
  },
@@ -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 };