Ejemplo n.º 1
0
    public void SortByTreeAndPriority()
    {
        if (mCurrentEditItems != null)
        {
            List <BundleInfo> tmpList = new List <BundleInfo>();
            foreach (var root in BundleManager.Roots)
            {
                foreach (var node in TreeToList(root))
                {
                    var bundle = mCurrentEditItems.Find(item => item.BundleName == node.name);
                    if (bundle != null)
                    {
                        mCurrentEditItems.Remove(bundle);
                        tmpList.Add(bundle);
                    }
                }
            }
            tmpList.AddRange(mCurrentEditItems);
            tmpList = tmpList.OrderBy(item =>
            {
                return(item.Priority);
            }).ToList();

            mCurrentEditItems.Clear();
            foreach (var bundle in tmpList)
            {
                EB.Collections.Stack <BundleInfo> list = new EB.Collections.Stack <BundleInfo>();

                var iter = bundle;
                list.Push(iter);
                while (iter != null && !string.IsNullOrEmpty(iter.Parent))
                {
                    iter = tmpList.Find(item => item.BundleName == iter.Parent);
                    if (iter != null)
                    {
                        list.Add(iter);
                    }
                }

                while (list.Count > 0)
                {
                    var item = list.Pop();
                    if (!mCurrentEditItems.Contains(item))
                    {
                        mCurrentEditItems.Add(item);
                    }
                }
            }

            mCurrentEditItemsChanged = true;
        }
    }
Ejemplo n.º 2
0
    public static List <string> GetFilesWildcardRecursive(string b, string w, string fileExt)
    {
        // 1.
        // Store results in the file results list.
        List <string> result = new List <string>();

        // 2.
        // Store a stack of our directories.
        EB.Collections.Stack <string> stack = new EB.Collections.Stack <string>();

        // 3.
        // Add initial directory.
        stack.Push(b);

        // 4.
        // Continue while there are directories to process
        while (stack.Count > 0)
        {
            // A.
            // Get top directory
            string dir = stack.Pop();

            try
            {
                // B
                // Add all files at this directory to the result List.
                if (dir.Contains(w))
                {
                    result.AddRange(GetFilesRootPath(dir, fileExt));
                }

                // C
                // Add all directories at this directory.
                foreach (string dn in Directory.GetDirectories(dir))
                {
                    stack.Push(dn);
                }
            }
            catch
            {
                Debug.Log("GetFilesRecursive - Error opening directory");
                // Could not open the directory
            }
        }
        return(result);
    }
Ejemplo n.º 3
0
    public string GetSystemPath(IDebuggable system)
    {
        EB.Collections.Stack <string> hierarchy = new EB.Collections.Stack <string>();
        IDebuggable currentSystem = system;

        while (currentSystem != null)
        {
            hierarchy.Push(_gameSystems[currentSystem].systemName);
            currentSystem = _gameSystems[currentSystem].parent;
        }

        System.Text.StringBuilder builder = new System.Text.StringBuilder();
        while (hierarchy.Count > 0)
        {
            builder.Append(hierarchy.Pop());

            if (hierarchy.Count > 0)
            {
                builder.Append("/");
            }
        }

        return(builder.ToString());
    }
Ejemplo n.º 4
0
    public void SetCache(string dataID, object value, bool refresh)
    {
        dataID = NormalizeDataID(dataID);
        if (!ReplaceInlineDataIDWithCacheValue(ref dataID))
        {
            throw new System.ArgumentException("Some dataID's inline parts cannot be found in the cache", "dataID");
        }

        IList <string> dataIDSplit = SplitDataID(dataID);

        object parentNode   = null;
        object currentNode  = dataCache;
        string currentSplit = "";
        string loopID       = "";

        EB.Collections.Stack <KeyValuePair <string, object> > ids = new EB.Collections.Stack <KeyValuePair <string, object> >();
        for (int i = 0; i < dataIDSplit.Count; i++)
        {
            if (DataIDSeparators.All.Contains(dataIDSplit[i]))
            {
                continue;
            }

            currentSplit = dataIDSplit[i];
            parentNode   = currentNode;
            object defaultValue = DefaultValue(dataIDSplit, i);
            currentNode = ExtendStruct(currentNode, currentSplit, defaultValue);

            if (string.IsNullOrEmpty(loopID))
            {
                loopID = currentSplit;
            }
            else if (parentNode is IDictionary)
            {
                loopID += "." + currentSplit;
            }
            else if (parentNode is IList)
            {
                loopID += "[" + currentSplit + "]";
            }
            ids.Push(new KeyValuePair <string, object>(loopID, currentNode));
        }
        FillStruct(parentNode, currentSplit, value);

        // drop old value
        ids.Pop();
        if (refresh)
        {
            // refresh children
            RefreshStruct(dataID, value);
        }
        else
        {
            // refresh new value
            ids.Push(new KeyValuePair <string, object>(loopID, value));
        }

        // refresh parents
        while (ids.Count > 0)
        {
            var pair = ids.Pop();
            StashUpdateLookupsCall(pair.Key, pair.Value);
        }

        // trigger callbacks
        ProcessUpdateLookupsCallsStack();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 执行ui出栈操作,移除栈顶ui
    /// </summary>
    /// <param name="isPartOfExitStack">是否是退出状态的一部分,从而决定是否做些uicontroller中的一些逻辑或回调</param>
    /// <returns></returns>
    private IEnumerator BackstackCoroutine(bool isPartOfExitStack)
    {
        if (_backStack.Count == 0)
        {
            EB.Debug.LogWarning("BackstackCoroutine: backStack is empty");
            yield break;
        }

        IStackableWrapper wrapper = _backStack.Pop();

        EB.Debug.LogUI("界面UIStack:【<color=#00ff00>{0}</color>】在<color=#fff348>UIStack</color>中<color=#ff0000>从栈顶出栈</color>", wrapper.stackable);

        // Clear eventual stacked renderers from the full stack
        while (_fullStack.Pop() != wrapper)
        {
            ;
        }

        if (onBackstack != null)
        {
            onBackstack(wrapper.stackable);
        }

        if (wrapper.inputBlockerInstance != null)
        {
            // Value might be changed later depending on whether we find another input blocker before the next panel
            _isInputBlockerVisible = false;
            TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
            ta.tweenFactor = 1.0f;
            EventDelegate.Add(ta.onFinished, () => Destroy(wrapper.inputBlockerInstance));
            ta.PlayReverse();
        }

        if (wrapper.firstStackDepth >= 0 && wrapper.firstStackDepth < _nextStackDepth)
        {
            _nextStackDepth = wrapper.firstStackDepth;
        }

        // Let the other windows know what happened, show what needs to be shown, etc.
        if (_backStack.Count > 0)
        {
            EB.Collections.Stack <IStackableWrapper> tempStack = new EB.Collections.Stack <IStackableWrapper>();
            while (_backStack.Count > 0 && !_backStack.Peek().stackable.IsFullscreen())
            {
                tempStack.Push(_backStack.Pop());

                if (wrapper.stackable.IsFullscreen())
                {
                    tempStack.Peek().stackable.Show(true);
                }
                if (tempStack.Peek().inputBlockerInstance != null && !_isInputBlockerVisible)
                {
                    // show top blocker
                    //TweenAlpha tempTa = tempStack.Peek().inputBlockerInstance.GetComponentInChildren<TweenAlpha>();
                    _isInputBlockerVisible = true;
                    tempStack.Peek().inputBlockerInstance.GetComponent <UIPanel>().alpha = 1f;                   // tempTa.to;

                    // update tween parameters
                    if (wrapper.inputBlockerInstance != null)
                    {
                        TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                        ta.tweenFactor = 0.0f;
                        wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                    }
                }
            }

            if (wrapper.stackable.IsFullscreen())
            {
                // If the count is positive, it means that we've hit a full screen
                if (_backStack.Count > 0)
                {
                    // show top full screen
                    _backStack.Peek().stackable.Show(true);
                    if (_backStack.Peek().inputBlockerInstance != null && !_isInputBlockerVisible)
                    {
                        // show top blocker
                        TweenAlpha tempTa = tempStack.Peek().inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                        _isInputBlockerVisible = true;
                        _backStack.Peek().inputBlockerInstance.GetComponent <UIPanel>().alpha = tempTa.to;

                        // update tween parameters
                        if (wrapper.inputBlockerInstance != null)
                        {
                            TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                            ta.tweenFactor = 0.0f;
                            wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                        }
                    }

                    GameUtils.SetMainCameraActive(_backStack.Peek().stackable.IsRenderingWorldWhileFullscreen());
                }
                else
                {
                    // No full screen, show the HUD
                    _isFullScreenOpened = false;
                }
            }

            while (tempStack.Count > 0)
            {
                _backStack.Push(tempStack.Pop());
            }
        }
        else
        {
            // There's nothing in the stack, so no full screen, no blocker
            _isFullScreenOpened    = false;
            _isInputBlockerVisible = false;
        }

        if (!_isFullScreenOpened && !IsLoadingScreenUp)
        {
            GameUtils.SetMainCameraActive(true);
        }

        if (wrapper.stackable == _currentQueuedStackableDisplayed)
        {
            _currentQueuedStackableDisplayed = null;
        }

        if (_enstackFlag == 0 && _backstackFlag == 0 && !isPartOfExitStack)
        {
            wrapper.stackable.OnBlur();
        }

        _enstackFlag   = 0;
        _backstackFlag = 0;

        _backstackFlag = ++s_seed;
        var currentFlag = _backstackFlag;

        wrapper.stackable.ClearData();
        yield return(StartCoroutine(wrapper.stackable.OnRemoveFromStack()));

        if (currentFlag == _backstackFlag)
        {
            _backstackFlag = 0;

            if (_backStack.Count > 0 && !isPartOfExitStack)
            {
                //EB.Debug.LogWarning("Backstack: finish {0} onfocus", backStack.Peek().stackable);
                _backStack.Peek().stackable.OnFocus();
            }
            else
            {
                //EB.Debug.LogWarning("Backstack: finish");
            }

            if (!isPartOfExitStack)
            {
                OnFinishedBackstacking();
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 入栈的协程
    /// </summary>
    /// <param name="stackable"></param>
    /// <param name="manualDepth"></param>
    /// <returns></returns>
    private IEnumerator EnStackCoroutine(IStackableUI stackable)
    {
        if (stackable != null && !stackable.Equals(null))
        {
            // disable Main Camera
            if (stackable.IsFullscreen())
            {
                _isFullScreenOpened = true;

                GameUtils.SetMainCameraActive(stackable.IsRenderingWorldWhileFullscreen());
            }

            // OnBlur Event on top ui
            if (_backStack.Count > 0)
            {
                if (_enstackFlag == 0 && _backstackFlag == 0)
                {
                    _backStack.Peek().stackable.OnBlur();
                }
            }

            _enstackFlag   = 0;
            _backstackFlag = 0;

            // Create wrapper
            IStackableWrapper wrapper = new IStackableWrapper();
            wrapper.stackable = stackable;

            // Insert an input blocker if needed
            if (stackable.ShowUIBlocker)
            {
                _isInputBlockerVisible            = true;
                wrapper.inputBlockerInstance      = GameObject.Instantiate(inputBlockerPrefab);
                wrapper.inputBlockerInstance.name = string.Format("InputBlockerFor{0}", stackable.ToString());
                wrapper.inputBlockerInstance.transform.SetParent(gameObject.transform);
                wrapper.inputBlockerInstance.transform.localPosition = Vector3.zero;
                wrapper.inputBlockerInstance.transform.localScale    = Vector3.one;
                wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                ta.tweenFactor = 1.0f;                  //0.0f
                ta.PlayForward();
            }

            // Warn other screens that we're about to stack someone
            if (onEnstack != null)
            {
                onEnstack(stackable);
            }

            _nextStackDepth = AssignDepths(wrapper);

            // Hide below, set visible variables
            EB.Collections.Stack <IStackableWrapper> tempStack = new EB.Collections.Stack <IStackableWrapper>();
            while (_backStack.Count > 0)
            {
                tempStack.Push(_backStack.Pop());

                if (stackable.IsFullscreen())
                {
                    tempStack.Peek().stackable.Show(false);
                }
                if (tempStack.Peek().inputBlockerInstance != null && (stackable.ShowUIBlocker || stackable.IsFullscreen()))
                {
                    if (stackable.IsFullscreen() && wrapper.inputBlockerInstance == null)
                    {
                        _isInputBlockerVisible = false;
                    }

                    // hide blocker for next frame
                    var tempPanel = tempStack.Peek().inputBlockerInstance.GetComponent <UIPanel>();
                    if (wrapper.inputBlockerInstance && wrapper.inputBlockerInstance.name.Contains("DataPanelNew"))
                    {
                        tempPanel.alpha = 0.0f;
                    }
                    else
                    {
                        EB.Coroutines.EndOfFrame(delegate()
                        {
                            tempPanel.alpha = 0.0f;
                        });
                    }
                }
            }

            while (tempStack.Count > 0)
            {
                _backStack.Push(tempStack.Pop());
            }

            // Fix again
            if (_isInputBlockerVisible && stackable.IsFullscreen() && wrapper.inputBlockerInstance == null)
            {
                _isInputBlockerVisible = false;
            }

            // Place stackable
            _backStack.Push(wrapper);
            _fullStack.Push(wrapper);

            // OnFocus Event
            _enstackFlag = ++s_seed;
            int currentFlag = _enstackFlag;
            yield return(StartCoroutine(stackable.OnAddToStack()));

            if (_enstackFlag == currentFlag && !IsLoadingScreenUp)
            {
                _enstackFlag = 0;
                stackable.OnFocus();
            }
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 把ui从堆栈中移除(可以不是栈顶的ui)
    /// </summary>
    /// <param name="ui"></param>
    /// <returns></returns>
    private IEnumerator Remove(IStackableUI ui)
    {
        EB.Debug.LogUI("界面UIStack:【<color=#00ff00>{0}</color>】在<color=#fff348>UIStack</color>中<color=#ff0000>从非栈顶出栈</color>,调用Remove方法", ui);
        // assume invisible first, update later
        _isInputBlockerVisible = false;
        _isFullScreenOpened    = false;

        // remove from backStack
        IStackableWrapper wrapper = null;

        EB.Collections.Stack <IStackableWrapper> tmp = new EB.Collections.Stack <IStackableWrapper>();
        while (_backStack.Count > 0)
        {
            var top = _backStack.Pop();
            if (top.stackable != ui)
            {
                if (top.stackable.IsFullscreen())
                {
                    _isFullScreenOpened = true;
                }
                if (top.inputBlockerInstance != null && !_isInputBlockerVisible)
                {
                    _isInputBlockerVisible = true;
                    top.inputBlockerInstance.GetComponent <UIPanel>().alpha = top.inputBlockerInstance.GetComponentInChildren <TweenAlpha>().to;
                }
                tmp.Push(top);
            }
            else
            {
                wrapper = top;
                break;
            }
        }

        IStackableWrapper[] below = _backStack.ToArray();

        while (tmp.Count > 0)
        {
            _backStack.Push(tmp.Pop());
        }

        // remove from fullStack
        EB.Collections.Stack <StackedItem> fullTmp = new EB.Collections.Stack <StackedItem>();
        while (_fullStack.Count > 0)
        {
            var top = _fullStack.Pop();
            if (top != wrapper)
            {
                fullTmp.Push(top);
            }
            else
            {
                break;
            }
        }

        while (fullTmp.Count > 0)
        {
            _fullStack.Push(fullTmp.Pop());
        }

        // update visibility
        for (int i = 0; i < below.Length; ++i)
        {
            if (!_isFullScreenOpened)
            {
                below[i].stackable.Show(true);

                if (below[i].inputBlockerInstance != null && !_isInputBlockerVisible)
                {
                    _isInputBlockerVisible = true;
                    below[i].inputBlockerInstance.GetComponent <UIPanel>().alpha = below[i].inputBlockerInstance.GetComponentInChildren <TweenAlpha>().to;
                }

                if (below[i].stackable.IsFullscreen())
                {
                    _isFullScreenOpened = true;

                    GameUtils.SetMainCameraActive(below[i].stackable.IsRenderingWorldWhileFullscreen());
                }
            }

            if (_isFullScreenOpened)
            {
                break;
            }
        }

        if (!_isFullScreenOpened && !IsLoadingScreenUp)
        {
            GameUtils.SetMainCameraActive(true);
        }

        // remove
        if (wrapper.inputBlockerInstance != null)
        {
            TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
            ta.tweenFactor = _isInputBlockerVisible ? 0.1f : 1.0f;
            EventDelegate.Add(ta.onFinished, () => Destroy(wrapper.inputBlockerInstance));
            ta.PlayReverse();
        }

        ui.ClearData();
        yield return(StartCoroutine(ui.OnRemoveFromStack()));
    }