From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../CustomBattlePasswordSettingHandler.cs | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs b/Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs new file mode 100644 index 00000000..e45ce9a7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs @@ -0,0 +1,130 @@ +using System; +using UILib; +using XMainClient.UI.UICommon; + +namespace XMainClient.UI.CustomBattle +{ + internal class CustomBattlePasswordSettingHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "GameSystem/CustomBattle/PasswordSettingFrame"; + } + } + + private XCustomBattleDocument _doc = null; + + private IXUIButton _ok; + + private IXUIButton _cancel; + + private IXUIInput _password; + + private bool passwordForJoin = false; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XCustomBattleDocument.uuID); + this._ok = (base.transform.Find("OK").GetComponent("XUIButton") as IXUIButton); + this._cancel = (base.transform.Find("Cancel").GetComponent("XUIButton") as IXUIButton); + this._password = (base.transform.Find("Password").GetComponent("XUIInput") as IXUIInput); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this._ok.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnOKButtonClicked)); + this._cancel.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCancelButtonClicked)); + } + + protected override void OnShow() + { + base.OnShow(); + this.passwordForJoin = this._doc.passwordForJoin; + this._doc.passwordForJoin = false; + this.RefreshData(); + } + + public override void RefreshData() + { + base.RefreshData(); + bool flag = DlgBase.singleton._CustomModeCreateHandler != null && DlgBase.singleton._CustomModeCreateHandler.IsVisible(); + if (flag) + { + bool flag2 = this._doc.CustomCreateData.hasPassword && !string.IsNullOrEmpty(this._doc.CustomCreateData.password); + if (flag2) + { + this._password.SetText(this._doc.CustomCreateData.password); + } + } + } + + private bool OnOKButtonClicked(IXUIButton button) + { + bool flag = this.passwordForJoin; + bool result; + if (flag) + { + bool flag2 = this._password.GetText() == this._password.GetDefault(); + if (flag2) + { + this._doc.SendCustomBattleJoin(this._doc.CurrentCustomData.gameID, false, ""); + } + else + { + this._doc.SendCustomBattleJoin(this._doc.CurrentCustomData.gameID, false, this._password.GetText()); + } + base.SetVisible(false); + result = true; + } + else + { + bool flag3 = this._password.GetText() == "" || this._password.GetText() == this._password.GetDefault(); + if (flag3) + { + bool flag4 = DlgBase.singleton._CustomModeCreateHandler != null && DlgBase.singleton._CustomModeCreateHandler.IsVisible(); + if (flag4) + { + this._doc.CustomCreateData.hasPassword = false; + this._doc.CustomCreateData.password = ""; + DlgBase.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(false); + } + } + else + { + bool flag5 = DlgBase.singleton._CustomModeCreateHandler != null && DlgBase.singleton._CustomModeCreateHandler.IsVisible(); + if (flag5) + { + this._doc.CustomCreateData.hasPassword = true; + this._doc.CustomCreateData.password = this._password.GetText(); + DlgBase.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(true); + } + } + bool flag6 = DlgBase.singleton._CustomModeBriefHandler != null && DlgBase.singleton._CustomModeBriefHandler.IsVisible(); + if (flag6) + { + this._doc.SendCustomBattleModifyPassword(this._doc.CurrentCustomData.gameID, this._password.GetText()); + } + base.SetVisible(false); + result = true; + } + return result; + } + + private bool OnCancelButtonClicked(IXUIButton button) + { + bool flag = DlgBase.singleton._CustomModeCreateHandler != null && DlgBase.singleton._CustomModeCreateHandler.IsVisible(); + if (flag) + { + this._doc.CustomCreateData.hasPassword = false; + this._doc.CustomCreateData.password = ""; + DlgBase.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(false); + } + base.SetVisible(false); + return true; + } + } +} -- cgit v1.1-26-g67d0