public void SetupScrollPanel() { //this probably needs to exist, otherwise the autoLayout of this UITransportPanel places the scrollbar weird _panelForScrollPanel = AddUIComponent <UIPanel>(); // needed so that the colorpicker finds the right parent _panelForScrollPanel.gameObject.AddComponent <UICustomControl>(); _panelForScrollPanel.width = width - 6; //_captions reporting 450 height? fixed value of 20 _panelForScrollPanel.height = height - _title.height - 20 * 2 - autoLayoutPadding.bottom * 4 - autoLayoutPadding.top * 4; // taken from http://www.reddit.com/r/CitiesSkylinesModding/comments/2zrz0k/extended_public_transport_ui_provides_addtional/cpnet5q _scrollablePanel = _panelForScrollPanel.AddUIComponent <UIScrollablePanel>(); _scrollablePanel.width = _scrollablePanel.parent.width - 5f; _scrollablePanel.height = _scrollablePanel.parent.height; _scrollablePanel.autoLayout = true; _scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; _scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; _scrollablePanel.autoLayoutPadding = new RectOffset(2, 5, 0, 0); _scrollablePanel.clipChildren = true; _scrollablePanel.pivot = UIPivotPoint.TopLeft; _scrollablePanel.AlignTo(_scrollablePanel.parent, UIAlignAnchor.TopLeft); UIScrollbar scrollbar = _panelForScrollPanel.AddUIComponent <UIScrollbar>(); scrollbar.width = scrollbar.parent.width - _scrollablePanel.width; scrollbar.height = _scrollablePanel.height; scrollbar.orientation = UIOrientation.Vertical; scrollbar.pivot = UIPivotPoint.BottomLeft; scrollbar.AlignTo(scrollbar.parent, UIAlignAnchor.TopRight); scrollbar.minValue = 0; scrollbar.value = 0; scrollbar.incrementAmount = 50; UISlicedSprite tracSprite = scrollbar.AddUIComponent <UISlicedSprite>(); tracSprite.relativePosition = Vector2.zero; tracSprite.autoSize = true; tracSprite.size = tracSprite.parent.size; tracSprite.fillDirection = UIFillDirection.Vertical; tracSprite.spriteName = "ScrollbarTrack"; scrollbar.trackObject = tracSprite; UISlicedSprite thumbSprite = tracSprite.AddUIComponent <UISlicedSprite>(); thumbSprite.relativePosition = Vector2.zero; thumbSprite.fillDirection = UIFillDirection.Vertical; thumbSprite.autoSize = true; thumbSprite.width = thumbSprite.parent.width; thumbSprite.spriteName = "ScrollbarThumb"; scrollbar.thumbObject = thumbSprite; _scrollablePanel.verticalScrollbar = scrollbar; _scrollablePanel.eventMouseWheel += (component, param) => { var sign = Math.Sign(param.wheelDelta); _scrollablePanel.scrollPosition += new Vector2(0, sign * (-1) * 20); }; }
private void SetupScrollPanel() { //this probably needs to exist, otherwise the autoLayout of this UITransportPanel places the scrollbar weird _panelForScrollPanel = AddUIComponent<UIPanel> (); // needed so that the colorpicker finds the right parent _panelForScrollPanel.gameObject.AddComponent<UICustomControl>(); _panelForScrollPanel.width = width - 6; //_captions reporting 450 height? fixed value of 20 _panelForScrollPanel.height = height - _title.height - _buttons.height - 20 - autoLayoutPadding.bottom * 4 - autoLayoutPadding.top * 4; // taken from http://www.reddit.com/r/CitiesSkylinesModding/comments/2zrz0k/extended_public_transport_ui_provides_addtional/cpnet5q _scrollablePanel = _panelForScrollPanel.AddUIComponent<UIScrollablePanel> (); _scrollablePanel.width = _scrollablePanel.parent.width - 5f; _scrollablePanel.height = _scrollablePanel.parent.height; _scrollablePanel.autoLayout = true; _scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; _scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; _scrollablePanel.autoLayoutPadding = new RectOffset (0, 0, 1, 1); _scrollablePanel.clipChildren = true; _scrollablePanel.pivot = UIPivotPoint.TopLeft; _scrollablePanel.AlignTo (_scrollablePanel.parent, UIAlignAnchor.TopLeft); UIScrollbar scrollbar = _panelForScrollPanel.AddUIComponent<UIScrollbar> (); scrollbar.width = scrollbar.parent.width - _scrollablePanel.width; scrollbar.height = scrollbar.parent.height; scrollbar.orientation = UIOrientation.Vertical; scrollbar.pivot = UIPivotPoint.BottomLeft; scrollbar.AlignTo (scrollbar.parent, UIAlignAnchor.TopRight); scrollbar.minValue = 0; scrollbar.value = 0; scrollbar.incrementAmount = 50; UISlicedSprite tracSprite = scrollbar.AddUIComponent<UISlicedSprite> (); tracSprite.relativePosition = Vector2.zero; tracSprite.autoSize = true; tracSprite.size = tracSprite.parent.size; tracSprite.fillDirection = UIFillDirection.Vertical; tracSprite.spriteName = "ScrollbarTrack"; scrollbar.trackObject = tracSprite; UISlicedSprite thumbSprite = tracSprite.AddUIComponent<UISlicedSprite> (); thumbSprite.relativePosition = Vector2.zero; thumbSprite.fillDirection = UIFillDirection.Vertical; thumbSprite.autoSize = true; thumbSprite.width = thumbSprite.parent.width; thumbSprite.spriteName = "ScrollbarThumb"; scrollbar.thumbObject = thumbSprite; _scrollablePanel.verticalScrollbar = scrollbar; _scrollablePanel.eventMouseWheel += (component, param) => { var sign = Math.Sign(param.wheelDelta); _scrollablePanel.scrollPosition += new Vector2(0, sign*(-1) * 20); }; }
private void SetupScrollPanel() { ModLogger.Debug("Setting up scroll panel"); // Create the main panel hosting the scrollable panel _mainPanel = AddUIComponent<UIPanel>(); _mainPanel.gameObject.AddComponent<UICustomControl>(); _mainPanel.width = width - UIConstants.MainWindowMainPanelWidthOffset; int[] offsettingItems = new int[] { UIConstants.TitlePanelHeight, UIConstants.CaptionPanelLabelOffset, UIConstants.CaptionPanelHeight, UIConstants.FilterPanelHeight, autoLayoutPadding.bottom * 4, autoLayoutPadding.top * 4 }; _mainPanel.height = height - offsettingItems.Sum(); // taken from http://www.reddit.com/r/CitiesSkylinesModding/comments/2zrz0k/extended_public_transport_ui_provides_addtional/cpnet5q _scrollablePanel = _mainPanel.AddUIComponent<UIScrollablePanel>(); _scrollablePanel.width = _scrollablePanel.parent.width - UIConstants.MainWindowScrollablePanelWidthOffset - 10; _scrollablePanel.height = _scrollablePanel.parent.height; _scrollablePanel.autoLayout = true; _scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; _scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; _scrollablePanel.autoLayoutPadding = UIConstants.AutoLayoutPadding; _scrollablePanel.clipChildren = true; _scrollablePanel.pivot = UIPivotPoint.TopLeft; _scrollablePanel.AlignTo(_scrollablePanel.parent, UIAlignAnchor.TopLeft); _scrollablePanel.relativePosition = new Vector3(5, 0); UIScrollbar scrollbar = _mainPanel.AddUIComponent<UIScrollbar>(); scrollbar.width = scrollbar.parent.width - _scrollablePanel.width; scrollbar.height = scrollbar.parent.height; scrollbar.orientation = UIOrientation.Vertical; scrollbar.pivot = UIPivotPoint.BottomLeft; scrollbar.AlignTo(scrollbar.parent, UIAlignAnchor.TopRight); scrollbar.minValue = 0; scrollbar.value = 0; scrollbar.incrementAmount = UIConstants.ScrollbarIncrementCount; UISlicedSprite trackSprite = scrollbar.AddUIComponent<UISlicedSprite>(); trackSprite.relativePosition = Vector2.zero; trackSprite.autoSize = true; trackSprite.size = trackSprite.parent.size; trackSprite.fillDirection = UIFillDirection.Vertical; trackSprite.spriteName = UIConstants.ScrollbarTrackSprite; scrollbar.trackObject = trackSprite; UISlicedSprite thumbSprite = trackSprite.AddUIComponent<UISlicedSprite>(); thumbSprite.relativePosition = Vector2.zero; thumbSprite.fillDirection = UIFillDirection.Vertical; thumbSprite.autoSize = true; thumbSprite.width = thumbSprite.parent.width; thumbSprite.spriteName = UIConstants.ScrollbarThumbSprite; scrollbar.thumbObject = thumbSprite; _scrollablePanel.verticalScrollbar = scrollbar; _scrollablePanel.eventMouseWheel += (component, param) => { var sign = Math.Sign(param.wheelDelta); _scrollablePanel.scrollPosition += new Vector2(0, sign * (-1) * UIConstants.ScrollbarMouseWheelOffset); }; ModLogger.Debug("Scroll panel set up"); }
private void SetupScrollPanel() { ModLogger.Debug("Setting up scroll panel"); // Create the main panel hosting the scrollable panel _mainPanel = AddUIComponent <UIPanel>(); _mainPanel.gameObject.AddComponent <UICustomControl>(); _mainPanel.width = width - UIConstants.MainWindowMainPanelWidthOffset; int[] offsettingItems = new int[] { UIConstants.TitlePanelHeight, UIConstants.CaptionPanelLabelOffset, UIConstants.CaptionPanelHeight, UIConstants.FilterPanelHeight, autoLayoutPadding.bottom * 4, autoLayoutPadding.top * 4 }; _mainPanel.height = height - offsettingItems.Sum(); // taken from http://www.reddit.com/r/CitiesSkylinesModding/comments/2zrz0k/extended_public_transport_ui_provides_addtional/cpnet5q _scrollablePanel = _mainPanel.AddUIComponent <UIScrollablePanel>(); _scrollablePanel.width = _scrollablePanel.parent.width - UIConstants.MainWindowScrollablePanelWidthOffset - 10; _scrollablePanel.height = _scrollablePanel.parent.height; _scrollablePanel.autoLayout = true; _scrollablePanel.autoLayoutDirection = LayoutDirection.Vertical; _scrollablePanel.autoLayoutStart = LayoutStart.TopLeft; _scrollablePanel.autoLayoutPadding = UIConstants.AutoLayoutPadding; _scrollablePanel.clipChildren = true; _scrollablePanel.pivot = UIPivotPoint.TopLeft; _scrollablePanel.AlignTo(_scrollablePanel.parent, UIAlignAnchor.TopLeft); _scrollablePanel.relativePosition = new Vector3(5, 0); UIScrollbar scrollbar = _mainPanel.AddUIComponent <UIScrollbar>(); scrollbar.width = scrollbar.parent.width - _scrollablePanel.width; scrollbar.height = scrollbar.parent.height; scrollbar.orientation = UIOrientation.Vertical; scrollbar.pivot = UIPivotPoint.BottomLeft; scrollbar.AlignTo(scrollbar.parent, UIAlignAnchor.TopRight); scrollbar.minValue = 0; scrollbar.value = 0; scrollbar.incrementAmount = UIConstants.ScrollbarIncrementCount; UISlicedSprite trackSprite = scrollbar.AddUIComponent <UISlicedSprite>(); trackSprite.relativePosition = Vector2.zero; trackSprite.autoSize = true; trackSprite.size = trackSprite.parent.size; trackSprite.fillDirection = UIFillDirection.Vertical; trackSprite.spriteName = UIConstants.ScrollbarTrackSprite; scrollbar.trackObject = trackSprite; UISlicedSprite thumbSprite = trackSprite.AddUIComponent <UISlicedSprite>(); thumbSprite.relativePosition = Vector2.zero; thumbSprite.fillDirection = UIFillDirection.Vertical; thumbSprite.autoSize = true; thumbSprite.width = thumbSprite.parent.width; thumbSprite.spriteName = UIConstants.ScrollbarThumbSprite; scrollbar.thumbObject = thumbSprite; _scrollablePanel.verticalScrollbar = scrollbar; _scrollablePanel.eventMouseWheel += (component, param) => { var sign = Math.Sign(param.wheelDelta); _scrollablePanel.scrollPosition += new Vector2(0, sign * (-1) * UIConstants.ScrollbarMouseWheelOffset); }; ModLogger.Debug("Scroll panel set up"); }