import ConfigManager from "../../engines/configs/ConfigManager";
import { EventDispatcher } from "../../engines/events/EventDispatcher";
import { GUIManager } from "../../engines/gui/GUIManager";
import GUIMediator from "../../engines/gui/GUIMediator";
import IInitiator from "../../engines/initiators/IInitiator";
import InitiatorEvent from "../../engines/initiators/InitiatorEvent";
import EggBinder from "../../ui/Egg/EggBinder";
import FightBinder from "../../ui/Fight/FightBinder";
import GameBasicsUIBinder from "../../ui/GameBasicsUI/GameBasicsUIBinder";
import HallBinder from "../../ui/Hall/HallBinder";
import WXSExportBinder from "../../ui/WXSExport/WXSExportBinder";
import EggMediator from "../modules/exports/EggMediator";
import WXS01Mediator from "../modules/exports/WXS01Mediator";
import WXS02Mediator from "../modules/exports/WXS02Mediator";
import WXS04Mediator from "../modules/exports/WXS04Mediator";
import FightingMediator from "../modules/fightings/FightingMediator";
import HallMediator from "../modules/halls/HallMediator";
import UIKeys from "../UIKeys";



export default class GameInitiator extends EventDispatcher implements IInitiator{

    constructor(){
        super();
    }

    Start(): void {
        this.DecodeConfigs();
        this.InitGUI();

        this.DispatchEvent(InitiatorEvent.EVENT_COMPLETE);
    }
    
    /**
     * 解析配置
     */
    private DecodeConfigs():void{
        ConfigManager.single.Decode();
    }

    private InitGUI():void{
        GameBasicsUIBinder.bindAll();
        HallBinder.bindAll();
        FightBinder.bindAll();
        WXSExportBinder.bindAll();
        EggBinder.bindAll();
        
        //大厅
        GUIManager.single.RegisterGUI(UIKeys.Hall,"mainPackage","ui/Hall","Hall",HallMediator);
        //战斗
        GUIManager.single.RegisterGUI(UIKeys.Fighting,"ui","Fight","Fight",FightingMediator);

        GUIManager.single.RegisterGUI(UIKeys.WXS01,"ui","WXSExport","WX_S_01",WXS01Mediator);
        GUIManager.single.RegisterGUI(UIKeys.WXS02,"ui","WXSExport","WX_S_02",WXS02Mediator);
        GUIManager.single.RegisterGUI(UIKeys.WXS04,"ui","WXSExport","WX_S_04",WXS04Mediator);

        GUIManager.single.RegisterGUI(UIKeys.EGG,"ui","Egg","Egg",EggMediator);
    }
    
    Destroy(): void {
        
    }

    GetName(): string {
        return "GameInitiator";
    }
}