Exemplo n.º 1
0
        /// <summary>
        /// Queue the screen to be popped from the screen stack. This will pop all screens on top of it as well.
        /// Callback will be invoked when the screen is reached, or popped if 'include' is true.
        /// </summary>
        public void QueuePopTo(RP.Screen.Id id, bool include, PoppedDelegate callback = null)
        {
            #if PRINT_QUEUE
            DebugPrintQueue(string.Format("[UIManager] QueuePopTo id: {0}, include: {1}", id, include));
            #endif

            bool found = false;

            for (int i = 0; i < _stack.Count; i++)
            {
                var screen = _stack[i];

                if (screen.id != id)
                {
                    var queuedPop = new QueuedScreenPop();
                    queuedPop.id = screen.id;

                    _queue.Enqueue(queuedPop);

                    #if PRINT_QUEUE
                    DebugPrintQueue(string.Format("[UIManager] Enqueued Screen: {0}", queuedPop));
                    #endif
                }
                else
                {
                    if (include)
                    {
                        var queuedPop = new QueuedScreenPop();
                        queuedPop.id       = screen.id;
                        queuedPop.callback = callback;

                        _queue.Enqueue(queuedPop);

                        #if PRINT_QUEUE
                        DebugPrintQueue(string.Format("[UIManager] Enqueued Screen: {0}", queuedPop));
                        #endif
                    }

                    if (callback != null)
                    {
                        callback(screen.id);
                    }

                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Debug.LogWarning(string.Format("[UIManager] {0} was not in the stack. All screens have been popped.", id));
            }

            if (CanExecuteNextQueueItem())
            {
                ExecuteNextQueueItem();
            }
        }
Exemplo n.º 2
0
        public Screen GetScreen(RP.Screen.Id id)
        {
            int count = _stack.Count;

            for (int i = 0; i < count; i++)
            {
                if (_stack[i].id == id)
                {
                    return(_stack[i]);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Queue the screen to be pushed onto the screen stack.
        /// Callback will be invoked when the screen is pushed to the stack.
        /// </summary>
        public void QueuePush(RP.Screen.Id id, RP.Screen.Data data, string prefabName = null, PushedDelegate callback = null)
        {
            string prefab = prefabName ?? id.defaultPrefabName;

            #if PRINT_QUEUE
            DebugPrintQueue(string.Format("[UIManager] QueuePush id: {0}, prefabName: {1}", id, prefab));
            #endif

            if (GetScreen(id) != null)
            {
                Debug.LogWarning(string.Format("Screen {0} already exists in the stack. Ignoring push request.", id));
                return;
            }

            //if (ScreenWillExist(id))
            //{
            //    Debug.LogWarning(string.Format("Screen {0} will exist in the stack after the queue is fully executed. Ignoring push request.", id));
            //    return;
            //}

            QueuedScreenPush push = new QueuedScreenPush();
            push.id         = id;
            push.data       = data;
            push.prefabName = prefab;
            push.callback   = callback;

            _queue.Enqueue(push);

            #if PRINT_QUEUE
            DebugPrintQueue(string.Format("[UIManager] Enqueued Screen: {0}, Frame: {1}", push, Time.frameCount));
            #endif

            if (CanExecuteNextQueueItem())
            {
                ExecuteNextQueueItem();
            }
        }
Exemplo n.º 4
0
        public T GetScreen <T> (RP.Screen.Id id) where T : RP.Screen
        {
            Screen screen = GetScreen(id);

            return((T)screen);
        }