Example #1
0
 private void ClearByTime(object sender, EventArgs e)
 {
     if (disposing)
     {
         return;
     }
     for (int i = 0; i < uis.Length; i++)
     {
         CGameUI ui = uis[i];
         if (null == ui)
         {
             continue;
         }
         if (ui.dontDestoryOnLoad)
         {
             continue;
         }
         if (ui.IsShow() || GameTimer.Within(ui.showTime, DISPOS_TIME) || ui.Layer == CUILayer.Free) //|| ui.IsMainFace
         {
             continue;
         }
         Remove(ui);
         ui.Dispose();
     }
 }
Example #2
0
        public CDialogueSystem()
        {
            _currentStatements = new Queue <CDialogueStatement>();

            _dialogueWindow = CGameUI.Instance().DialogueWindow;
            _dialogueWindow.Initialize(nextStatementCallback);
        }
Example #3
0
    public void Remove(CGameUI ui)
    {
        if (!ui || ui.disposed)
        {
            return;
        }
        if (ui.index < 0)
        {
            return;
        }
        uis[ui.index] = null;
        ui.Close();
        names.Remove(ui.Name);
        index_pool.Free(ui.index);
        ui.index = -1;

        if (loading.ContainsKey(ui.Name))
        {
            CGameUIAsset asset = loading[ui.Name] as CGameUIAsset;
            CClientCommon.DestroyImmediate(ref asset);
            loading.Remove(ui.Name);
        }
        ui.Dispose();
        ui = null;
    }
Example #4
0
    public static void CreateSprite(this CUIBehaviour self, CImage sprite, string spname, string spritename)
    {
        CGameUI root = self.GetRoot <CGameUI>();

        if (root == null)
        {
            return;
        }
        root.CreateSprite(sprite, spname, spritename);
    }
Example #5
0
    public static void CreateImage(this CUIBehaviour self, RawImage texture, string name)
    {
        CGameUI root = self.GetRoot <CGameUI>();

        if (root == null)
        {
            return;
        }
        root.CreateImage(texture, name);
    }
Example #6
0
    public static CEffectObject CreateEffect(this CUIBehaviour self, string filename, Transform parent, Vector3 position, Vector3 scale, Vector3 euler_angle)
    {
        CGameUI root = self.GetRoot <CGameUI>();

        if (root == null)
        {
            return(null);
        }
        return(root.CreateEffect(filename, parent, position, scale, euler_angle));
    }
Example #7
0
    // Start is called before the first frame update
    private void Awake()
    {
        if (_instance != null)
        {
            Destroy(this);
            return;
        }

        _instance = this;

        if (!_isInitialized)
        {
            initialize();
        }
    }
        private static IntPtr CGameUI__ConstructorHook(CGameUI @this)
        {
            var result = CGameUI__Constructor(@this);

            try
            {
                InternalInterface.GameUI = @this.AsUnsafe();
            }
            catch (Exception e)
            {
                Trace.WriteLine("Unhandled Exception in InternalInterface.CGameUI__ConstructorHook!");
                Trace.WriteLine(e.ToString());
            }

            return(result);
        }
Example #9
0
    public static CGameUI Instance()
    {
        if (_instance == null)
        {
            _instance = FindObjectOfType <CGameUI>();
            if (_instance == null)
            {
                _instance = new GameObject().AddComponent <CGameUI>();
            }
        }

        if (!_instance._isInitialized)
        {
            _instance.initialize();
        }

        return(_instance);
    }
Example #10
0
 public void CloseActiveUIs(CGameUI other)
 {
     if (other.Layer == CUILayer.FullWindow)
     {
         for (int i = 0; i < uis.Length; i++)
         {
             CGameUI ui = uis[i];
             if (null == ui || !ui.IsShow() || other == ui)
             {
                 continue;
             }
             if (other.Layer >= ui.Layer)
             {
                 other.AddCloseUI(ui);
             }
         }
     }
 }
Example #11
0
        private static IntPtr CGameUI__DisplayChatMessageHook(CGameUI _this, Int32 sender, String message, ChatRecipients recipients, Single duration)
        {
            try
            {
                InternalInput.OnPlayerChat(sender, message, recipients);

                if (InternalInput.BlockChat)
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Unhandled Exception in InternalInput.CGameUI__DisplayChatMessageHook!");
                Trace.WriteLine(e.ToString());
            }

            return(CGameUI__DisplayChatMessage(_this, sender, message, recipients, duration));
        }
Example #12
0
 public virtual void Close()
 {
     if (UIClose())
     {
         foreach (var kvp in ClosedDic)
         {
             string  ui_name = Global.ui_mgr.GetNameByType(kvp.Key);
             CGameUI ui      = Global.ui_mgr.Get(ui_name);
             if (ui)
             {
                 ui.UIShow();
             }
             else if (kvp.Value)
             {
                 Global.ui_mgr.LoadUI(kvp.Key);
             }
         }
         ClosedDic.Clear();
     }
 }
Example #13
0
    public void LoadUI(Type ui_type, object context = null, bool needwait = false)
    {
        if (ui_type == null || !ui_type.IsSubclassOf(typeof(CGameUI)))
        {
            return;
        }
        string  ui_name = rg.Match(ui_type.Name).Value;
        CGameUI exists  = Global.ui_mgr.Get(ui_name) as CGameUI;

        if (exists != null)
        {
            exists.context = context;//在界面还没有show前赋值所传的参数列表
            if (!exists.IsShow())
            {
                exists.Show();
            }
            exists.LoadUICallback();
            return;
        }
        // 防止重复加载
        if (IsLoading(ui_name))
        {
            return;
        }
        CGameUIAsset asset = CResourceFactory.CreateInstance <CGameUIAsset>(string.Format("res/ui/uiprefab/{0}.ui", ui_name).ToLower(), null);

        AddLoading(ui_name, asset);

        asset.RegisterCompleteCallback(delegate(CGameUIAsset e)
        {
            CGameUI ui = e.gameObject.AddComponent(ui_type) as CGameUI;
            ui.SetName(ui_name);
            ui.SetAsset(e);
            ui.context = context;
            Global.ui_mgr.Add(ui);
            ui.LoadUICallback();
            RemoveLoading(ui_name);
        });
    }
Example #14
0
    public void Add(CGameUI ui)
    {
        if (!index_pool.CanAlloc())
        {
            LOG.TraceRed("ERROR: ui数量超出上限。ui name:{0}", ui.Name);
            return;
        }
        int index = index_pool.Alloc();

        if (uis[index] != null)
        {
            throw new Exception(string.Format("[CUIManager] ui index:{0} is already in use", index));
        }
        if (names.ContainsKey(ui.Name))
        {
            throw new Exception(string.Format("[CUIManager] ui name:{0} is already exist", ui.Name));
        }
        uis[index]     = ui;
        names[ui.Name] = ui;
        ui.index       = index;
        ui.SetPosition(new Vector3((ui.index + 1) * 100, 0, 0));
        // 最后显示该ui
        ui.Show();
    }
Example #15
0
 public void AddCloseUI(CGameUI ui)
 {
     ui.UIClose();
     ClosedDic[ui.GetType()] = ui.autoLoad;
 }
Example #16
0
 public static IntPtr CGameUI__Constructor(CGameUI @this)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CGameUI__Constructor, @this));
 }
Example #17
0
 /// <summary>
 /// Displays a chat message as sent by a player.
 /// </summary>
 /// <param name="this">The CGameUI instance.</param>
 /// <param name="sender">The player that send the message.</param>
 /// <param name="message">The message sent.</param>
 /// <param name="recipients">The team to receive the message.</param>
 /// <param name="duration">The duration the message should be shown.</param>
 /// <returns>Unknown</returns>
 public static IntPtr CGameUI__DisplayChatMessage(CGameUI @this, Int32 sender, String message, ChatRecipients recipients, Single duration)
 {
     return(ThisCall.Invoke <IntPtr>(GameAddresses.CGameUI__DisplayChatMessage, @this, sender, message, recipients, duration));
 }