import Func from '@/Engine/ECS/Function';
import { PAGE_KEY } from '@/Project/constants';
import { FuncMainState } from '../FuncMain';
export enum FuncProjectMenuState {
  ProjectMenu,
}

export default class FuncProjectMenu extends Func<FuncProjectMenuState> {
  constructor(name: string) {
    super(name);
    super.initStates((sm) => {
      sm.addState(
        FuncProjectMenuState.ProjectMenu,
        this.onStateIn,
        null,
        this.onStateExit,
        this,
      );
    });
  }
  onStateIn(): void {
    window.GT_APP.sysPage.add(PAGE_KEY.ProjectMenu, {
      clickMenu: this.clickMenu,
      subModule: window.GT_APP.funcMain.subModule,
    });
  }
  onStateExit(): void {
    window.GT_APP.sysPage.removeByKey(PAGE_KEY.ProjectMenu);
  }
  clickMenu(menu: Api.IMenu): void {
    console.log(menu);
    if (!menu.UnityPath) return;
    let app = window.GT_APP;
    switch (menu.UnityPath) {
      case '1':
        app.funcMain.changeState(FuncMainState.PageMenu);
        break;
    }
  }
}
