using System; using System.Collections.Generic; using KKSG; using MiniJSON; using UILib; using UnityEngine; using XMainClient.UI.UICommon; using XUpdater; using XUtliPoolLib; namespace XMainClient.UI { internal class GameCommunityHandler : DlgHandlerBase { protected override string FileName { get { return "GameSystem/GameCommunityDlg"; } } private XMainInterfaceDocument _doc = null; private int _bgWidthDelta; private bool _widthInit = false; public IXUISprite m_Bg; public Transform m_SystemParent; protected override void Init() { base.Init(); this._doc = XDocuments.GetSpecificDocument(XMainInterfaceDocument.uuID); this.m_Bg = (base.transform.Find("Bg/Bg").GetComponent("XUISprite") as IXUISprite); this.m_SystemParent = base.transform.Find("Bg/Sys"); XSingleton.singleton.RefreshWebViewConfig(); } protected override void OnShow() { base.OnShow(); bool flag = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ; int num = 0; int num2 = 0; for (int i = 0; i < this._doc.GameCommunityReader.Table.Length; i++) { GameCommunityTable.RowData rowData = this._doc.GameCommunityReader.Table[i]; IXUIButton ixuibutton = this.m_SystemParent.Find(rowData.ButtonName).GetComponent("XUIButton") as IXUIButton; ixuibutton.SetVisible(false); GameObject gameObject = ixuibutton.gameObject.transform.Find("RedPoint").gameObject; bool flag2 = i == 0; if (flag2) { num2 = ixuibutton.spriteWidth; bool flag3 = !this._widthInit; if (flag3) { this._widthInit = true; this._bgWidthDelta = this.m_Bg.spriteWidth - num2; } } bool flag4 = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)rowData.OpenLevel); if (!flag4) { bool flag5 = !XSingleton.singleton.IsSystemOpened((XSysDefine)rowData.SysID); if (!flag5) { bool flag6 = !this.LoginStateTrue(rowData); if (!flag6) { bool flag7 = rowData.ID == 13; if (flag7) { bool flag8 = this.IsSuportReplay(); if (flag8) { ixuibutton.SetVisible(true); ixuibutton.gameObject.transform.localPosition = new Vector3((float)(num * num2), 0f); ixuibutton.ID = (ulong)((long)rowData.ID); ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSysBtnClick)); num++; } } else { bool flag9 = rowData.ID == 12; if (flag9) { bool flag10 = this.GetQuestionnaireStage() == 0; if (!flag10) { ixuibutton.SetVisible(true); ixuibutton.gameObject.transform.localPosition = new Vector3((float)(num * num2), 0f); ixuibutton.ID = (ulong)((long)rowData.ID); ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSysBtnClick)); num++; gameObject.SetActive(XSingleton.singleton.GetSysRedPointStateConsiderBlock(XSysDefine.XSys_Questionnaire)); } } else { bool flag11 = rowData.ID == 14; if (flag11) { XSingleton.singleton.AddLog("Is show tv: ", this._doc.ShowWebView.ToString(), null, null, null, null, XDebugColor.XDebug_None); bool flag12 = SystemInfo.processorType.StartsWith("Intel"); int num3 = int.Parse(XSingleton.singleton.GetValue("HideWebView")); bool flag13 = SystemInfo.systemMemorySize >= XSingleton.singleton.GetInt("WebMemory"); XSingleton.singleton.AddLog("memory: ", flag13.ToString(), " x86: ", flag12.ToString(), " hide: ", num3.ToString(), XDebugColor.XDebug_None); bool flag14 = this._doc.ShowWebView && num3 != 1 && !flag12 && flag13; ixuibutton.SetVisible(flag14); bool flag15 = flag14; if (flag15) { ixuibutton.gameObject.transform.localPosition = new Vector3((float)(num * num2), 0f); ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSysBtnClick)); num++; ixuibutton.ID = (ulong)((long)rowData.ID); } } else { bool flag16 = rowData.ID == 8 && (XSingleton.singleton.GetLaunchTypeServerInfo() != StartUpType.StartUp_QQ || XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ); if (!flag16) { bool flag17 = rowData.ID == 9 && (XSingleton.singleton.GetLaunchTypeServerInfo() != StartUpType.StartUp_WX || XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_WeChat); if (!flag17) { ixuibutton.SetVisible(true); ixuibutton.gameObject.transform.localPosition = new Vector3((float)(num * num2), 0f); ixuibutton.ID = (ulong)((long)rowData.ID); ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSysBtnClick)); num++; gameObject.SetActive(XSingleton.singleton.GetSysRedPointStateConsiderBlock((XSysDefine)rowData.SysID)); } } } } } } } } } this.m_Bg.spriteWidth = this._bgWidthDelta + num * num2; } private bool OnSysBtnClick(IXUIButton btn) { Dictionary dictionary = new Dictionary(); ulong id = btn.ID; ulong num = id - 1UL; if (num <= 15UL) { switch ((uint)num) { case 0u: { PtcC2G_CloseHintNtf ptcC2G_CloseHintNtf = new PtcC2G_CloseHintNtf(); ptcC2G_CloseHintNtf.Data.systemid = (uint)XFastEnumIntEqualityComparer.ToInt(XSysDefine.XSys_GC_XinYueVIP); XSingleton.singleton.Send(ptcC2G_CloseHintNtf); XSingleton.singleton.SetSysRedPointState(XSysDefine.XSys_GC_XinYueVIP, false); XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GameCommunity, true); GameObject gameObject = btn.gameObject.transform.Find("RedPoint").gameObject; gameObject.SetActive(false); string text = string.Format("{0}?game_id={1}&opencode={2}&partition_id={3}&role_id={4}", new object[] { XSingleton.singleton.GetValue("XinYueInternalURL"), XSingleton.singleton.GameId, XSingleton.singleton.OpenCode, XSingleton.singleton.ServerID, XSingleton.singleton.XPlayerData.RoleID }); XSingleton.singleton.AddLog("url = " + text, null, null, null, null, null, XDebugColor.XDebug_None); dictionary["url"] = text; dictionary["screendir"] = "SENSOR"; XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); break; } case 6u: XSingleton.singleton.OpenHtmlUrl("DeepLinkAddress"); break; case 7u: case 8u: DlgBase.singleton.SetVisibleWithAnimation(true, null); break; case 9u: { string text = string.Format("{0}?partition={1}&roleid={2}&area={3}&algorithm={4}&version={5}×tamp={6}&appid={7}&openid={8}&sig={9}&encode={10}", new object[] { XSingleton.singleton.GetValue("MicroCommunityURL"), XSingleton.singleton.ServerID, XSingleton.singleton.XPlayerData.RoleID, XSingleton.singleton.AreaId, "v2", XSingleton.singleton.Version, XSingleton.singleton.GetTimeStamp(), XSingleton.singleton.AppId, XSingleton.singleton.OpenID, XSingleton.singleton.XPlatform.GetMD5(string.Format("{0}{1}", XSingleton.singleton.MSDKKey, XSingleton.singleton.GetTimeStamp())), "2" }); XSingleton.singleton.AddLog("url = " + text, null, null, null, null, null, XDebugColor.XDebug_None); dictionary["url"] = text; dictionary["screendir"] = "SENSOR"; XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); break; } case 10u: XSingleton.singleton.OpenHtmlUrl("HordeInsideAddress"); break; case 11u: { PtcC2G_CancelRedDotReq ptcC2G_CancelRedDotReq = new PtcC2G_CancelRedDotReq(); ptcC2G_CancelRedDotReq.Data.systemid = (uint)XFastEnumIntEqualityComparer.ToInt(XSysDefine.XSys_Questionnaire); XSingleton.singleton.Send(ptcC2G_CancelRedDotReq); XSingleton.singleton.SetSysRedPointState(XSysDefine.XSys_Questionnaire, false); XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GameCommunity, true); GameObject gameObject2 = btn.gameObject.transform.Find("RedPoint").gameObject; gameObject2.SetActive(false); int questionnaireStage = this.GetQuestionnaireStage(); dictionary["url"] = XSingleton.singleton.GetValue(string.Format("QuestionnaireUrl{0}", questionnaireStage)); dictionary["screendir"] = "SENSOR"; XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); break; } case 12u: this.OnReplayClick(btn); break; case 13u: DlgBase.singleton.SetVisible(true, true); break; case 14u: { XSingleton.singleton.CloseSysAndNoticeServer((uint)XFastEnumIntEqualityComparer.ToInt(XSysDefine.XSys_GC_XiaoYueGuanJia)); btn.gameObject.transform.Find("RedPoint").gameObject.SetActive(false); string text2 = ((int)Application.platform == 11) ? "1" : "0"; string text = string.Format("{0}?game_id={1}&opencode={2}&sig={3}×tamp={4}&role_id={5}&partition_id={6}&plat_id={7}", new object[] { XSingleton.singleton.GetValue("XiaoYueUrl"), XSingleton.singleton.GetValue("XiaoYueGameID"), XSingleton.singleton.OpenCode, XSingleton.singleton.XPlatform.GetMD5(string.Format("{0}{1}", XSingleton.singleton.MSDKKey, XSingleton.singleton.GetTimeStamp())), XSingleton.singleton.GetTimeStamp(), XSingleton.singleton.GetRoleId(), XSingleton.singleton.ServerID, text2 }); XSingleton.singleton.AddLog("url = " + text, null, null, null, null, null, XDebugColor.XDebug_None); dictionary["url"] = text; dictionary["screendir"] = "SENSOR"; XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); break; } case 15u: XSingleton.singleton.OpenHtmlUrl("LibaozhongxinUrl"); break; } } return true; } private bool LoginStateTrue(GameCommunityTable.RowData data) { bool flag = (int)Application.platform == 7 || Application.platform == 0; bool result; if (flag) { result = true; } else { switch (XSingleton.singleton.Channel) { case XAuthorizationChannel.XAuthorization_QQ: result = data.QQ; break; case XAuthorizationChannel.XAuthorization_WeChat: result = data.WX; break; case XAuthorizationChannel.XAuthorization_Guest: result = data.YK; break; default: result = false; break; } } return result; } public bool IsSuportReplay() { bool flag = (int)Application.platform == 8; return flag && !this.isIpadMode() && XSingleton.singleton.XPlatform.CheckStatus("is_screen_record_available", ""); } private bool isIpadMode() { return false; } private bool OnReplayClick(IXUIButton btn) { bool flag = DlgBase.singleton.isPlaying || DlgBase.singleton.isReadyPlaying; if (flag) { XSingleton.singleton.AddLog("Close Replay..", null, null, null, null, null, XDebugColor.XDebug_None); DlgBase.singleton.OnStopClick(null); } else { bool isBroadcast = DlgBase.singleton.isBroadcast; if (isBroadcast) { XSingleton.singleton.AddLog("replay isBroadcasting", null, null, null, null, null, XDebugColor.XDebug_None); XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("Replay_IsBroadcasting"), "fece00"); } else { bool flag2 = XSingleton.singleton.XPlatform.CheckStatus("is_broadcasting", ""); XSingleton.singleton.AddLog("open: ", flag2.ToString(), null, null, null, null, XDebugColor.XDebug_None); bool flag3 = !flag2; if (flag3) { DlgBase.singleton.OpenRepaly(); } else { bool flag4 = (int) Application.platform == 7; if (flag4) { DlgBase.singleton.Show(true); } } } } return true; } private int GetQuestionnaireStage() { uint level = XSingleton.singleton.XPlayerData.Level; SeqList sequenceList = XSingleton.singleton.GetSequenceList("QuestionnaireLevel", true); for (int i = 0; i < (int)sequenceList.Count; i++) { bool flag = (ulong)level >= (ulong)((long)sequenceList[i, 0]) && (ulong)level <= (ulong)((long)sequenceList[i, 1]); if (flag) { return i + 1; } } return 0; } } }