Пример #1
0
        /*--------------------------------------------------------------------------------------------*/
        public virtual void TreeUpdate()
        {
            HoverItem hoverItem = GetComponent <HoverItem>();

            DestroyRenderersIfNecessary();
            TryRebuildWithItemType(hoverItem.ItemType);

            ////

            HoverItemHighlightState highState      = GetComponent <HoverItemHighlightState>();
            HoverItemSelectionState selState       = GetComponent <HoverItemSelectionState>();
            HoverRenderer           activeRenderer = ((HoverRenderer)ButtonRenderer ?? SliderRenderer);

            UpdateRenderer(activeRenderer, hoverItem);
            UpdateRendererCanvas(activeRenderer, hoverItem);
            UpdateRendererIndicator(activeRenderer, highState, selState);

            if (ButtonRenderer != null)
            {
                UpdateButtonSettings(highState);
            }

            if (SliderRenderer != null)
            {
                UpdateSliderSettings(hoverItem);
                UpdateSliderSettings(hoverItem, highState);
            }

            Controllers.TryExpireControllers();
        }
Пример #2
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateRendererCanvas(HoverRenderer pRenderer, HoverItem pHoverItem)
        {
            HoverCanvasDataUpdater canvasUp = pRenderer.GetCanvasDataUpdater();

            if (canvasUp == null)
            {
                return;
            }

            IItemData         data         = pHoverItem.Data;
            IItemDataCheckbox checkboxData = (data as IItemDataCheckbox);
            IItemDataRadio    radioData    = (data as IItemDataRadio);
            IItemDataSelector selectorData = (data as IItemDataSelector);
            IItemDataSticky   stickyData   = (data as IItemDataSticky);
            IItemDataSlider   sliderData   = (data as IItemDataSlider);
            var icon = HoverCanvasDataUpdater.IconPairType.Unspecified;

            if (checkboxData != null)
            {
                icon = (checkboxData.Value ?
                        HoverCanvasDataUpdater.IconPairType.CheckboxOn :
                        HoverCanvasDataUpdater.IconPairType.CheckboxOff);
            }
            else if (radioData != null)
            {
                icon = (radioData.Value ?
                        HoverCanvasDataUpdater.IconPairType.RadioOn :
                        HoverCanvasDataUpdater.IconPairType.RadioOff);
            }
            else if (selectorData != null)
            {
                if (selectorData.Action == SelectorActionType.NavigateIn)
                {
                    icon = HoverCanvasDataUpdater.IconPairType.NavigateIn;
                }
                else if (selectorData.Action == SelectorActionType.NavigateOut)
                {
                    icon = HoverCanvasDataUpdater.IconPairType.NavigateOut;
                }
            }
            else if (stickyData != null)
            {
                icon = HoverCanvasDataUpdater.IconPairType.Sticky;
            }
            else if (sliderData != null)
            {
                icon = HoverCanvasDataUpdater.IconPairType.Slider;
            }

            canvasUp.Controllers.Set(HoverCanvasDataUpdater.LabelTextName, this);
            canvasUp.Controllers.Set(HoverCanvasDataUpdater.IconTypeName, this);

            canvasUp.LabelText = (sliderData == null ? data.Label :
                                  sliderData.GetFormattedLabel(sliderData));
            canvasUp.IconType = icon;
        }
Пример #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateSliderSettings(HoverItem pHoverItem)
        {
            IItemDataSlider data = (IItemDataSlider)pHoverItem.Data;

            SliderRenderer.Controllers.Set(HoverRendererSlider.HandleValueName, this);
            SliderRenderer.Controllers.Set(HoverRendererSlider.FillStartingPointName, this);
            SliderRenderer.Controllers.Set(HoverRendererSlider.ZeroValueName, this);
            SliderRenderer.Controllers.Set(HoverRendererSlider.AllowJumpName, this);
            SliderRenderer.Controllers.Set(HoverRendererSlider.TickCountName, this);

            SliderRenderer.HandleValue       = data.SnappedValue;
            SliderRenderer.FillStartingPoint = data.FillStartingPoint;
            SliderRenderer.ZeroValue         = Mathf.InverseLerp(data.RangeMin, data.RangeMax, 0);
            SliderRenderer.AllowJump         = data.AllowJump;
            SliderRenderer.TickCount         = data.Ticks;
        }
Пример #4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private bool FindDuplicateData()
        {
            HoverItem[] items = FindObjectsOfType <HoverItem>();

            for (int i = 0; i < items.Length; i++)
            {
                HoverItem item = items[i];

                if (item != this && item.Data == _Data)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void PerformBuild()
        {
            TreeUpdater treeUp = gameObject.AddComponent <TreeUpdater>();

            HoverItem item = gameObject.AddComponent <HoverItem>();

            item.ItemType = ItemType;

            HoverItemHighlightState highState = gameObject.AddComponent <HoverItemHighlightState>();

            gameObject.AddComponent <HoverItemSelectionState>();

            HoverItemRendererUpdater rendUp = gameObject.AddComponent <HoverItemRendererUpdater>();

            rendUp.ButtonRendererPrefab = ButtonRendererPrefab;
            rendUp.SliderRendererPrefab = SliderRendererPrefab;
            highState.ProximityProvider = rendUp;

            treeUp.Update();             //forces the entire item to update
        }
Пример #6
0
        /*--------------------------------------------------------------------------------------------*/
        private static IItemData[] GetChildItemsFromGameObject(GameObject pParentObj)
        {
            Transform tx         = pParentObj.transform;
            int       childCount = tx.childCount;
            var       items      = new List <IItemData>();

            for (int i = 0; i < childCount; ++i)
            {
                HoverItem hni  = tx.GetChild(i).GetComponent <HoverItem>();
                IItemData item = hni.Data;

                if (!item.IsVisible)
                {
                    continue;
                }

                items.Add(item);
            }

            return(items.ToArray());
        }
Пример #7
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateSliderSettings(HoverItem pHoverItem, HoverItemHighlightState pHighState)
        {
            HoverItemDataSlider data = (HoverItemDataSlider)pHoverItem.Data;

            HoverItemHighlightState.Highlight?high = pHighState.NearestHighlight;
            float highProg  = pHighState.MaxHighlightProgress;
            bool  isNearest = pHighState.IsNearestAcrossAllItemsForAnyCursor;

            SliderRenderer.Controllers.Set(HoverRendererSlider.JumpValueName, this);
            SliderRenderer.Controllers.Set(HoverRendererSlider.ShowButtonEdgesName, this);

            SliderRenderer.ShowButtonEdges = (isNearest && highProg > 0);

            if (high == null || highProg <= 0 || !isNearest)
            {
                data.HoverValue          = null;
                SliderRenderer.JumpValue = -1;
                return;
            }

            float value = SliderRenderer.GetValueViaNearestWorldPosition(high.Value.NearestWorldPos);

            data.HoverValue = value;

            float snapValue = (float)data.SnappedHoverValue;
            //float easePower = (1-high.Value.Progress)*5+1; //gets "snappier" as you pull away
            float showValue = DisplayUtil.GetEasedValue(data.Snaps, value, snapValue, 3);

            SliderRenderer.JumpValue = showValue;

            if (data.IsStickySelected)
            {
                data.Value = value;
                SliderRenderer.Controllers.Set(HoverRendererSlider.HandleValueName, this);
                SliderRenderer.HandleValue = showValue;
            }
        }
Пример #8
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 private void UpdateRenderer(HoverRenderer pRenderer, HoverItem pHoverItem)
 {
     pRenderer.Controllers.Set(HoverRenderer.IsEnabledName, this);
     pRenderer.IsEnabled = pHoverItem.Data.IsEnabled;
 }