import { _decorator, Button, Component, Node } from 'cc';
import { UIPanel } from '../base/UIPanel';
import { PopupType } from '../popup/PopupType';
import { GameManager } from '../../Managers/global/state/GameManager';
import { ManagerType } from '../../Managers/global/data-flow/TopLevelManager';
const { ccclass, property } = _decorator;

@ccclass('MenuPanel')
export class MenuPanel extends UIPanel 
{
    @property({type: Button})
    private startBtn: Button;

    @property({type: Button})
    private settingsBtn: Button;

    @property({type: Button})
    private quitBtn: Button;

    protected onEnable(): void 
    {
        super.onEnable();
        
        this.startBtn.node.on(Button.EventType.CLICK, () =>
        { 
            this.uiManager.fn_DeactivateSpecificPanel(PopupType.PT_MainMenu);
            this.uiManager.fn_ActivatePanel(PopupType.PT_Levels);
        });
        
        this.settingsBtn.node.on(Button.EventType.CLICK, () => 
        {
            this.uiManager.fn_DeactivateCurrentActivePanel();
            this.uiManager.fn_ActivatePanel(PopupType.PT_MenuSettings);
        });
        this.quitBtn.node.on(Button.EventType.CLICK, () => this.uiManager.fn_OnQuitGameClicked());
    }

    protected onDisable(): void 
    {
        // super.onDisable();

        this.startBtn.node.off(Button.EventType.CLICK);
        this.settingsBtn.node.off(Button.EventType.CLICK);
        this.quitBtn.node.off(Button.EventType.CLICK);
    }
}


