From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/Team/XTeamPasswordHandler.cs | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Team/XTeamPasswordHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/Team/XTeamPasswordHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/Team/XTeamPasswordHandler.cs b/Client/Assets/Scripts/XMainClient/Team/XTeamPasswordHandler.cs new file mode 100644 index 00000000..ffe9689d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Team/XTeamPasswordHandler.cs @@ -0,0 +1,133 @@ +using System; +using KKSG; +using UILib; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XTeamPasswordHandler : DlgHandlerBase + { + public IXUICheckBox m_BtnNeedPwd; + + public IXUIInput m_IptPwd; + + public IXUITweenTool m_PwdTween; + + private XTeamDocument doc; + + private XOptionsDocument optionsDoc; + + protected override void Init() + { + base.Init(); + this.m_BtnNeedPwd = (base.PanelObject.transform.Find("BtnNeedPwd").GetComponent("XUICheckBox") as IXUICheckBox); + this.m_IptPwd = (base.PanelObject.transform.Find("Input").GetComponent("XUIInput") as IXUIInput); + this.m_PwdTween = (base.PanelObject.transform.Find("BtnNeedPwd").GetComponent("XUIPlayTween") as IXUITweenTool); + this.doc = XDocuments.GetSpecificDocument(XTeamDocument.uuID); + this.optionsDoc = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_BtnNeedPwd.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this._OnUsePasswordChanged)); + } + + protected override void OnShow() + { + base.OnShow(); + this.RefreshData(); + } + + public void RefreshState() + { + bool bIsLeader = this.doc.bIsLeader; + if (bIsLeader) + { + bool flag = base.IsVisible(); + if (flag) + { + this.RefreshData(); + } + else + { + base.SetVisible(true); + } + } + else + { + base.SetVisible(false); + } + } + + public override void RefreshData() + { + base.RefreshData(); + bool flag = !this.doc.bInTeam; + if (flag) + { + this.m_BtnNeedPwd.bChecked = false; + this.m_PwdTween.ResetTweenByCurGroup(false); + this.m_IptPwd.SetText(this.optionsDoc.GetStrValue(XOptionsDefine.OD_TEAM_PASSWORD)); + } + else + { + bool flag2 = string.IsNullOrEmpty(this.doc.password); + if (flag2) + { + base.SetVisible(false); + } + bool hasPwd = this.doc.MyTeam.teamBrief.hasPwd; + this.m_BtnNeedPwd.bChecked = hasPwd; + this.m_PwdTween.ResetTweenByCurGroup(hasPwd); + this.m_IptPwd.SetText(this.doc.MyTeam.teamBrief.password); + } + } + + public string GetPassword() + { + return this.m_BtnNeedPwd.bChecked ? this.m_IptPwd.GetText() : string.Empty; + } + + public string GetInputPassword() + { + return this.m_IptPwd.GetText(); + } + + private bool _OnUsePasswordChanged(IXUICheckBox ckb) + { + this.m_PwdTween.PlayTween(!ckb.bChecked, -1f); + bool bIsLeader = this.doc.bIsLeader; + if (bIsLeader) + { + bool bChecked = ckb.bChecked; + if (bChecked) + { + bool flag = !this.doc.MyTeam.teamBrief.hasPwd; + if (flag) + { + this.doc.ReqTeamOp(TeamOperate.TEAM_CHANGE_PASSWORD, 0UL, this.doc.password, TeamMemberType.TMT_NORMAL, null); + } + } + else + { + bool hasPwd = this.doc.MyTeam.teamBrief.hasPwd; + if (hasPwd) + { + this.doc.ReqTeamOp(TeamOperate.TEAM_CHANGE_PASSWORD, 0UL, string.Empty, TeamMemberType.TMT_NORMAL, null); + } + } + } + return true; + } + + private void _OnInputSubmit(IXUIInput input) + { + bool bIsLeader = this.doc.bIsLeader; + if (bIsLeader) + { + XSingleton.singleton.AddGreenLog("Change password to ", input.GetText(), null, null, null, null); + } + } + } +} -- cgit v1.1-26-g67d0