summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/UI/CustomBattle/CustomBattlePasswordSettingHandler.cs130
1 files changed, 130 insertions, 0 deletions
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>(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<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler != null && DlgBase<CustomBattleView, TabDlgBehaviour>.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<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler != null && DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.IsVisible();
+ if (flag4)
+ {
+ this._doc.CustomCreateData.hasPassword = false;
+ this._doc.CustomCreateData.password = "";
+ DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(false);
+ }
+ }
+ else
+ {
+ bool flag5 = DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler != null && DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.IsVisible();
+ if (flag5)
+ {
+ this._doc.CustomCreateData.hasPassword = true;
+ this._doc.CustomCreateData.password = this._password.GetText();
+ DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(true);
+ }
+ }
+ bool flag6 = DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeBriefHandler != null && DlgBase<CustomBattleView, TabDlgBehaviour>.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<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler != null && DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.IsVisible();
+ if (flag)
+ {
+ this._doc.CustomCreateData.hasPassword = false;
+ this._doc.CustomCreateData.password = "";
+ DlgBase<CustomBattleView, TabDlgBehaviour>.singleton._CustomModeCreateHandler.SetPasswordSwitchSprite(false);
+ }
+ base.SetVisible(false);
+ return true;
+ }
+ }
+}