From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/UICommon/DlgBase.cs | 750 +++++++++++++++++++++ .../XMainClient/UI/UICommon/DlgBase.cs.meta | 12 + .../XMainClient/UI/UICommon/DlgBehaviourBase.cs | 130 ++++ .../UI/UICommon/DlgBehaviourBase.cs.meta | 12 + .../XMainClient/UI/UICommon/TabHandleBase.cs | 60 ++ .../XMainClient/UI/UICommon/TabHandleBase.cs.meta | 12 + .../Scripts/XMainClient/UI/UICommon/UIManager.cs | 586 ++++++++++++++++ .../XMainClient/UI/UICommon/UIManager.cs.meta | 12 + .../XMainClient/UI/UICommon/VirtualJoystick.cs | 139 ++++ .../UI/UICommon/VirtualJoystick.cs.meta | 12 + 10 files changed, 1725 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs.meta (limited to 'Client/Assets/Scripts/XMainClient/UI/UICommon') diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs new file mode 100644 index 00000000..234b0f2c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs @@ -0,0 +1,750 @@ +using System; +using UILib; +using UnityEngine; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient.UI.UICommon +{ + public abstract class DlgBase : IXUIDlg, IDlgHandlerMgr where TDlgClass : IXUIDlg, new() where TUIBehaviour : DlgBehaviourBase + { + public static TDlgClass singleton + { + get + { + bool flag = DlgBase.s_instance == null; + if (flag) + { + object obj = DlgBase.s_objLock; + lock (obj) + { + bool flag2 = DlgBase.s_instance == null; + if (flag2) + { + DlgBase.s_instance = Activator.CreateInstance(); + } + } + } + return DlgBase.s_instance; + } + } + + public IXUIBehaviour uiBehaviourInterface + { + get + { + return this.m_uiBehaviour; + } + } + + public TUIBehaviour uiBehaviour + { + get + { + return this.m_uiBehaviour; + } + } + + public virtual string fileName + { + get + { + return ""; + } + } + + public string luaFileName + { + get + { + bool flag = this.fileName.Length > 1 && this.fileName.Contains("/"); + string result; + if (flag) + { + result = this.fileName.Substring(this.fileName.LastIndexOf('/') + 1); + } + else + { + result = this.fileName; + } + return result; + } + } + + public virtual int layer + { + get + { + return 2; + } + } + + public virtual int group + { + get + { + return 0; + } + } + + public virtual bool exclusive + { + get + { + return false; + } + } + + public virtual bool autoload + { + get + { + return false; + } + } + + public virtual bool isHideChat + { + get + { + return true; + } + } + + public virtual bool hideMainMenu + { + get + { + return false; + } + } + + public virtual bool pushstack + { + get + { + return false; + } + } + + public virtual bool isMainUI + { + get + { + return false; + } + } + + public virtual bool isHideTutorial + { + get + { + return false; + } + } + + public virtual int sysid + { + get + { + return 0; + } + } + + public virtual bool fullscreenui + { + get + { + return false; + } + } + + public bool Prepared + { + get + { + return null != this.m_uiBehaviour; + } + } + + public virtual bool isPopup + { + get + { + return false; + } + } + + public virtual bool needOnTop + { + get + { + return false; + } + } + + public DlgHandlerMgr HandlerMgr + { + get + { + return this.m_DlgHandlerMgr; + } + } + + private LoadUIFinishedEventHandler _loadUICb = null; + + protected int m_dummPool = -1; + + private IXNGUICallback panelCB = null; + + protected TUIBehaviour m_uiBehaviour = default(TUIBehaviour); + + private static TDlgClass s_instance = default(TDlgClass); + + private static object s_objLock = new object(); + + private bool m_bVisible = false; + + protected bool m_bLoaded = false; + + private float m_fDepthZ = 0f; + + private bool m_bBindedReverse = false; + + private Transform m_DlgController = null; + + private bool m_bCacheVisible = false; + + private DlgBase.OnAnimationOver m_animationOver; + + private IXUIDlg m_RelatedDlg; + + private DlgHandlerMgr m_DlgHandlerMgr = new DlgHandlerMgr(); + + public delegate void OnAnimationOver(); + + public DlgBase() + { + this._loadUICb = new LoadUIFinishedEventHandler(this.OnLoadUIFinishedEventHandler); + } + + public virtual void OnUpdate() + { + this.HandlerMgr.OnUpdate(); + } + + public virtual void OnPostUpdate() + { + } + + public void SetVisiblePure(bool bVisible) + { + bool flag = !this.m_bLoaded && this.autoload; + if (flag) + { + this.Load(); + } + else + { + bool flag2 = !this.m_bLoaded && !this.autoload; + if (flag2) + { + return; + } + } + this.uiBehaviour.SetVisible(bVisible); + this.m_bVisible = bVisible; + this.OnSetVisiblePure(bVisible); + bool flag3 = this.m_RelatedDlg != null; + if (flag3) + { + this.m_RelatedDlg.SetRelatedVisible(this.m_bVisible); + } + } + + public virtual void SetVisible(bool bIsVisible, bool bEnableAuto = true) + { + bool bLoaded = this.m_bLoaded; + if (!bLoaded) + { + bool flag = this.autoload && bEnableAuto; + if (!flag) + { + return; + } + this.Load(); + } + bool flag2 = bIsVisible && !this._CanShow(); + if (!flag2) + { + bool prepared = this.Prepared; + if (prepared) + { + bool flag3 = this.m_bVisible != bIsVisible; + if (flag3) + { + this.uiBehaviour.SetVisible(bIsVisible); + this.m_bVisible = bIsVisible; + if (bIsVisible) + { + XSingleton.singleton.OnDlgShow(DlgBase.s_instance); + ILuaEngine xluaEngine = XSingleton.singleton.XLuaEngine; + bool flag4 = !xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.BEFORE, this.luaFileName, this.uiBehaviour.gameObject); + if (flag4) + { + this.OnShow(); + xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.AFTER, this.luaFileName, this.uiBehaviour.gameObject); + } + bool flag5 = this.fullscreenui && XSingleton.singleton.GameCamera != null && XSingleton.singleton.GameCamera.UnityCamera != null; + if (flag5) + { + XSingleton.singleton.GameCamera.UnityCamera.enabled = false; + } + } + else + { + this.OnHide(); + XSingleton.singleton.OnDlgHide(DlgBase.s_instance); + ILuaEngine xluaEngine2 = XSingleton.singleton.XLuaEngine; + xluaEngine2.hotfixMgr.TryFixRefresh(HotfixMode.HIDE, this.luaFileName, this.uiBehaviour.gameObject); + bool flag6 = XSingleton.singleton.GetFullScreenUICount() == 0 && XSingleton.singleton.GameCamera != null && XSingleton.singleton.GameCamera.UnityCamera != null; + if (flag6) + { + XSingleton.singleton.GameCamera.UnityCamera.enabled = true; + } + } + bool flag7 = this.m_RelatedDlg != null; + if (flag7) + { + this.m_RelatedDlg.SetVisible(this.m_bVisible, true); + } + } + } + } + } + + public virtual void SetVisibleWithAnimation(bool bVisible, DlgBase.OnAnimationOver AnimationOverDelegate) + { + bool flag = !this.m_bLoaded; + if (flag) + { + this.Load(); + } + bool flag2 = bVisible && !this._CanShow(); + if (!flag2) + { + int fullScreenUICount = XSingleton.singleton.GetFullScreenUICount(); + bool flag3 = (bVisible && fullScreenUICount > 0) || (!bVisible && ((this.fullscreenui && fullScreenUICount > 1) || (!this.fullscreenui && fullScreenUICount > 0))); + if (flag3) + { + this.SetVisible(bVisible, true); + bool flag4 = AnimationOverDelegate != null; + if (flag4) + { + AnimationOverDelegate(); + } + } + else + { + this.SetVisible(bVisible, true); + this.m_bCacheVisible = bVisible; + this.m_animationOver = AnimationOverDelegate; + bool flag5 = AnimationOverDelegate != null; + if (flag5) + { + AnimationOverDelegate(); + } + } + } + } + + protected void OnShowAnimationFinish(IXUITweenTool tween) + { + bool fullscreenui = this.fullscreenui; + if (fullscreenui) + { + XSingleton.singleton.GameCamera.UnityCamera.enabled = false; + } + } + + protected void OnCloseAnimationFinish(IXUITweenTool tween) + { + this.SetVisible(false, true); + bool flag = this.m_animationOver != null; + if (flag) + { + this.m_animationOver(); + } + } + + protected virtual void OnShow() + { + } + + protected virtual void OnHide() + { + } + + protected virtual void OnLoad() + { + } + + protected virtual void OnUnload() + { + this.UnRegisterEvent(); + } + + public bool IsVisible() + { + bool bLoaded = this.m_bLoaded; + return bLoaded && this.uiBehaviour.IsVisible(); + } + + public void SetDepthZ(int nDepthZ) + { + this.m_fDepthZ = (float)(nDepthZ * 10); + bool prepared = this.Prepared; + if (prepared) + { + Vector3 localPosition = this.uiBehaviour.transform.localPosition; + localPosition.z = this.m_fDepthZ; + this.uiBehaviour.transform.localPosition = localPosition; + } + } + + public virtual void Reset() + { + } + + public virtual void StackRefresh() + { + bool flag = this.HandlerMgr != null; + if (flag) + { + this.HandlerMgr.StackRefresh(); + } + } + + public virtual void LeaveStackTop() + { + bool flag = this.HandlerMgr != null; + if (flag) + { + this.HandlerMgr.LeaveStackTop(); + } + } + + protected virtual void OnSetVisiblePure(bool bShow) + { + } + + protected virtual void Init() + { + } + + private void InnerInit() + { + this.m_uiBehaviour.Init(); + Vector3 localPosition = this.uiBehaviour.transform.localPosition; + localPosition.z = this.m_fDepthZ; + this.uiBehaviour.transform.localPosition = localPosition; + this.m_DlgController = this.uiBehaviour.transform.Find("DlgController"); + } + + public void Load() + { + bool flag = !this.m_bLoaded; + if (flag) + { + this.m_bLoaded = true; + XSingleton.singleton.LoadUI(this.fileName, this._loadUICb); + XSingleton.singleton.AddDlg(DlgBase.s_instance); + this.OnLoad(); + } + } + + public bool IsLoaded() + { + return this.m_bLoaded; + } + + public void UnLoad(bool bTransfer = false) + { + bool bLoaded = this.m_bLoaded; + if (bLoaded) + { + if (bTransfer) + { + this.SetVisible(false, false); + } + else + { + ILuaEngine xluaEngine = XSingleton.singleton.XLuaEngine; + xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.UNLOAD, this.luaFileName, this.uiBehaviour.gameObject); + this.OnUnload(); + this.HandlerMgr.Unload(); + XSingleton.singleton.RemoveDlg(DlgBase.s_instance); + XSingleton.singleton.UnSafeDestroy(this.uiBehaviour.gameObject, false, true); + this.m_uiBehaviour = default(TUIBehaviour); + this.m_uiBehaviour = default(TUIBehaviour); + this.m_bLoaded = false; + bool flag = !XSingleton.singleton.switchScene; + if (flag) + { + bool flag2 = XSingleton.singleton.unloadUICount >= 10; + if (flag2) + { + Resources.UnloadUnusedAssets(); + XSingleton.singleton.unloadUICount = 0; + } + else + { + XSingleton.singleton.unloadUICount++; + } + } + } + } + } + + public void SetAlpha(float a) + { + IXUIPanel ixuipanel = this.uiBehaviour.gameObject.GetComponent("XUIPanel") as IXUIPanel; + bool flag = ixuipanel != null; + if (flag) + { + ixuipanel.SetAlpha(a); + } + } + + public float GetAlpha() + { + IXUIPanel ixuipanel = this.uiBehaviour.gameObject.GetComponent("XUIPanel") as IXUIPanel; + bool flag = ixuipanel != null; + float result; + if (flag) + { + result = ixuipanel.GetAlpha(); + } + else + { + result = 1f; + } + return result; + } + + public void RegCallBack() + { + this.panelCB = (this.uiBehaviour.gameObject.GetComponent("NGUIAssetCallBack") as IXNGUICallback); + bool flag = this.panelCB != null; + if (flag) + { + this.panelCB.RegisterClickEventHandler(new IXNGUIClickEventHandler(this.OnXNGUIClick)); + } + } + + public virtual void OnXNGUIClick(GameObject obj, string path) + { + XSingleton.singleton.AddLog(obj.name, " ", path, null, null, null, XDebugColor.XDebug_None); + } + + protected GameObject SetXUILable(string name, string content) + { + bool flag = this.uiBehaviour.transform == null; + GameObject result; + if (flag) + { + result = null; + } + else + { + bool flag2 = string.IsNullOrEmpty(content); + if (flag2) + { + content = string.Empty; + } + IXUILabel ixuilabel = this.uiBehaviour.transform.Find(name).GetComponent("XUILabel") as IXUILabel; + bool flag3 = ixuilabel == null; + if (flag3) + { + XSingleton.singleton.AddErrorLog("SetXUILable ", name, " ", content, null, null); + result = null; + } + else + { + ixuilabel.SetText(content); + result = ixuilabel.gameObject; + } + } + return result; + } + + private void OnLoadUIFinishedEventHandler(string location) + { + GameObject gameObject = XSingleton.singleton.CreateFromPrefab("UI/" + location, true, false) as GameObject; + bool flag = null != gameObject; + if (flag) + { + gameObject.transform.parent = XSingleton.singleton.UIRoot; + gameObject.transform.localPosition = new Vector3(0f, 0f, 0f); + gameObject.transform.localScale = new Vector3(1f, 1f, 1f); + this.m_uiBehaviour = gameObject.AddComponent(); + this.m_uiBehaviour.uiDlgInterface = this; + bool flag2 = !this.m_bBindedReverse; + if (flag2) + { + this.Init(); + this.InnerInit(); + this.RegisterEvent(); + this.RegCallBack(); + this.uiBehaviour.SetVisible(false); + this.m_bVisible = false; + } + } + } + + public bool BindReverse(IXUIBehaviour iXUIBehaviour) + { + TUIBehaviour tuibehaviour = iXUIBehaviour as TUIBehaviour; + bool flag = null == tuibehaviour; + bool result; + if (flag) + { + result = false; + } + else + { + this.m_bLoaded = true; + this.m_uiBehaviour = tuibehaviour; + this.m_uiBehaviour.uiDlgInterface = this; + this.RegisterEvent(); + this.InnerInit(); + this.Init(); + this.m_bBindedReverse = true; + result = true; + } + return result; + } + + public virtual void RegisterEvent() + { + } + + protected virtual void UnRegisterEvent() + { + } + + public virtual void SetRelatedDlg(IXUIDlg dlg) + { + this.m_RelatedDlg = dlg; + } + + protected virtual void OnRelatedShow() + { + } + + protected virtual void OnRelatedHide() + { + } + + public void SetRelatedVisible(bool bVisible) + { + bool bLoaded = this.m_bLoaded; + if (bLoaded) + { + this.SetVisiblePure(bVisible); + if (bVisible) + { + this.OnRelatedShow(); + } + else + { + this.OnRelatedHide(); + } + } + } + + private bool _CanShow() + { + bool flag = this.isPopup && XSingleton.singleton.InTutorial; + bool result; + if (flag) + { + this.OnPopupBlocked(); + result = false; + } + else + { + result = true; + } + return result; + } + + protected virtual void OnPopupBlocked() + { + } + + public virtual int[] GetTitanBarItems() + { + return null; + } + + protected void Alloc3DAvatarPool(string user) + { + bool flag = this.m_dummPool < 0; + if (flag) + { + this.m_dummPool = XSingleton.singleton.AllocDummyPool(user, 1); + } + } + + protected void Return3DAvatarPool() + { + XSingleton.singleton.ReturnDummyPool(this.m_dummPool); + this.m_dummPool = -1; + } + + public static Transform FindChildRecursively(string childName) + { + TDlgClass singleton = DlgBase.singleton; + TUIBehaviour tuibehaviour = singleton.uiBehaviourInterface as TUIBehaviour; + bool flag = !tuibehaviour.IsVisible(); + Transform result; + if (flag) + { + result = null; + } + else + { + Transform transform = XSingleton.singleton.FindChildRecursively(tuibehaviour.transform, childName); + result = transform; + } + return result; + } + + public static Vector3 GetChildWorldPos(string childName) + { + TDlgClass singleton = DlgBase.singleton; + TUIBehaviour tuibehaviour = singleton.uiBehaviourInterface as TUIBehaviour; + bool flag = !tuibehaviour.IsVisible(); + Vector3 result; + if (flag) + { + result = Vector3.zero; + } + else + { + Transform transform = XSingleton.singleton.FindChildRecursively(tuibehaviour.transform, childName); + bool flag2 = transform != null; + if (flag2) + { + result = transform.position; + } + else + { + result = Vector3.zero; + } + } + return result; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs.meta b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs.meta new file mode 100644 index 00000000..a0c60016 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b88aeb92feab8b24eaca74836f7b7ce3 +timeCreated: 1611404405 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs new file mode 100644 index 00000000..82af93d4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs @@ -0,0 +1,130 @@ +using System; +using UILib; +using UnityEngine; + +namespace XMainClient.UI.UICommon +{ + public class DlgBehaviourBase : MonoBehaviour, IXUIBehaviour, IXUIObject + { + public IXUIObject parent + { + get + { + return null; + } + set + { + } + } + + public ulong ID + { + get + { + return this.m_id; + } + set + { + this.m_id = value; + } + } + + public bool Exculsive + { + get + { + return this.m_bExculsive; + } + set + { + this.m_bExculsive = value; + } + } + + public IXUIDlg uiDlgInterface + { + get + { + return this.m_uiDlgInterface; + } + set + { + this.m_uiDlgInterface = value; + } + } + + public IXUIObject[] uiChilds + { + get + { + return this.m_uiChilds; + } + } + + private IXUIDlg m_uiDlgInterface = null; + + private IXUIObject[] m_uiChilds = null; + + private ulong m_id; + + private bool m_bExculsive = false; + + public bool IsVisible() + { + return base.gameObject.activeInHierarchy; + } + + public void SetVisible(bool bVisible) + { + base.gameObject.SetActive(bVisible); + } + + public IXUIObject GetUIObject(string strName) + { + Transform transform = base.transform.Find(strName); + bool flag = null != transform; + IXUIObject result; + if (flag) + { + result = transform.GetComponent(); + } + else + { + result = null; + } + return result; + } + + public void OnPress() + { + this.OnFocus(); + } + + public void OnFocus() + { + } + + public virtual void Init() + { + IXUIObject[] componentsInChildren = base.GetComponentsInChildren(); + this.m_uiChilds = componentsInChildren; + for (int i = 0; i < this.m_uiChilds.Length; i++) + { + XUIObjectBase xuiobjectBase = this.m_uiChilds[i] as XUIObjectBase; + xuiobjectBase.Init(); + } + } + + public virtual void Highlight(bool bTrue) + { + } + + GameObject IXUIObject.gameObject + { + get + { + return base.gameObject; + } + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs.meta b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs.meta new file mode 100644 index 00000000..e0064525 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/DlgBehaviourBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 093a7d627ed1d7245be463c2fa874487 +timeCreated: 1611403150 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs new file mode 100644 index 00000000..9877b620 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; + +namespace XMainClient.UI.UICommon +{ + internal class TabHandleBase : DlgBase, IDlgHandlerMgr where T : IXUIDlg, new() where V : DlgBehaviourBase + { + private Dictionary m_handles = new Dictionary(); + + protected XSysDefine m_select; + + public virtual void RefreshData() + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(this.m_select, out dlgHandlerBase) && dlgHandlerBase.IsVisible(); + if (flag) + { + dlgHandlerBase.RefreshData(); + } + } + + protected void SetHandleVisible(XSysDefine define, bool isVisible) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + dlgHandlerBase.SetVisible(isVisible); + if (isVisible) + { + this.m_select = define; + } + } + } + + protected void RegisterHandler(XSysDefine define, GameObject g, bool show = false) where C : DlgHandlerBase, new() + { + bool flag = !this.m_handles.ContainsKey(define); + if (flag) + { + C c = default(C); + c = DlgHandlerBase.EnsureCreate(ref c, g, this, false); + this.m_handles.Add(define, c); + } + } + + protected void RemoveHandler(XSysDefine define) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + DlgHandlerBase.EnsureUnload(ref dlgHandlerBase); + this.m_handles.Remove(define); + } + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs.meta b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs.meta new file mode 100644 index 00000000..fc6bb5f0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e4570d8459fc126439209e57f1539a48 +timeCreated: 1611404737 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs new file mode 100644 index 00000000..0daba0f9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs @@ -0,0 +1,586 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UILib; +using UnityEngine; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient.UI.UICommon +{ + internal class UIManager : XSingleton + { + public Transform UIRoot + { + get + { + return this.m_uiRoot; + } + set + { + this.m_uiRoot = value; + } + } + + private Dictionary m_dicDlgs = new Dictionary(); + + private Dictionary> m_dicUILayer = new Dictionary>(); + + private List m_iterDlgs = new List(); + + private Transform m_uiRoot = null; + + private Dictionary m_GroupDlg = new Dictionary(); + + private List m_ShowedDlg = new List(); + + private int m_TutorialClashUICount = 0; + + private List m_ToBeUnloadDlg = new List(); + + private XLFU m_LFU = new XLFU(5); + + private List m_CachedExculsiveUI = new List(); + + private Stack m_ShowUIStack = new Stack(); + + private List m_StoreUIList = new List(); + + private List m_AvatarStack = new List(); + + public int unloadUICount = 0; + + public void OnEnterScene() + { + this.m_LFU.Clear(); + this.m_ShowedDlg.Clear(); + this.m_TutorialClashUICount = 0; + this.m_CachedExculsiveUI.Clear(); + this.m_ShowUIStack.Clear(); + this.m_ToBeUnloadDlg.Clear(); + this.m_StoreUIList.Clear(); + this.unloadUICount = 0; + } + + public void OnLeaveScene(bool transfer) + { + for (int i = this.m_iterDlgs.Count - 1; i >= 0; i--) + { + bool flag = i < this.m_iterDlgs.Count && this.m_iterDlgs[i] != null; + if (flag) + { + this.m_iterDlgs[i].UnLoad(transfer); + } + } + this.m_AvatarStack.Clear(); + this.unloadUICount = 0; + } + + public override bool Init() + { + RuntimePlatform platform = Application.platform; + int @int; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + @int = XSingleton.singleton.GetInt("UIUnloadLFUSizeDefault"); + } + else + { + @int = XSingleton.singleton.GetInt("UIUnloadLFUSizeAndroid"); + } + } + else + { + @int = XSingleton.singleton.GetInt("UIUnloadLFUSizeIPhone"); + } + this.m_LFU = new XLFU(@int); + return true; + } + + public override void Uninit() + { + } + + public void LoadUI(string strUIFile, LoadUIFinishedEventHandler eventHandler) + { + bool flag = eventHandler != null; + if (flag) + { + eventHandler(strUIFile); + } + } + + public void Update(float fDeltaT) + { + int i = 0; + while (i < this.m_iterDlgs.Count) + { + IXUIDlg ixuidlg = this.m_iterDlgs[i]; + bool flag = ixuidlg != null; + if (flag) + { + bool flag2 = ixuidlg.uiBehaviourInterface == null || ixuidlg.uiBehaviourInterface.gameObject == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("UI missing: ", ixuidlg.fileName, null, null, null, null); + } + else + { + bool activeInHierarchy = ixuidlg.uiBehaviourInterface.gameObject.activeInHierarchy; + if (activeInHierarchy) + { + ixuidlg.OnUpdate(); + } + } + } + IL_78: + i++; + continue; + goto IL_78; + } + } + + public void PostUpdate(float fDeltaT) + { + for (int i = 0; i < this.m_iterDlgs.Count; i++) + { + bool flag = this.m_iterDlgs[i] != null; + if (flag) + { + this.m_iterDlgs[i].OnPostUpdate(); + } + } + bool flag2 = this.m_ToBeUnloadDlg.Count > 0; + if (flag2) + { + for (int j = 0; j < this.m_ToBeUnloadDlg.Count; j++) + { + this.m_ToBeUnloadDlg[j].UnLoad(false); + } + this.m_ToBeUnloadDlg.Clear(); + } + } + + public bool IsUIShowed() + { + bool flag = this.m_ShowUIStack.Count > 0; + bool result; + if (flag) + { + result = true; + } + else + { + bool flag2 = DlgBase.singleton.IsLoaded() && DlgBase.singleton.IsVisible(); + if (flag2) + { + result = true; + } + else + { + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + result = true; + } + else + { + bool flag4 = XSingleton.singleton.XLuaEngine.luaUIManager.IsUIShowed(); + result = flag4; + } + } + } + return result; + } + + public bool IsHideTutorial() + { + return this.m_TutorialClashUICount != 0; + } + + public int GetUIStackCount() + { + return this.m_ShowUIStack.Count; + } + + public int GetFullScreenUICount() + { + int num = 0; + foreach (IXUIDlg ixuidlg in this.m_ShowUIStack) + { + bool fullscreenui = ixuidlg.fullscreenui; + if (fullscreenui) + { + num++; + } + } + return num; + } + + public void RemoveDlg(IXUIDlg dlg) + { + List list = null; + bool flag = this.m_dicUILayer.TryGetValue(dlg.layer, out list); + if (flag) + { + list.Remove(dlg); + } + bool flag2 = this.m_dicDlgs.ContainsKey(dlg.fileName); + if (flag2) + { + this.m_dicDlgs.Remove(dlg.fileName); + this.m_iterDlgs.Remove(dlg); + } + bool flag3 = this.m_GroupDlg.ContainsKey(dlg.group); + if (flag3) + { + this.m_GroupDlg.Remove(dlg.group); + } + bool flag4 = this.m_ShowedDlg.Contains(dlg); + if (flag4) + { + bool isHideTutorial = dlg.isHideTutorial; + if (isHideTutorial) + { + this.ChangeTutorialClashUI(false); + } + this.m_ShowedDlg.Remove(dlg); + } + this.m_LFU.Remove(dlg); + this.m_AvatarStack.Remove(dlg); + } + + public bool AddDlg(IXUIDlg dlg) + { + bool flag = this.m_dicDlgs.ContainsKey(dlg.fileName); + bool result; + if (flag) + { + XSingleton.singleton.AddLog("true == m_dicDlgs.ContainsKey(dlg.fileName): ", dlg.fileName, null, null, null, null, XDebugColor.XDebug_None); + result = false; + } + else + { + this.m_dicDlgs.Add(dlg.fileName, dlg); + this.m_iterDlgs.Add(dlg); + List list = null; + bool flag2 = this.m_dicUILayer.TryGetValue(dlg.layer, out list); + if (flag2) + { + list.Add(dlg); + } + else + { + list = new List(); + list.Add(dlg); + this.m_dicUILayer.Add(dlg.layer, list); + } + result = true; + } + return result; + } + + protected void CacheExclusiveUI() + { + this.m_CachedExculsiveUI.Clear(); + for (int i = 0; i < this.m_ShowedDlg.Count; i++) + { + this.m_CachedExculsiveUI.Add(this.m_ShowedDlg[i]); + } + } + + public void CloseAllUI() + { + this.ClearUIinStack(); + List list = new List(); + for (int i = 0; i < this.m_ShowedDlg.Count; i++) + { + bool flag = !this.m_ShowedDlg[i].isMainUI; + if (flag) + { + list.Add(this.m_ShowedDlg[i]); + } + } + for (int j = 0; j < list.Count; j++) + { + list[j].SetVisible(false, true); + } + } + + public void OnDlgShow(IXUIDlg dlg) + { + bool exclusive = dlg.exclusive; + if (exclusive) + { + this.CloseAllUI(); + this.CacheExclusiveUI(); + for (int i = 0; i < this.m_CachedExculsiveUI.Count; i++) + { + this.m_CachedExculsiveUI[i].uiBehaviourInterface.uiDlgInterface.SetVisiblePure(false); + } + this.ChangeTutorialClashUI(true); + } + else + { + bool flag = !this.m_ShowedDlg.Contains(dlg); + if (flag) + { + this.m_ShowedDlg.Add(dlg); + bool isHideTutorial = dlg.isHideTutorial; + if (isHideTutorial) + { + this.ChangeTutorialClashUI(true); + } + } + bool flag2 = !dlg.needOnTop; + if (flag2) + { + this.m_AvatarStack.Remove(dlg); + this.m_AvatarStack.Add(dlg); + } + else + { + Vector3 localPosition = dlg.uiBehaviourInterface.gameObject.transform.localPosition; + localPosition.z = 0f; + dlg.uiBehaviourInterface.gameObject.transform.localPosition = localPosition; + } + float num = 0f; + for (int j = this.m_AvatarStack.Count - 1; j >= 0; j--) + { + IXUIDlg ixuidlg = this.m_AvatarStack[j]; + Vector3 localPosition2 = ixuidlg.uiBehaviourInterface.gameObject.transform.localPosition; + localPosition2.z = num; + ixuidlg.uiBehaviourInterface.gameObject.transform.localPosition = localPosition2; + num += 800f; + } + } + bool pushstack = dlg.pushstack; + if (pushstack) + { + IXUIDlg ixuidlg2 = this.m_LFU.Add(dlg); + bool flag3 = ixuidlg2 != null; + if (flag3) + { + this.m_ToBeUnloadDlg.Add(ixuidlg2); + XSingleton.singleton.AddGreenLog("Auto Unload UI: ", ixuidlg2.fileName, " while opening ", dlg.fileName, null, null); + } + XSingleton.singleton.Cancel(); + } + bool hideMainMenu = dlg.hideMainMenu; + if (hideMainMenu) + { + this.UIBlurEffect(true); + } + bool pushstack2 = dlg.pushstack; + if (pushstack2) + { + XMainInterfaceDocument specificDocument = XDocuments.GetSpecificDocument(XMainInterfaceDocument.uuID); + bool flag4 = this.m_ShowUIStack.Count > 0; + if (flag4) + { + IXUIDlg ixuidlg3 = this.m_ShowUIStack.Peek(); + ixuidlg3.LeaveStackTop(); + ixuidlg3.uiBehaviourInterface.uiDlgInterface.SetVisiblePure(false); + Stack stack = new Stack(); + IXUIDlg ixuidlg4 = this.m_ShowUIStack.Pop(); + while (ixuidlg4 != dlg && this.m_ShowUIStack.Count > 0) + { + stack.Push(ixuidlg4); + ixuidlg4 = this.m_ShowUIStack.Pop(); + } + bool flag5 = ixuidlg4 != dlg; + if (flag5) + { + this.m_ShowUIStack.Push(ixuidlg4); + } + while (stack.Count > 0) + { + this.m_ShowUIStack.Push(stack.Pop()); + } + } + this.m_ShowUIStack.Push(dlg); + specificDocument.OnTopUIRefreshed(dlg); + } + DlgBase.singleton.TryCloseChat(dlg); + } + + public void UIBlurEffect(bool bOn) + { + bool flag = DlgBase.singleton.IsLoaded(); + if (flag) + { + DlgBase.singleton.FakeShowSelf(!bOn); + } + } + + public void OnDlgHide(IXUIDlg dlg) + { + bool exclusive = dlg.exclusive; + if (exclusive) + { + for (int i = 0; i < this.m_CachedExculsiveUI.Count; i++) + { + this.m_CachedExculsiveUI[i].uiBehaviourInterface.uiDlgInterface.SetVisiblePure(true); + } + this.ChangeTutorialClashUI(false); + } + else + { + this.m_ShowedDlg.Remove(dlg); + bool isHideTutorial = dlg.isHideTutorial; + if (isHideTutorial) + { + this.ChangeTutorialClashUI(false); + } + this.m_AvatarStack.Remove(dlg); + } + bool pushstack = dlg.pushstack; + if (pushstack) + { + this.m_LFU.MarkCanPop(dlg, true); + } + bool hideMainMenu = dlg.hideMainMenu; + if (hideMainMenu) + { + this.UIBlurEffect(false); + } + bool flag = dlg.pushstack && this.m_ShowUIStack.Count > 0; + if (flag) + { + IXUIDlg ixuidlg = this.m_ShowUIStack.Peek(); + bool flag2 = ixuidlg != dlg; + if (flag2) + { + XSingleton.singleton.AddLog("Not hide top of ui stack!:", dlg.fileName, null, null, null, null, XDebugColor.XDebug_None); + Stack stack = new Stack(); + for (IXUIDlg ixuidlg2 = this.m_ShowUIStack.Pop(); ixuidlg2 != dlg; ixuidlg2 = this.m_ShowUIStack.Pop()) + { + stack.Push(ixuidlg2); + bool flag3 = this.m_ShowUIStack.Count == 0; + if (flag3) + { + StringBuilder sharedStringBuilder = XSingleton.singleton.GetSharedStringBuilder(); + sharedStringBuilder.Length = 0; + sharedStringBuilder.Append("Hide UI not in stack!!!! : ").Append(dlg.fileName); + sharedStringBuilder.Append("; UIs in stack: "); + foreach (IXUIDlg ixuidlg3 in stack) + { + sharedStringBuilder.Append(ixuidlg3.fileName).Append(" "); + } + XSingleton.singleton.AddErrorLog(sharedStringBuilder.ToString(), null, null, null, null, null); + break; + } + } + while (stack.Count > 0) + { + this.m_ShowUIStack.Push(stack.Pop()); + } + bool flag4 = this.m_ShowUIStack.Count > 0; + if (flag4) + { + IXUIDlg ixuidlg4 = this.m_ShowUIStack.Peek(); + bool hideMainMenu2 = ixuidlg4.hideMainMenu; + if (hideMainMenu2) + { + this.UIBlurEffect(true); + } + } + } + else + { + this.m_ShowUIStack.Pop(); + XMainInterfaceDocument specificDocument = XDocuments.GetSpecificDocument(XMainInterfaceDocument.uuID); + bool flag5 = this.m_ShowUIStack.Count > 0; + if (flag5) + { + IXUIDlg ixuidlg5 = this.m_ShowUIStack.Peek(); + ixuidlg5.uiBehaviourInterface.uiDlgInterface.SetVisiblePure(true); + ixuidlg5.StackRefresh(); + specificDocument.OnTopUIRefreshed(ixuidlg5); + bool hideMainMenu3 = ixuidlg5.hideMainMenu; + if (hideMainMenu3) + { + this.UIBlurEffect(true); + } + } + else + { + specificDocument.OnTopUIRefreshed(null); + } + } + } + } + + public List GetShowedUI() + { + return this.m_ShowedDlg; + } + + public void ClearUIinStack() + { + while (this.m_ShowUIStack.Count > 0) + { + IXUIDlg ixuidlg = this.m_ShowUIStack.Peek(); + bool flag = ixuidlg != null; + if (flag) + { + ixuidlg.SetVisiblePure(true); + ixuidlg.SetVisible(false, true); + } + } + this.UIBlurEffect(false); + } + + public void HideAllUIWithOutCall() + { + for (int i = 0; i < this.m_ShowedDlg.Count; i++) + { + bool flag = this.m_ShowedDlg[i] == DlgBase.singleton || this.m_ShowedDlg[i] == DlgBase.singleton || this.m_ShowedDlg[i] == DlgBase.singleton; + if (!flag) + { + bool flag2 = this.m_ShowedDlg[i].IsVisible(); + if (flag2) + { + this.m_StoreUIList.Add(this.m_ShowedDlg[i]); + this.m_ShowedDlg[i].SetVisiblePure(false); + } + } + } + } + + public void RestoreAllUIWithOutCall() + { + for (int i = 0; i < this.m_StoreUIList.Count; i++) + { + bool flag = this.m_StoreUIList[i] != null; + if (flag) + { + this.m_StoreUIList[i].SetVisiblePure(true); + } + } + this.m_StoreUIList.Clear(); + } + + private void ChangeTutorialClashUI(bool isAdd) + { + if (isAdd) + { + this.m_TutorialClashUICount++; + XSingleton.singleton.AddGreenLog("TutorialClashUICount++:" + this.m_TutorialClashUICount, null, null, null, null, null); + } + else + { + this.m_TutorialClashUICount--; + XSingleton.singleton.AddGreenLog("TutorialClashUICount--:" + this.m_TutorialClashUICount, null, null, null, null, null); + bool flag = this.m_TutorialClashUICount < 0; + if (flag) + { + this.m_TutorialClashUICount = 0; + XSingleton.singleton.AddErrorLog("TutorialClashUICount Error", null, null, null, null, null); + } + } + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs.meta b/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs.meta new file mode 100644 index 00000000..479bd1c0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/UIManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0fd49ef83c692c14989b481f9d306410 +timeCreated: 1611403214 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs new file mode 100644 index 00000000..679b3431 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs @@ -0,0 +1,139 @@ +using System; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient.UI.UICommon +{ + internal class VirtualJoystick : DlgBase + { + public override string fileName + { + get + { + return "Common/VirtualJoyStick"; + } + } + + public override int layer + { + get + { + return 1; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + private bool _bLogicalVisible; + + protected override void Init() + { + this.Hide(); + } + + protected void Hide() + { + bool flag = !base.IsLoaded(); + if (!flag) + { + base.uiBehaviour.m_Panel.gameObject.transform.localPosition = new Vector3((float)XGameUI._far_far_away, (float)XGameUI._far_far_away, 0f); + this._bLogicalVisible = false; + } + } + + public void ShowPanel(bool bShow, Vector2 screenPos = default(Vector2)) + { + Debug.Log("screenPos=" + screenPos); + if (bShow) + { + bool flag = !base.IsVisible(); + if (flag) + { + this.SetVisible(true, true); + } + Vector3 vector = XSingleton.singleton.UICamera.ScreenToWorldPoint(screenPos); + Vector3 vec = this.m_uiBehaviour.transform.InverseTransformPoint(vector); + Vector3 finalPos = /*this.LimitPosition(*/vec/*)*/; + Debug.Log("Virtual Joystick Pos = " + finalPos); + base.uiBehaviour.m_Panel.gameObject.transform.localPosition = finalPos; + bool flag2 = !this._bLogicalVisible; + if (flag2) + { + IXUITweenTool ixuitweenTool = base.uiBehaviour.m_Direction.GetComponent("XUIPlayTween") as IXUITweenTool; + ixuitweenTool.PlayTween(true, -1f); + } + this._bLogicalVisible = true; + } + else + { + this.Hide(); + } + } + + public void SetJoystickPos(float radius, float angle) + { + float num = this.GetPanelRadius() + this.GetJoystickRadius(); + float num2 = (radius > num) ? num : radius; + float num3 = angle / 180f * 3.14159274f; + float num4 = Mathf.Cos(num3) * num2; + float num5 = -Mathf.Sin(num3) * num2; + base.uiBehaviour.m_Direction.gameObject.transform.localPosition = new Vector3(num4, num5, 0f); + } + + public float GetPanelRadius() + { + bool flag = !this.m_bLoaded && this.autoload; + if (flag) + { + base.Load(); + } + return (float)(base.uiBehaviour.m_Panel.spriteWidth / 2); + } + + public float GetJoystickRadius() + { + bool flag = !this.m_bLoaded && this.autoload; + if (flag) + { + base.Load(); + } + return (float)(base.uiBehaviour.m_Joystick.spriteWidth / 2 - 15); + } + + protected Vector3 LimitPosition(Vector3 vec) + { + Vector3 result = vec; + int base_UI_Width = XSingleton.singleton.Base_UI_Width; + int base_UI_Height = XSingleton.singleton.Base_UI_Height; + float num = this.GetPanelRadius() + this.GetJoystickRadius() * 2f; + bool flag = vec.x - num < (float)(-(float)base_UI_Width / 2); + if (flag) + { + result.x = (float)(-(float)base_UI_Width / 2) + num; + } + bool flag2 = vec.x + num > (float)(base_UI_Width / 2); + if (flag2) + { + result.x = (float)(base_UI_Width / 2) - num; + } + bool flag3 = vec.y + num > (float)(base_UI_Height / 2); + if (flag3) + { + result.y = (float)(base_UI_Height / 2) - num; + } + bool flag4 = vec.y - num < (float)(-(float)base_UI_Height / 2); + if (flag4) + { + result.y = (float)(-(float)base_UI_Height / 2) + num; + } + return result; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs.meta b/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs.meta new file mode 100644 index 00000000..66e596b5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/VirtualJoystick.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0731ce81c4a25cd40b1d3e2bca49bf54 +timeCreated: 1611402967 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0