import { SpriteAtlas } from "cc"
import { AssetType, resLoader } from "../res/ResLoader"
import { AsyncQueue, NextFunction } from "../queue/AsyncQueue";

export class MaterialUtil {

    static iconGame: SpriteAtlas = null;
    static iconFilter: SpriteAtlas = null;

    static Restart() {

    }

    static init(callback) {
        // let queue = new AsyncQueue();
        // queue.pushMulti("InitPool", async (next: NextFunction, params: any, args: any) => {
        //     resLoader.load('package', 'texture/hall/Games/Icon_Game', SpriteAtlas, (error: Error, res: SpriteAtlas) => {
        //         if (!error) {
        //             this.iconGame = res;
        //             if(callback) callback();
        //             next()
        //             console.log('游戏入口图标加载完成');
        //         }
        //     });
        // }, async (next: NextFunction, params: any, args: any) => {
        //     resLoader.load('package', 'texture/hall/Games/Icon_Filter', SpriteAtlas, (error: Error, res: SpriteAtlas) => {
        //         if (!error) {
        //             this.iconFilter = res;
        //             if(callback) callback();
        //             next()
        //             console.log('游戏筛选图标加载完成');
        //         }
        //     });
        // });

        // queue.complete = () => {
        //     console.log('materialUtil初始化完成');
        // };
        
        // queue.play();
    }

    _loadRes(LoadType: AssetType, Url, Back) {
        resLoader.load('package', Url, LoadType, (error: Error, res) => {
            if (!error) {
                Back(res)
            }
        });
    }

    // /** 游戏入口图标 */
    // static getIconGameByID(id) {
    //     return this.iconGame.spriteFrames[id];
    // }

    // /** 游戏筛选图标 */
    // static getIconFilterByName(name) {
    //     return this.iconFilter.spriteFrames[name];
    // }
}