From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/RandomGiftView.cs | 228 +++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/RandomGiftView.cs (limited to 'Client/Assets/Scripts/XMainClient/RandomGiftView.cs') diff --git a/Client/Assets/Scripts/XMainClient/RandomGiftView.cs b/Client/Assets/Scripts/XMainClient/RandomGiftView.cs new file mode 100644 index 00000000..7027c2e7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/RandomGiftView.cs @@ -0,0 +1,228 @@ +using System; +using KKSG; +using UILib; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class RandomGiftView : DlgBase + { + private int shareId + { + get + { + return int.Parse(XSingleton.singleton.GetValue("ShareGiftTableID")); + } + } + + public override string fileName + { + get + { + return "Common/RandomGift"; + } + } + + public override int layer + { + get + { + return 1; + } + } + + public override int group + { + get + { + return 1; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + private string _boxId = null; + + private string _actId = null; + + private string _url = null; + + private enum ShareType + { + WXFriend, + WXTimeline, + QQFriend, + QQZone + } + + protected override void Init() + { + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + base.uiBehaviour.m_Share.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShareClick)); + base.uiBehaviour.m_WXFriend.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShareWXFriendClick)); + base.uiBehaviour.m_WXTimeline.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShareWXTimelineClick)); + base.uiBehaviour.m_QQFriend.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShareQQFriendClick)); + base.uiBehaviour.m_QQZone.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShareQQZoneClick)); + } + + public bool OnCloseClicked(IXUIButton btn) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + + protected override void OnShow() + { + base.OnShow(); + base.uiBehaviour.m_WX.gameObject.SetActive(false); + base.uiBehaviour.m_QQ.gameObject.SetActive(false); + base.uiBehaviour.m_BoxWX.gameObject.SetActive(XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat); + base.uiBehaviour.m_BoxQQ.gameObject.SetActive(XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ); + bool flag = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat; + if (flag) + { + base.uiBehaviour.m_Title.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("RANDOM_GIFT_TITLE_WX"))); + base.uiBehaviour.m_Description.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("RANDOM_GIFT_DESCRIPTION_WX"))); + } + else + { + bool flag2 = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ; + if (flag2) + { + base.uiBehaviour.m_Title.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("RANDOM_GIFT_TITLE_QQ"))); + base.uiBehaviour.m_Description.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("RANDOM_GIFT_DESCRIPTION_QQ"))); + } + } + } + + protected override void OnHide() + { + this._boxId = null; + this._actId = null; + this._url = null; + base.OnHide(); + } + + protected override void OnUnload() + { + base.OnUnload(); + } + + public void TryOpenUI() + { + bool flag = (this._boxId == null || this._actId == null) && this._url == null; + if (!flag) + { + bool flag2 = !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Random_Gift); + if (!flag2) + { + this.SetVisibleWithAnimation(true, null); + } + } + } + + public bool OnShareClick(IXUIButton btn) + { + bool flag = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat; + if (flag) + { + base.uiBehaviour.m_WX.gameObject.SetActive(!base.uiBehaviour.m_WX.gameObject.activeSelf); + } + else + { + bool flag2 = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ; + if (flag2) + { + base.uiBehaviour.m_QQ.gameObject.SetActive(!base.uiBehaviour.m_QQ.gameObject.activeSelf); + } + else + { + base.uiBehaviour.m_WX.gameObject.SetActive(!base.uiBehaviour.m_WX.gameObject.activeSelf); + XSingleton.singleton.AddLog("OnShareClick", null, null, null, null, null, XDebugColor.XDebug_None); + } + } + return true; + } + + public bool OnShareWXFriendClick(IXUIButton btn) + { + this.ShareGift(RandomGiftView.ShareType.WXFriend, ShareTagType.GiftBag_Tag); + return true; + } + + public bool OnShareWXTimelineClick(IXUIButton btn) + { + this.ShareGift(RandomGiftView.ShareType.WXTimeline, ShareTagType.GiftBag_Tag); + return true; + } + + public bool OnShareQQFriendClick(IXUIButton btn) + { + this.ShareGift(RandomGiftView.ShareType.QQFriend, ShareTagType.Invite_Tag); + return true; + } + + public bool OnShareQQZoneClick(IXUIButton btn) + { + this.ShareGift(RandomGiftView.ShareType.QQZone, ShareTagType.Invite_Tag); + return true; + } + + public void ReadyShareGift(GetPlatformShareChestArg oArg, GetPlatformShareChestRes oRes) + { + this.SetGift(oRes.act_id.ToString(), oRes.boxid, oRes.url); + } + + public void SetGift(string actId, string boxId, string url) + { + this._actId = actId; + this._boxId = boxId; + this._url = url; + XSingleton.singleton.AddLog(string.Concat(new string[] + { + "RandomGift _boxId:", + this._boxId, + " _actId:", + this._actId, + "_url:", + this._url + }), null, null, null, null, null, XDebugColor.XDebug_None); + } + + private void ShareGift(RandomGiftView.ShareType type, ShareTagType tagType) + { + bool issession = type == RandomGiftView.ShareType.WXFriend || type == RandomGiftView.ShareType.QQFriend; + XSingleton.singleton.AddLog(string.Concat(new object[] + { + "shareId:", + this.shareId, + " isSession:", + issession.ToString(), + " _actId:", + this._actId, + " _boxId:", + this._boxId, + " tagType:", + tagType + }), null, null, null, null, null, XDebugColor.XDebug_None); + XSingleton.singleton.DoShareWithLink(this.shareId, issession, tagType, this._url, new object[] + { + this._actId, + this._boxId + }); + this.OnCloseClicked(null); + } + } +} -- cgit v1.1-26-g67d0