import { _decorator, Component, Node } from 'cc';
import { UIMgr } from '../Frames/UIManager';
import { resMgr } from '../Frames/ResourcesMgr';
import { dataMgr } from '../Frames/DataManager';
import { UIType } from './GameFrameWork/UIBase';
import { LoadingUI } from './UI/LoadingUI';
const { ccclass, property } = _decorator;

@ccclass('MyApp')
export class MyApp extends Component {
    protected async  onLoad(){
        await UIMgr.openUI("LoadingUI",UIType.PAGE);
        const loadingUI = UIMgr.getUI(LoadingUI);
        
        await resMgr.loadAllRes("Res", (finish, total)=>{
            if(loadingUI){
                loadingUI.updateProgress(finish / total);
                loadingUI.updateWhichRes(1);
            }
        });
        await resMgr.loadAllRes("UI", (finish, total)=>{
            if(loadingUI){
                loadingUI.updateProgress(finish / total);
                loadingUI.updateWhichRes(2);
            }
        });
        await dataMgr.loadDataDir("Data");
        UIMgr.closeUI("LoadingUI");
        UIMgr.openUI("Start",UIType.PAGE);
    }
}


