//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override IItemVisualSettings GetSettingsInner(IBaseItem pItem, IItemVisualSettings pDefault, bool pFillWithDefault) { var sett = new ItemVisualSettingsStandard(); if ( pFillWithDefault ) { sett.FillWith(pDefault, false); } else { sett.TextSize = TextSize; sett.TextColor = TextColor; sett.TextFont = TextFont; sett.ArrowIconColor = ArrowIconColor; sett.ToggleIconColor = ToggleIconColor; sett.BackgroundColor = BackgroundColor; sett.EdgeColor = EdgeColor; sett.HighlightColor = HighlightColor; sett.SelectionColor = SelectionColor; sett.SliderTrackColor = SliderTrackColor; sett.SliderFillColor = SliderFillColor; sett.SliderTickColor = SliderTickColor; sett.ExpandSize = ExpandSize; } sett.Renderer = GetRendererForItem(pItem); return sett; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override IItemVisualSettings GetSettingsInner(IBaseItem pItem, IItemVisualSettings pDefault, bool pFillWithDefault) { var sett = new ItemVisualSettingsStandard(); if (pFillWithDefault) { sett.FillWith(pDefault, false); } else { sett.TextSize = TextSize; sett.TextColor = TextColor; sett.TextFont = TextFont; sett.ArrowIconColor = ArrowIconColor; sett.ToggleIconColor = ToggleIconColor; sett.BackgroundColor = BackgroundColor; sett.EdgeColor = EdgeColor; sett.HighlightColor = HighlightColor; sett.SelectionColor = SelectionColor; sett.SliderTrackColor = SliderTrackColor; sett.SliderFillColor = SliderFillColor; sett.SliderTickColor = SliderTickColor; } sett.Renderer = GetRendererForItem(pItem); return(sett); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public virtual void Build(IHoverboardPanelState pPanelState, IHoverboardLayoutState pLayoutState, IBaseItemState pItemState, IItemVisualSettings pSettings) { vPanelState = pPanelState; vLayoutState = pLayoutState; vItemState = pItemState; vSettings = (ItemVisualSettingsStandard)pSettings; gameObject.transform.SetParent(gameObject.transform, false); vHoverRect = new UiHoverMeshRect(gameObject); var labelObj = new GameObject("Label"); labelObj.transform.SetParent(gameObject.transform, false); vLabel = labelObj.AddComponent<UiLabel>(); float width = UiItem.Size*vItemState.Item.Width; float height = UiItem.Size*vItemState.Item.Height; SetCustomSize(width, height); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void FillWith(IItemVisualSettings pSourceSettings, bool pIncludeRenderer) { ItemVisualSettingsStandard sett = (ItemVisualSettingsStandard)pSourceSettings; if (pIncludeRenderer) { Renderer = sett.Renderer; } TextSize = sett.TextSize; TextColor = sett.TextColor; TextFont = sett.TextFont; ArrowIconColor = sett.ArrowIconColor; ToggleIconColor = sett.ToggleIconColor; BackgroundColor = sett.BackgroundColor; EdgeColor = sett.EdgeColor; HighlightColor = sett.HighlightColor; SelectionColor = sett.SelectionColor; SliderTrackColor = sett.SliderTrackColor; SliderFillColor = sett.SliderFillColor; SliderTickColor = sett.SliderTickColor; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public virtual void Build(IHoverboardPanelState pPanelState, IHoverboardLayoutState pLayoutState, IBaseItemState pItemState, IItemVisualSettings pSettings) { vPanelState = pPanelState; vLayoutState = pLayoutState; vItemState = pItemState; vSettings = (ItemVisualSettingsStandard)pSettings; vSliderItem = (ISliderItem)vItemState.Item; vTicks = new GameObject[vSliderItem.Ticks]; vWidth = UiItem.Size*vSliderItem.Width; vHeight = UiItem.Size*vSliderItem.Height; vIsVert = (vHeight > vWidth); vGrabW = 1; vZeroValue = (0-vSliderItem.RangeMin)/(vSliderItem.RangeMax-vSliderItem.RangeMin); gameObject.transform.SetParent(gameObject.transform, false); gameObject.transform.localPosition = new Vector3(vWidth/2, 0, vHeight/2f); gameObject.transform.localRotation = Quaternion.AngleAxis((vIsVert ? 90 : 0), Vector3.up); if ( vIsVert ) { //swap dimensions here + rotate graphics later float tempW = vWidth; vWidth = vHeight; vHeight = tempW; } vSlideX0 = (vGrabW-vWidth)/2; vSlideW = vWidth-vGrabW; //// vHiddenRect = new UiHoverMeshRectBg(gameObject); vHiddenRect.UpdateSize(vWidth, vHeight); var trackObj = new GameObject("Track"); trackObj.transform.SetParent(gameObject.transform, false); trackObj.transform.localPosition = new Vector3(-vWidth/2, 0, 0); vTrack = new UiItemSliderTrackRenderer(trackObj); vTrackSegments = new ReadList<DisplayUtil.TrackSegment>(); vTrackCuts = new ReadList<DisplayUtil.TrackSegment>(); //// if ( vSliderItem.Ticks > 1 ) { Vector3 quadScale = new Vector3(UiHoverMeshRect.SizeInset*2, 0.36f, 0.1f); float percPerTick = 1/(float)(vSliderItem.Ticks-1); vTickMeshBuilder = new MeshBuilder(); MeshUtil.BuildQuadMesh(vTickMeshBuilder); vTickMeshBuilder.Commit(); vTickMeshBuilder.CommitColors(Color.clear); for ( int i = 0 ; i < vSliderItem.Ticks ; ++i ) { GameObject tickObj = new GameObject("Tick"+i); tickObj.transform.SetParent(gameObject.transform, false); tickObj.transform.localPosition = Vector3.right*(vSlideX0+vSlideW*i*percPerTick); tickObj.transform.localRotation = TickQuatRot; tickObj.transform.localScale = quadScale; tickObj.AddComponent<MeshRenderer>(); MeshFilter tickFilt = tickObj.AddComponent<MeshFilter>(); tickFilt.sharedMesh = vTickMeshBuilder.Mesh; vTicks[i] = tickObj; } } //// vGrabHold = new GameObject("GrabHold"); vGrabHold.transform.SetParent(gameObject.transform, false); vGrabHold.transform.localRotation = Quaternion.Inverse(gameObject.transform.localRotation); var grabObj = new GameObject("Grab"); grabObj.transform.SetParent(vGrabHold.transform, false); vGrab = grabObj.AddComponent<UiItemSliderGrabRenderer>(); vGrab.IsVert = vIsVert; vGrab.Build(vPanelState, vLayoutState, vItemState, vSettings); if ( vIsVert ) { vGrab.SetCustomSize(vHeight, vGrabW, false); } else { vGrab.SetCustomSize(vGrabW, vHeight, false); } //// vHoverHold = new GameObject("HoverHold"); vHoverHold.transform.SetParent(gameObject.transform, false); var hoverObj = new GameObject("Hover"); hoverObj.transform.SetParent(vHoverHold.transform, false); vHover = new UiHoverMeshRect(hoverObj, "Hover"); }