@cc-component/cc-core 1.1.9 → 1.2.1
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.
|
@@ -16,8 +16,8 @@ export abstract class WindowHandler {
|
|
|
16
16
|
Object.keys(configMap).forEach(key => {
|
|
17
17
|
const cof = configMap[key];
|
|
18
18
|
if (cof.module = moduleName) {
|
|
19
|
-
(this as any)[key] = (params: any) => {
|
|
20
|
-
MainModule.OpenWindow(configMap[key], params);
|
|
19
|
+
(this as any)[key] = async (params: any) => {
|
|
20
|
+
return await MainModule.OpenWindow(configMap[key], params);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { tween } from 'cc';
|
|
3
|
+
import { Label } from 'cc';
|
|
3
4
|
import { ProgressBar } from 'cc';
|
|
4
5
|
import { _decorator, Component, Node, game, find, director } from 'cc';
|
|
5
6
|
const { ccclass, property, menu } = _decorator;
|
|
@@ -25,8 +26,17 @@ export class ProgessWindow extends Component {
|
|
|
25
26
|
type: ProgressBar,
|
|
26
27
|
displayName: "进度条"
|
|
27
28
|
})
|
|
28
|
-
pro_bar
|
|
29
|
-
|
|
29
|
+
pro_bar: ProgressBar;
|
|
30
|
+
|
|
31
|
+
@property({
|
|
32
|
+
type: Label,
|
|
33
|
+
displayName: "进度条文本"
|
|
34
|
+
})
|
|
35
|
+
pro_lb: Label;
|
|
36
|
+
/**监听进度
|
|
37
|
+
* pro:0-100
|
|
38
|
+
*/
|
|
39
|
+
public onProgress: (pro: number) => void
|
|
30
40
|
|
|
31
41
|
protected onLoad(): void {
|
|
32
42
|
|
|
@@ -37,27 +47,18 @@ export class ProgessWindow extends Component {
|
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
/***更新进度--假的进度 */
|
|
40
|
-
async ProgessValueAuto(
|
|
41
|
-
this.
|
|
42
|
-
if (isOk) {
|
|
43
|
-
for (var i = 90; i < 101; i++) {
|
|
44
|
-
await MainModule.timeManager.AwaitMS(1);
|
|
45
|
-
this.ProgessValue((i));
|
|
46
|
-
}
|
|
47
|
-
this.Hide()
|
|
48
|
-
} else {
|
|
49
|
-
for (var i = 0; i < 90; i++) {
|
|
50
|
-
if (this.stop) { return }
|
|
51
|
-
await MainModule.timeManager.AwaitMS(1);
|
|
52
|
-
this.ProgessValue((i));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
50
|
+
async ProgessValueAuto(param: { startTime: number, endTime: number }) {
|
|
51
|
+
await this.loadProgress(param.startTime, param.endTime, (pro: number) => { this.ProgessValue((pro)); })
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
/***更新进度 */
|
|
58
55
|
public ProgessValue(value: number) {
|
|
59
56
|
if (this.pro_bar) {
|
|
60
|
-
this.
|
|
57
|
+
this.onProgress?.(value)
|
|
58
|
+
if (this.pro_lb) {
|
|
59
|
+
this.pro_lb.string = `${value}%`
|
|
60
|
+
}
|
|
61
|
+
this.pro(this.pro_bar, value, 100, 0);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -84,5 +85,25 @@ export class ProgessWindow extends Component {
|
|
|
84
85
|
proBar.progress = pro;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
88
|
+
|
|
89
|
+
/** 模拟假加载进度(仅用于调试) */
|
|
90
|
+
loadProgress(startTime: number = 0, durationSeconds: number = 2, pro: (pro: number) => void): Promise<void> {
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
let progress = startTime;
|
|
93
|
+
const step = 1; // 每次增加 1%
|
|
94
|
+
const intervalMs = (durationSeconds * 1000) / 100; // 总毫秒数 / 100 步
|
|
95
|
+
const timer = setInterval(() => {
|
|
96
|
+
progress += step;
|
|
97
|
+
if (progress >= 100) {
|
|
98
|
+
progress = 100;
|
|
99
|
+
clearInterval(timer);
|
|
100
|
+
pro?.(progress);
|
|
101
|
+
resolve();
|
|
102
|
+
} else {
|
|
103
|
+
pro?.(progress);
|
|
104
|
+
}
|
|
105
|
+
}, intervalMs);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
87
108
|
}
|
|
88
109
|
|