import { _decorator, Component, Label, ProgressBar } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LoadingUI')
// export class LoadingUI extends UIBase {
//     progressBar: ProgressBar = null;
//     progressLabel: Label = null;
//     whichRes: Label = null;
//     protected onStart(): void {
//         this.progressBar = this.getComponentInChildren(ProgressBar);
//         this.progressLabel = this.getComponentInChildren(Label);
//         this.whichRes = this.getLabel("_which");
//     }
//     public updateProgress(progress: number){
//         if(this.progressBar){
//             this.progressBar.progress = progress;
//         }
//         if(this.progressLabel){
//             this.progressLabel.string = `${Math.floor(progress * 100)}%`;
//         }
//     }
//     public updateWhichRes(which: number){
//         if(this.whichRes){
//             this.whichRes.string = `${which}/2`;
//         }
//     }
// }
export class LoadingUI extends Component {
    progressBar: ProgressBar = null;
    progressLabel: Label = null;
    whichRes: Label = null;
    protected start(): void {
        this.progressBar = this.getComponentInChildren(ProgressBar);
        this.progressLabel = this.getComponentInChildren(Label);
        this.whichRes = this.node.getChildByName("_which").getComponent(Label);
    }
    public updateProgress(progress: number) {
        if (this.progressBar) {
            this.progressBar.progress = progress;
        }
        if (this.progressLabel) {
            this.progressLabel.string = `${Math.floor(progress * 100)}%`;
        }
    }
    public updateWhichRes(which: number) {
        if (this.whichRes) {
            this.whichRes.string = `${which}/3`;
        }
    }
}


