Example #1
0
    private static void RefreshDisplayObjectItem()
    {
        RecycleAllDisplayObjectItem();
        if (!string.IsNullOrWhiteSpace(_searchText))
        {
            ShowAllSearchedDisplayObjectItem();
            return;
        }

        if (string.IsNullOrEmpty(GlobalData.CurrentModule))
        {
            return;
        }
        int currentModuleIdx = ModuleItems.FindIndex(module => module.name.Equals(GlobalData.CurrentModule));

        if (currentModuleIdx == -1)
        {
            return;
        }
        SwapImageManager swapImage = ModuleItems[currentModuleIdx].GetComponentInChildren <SwapImageManager>();

        swapImage.UpdateSwapImage(true);
        ModuleItems[currentModuleIdx].GetChild(0).gameObject.SetActive(true);
        int count = GlobalData.CurrentDisplayObjects.Count;

        for (int idx = 0; idx < count; ++idx)
        {
            Transform displayObjectItem = GetDisplayObjectItem();
            DisplayObjectItems.Add(displayObjectItem);
            displayObjectItem.SetParent(GlobalData.HierarchyContainer.transform);
            displayObjectItem.SetSiblingIndex(currentModuleIdx + idx + 1);
            displayObjectItem.name = GlobalData.CurrentDisplayObjects[idx].name;
            displayObjectItem.GetComponentInChildren <Text>().text = GlobalData.CurrentDisplayObjects[idx].name;
            SwapImageManager sim = displayObjectItem.GetComponentInChildren <SwapImageManager>();
            if (!sim)
            {
                continue;
            }
            Element element = GlobalData.GetElement(displayObjectItem.name);
            if (element != null)
            {
                sim.UpdateSwapImage(!element.Visible);
            }
        }

        if (count == 0 || GlobalData.CurrentSelectDisplayObjectDic.Count == 0)
        {
            return;
        }
        foreach (Transform displayObjectItem in GlobalData.CurrentSelectDisplayObjectDic.Select(pair => DisplayObjectItems.Find(element => element.name.Equals(pair.Key)))
                 .Where(displayObjectItem => displayObjectItem != null))
        {
            displayObjectItem.GetChild(0).gameObject.SetActive(true);
        }
    }
Example #2
0
    private static void ShowAllSearchedDisplayObjectItem()
    {
        if (string.IsNullOrWhiteSpace(_searchText))
        {
            return;
        }
        if (!_isGlobalSearchFlag && string.IsNullOrWhiteSpace(GlobalData.CurrentModule))
        {
            return;
        }
        int count = GlobalData.Modules.Count;

        for (int idx = 0; idx < count; ++idx)
        {
            if (_isGlobalSearchFlag && ModuleItems[idx].name.IndexOf(_searchText, StringComparison.Ordinal) != -1)
            {
                ModuleItems[idx].GetComponentInChildren <Text>().text = ModuleItems[idx].name.HighlightText(_searchText);
            }
            if (!_isGlobalSearchFlag && !GlobalData.Modules[idx].Equals(GlobalData.CurrentModule))
            {
                continue;
            }
            int            siblingIndex   = ModuleItems[idx].GetSiblingIndex();
            List <Element> displayObjects = GlobalData.ModuleDic[GlobalData.Modules[idx]];
            bool           hasFind        = false;
            int            count2         = displayObjects.Count;
            for (int idx2 = 0; idx2 < count2; ++idx2)
            {
                Element displayObject = displayObjects[idx2];
                if (displayObject.Name.IndexOf(_searchText, StringComparison.Ordinal) == -1)
                {
                    continue;
                }
                hasFind = true;
                Transform displayObjectItem = GetDisplayObjectItem();
                DisplayObjectItems.Add(displayObjectItem);
                displayObjectItem.SetParent(GlobalData.HierarchyContainer.transform);
                displayObjectItem.SetSiblingIndex(++siblingIndex);
                displayObjectItem.name = displayObject.Name.HighlightText(_searchText);
                displayObjectItem.GetComponentInChildren <Text>().text = displayObjectItem.name;
            }

            if (!hasFind)
            {
                continue;
            }
            SwapImageManager swapImage = ModuleItems[idx].GetComponentInChildren <SwapImageManager>();
            swapImage.UpdateSwapImage(true);
        }
    }
Example #3
0
    private static void RecycleModuleItem(Transform moduleItem)
    {
        if (!moduleItem)
        {
            return;
        }
        moduleItem.SetParent(null);
        moduleItem.GetChild(0).gameObject.SetActive(false);
        SwapImageManager swapImage = moduleItem.GetComponentInChildren <SwapImageManager>();

        swapImage.UpdateSwapImage(false);
        moduleItem.GetComponentInChildren <ImageHoverManager>().SimulatePointerExit();
        ModuleItemPool.Add(moduleItem);
    }
Example #4
0
    private static Transform GetModuleItem()
    {
        int length = ModuleItemPool.Count;

        if (length == 0)
        {
            return(Instantiate(GlobalData.ModuleItemPrefab.transform, GlobalData.HierarchyContainer.transform));
        }
        Transform        result    = ModuleItemPool[length - 1];
        SwapImageManager swapImage = result.GetComponentInChildren <SwapImageManager>();

        swapImage.UpdateSwapImage(false);
        result.GetChild(0).gameObject.SetActive(false);
        ModuleItemPool.RemoveAt(length - 1);
        return(result);
    }
Example #5
0
    private static void StartObserveSwapImage()
    {
        Subject <SwapImageEventData> subject = UlEventSystem.TryToGetSubject <UIEventType, SwapImageEventData>(UIEventType.SwapImage);

        if (subject != null)
        {
            return;
        }
        UlEventSystem.GetSubject <UIEventType, SwapImageEventData>(UIEventType.SwapImage)
        .Subscribe(eventData => {
            if (eventData == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(eventData.ModuleName) || !eventData.ModuleName.Equals(GlobalData.CurrentModule))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(eventData.ElementName))
            {
                return;
            }
            Transform displayObject = GlobalData.CurrentDisplayObjectDic[eventData.ElementName];
            if (displayObject)
            {
                displayObject.gameObject.SetActive(!eventData.IsSwap);
            }
            Transform item = GetDisplayObjectItem(eventData.ModuleName, eventData.ElementName);
            if (item)
            {
                SwapImageManager sim = item.GetComponentInChildren <SwapImageManager>();
                if (sim)
                {
                    sim.UpdateSwapImage(eventData.IsSwap);
                }
            }
            Element element = GlobalData.GetElement(eventData.ElementName);
            if (element != null)
            {
                element.Visible = !eventData.IsSwap;
            }
        });
    }
    public void OnPointerDown(PointerEventData eventData)
    {
        string elementName = transform.name.CancelHighlight();

        if (itemType == 1)
        {
            ContainerManager.UpdateCurrentDisplayObjectData();
            string moduleName = elementName;
            if (moduleName.Equals(GlobalData.CurrentModule))
            {
                moduleName = null;
            }
            HistoryManager.Do(BehaviorFactory.GetOpenModuleBehavior(moduleName));
            return;
        }
        if (itemType != 2)
        {
            return;
        }
        if (HierarchyManager.InSearchMode())
        {
            string module = HierarchyManager.GetModuleName(transform.GetSiblingIndex());
            if (string.IsNullOrEmpty(module))
            {
                return;
            }
            HistoryManager.Do(BehaviorFactory.GetOpenModuleBehavior(module, CombineType.Next));
            HistoryManager.Do(BehaviorFactory.GetUpdateSelectDisplayObjectBehavior(module, new List <string> {
                elementName
            }));
            return;
        }
        if (string.IsNullOrEmpty(GlobalData.CurrentModule))
        {
            return;
        }
        Transform displayObject = GlobalData.CurrentDisplayObjectDic[elementName];

        if (displayObject.parent == null)
        {
            return;
        }
        SwapImageManager sim = transform.GetComponentInChildren <SwapImageManager>();

        if (sim && Utils.IsPointOverGameObject(sim.gameObject))
        {
            HistoryManager.Do(BehaviorFactory.GetUpdateSwapImageBehavior(GlobalData.CurrentModule, elementName, !sim.isSwap));
            return;
        }
        bool          isSelect = GlobalData.CurrentSelectDisplayObjectDic.ContainsKey(elementName);
        List <string> addElements = null, removeElements = null;

        if (isSelect)
        {
            if (KeyboardEventManager.GetControl())
            {
                removeElements = new List <string> {
                    elementName
                };
            }
            else if (GlobalData.CurrentSelectDisplayObjectDic.Count > 1)
            {
                removeElements = GlobalData.CurrentSelectDisplayObjectDic.KeyList();
                removeElements.Remove(elementName);
            }
        }
        else
        {
            if (!KeyboardEventManager.GetShift())
            {
                removeElements = GlobalData.CurrentSelectDisplayObjectDic.KeyList();
            }
            addElements = new List <string> {
                elementName
            };
        }
        if (addElements != null || removeElements != null)
        {
            HistoryManager.Do(BehaviorFactory.GetUpdateSelectDisplayObjectBehavior(GlobalData.CurrentModule, addElements, removeElements));
        }
    }