public static UIPanel CreateFormElement(UIComponent parent, string position)
        {
            UIPanel panel = parent.AddUIComponent <UIPanel>();

            panel.height              = 50;
            panel.width               = parent.width;
            panel.padding             = new RectOffset(5, 5, 0, 15);
            panel.autoLayout          = true;
            panel.autoLayoutDirection = LayoutDirection.Vertical;

            if (position == "top")
            {
                panel.height  = 65;
                panel.padding = new RectOffset(5, 5, 20, 15);
                panel.AlignTo(parent, UIAlignAnchor.TopLeft);
                panel.relativePosition = new Vector3(0, 0);
            }
            else if (position == "bottom")
            {
                panel.height = 40;
                panel.AlignTo(parent, UIAlignAnchor.BottomLeft);
                panel.relativePosition = new Vector3(0, 305);
            }
            else
            {
                panel.padding = new RectOffset(5, 5, 0, 0);
            }

            return(panel);
        }
Exemple #2
0
        private void CreateStopsPanel()
        {
            var parentHeight = 285f; //uiPanel.parent.height; broken due to autoformat

            UIPanel uiPanel = this._cityServiceWorldInfoPanel.component.AddUIComponent <UIPanel>();

            uiPanel.name = "ListBoxPanel";
            uiPanel.AlignTo(uiPanel.parent, UIAlignAnchor.TopRight);
            uiPanel.relativePosition = new Vector3(uiPanel.parent.width + 1f, VerticalOffset);
            uiPanel.width            = 180f;
            uiPanel.height           = parentHeight - 16f;
            uiPanel.backgroundSprite = "UnlockingPanel2";
            uiPanel.opacity          = 0.95f;
            this._listBoxPanel       = uiPanel;
            UILabel uiLabel = uiPanel.AddUIComponent <UILabel>();

            uiLabel.size          = new Vector2(180f, 20f);
            uiLabel.autoSize      = false;
            uiLabel.textAlignment = UIHorizontalAlignment.Center;
            uiLabel.font          = UIUtils.Font;
            uiLabel.position      = new Vector3((float)((double)uiPanel.width / 2.0 - (double)uiLabel.width / 2.0), (float)((double)uiLabel.height / 2.0 - 20.0));
            this._titleLabel      = uiLabel;
            StopListBox stopListBox = StopListBox.Create((UIComponent)uiPanel);

            stopListBox.name = "StationStopsListBox";
            stopListBox.AlignTo((UIComponent)uiPanel, UIAlignAnchor.TopLeft);
            stopListBox.relativePosition = new Vector3(3f, 40f);
            stopListBox.width            = uiPanel.width - 6f;
            stopListBox.height           = parentHeight - 61f;
            stopListBox.Font             = UIUtils.Font;
            this._stopsListBox           = stopListBox;
            VehicleListBox vehicleListBox = VehicleListBox.Create((UIComponent)uiPanel);

            vehicleListBox.name = "DepotVehiclesListBox";
            vehicleListBox.AlignTo((UIComponent)uiPanel, UIAlignAnchor.TopLeft);
            vehicleListBox.relativePosition = new Vector3(3f, 40f);
            vehicleListBox.width            = uiPanel.width - 6f;
            vehicleListBox.height           = parentHeight - 61f;
            vehicleListBox.Font             = UIUtils.Font;
            this._vehicleListBox            = vehicleListBox;
        }
        private void CreateExtenderPanel()
        {
            try
            {
                _extenderPanel = UIUtils.CreatePanel(_zonedBuildingWorldInfoPanel.component, "ShowItZonedBuildingExtenderPanel");

                int   columns;
                float gap;
                float separator;

                if (ModConfig.Instance.ExtendedPanelAlignment is "Bottom")
                {
                    _extenderPanel.AlignTo(_extenderPanel.parent, UIAlignAnchor.BottomLeft);
                    _extenderPanel.relativePosition = new Vector3(0f, _extenderPanel.parent.height - 15f);
                    _extenderPanel.width            = _extenderPanel.parent.width;
                    _extenderPanel.height           = 350f;
                    columns   = 6;
                    separator = 23;
                    gap       = 32;
                }
                else
                {
                    _extenderPanel.AlignTo(_extenderPanel.parent, UIAlignAnchor.TopRight);
                    _extenderPanel.relativePosition = new Vector3(_extenderPanel.parent.width + 1f, 0f);
                    _extenderPanel.width            = 340f;
                    _extenderPanel.height           = _extenderPanel.parent.height - 15f;
                    columns   = 5;
                    separator = 15;
                    gap       = 10;
                }

                _extenderPanel.backgroundSprite = ModConfig.Instance.ExtendedPanelBackgroundSprite ?? "InfoBubbleService";
                _extenderPanel.opacity          = ModConfig.Instance.ExtendedPanelOpacity > 0f ? ModConfig.Instance.ExtendedPanelOpacity : 0.95f;

                _headingLabel = UIUtils.CreateLabel(_extenderPanel, "ShowItZonedBuildingExtenderPanelHeading", "Indicators");
                _headingLabel.textAlignment = UIHorizontalAlignment.Center;
                _headingLabel.position      = new Vector3(_extenderPanel.width / 2f - _headingLabel.width / 2f, _headingLabel.height / 2f - 20f);

                _effectChartHover           = UIUtils.CreateSprite(_extenderPanel, "ShowItZonedBuildingExtenderPanelEffectChartHover", "ToolbarIconGroup1Hovered");
                _effectChartHover.size      = new Vector3(55f, 60f);
                _effectChartHover.isVisible = false;

                UIRadialChart impactChart;
                UILabel       impactOverlay;
                UILabel       impactLegend;
                UISprite      impactIcon;

                for (var i = 0; i < 20; i++)
                {
                    impactChart = UIUtils.CreateTwoSlicedRadialChart(_extenderPanel, "ShowItZonedBuildingExtenderPanelEffectChart" + i);
                    impactChart.AlignTo(_extenderPanel, UIAlignAnchor.TopRight);
                    impactChart.relativePosition = new Vector3((float)separator + i % columns * (impactChart.width + separator), (float)(separator + impactChart.width) + i / columns * (separator + impactChart.width) - gap);
                    impactChart.eventMouseEnter += new MouseEventHandler(this.OnImpactChartEnter);
                    impactChart.eventMouseLeave += new MouseEventHandler(this.OnImpactChartLeave);
                    impactChart.eventClick      += new MouseEventHandler(this.OnImpactChartClick);
                    _effectCharts.Add(i, impactChart);

                    impactOverlay = UIUtils.CreateLabel(impactChart, "ShowItZonedBuildingExtenderPanelOverlayLabel" + i, "");
                    impactOverlay.textAlignment = UIHorizontalAlignment.Center;
                    impactOverlay.textScale     = ModConfig.Instance.ExtendedPanelChartOverlayTextScale > 0f ? ModConfig.Instance.ExtendedPanelChartOverlayTextScale : 0.7f;
                    _effectOverlays.Add(i, impactOverlay);

                    if (ModConfig.Instance.ExtendedPanelChartHelp is "Icon")
                    {
                        impactIcon      = UIUtils.CreateSprite(impactChart, "ShowItZonedBuildingExtenderPanelIconSprite" + i, "");
                        impactIcon.size = new Vector3(ModConfig.Instance.ExtendedPanelChartIconSize > 0f ? ModConfig.Instance.ExtendedPanelChartIconSize : 25f, ModConfig.Instance.ExtendedPanelChartIconSize > 0f ? ModConfig.Instance.ExtendedPanelChartIconSize : 25f);
                        _effectIcons.Add(i, impactIcon);
                    }
                    else
                    {
                        impactLegend = UIUtils.CreateLabel(impactChart, "ShowItZonedBuildingExtenderPanelLegendLabel" + i, "");
                        impactLegend.textAlignment = UIHorizontalAlignment.Center;
                        impactLegend.textScale     = ModConfig.Instance.ExtendedPanelChartLegendTextScale > 0f ? ModConfig.Instance.ExtendedPanelChartLegendTextScale : 0.4f;
                        _effectLegends.Add(i, impactLegend);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log("[Show It!] ZonedBuildingExtenderPanel:CreateExtenderPanel -> Exception: " + e.Message);
            }
        }
        public override void Start()
        {
            base.Start();
            if (this._showPanel)
            {
                this.backgroundSprite = "ButtonMenu";
                this.eventMouseEnter += (MouseEventHandler)((component, param) => (component as DropDown).backgroundSprite = "ButtonMenuHovered");
                this.eventMouseLeave += (MouseEventHandler)((component, param) => (component as DropDown).backgroundSprite = "ButtonMenu");
            }
            this.zOrder = 1;
            UIButton uiButton = this.AddUIComponent <UIButton>();

            uiButton.width            = this.width;
            uiButton.height           = this.height;
            uiButton.relativePosition = new Vector3(0.0f, 0.0f);
            if ((UnityEngine.Object) this.Font != (UnityEngine.Object)null)
            {
                uiButton.font = this.Font;
            }
            uiButton.textScale               = 0.8f;
            uiButton.textVerticalAlignment   = UIVerticalAlignment.Middle;
            uiButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
            uiButton.textPadding             = new RectOffset(6, 0, 4, 0);
            uiButton.normalFgSprite          = "IconDownArrow";
            uiButton.hoveredFgSprite         = "IconDownArrowHovered";
            uiButton.pressedFgSprite         = "IconDownArrowPressed";
            uiButton.focusedFgSprite         = "IconDownArrow";
            uiButton.disabledFgSprite        = "IconDownArrowDisabled";
            uiButton.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            uiButton.horizontalAlignment     = UIHorizontalAlignment.Right;
            uiButton.verticalAlignment       = UIVerticalAlignment.Middle;
            uiButton.zOrder      = 0;
            uiButton.eventClick += new MouseEventHandler(this.OnButtonClick);
            this._triggerButton  = uiButton;
            this.Text            = "Default";
            UIPanel uiPanel1 = this.AddUIComponent(typeof(UIPanel)) as UIPanel;

            uiPanel1.name                = "PopUpPanel";
            uiPanel1.isVisible           = false;
            uiPanel1.width               = (double)this.ListWidth > 0.0 ? this.ListWidth : this.width;
            uiPanel1.height              = (float)(this._itemHeight * this._maxVisibleItems);
            uiPanel1.autoLayoutDirection = LayoutDirection.Horizontal;
            uiPanel1.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel1.autoLayoutPadding   = new RectOffset(0, 0, 0, 0);
            uiPanel1.autoLayout          = true;
            uiPanel1.backgroundSprite    = "GenericPanelWhite";
            uiPanel1.color               = (Color32)Color.black;
            uiPanel1.AlignTo(this._dropDownPanelAlignParent, UIAlignAnchor.TopLeft);
            this._dropDownPanel = uiPanel1;
            UIScrollablePanel uiScrollablePanel = uiPanel1.AddUIComponent <UIScrollablePanel>();

            uiScrollablePanel.width  = uiPanel1.width - 10f;
            uiScrollablePanel.height = uiPanel1.height;
            uiScrollablePanel.autoLayoutDirection = LayoutDirection.Vertical;
            uiScrollablePanel.autoLayoutStart     = LayoutStart.TopLeft;
            uiScrollablePanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 0);
            uiScrollablePanel.autoLayout          = true;
            uiScrollablePanel.clipChildren        = true;
            uiScrollablePanel.backgroundSprite    = "GenericPanelWhite";
            uiScrollablePanel.color = (Color32)Color.black;
            this._scrollablePanel   = uiScrollablePanel;
            UIPanel uiPanel2 = uiPanel1.AddUIComponent <UIPanel>();

            uiPanel2.width  = 10f;
            uiPanel2.height = uiPanel2.parent.height;
            uiPanel2.autoLayoutDirection = LayoutDirection.Horizontal;
            uiPanel2.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel2.autoLayoutPadding   = new RectOffset(0, 0, 0, 0);
            uiPanel2.autoLayout          = true;
            this._scrollbarPanel         = uiPanel2;
            UIScrollbar scrollbar = uiPanel2.AddUIComponent <UIScrollbar>();

            scrollbar.width       = 10f;
            scrollbar.height      = uiPanel2.height;
            scrollbar.orientation = UIOrientation.Vertical;
            scrollbar.pivot       = UIPivotPoint.BottomLeft;
            scrollbar.AlignTo((UIComponent)uiPanel2, UIAlignAnchor.TopRight);
            scrollbar.minValue        = 0.0f;
            scrollbar.value           = 0.0f;
            scrollbar.incrementAmount = (float)this._itemHeight;
            this._scrollbar           = scrollbar;
            UISlicedSprite uiSlicedSprite1 = scrollbar.AddUIComponent <UISlicedSprite>();

            uiSlicedSprite1.relativePosition = (Vector3)Vector2.zero;
            uiSlicedSprite1.autoSize         = true;
            uiSlicedSprite1.size             = uiSlicedSprite1.parent.size;
            uiSlicedSprite1.fillDirection    = UIFillDirection.Vertical;
            uiSlicedSprite1.spriteName       = "ScrollbarTrack";
            scrollbar.trackObject            = (UIComponent)uiSlicedSprite1;
            UISlicedSprite uiSlicedSprite2 = uiSlicedSprite1.AddUIComponent <UISlicedSprite>();

            uiSlicedSprite2.relativePosition        = (Vector3)Vector2.zero;
            uiSlicedSprite2.fillDirection           = UIFillDirection.Vertical;
            uiSlicedSprite2.autoSize                = true;
            uiSlicedSprite2.width                   = uiSlicedSprite2.parent.width - 4f;
            uiSlicedSprite2.spriteName              = "ScrollbarThumb";
            scrollbar.thumbObject                   = (UIComponent)uiSlicedSprite2;
            this._scrollablePanel.verticalScrollbar = scrollbar;
            this._scrollablePanel.eventMouseWheel  += (MouseEventHandler)((component, param) => this._scrollablePanel.scrollPosition += new Vector2(0.0f, Mathf.Sign(param.wheelDelta) * -1f * scrollbar.incrementAmount));
        }