/**
 * 自动下注逻辑
 */
class Auto {
	private static _instance: Auto;
	static get instance(): Auto {
		if (!this._instance) {
			this._instance = new Auto();
		}
		return this._instance;
	}

	private uiAuto: UI_Auto;
	private uiAutoDetail: UI_AutoDetail;

	public constructor() {
	}

	openAutoView(): void {
		if(this.uiAuto) {
			this.uiAuto.visible = true;
		} else {
			this.uiAuto = UIController.instance.popupView<UI_Auto>(UI_Auto);
		}
	}

	closeAutoView(): void {
		this.uiAuto && (this.uiAuto.visible = false);
	}

	openAutoDetailView(): void {
		if(this.uiAutoDetail) {
			this.uiAutoDetail.visible = true;
		} else {
			this.uiAutoDetail = UIController.instance.createView<UI_AutoDetail>(UI_AutoDetail);
			this.uiAuto.addChild(this.uiAutoDetail);
		}
	}

	closeAutoDetailView(): void {
		this.uiAutoDetail && (this.uiAutoDetail.visible = false);
	}
}