import GameDataCenter from "../../data/GameDataCenter";
import { uiCommon } from "../../utils/UICommon";
import UIHelp from "../ui/UIHelp";

const { ccclass, property } = cc._decorator;
interface DebugParam {
    btnName: string,
    btnFunc: Function,
    showInput: boolean,
    defaultInput?: string
}
@ccclass
export default class UIDebugPanel extends cc.Component {

    @property(cc.Node) debugItem: cc.Node = null;
    @property(cc.Node) content: cc.Node = null;
    start() {
        this.AddLayerDebug();

    }

    // protected onEnable(): void {
    //     cc.sys.localStorage.getItem("DebugXhid", "");

    // }

    private AddDebugItem(param: DebugParam) {
        let item = cc.instantiate(this.debugItem);
        this.content.addChild(item);
        item.active = true;
        let input = item.getChildByName("EbInput");
        item.getChildByName("EbInput").active = param.showInput;
        let btn = item.getChildByName("DebugItemBtn");
        btn.getChildByName("Background").getChildByName("Label").getComponent(cc.Label).string = param.btnName;
        uiCommon.onRegisterEvent(btn, () => {
            param.btnFunc(param.showInput ? input.getComponent(cc.EditBox).string : "");
        }, this);
        if (param.showInput && param.defaultInput) {
            input.getComponent(cc.EditBox).string = param.defaultInput;
        }
    }

    private AddLayerDebug() {


    }


}
