Esempio n. 1
0
        public override void Awake()
        {
            base.Awake();
            name   = nameof(UICheckBoxExt);
            height = 30;
            width  = 100;

            //clipChildren = true;

            UISprite sprite = AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(height, height);
            sprite.relativePosition = new Vector2(0, (height - sprite.height) / 2);
            sprite.atlas            = TextureUtil.Ingame;


            var sprite2 = sprite.AddUIComponent <UISprite>();

            sprite2.atlas                     = TextureUtil.Ingame;
            sprite2.spriteName                = "ToggleBaseFocused";
            checkedBoxObject                  = sprite2;
            checkedBoxObject.size             = sprite.size;
            checkedBoxObject.relativePosition = Vector3.zero;

            label                  = AddUIComponent <UILabel>();
            label.text             = GetType().Name;
            label.textScale        = 0.9f;
            label.relativePosition = new Vector2(
                sprite.width + 5f,
                (height - label.height) / 2 + 1);

            eventCheckChanged += OnCheckChanged;
        }
        public static UICheckBox CreateCheckBox(UIComponent parent, string text)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 300f;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            //sprite.atlas = GetAtlas("Ingame");
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = new Vector3(0f, 0f);

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            //((UISprite)checkBox.checkedBoxObject).atlas = GetAtlas("Ingame");
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = new Vector3(0f, 0f);

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = text;
            checkBox.label.textScale        = 0.95f;
            checkBox.label.relativePosition = new Vector3(22f, 0f);

            return(checkBox);
        }
        private UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = (UICheckBox)parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 300f;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.atlas            = m_toolOptionsPanel.atlas;
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = m_toolOptionsPanel.atlas;
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            return(checkBox);
        }
        public override void Awake()
        {
            base.Awake();
            name         = nameof(UIUnFlattenJunctionsCheckbox);
            height       = 20f;
            clipChildren = true;

            UISprite sprite = AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(20f, 20f);
            sprite.relativePosition = new Vector2(0, (height - sprite.height) / 2);
            sprite.atlas            = TextureUtil.Ingame;

            checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkedBoxObject).spriteName = "ToggleBaseFocused";
            ((UISprite)checkedBoxObject).atlas      = TextureUtil.Ingame;
            checkedBoxObject.size             = sprite.size;
            checkedBoxObject.relativePosition = Vector3.zero;

            label                  = AddUIComponent <UILabel>();
            label.text             = "flatten segment end";
            label.textScale        = 0.9f;
            label.relativePosition = new Vector2(sprite.width + 5f, (height - label.height) / 2 + 1);

            eventCheckChanged += OnCheckChanged;
        }
Esempio n. 5
0
        /********** Custom Methods **********/

        private void HookToMainToolBar()
        {
            UISprite _demandBack = (UISprite)oGameNativeUI.FindUIComponent("DemandBack");

            oDemandTriggerButton = _demandBack.AddUIComponent <RCIButton>();
            CreateButton(ref oDemandTriggerButton);
        }
Esempio n. 6
0
        private void CreateEventBlock(double startPercent, double endPercent, Color32 colour, ushort buildingId, string tooltip = "")
        {
            int padding = 2;

            float startPosition = (float)(_newDayProgressSprite.width * startPercent);
            float endPosition   = (float)(_newDayProgressSprite.width * endPercent);
            int   endWidth      = (int)Mathf.Round(endPosition - startPosition);

            UISprite eventSprite = _newDayProgressSprite.AddUIComponent <UISprite>();

            eventSprite.relativePosition = new Vector3(startPosition, padding);
            eventSprite.atlas            = _newDayProgressSprite.atlas;
            eventSprite.spriteName       = _newDayProgressSprite.spriteName;
            eventSprite.height           = _newDayProgressSprite.height - (padding * 2);
            eventSprite.width            = endWidth;
            eventSprite.fillDirection    = UIFillDirection.Horizontal;
            eventSprite.color            = colour;
            eventSprite.fillAmount       = 1F;
            eventSprite.tooltip          = tooltip;
            eventSprite.eventClicked    += ((component, eventHandler) =>
            {
                InstanceID instance = new InstanceID();
                instance.Building = buildingId;

                cameraController.SetTarget(instance, Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].m_position, true);
            });

            _eventBars.Add(eventSprite);
        }
Esempio n. 7
0
        /// <summary>
        /// Adds an icon toggle checkbox.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative X position</param>
        /// <param name="yPos">Relative Y position</param>
        /// <param name="atlasName">Atlas name (for loading from file)</param>
        /// <param name="tooltipKey">Tooltip translation key</param>
        /// <returns>New checkbox</returns>
        protected UICheckBox IconToggleCheck(UIComponent parent, float xPos, float yPos, string atlasName, string tooltipKey)
        {
            // Size and position.
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.width            = ToggleSize;
            checkBox.height           = ToggleSize;
            checkBox.clipChildren     = true;
            checkBox.relativePosition = new Vector2(xPos, yPos);

            // Checkbox sprites.
            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.name             = "UncheckedSprite";
            sprite.atlas            = TextureUtils.LoadSpriteAtlas(atlasName);
            sprite.spriteName       = "disabled";
            sprite.size             = new Vector2(ToggleSize, ToggleSize);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = TextureUtils.LoadSpriteAtlas(atlasName);
            ((UISprite)checkBox.checkedBoxObject).spriteName = "pressed";
            checkBox.checkedBoxObject.size             = new Vector2(ToggleSize, ToggleSize);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.tooltip = Translations.Translate(tooltipKey);

            return(checkBox);
        }
Esempio n. 8
0
        private void CreateCheckbox()
        {
            _checkboxPanel      = AddUIComponent <UIPanel>();
            _checkboxPanel.size = new Vector2(66.0f, 66.0f);

            _favouriteCheckbox                  = _checkboxPanel.AddUIComponent <UICheckBox>();
            _favouriteCheckbox.size             = new Vector2(22f, 22f);
            _favouriteCheckbox.relativePosition = new Vector3(22.0f, 22.0f);

            _uncheckedSprite                  = _favouriteCheckbox.AddUIComponent <UISprite>();
            _uncheckedSprite.atlas            = UISprites.Atlas;
            _uncheckedSprite.spriteName       = UISprites.StarOutline;
            _uncheckedSprite.size             = _favouriteCheckbox.size;
            _uncheckedSprite.relativePosition = Vector3.zero;

            _checkedSprite                  = _uncheckedSprite.AddUIComponent <UISprite>();
            _checkedSprite.atlas            = UISprites.Atlas;
            _checkedSprite.spriteName       = UISprites.Star;
            _checkedSprite.size             = _favouriteCheckbox.size;
            _checkedSprite.relativePosition = Vector2.zero;

            _favouriteCheckbox.checkedBoxObject = _checkedSprite;
            _favouriteCheckbox.eventMouseUp    += OnFavouriteCheckboxMouseUp;
            _favouriteCheckbox.isChecked        = false;
        }
Esempio n. 9
0
        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox uiCheckBox = parent.AddUIComponent <UICheckBox>();
            Vector2    size       = parent.size;

            uiCheckBox.size = size;
            int num = 1;

            uiCheckBox.clipChildren = num != 0;
            UISprite uiSprite1 = uiCheckBox.AddUIComponent <UISprite>();

            uiSprite1.spriteName       = "check-unchecked";
            uiSprite1.size             = new Vector2(16f, 16f);
            uiSprite1.relativePosition = Vector3.zero;
            UISprite uiSprite2 = uiSprite1.AddUIComponent <UISprite>();

            uiCheckBox.checkedBoxObject = (UIComponent)uiSprite2;
            ((UISprite)uiCheckBox.checkedBoxObject).spriteName = "check-checked";
            uiCheckBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            uiCheckBox.checkedBoxObject.relativePosition = Vector3.zero;
            UILabel uiLabel = uiCheckBox.AddUIComponent <UILabel>();

            uiCheckBox.label                  = uiLabel;
            uiCheckBox.label.font             = UIUtils.Font;
            uiCheckBox.label.textColor        = (Color32)Color.white;
            uiCheckBox.label.textScale        = 0.8f;
            uiCheckBox.label.relativePosition = new Vector3(22f, 2f);
            return(uiCheckBox);
        }
Esempio n. 10
0
        public static UICheckBox CreateCheckBox(this UIComponent uiComponent, string text, Vector2 position)
        {
            UICheckBox checkBox = (UICheckBox)uiComponent.AddUIComponent(typeof(UICheckBox));

            checkBox.width        = 300f;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;
            checkBox.position     = position;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.atlas            = GetAtlas("Ingame");
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = GetAtlas("Ingame");
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;
            checkBox.checkedBoxObject.isInteractive    = false;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = text;
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            return(checkBox);
        }
Esempio n. 11
0
        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = (UICheckBox)parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 300f;
            checkBox.height       = 28f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.atlas            = GetAtlas("Ingame");
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = new Vector3(8f, 6f);

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = GetAtlas("Ingame");
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.75f;
            checkBox.label.relativePosition = new Vector3(30f, 8f);
            checkBox.label.color            = new Color32(255, 255, 255, 200);

            return(checkBox);
        }
        public override void Awake()
        {
            base.Awake();
            Instance     = this;
            name         = nameof(UIHideMarkingsCheckbox);
            height       = 30f;
            clipChildren = true;

            UISprite sprite = AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(19f, 19f);
            sprite.relativePosition = new Vector2(0, (height - sprite.height) / 2);
            sprite.atlas            = KianCommons.UI.TextureUtil.GetAtlas("InGame");
            sprite.atlas            = TextureUtil.Ingame;

            checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkedBoxObject).spriteName = "ToggleBaseFocused";
            ((UISprite)checkedBoxObject).atlas      = TextureUtil.Ingame;
            checkedBoxObject.size             = sprite.size;
            checkedBoxObject.relativePosition = Vector3.zero;

            label                  = AddUIComponent <UILabel>();
            label.text             = "No junction markings";
            label.textScale        = 0.9f;
            label.relativePosition = new Vector2(sprite.width + 5f, (height - label.height) / 2 + 1);

            eventCheckChanged += OnCheckChanged;
        }
Esempio n. 13
0
        private void DisplayCityEvent(ICityEvent cityEvent, DateTime todayStart, DateTime todayEnd)
        {
            float startPercent = cityEvent.StartTime <= todayStart
                ? 0
                : (float)cityEvent.StartTime.TimeOfDay.TotalHours / 24f;

            float endPercent = cityEvent.EndTime >= todayEnd
                ? 1f
                : (float)cityEvent.EndTime.TimeOfDay.TotalHours / 24f;

            float startPosition = progressSprite.width * startPercent;
            float endPosition   = progressSprite.width * endPercent;

            UISprite eventSprite = progressSprite.AddUIComponent <UISprite>();

            eventSprite.name             = UISpriteEvent + cityEvent.BuildingId;
            eventSprite.relativePosition = new Vector3(startPosition, 0);
            eventSprite.atlas            = progressSprite.atlas;
            eventSprite.spriteName       = progressSprite.spriteName;
            eventSprite.height           = progressSprite.height;
            eventSprite.width            = endPosition - startPosition;
            eventSprite.fillDirection    = UIFillDirection.Horizontal;
            eventSprite.color            = EventColor;
            eventSprite.fillAmount       = 1f;
            eventSprite.objectUserData   = cityEvent;
            eventSprite.eventClicked    += EventSprite_Clicked;
            SetEventTooltip(eventSprite, todayStart, todayEnd);
        }
Esempio n. 14
0
        public static UICheckBox CreateIconToggle(UIComponent parent, string atlas, string checkedSprite, string uncheckedSprite)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 35f;
            checkBox.height       = 35f;
            checkBox.clipChildren = true;

            UIPanel panel = checkBox.AddUIComponent <UIPanel>();

            panel.atlas            = GetAtlas("Ingame");
            panel.backgroundSprite = "IconPolicyBaseRect";
            panel.size             = checkBox.size;
            panel.relativePosition = Vector3.zero;

            checkBox.eventCheckChanged += (c, b) =>
            {
                if (checkBox.isChecked)
                {
                    panel.backgroundSprite = "IconPolicyBaseRect";
                }
                else
                {
                    panel.backgroundSprite = "IconPolicyBaseRectDisabled";
                }
                panel.Invalidate();
            };

            checkBox.eventMouseEnter += (c, p) =>
            {
                panel.backgroundSprite = "IconPolicyBaseRectHovered";
            };

            checkBox.eventMouseLeave += (c, p) =>
            {
                if (checkBox.isChecked)
                {
                    panel.backgroundSprite = "IconPolicyBaseRect";
                }
                else
                {
                    panel.backgroundSprite = "IconPolicyBaseRectDisabled";
                }
            };

            UISprite sprite = panel.AddUIComponent <UISprite>();

            sprite.atlas            = GetAtlas(atlas);
            sprite.spriteName       = uncheckedSprite;
            sprite.size             = checkBox.size;
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = sprite.atlas;
            ((UISprite)checkBox.checkedBoxObject).spriteName = checkedSprite;
            checkBox.checkedBoxObject.size             = checkBox.size;
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            return(checkBox);
        }
Esempio n. 15
0
        /* The code below was copied from Fine Road Tool and More Shortcuts mod by SamsamTS. Thanks! */

        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = (UICheckBox)parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 300f;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.atlas            = ResourceLoader.GetAtlas("Ingame");
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = ResourceLoader.GetAtlas("Ingame");
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            checkBox.playAudioEvents = true;

            return(checkBox);
        }
Esempio n. 16
0
        /// <summary>
        /// Adds a checkbox without a label.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative x position</param>
        /// <param name="yPos">Relative y position</param>
        /// <param name="size">Checkbox size (default 16f)</param>
        /// <param name="tooltip">Tooltip, if any</param>
        /// <returns>New UI checkbox *without* attached labels</returns>
        public static UICheckBox AddCheckBox(UIComponent parent, float xPos, float yPos, float size = 16f, string tooltip = null)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            // Size and position.
            checkBox.width            = size;
            checkBox.height           = size;
            checkBox.clipChildren     = false;
            checkBox.relativePosition = new Vector3(xPos, yPos);

            // Sprites.
            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "check-unchecked";
            sprite.size             = new Vector2(size, size);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "check-checked";
            checkBox.checkedBoxObject.size             = new Vector2(size, size);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            // Add tooltip.
            if (tooltip != null)
            {
                checkBox.tooltip = tooltip;
            }

            return(checkBox);
        }
Esempio n. 17
0
        public override void Awake()
        {
            base.Awake();
            Instance     = this;
            name         = nameof(TwistCheckbox);
            height       = 20f;
            clipChildren = true;

            UISprite sprite = UncheckedSprite = AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(20f, 20f);
            sprite.relativePosition = new Vector2(0, (height - sprite.height) / 2);

            checkedBoxObject = CheckedSprite = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkedBoxObject.size             = sprite.size;
            checkedBoxObject.relativePosition = Vector3.zero;

            label                  = AddUIComponent <UILabel>();
            label.text             = "Twist segment ends";
            label.textScale        = 0.9f;
            label.relativePosition = new Vector2(sprite.width + 5f, (height - label.height) / 2 + 1);

            eventCheckChanged += OnCheckChanged;
        }
Esempio n. 18
0
        public static UICheckBox CreateCheckBox(UIComponent parent, int offset, string label)
        {
            UIPanel container = parent.AddUIComponent <UIPanel>();

            container.height           = 25;
            container.width            = 240;
            container.relativePosition = new Vector3(0, offset, 0);

            UICheckBox checkBox = container.AddUIComponent <UICheckBox>();

            checkBox.width            = container.width;
            checkBox.height           = 20f;
            checkBox.clipChildren     = true;
            checkBox.relativePosition = new Vector3(200, 6);

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            UILabel serviceLabel = container.AddUIComponent <UILabel>();

            serviceLabel.textScale        = 0.8f;
            serviceLabel.text             = label;
            serviceLabel.relativePosition = new Vector3(15, 6, 0);

            return(checkBox);
        }
Esempio n. 19
0
        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = (UICheckBox)parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 300f;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.atlas            = GetAtlas("Ingame");
            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = GetAtlas("Ingame");
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;
            checkBox.checkedBoxObject.isInteractive    = false; // Don't eat my double click event please

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            return(checkBox);
        }
        public static UICheckBox CreateCheckBox(UIComponent parent)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.width            = parent.width - 10;
            checkBox.height           = 20f;
            checkBox.relativePosition = new Vector3(5, 0);

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "InfoIconBaseHovered";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = new Vector3(355, 0);

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "InfoIconBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.autoSize               = false;
            checkBox.label.textScale        = 0.9f;
            checkBox.label.width            = parent.width - 22;
            checkBox.label.relativePosition = Vector2.zero;

            return(checkBox);
        }
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (_HistoricalStatusCheckBox != null)
            {
                return;
            }

            ZonedBuildingWorldInfoPanel panel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);
            UICheckBox checkBox = panel.component.AddUIComponent <UICheckBox>();

            checkBox.width        = panel.component.width;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            checkBox.name = "HistoricalStatus";
            checkBox.text = "Historical Status";

            checkBox.relativePosition = new Vector3(14f, 164f + 130f + 5f);

            panel.component.height = 321f + 5f + 16f;

            _HistoricalStatusCheckBox = checkBox;

            checkBox.eventCheckChanged += (component, check) =>
            {
                ushort buildingId = WorldInfoPanel.GetCurrentInstanceID().Building;

                if (check)
                {
                    HistoricalStatusDataManager.Instance.AddBuildingId(buildingId);
                }
                else
                {
                    HistoricalStatusDataManager.Instance.RemoveBuildingId(buildingId);
                }
            };
        }
Esempio n. 22
0
        public void Initialise()
        {
            UIPanel _uiPanel   = UIView.Find <UIPanel>("InfoPanel");
            UIPanel _panelTime = _uiPanel == null ? null : _uiPanel.Find <UIPanel>("PanelTime");

            _oldDayProgressSprite = _panelTime == null ? null : _panelTime.Find <UISprite>("Sprite");
            UILabel _dateLabel = _oldDayProgressSprite == null ? null : _oldDayProgressSprite.Find <UILabel>("Time");

            if (_uiPanel != null && _panelTime != null && _oldDayProgressSprite != null && _dateLabel != null)
            {
                _newDayProgressSprite                  = _panelTime.AddUIComponent <UISprite>();
                _newDayProgressSprite.name             = "NewSprite";
                _newDayProgressSprite.relativePosition = _oldDayProgressSprite.relativePosition;
                _newDayProgressSprite.atlas            = _oldDayProgressSprite.atlas;
                _newDayProgressSprite.spriteName       = _oldDayProgressSprite.spriteName;
                _newDayProgressSprite.size             = _oldDayProgressSprite.size;
                _newDayProgressSprite.fillAmount       = 0.5f;
                _newDayProgressSprite.fillDirection    = UIFillDirection.Horizontal;
                _newDayProgressSprite.color            = new Color32(255, 255, 255, 255);

                _newDayProgressLabel                   = _newDayProgressSprite.AddUIComponent <UILabel>();
                _newDayProgressLabel.name              = "NewTime";
                _newDayProgressLabel.autoSize          = false;
                _newDayProgressLabel.autoHeight        = false;
                _newDayProgressLabel.font              = _dateLabel.font;
                _newDayProgressLabel.atlas             = _dateLabel.atlas;
                _newDayProgressLabel.color             = _dateLabel.color;
                _newDayProgressLabel.textColor         = _dateLabel.textColor;
                _newDayProgressLabel.size              = _newDayProgressSprite.size;
                _newDayProgressLabel.width             = _newDayProgressSprite.width;
                _newDayProgressLabel.height            = _newDayProgressSprite.height;
                _newDayProgressLabel.textAlignment     = UIHorizontalAlignment.Center;
                _newDayProgressLabel.verticalAlignment = UIVerticalAlignment.Middle;
                _newDayProgressLabel.relativePosition  = new Vector3(0, 0, 0);
                _newDayProgressLabel.isInteractive     = false;

                _oldDayProgressSprite.Hide();

                InitialiseUpdatePanel(_newDayProgressSprite);
                Update();
            }
            else
            {
                Debug.LogWarning("Didn't replace sprite.");
            }

            CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += new LanguageChangedEventHandler(delegate(string languageIdentifier)
            {
                UpdateEventBlocks();
            });

            Debug.Log("Rush Hour: DateTimeBar initialised");
        }
Esempio n. 23
0
 private void CreateCheckbox()
 {
     checkboxPanel                      = AddUIComponent <UIPanel>();
     checkboxPanel.size                 = new Vector2(22.0f, 30.0f);
     favouriteCheckbox                  = checkboxPanel.AddUIComponent <UICheckBox>();
     favouriteCheckbox.size             = new Vector2(22f, 22f);
     favouriteCheckbox.relativePosition = new Vector3(0.0f, 4.0f);
     uncheckedSprite                    = favouriteCheckbox.AddUIComponent <UISprite>();
     uncheckedSprite.atlas              = Resources.Atlas;
     uncheckedSprite.spriteName         = Resources.StarOutline;
     uncheckedSprite.size               = favouriteCheckbox.size;
     uncheckedSprite.relativePosition   = Vector3.zero;
     checkedSprite                      = uncheckedSprite.AddUIComponent <UISprite>();
     checkedSprite.atlas                = Resources.Atlas;
     checkedSprite.spriteName           = Resources.Star;
     checkedSprite.size                 = favouriteCheckbox.size;
     checkedSprite.relativePosition     = Vector2.zero;
     favouriteCheckbox.checkedBoxObject = checkedSprite;
     favouriteCheckbox.eventMouseUp    += OnFavouriteCheckboxMouseUp;
 }
            public override void Awake()
            {
                base.Awake();

                this.position = new Vector3(45, -4);
                this.size     = new Vector2(30f, 40f);

                // Enable/disable checkbox
                checkBox          = this.AddUIComponent <UICheckBox>();
                checkBox.position = new Vector3(6, 0);
                checkBox.size     = new Vector2(30, 20);

                UISprite sprite = checkBox.AddUIComponent <UISprite>();

                sprite.spriteName       = "ToggleBase";
                sprite.size             = new Vector2(16f, 16f);
                sprite.relativePosition = new Vector3(2f, 2f);

                checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
                ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
                checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
                checkBox.checkedBoxObject.relativePosition = Vector3.zero;

                // Options button
                btn                 = this.AddUIComponent <UIButton>();
                btn.position        = new Vector3(0, -20);
                btn.size            = new Vector2(30, 16);
                btn.text            = "...";
                btn.textColor       = Color.white;
                btn.normalBgSprite  = "ButtonMenu";
                btn.hoveredBgSprite = "ButtonMenuHovered";
                btn.eventClick     += delegate(UIComponent component, UIMouseEventParameter eventParam)
                {
                    if (!string.IsNullOrEmpty(budgetItemName))
                    {
                        BudgetControlsManager.showOptionsPanel(budgetItemName);
                    }
                };
            }
Esempio n. 25
0
        /// <summary>
        /// Adds a checkbox without a label.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative x position</param>
        /// <param name="yPos">Relative y position</param>
        /// <returns>New UI checkbox *without* attached labels</returns>
        public static UICheckBox AddCheckBox(UIComponent parent, float xPos, float yPos)
        {
            UICheckBox checkBox = parent.AddUIComponent<UICheckBox>();

            // Size and position.
            checkBox.height = 16f;
            checkBox.width = 16f;
            checkBox.clipChildren = false;
            checkBox.relativePosition = new Vector3(xPos, yPos);

            // Sprites.
            UISprite sprite = checkBox.AddUIComponent<UISprite>();
            sprite.spriteName = "check-unchecked";
            sprite.size = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent<UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "check-checked";
            checkBox.checkedBoxObject.size = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            return checkBox;
        }
Esempio n. 26
0
        public static UICheckBox CreateCheckBar(UIComponent parent, string label)
        {
            UIPanel basePanel = parent.AddUIComponent <UIPanel>();

            basePanel.height           = 25;
            basePanel.backgroundSprite = "ScrollbarTrack";
            basePanel.width            = 275;
            basePanel.relativePosition = new Vector3(0, 5);

            UICheckBox checkBox = basePanel.AddUIComponent <UICheckBox>();

            checkBox.width            = basePanel.width;
            checkBox.height           = 20f;
            checkBox.clipChildren     = true;
            checkBox.relativePosition = new Vector3(7, 4, 0);

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = label;
            checkBox.label.textScale        = 0.8f;
            checkBox.label.autoSize         = false;
            checkBox.label.size             = new Vector2(190f, 18f);
            checkBox.label.textAlignment    = UIHorizontalAlignment.Center;
            checkBox.label.relativePosition = new Vector3(25f, 2f);

            return(checkBox);
        }
Esempio n. 27
0
        public static UICheckBox CreateCheckBox(UIComponent parent, string fieldName)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.name             = fieldName;
            checkBox.width            = 20f;
            checkBox.height           = 20f;
            checkBox.relativePosition = Vector3.zero;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = new Vector3(2f, 2f);

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.eventCheckChanged += EventCheckChangedHandler;
            checkBox.isChecked          = (bool)CustomizeIt.instance.CurrentBuilding.m_buildingAI.GetType().GetField(fieldName).GetValue(CustomizeIt.instance.CurrentBuilding.m_buildingAI);
            return(checkBox);
        }
Esempio n. 28
0
        private void SetupControls()
        {
            if (m_policyButton != null) return;

            isVisible = true;
            canFocus = true;
            isInteractive = true;
            backgroundSprite = "GenericPanel";
            size = new Vector2(364f, 44f);
            objectUserData = ToolsModifierControl.policiesPanel;

            m_policyButton = AddUIComponent<UIButton>();
            m_policyButton.name = "PolicyButton";
            m_policyButton.text = "Theme Name";
            m_policyButton.size = new Vector2(324f, 40f);
            m_policyButton.focusedBgSprite = "PolicyBarBackActive";
            m_policyButton.normalBgSprite = "PolicyBarBack";
            m_policyButton.relativePosition = new Vector3(2f, 2f, 0f);
            m_policyButton.textPadding.left = 50;
            m_policyButton.textColor = new Color32(0, 0, 0, 255);
            m_policyButton.disabledTextColor = new Color32(0, 0, 0, 255);
            m_policyButton.hoveredTextColor = new Color32(0, 0, 0, 255);
            m_policyButton.pressedTextColor = new Color32(0, 0, 0, 255);
            m_policyButton.focusedTextColor = new Color32(0, 0, 0, 255);
            m_policyButton.disabledColor = new Color32(124, 124, 124, 255);
            m_policyButton.dropShadowColor = new Color32(103, 103, 103, 255);
            m_policyButton.dropShadowOffset = new Vector2(1f, 1f);
            m_policyButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
            m_policyButton.useDropShadow = false;
            m_policyButton.textScale = 0.875f;

            // This helper component updates the checkbox state every game tick
            m_policyButton.gameObject.AddComponent<ThemePolicyContainer>();

            m_policyCheckBox = m_policyButton.AddUIComponent<UICheckBox>();
            m_policyCheckBox.name = "Checkbox";
            m_policyCheckBox.size = new Vector2(363f, 44f);
            m_policyCheckBox.relativePosition = new Vector3(0f, -2f, 0f);
            m_policyCheckBox.clipChildren = true;

            // Connect the checkbox with our theme manager
            m_policyCheckBox.eventCheckChanged += delegate(UIComponent component, bool isChecked)
            {
                lock (component)
                {
                    var districtId = ToolsModifierControl.policiesPanel.targetDistrict;
                    var districtThemes = BuildingThemesManager.instance.GetDistrictThemes(districtId, true);

                    if (isChecked == districtThemes.Contains(m_theme)) return;

                    if (isChecked)
                    {
                        BuildingThemesManager.instance.EnableTheme(districtId, m_theme);
                    }
                    else
                    {
                        BuildingThemesManager.instance.DisableTheme(districtId, m_theme);
                    }
                }

            };

            // Checkbox-related UI components
            m_sprite = m_policyCheckBox.AddUIComponent<UISprite>();
            m_sprite.name = "Unchecked";
            m_sprite.spriteName = "ToggleBase";
            m_sprite.size = new Vector2(16f, 16f);
            m_sprite.relativePosition = new Vector3(336.6984f, 14, 0f);

            m_policyCheckBox.checkedBoxObject = m_sprite.AddUIComponent<UISprite>();
            m_policyCheckBox.checkedBoxObject.name = "Checked";
            ((UISprite)m_policyCheckBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            m_policyCheckBox.checkedBoxObject.size = new Vector2(16f, 16f);
            m_policyCheckBox.checkedBoxObject.relativePosition = Vector3.zero;
        }
Esempio n. 29
0
        /// <summary>
        /// Performs initial setup for the panel; we no longer use Start() as that's not sufficiently reliable (race conditions), and is no longer needed, with the new create/destroy process.
        /// </summary>
        internal void Setup()
        {
            // Category toggles.
            categoryToggles = new UICheckBox[NumOfCategories];

            // First row.
            for (int i = 0; i < SecondRow; i++)
            {
                categoryToggles[i]                  = UIUtils.CreateIconToggle(this, OriginalCategories.atlases[i], OriginalCategories.spriteNames[i], OriginalCategories.spriteNames[i] + "Disabled");
                categoryToggles[i].tooltip          = Translations.Translate(OriginalCategories.tooltipKeys[i]);
                categoryToggles[i].relativePosition = new Vector2((FirstRowSize + Margin) * i, FirstRowY);
                categoryToggles[i].isChecked        = true;
                categoryToggles[i].readOnly         = true;
                categoryToggles[i].eventClick      += (control, clickEvent) => ToggleCat(control as UICheckBox);
            }

            // Second row (starts disabled).
            for (int i = SecondRow; i < NumOfCategories; i++)
            {
                categoryToggles[i]                  = UIUtils.CreateIconToggle(this, OriginalCategories.atlases[i], OriginalCategories.spriteNames[i], OriginalCategories.spriteNames[i] + "Disabled", 25f);
                categoryToggles[i].tooltip          = Translations.Translate(OriginalCategories.tooltipKeys[i]);
                categoryToggles[i].relativePosition = new Vector2((SecondRowSize + Margin) * (i - SecondRow), SecondRowY);
                categoryToggles[i].isChecked        = true;
                categoryToggles[i].readOnly         = true;
                categoryToggles[i].eventClick      += (control, clickEvent) => ToggleCat(control as UICheckBox);

                // Start deselected (need to toggle here after setting as checked above to force correct initial 'unchecked' background state, otherwise the 'checked' background is used).
                categoryToggles[i].isChecked = false;
            }

            // 'Select all' button.
            allCats             = UIControls.AddButton(this, (FirstRowSize + Margin) * SecondRow, Margin, Translations.Translate("PRR_FTR_ALL"), 55f);
            allCats.eventClick += (control, clickEvent) =>
            {
                // Iterate through all toggles in top row and activate.
                for (int i = 0; i < SecondRow; i++)
                {
                    categoryToggles[i].isChecked = true;
                }

                // Trigger an update.
                EventFilteringChanged(this, 0);
            };

            // 'Select none'button.
            noCats             = UIControls.AddButton(this, allCats.relativePosition.x + allCats.width + Margin, Margin, Translations.Translate("PRR_FTR_NON"), 55f);
            noCats.eventClick += (c, p) =>
            {
                // Iterate through all toggles and deactivate.
                for (int i = 0; i < NumOfCategories; ++i)
                {
                    categoryToggles[i].isChecked = false;
                }

                // Trigger an update.
                EventFilteringChanged(this, 0);
            };

            // Name filter textfield.
            nameFilter = UIControls.BigLabelledTextField(this, width - 200f, 0, Translations.Translate("PRR_FTR_NAM") + ": ");

            // Trigger events when textfield is updated.
            nameFilter.eventTextChanged   += (control, value) => EventFilteringChanged(this, 5);
            nameFilter.eventTextSubmitted += (control, value) => EventFilteringChanged(this, 5);

            // Create settings filters.
            UILabel filterLabel = this.AddUIComponent <UILabel>();

            filterLabel.textScale         = 0.7f;
            filterLabel.text              = Translations.Translate("PRR_FTR_SET");
            filterLabel.verticalAlignment = UIVerticalAlignment.Middle;
            filterLabel.autoSize          = false;
            filterLabel.width             = 270f;
            filterLabel.autoHeight        = true;
            filterLabel.wordWrap          = true;
            filterLabel.relativePosition  = new Vector2(1f, SettingsFilterY + ((SettingsCheckSize - filterLabel.height) / 2f));

            // Setting filter checkboxes.
            settingsFilter = new UICheckBox[NumOfSettings];
            for (int i = 0; i < NumOfSettings; ++i)
            {
                settingsFilter[i]                  = this.AddUIComponent <UICheckBox>();
                settingsFilter[i].width            = SettingsCheckSize;
                settingsFilter[i].height           = SettingsCheckSize;
                settingsFilter[i].clipChildren     = true;
                settingsFilter[i].relativePosition = new Vector2(280 + (30f * i), SettingsFilterY);

                // Checkbox sprites.
                UISprite sprite = settingsFilter[i].AddUIComponent <UISprite>();
                sprite.spriteName       = "ToggleBase";
                sprite.size             = new Vector2(20f, 20f);
                sprite.relativePosition = Vector3.zero;

                settingsFilter[i].checkedBoxObject = sprite.AddUIComponent <UISprite>();
                ((UISprite)settingsFilter[i].checkedBoxObject).spriteName = "ToggleBaseFocused";
                settingsFilter[i].checkedBoxObject.size             = new Vector2(20f, 20f);
                settingsFilter[i].checkedBoxObject.relativePosition = Vector3.zero;

                // Special event handling for 'any' checkbox.
                if (i == (NumOfSettings - 1))
                {
                    settingsFilter[i].eventCheckChanged += (control, isChecked) =>
                    {
                        if (isChecked)
                        {
                            // Unselect all other checkboxes if 'any' is checked.
                            settingsFilter[0].isChecked = false;
                            settingsFilter[1].isChecked = false;
                            settingsFilter[2].isChecked = false;
                        }
                    };
                }
                else
                {
                    // Non-'any' checkboxes.
                    // Unselect 'any' checkbox if any other is checked.
                    settingsFilter[i].eventCheckChanged += (control, isChecked) =>
                    {
                        if (isChecked)
                        {
                            settingsFilter[3].isChecked = false;
                        }
                    };
                }

                // Trigger filtering changed event if any checkbox is changed.
                settingsFilter[i].eventCheckChanged += (control, isChecked) => { EventFilteringChanged(this, 0); };
            }

            // Add settings filter tooltips.
            settingsFilter[0].tooltip = Translations.Translate("PRR_SET_HASMOD");
            settingsFilter[1].tooltip = Translations.Translate("PRR_SET_HASAUT");
            settingsFilter[2].tooltip = Translations.Translate("PRR_SET_HASLOC");
            settingsFilter[3].tooltip = Translations.Translate("PRR_SET_HASANY");
        }
Esempio n. 30
0
        private void SetupPanel()
        {
            this.name             = "PublicTransportStopWorldInfoPanel";
            this.isVisible        = false;
            this.canFocus         = true;
            this.isInteractive    = true;
            this.anchor           = UIAnchorStyle.None;
            this.pivot            = UIPivotPoint.BottomLeft;
            this.width            = 380f;
            this.height           = 280f;
            this.backgroundSprite = "InfoBubbleVehicle";
            UIPanel uiPanel1 = this.AddUIComponent <UIPanel>();
            string  str1     = "Caption";

            uiPanel1.name = str1;
            double width = (double)this.width;

            uiPanel1.width = (float)width;
            double num1 = 40.0;

            uiPanel1.height = (float)num1;
            Vector3 vector3_1 = new Vector3(0.0f, 0.0f);

            uiPanel1.relativePosition = vector3_1;
            UISprite uiSprite1 = uiPanel1.AddUIComponent <UISprite>();

            uiSprite1.name             = "VehicleType";
            uiSprite1.size             = new Vector2(32f, 22f);
            uiSprite1.relativePosition = new Vector3(8f, 9f, 0.0f);
            this.m_VehicleType         = uiSprite1;
            UITextField uiTextField = uiPanel1.AddUIComponent <UITextField>();

            uiTextField.name                 = "StopName";
            uiTextField.font                 = UIHelper.Font;
            uiTextField.height               = 25f;
            uiTextField.width                = 200f;
            uiTextField.maxLength            = 32;
            uiTextField.builtinKeyNavigation = true;
            uiTextField.submitOnFocusLost    = true;
            uiTextField.focusedBgSprite      = "TextFieldPanel";
            uiTextField.hoveredBgSprite      = "TextFieldPanelHovered";
            uiTextField.padding              = new RectOffset(0, 0, 4, 0);
            uiTextField.selectionSprite      = "EmptySprite";
            uiTextField.verticalAlignment    = UIVerticalAlignment.Middle;
            uiTextField.position             = new Vector3((float)((double)this.width / 2.0 - (double)uiTextField.width / 2.0), (float)((double)uiTextField.height / 2.0 - 20.0));
            uiTextField.eventTextSubmitted  += new PropertyChangedEventHandler <string>(this.OnRename);
            this.m_StopName = uiTextField;
            DropDown dropDown = DropDown.Create((UIComponent)uiPanel1);

            dropDown.name      = "SuggestedNames";
            dropDown.size      = new Vector2(30f, 25f);
            dropDown.ListWidth = 200f;
            dropDown.DropDownPanelAlignParent = (UIComponent)this;
            dropDown.Font      = UIHelper.Font;
            dropDown.position  = new Vector3((float)((double)this.width / 2.0 + (double)uiTextField.width / 2.0), (float)((double)dropDown.height / 2.0 - 20.0));
            dropDown.tooltip   = Localization.Get("STOP_PANEL_SUGGESTED_NAMES_TOOLTIP");
            dropDown.ShowPanel = false;
            dropDown.eventSelectedItemChanged += new PropertyChangedEventHandler <ushort>(this.OnSelectedItemChanged);
            this.m_SuggestedNames              = dropDown;
            UIButton uiButton1 = uiPanel1.AddUIComponent <UIButton>();

            uiButton1.name             = "ReuseName";
            uiButton1.tooltip          = Localization.Get("STOP_PANEL_REUSE_NAME_TOOLTIP");
            uiButton1.size             = new Vector2(30f, 30f);
            uiButton1.normalBgSprite   = "IconPolicyRecycling";
            uiButton1.hoveredBgSprite  = "IconPolicyRecyclingHovered";
            uiButton1.pressedBgSprite  = "IconPolicyRecyclingPressed";
            uiButton1.relativePosition = new Vector3((float)((double)this.width - 32.0 - (double)uiButton1.width - 2.0), 6f);
            uiButton1.eventClick      += new MouseEventHandler(this.OnReuseNameButtonClick);
            UIButton uiButton2 = uiPanel1.AddUIComponent <UIButton>();

            uiButton2.name             = "Close";
            uiButton2.size             = new Vector2(32f, 32f);
            uiButton2.normalBgSprite   = "buttonclose";
            uiButton2.hoveredBgSprite  = "buttonclosehover";
            uiButton2.pressedBgSprite  = "buttonclosepressed";
            uiButton2.relativePosition = new Vector3((float)((double)this.width - (double)uiButton2.width - 2.0), 2f);
            uiButton2.eventClick      += new MouseEventHandler(this.OnCloseButtonClick);
            UIPanel uiPanel2 = this.AddUIComponent <UIPanel>();
            string  str2     = "Container";

            uiPanel2.name = str2;
            double num2 = 365.0;

            uiPanel2.width = (float)num2;
            double num3 = 197.0;

            uiPanel2.height = (float)num3;
            int num4 = 1;

            uiPanel2.autoLayout = num4 != 0;
            int num5 = 1;

            uiPanel2.autoLayoutDirection = (LayoutDirection)num5;
            RectOffset rectOffset1 = new RectOffset(10, 10, 5, 0);

            uiPanel2.autoLayoutPadding = rectOffset1;
            int num6 = 0;

            uiPanel2.autoLayoutStart = (LayoutStart)num6;
            Vector3 vector3_2 = new Vector3(6f, 46f);

            uiPanel2.relativePosition = vector3_2;
            UIPanel uiPanel3 = uiPanel2.AddUIComponent <UIPanel>();
            string  str3     = "PassengerCountPanel";

            uiPanel3.name = str3;
            int num7 = 13;

            uiPanel3.anchor = (UIAnchorStyle)num7;
            int num8 = 1;

            uiPanel3.autoLayout = num8 != 0;
            int num9 = 0;

            uiPanel3.autoLayoutDirection = (LayoutDirection)num9;
            RectOffset rectOffset2 = new RectOffset(0, 5, 0, 0);

            uiPanel3.autoLayoutPadding = rectOffset2;
            int num10 = 0;

            uiPanel3.autoLayoutStart = (LayoutStart)num10;
            Vector2 vector2_1 = new Vector2(345f, 14f);

            uiPanel3.size = vector2_1;
            UILabel uiLabel1 = uiPanel3.AddUIComponent <UILabel>();

            uiLabel1.name         = "PassengerCount";
            uiLabel1.font         = UIHelper.Font;
            uiLabel1.autoSize     = true;
            uiLabel1.height       = 15f;
            uiLabel1.textScale    = 13f / 16f;
            uiLabel1.textColor    = new Color32((byte)185, (byte)221, (byte)254, byte.MaxValue);
            this.m_PassengerCount = uiLabel1;
            UIPanel uiPanel4 = uiPanel2.AddUIComponent <UIPanel>();
            string  str4     = "BoredCountdownPanel";

            uiPanel4.name = str4;
            int num11 = 13;

            uiPanel4.anchor = (UIAnchorStyle)num11;
            int num12 = 1;

            uiPanel4.autoLayout = num12 != 0;
            int num13 = 0;

            uiPanel4.autoLayoutDirection = (LayoutDirection)num13;
            RectOffset rectOffset3 = new RectOffset(0, 5, 0, 0);

            uiPanel4.autoLayoutPadding = rectOffset3;
            int num14 = 0;

            uiPanel4.autoLayoutStart = (LayoutStart)num14;
            Vector2 vector2_2 = new Vector2(345f, 14f);

            uiPanel4.size = vector2_2;
            UILabel uiLabel2 = uiPanel4.AddUIComponent <UILabel>();

            uiLabel2.name          = "BoredCountdown";
            uiLabel2.tooltip       = Localization.Get("STOP_PANEL_BORED_TIMER_TOOLTIP");
            uiLabel2.font          = UIHelper.Font;
            uiLabel2.autoSize      = true;
            uiLabel2.height        = 15f;
            uiLabel2.textScale     = 13f / 16f;
            uiLabel2.textColor     = new Color32((byte)185, (byte)221, (byte)254, byte.MaxValue);
            uiLabel2.processMarkup = true;
            this.m_BoredCountdown  = uiLabel2;
            UIPanel uiPanel5 = uiPanel2.AddUIComponent <UIPanel>();
            string  str5     = "PassengerStats";

            uiPanel5.name = str5;
            int num15 = 13;

            uiPanel5.anchor = (UIAnchorStyle)num15;
            int num16 = 1;

            uiPanel5.autoLayout = num16 != 0;
            int num17 = 1;

            uiPanel5.autoLayoutDirection = (LayoutDirection)num17;
            RectOffset rectOffset4 = new RectOffset(0, 0, 0, 0);

            uiPanel5.autoLayoutPadding = rectOffset4;
            int num18 = 0;

            uiPanel5.autoLayoutStart = (LayoutStart)num18;
            Vector2 vector2_3 = new Vector2(349f, 75f);

            uiPanel5.size = vector2_3;
            UILabel uiLabel3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label1_1 = @uiLabel3;
            UILabel  uiLabel4;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label2_1 = @uiLabel4;
            UILabel  uiLabel5;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label3_1 = @uiLabel5;
            UILabel  uiLabel6;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label4_1 = @uiLabel6;
            int      num19    = 1;

            PublicTransportStopWorldInfoPanel.CreateStatisticRow((UIComponent)uiPanel5, label1_1, label2_1, label3_1, label4_1, num19 != 0);
            uiLabel4.text    = Localization.Get("CURRENT_WEEK");
            uiLabel5.text    = Localization.Get("LAST_WEEK");
            uiLabel6.text    = Localization.Get("AVERAGE");
            uiLabel6.tooltip = string.Format(Localization.Get("AVERAGE_TOOLTIP"), (object)ImprovedPublicTransportMod.Settings.StatisticWeeks);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label1_2 = @uiLabel3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label2_2 = @this.m_passengersInCurrent;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label3_2 = @this.m_passengersInLast;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label4_2 = @this.m_passengersInAverage;
            int      num20    = 0;

            PublicTransportStopWorldInfoPanel.CreateStatisticRow((UIComponent)uiPanel5, label1_2, label2_2, label3_2, label4_2, num20 != 0);
            uiLabel3.text    = Localization.Get("STOP_PANEL_PASSENGERS_IN");
            uiLabel3.tooltip = Localization.Get("STOP_PANEL_PASSENGERS_IN_TOOLTIP");
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label1_3 = @uiLabel3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label2_3 = @this.m_passengersOutCurrent;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label3_3 = @this.m_passengersOutLast;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label4_3 = @this.m_passengersOutAverage;
            int      num21    = 0;

            PublicTransportStopWorldInfoPanel.CreateStatisticRow((UIComponent)uiPanel5, label1_3, label2_3, label3_3, label4_3, num21 != 0);
            uiLabel3.text    = Localization.Get("STOP_PANEL_PASSENGERS_OUT");
            uiLabel3.tooltip = Localization.Get("STOP_PANEL_PASSENGERS_OUT_TOOLTIP");
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label1_4 = @uiLabel3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label2_4 = @this.m_passengersTotalCurrent;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label3_4 = @this.m_passengersTotalLast;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            UILabel& label4_4 = @this.m_passengersTotalAverage;
            int      num22    = 0;

            PublicTransportStopWorldInfoPanel.CreateStatisticRow((UIComponent)uiPanel5, label1_4, label2_4, label3_4, label4_4, num22 != 0);
            uiLabel3.text    = Localization.Get("STOP_PANEL_PASSENGERS_TOTAL");
            uiLabel3.tooltip = Localization.Get("STOP_PANEL_PASSENGERS_TOTAL_TOOLTIP");
            UIPanel uiPanel6 = uiPanel2.AddUIComponent <UIPanel>();
            string  str6     = "Unbunching";

            uiPanel6.name = str6;
            int num23 = 13;

            uiPanel6.anchor = (UIAnchorStyle)num23;
            int num24 = 1;

            uiPanel6.autoLayout = num24 != 0;
            int num25 = 0;

            uiPanel6.autoLayoutDirection = (LayoutDirection)num25;
            RectOffset rectOffset5 = new RectOffset(0, 5, 0, 0);

            uiPanel6.autoLayoutPadding = rectOffset5;
            int num26 = 0;

            uiPanel6.autoLayoutStart = (LayoutStart)num26;
            Vector2 vector2_4 = new Vector2(345f, 25f);

            uiPanel6.size = vector2_4;
            int num27 = 1;

            uiPanel6.useCenter = num27 != 0;
            UICheckBox uiCheckBox = uiPanel6.AddUIComponent <UICheckBox>();

            uiCheckBox.anchor        = UIAnchorStyle.Left | UIAnchorStyle.CenterVertical;
            uiCheckBox.clipChildren  = true;
            uiCheckBox.tooltip       = Localization.Get("STOP_PANEL_UNBUNCHING_TOOLTIP") + System.Environment.NewLine + Localization.Get("EXPLANATION_UNBUNCHING");
            uiCheckBox.eventClicked += new MouseEventHandler(this.OnUnbunchingClick);
            UISprite uiSprite2 = uiCheckBox.AddUIComponent <UISprite>();

            uiSprite2.spriteName        = "check-unchecked";
            uiSprite2.size              = new Vector2(16f, 16f);
            uiSprite2.relativePosition  = Vector3.zero;
            uiCheckBox.checkedBoxObject = (UIComponent)uiSprite2.AddUIComponent <UISprite>();
            ((UISprite)uiCheckBox.checkedBoxObject).spriteName = "check-checked";
            uiCheckBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            uiCheckBox.checkedBoxObject.relativePosition = Vector3.zero;
            uiCheckBox.label                   = uiCheckBox.AddUIComponent <UILabel>();
            uiCheckBox.label.font              = UIHelper.Font;
            uiCheckBox.label.textColor         = new Color32((byte)185, (byte)221, (byte)254, byte.MaxValue);
            uiCheckBox.label.disabledTextColor = (Color32)Color.black;
            uiCheckBox.label.textScale         = 13f / 16f;
            uiCheckBox.label.text              = (int)ImprovedPublicTransportMod.Settings.IntervalAggressionFactor == 0 ? Localization.Get("UNBUNCHING_DISABLED") : Localization.Get("UNBUNCHING_ENABLED");
            uiCheckBox.label.relativePosition  = new Vector3(22f, 2f);
            uiCheckBox.size   = new Vector2(uiCheckBox.label.width + 22f, 16f);
            this.m_unbunching = uiCheckBox;
            UIPanel uiPanel7 = uiPanel2.AddUIComponent <UIPanel>();
            string  str7     = "Line";

            uiPanel7.name = str7;
            int num28 = 13;

            uiPanel7.anchor = (UIAnchorStyle)num28;
            Vector2 vector2_5 = new Vector2(345f, 25f);

            uiPanel7.size = vector2_5;
            int num29 = 1;

            uiPanel7.autoLayout = num29 != 0;
            int num30 = 0;

            uiPanel7.autoLayoutDirection = (LayoutDirection)num30;
            RectOffset rectOffset6 = new RectOffset(0, 10, 0, 0);

            uiPanel7.autoLayoutPadding = rectOffset6;
            int num31 = 0;

            uiPanel7.autoLayoutStart = (LayoutStart)num31;
            int num32 = 1;

            uiPanel7.useCenter = num32 != 0;
            UILabel uiLabel7 = uiPanel7.AddUIComponent <UILabel>();

            uiLabel7.name              = "Line";
            uiLabel7.anchor            = UIAnchorStyle.Left | UIAnchorStyle.CenterVertical;
            uiLabel7.font              = UIHelper.Font;
            uiLabel7.autoSize          = true;
            uiLabel7.height            = 25f;
            uiLabel7.textScale         = 13f / 16f;
            uiLabel7.textColor         = new Color32((byte)185, (byte)221, (byte)254, byte.MaxValue);
            uiLabel7.verticalAlignment = UIVerticalAlignment.Middle;
            uiLabel7.relativePosition  = new Vector3(0.0f, 5f);
            this.m_Line = uiLabel7;
            UIButton button1 = UIHelper.CreateButton((UIComponent)uiPanel7);

            button1.name        = "ModifyLine";
            button1.autoSize    = true;
            button1.textPadding = new RectOffset(10, 10, 4, 2);
            button1.anchor      = UIAnchorStyle.Left | UIAnchorStyle.CenterVertical;
            button1.localeID    = "VEHICLE_MODIFYLINE";
            button1.textScale   = 0.75f;
            button1.eventClick += new MouseEventHandler(this.OnModifyLineClick);
            UIPanel uiPanel8 = uiPanel2.AddUIComponent <UIPanel>();
            string  str8     = "Buttons";

            uiPanel8.name = str8;
            int num33 = 13;

            uiPanel8.anchor = (UIAnchorStyle)num33;
            int num34 = 1;

            uiPanel8.autoLayout = num34 != 0;
            int num35 = 0;

            uiPanel8.autoLayoutDirection = (LayoutDirection)num35;
            RectOffset rectOffset7 = new RectOffset(0, 5, 0, 0);

            uiPanel8.autoLayoutPadding = rectOffset7;
            int num36 = 0;

            uiPanel8.autoLayoutStart = (LayoutStart)num36;
            Vector2 vector2_6 = new Vector2(345f, 32f);

            uiPanel8.size = vector2_6;
            UIButton button2 = UIHelper.CreateButton((UIComponent)uiPanel8);

            button2.name        = "PreviousStop";
            button2.textPadding = new RectOffset(10, 10, 4, 0);
            button2.text        = Localization.Get("STOP_PANEL_PREVIOUS");
            button2.tooltip     = Localization.Get("STOP_PANEL_PREVIOUS_TOOLTIP");
            button2.textScale   = 0.75f;
            button2.size        = new Vector2(110f, 32f);
            button2.wordWrap    = true;
            button2.eventClick += new MouseEventHandler(this.OnPreviousStopClick);
            UIButton button3 = UIHelper.CreateButton((UIComponent)uiPanel8);

            button3.name             = "DeleteStop";
            button3.textPadding      = new RectOffset(10, 10, 4, 0);
            button3.text             = Localization.Get("STOP_PANEL_DELETE_STOP");
            button3.tooltip          = Localization.Get("STOP_PANEL_DELETE_STOP_TOOLTIP");
            button3.isEnabled        = false;
            button3.textScale        = 0.75f;
            button3.size             = new Vector2(110f, 32f);
            button3.wordWrap         = true;
            button3.hoveredTextColor = (Color32)Color.red;
            button3.focusedTextColor = (Color32)Color.red;
            button3.pressedTextColor = (Color32)Color.red;
            button3.eventClick      += new MouseEventHandler(this.OnDeleteStopClick);
            this.m_DeleteStop        = button3;
            UIButton button4 = UIHelper.CreateButton((UIComponent)uiPanel8);

            button4.name        = "NextStop";
            button4.textPadding = new RectOffset(10, 10, 4, 0);
            button4.text        = Localization.Get("STOP_PANEL_NEXT");
            button4.tooltip     = Localization.Get("STOP_PANEL_NEXT_TOOLTIP");
            button4.textScale   = 0.75f;
            button4.size        = new Vector2(110f, 32f);
            button4.wordWrap    = true;
            button4.eventClick += new MouseEventHandler(this.OnNextStopClick);
        }
Esempio n. 31
0
        private void SetupControls()
        {
            if (m_policyButton != null)
            {
                return;
            }

            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;
            backgroundSprite = "GenericPanel";
            size             = new Vector2(364f, 44f);
            objectUserData   = ToolsModifierControl.policiesPanel;

            m_policyButton                         = AddUIComponent <UIButton>();
            m_policyButton.name                    = "PolicyButton";
            m_policyButton.text                    = "Theme Name";
            m_policyButton.size                    = new Vector2(324f, 40f);
            m_policyButton.focusedBgSprite         = "PolicyBarBackActive";
            m_policyButton.normalBgSprite          = "PolicyBarBack";
            m_policyButton.relativePosition        = new Vector3(2f, 2f, 0f);
            m_policyButton.textPadding.left        = 50;
            m_policyButton.textColor               = new Color32(0, 0, 0, 255);
            m_policyButton.disabledTextColor       = new Color32(0, 0, 0, 255);
            m_policyButton.hoveredTextColor        = new Color32(0, 0, 0, 255);
            m_policyButton.pressedTextColor        = new Color32(0, 0, 0, 255);
            m_policyButton.focusedTextColor        = new Color32(0, 0, 0, 255);
            m_policyButton.disabledColor           = new Color32(124, 124, 124, 255);
            m_policyButton.dropShadowColor         = new Color32(103, 103, 103, 255);
            m_policyButton.dropShadowOffset        = new Vector2(1f, 1f);
            m_policyButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
            m_policyButton.useDropShadow           = false;
            m_policyButton.textScale               = 0.875f;

            // This helper component updates the checkbox state every game tick
            m_policyButton.gameObject.AddComponent <ThemePolicyContainer>();

            m_policyCheckBox                  = m_policyButton.AddUIComponent <UICheckBox>();
            m_policyCheckBox.name             = "Checkbox";
            m_policyCheckBox.size             = new Vector2(363f, 44f);
            m_policyCheckBox.relativePosition = new Vector3(0f, -2f, 0f);
            m_policyCheckBox.clipChildren     = true;

            // Connect the checkbox with our theme manager
            m_policyCheckBox.eventCheckChanged += delegate(UIComponent component, bool isChecked)
            {
                lock (component)
                {
                    var districtId     = ToolsModifierControl.policiesPanel.targetDistrict;
                    var districtThemes = BuildingThemesManager.instance.GetDistrictThemes(districtId, true);

                    if (isChecked == districtThemes.Contains(m_theme))
                    {
                        return;
                    }

                    if (isChecked)
                    {
                        BuildingThemesManager.instance.EnableTheme(districtId, m_theme);
                    }
                    else
                    {
                        BuildingThemesManager.instance.DisableTheme(districtId, m_theme);
                    }
                }
            };

            // Checkbox-related UI components
            m_sprite                  = m_policyCheckBox.AddUIComponent <UISprite>();
            m_sprite.name             = "Unchecked";
            m_sprite.spriteName       = "ToggleBase";
            m_sprite.size             = new Vector2(16f, 16f);
            m_sprite.relativePosition = new Vector3(336.6984f, 14, 0f);

            m_policyCheckBox.checkedBoxObject      = m_sprite.AddUIComponent <UISprite>();
            m_policyCheckBox.checkedBoxObject.name = "Checked";
            ((UISprite)m_policyCheckBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            m_policyCheckBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            m_policyCheckBox.checkedBoxObject.relativePosition = Vector3.zero;
        }