Esempio n. 1
0
        public override void Start()
        {
            base.Start();

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = 740f;
            height        = 40f;

            m_name = UIUtils.CreateLabel(this, 300f, height);
            m_name.textAlignment    = UIHorizontalAlignment.Left;
            m_name.pivot            = UIPivotPoint.MiddleLeft;
            m_name.relativePosition = new Vector3(10f, 0f);
            statusLabel             = UIUtils.CreateLabelForGrid(this, m_name, 190f, height);
            m_triangles             = UIUtils.CreateLabelForGrid(this, statusLabel, 150f, height);
            m_textureSize           = UIUtils.CreateLabelForGrid(this, m_triangles, 90f, height);

            eventMouseEnter += (component, eventParam) => Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.5f);
            eventMouseLeave += (component, eventParam) => Background.opacity = baseBgOpacity;
            eventClick      += (component, p) =>
            {
                Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.75f);
                WorldInfoPanel.Show <CityServiceWorldInfoPanel>(m_meshData.position, m_meshData.instanceID);
                ToolsModifierControl.cameraController.SetTarget(m_meshData.instanceID, m_meshData.position, true);
            };
        }
Esempio n. 2
0
        public void Display(object data, bool isRowOdd)
        {
            m_options = data as VehicleOptions;

            if (m_icon == null || m_options == null)
            {
                return;
            }

            m_icon.spriteName = UIMainPanel.vehicleIconList[(int)m_options.category];
            m_icon.size       = m_icon.spriteInfo.pixelSize;
            UIUtils.ResizeIcon(m_icon, new Vector2(32, 32));
            m_icon.relativePosition = new Vector3(10, Mathf.Floor((height - m_icon.height) / 2));

            m_name.text = m_options.localizedName;

            m_disabled.isVisible = !options.enabled;
            m_name.textColor     = options.enabled ? new Color32(255, 255, 255, 255) : new Color32(128, 128, 128, 255);

            m_steamIcon.tooltip   = m_options.steamID;
            m_steamIcon.isVisible = m_options.steamID != null;

            if (isRowOdd)
            {
                background.backgroundSprite = "UnlockingItemBackground";
                background.color            = new Color32(0, 0, 0, 128);
            }
            else
            {
                background.backgroundSprite = null;
            }
        }
Esempio n. 3
0
        public override void Start()
        {
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "GenericPanelWhite";

            size      = new Vector2(300, 100);
            padding   = new RectOffset(10, 10, 10, 10);
            textColor = new Color32(109, 109, 109, 255);
            textScale = 0.9f;

            wordWrap   = true;
            autoHeight = true;

            instance = this;

            Random.InitState(System.DateTime.Now.Second);
            if (Random.Range(0, 2) == 0)
            {
                m_currentTip = 0;
            }
            if (Random.Range(0, 8) == 0)
            {
                m_currentTip = m_tips.Length - 2;
            }
            NextTip();
        }
Esempio n. 4
0
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "MoveIt_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3(430 - deleteButton.width - 8, 8);
            deleteButton.tooltip          = "Delete saved path";

            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "MoveIt_SaveLoadFileButton";
            saveLoadButton.text             = UISaveWindow.instance != null ? "Export" : "Import";
            saveLoadButton.size             = new Vector2(80f, 30f);
            saveLoadButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveLoadButton.width - 8, 8);

            saveLoadButton.eventClicked += (c, p) =>
            {
                if (UISaveWindow.instance != null)
                {
                    UISaveWindow.Export(fileNameLabel.text);
                }
                else
                {
                    UILoadWindow.Close();
                    MoveItTool.instance.Import(fileNameLabel.text);
                }
            };

            deleteButton.eventClicked += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete file", "Do you want to delete the file '" + fileNameLabel.text + "' permanently?", (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Delete(fileNameLabel.text);

                        if (UISaveWindow.instance != null)
                        {
                            UISaveWindow.instance.RefreshFileList();
                        }
                        else
                        {
                            UILoadWindow.instance.RefreshFileList();
                        }
                    }
                });
            };

            fileNameLabel.width = saveLoadButton.relativePosition.x - 16f;
        }
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "CCX_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3(430 - deleteButton.width - 8, 8);
            deleteButton.tooltip          = "Delete saved path";

            saveButton                  = UIUtils.CreateButton(this);
            saveButton.name             = "CCX_SaveFileButton";
            saveButton.text             = "Save";
            saveButton.size             = new Vector2(80f, 30f);
            saveButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveButton.width - 8, 8);
            saveButton.tooltip          = "Save path";

            loadButton                  = UIUtils.CreateButton(this);
            loadButton.name             = "CCX_LoadFileButton";
            loadButton.text             = "Load";
            loadButton.size             = new Vector2(80f, 30f);
            loadButton.relativePosition = new Vector3(saveButton.relativePosition.x - loadButton.width - 8, 8);
            loadButton.tooltip          = "Load path";

            saveButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.Serialize(fileNameLabel.text);
            };

            loadButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.Deserialize(fileNameLabel.text);
                CameraDirector.mainWindow.RefreshKnotList();
            };

            deleteButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.Delete(fileNameLabel.text);
                CameraDirector.mainWindow.saveLoadWindow.RefreshFileList();
            };

            fileNameLabel.width = loadButton.relativePosition.x - 16f;
        }
        private void AddKeymapping(string label, Shortcut shortcut)
        {
            UIPanel uIPanel = component.AttachUIComponent(UITemplateManager.GetAsGameObject(kKeyBindingTemplate)) as UIPanel;

            uIPanel.name = "ShortcutItem";
            if (count++ % 2 == 1)
            {
                uIPanel.backgroundSprite = null;
            }

            UILabel  uILabel  = uIPanel.Find <UILabel>("Name");
            UIButton uIButton = uIPanel.Find <UIButton>("Binding");

            uIButton.eventClick += (c, p) =>
            {
                GUI.UIShortcutModal.instance.title    = "Edit Shortcut";
                GUI.UIShortcutModal.instance.shortcut = shortcut;

                UIView.PushModal(GUI.UIShortcutModal.instance);
                GUI.UIShortcutModal.instance.Show();
            };

            uILabel.text            = label;
            uIButton.text           = SavedInputKey.ToLocalizedString("KEYNAME", shortcut.inputKey);
            uIButton.objectUserData = shortcut;
            uIButton.stringUserData = "MoreShortcuts";

            UIButton delete = uIPanel.AddUIComponent <UIButton>();

            delete.atlas           = UIUtils.GetAtlas("Ingame");
            delete.normalBgSprite  = "buttonclose";
            delete.hoveredBgSprite = "buttonclosehover";
            delete.pressedBgSprite = "buttonclosepressed";
            delete.tooltip         = "Delete Shortcut";
            delete.eventClick     += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete Shortcut", "Are you sure you want to delete the [" + shortcut.name + "] shortcut?", (c2, ret) =>
                {
                    if (ret == 1)
                    {
                        Shortcut.RemoveShortcut(shortcut);
                        Shortcut.SaveShorcuts();
                        RefreshShortcutsList();
                    }
                });
            };

            delete.relativePosition = uIButton.relativePosition + new Vector3(uIButton.width + 10, 0);
        }
Esempio n. 7
0
        public override void Start()
        {
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "GenericPanelWhite";

            size      = new Vector2(300, 100);
            padding   = new RectOffset(10, 10, 10, 10);
            textColor = new Color32(109, 109, 109, 255);
            textScale = 0.9f;

            wordWrap   = true;
            autoHeight = true;

            instance = this;
        }
Esempio n. 8
0
        public override void Start()
        {
            base.Start();

            name             = "MeshInfo";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "UnlockingPanel2";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            width            = 770;
            height           = 475;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            SetupControls();
        }
Esempio n. 9
0
        public void Display(object data, bool isRowOdd)
        {
            m_options = data as VehicleOptions;

            if (m_icon == null || m_options == null)
            {
                return;
            }

            m_icon.spriteName = UIMainPanel.vehicleIconList[(int)m_options.category];
            m_icon.size       = m_icon.spriteInfo.pixelSize;
            UIUtils.ResizeIcon(m_icon, new Vector2(32, 32));
            m_icon.relativePosition = new Vector3(10, Mathf.Floor((height - m_icon.height) / 2));

            m_name.text = m_options.localizedName;

            m_disabled.isVisible = !options.enabled;

            //Verify if the vehicle is a Game Controlled Spawn Public Transport vehicle, where the game controls spawning; if disabled/deactivated set to enabled
            if (options.isPublicTransportGame == true)             // && AdvancedVehicleOptionsUID.SpawnControl == true)  && options.isUncontrolledPublicTransport == false)
            {
                if (options.enabled == false)
                {
                    options.enabled = true;
                }
            }

            m_disabled.isVisible = !options.enabled;

            m_name.textColor = options.enabled ? new Color32(255, 255, 255, 255) : new Color32(128, 128, 128, 255);

            m_steamIcon.tooltip   = m_options.steamID;
            m_steamIcon.isVisible = m_options.steamID != null;

            if (isRowOdd)
            {
                background.backgroundSprite = "UnlockingItemBackground";
                background.color            = new Color32(0, 0, 0, 128);
            }
            else
            {
                background.backgroundSprite = null;
            }
        }
        public override void Start()
        {
            base.Start();

            backgroundSprite = "UnlockingPanel2";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            clipChildren     = true;
            width            = 600;
            height           = 200;
            relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Advanced Vehicle Options - Warning";
            m_title.iconSprite = "IconCitizenVehicle";
            m_title.isModal    = true;

            // Icon
            m_warningIcon            = AddUIComponent <UISprite>();
            m_warningIcon.size       = new Vector2(90, 90);
            m_warningIcon.spriteName = "IconWarning";

            // Message
            m_messageLabel          = AddUIComponent <UILabel>();
            m_messageLabel.wordWrap = true;

            // Ok
            m_ok      = UIUtils.CreateButton(this);
            m_ok.text = "OK";

            m_ok.eventClick += (c, p) =>
            {
                UIView.PopModal();
                Hide();
            };

            message = m_message;

            isVisible = true;
        }
Esempio n. 11
0
        private void SetupControls()
        {
            width            = parent.width;
            height           = 40;
            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;
            relativePosition = Vector3.zero;

            m_title                   = AddUIComponent <UILabel>();
            m_title.autoSize          = false;
            m_title.textAlignment     = UIHorizontalAlignment.Center;
            m_title.verticalAlignment = UIVerticalAlignment.Middle;
            m_title.text              = title;
            m_title.textScale         = 1.3f;
            m_title.size              = new Vector2(width, height);
            m_title.relativePosition  = new Vector3(0, 0);

            m_close                  = AddUIComponent <UIButton>();
            m_close.atlas            = UIUtils.GetAtlas("Ingame");
            m_close.relativePosition = new Vector3(width - 35, 2);
            m_close.normalBgSprite   = "buttonclose";
            m_close.hoveredBgSprite  = "buttonclosehover";
            m_close.pressedBgSprite  = "buttonclosepressed";
            m_close.eventClick      += (component, param) =>
            {
                if (isModal && isVisible)
                {
                    UIView.PopModal();
                }
                parent.Hide();
            };

            m_drag                  = AddUIComponent <UIDragHandle>();
            m_drag.width            = width - 50;
            m_drag.height           = height;
            m_drag.relativePosition = Vector3.zero;
            m_drag.target           = parent;
        }
Esempio n. 12
0
        public override void Start()
        {
            base.Start();

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = parent.width;
            height        = 40;

            m_icon = AddUIComponent <UISprite>();

            m_disabled            = AddUIComponent <UISprite>();
            m_disabled.spriteName = "Niet";
            m_disabled.size       = m_disabled.spriteInfo.pixelSize;
            UIUtils.ResizeIcon(m_disabled, new Vector2(32, 32));
            m_disabled.relativePosition = new Vector3(10, Mathf.Floor((height - m_disabled.height) / 2));

            m_name                  = AddUIComponent <UILabel>();
            m_name.textScale        = 0.8f;
            m_name.relativePosition = new Vector3(55, 13);

            m_steamIcon                  = AddUIComponent <UISprite>();
            m_steamIcon.spriteName       = "SteamWorkshop";
            m_steamIcon.isVisible        = false;
            m_steamIcon.relativePosition = new Vector3(width - 45, 12.5f);

            UIUtils.ResizeIcon(m_steamIcon, new Vector2(25, 25));

            if (PlatformService.IsOverlayEnabled())
            {
                m_steamIcon.eventClick += (c, p) =>
                {
                    p.Use();
                    PlatformService.ActivateGameOverlayToWorkshopItem(new PublishedFileId(ulong.Parse(m_options.steamID)));
                };
            }
        }
Esempio n. 13
0
 internal void CreateSubPanel(string subName, float entries)
 {
     m_panel.atlas                  = UIUtils.GetAtlas("Ingame");
     m_panel.backgroundSprite       = "SubcategoriesPanel";
     m_panel.clipChildren           = true;
     m_panel.size                   = new Vector2(160, 12 + (entries * 32f)); // Width is changed at runtime
     m_panel.isVisible              = false;
     m_subpanel.name                = subName;
     m_subpanel.padding             = new RectOffset(1, 1, 6, 6);
     m_subpanel.size                = m_panel.size;
     m_subpanel.autoLayoutDirection = LayoutDirection.Vertical;
     m_subpanel.autoLayout          = true;
     m_subpanel.relativePosition    = new Vector3(0, 0, 0);
     m_subpanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 2);
     m_panel.autoLayout             = false;
     m_panel.absolutePosition       = UIMoreTools.MoreToolsBtn.absolutePosition + new Vector3(-m_panel.width, -m_panel.height - 10);
     m_panel.eventMouseEnter       += (UIComponent c, UIMouseEventParameter p) =>
     {
         UIMoreTools.m_activeDisplayMenu = this;
         if (MoveItTool.marqueeSelection)
         {
             UIToolOptionPanel.instance.m_filtersPanel.isVisible = false;
         }
         c.isVisible = true;
         UIMoreTools.UpdateMoreTools();
     };
     m_panel.eventMouseLeave += (UIComponent c, UIMouseEventParameter p) =>
     {
         UIMoreTools.m_activeDisplayMenu = null;
         if (MoveItTool.marqueeSelection)
         {
             UIToolOptionPanel.instance.m_filtersPanel.isVisible = true;
         }
         c.isVisible = false;
         UIMoreTools.UpdateMoreTools();
     };
 }
Esempio n. 14
0
        private void SetupControls()
        {
            if (m_panel != null)
            {
                return;
            }

            // Panel
            m_panel                  = AddUIComponent <UIPanel>();
            m_panel.atlas            = UIUtils.GetAtlas("Ingame");
            m_panel.width            = width - 10f;
            m_panel.height           = height;
            m_panel.backgroundSprite = m_backgroundSprite;
            m_panel.color            = m_color;
            m_panel.clipChildren     = true;
            m_panel.relativePosition = Vector2.zero;

            // Scrollbar
            m_scrollbar             = AddUIComponent <UIScrollbar>();
            m_scrollbar.width       = 20f;
            m_scrollbar.height      = height;
            m_scrollbar.orientation = UIOrientation.Vertical;
            m_scrollbar.pivot       = UIPivotPoint.BottomLeft;
            m_scrollbar.AlignTo(this, UIAlignAnchor.TopRight);
            m_scrollbar.minValue        = 0;
            m_scrollbar.value           = 0;
            m_scrollbar.incrementAmount = 50;

            UISlicedSprite tracSprite = m_scrollbar.AddUIComponent <UISlicedSprite>();

            tracSprite.atlas            = UIUtils.GetAtlas("Ingame");
            tracSprite.relativePosition = Vector2.zero;
            tracSprite.autoSize         = true;
            tracSprite.size             = tracSprite.parent.size;
            tracSprite.fillDirection    = UIFillDirection.Vertical;
            tracSprite.spriteName       = "ScrollbarTrack";

            m_scrollbar.trackObject = tracSprite;

            UISlicedSprite thumbSprite = tracSprite.AddUIComponent <UISlicedSprite>();

            thumbSprite.atlas            = UIUtils.GetAtlas("Ingame");
            thumbSprite.relativePosition = Vector2.zero;
            thumbSprite.fillDirection    = UIFillDirection.Vertical;
            thumbSprite.autoSize         = true;
            thumbSprite.width            = thumbSprite.parent.width - 8;
            thumbSprite.spriteName       = "ScrollbarThumb";

            m_scrollbar.thumbObject = thumbSprite;

            // Rows
            CheckRows();

            m_scrollbar.eventValueChanged += (c, t) =>
            {
                if (m_lock || m_rowHeight <= 0)
                {
                    return;
                }

                m_lock = true;

                listPosition = m_scrollbar.value * (m_rowsData.m_size - height / m_rowHeight) / (height - m_scrollbar.scrollSize - 1f);
                m_lock       = false;
            };
        }
Esempio n. 15
0
        public override void Awake()
        {
            height = 46;

            focusButton                  = UIUtils.CreateButton(this);
            focusButton.name             = "CCX_FocusButton";
            focusButton.text             = "Point 0";
            focusButton.size             = new Vector2(70f, 30f);
            focusButton.relativePosition = new Vector3(8, 8);
            focusButton.tooltip          = "Click here to place the camera at this point";

            easingDropDown           = UIUtils.CreateDropDown(this);
            easingDropDown.name      = "CCX_EasingDropDown";
            easingDropDown.textScale = 0.9f;
            easingDropDown.AddItem("None");
            easingDropDown.AddItem("Auto");
            easingDropDown.AddItem("In");
            easingDropDown.AddItem("Out");
            easingDropDown.AddItem("InOut");
            easingDropDown.selectedValue        = "Auto";
            easingDropDown.size                 = new Vector2(80f, 30f);
            easingDropDown.textFieldPadding.top = 7;
            easingDropDown.relativePosition     = new Vector3(focusButton.relativePosition.x + focusButton.width + 8, 8);
            easingDropDown.tooltip              = "Camera movement easing";

            durationInput                  = UIUtils.CreateTextField(this);
            durationInput.name             = "CCX_DurationInput";
            durationInput.size             = new Vector2(40f, 26f);
            durationInput.numericalOnly    = true;
            durationInput.allowFloats      = true;
            durationInput.padding.top      = 6;
            durationInput.relativePosition = new Vector3(easingDropDown.relativePosition.x + easingDropDown.width + 8, 10);
            durationInput.tooltip          = "Duration in seconds";

            delayInput                  = UIUtils.CreateTextField(this);
            delayInput.name             = "CCX_DelayInput";
            delayInput.size             = new Vector2(45f, 26f);
            delayInput.numericalOnly    = true;
            delayInput.allowFloats      = true;
            delayInput.padding.top      = 6;
            delayInput.relativePosition = new Vector3(durationInput.relativePosition.x + durationInput.width + 8, 10);
            delayInput.tooltip          = "Delay in seconds";

            fovInput                  = UIUtils.CreateTextField(this);
            fovInput.name             = "CCX_DelayInput";
            fovInput.size             = new Vector2(45f, 26);
            fovInput.numericalOnly    = true;
            fovInput.allowFloats      = true;
            fovInput.padding.top      = 6;
            fovInput.relativePosition = new Vector3(delayInput.relativePosition.x + delayInput.width + 8, 10);
            fovInput.tooltip          = "Field of view in degrees";

            resetButton                  = UIUtils.CreateButton(this);
            resetButton.name             = "CCX_ResetButton";
            resetButton.text             = "O";
            resetButton.size             = new Vector2(45f, 30f);
            resetButton.relativePosition = new Vector3(fovInput.relativePosition.x + fovInput.width + 8, 8);
            resetButton.tooltip          = "Recapture the camera position";

            removeButton                  = UIUtils.CreateButton(this);
            removeButton.name             = "CCX_RemoveButton";
            removeButton.text             = "X";
            removeButton.size             = new Vector2(40f, 30f);
            removeButton.relativePosition = new Vector3(resetButton.relativePosition.x + resetButton.width + 8, 8);
            removeButton.tooltip          = "Remove this point";

            focusButton.eventClicked += (c, p) =>
            {
                CameraPath.SetCitiesCameraTransform(knot);
            };

            easingDropDown.eventSelectedIndexChanged += (c, p) =>
            {
                knot.mode = (EasingMode)p;
            };

            durationInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value) && value > 0)
                {
                    knot.duration = value;
                }

                durationInput.text = knot.duration.ToString();
            };

            durationInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(durationInput.text, out value))
                {
                    knot.duration      = Mathf.Max(0, value + p.wheelDelta);
                    durationInput.text = knot.duration.ToString();
                }
                p.Use();
            };

            delayInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    knot.delay = Mathf.Max(0, value);
                }

                delayInput.text = knot.delay.ToString();
            };

            delayInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(delayInput.text, out value))
                {
                    knot.delay      = Mathf.Max(0, value + p.wheelDelta);
                    delayInput.text = knot.delay.ToString();
                }
                p.Use();
            };

            fovInput.eventTextSubmitted += (c, p) =>
            {
                float value;
                if (float.TryParse(p, out value))
                {
                    knot.fov = Mathf.Clamp(value, 20f, 179f) / 2f;
                }

                fovInput.text = (2f * knot.fov).ToString();
            };

            fovInput.eventMouseWheel += (c, p) =>
            {
                float value;
                if (float.TryParse(fovInput.text, out value))
                {
                    knot.fov      = Mathf.Clamp(value + p.wheelDelta, 20f, 179f) / 2f;
                    fovInput.text = (2f * knot.fov).ToString();
                }
                p.Use();
            };

            resetButton.eventClicked += (c, p) =>
            {
                knot.CaptureCamera();
                fovInput.text = (2f * knot.fov).ToString();
            };

            removeButton.eventClicked += (c, p) =>
            {
                CameraDirector.cameraPath.knots.RemoveAt(index);
                CameraDirector.mainWindow.RefreshKnotList();
            };
        }
Esempio n. 16
0
        public override void Start()
        {
            UIMoreTools.Initialise();

            instance = this;

            UICheckBox checkBox = null;

            atlas            = UIUtils.GetAtlas("Ingame");
            size             = new Vector2(41, 41);
            relativePosition = new Vector2(GetUIView().GetScreenResolution().x - 448, -41);
            name             = "MoveIt_ToolOptionPanel";

            DebugUtils.Log("ToolOptionPanel position: " + absolutePosition);

            #region Group
            // Group
            m_group                 = AddUIComponent <UIButton>();
            m_group.name            = "MoveIt_Group";
            m_group.group           = m_tabStrip;
            m_group.atlas           = GetIconsAtlas();
            m_group.tooltip         = "Group";
            m_group.playAudioEvents = true;

            m_group.size = new Vector2(36, 36);

            m_group.normalBgSprite   = "OptionBase";
            m_group.hoveredBgSprite  = "OptionBaseHovered";
            m_group.pressedBgSprite  = "OptionBasePressed";
            m_group.disabledBgSprite = "OptionBaseDisabled";

            m_group.normalFgSprite = "Group";

            m_group.relativePosition = Vector2.zero;
            m_group.isVisible        = false; //TODO: temporary
            #endregion

            #region Save
            m_save                 = AddUIComponent <UIButton>();
            m_save.name            = "MoveIt_Save";
            m_save.group           = m_tabStrip;
            m_save.atlas           = GetIconsAtlas();
            m_save.tooltip         = "Export";
            m_save.playAudioEvents = true;

            m_save.size = new Vector2(36, 36);

            m_save.normalBgSprite   = "OptionBase";
            m_save.hoveredBgSprite  = "OptionBaseHovered";
            m_save.pressedBgSprite  = "OptionBasePressed";
            m_save.disabledBgSprite = "OptionBaseDisabled";

            m_save.normalFgSprite   = "Save";
            m_save.disabledFgSprite = "Save_disabled";

            m_save.relativePosition = m_group.relativePosition + new Vector3(m_group.width, 0);

            m_save.eventClicked += (c, p) =>
            {
                if (MoveItTool.IsExportSelectionValid())
                {
                    UISaveWindow.Open();
                }
                else
                {
                    UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Selection invalid", "The selection is empty or invalid.", false);
                }
            };
            #endregion

            #region Load
            m_load                 = AddUIComponent <UIButton>();
            m_load.name            = "MoveIt_Load";
            m_load.group           = m_tabStrip;
            m_load.atlas           = GetIconsAtlas();
            m_load.tooltip         = "Import";
            m_load.playAudioEvents = true;

            m_load.size = new Vector2(36, 36);

            m_load.normalBgSprite   = "OptionBase";
            m_load.hoveredBgSprite  = "OptionBaseHovered";
            m_load.pressedBgSprite  = "OptionBasePressed";
            m_load.disabledBgSprite = "OptionBaseDisabled";

            m_load.normalFgSprite = "Load";

            m_load.relativePosition = m_save.relativePosition + new Vector3(m_save.width, 0);

            m_load.eventClicked += (c, p) =>
            {
                UILoadWindow.Open();
            };
            #endregion

            #region Follow Terrain
            m_followTerrain                 = AddUIComponent <UIMultiStateButton>();
            m_followTerrain.atlas           = GetFollowTerrainAtlas();
            m_followTerrain.name            = "MoveIt_FollowTerrain";
            m_followTerrain.tooltip         = "Follow Terrain";
            m_followTerrain.playAudioEvents = true;

            m_followTerrain.size          = new Vector2(36, 36);
            m_followTerrain.spritePadding = new RectOffset();

            m_followTerrain.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_followTerrain.backgroundSprites[0].normal   = "ToggleBase";
            m_followTerrain.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_followTerrain.backgroundSprites.AddState();
            m_followTerrain.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[1].hovered  = "";
            m_followTerrain.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_followTerrain.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_followTerrain.foregroundSprites[0].normal = "FollowTerrain_disabled";

            m_followTerrain.foregroundSprites.AddState();
            m_followTerrain.foregroundSprites[1].normal = "FollowTerrain";

            m_followTerrain.relativePosition = m_load.relativePosition + new Vector3(m_load.width + m_load.width / 2, 0);

            m_followTerrain.activeStateIndex = MoveItTool.followTerrain ? 1 : 0;

            m_followTerrain.eventClicked += (c, p) =>
            {
                MoveItTool.followTerrain = (m_followTerrain.activeStateIndex == 1);
                MoveItTool.followTerrainModeEnabled.value = (m_followTerrain.activeStateIndex == 1);
            };
            #endregion

            #region Snapping
            m_snapping                 = AddUIComponent <UIMultiStateButton>();
            m_snapping.atlas           = UIUtils.GetAtlas("Ingame");
            m_snapping.name            = "MoveIt_Snapping";
            m_snapping.tooltip         = "Toggle Snapping";
            m_snapping.playAudioEvents = true;

            m_snapping.size          = new Vector2(36, 36);
            m_snapping.spritePadding = new RectOffset();

            m_snapping.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_snapping.backgroundSprites[0].normal   = "ToggleBase";
            m_snapping.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_snapping.backgroundSprites.AddState();
            m_snapping.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[1].hovered  = "";
            m_snapping.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_snapping.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_snapping.foregroundSprites[0].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[0].hovered  = "SnappingHovered";
            m_snapping.foregroundSprites[0].normal   = "Snapping";
            m_snapping.foregroundSprites[0].pressed  = "SnappingPressed";

            m_snapping.foregroundSprites.AddState();
            m_snapping.foregroundSprites[1].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[1].hovered  = "";
            m_snapping.foregroundSprites[1].normal   = "SnappingFocused";
            m_snapping.foregroundSprites[1].pressed  = "SnappingPressed";

            m_snapping.relativePosition = m_followTerrain.relativePosition + new Vector3(m_followTerrain.width, 0);

            m_snapping.activeStateIndex = (MoveItTool.instance != null && MoveItTool.instance.snapping) ? 1 : 0;

            m_snapping.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.snapping = (m_snapping.activeStateIndex == 1);
                }
            };
            #endregion

            m_tabStrip      = AddUIComponent <UITabstrip>();
            m_tabStrip.size = new Vector2(36, 72);

            m_tabStrip.relativePosition = m_snapping.relativePosition + new Vector3(m_snapping.width, 0);

            #region Single Select
            m_single                 = m_tabStrip.AddTab("MoveIt_Single", null, false);
            m_single.group           = m_tabStrip;
            m_single.atlas           = UIUtils.GetAtlas("Ingame");
            m_single.tooltip         = "Single Selection";
            m_single.playAudioEvents = true;

            m_single.size = new Vector2(36, 36);

            m_single.normalBgSprite    = "OptionBase";
            m_single.focusedBgSprite   = "OptionBaseFocused";
            m_single.hoveredBgSprite   = "OptionBaseHovered";
            m_single.pressedBgSprite   = "OptionBasePressed";
            m_single.disabledBgSprite  = "OptionBaseDisabled";
            m_single.text              = "•";
            m_single.textScale         = 1.5f;
            m_single.textPadding       = new RectOffset(0, 1, 4, 0);
            m_single.textColor         = new Color32(119, 124, 126, 255);
            m_single.hoveredTextColor  = new Color32(110, 113, 114, 255);
            m_single.pressedTextColor  = new Color32(172, 175, 176, 255);
            m_single.focusedTextColor  = new Color32(187, 224, 235, 255);
            m_single.disabledTextColor = new Color32(66, 69, 70, 255);
            #endregion

            #region Marquee Select
            m_marquee                 = m_tabStrip.AddTab("MoveIt_Marquee", null, false);
            m_marquee.group           = m_tabStrip;
            m_marquee.atlas           = UIUtils.GetAtlas("Ingame");
            m_marquee.tooltip         = "Marquee Selection";
            m_marquee.playAudioEvents = true;

            m_marquee.size = new Vector2(36, 36);

            m_marquee.normalBgSprite   = "OptionBase";
            m_marquee.focusedBgSprite  = "OptionBaseFocused";
            m_marquee.hoveredBgSprite  = "OptionBaseHovered";
            m_marquee.pressedBgSprite  = "OptionBasePressed";
            m_marquee.disabledBgSprite = "OptionBaseDisabled";

            m_marquee.normalFgSprite   = "ZoningOptionMarquee";
            m_marquee.relativePosition = m_single.relativePosition + new Vector3(m_single.width, 0);
            #endregion

            #region filtersPanel

            m_filtersPanel                  = AddUIComponent(typeof(UIPanel)) as UIPanel;
            m_filtersPanel.atlas            = UIUtils.GetAtlas("Ingame");
            m_filtersPanel.backgroundSprite = "SubcategoriesPanel";
            m_filtersPanel.clipChildren     = true;
            m_filtersPanel.size             = new Vector2(150, 235);
            m_filtersPanel.isVisible        = false;
            UIFilters.FilterPanel           = m_filtersPanel;

            void OnDoubleClick(UIComponent c, UIMouseEventParameter p)
            {
                foreach (UICheckBox cb in UIFilters.FilterCBs)
                {
                    cb.isChecked = false;
                    Filters.SetFilter(cb.name, false);
                }
                ((UICheckBox)c).isChecked = true;
                Filters.SetFilter(c.name, true);

                UIFilters.RefreshFilters();
            }

            void OnPickerClick(UIComponent c, UIMouseEventParameter p)
            {
                MoveItTool.instance.ToolState = MoveItTool.ToolStates.Picking;
                UIFilters.UpdatePickerButton(2);
            }

            void OnPickerDoubleClick(UIComponent c, UIMouseEventParameter p)
            {
                Filters.Picker = new PickerFilter();

                Filters.SetFilter("Picker", false);
                MoveItTool.instance.ToolState = MoveItTool.ToolStates.Default;
                UIFilters.UpdatePickerButton(1);
            }

            #region Standard Filters
            m_filtersPanelList      = m_filtersPanel.AddUIComponent(typeof(UIPanel)) as UIPanel;
            m_filtersPanelList.name = "m_filtersPanelList";

            m_picker = UIUtils.CreateButton(m_filtersPanel);
            m_picker.relativePosition  = new Vector3(122, 9);
            m_picker.size              = new Vector2(20, 20);
            m_picker.atlas             = GetIconsAtlas();
            m_picker.normalFgSprite    = "EyeDropper";
            m_picker.normalBgSprite    = "OptionsDropboxListbox";
            m_picker.hoveredBgSprite   = "OptionsDropboxListboxFocused";
            m_picker.pressedBgSprite   = "OptionsDropboxListboxHovered";
            m_picker.eventClick       += OnPickerClick;
            m_picker.eventDoubleClick += OnPickerDoubleClick;
            m_picker.name              = "mit_pickerButton";

            checkBox        = UIFilters.CreateFilterCB(m_filtersPanelList, "Picker", null, false);
            checkBox.width -= 21;
            UIFilters.UpdatePickerLabel("Picker", "Pick an object to filter for objects of the same type", UIFilters.InactiveLabelColor, false);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Buildings");
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Props");
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Decals");
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Surfaces");
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Trees");
            checkBox.eventDoubleClick += OnDoubleClick;

            if (MoveItTool.PO.Enabled)
            {
                if (MoveItTool.PO.Active)
                {
                    m_filtersPanel.height += 20f;
                }
                checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "PO");
                checkBox.eventDoubleClick += OnDoubleClick;
                checkBox.isVisible         = MoveItTool.PO.Active;
            }

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Nodes");
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Segments");
            checkBox.eventDoubleClick += OnDoubleClick;
            #endregion

            #region Network Filters
            UIButton btnNetworks = UIFilters.CreateToggleNFBtn();
            void OnDoubleClickNetworkFilter(UIComponent c, UIMouseEventParameter p)
            {
                foreach (UICheckBox cb in UIFilters.NetworkCBs)
                {
                    cb.isChecked = false;
                    Filters.SetNetworkFilter(cb.name, false);
                }
                ((UICheckBox)c).isChecked = true;
                Filters.SetNetworkFilter(c.name, true);

                UIFilters.RefreshFilters();
            }

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Roads");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Tracks");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Paths");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Fences");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Powerlines");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Others");
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            UIFilters.RefreshFilters();
            #endregion

            m_filtersPanelList.padding             = new RectOffset(10, 10, 10, 10);
            m_filtersPanelList.autoLayoutDirection = LayoutDirection.Vertical;
            m_filtersPanelList.autoLayoutPadding   = new RectOffset(0, 0, 0, 5);
            m_filtersPanelList.autoLayout          = true;
            m_filtersPanelList.relativePosition    = new Vector3(0, 0, 0);
            m_filtersPanel.autoLayout       = false;
            m_filtersPanel.absolutePosition = m_marquee.absolutePosition + new Vector3(-47, -5 - m_filtersPanel.height);
            #endregion

            m_marquee.eventButtonStateChanged += (c, p) =>
            {
                MoveItTool.marqueeSelection = p == UIButton.ButtonState.Focused;
                m_filtersPanel.isVisible    = MoveItTool.marqueeSelection;

                if (UIChangesWindow.instance != null)
                {
                    UIChangesWindow.instance.RefreshPosition();
                }
            };
            m_marquee.eventDoubleClick += (UIComponent c, UIMouseEventParameter p) =>
            {
                bool newChecked = false;
                foreach (UICheckBox cb in m_filtersPanel.GetComponentsInChildren <UICheckBox>())
                {
                    if (cb.name == "Picker")
                    {
                        continue;
                    }
                    if (!cb.isChecked)
                    {
                        newChecked = true;
                        break;
                    }
                }

                foreach (UICheckBox cb in m_filtersPanel.GetComponentsInChildren <UICheckBox>())
                {
                    if (cb.name == "Picker")
                    {
                        cb.isChecked = false;
                        Filters.SetAnyFilter(cb.name, false);
                    }
                    else
                    {
                        cb.isChecked = newChecked;
                        Filters.SetAnyFilter(cb.name, newChecked);
                    }
                }

                UIFilters.RefreshFilters();
            };

            #region Copy
            m_copy                 = AddUIComponent <UIButton>();
            m_copy.name            = "MoveIt_Copy";
            m_copy.group           = m_tabStrip;
            m_copy.atlas           = GetIconsAtlas();
            m_copy.tooltip         = "Copy (Alt+Click to duplicate in-place)";
            m_copy.playAudioEvents = true;

            m_copy.size = new Vector2(36, 36);

            m_copy.normalBgSprite   = "OptionBase";
            m_copy.hoveredBgSprite  = "OptionBaseHovered";
            m_copy.pressedBgSprite  = "OptionBasePressed";
            m_copy.disabledBgSprite = "OptionBaseDisabled";

            m_copy.normalFgSprite = "Copy";

            m_copy.relativePosition = m_tabStrip.relativePosition + new Vector3(m_single.width + m_marquee.width, 0);

            m_copy.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    if (MoveItTool.instance.ToolState == MoveItTool.ToolStates.Cloning)
                    {
                        MoveItTool.instance.StopCloning();
                    }
                    else
                    {
                        if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                        {
                            if (Action.selection.Count > 0)
                            {
                                DuplicateAction action = new DuplicateAction();
                                if (action.Count > 0)
                                {
                                    ActionQueue.instance.Push(action);
                                    ActionQueue.instance.Do();
                                }
                            }
                        }
                        else
                        {
                            MoveItTool.instance.StartCloning();
                        }
                    }
                }
            };
            #endregion

            #region Bulldoze
            m_bulldoze                 = AddUIComponent <UIButton>();
            m_bulldoze.name            = "MoveIt_Bulldoze";
            m_bulldoze.group           = m_tabStrip;
            m_bulldoze.atlas           = GetIconsAtlas();
            m_bulldoze.tooltip         = "Bulldoze";
            m_bulldoze.playAudioEvents = true;

            m_bulldoze.size = new Vector2(36, 36);

            m_bulldoze.normalBgSprite   = "OptionBase";
            m_bulldoze.hoveredBgSprite  = "OptionBaseHovered";
            m_bulldoze.pressedBgSprite  = "OptionBasePressed";
            m_bulldoze.disabledBgSprite = "OptionBaseDisabled";

            m_bulldoze.normalFgSprite = "Bulldoze";

            m_bulldoze.relativePosition = m_copy.relativePosition + new Vector3(m_copy.width, 0);

            m_bulldoze.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                    {
                        MoveItTool.instance.StartReset();
                    }
                    else
                    {
                        MoveItTool.instance.StartBulldoze();
                    }
                }
            };
            #endregion

            #region More Tools
            m_moreTools = AddUIComponent <UIButton>();
            UIMoreTools.MoreToolsBtn     = m_moreTools;
            m_moreTools.name             = "MoveIt_MoreToolsBtn";
            m_moreTools.group            = m_tabStrip;
            m_moreTools.atlas            = GetIconsAtlas();
            m_moreTools.tooltip          = "More Tools";
            m_moreTools.playAudioEvents  = true;
            m_moreTools.size             = new Vector2(36, 36);
            m_moreTools.normalBgSprite   = "OptionBase";
            m_moreTools.hoveredBgSprite  = "OptionBaseHovered";
            m_moreTools.pressedBgSprite  = "OptionBasePressed";
            m_moreTools.disabledBgSprite = "OptionBaseDisabled";
            m_moreTools.normalFgSprite   = "MoreTools";
            m_moreTools.relativePosition = m_bulldoze.relativePosition + new Vector3(m_bulldoze.width, 0);
            m_moreTools.eventClicked    += UIMoreTools.MoreToolsClicked;

            m_moreToolsPanel                  = AddUIComponent <UIPanel>();
            UIMoreTools.MoreToolsPanel        = m_moreToolsPanel;
            m_moreToolsPanel.name             = "mtPanel";
            m_moreToolsPanel.autoLayout       = false;
            m_moreToolsPanel.clipChildren     = true;
            m_moreToolsPanel.size             = new Vector2(36, 322 + (MoveItTool.PO.Enabled ? 40 : 0));
            m_moreToolsPanel.isVisible        = false;
            m_moreToolsPanel.absolutePosition = m_moreTools.absolutePosition + new Vector3(0, 10 - m_moreToolsPanel.height);
            m_moreTools.zOrder                = m_moreToolsPanel.zOrder + 10;

            // The vertical shade
            UIPanel mtpBackground = m_moreToolsPanel.AddUIComponent <UIPanel>();
            mtpBackground.name             = "mtpBackground";
            mtpBackground.clipChildren     = true;
            mtpBackground.relativePosition = new Vector3(5, 10);
            mtpBackground.atlas            = UIUtils.GetAtlas("Ingame");
            mtpBackground.backgroundSprite = "InfoPanelBack";
            mtpBackground.size             = m_moreToolsPanel.size - new Vector2(10, 10);

            UIPanel mtpContainer = m_moreToolsPanel.AddUIComponent <UIPanel>();
            mtpContainer.name = "mtpContainer";
            mtpContainer.autoLayoutDirection = LayoutDirection.Vertical;
            mtpContainer.autoLayoutPadding   = new RectOffset(0, 0, 0, 3);
            mtpContainer.autoLayout          = true;
            mtpContainer.relativePosition    = Vector3.zero;
            mtpContainer.size = m_moreToolsPanel.size;

            UIMoreTools.MoreButtons.Clear();

            if (MoveItTool.PO.Enabled)
            {
                UIMoreTools.MoreButtons.Add("MoveIt_ConvertToPOBtn", mtpContainer.AddUIComponent <UIButton>());
                UIButton convertToPO = UIMoreTools.MoreButtons["MoveIt_ConvertToPOBtn"];
                convertToPO.name             = "MoveIt_ConvertToPOBtn";
                convertToPO.atlas            = GetIconsAtlas();
                convertToPO.tooltip          = "Convert To PO - tries to convert all selected\nbuildings and props into Procedural Objects.";
                convertToPO.playAudioEvents  = true;
                convertToPO.size             = new Vector2(36, 36);
                convertToPO.normalBgSprite   = "OptionBase";
                convertToPO.hoveredBgSprite  = "OptionBaseHovered";
                convertToPO.pressedBgSprite  = "OptionBasePressed";
                convertToPO.disabledBgSprite = "OptionBaseDisabled";
                convertToPO.normalFgSprite   = "ConvertToPO";
                convertToPO.eventClicked    += UIMoreTools.MoreToolsClicked;
            }

            UIMoreTools.MoreButtons.Add("MoveIt_ResetObjectBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton resetObject = UIMoreTools.MoreButtons["MoveIt_ResetObjectBtn"];
            resetObject.name             = "MoveIt_ResetObjectBtn";
            resetObject.atlas            = GetIconsAtlas();
            resetObject.tooltip          = "Reset - Rebuild selected objects, repairing them and changing size/color variations.";
            resetObject.playAudioEvents  = true;
            resetObject.size             = new Vector2(36, 36);
            resetObject.normalBgSprite   = "OptionBase";
            resetObject.hoveredBgSprite  = "OptionBaseHovered";
            resetObject.pressedBgSprite  = "OptionBasePressed";
            resetObject.disabledBgSprite = "OptionBaseDisabled";
            resetObject.normalFgSprite   = "ResetObject";
            resetObject.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignMirrorBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignMirror = UIMoreTools.MoreButtons["MoveIt_AlignMirrorBtn"];
            alignMirror.name             = "MoveIt_AlignMirrorBtn";
            alignMirror.atlas            = GetIconsAtlas();
            alignMirror.tooltip          = "Align Mirror - Click on a network segment to set the\nmirror axis to create a mirrored copy of selection";
            alignMirror.playAudioEvents  = true;
            alignMirror.size             = new Vector2(36, 36);
            alignMirror.normalBgSprite   = "OptionBase";
            alignMirror.hoveredBgSprite  = "OptionBaseHovered";
            alignMirror.pressedBgSprite  = "OptionBasePressed";
            alignMirror.disabledBgSprite = "OptionBaseDisabled";
            alignMirror.normalFgSprite   = "AlignMirror";
            alignMirror.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignRandomBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignRandom = UIMoreTools.MoreButtons["MoveIt_AlignRandomBtn"];
            alignRandom.name             = "MoveIt_AlignRandomBtn";
            alignRandom.atlas            = GetIconsAtlas();
            alignRandom.tooltip          = "Random - Immediately rotate valid objects randomly";
            alignRandom.playAudioEvents  = true;
            alignRandom.size             = new Vector2(36, 36);
            alignRandom.normalBgSprite   = "OptionBase";
            alignRandom.hoveredBgSprite  = "OptionBaseHovered";
            alignRandom.pressedBgSprite  = "OptionBasePressed";
            alignRandom.disabledBgSprite = "OptionBaseDisabled";
            alignRandom.normalFgSprite   = "AlignRandom";
            alignRandom.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignGroupBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignGroup = UIMoreTools.MoreButtons["MoveIt_AlignGroupBtn"];
            alignGroup.name             = "MoveIt_AlignGroupBtn";
            alignGroup.atlas            = GetIconsAtlas();
            alignGroup.tooltip          = "Align as Group - click on an object to rotate\nselection around a central point to face\nobject's direction";
            alignGroup.playAudioEvents  = true;
            alignGroup.size             = new Vector2(36, 36);
            alignGroup.normalBgSprite   = "OptionBase";
            alignGroup.hoveredBgSprite  = "OptionBaseHovered";
            alignGroup.pressedBgSprite  = "OptionBasePressed";
            alignGroup.disabledBgSprite = "OptionBaseDisabled";
            alignGroup.normalFgSprite   = "AlignGroup";
            alignGroup.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignIndividualBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignIndividual = UIMoreTools.MoreButtons["MoveIt_AlignIndividualBtn"];
            alignIndividual.name             = "MoveIt_AlignIndividualBtn";
            alignIndividual.atlas            = GetIconsAtlas();
            alignIndividual.tooltip          = "Align In-Place - click on an object to\nrotate selected items to face that direction";
            alignIndividual.playAudioEvents  = true;
            alignIndividual.size             = new Vector2(36, 36);
            alignIndividual.normalBgSprite   = "OptionBase";
            alignIndividual.hoveredBgSprite  = "OptionBaseHovered";
            alignIndividual.pressedBgSprite  = "OptionBasePressed";
            alignIndividual.disabledBgSprite = "OptionBaseDisabled";
            alignIndividual.normalFgSprite   = "AlignIndividual";
            alignIndividual.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignSlopeBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignSlope = UIMoreTools.MoreButtons["MoveIt_AlignSlopeBtn"];
            alignSlope.name             = "MoveIt_AlignSlopeBtn";
            alignSlope.atlas            = GetIconsAtlas();
            alignSlope.tooltip          = "Align Slope - click on 2 objects to define\nthe slope axis to move selected objects\nup/down to that height";
            alignSlope.playAudioEvents  = true;
            alignSlope.size             = new Vector2(36, 36);
            alignSlope.normalBgSprite   = "OptionBase";
            alignSlope.hoveredBgSprite  = "OptionBaseHovered";
            alignSlope.pressedBgSprite  = "OptionBasePressed";
            alignSlope.disabledBgSprite = "OptionBaseDisabled";
            alignSlope.normalFgSprite   = "AlignSlope";
            alignSlope.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignTerrainHeightBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignTerrainHeight = UIMoreTools.MoreButtons["MoveIt_AlignTerrainHeightBtn"];
            alignTerrainHeight.name             = "MoveIt_AlignTerrainHeightBtn";
            alignTerrainHeight.atlas            = GetIconsAtlas();
            alignTerrainHeight.tooltip          = "Immediately Align objects to Terrain Height";
            alignTerrainHeight.playAudioEvents  = true;
            alignTerrainHeight.size             = new Vector2(36, 36);
            alignTerrainHeight.normalBgSprite   = "OptionBase";
            alignTerrainHeight.hoveredBgSprite  = "OptionBaseHovered";
            alignTerrainHeight.pressedBgSprite  = "OptionBasePressed";
            alignTerrainHeight.disabledBgSprite = "OptionBaseDisabled";
            alignTerrainHeight.normalFgSprite   = "AlignTerrainHeight";
            alignTerrainHeight.eventClicked    += UIMoreTools.MoreToolsClicked;

            UIMoreTools.MoreButtons.Add("MoveIt_AlignHeightBtn", mtpContainer.AddUIComponent <UIButton>());
            UIButton alignHeight = UIMoreTools.MoreButtons["MoveIt_AlignHeightBtn"];
            alignHeight.name             = "MoveIt_AlignHeightBtn";
            alignHeight.atlas            = GetIconsAtlas();
            alignHeight.tooltip          = "Align Height - click on an object to move\nselected objects up/down to that height";
            alignHeight.playAudioEvents  = true;
            alignHeight.size             = new Vector2(36, 36);
            alignHeight.normalBgSprite   = "OptionBase";
            alignHeight.hoveredBgSprite  = "OptionBaseHovered";
            alignHeight.pressedBgSprite  = "OptionBasePressed";
            alignHeight.disabledBgSprite = "OptionBaseDisabled";
            alignHeight.normalFgSprite   = "AlignHeight";
            alignHeight.eventClicked    += UIMoreTools.MoreToolsClicked;
            #endregion

            #region View Options
            m_viewOptions                  = AddUIComponent <UIPanel>();
            m_viewOptions.atlas            = UIUtils.GetAtlas("Ingame");
            m_viewOptions.backgroundSprite = "InfoPanelBack";
            m_viewOptions.size             = new Vector2(44f, 80f);

            m_viewOptions.absolutePosition = new Vector3(GetUIView().GetScreenResolution().x - m_viewOptions.width, absolutePosition.y - m_viewOptions.height - 8f);


            grid                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
            grid.atlas           = GetIconsAtlas();
            grid.name            = "MoveIt_GridView";
            grid.tooltip         = "Toggle Grid";
            grid.playAudioEvents = true;

            grid.size          = new Vector2(36, 36);
            grid.spritePadding = new RectOffset();

            grid.backgroundSprites[0].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[0].hovered  = "OptionBaseHovered";
            grid.backgroundSprites[0].normal   = "OptionBase";
            grid.backgroundSprites[0].pressed  = "OptionBasePressed";

            grid.backgroundSprites.AddState();
            grid.backgroundSprites[1].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[1].hovered  = "";
            grid.backgroundSprites[1].normal   = "OptionBaseFocused";
            grid.backgroundSprites[1].pressed  = "OptionBasePressed";

            grid.foregroundSprites[0].normal = "Grid";

            grid.foregroundSprites.AddState();
            grid.foregroundSprites[1].normal = "GridFocused";

            grid.relativePosition = new Vector3(4f, 4f);

            grid.activeStateIndex = 0;

            grid.eventClicked += (c, p) =>
            {
                MoveItTool.gridVisible = (grid.activeStateIndex == 1);
            };


            underground                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
            underground.atlas           = UIUtils.GetAtlas("Ingame");
            underground.name            = "MoveIt_UndergroundView";
            underground.tooltip         = "Toogle Underground View";
            underground.playAudioEvents = true;

            underground.size          = new Vector2(36, 36);
            underground.spritePadding = new RectOffset();

            underground.backgroundSprites[0].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[0].hovered  = "OptionBaseHovered";
            underground.backgroundSprites[0].normal   = "OptionBase";
            underground.backgroundSprites[0].pressed  = "OptionBasePressed";

            underground.backgroundSprites.AddState();
            underground.backgroundSprites[1].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[1].hovered  = "";
            underground.backgroundSprites[1].normal   = "OptionBaseFocused";
            underground.backgroundSprites[1].pressed  = "OptionBasePressed";

            underground.foregroundSprites[0].normal = "BulldozerOptionPipes";

            underground.foregroundSprites.AddState();
            underground.foregroundSprites[1].normal = "BulldozerOptionPipesFocused";

            underground.relativePosition = new Vector3(4f, 40f);

            underground.activeStateIndex = 0;

            underground.eventClicked += (c, p) =>
            {
                MoveItTool.tunnelVisible = (underground.activeStateIndex == 1);
            };


            if (MoveItTool.PO.Enabled)
            {
                PO_button                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
                PO_button.atlas           = GetIconsAtlas();
                PO_button.name            = "MoveIt_PO_button";
                PO_button.tooltip         = "Toggle Procedural Objects";
                PO_button.playAudioEvents = true;

                PO_button.size          = new Vector2(36, 36);
                PO_button.spritePadding = new RectOffset();

                PO_button.backgroundSprites[0].disabled = "OptionBaseDisabled";
                PO_button.backgroundSprites[0].hovered  = "OptionBaseHovered";
                PO_button.backgroundSprites[0].normal   = "OptionBase";
                PO_button.backgroundSprites[0].pressed  = "OptionBasePressed";

                PO_button.backgroundSprites.AddState();
                PO_button.backgroundSprites[1].disabled = "OptionBaseDisabled";
                PO_button.backgroundSprites[1].hovered  = "";
                PO_button.backgroundSprites[1].normal   = "OptionBaseFocused";
                PO_button.backgroundSprites[1].pressed  = "OptionBasePressed";

                PO_button.foregroundSprites[0].normal = "PO";

                PO_button.foregroundSprites.AddState();
                PO_button.foregroundSprites[1].normal = "POFocused";

                PO_button.relativePosition = new Vector3(4f, 76f);

                PO_button.activeStateIndex = 0;

                PO_button.eventClicked += (c, p) =>
                {
                    MoveItTool.PO.Active = (PO_button.activeStateIndex == 1);
                    if (MoveItTool.PO.Active)
                    {
                        if (MoveItTool.instance.ToolState == MoveItTool.ToolStates.Cloning)
                        {
                            MoveItTool.instance.StopCloning();
                        }

                        MoveItTool.PO.ToolEnabled();
                        ActionQueue.instance.Push(new TransformAction());
                    }
                    else
                    {
                        Action.ClearPOFromSelection();
                    }
                    UIFilters.POToggled();
                };

                m_viewOptions.height           += 36;
                m_viewOptions.absolutePosition += new Vector3(0, -36);
            }

            #endregion
        }
Esempio n. 17
0
        internal void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = AVOMod.ModName + " " + AVOMod.Version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = Translations.Translate("AVO_MOD_MP56");

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = Translations.Translate("AVO_MOD_MP39");
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = Translations.Translate("AVO_MOD_MP40");
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = Translations.Translate("AVO_MOD_MP55");

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = Translations.Translate("AVO_MOD_MP41");
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = Translations.Translate("AVO_MOD_MP42");
            m_import.width            = 80;
            m_import.tooltip          = Translations.Translate("AVO_MOD_MP43");
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = Translations.Translate("AVO_MOD_MP44");
            m_export.width            = 80;
            m_export.tooltip          = Translations.Translate("AVO_MOD_MP45");
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = Translations.Translate("AVO_MOD_MP46");
            m_resetall.width            = 80;
            m_resetall.tooltip          = Translations.Translate("AVO_MOD_MP47");
            m_resetall.relativePosition = new Vector3(180, height - 45);

            m_autosave                  = AddUIComponent <UILabel>();
            m_autosave.textScale        = 0.6f;
            m_autosave.text             = Translations.Translate("AVO_MOD_MP48");
            m_autosave.relativePosition = new Vector3(275, height - 40);
            m_autosave.autoSize         = true;
            m_autosave.textAlignment    = UIHorizontalAlignment.Center;
            m_autosave.textColor        = Color.green;
            m_autosave.tooltip          = Translations.Translate("AVO_MOD_MP49");
            m_autosave.isVisible        = AdvancedVehicleOptions.AutoSaveVehicleConfig;

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = Translations.Translate("AVO_MOD_MP50");
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = Translations.Translate("AVO_MOD_MP51");
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;

            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportVehicleDataConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };

            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportVehicleDataConfig(true);

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal(Translations.Translate("AVO_MOD_MP52"), Translations.Translate("AVO_MOD_MP53"), (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptions.ResetVehicleDataConfig();
                    optionList = AdvancedVehicleOptions.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", Translations.Translate("AVO_MOD_MP54"), false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
Esempio n. 18
0
        public override void Start()
        {
            instance = this;

            atlas            = UIUtils.GetAtlas("Ingame");
            size             = new Vector2(41, 41);
            relativePosition = new Vector2(GetUIView().GetScreenResolution().x - 340, -41);
            name             = "MoveIt_ToolOptionPanel";

            DebugUtils.Log("ToolOptionPanel position: " + absolutePosition);

            m_followTerrain                 = AddUIComponent <UIMultiStateButton>();
            m_followTerrain.atlas           = GetFollowTerrainAtlas();
            m_followTerrain.name            = "MoveIt_Snapping";
            m_followTerrain.tooltip         = "Follow Terrain";
            m_followTerrain.playAudioEvents = true;

            m_followTerrain.size          = new Vector2(36, 36);
            m_followTerrain.spritePadding = new RectOffset();

            m_followTerrain.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_followTerrain.backgroundSprites[0].normal   = "ToggleBase";
            m_followTerrain.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_followTerrain.backgroundSprites.AddState();
            m_followTerrain.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[1].hovered  = "";
            m_followTerrain.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_followTerrain.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_followTerrain.foregroundSprites[0].normal = "FollowTerrain_disabled";

            m_followTerrain.foregroundSprites.AddState();
            m_followTerrain.foregroundSprites[1].normal = "FollowTerrain";

            m_followTerrain.relativePosition = Vector2.zero;

            m_followTerrain.activeStateIndex = MoveItTool.followTerrain ? 1 : 0;

            m_followTerrain.eventClicked += (c, p) =>
            {
                MoveItTool.followTerrain = (m_followTerrain.activeStateIndex == 1);
            };

            m_snapping                 = AddUIComponent <UIMultiStateButton>();
            m_snapping.atlas           = UIUtils.GetAtlas("Ingame");
            m_snapping.name            = "MoveIt_Snapping";
            m_snapping.tooltip         = "Toggle Snapping";
            m_snapping.playAudioEvents = true;

            m_snapping.size          = new Vector2(36, 36);
            m_snapping.spritePadding = new RectOffset();

            m_snapping.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_snapping.backgroundSprites[0].normal   = "ToggleBase";
            m_snapping.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_snapping.backgroundSprites.AddState();
            m_snapping.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[1].hovered  = "";
            m_snapping.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_snapping.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_snapping.foregroundSprites[0].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[0].hovered  = "SnappingHovered";
            m_snapping.foregroundSprites[0].normal   = "Snapping";
            m_snapping.foregroundSprites[0].pressed  = "SnappingPressed";

            m_snapping.foregroundSprites.AddState();
            m_snapping.foregroundSprites[1].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[1].hovered  = "";
            m_snapping.foregroundSprites[1].normal   = "SnappingFocused";
            m_snapping.foregroundSprites[1].pressed  = "SnappingPressed";

            m_snapping.relativePosition = m_followTerrain.relativePosition + new Vector3(m_followTerrain.width, 0);

            m_snapping.activeStateIndex = (MoveItTool.instance != null && MoveItTool.instance.snapping) ? 1 : 0;

            m_snapping.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.snapping = (m_snapping.activeStateIndex == 1);
                }
            };

            m_tabStrip      = AddUIComponent <UITabstrip>();
            m_tabStrip.size = new Vector2(36, 72);

            m_tabStrip.relativePosition = m_snapping.relativePosition + new Vector3(m_snapping.width, 0);

            m_single                 = m_tabStrip.AddTab("MoveIt_Single", null, false);
            m_single.group           = m_tabStrip;
            m_single.atlas           = UIUtils.GetAtlas("Ingame");
            m_single.tooltip         = "Single Selection";
            m_single.playAudioEvents = true;

            m_single.size = new Vector2(36, 36);

            m_single.normalBgSprite    = "OptionBase";
            m_single.focusedBgSprite   = "OptionBaseFocused";
            m_single.hoveredBgSprite   = "OptionBaseHovered";
            m_single.pressedBgSprite   = "OptionBasePressed";
            m_single.disabledBgSprite  = "OptionBaseDisabled";
            m_single.text              = "•";
            m_single.textScale         = 1.5f;
            m_single.textPadding       = new RectOffset(0, 1, 4, 0);
            m_single.textColor         = new Color32(119, 124, 126, 255);
            m_single.hoveredTextColor  = new Color32(110, 113, 114, 255);
            m_single.pressedTextColor  = new Color32(172, 175, 176, 255);
            m_single.focusedTextColor  = new Color32(187, 224, 235, 255);
            m_single.disabledTextColor = new Color32(66, 69, 70, 255);

            m_marquee                 = m_tabStrip.AddTab("MoveIt_Marquee", null, false);
            m_marquee.group           = m_tabStrip;
            m_marquee.atlas           = UIUtils.GetAtlas("Ingame");
            m_marquee.tooltip         = "Marquee Selection";
            m_marquee.playAudioEvents = true;

            m_marquee.size = new Vector2(36, 36);

            m_marquee.normalBgSprite   = "OptionBase";
            m_marquee.focusedBgSprite  = "OptionBaseFocused";
            m_marquee.hoveredBgSprite  = "OptionBaseHovered";
            m_marquee.pressedBgSprite  = "OptionBasePressed";
            m_marquee.disabledBgSprite = "OptionBaseDisabled";

            m_marquee.normalFgSprite = "ZoningOptionMarquee";

            m_marquee.relativePosition = m_single.relativePosition + new Vector3(m_single.width, 0);

            filtersPanel                  = AddUIComponent(typeof(UIPanel)) as UIPanel;
            filtersPanel.atlas            = UIUtils.GetAtlas("Ingame");
            filtersPanel.backgroundSprite = "SubcategoriesPanel";
            filtersPanel.clipChildren     = true;

            filtersPanel.size      = new Vector2(150, 140);
            filtersPanel.isVisible = false;

            MouseEventHandler OnDoubleClick = (c, p) =>
            {
                foreach (UIComponent comp in filtersPanel.components)
                {
                    UICheckBox box = comp as UICheckBox;
                    if (box != null && box != c)
                    {
                        box.isChecked = false;
                    }
                }

                ((UICheckBox)c).isChecked = true;
            };

            UICheckBox checkBox = UIUtils.CreateCheckBox(filtersPanel);

            checkBox.label.text         = "Buildings";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterBuildings = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;


            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Props";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterProps = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Decals";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterDecals = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Trees";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterTrees = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Nodes";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterNodes = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Segments";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterSegments = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            filtersPanel.padding             = new RectOffset(10, 10, 10, 10);
            filtersPanel.autoLayoutDirection = LayoutDirection.Vertical;
            filtersPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 5);
            filtersPanel.autoLayout          = true;

            filtersPanel.height = 160;

            filtersPanel.absolutePosition = m_marquee.absolutePosition - new Vector3(57, filtersPanel.height + 5);

            m_marquee.eventButtonStateChanged += (c, p) =>
            {
                MoveItTool.marqueeSelection = p == UIButton.ButtonState.Focused;
                filtersPanel.isVisible      = MoveItTool.marqueeSelection;

                if (UITipsWindow.instance != null)
                {
                    UITipsWindow.instance.RefreshPosition();
                }
            };

            m_alignHeight                 = AddUIComponent <UIButton>();
            m_alignHeight.name            = "MoveIt_AlignHeight";
            m_alignHeight.group           = m_tabStrip;
            m_alignHeight.atlas           = GetIconsAtlas();
            m_alignHeight.tooltip         = "Align Heights";
            m_alignHeight.playAudioEvents = true;

            m_alignHeight.size = new Vector2(36, 36);

            m_alignHeight.normalBgSprite   = "OptionBase";
            m_alignHeight.hoveredBgSprite  = "OptionBaseHovered";
            m_alignHeight.pressedBgSprite  = "OptionBasePressed";
            m_alignHeight.disabledBgSprite = "OptionBaseDisabled";

            m_alignHeight.normalFgSprite = "AlignHeight";

            m_alignHeight.relativePosition = m_tabStrip.relativePosition + new Vector3(m_single.width + m_marquee.width, 0);

            m_alignHeight.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.StartAligningHeight();
                    RefreshAlignHeightButton();
                }
            };

            m_copy                 = AddUIComponent <UIButton>();
            m_copy.name            = "MoveIt_Copy";
            m_copy.group           = m_tabStrip;
            m_copy.atlas           = GetIconsAtlas();
            m_copy.tooltip         = "Copy";
            m_copy.playAudioEvents = true;

            m_copy.size = new Vector2(36, 36);

            m_copy.normalBgSprite   = "OptionBase";
            m_copy.hoveredBgSprite  = "OptionBaseHovered";
            m_copy.pressedBgSprite  = "OptionBasePressed";
            m_copy.disabledBgSprite = "OptionBaseDisabled";

            m_copy.normalFgSprite = "Copy";

            m_copy.relativePosition = m_alignHeight.relativePosition + new Vector3(m_alignHeight.width, 0);

            m_copy.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.StartCloning();
                }
            };

            m_bulldoze                 = AddUIComponent <UIButton>();
            m_bulldoze.name            = "MoveIt_Bulldoze";
            m_bulldoze.group           = m_tabStrip;
            m_bulldoze.atlas           = GetIconsAtlas();
            m_bulldoze.tooltip         = "Bulldoze\nWARNING: NO UNDO!";
            m_bulldoze.playAudioEvents = true;

            m_bulldoze.size = new Vector2(36, 36);

            m_bulldoze.normalBgSprite   = "OptionBase";
            m_bulldoze.hoveredBgSprite  = "OptionBaseHovered";
            m_bulldoze.pressedBgSprite  = "OptionBasePressed";
            m_bulldoze.disabledBgSprite = "OptionBaseDisabled";

            m_bulldoze.normalFgSprite = "Bulldoze";

            m_bulldoze.relativePosition = m_copy.relativePosition + new Vector3(m_copy.width, 0);

            m_bulldoze.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.StartBulldoze();
                }
            };
        }
Esempio n. 19
0
        /*public override void OnDestroy()
         * {
         *  base.OnDestroy();
         *
         *  DebugUtils.Log("Destroying UIMainPanel");
         *
         *  if (m_button != null) GameObject.Destroy(m_button.gameObject);
         *  GameObject.Destroy(m_optionPanel.gameObject);
         * }*/

        private void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = "Advanced Vehicle Options " + ModInfo.version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = "Category :";

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 150;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = "Select a category to display\nTip: Use the mouse wheel to switch between categories faster";
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = "Type the name of a vehicle type";
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = "Configuration file:";
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(10, height - 60);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = "Import";
            m_import.tooltip          = "Import the configuration";
            m_import.relativePosition = new Vector3(10, height - 40);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = "Export";
            m_export.tooltip          = "Export the configuration";
            m_export.relativePosition = new Vector3(105, height - 40);

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = "Click here to cycle through the existing vehicles of that type";
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;
            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };
            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportConfig();

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
Esempio n. 20
0
        public override void Start()
        {
            base.Start();

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = 740f;
            height        = 40f;

            m_name                  = AddUIComponent <UILabel>();
            m_name.textScale        = 0.9f;
            m_name.width            = 300f;
            m_name.height           = height;
            m_name.textAlignment    = UIHorizontalAlignment.Left;
            m_name.pivot            = UIPivotPoint.MiddleLeft;
            m_name.relativePosition = new Vector3(10f, 0f);

            m_lodTextureSize               = AddUIComponent <UILabel>();
            m_lodTextureSize.textScale     = 0.9f;
            m_lodTextureSize.width         = 70f;
            m_lodTextureSize.height        = height;
            m_lodTextureSize.textAlignment = UIHorizontalAlignment.Center;
            m_lodTextureSize.pivot         = UIPivotPoint.MiddleCenter;
            m_lodTextureSize.padding       = new RectOffset(0, 10, 0, 0);
            m_lodTextureSize.AlignTo(this, UIAlignAnchor.TopRight);

            m_textureSize                  = AddUIComponent <UILabel>();
            m_textureSize.textScale        = 0.9f;
            m_textureSize.width            = 90f;
            m_textureSize.height           = height;
            m_textureSize.textAlignment    = UIHorizontalAlignment.Center;
            m_textureSize.pivot            = UIPivotPoint.MiddleCenter;
            m_textureSize.padding          = new RectOffset(0, 10, 0, 0);
            m_textureSize.relativePosition = m_lodTextureSize.relativePosition - new Vector3(90f, 0f);

            m_lodWeight                  = AddUIComponent <UILabel>();
            m_lodWeight.textScale        = 0.9f;
            m_lodWeight.width            = 50f;
            m_lodWeight.height           = height;
            m_lodWeight.textAlignment    = UIHorizontalAlignment.Center;
            m_lodWeight.pivot            = UIPivotPoint.MiddleCenter;
            m_lodWeight.relativePosition = m_textureSize.relativePosition - new Vector3(50f, 0f);

            m_weight                  = AddUIComponent <UILabel>();
            m_weight.textScale        = 0.9f;
            m_weight.width            = 50f;
            m_weight.height           = height;
            m_weight.textAlignment    = UIHorizontalAlignment.Center;
            m_weight.pivot            = UIPivotPoint.MiddleCenter;
            m_weight.relativePosition = m_lodWeight.relativePosition - new Vector3(50f, 0f);

            m_lodTriangles                  = AddUIComponent <UILabel>();
            m_lodTriangles.textScale        = 0.9f;
            m_lodTriangles.width            = 50f;
            m_lodTriangles.height           = height;
            m_lodTriangles.textAlignment    = UIHorizontalAlignment.Center;
            m_lodTriangles.pivot            = UIPivotPoint.MiddleCenter;
            m_lodTriangles.relativePosition = m_weight.relativePosition - new Vector3(50f, 0f);

            m_triangles                  = AddUIComponent <UILabel>();
            m_triangles.textScale        = 0.9f;
            m_triangles.width            = 80f;
            m_triangles.height           = height;
            m_triangles.textAlignment    = UIHorizontalAlignment.Center;
            m_triangles.pivot            = UIPivotPoint.MiddleCenter;
            m_triangles.relativePosition = m_lodTriangles.relativePosition - new Vector3(80f, 0f);

            m_steamID = UIUtils.CreateTextField(this);
            m_steamID.normalBgSprite           = null;
            m_steamID.padding                  = new RectOffset(5, 5, 14, 14);
            m_steamID.textScale                = 0.8f;
            m_steamID.height                   = 40;
            m_steamID.textColor                = new Color32(128, 128, 128, 255);
            m_steamID.selectionBackgroundColor = new Color32(0, 0, 0, 128);
            m_steamID.numericalOnly            = true;
            m_steamID.relativePosition         = m_triangles.relativePosition - new Vector3(100f, 0f);

            m_steamID.eventTextChanged += (c, t) =>
            {
                if (m_meshData.name.Contains("."))
                {
                    m_steamID.text = m_meshData.name.Substring(0, m_meshData.name.IndexOf("."));
                }
            };

            m_name.eventDoubleClick += (c, t) =>
            {
                if (PlatformService.IsOverlayEnabled() && !String.IsNullOrEmpty(m_steamID.text))
                {
                    PublishedFileId publishedFileId = new PublishedFileId((ulong)Int32.Parse(m_steamID.text));

                    if (publishedFileId != PublishedFileId.invalid)
                    {
                        PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId);
                    }
                }
            };
        }
Esempio n. 21
0
        public override void Start()
        {
            name             = "MoveIt_SaveWindow";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 272); // 180
            canFocus         = true;

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;

            close                  = AddUIComponent <UIButton>();
            close.size             = new Vector2(30f, 30f);
            close.text             = "X";
            close.textScale        = 0.9f;
            close.textColor        = new Color32(118, 123, 123, 255);
            close.focusedTextColor = new Color32(118, 123, 123, 255);
            close.hoveredTextColor = new Color32(140, 142, 142, 255);
            close.pressedTextColor = new Color32(99, 102, 102, 102);
            close.textPadding      = new RectOffset(8, 8, 8, 8);
            close.canFocus         = false;
            close.playAudioEvents  = true;
            close.relativePosition = new Vector3(width - close.width, 0);

            close.eventClicked += (c, p) =>
            {
                Close();
            };

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Export";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            // Save Panel
            UIPanel savePanel = AddUIComponent <UIPanel>();

            savePanel.atlas            = atlas;
            savePanel.backgroundSprite = "GenericPanel";
            savePanel.color            = new Color32(206, 206, 206, 255);
            savePanel.size             = new Vector2(width - 16, 46);
            savePanel.relativePosition = new Vector2(8, 28);

            // Input
            fileNameInput                     = UIUtils.CreateTextField(savePanel);
            fileNameInput.padding.top         = 7;
            fileNameInput.horizontalAlignment = UIHorizontalAlignment.Left;
            fileNameInput.relativePosition    = new Vector3(8, 8);

            fileNameInput.eventKeyDown += (c, p) =>
            {
                if (p.keycode == KeyCode.Return)
                {
                    saveButton.SimulateClick();
                }
            };

            // Save
            saveButton                  = UIUtils.CreateButton(savePanel);
            saveButton.name             = "MoveIt_SaveButton";
            saveButton.text             = "Export";
            saveButton.size             = new Vector2(100f, 30f);
            saveButton.relativePosition = new Vector3(savePanel.width - saveButton.width - 8, 8);

            fileNameInput.size = new Vector2(saveButton.relativePosition.x - 16f, 30f);

            // FastList
            fastList = AddUIComponent <UIFastList>();
            fastList.backgroundSprite = "UnlockingPanel";
            fastList.width            = width - 16;
            fastList.height           = 46 * 7;
            fastList.canSelect        = true;
            fastList.relativePosition = new Vector3(8, savePanel.relativePosition.y + savePanel.height + 8);

            fastList.rowHeight = 46f;

            saveButton.eventClicked += (c, p) =>
            {
                string filename = fileNameInput.text.Trim();
                filename = String.Concat(filename.Split(Path.GetInvalidFileNameChars()));

                if (!filename.IsNullOrWhiteSpace())
                {
                    Export(filename);
                }
            };

            height           = fastList.relativePosition.y + fastList.height + 8;
            dragHandle.size  = size;
            absolutePosition = new Vector3(saveWindowX.value, saveWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            UIComponent modalEffect = GetUIView().panelsLibraryModalEffect;

            if (modalEffect != null && !modalEffect.isVisible)
            {
                modalEffect.Show(false);
                ValueAnimator.Animate("ModalEffect", delegate(float val)
                {
                    modalEffect.opacity = val;
                }, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));
            }

            BringToFront();
            fileNameInput.Focus();
        }
        private void SetupControls()
        {
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.gameObject.AddComponent <UICustomControl>();

            panel.backgroundSprite = "UnlockingPanel";
            panel.width            = width - 10;
            panel.height           = height - 75;
            panel.relativePosition = new Vector3(5, 0);

            // Max Speed
            UILabel maxSpeedLabel = panel.AddUIComponent <UILabel>();

            maxSpeedLabel.text             = "Maximum speed:";
            maxSpeedLabel.textScale        = 0.8f;
            maxSpeedLabel.relativePosition = new Vector3(15, 15);

            m_maxSpeed = UIUtils.CreateTextField(panel);
            m_maxSpeed.numericalOnly    = true;
            m_maxSpeed.width            = 75;
            m_maxSpeed.tooltip          = "Change the maximum speed of the vehicle\nPlease note that vehicles do not go beyond speed limits";
            m_maxSpeed.relativePosition = new Vector3(15, 35);

            UILabel kmh = panel.AddUIComponent <UILabel>();

            kmh.text             = "km/h";
            kmh.textScale        = 0.8f;
            kmh.relativePosition = new Vector3(95, 40);

            // Acceleration
            UILabel accelerationLabel = panel.AddUIComponent <UILabel>();

            accelerationLabel.text             = "Acceleration/Brake:";
            accelerationLabel.textScale        = 0.8f;
            accelerationLabel.relativePosition = new Vector3(160, 15);

            m_acceleration = UIUtils.CreateTextField(panel);
            m_acceleration.numericalOnly    = true;
            m_acceleration.allowFloats      = true;
            m_acceleration.width            = 60;
            m_acceleration.tooltip          = "Change the vehicle acceleration factor";
            m_acceleration.relativePosition = new Vector3(160, 35);

            // Braking
            m_braking = UIUtils.CreateTextField(panel);
            m_braking.numericalOnly    = true;
            m_braking.allowFloats      = true;
            m_braking.width            = 60;
            m_braking.tooltip          = "Change the vehicle braking factor";
            m_braking.relativePosition = new Vector3(230, 35);

            // Colors
            m_useColors                  = UIUtils.CreateCheckBox(panel);
            m_useColors.text             = "Color variations:";
            m_useColors.isChecked        = true;
            m_useColors.width            = width - 40;
            m_useColors.tooltip          = "Enable color variations\nA random color is chosen between the four following colors";
            m_useColors.relativePosition = new Vector3(15, 70);

            m_color0                      = UIUtils.CreateColorField(panel);
            m_color0.name                 = "AVO-color0";
            m_color0.popupTopmostRoot     = false;
            m_color0.relativePosition     = new Vector3(13, 95 - 2);
            m_color0_hex                  = UIUtils.CreateTextField(panel);
            m_color0_hex.maxLength        = 6;
            m_color0_hex.relativePosition = new Vector3(55, 95);

            m_color1                      = UIUtils.CreateColorField(panel);
            m_color1.name                 = "AVO-color1";
            m_color1.popupTopmostRoot     = false;
            m_color1.relativePosition     = new Vector3(13, 120 - 2);
            m_color1_hex                  = UIUtils.CreateTextField(panel);
            m_color1_hex.maxLength        = 6;
            m_color1_hex.relativePosition = new Vector3(55, 120);

            m_color2                      = UIUtils.CreateColorField(panel);
            m_color2.name                 = "AVO-color2";
            m_color2.popupTopmostRoot     = false;
            m_color2.relativePosition     = new Vector3(158, 95 - 2);
            m_color2_hex                  = UIUtils.CreateTextField(panel);
            m_color2_hex.maxLength        = 6;
            m_color2_hex.relativePosition = new Vector3(200, 95);

            m_color3                      = UIUtils.CreateColorField(panel);
            m_color3.name                 = "AVO-color3";
            m_color3.popupTopmostRoot     = false;
            m_color3.relativePosition     = new Vector3(158, 120 - 2);
            m_color3_hex                  = UIUtils.CreateTextField(panel);
            m_color3_hex.maxLength        = 6;
            m_color3_hex.relativePosition = new Vector3(200, 120);

            // Enable & BackEngine
            m_enabled                  = UIUtils.CreateCheckBox(panel);
            m_enabled.text             = "Allow this vehicle to spawn";
            m_enabled.isChecked        = true;
            m_enabled.width            = width - 40;
            m_enabled.tooltip          = "Make sure you have at least one vehicle allowed to spawn for that category";
            m_enabled.relativePosition = new Vector3(15, 155);;

            m_addBackEngine                  = UIUtils.CreateCheckBox(panel);
            m_addBackEngine.text             = "Replace last car with engine";
            m_addBackEngine.isChecked        = false;
            m_addBackEngine.width            = width - 40;
            m_addBackEngine.tooltip          = "Make the last car of this train be an engine";
            m_addBackEngine.relativePosition = new Vector3(15, 175);

            // Capacity
            UIPanel capacityPanel = panel.AddUIComponent <UIPanel>();

            capacityPanel.size             = Vector2.zero;
            capacityPanel.relativePosition = new Vector3(15, 200);

            UILabel capacityLabel = capacityPanel.AddUIComponent <UILabel>();

            capacityLabel.text             = "Capacity:";
            capacityLabel.textScale        = 0.8f;
            capacityLabel.relativePosition = Vector3.zero;

            m_capacity = UIUtils.CreateTextField(capacityPanel);
            m_capacity.numericalOnly    = true;
            m_capacity.width            = 110;
            m_capacity.tooltip          = "Change the capacity of the vehicle";
            m_capacity.relativePosition = new Vector3(0, 20);

            // Restore default
            m_restore                  = UIUtils.CreateButton(panel);
            m_restore.text             = "Restore default";
            m_restore.width            = 130;
            m_restore.tooltip          = "Restore all values to default";
            m_restore.relativePosition = new Vector3(160, 215);

            // Remove Vehicles
            m_removeLabel                  = this.AddUIComponent <UILabel>();
            m_removeLabel.text             = "Remove vehicles:";
            m_removeLabel.textScale        = 0.8f;
            m_removeLabel.relativePosition = new Vector3(10, height - 60);

            m_clearVehicles                  = UIUtils.CreateButton(this);
            m_clearVehicles.text             = "Driving";
            m_clearVehicles.width            = 90f;
            m_clearVehicles.tooltip          = "Remove all driving vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearVehicles.relativePosition = new Vector3(10, height - 40);

            m_clearParked                  = UIUtils.CreateButton(this);
            m_clearParked.text             = "Parked";
            m_clearParked.width            = 90f;
            m_clearParked.tooltip          = "Remove all parked vehicles of that type\nHold the SHIFT key to remove all types";
            m_clearParked.relativePosition = new Vector3(105, height - 40);

            panel.BringToFront();

            // Event handlers
            m_maxSpeed.eventTextSubmitted     += OnMaxSpeedSubmitted;
            m_acceleration.eventTextSubmitted += OnAccelerationSubmitted;
            m_braking.eventTextSubmitted      += OnBrakingSubmitted;

            m_useColors.eventCheckChanged += OnCheckChanged;

            MouseEventHandler mousehandler = (c, p) => { if (m_initialized)
                                                         {
                                                             (parent as UIMainPanel).ChangePreviewColor((c as UIColorField).selectedColor);
                                                         }
            };

            m_color0.eventMouseEnter += mousehandler;
            m_color1.eventMouseEnter += mousehandler;
            m_color2.eventMouseEnter += mousehandler;
            m_color3.eventMouseEnter += mousehandler;

            m_color0_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);
                                                        }
            };
            m_color1_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color1.selectedColor);
                                                        }
            };
            m_color2_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color2.selectedColor);
                                                        }
            };
            m_color3_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color3.selectedColor);
                                                        }
            };

            m_color0.eventSelectedColorChanged += OnColorChanged;
            m_color1.eventSelectedColorChanged += OnColorChanged;
            m_color2.eventSelectedColorChanged += OnColorChanged;
            m_color3.eventSelectedColorChanged += OnColorChanged;

            m_color0_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color1_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color2_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color3_hex.eventTextSubmitted += OnColorHexSubmitted;

            m_enabled.eventCheckChanged       += OnCheckChanged;
            m_addBackEngine.eventCheckChanged += OnCheckChanged;

            m_capacity.eventTextSubmitted += OnCapacitySubmitted;

            m_restore.eventClick += (c, p) =>
            {
                m_initialized = false;
                bool isEnabled = m_options.enabled;
                DefaultOptions.Restore(m_options.prefab);
                VehicleOptions.UpdateTransfertVehicles();

                VehicleOptions.prefabUpdateEngine = m_options.prefab;
                VehicleOptions.prefabUpdateUnits  = m_options.prefab;
                new EnumerableActionThread(VehicleOptions.UpdateBackEngines);
                new EnumerableActionThread(VehicleOptions.UpdateCapacityUnits);

                Show(m_options);

                if (m_options.enabled != isEnabled)
                {
                    eventEnableCheckChanged(this, m_options.enabled);
                }
            };

            m_clearVehicles.eventClick += OnClearVehicleClicked;
            m_clearParked.eventClick   += OnClearVehicleClicked;
        }
Esempio n. 23
0
        public override void Start()
        {
            instance = this;

            atlas            = UIUtils.GetAtlas("Ingame");
            size             = new Vector2(41, 41);
            relativePosition = new Vector2(GetUIView().GetScreenResolution().x - 448, -41);
            name             = "MoveIt_ToolOptionPanel";

            DebugUtils.Log("ToolOptionPanel position: " + absolutePosition);

            // Group
            m_group                 = AddUIComponent <UIButton>();
            m_group.name            = "MoveIt_Group";
            m_group.group           = m_tabStrip;
            m_group.atlas           = GetIconsAtlas();
            m_group.tooltip         = "Group";
            m_group.playAudioEvents = true;

            m_group.size = new Vector2(36, 36);

            m_group.normalBgSprite   = "OptionBase";
            m_group.hoveredBgSprite  = "OptionBaseHovered";
            m_group.pressedBgSprite  = "OptionBasePressed";
            m_group.disabledBgSprite = "OptionBaseDisabled";

            m_group.normalFgSprite = "Group";

            m_group.relativePosition = Vector2.zero;
            m_group.isVisible        = false; //TODO: temporary

            // Save
            m_save                 = AddUIComponent <UIButton>();
            m_save.name            = "MoveIt_Save";
            m_save.group           = m_tabStrip;
            m_save.atlas           = GetIconsAtlas();
            m_save.tooltip         = "Export";
            m_save.playAudioEvents = true;

            m_save.size = new Vector2(36, 36);

            m_save.normalBgSprite   = "OptionBase";
            m_save.hoveredBgSprite  = "OptionBaseHovered";
            m_save.pressedBgSprite  = "OptionBasePressed";
            m_save.disabledBgSprite = "OptionBaseDisabled";

            m_save.normalFgSprite   = "Save";
            m_save.disabledFgSprite = "Save_disabled";

            m_save.relativePosition = m_group.relativePosition + new Vector3(m_group.width, 0);

            m_save.eventClicked += (c, p) =>
            {
                if (MoveItTool.IsExportSelectionValid())
                {
                    UISaveWindow.Open();
                }
                else
                {
                    UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Selection invalid", "The selection is empty or invalid.", false);
                }
            };

            // Load
            m_load                 = AddUIComponent <UIButton>();
            m_load.name            = "MoveIt_Load";
            m_load.group           = m_tabStrip;
            m_load.atlas           = GetIconsAtlas();
            m_load.tooltip         = "Import";
            m_load.playAudioEvents = true;

            m_load.size = new Vector2(36, 36);

            m_load.normalBgSprite   = "OptionBase";
            m_load.hoveredBgSprite  = "OptionBaseHovered";
            m_load.pressedBgSprite  = "OptionBasePressed";
            m_load.disabledBgSprite = "OptionBaseDisabled";

            m_load.normalFgSprite = "Load";

            m_load.relativePosition = m_save.relativePosition + new Vector3(m_save.width, 0);

            m_load.eventClicked += (c, p) =>
            {
                UILoadWindow.Open();
            };

            // Follow Terrain
            m_followTerrain                 = AddUIComponent <UIMultiStateButton>();
            m_followTerrain.atlas           = GetFollowTerrainAtlas();
            m_followTerrain.name            = "MoveIt_FollowTerrain";
            m_followTerrain.tooltip         = "Follow Terrain";
            m_followTerrain.playAudioEvents = true;

            m_followTerrain.size          = new Vector2(36, 36);
            m_followTerrain.spritePadding = new RectOffset();

            m_followTerrain.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_followTerrain.backgroundSprites[0].normal   = "ToggleBase";
            m_followTerrain.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_followTerrain.backgroundSprites.AddState();
            m_followTerrain.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[1].hovered  = "";
            m_followTerrain.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_followTerrain.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_followTerrain.foregroundSprites[0].normal = "FollowTerrain_disabled";

            m_followTerrain.foregroundSprites.AddState();
            m_followTerrain.foregroundSprites[1].normal = "FollowTerrain";

            m_followTerrain.relativePosition = m_load.relativePosition + new Vector3(m_load.width + m_load.width / 2, 0);

            m_followTerrain.activeStateIndex = MoveItTool.followTerrain ? 1 : 0;

            m_followTerrain.eventClicked += (c, p) =>
            {
                MoveItTool.followTerrain = (m_followTerrain.activeStateIndex == 1);
            };

            // Snapping
            m_snapping                 = AddUIComponent <UIMultiStateButton>();
            m_snapping.atlas           = UIUtils.GetAtlas("Ingame");
            m_snapping.name            = "MoveIt_Snapping";
            m_snapping.tooltip         = "Toggle Snapping";
            m_snapping.playAudioEvents = true;

            m_snapping.size          = new Vector2(36, 36);
            m_snapping.spritePadding = new RectOffset();

            m_snapping.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_snapping.backgroundSprites[0].normal   = "ToggleBase";
            m_snapping.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_snapping.backgroundSprites.AddState();
            m_snapping.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[1].hovered  = "";
            m_snapping.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_snapping.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_snapping.foregroundSprites[0].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[0].hovered  = "SnappingHovered";
            m_snapping.foregroundSprites[0].normal   = "Snapping";
            m_snapping.foregroundSprites[0].pressed  = "SnappingPressed";

            m_snapping.foregroundSprites.AddState();
            m_snapping.foregroundSprites[1].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[1].hovered  = "";
            m_snapping.foregroundSprites[1].normal   = "SnappingFocused";
            m_snapping.foregroundSprites[1].pressed  = "SnappingPressed";

            m_snapping.relativePosition = m_followTerrain.relativePosition + new Vector3(m_followTerrain.width, 0);

            m_snapping.activeStateIndex = (MoveItTool.instance != null && MoveItTool.instance.snapping) ? 1 : 0;

            m_snapping.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.snapping = (m_snapping.activeStateIndex == 1);
                }
            };

            m_tabStrip      = AddUIComponent <UITabstrip>();
            m_tabStrip.size = new Vector2(36, 72);

            m_tabStrip.relativePosition = m_snapping.relativePosition + new Vector3(m_snapping.width, 0);

            m_single                 = m_tabStrip.AddTab("MoveIt_Single", null, false);
            m_single.group           = m_tabStrip;
            m_single.atlas           = UIUtils.GetAtlas("Ingame");
            m_single.tooltip         = "Single Selection";
            m_single.playAudioEvents = true;

            m_single.size = new Vector2(36, 36);

            m_single.normalBgSprite    = "OptionBase";
            m_single.focusedBgSprite   = "OptionBaseFocused";
            m_single.hoveredBgSprite   = "OptionBaseHovered";
            m_single.pressedBgSprite   = "OptionBasePressed";
            m_single.disabledBgSprite  = "OptionBaseDisabled";
            m_single.text              = "•";
            m_single.textScale         = 1.5f;
            m_single.textPadding       = new RectOffset(0, 1, 4, 0);
            m_single.textColor         = new Color32(119, 124, 126, 255);
            m_single.hoveredTextColor  = new Color32(110, 113, 114, 255);
            m_single.pressedTextColor  = new Color32(172, 175, 176, 255);
            m_single.focusedTextColor  = new Color32(187, 224, 235, 255);
            m_single.disabledTextColor = new Color32(66, 69, 70, 255);

            m_marquee                 = m_tabStrip.AddTab("MoveIt_Marquee", null, false);
            m_marquee.group           = m_tabStrip;
            m_marquee.atlas           = UIUtils.GetAtlas("Ingame");
            m_marquee.tooltip         = "Marquee Selection";
            m_marquee.playAudioEvents = true;

            m_marquee.size = new Vector2(36, 36);

            m_marquee.normalBgSprite   = "OptionBase";
            m_marquee.focusedBgSprite  = "OptionBaseFocused";
            m_marquee.hoveredBgSprite  = "OptionBaseHovered";
            m_marquee.pressedBgSprite  = "OptionBasePressed";
            m_marquee.disabledBgSprite = "OptionBaseDisabled";

            m_marquee.normalFgSprite = "ZoningOptionMarquee";

            m_marquee.relativePosition = m_single.relativePosition + new Vector3(m_single.width, 0);

            filtersPanel                  = AddUIComponent(typeof(UIPanel)) as UIPanel;
            filtersPanel.atlas            = UIUtils.GetAtlas("Ingame");
            filtersPanel.backgroundSprite = "SubcategoriesPanel";
            filtersPanel.clipChildren     = true;

            filtersPanel.size      = new Vector2(150, 140);
            filtersPanel.isVisible = false;

            void OnDoubleClick(UIComponent c, UIMouseEventParameter p)
            {
                foreach (UIComponent comp in filtersPanel.components)
                {
                    UICheckBox box = comp as UICheckBox;
                    if (box != null && box != c)
                    {
                        box.isChecked = false;
                    }
                }

                ((UICheckBox)c).isChecked = true;
            }

            UICheckBox checkBox = UIUtils.CreateCheckBox(filtersPanel);

            checkBox.label.text         = "Buildings";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterBuildings = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;


            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Props";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterProps = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Decals";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterDecals = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Trees";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterTrees = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Nodes";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterNodes = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox                    = UIUtils.CreateCheckBox(filtersPanel);
            checkBox.label.text         = "Segments";
            checkBox.isChecked          = true;
            checkBox.eventCheckChanged += (c, p) =>
            {
                MoveItTool.filterSegments = p;
            };

            checkBox.eventDoubleClick += OnDoubleClick;

            filtersPanel.padding             = new RectOffset(10, 10, 10, 10);
            filtersPanel.autoLayoutDirection = LayoutDirection.Vertical;
            filtersPanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 5);
            filtersPanel.autoLayout          = true;

            filtersPanel.height = 160;

            filtersPanel.absolutePosition = m_marquee.absolutePosition - new Vector3(57, filtersPanel.height + 5);

            m_marquee.eventButtonStateChanged += (c, p) =>
            {
                MoveItTool.marqueeSelection = p == UIButton.ButtonState.Focused;
                filtersPanel.isVisible      = MoveItTool.marqueeSelection;

                if (UITipsWindow.instance != null)
                {
                    UITipsWindow.instance.RefreshPosition();
                }
            };

            m_alignHeight                 = AddUIComponent <UIButton>();
            m_alignHeight.name            = "MoveIt_AlignHeight";
            m_alignHeight.group           = m_tabStrip;
            m_alignHeight.atlas           = GetIconsAtlas();
            m_alignHeight.tooltip         = "Align Heights";
            m_alignHeight.playAudioEvents = true;

            m_alignHeight.size = new Vector2(36, 36);

            m_alignHeight.normalBgSprite   = "OptionBase";
            m_alignHeight.hoveredBgSprite  = "OptionBaseHovered";
            m_alignHeight.pressedBgSprite  = "OptionBasePressed";
            m_alignHeight.disabledBgSprite = "OptionBaseDisabled";

            m_alignHeight.normalFgSprite = "AlignHeight";

            m_alignHeight.relativePosition = m_tabStrip.relativePosition + new Vector3(m_single.width + m_marquee.width, 0);

            m_alignHeight.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    if (MoveItTool.instance.toolState == MoveItTool.ToolState.AligningHeights)
                    {
                        MoveItTool.instance.StopAligningHeights();
                    }
                    else
                    {
                        MoveItTool.instance.StartAligningHeights();
                    }
                }
            };

            m_copy                 = AddUIComponent <UIButton>();
            m_copy.name            = "MoveIt_Copy";
            m_copy.group           = m_tabStrip;
            m_copy.atlas           = GetIconsAtlas();
            m_copy.tooltip         = "Copy";
            m_copy.playAudioEvents = true;

            m_copy.size = new Vector2(36, 36);

            m_copy.normalBgSprite   = "OptionBase";
            m_copy.hoveredBgSprite  = "OptionBaseHovered";
            m_copy.pressedBgSprite  = "OptionBasePressed";
            m_copy.disabledBgSprite = "OptionBaseDisabled";

            m_copy.normalFgSprite = "Copy";

            m_copy.relativePosition = m_alignHeight.relativePosition + new Vector3(m_alignHeight.width, 0);

            m_copy.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    if (MoveItTool.instance.toolState == MoveItTool.ToolState.Cloning)
                    {
                        MoveItTool.instance.StopCloning();
                    }
                    else
                    {
                        MoveItTool.instance.StartCloning();
                    }
                }
            };

            m_bulldoze                 = AddUIComponent <UIButton>();
            m_bulldoze.name            = "MoveIt_Bulldoze";
            m_bulldoze.group           = m_tabStrip;
            m_bulldoze.atlas           = GetIconsAtlas();
            m_bulldoze.tooltip         = "Bulldoze";
            m_bulldoze.playAudioEvents = true;

            m_bulldoze.size = new Vector2(36, 36);

            m_bulldoze.normalBgSprite   = "OptionBase";
            m_bulldoze.hoveredBgSprite  = "OptionBaseHovered";
            m_bulldoze.pressedBgSprite  = "OptionBasePressed";
            m_bulldoze.disabledBgSprite = "OptionBaseDisabled";

            m_bulldoze.normalFgSprite = "Bulldoze";

            m_bulldoze.relativePosition = m_copy.relativePosition + new Vector3(m_copy.width, 0);

            m_bulldoze.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.StartBulldoze();
                }
            };

            // View options
            UIPanel viewOptions = AddUIComponent <UIPanel>();

            viewOptions.atlas            = UIUtils.GetAtlas("Ingame");
            viewOptions.backgroundSprite = "InfoPanelBack";
            viewOptions.size             = new Vector2(44f, 80f);

            viewOptions.absolutePosition = new Vector3(GetUIView().GetScreenResolution().x - viewOptions.width, absolutePosition.y - viewOptions.height - 8f);

            grid                 = viewOptions.AddUIComponent <UIMultiStateButton>();
            grid.atlas           = GetIconsAtlas();
            grid.name            = "MoveIt_GridView";
            grid.tooltip         = "Toggle Grid";
            grid.playAudioEvents = true;

            grid.size          = new Vector2(36, 36);
            grid.spritePadding = new RectOffset();

            grid.backgroundSprites[0].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[0].hovered  = "OptionBaseHovered";
            grid.backgroundSprites[0].normal   = "OptionBase";
            grid.backgroundSprites[0].pressed  = "OptionBasePressed";

            grid.backgroundSprites.AddState();
            grid.backgroundSprites[1].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[1].hovered  = "";
            grid.backgroundSprites[1].normal   = "OptionBaseFocused";
            grid.backgroundSprites[1].pressed  = "OptionBasePressed";

            grid.foregroundSprites[0].normal = "Grid";

            grid.foregroundSprites.AddState();
            grid.foregroundSprites[1].normal = "GridFocused";

            grid.relativePosition = new Vector3(4f, 4f);

            grid.activeStateIndex = 0;

            grid.eventClicked += (c, p) =>
            {
                MoveItTool.gridVisible = (grid.activeStateIndex == 1);
            };

            underground                 = viewOptions.AddUIComponent <UIMultiStateButton>();
            underground.atlas           = UIUtils.GetAtlas("Ingame");
            underground.name            = "MoveIt_UndergroundView";
            underground.tooltip         = "Toogle Underground View";
            underground.playAudioEvents = true;

            underground.size          = new Vector2(36, 36);
            underground.spritePadding = new RectOffset();

            underground.backgroundSprites[0].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[0].hovered  = "OptionBaseHovered";
            underground.backgroundSprites[0].normal   = "OptionBase";
            underground.backgroundSprites[0].pressed  = "OptionBasePressed";

            underground.backgroundSprites.AddState();
            underground.backgroundSprites[1].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[1].hovered  = "";
            underground.backgroundSprites[1].normal   = "OptionBaseFocused";
            underground.backgroundSprites[1].pressed  = "OptionBasePressed";

            underground.foregroundSprites[0].normal = "BulldozerOptionPipes";

            underground.foregroundSprites.AddState();
            underground.foregroundSprites[1].normal = "BulldozerOptionPipesFocused";

            underground.relativePosition = new Vector3(4f, 40f);

            underground.activeStateIndex = 0;

            underground.eventClicked += (c, p) =>
            {
                MoveItTool.tunnelVisible = (underground.activeStateIndex == 1);
            };
        }
Esempio n. 24
0
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "MoveIt_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3((UISaveWindow.instance != null ? 430 : 510) - deleteButton.width - 8, 8);
            deleteButton.tooltip          = Str.xml_DeleteLabel;

            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "MoveIt_SaveLoadFileButton";
            saveLoadButton.text             = UISaveWindow.instance != null ? Str.xml_Export : Str.xml_Import;
            saveLoadButton.size             = new Vector2(80f, 30f);
            saveLoadButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveLoadButton.width - 8, 8);

            if (UISaveWindow.instance == null) // Importing
            {
                loadToPosition                  = UIUtils.CreateButton(this);
                loadToPosition.name             = "MoveIt_loadToPosition";
                loadToPosition.text             = Str.xml_Restore;
                loadToPosition.tooltip          = Str.xml_Restore_Tooltip;
                loadToPosition.size             = new Vector2(80f, 30f);
                loadToPosition.relativePosition = new Vector3(saveLoadButton.relativePosition.x - loadToPosition.width - 8, 8);

                loadToPosition.eventClicked += (c, p) =>
                {
                    UIView.Find("DefaultTooltip")?.Hide();
                    UILoadWindow.Close();
                    Destroy(loadToPosition);
                    MoveItTool.instance.Restore(fileNameLabel.text);
                };
            }
            else
            {
                loadToPosition = null;
            }

            saveLoadButton.eventClicked += (c, p) =>
            {
                UIView.Find("DefaultTooltip")?.Hide();
                if (UISaveWindow.instance != null)
                {
                    UISaveWindow.Export(fileNameLabel.text);
                }
                else
                {
                    UILoadWindow.Close();
                    MoveItTool.instance.Import(fileNameLabel.text);
                }
            };

            deleteButton.eventClicked += (c, p) =>
            {
                ConfirmPanel.ShowModal(Str.xml_DeleteConfirmTitle, String.Format(Str.xml_DeleteConfirmMessage, fileNameLabel.text), (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Delete(fileNameLabel.text);

                        if (UISaveWindow.instance != null)
                        {
                            UISaveWindow.instance.RefreshFileList();
                        }
                        else
                        {
                            UILoadWindow.instance.RefreshFileList();
                        }
                    }
                });
            };

            if (UISaveWindow.instance == null) // Importing
            {
                fileNameLabel.width = loadToPosition.relativePosition.x - 16f;
            }
            else
            {
                fileNameLabel.width = saveLoadButton.relativePosition.x - 16f;
            }
        }
Esempio n. 25
0
        public override void Start()
        {
            UIMoreTools.Initialise();

            instance = this;

            UICheckBox checkBox = null;

            atlas            = UIUtils.GetAtlas("Ingame");
            size             = new Vector2(41, 41);
            relativePosition = new Vector2(GetUIView().GetScreenResolution().x - 340, -41);
            name             = "MoveIt_ToolOptionPanel";

            DebugUtils.Log("ToolOptionPanel position: " + absolutePosition);

            #region Follow Terrain
            m_followTerrain                 = AddUIComponent <UIMultiStateButton>();
            m_followTerrain.atlas           = GetFollowTerrainAtlas();
            m_followTerrain.name            = "MoveIt_FollowTerrain";
            m_followTerrain.tooltip         = Str.baseUI_FollowTerrain_Tooltip;
            m_followTerrain.playAudioEvents = true;

            m_followTerrain.size          = new Vector2(36, 36);
            m_followTerrain.spritePadding = new RectOffset();

            m_followTerrain.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_followTerrain.backgroundSprites[0].normal   = "ToggleBase";
            m_followTerrain.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_followTerrain.backgroundSprites.AddState();
            m_followTerrain.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_followTerrain.backgroundSprites[1].hovered  = "";
            m_followTerrain.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_followTerrain.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_followTerrain.foregroundSprites[0].normal = "FollowTerrain_disabled";

            m_followTerrain.foregroundSprites.AddState();
            m_followTerrain.foregroundSprites[1].normal = "FollowTerrain";

            m_followTerrain.relativePosition = Vector2.zero;

            m_followTerrain.activeStateIndex = MoveItTool.followTerrain ? 1 : 0;

            m_followTerrain.eventClicked += (c, p) =>
            {
                MoveItTool.followTerrain = (m_followTerrain.activeStateIndex == 1);
                MoveItTool.followTerrainModeEnabled.value = (m_followTerrain.activeStateIndex == 1);
            };
            #endregion

            #region Snapping
            m_snapping                 = AddUIComponent <UIMultiStateButton>();
            m_snapping.atlas           = UIUtils.GetAtlas("Ingame");
            m_snapping.name            = "MoveIt_Snapping";
            m_snapping.tooltip         = Str.baseUI_ToggleSnapping_Tooltip;
            m_snapping.playAudioEvents = true;

            m_snapping.size          = new Vector2(36, 36);
            m_snapping.spritePadding = new RectOffset();

            m_snapping.backgroundSprites[0].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[0].hovered  = "ToggleBaseHovered";
            m_snapping.backgroundSprites[0].normal   = "ToggleBase";
            m_snapping.backgroundSprites[0].pressed  = "ToggleBasePressed";

            m_snapping.backgroundSprites.AddState();
            m_snapping.backgroundSprites[1].disabled = "ToggleBaseDisabled";
            m_snapping.backgroundSprites[1].hovered  = "";
            m_snapping.backgroundSprites[1].normal   = "ToggleBaseFocused";
            m_snapping.backgroundSprites[1].pressed  = "ToggleBasePressed";

            m_snapping.foregroundSprites[0].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[0].hovered  = "SnappingHovered";
            m_snapping.foregroundSprites[0].normal   = "Snapping";
            m_snapping.foregroundSprites[0].pressed  = "SnappingPressed";

            m_snapping.foregroundSprites.AddState();
            m_snapping.foregroundSprites[1].disabled = "SnappingDisabled";
            m_snapping.foregroundSprites[1].hovered  = "";
            m_snapping.foregroundSprites[1].normal   = "SnappingFocused";
            m_snapping.foregroundSprites[1].pressed  = "SnappingPressed";

            m_snapping.relativePosition = m_followTerrain.relativePosition + new Vector3(m_followTerrain.width, 0);

            m_snapping.activeStateIndex = (MoveItTool.instance != null && MoveItTool.instance.snapping) ? 1 : 0;

            m_snapping.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.snapping = (m_snapping.activeStateIndex == 1);
                }
            };
            #endregion

            m_tabStrip      = AddUIComponent <UITabstrip>();
            m_tabStrip.size = new Vector2(36, 72);

            m_tabStrip.relativePosition = m_snapping.relativePosition + new Vector3(m_snapping.width, 0);

            #region Single Select
            m_single                 = m_tabStrip.AddTab("MoveIt_Single", null, false);
            m_single.group           = m_tabStrip;
            m_single.atlas           = UIUtils.GetAtlas("Ingame");
            m_single.tooltip         = Str.baseUI_Single_Tooltip;
            m_single.playAudioEvents = true;

            m_single.size = new Vector2(36, 36);

            m_single.normalBgSprite    = "OptionBase";
            m_single.focusedBgSprite   = "OptionBaseFocused";
            m_single.hoveredBgSprite   = "OptionBaseHovered";
            m_single.pressedBgSprite   = "OptionBasePressed";
            m_single.disabledBgSprite  = "OptionBaseDisabled";
            m_single.text              = "•";
            m_single.textScale         = 1.5f;
            m_single.textPadding       = new RectOffset(0, 1, 4, 0);
            m_single.textColor         = new Color32(119, 124, 126, 255);
            m_single.hoveredTextColor  = new Color32(110, 113, 114, 255);
            m_single.pressedTextColor  = new Color32(172, 175, 176, 255);
            m_single.focusedTextColor  = new Color32(187, 224, 235, 255);
            m_single.disabledTextColor = new Color32(66, 69, 70, 255);
            #endregion

            #region Marquee Select
            m_marquee                 = m_tabStrip.AddTab("MoveIt_Marquee", null, false);
            m_marquee.group           = m_tabStrip;
            m_marquee.atlas           = UIUtils.GetAtlas("Ingame");
            m_marquee.tooltip         = Str.baseUI_Marquee_Tooltip;
            m_marquee.playAudioEvents = true;

            m_marquee.size = new Vector2(36, 36);

            m_marquee.normalBgSprite   = "OptionBase";
            m_marquee.focusedBgSprite  = "OptionBaseFocused";
            m_marquee.hoveredBgSprite  = "OptionBaseHovered";
            m_marquee.pressedBgSprite  = "OptionBasePressed";
            m_marquee.disabledBgSprite = "OptionBaseDisabled";

            m_marquee.normalFgSprite   = "ZoningOptionMarquee";
            m_marquee.relativePosition = m_single.relativePosition + new Vector3(m_single.width, 0);

            #region filtersPanel
            m_filtersPanel                  = AddUIComponent(typeof(UIPanel)) as UIPanel;
            m_filtersPanel.atlas            = UIUtils.GetAtlas("Ingame");
            m_filtersPanel.backgroundSprite = "SubcategoriesPanel";
            m_filtersPanel.clipChildren     = true;
            m_filtersPanel.size             = new Vector2(150, 235);
            m_filtersPanel.isVisible        = false;
            UIFilters.FilterPanel           = m_filtersPanel;

            void OnDoubleClick(UIComponent c, UIMouseEventParameter p)
            {
                foreach (UICheckBox cb in UIFilters.FilterCBs)
                {
                    cb.isChecked = false;
                    Filters.SetFilter(cb.name, false);
                }
                ((UICheckBox)c).isChecked = true;
                Filters.SetFilter(c.name, true);

                UIFilters.RefreshFilters();
            }

            void OnPickerClick(UIComponent c, UIMouseEventParameter p)
            {
                MoveItTool.SetToolState(MoveItTool.ToolStates.Picking);
                UIFilters.UpdatePickerButton(2);
            }

            void OnPickerDoubleClick(UIComponent c, UIMouseEventParameter p)
            {
                Filters.Picker = new PickerFilter();

                Filters.SetFilter("Picker", false);
                MoveItTool.SetToolState();
                UIFilters.UpdatePickerButton(1);
            }

            #region Standard Filters
            m_filtersPanelList      = m_filtersPanel.AddUIComponent(typeof(UIPanel)) as UIPanel;
            m_filtersPanelList.name = "m_filtersPanelList";

            m_picker = UIUtils.CreateButton(m_filtersPanel);
            m_picker.relativePosition  = new Vector3(122, 9);
            m_picker.size              = new Vector2(20, 20);
            m_picker.atlas             = GetIconsAtlas();
            m_picker.normalFgSprite    = "EyeDropper";
            m_picker.normalBgSprite    = "OptionsDropboxListbox";
            m_picker.hoveredBgSprite   = "OptionsDropboxListboxFocused";
            m_picker.pressedBgSprite   = "OptionsDropboxListboxHovered";
            m_picker.eventClick       += OnPickerClick;
            m_picker.eventDoubleClick += OnPickerDoubleClick;
            m_picker.name              = "mit_pickerButton";

            checkBox        = UIFilters.CreateFilterCB(m_filtersPanelList, "Picker", Str.filter_Picker, false);
            checkBox.width -= 21;
            UIFilters.UpdatePickerLabel(Str.filter_Picker, Str.filter_Picker_Tooltip, UIFilters.InactiveLabelColor, false);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Buildings", Str.filter_Buildings);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Props", Str.filter_Props);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Decals", Str.filter_Decals);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Surfaces", Str.filter_Surfaces);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Trees", Str.filter_Trees);
            checkBox.eventDoubleClick += OnDoubleClick;

            if (MoveItTool.PO.Enabled)
            {
                if (MoveItTool.PO.Active)
                {
                    m_filtersPanel.height += 20f;
                }
                checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "PO", Str.filter_PO);
                checkBox.eventDoubleClick += OnDoubleClick;
                checkBox.isVisible         = MoveItTool.PO.Active;
            }

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Nodes", Str.filter_Nodes);
            checkBox.eventDoubleClick += OnDoubleClick;

            checkBox = UIFilters.CreateFilterCB(m_filtersPanelList, "Segments", Str.filter_Segments);
            checkBox.eventDoubleClick += OnDoubleClick;
            #endregion

            #region Network Filters
            UIButton btnNetworks = UIFilters.CreateToggleNFBtn();
            void OnDoubleClickNetworkFilter(UIComponent c, UIMouseEventParameter p)
            {
                foreach (UICheckBox cb in UIFilters.NetworkCBs)
                {
                    cb.isChecked = false;
                    Filters.SetNetworkFilter(cb.name, false);
                }
                ((UICheckBox)c).isChecked = true;
                Filters.SetNetworkFilter(c.name, true);

                UIFilters.RefreshFilters();
            }

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Roads", Str.filter_Roads);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Tracks", Str.filter_Tracks);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Paths", Str.filter_Paths);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Fences", Str.filter_Fences);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Powerlines", Str.filter_Powerlines);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            checkBox = UIFilters.CreateNetworkFilterCB(m_filtersPanelList, "Others", Str.filter_Others);
            checkBox.eventDoubleClick += OnDoubleClickNetworkFilter;

            UIFilters.RefreshFilters();
            #endregion

            m_filtersPanelList.padding             = new RectOffset(10, 10, 10, 10);
            m_filtersPanelList.autoLayoutDirection = LayoutDirection.Vertical;
            m_filtersPanelList.autoLayoutPadding   = new RectOffset(0, 0, 0, 5);
            m_filtersPanelList.autoLayout          = true;
            m_filtersPanelList.relativePosition    = new Vector3(0, 0, 0);
            m_filtersPanel.autoLayout       = false;
            m_filtersPanel.absolutePosition = m_marquee.absolutePosition + new Vector3(-47, -5 - m_filtersPanel.height);
            #endregion

            m_marquee.eventButtonStateChanged += (c, p) =>
            {
                MoveItTool.marqueeSelection = p == UIButton.ButtonState.Focused;
                m_filtersPanel.isVisible    = MoveItTool.marqueeSelection;

                if (UIChangesWindow.instance != null)
                {
                    UIChangesWindow.instance.RefreshPosition();
                }
            };
            m_marquee.eventDoubleClick += (UIComponent c, UIMouseEventParameter p) =>
            {
                bool newChecked = false;
                foreach (UICheckBox cb in m_filtersPanel.GetComponentsInChildren <UICheckBox>())
                {
                    if (cb.name == "Picker")
                    {
                        continue;
                    }
                    if (!cb.isChecked)
                    {
                        newChecked = true;
                        break;
                    }
                }

                foreach (UICheckBox cb in m_filtersPanel.GetComponentsInChildren <UICheckBox>())
                {
                    if (cb.name == "Picker")
                    {
                        cb.isChecked = false;
                        Filters.SetAnyFilter(cb.name, false);
                    }
                    else
                    {
                        cb.isChecked = newChecked;
                        Filters.SetAnyFilter(cb.name, newChecked);
                    }
                }

                UIFilters.RefreshFilters();
            };
            #endregion

            #region Copy
            m_copy                 = AddUIComponent <UIButton>();
            m_copy.name            = "MoveIt_Copy";
            m_copy.group           = m_tabStrip;
            m_copy.atlas           = GetIconsAtlas();
            m_copy.tooltip         = Str.baseUI_Clone_Tooltip;;
            m_copy.playAudioEvents = true;

            m_copy.size = new Vector2(36, 36);

            m_copy.normalBgSprite   = "OptionBase";
            m_copy.hoveredBgSprite  = "OptionBaseHovered";
            m_copy.pressedBgSprite  = "OptionBasePressed";
            m_copy.disabledBgSprite = "OptionBaseDisabled";

            m_copy.normalFgSprite = "Copy";

            m_copy.relativePosition = m_tabStrip.relativePosition + new Vector3(m_single.width + m_marquee.width, 0);

            m_copy.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    if (MoveItTool.ToolState == MoveItTool.ToolStates.Cloning)
                    {
                        MoveItTool.instance.StopCloning();
                    }
                    else
                    {
                        if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
                        {
                            if (Action.HasSelection())
                            {
                                DuplicateAction action = new DuplicateAction();
                                if (action.Count > 0)
                                {
                                    ActionQueue.instance.Push(action);
                                    ActionQueue.instance.Do();
                                }
                            }
                        }
                        else
                        {
                            MoveItTool.instance.StartCloning();
                        }
                    }
                }
            };
            #endregion

            #region Bulldoze
            m_bulldoze                 = AddUIComponent <UIButton>();
            m_bulldoze.name            = "MoveIt_Bulldoze";
            m_bulldoze.group           = m_tabStrip;
            m_bulldoze.atlas           = GetIconsAtlas();
            m_bulldoze.tooltip         = Str.baseUI_Bulldoze_Tooltip;
            m_bulldoze.playAudioEvents = true;

            m_bulldoze.size = new Vector2(36, 36);

            m_bulldoze.normalBgSprite   = "OptionBase";
            m_bulldoze.hoveredBgSprite  = "OptionBaseHovered";
            m_bulldoze.pressedBgSprite  = "OptionBasePressed";
            m_bulldoze.disabledBgSprite = "OptionBaseDisabled";

            m_bulldoze.normalFgSprite = "Bulldoze";

            m_bulldoze.relativePosition = m_copy.relativePosition + new Vector3(m_copy.width, 0);

            m_bulldoze.eventClicked += (c, p) =>
            {
                if (MoveItTool.instance != null)
                {
                    MoveItTool.instance.StartBulldoze();
                }
            };
            #endregion

            #region More Tools
            #region More Tools Container
            m_moreTools = AddUIComponent <UIButton>();
            UIMoreTools.MoreToolsBtn     = m_moreTools;
            m_moreTools.name             = "MoveIt_MoreToolsBtn";
            m_moreTools.group            = m_tabStrip;
            m_moreTools.atlas            = GetIconsAtlas();
            m_moreTools.tooltip          = Str.baseUI_Toolbox_Tooltip;
            m_moreTools.playAudioEvents  = true;
            m_moreTools.size             = new Vector2(36, 36);
            m_moreTools.normalBgSprite   = "OptionBase";
            m_moreTools.hoveredBgSprite  = "OptionBaseHovered";
            m_moreTools.pressedBgSprite  = "OptionBasePressed";
            m_moreTools.disabledBgSprite = "OptionBaseDisabled";
            m_moreTools.normalFgSprite   = "MoreTools";
            m_moreTools.relativePosition = m_bulldoze.relativePosition + new Vector3(m_bulldoze.width, 0);
            m_moreTools.eventClicked    += (UIComponent c, UIMouseEventParameter p) =>
            {
                UIMoreTools.MoreToolsClicked(m_moreTools.name);
            };

            m_moreToolsPanel                  = AddUIComponent <UIPanel>();
            UIMoreTools.MoreToolsPanel        = m_moreToolsPanel;
            m_moreToolsPanel.name             = "mtPanel";
            m_moreToolsPanel.autoLayout       = false;
            m_moreToolsPanel.clipChildren     = true;
            m_moreToolsPanel.size             = new Vector2(36, 132);
            m_moreToolsPanel.isVisible        = false;
            m_moreToolsPanel.absolutePosition = m_moreTools.absolutePosition + new Vector3(0, 10 - m_moreToolsPanel.height);
            m_moreTools.zOrder                = m_moreToolsPanel.zOrder + 10;

            // The vertical shade
            UIPanel mtpBackground = m_moreToolsPanel.AddUIComponent <UIPanel>();
            mtpBackground.name             = "mtpBackground";
            mtpBackground.clipChildren     = true;
            mtpBackground.relativePosition = new Vector3(5, 10);
            mtpBackground.atlas            = UIUtils.GetAtlas("Ingame");
            mtpBackground.backgroundSprite = "InfoPanelBack";
            mtpBackground.size             = m_moreToolsPanel.size - new Vector2(10, 10);

            UIPanel mtpContainer = m_moreToolsPanel.AddUIComponent <UIPanel>();
            mtpContainer.name = "mtpContainer";
            mtpContainer.autoLayoutDirection = LayoutDirection.Vertical;
            mtpContainer.autoLayoutPadding   = new RectOffset(0, 0, 0, 4);
            mtpContainer.autoLayout          = true;
            mtpContainer.relativePosition    = Vector3.zero;
            mtpContainer.size             = m_moreToolsPanel.size;
            mtpContainer.eventMouseEnter += (UIComponent c, UIMouseEventParameter p) => { if (MoveItTool.marqueeSelection)
                                                                                          {
                                                                                              m_filtersPanel.isVisible = false;
                                                                                          }
            };
            mtpContainer.eventMouseLeave += (UIComponent c, UIMouseEventParameter p) => { if (MoveItTool.marqueeSelection)
                                                                                          {
                                                                                              m_filtersPanel.isVisible = true;
                                                                                          }
            };

            UIMoreTools.MoreButtons.Clear();
            UIMoreTools.MoreSubButtons.Clear();
            #endregion

            try
            {
                AddMoreButtonCallback?.Invoke(this, m_moreTools, mtpBackground, mtpContainer);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            #region More Tools / Toolbox buttons
            UIMoreToolsBtn othersBtn = new UIMoreToolsBtn(this, "MoveIt_OthersBtn", Str.toolbox_OtherTools_Tooltip, "MenuOthers", mtpContainer, "m_mtOthersList", (MoveItTool.PO.Enabled ? 7.25f : 6.25f));
            if (MoveItTool.PO.Enabled)
            {
                othersBtn.CreateSubButton("MoveIt_ConvertToPOBtn", Str.toolbox_ConvertToPO, "ConvertToPO");
            }
            othersBtn.CreateSubButton("MoveIt_AlignLineBtn", Str.toolbox_LineUpObjects, "AlignLine");
            othersBtn.CreateSubButton("MoveIt_AlignMirrorBtn", Str.toolbox_MirrorObjects, "AlignMirror");
            othersBtn.CreateSubButton("MoveIt_ResetObjectBtn", Str.toolbox_ResetObjects, "ResetObject");
            othersBtn.CreateSubButton("MoveIt_MoveToBtn", Str.toolbox_SetPosition, "MoveTo");
            othersBtn.CreateSubSeparator("MoveIt_FileSeparator");
            othersBtn.CreateSubButton("MoveIt_LoadBtn", Str.toolbox_ImportSelection, "Load");
            othersBtn.CreateSubButton("MoveIt_SaveBtn", Str.toolbox_ExportSelection, "Save");
            othersBtn.UpdateWidth();

            UIMoreToolsBtn rotateBtn = new UIMoreToolsBtn(this, "MoveIt_RotateBtn", Str.toolbox_RotationTools_Tooltip, "MenuRotate", mtpContainer, "m_mtRotateList", 3f);
            rotateBtn.CreateSubButton("MoveIt_AlignRandomBtn", Str.toolbox_RotateRandomly, "AlignRandom");
            rotateBtn.CreateSubButton("MoveIt_AlignGroupBtn", Str.toolbox_RotateAtCentre, "AlignGroup");
            rotateBtn.CreateSubButton("MoveIt_AlignIndividualBtn", Str.toolbox_RotateInPlace, "AlignIndividual");
            rotateBtn.UpdateWidth();

            UIMoreToolsBtn heightBtn = new UIMoreToolsBtn(this, "MoveIt_HeightBtn", Str.toolbox_HeightTools_Tooltip, "MenuHeight", mtpContainer, "m_mtHeightList", 3f);
            heightBtn.CreateSubButton("MoveIt_AlignSlopeBtn", Str.toolbox_SlopeObjects, "AlignSlope");
            heightBtn.CreateSubButton("MoveIt_AlignTerrainHeightBtn", Str.toolbox_ToTerrainHeight, "AlignTerrainHeight");
            heightBtn.CreateSubButton("MoveIt_AlignHeightBtn", Str.toolbox_ToObjectHeight, "AlignHeight");
            heightBtn.UpdateWidth();
            #endregion
            #endregion

            #region View Options
            m_viewOptions                  = AddUIComponent <UIPanel>();
            m_viewOptions.atlas            = UIUtils.GetAtlas("Ingame");
            m_viewOptions.backgroundSprite = "InfoPanelBack";
            m_viewOptions.size             = new Vector2(44f, 80f);

            m_viewOptions.absolutePosition = new Vector3(GetUIView().GetScreenResolution().x - m_viewOptions.width, absolutePosition.y - m_viewOptions.height - 8f);


            grid                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
            grid.atlas           = GetIconsAtlas();
            grid.name            = "MoveIt_GridView";
            grid.tooltip         = Str.baseUI_ToggleGrid_Tooltip;
            grid.playAudioEvents = true;

            grid.size          = new Vector2(36, 36);
            grid.spritePadding = new RectOffset();

            grid.backgroundSprites[0].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[0].hovered  = "OptionBaseHovered";
            grid.backgroundSprites[0].normal   = "OptionBase";
            grid.backgroundSprites[0].pressed  = "OptionBasePressed";

            grid.backgroundSprites.AddState();
            grid.backgroundSprites[1].disabled = "OptionBaseDisabled";
            grid.backgroundSprites[1].hovered  = "";
            grid.backgroundSprites[1].normal   = "OptionBaseFocused";
            grid.backgroundSprites[1].pressed  = "OptionBasePressed";

            grid.foregroundSprites[0].normal = "Grid";

            grid.foregroundSprites.AddState();
            grid.foregroundSprites[1].normal = "GridFocused";

            grid.relativePosition = new Vector3(4f, 4f);

            grid.activeStateIndex = 0;

            grid.eventClicked += (c, p) =>
            {
                MoveItTool.gridVisible = (grid.activeStateIndex == 1);
            };


            underground                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
            underground.atlas           = UIUtils.GetAtlas("Ingame");
            underground.name            = "MoveIt_UndergroundView";
            underground.tooltip         = Str.baseUI_ToggleUnderground_Tooltip;
            underground.playAudioEvents = true;

            underground.size          = new Vector2(36, 36);
            underground.spritePadding = new RectOffset();

            underground.backgroundSprites[0].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[0].hovered  = "OptionBaseHovered";
            underground.backgroundSprites[0].normal   = "OptionBase";
            underground.backgroundSprites[0].pressed  = "OptionBasePressed";

            underground.backgroundSprites.AddState();
            underground.backgroundSprites[1].disabled = "OptionBaseDisabled";
            underground.backgroundSprites[1].hovered  = "";
            underground.backgroundSprites[1].normal   = "OptionBaseFocused";
            underground.backgroundSprites[1].pressed  = "OptionBasePressed";

            underground.foregroundSprites[0].normal = "BulldozerOptionPipes";

            underground.foregroundSprites.AddState();
            underground.foregroundSprites[1].normal = "BulldozerOptionPipesFocused";

            underground.relativePosition = new Vector3(4f, 40f);

            underground.activeStateIndex = 0;

            underground.eventClicked += (c, p) =>
            {
                MoveItTool.tunnelVisible = (underground.activeStateIndex == 1);
            };


            if (MoveItTool.PO.Enabled)
            {
                PO_button                 = m_viewOptions.AddUIComponent <UIMultiStateButton>();
                PO_button.atlas           = GetIconsAtlas();
                PO_button.name            = "MoveIt_PO_button";
                PO_button.tooltip         = Str.baseUI_TogglePO_Tooltip;
                PO_button.playAudioEvents = true;

                PO_button.size          = new Vector2(36, 36);
                PO_button.spritePadding = new RectOffset();

                PO_button.backgroundSprites[0].disabled = "OptionBaseDisabled";
                PO_button.backgroundSprites[0].hovered  = "OptionBaseHovered";
                PO_button.backgroundSprites[0].normal   = "OptionBase";
                PO_button.backgroundSprites[0].pressed  = "OptionBasePressed";

                PO_button.backgroundSprites.AddState();
                PO_button.backgroundSprites[1].disabled = "OptionBaseDisabled";
                PO_button.backgroundSprites[1].hovered  = "";
                PO_button.backgroundSprites[1].normal   = "OptionBaseFocused";
                PO_button.backgroundSprites[1].pressed  = "OptionBasePressed";

                PO_button.foregroundSprites[0].normal = "PO";

                PO_button.foregroundSprites.AddState();
                PO_button.foregroundSprites[1].normal = "POFocused";

                PO_button.relativePosition = new Vector3(4f, 76f);

                PO_button.activeStateIndex = 0;

                PO_button.eventClicked += (c, p) =>
                {
                    MoveItTool.PO.InitialiseTool();
                };

                m_viewOptions.height           += 36;
                m_viewOptions.absolutePosition += new Vector3(0, -36);
            }

            #endregion
        }
Esempio n. 26
0
        public override void Start()
        {
            name             = "MoveIt_SaveWindow";
            atlas            = UIUtils.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 180);
            canFocus         = true;

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;

            close                  = AddUIComponent <UIButton>();
            close.size             = new Vector2(30f, 30f);
            close.text             = "X";
            close.textScale        = 0.9f;
            close.textColor        = new Color32(118, 123, 123, 255);
            close.focusedTextColor = new Color32(118, 123, 123, 255);
            close.hoveredTextColor = new Color32(140, 142, 142, 255);
            close.pressedTextColor = new Color32(99, 102, 102, 102);
            close.textPadding      = new RectOffset(8, 8, 8, 8);
            close.canFocus         = false;
            close.playAudioEvents  = true;
            close.relativePosition = new Vector3(width - close.width, 0);

            close.eventClicked += (c, p) =>
            {
                Close();
            };

            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Export";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            // FastList
            fastList = AddUIComponent <UIFastList>();
            fastList.backgroundSprite = "UnlockingPanel";
            fastList.width            = width - 16;
            fastList.height           = 46 * 5;
            fastList.canSelect        = true;
            fastList.relativePosition = new Vector3(8, 28);

            fastList.rowHeight = 46f;

            height           = fastList.relativePosition.y + fastList.height + 8;
            dragHandle.size  = size;
            absolutePosition = new Vector3(loadWindowX.value, loadWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            UIComponent modalEffect = GetUIView().panelsLibraryModalEffect;

            if (modalEffect != null && !modalEffect.isVisible)
            {
                modalEffect.Show(false);
                ValueAnimator.Animate("ModalEffect", delegate(float val)
                {
                    modalEffect.opacity = val;
                }, new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));
            }

            BringToFront();
            Focus();
        }
Esempio n. 27
0
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "MoveIt_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3((UISaveWindow.instance != null ? 430 : 510) - deleteButton.width - 8, 8);
            deleteButton.tooltip          = "Delete saved selection";

            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "MoveIt_SaveLoadFileButton";
            saveLoadButton.text             = UISaveWindow.instance != null ? "Export" : "Import";
            saveLoadButton.size             = new Vector2(80f, 30f);
            saveLoadButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveLoadButton.width - 8, 8);

            if (UISaveWindow.instance == null) // Importing
            {
                loadToPosition                  = UIUtils.CreateButton(this);
                loadToPosition.name             = "MoveIt_loadToPosition";
                loadToPosition.text             = "Restore";
                loadToPosition.tooltip          = "Import the selection to the position it was exported";
                loadToPosition.size             = new Vector2(80f, 30f);
                loadToPosition.relativePosition = new Vector3(saveLoadButton.relativePosition.x - loadToPosition.width - 8, 8);

                loadToPosition.eventClicked += (c, p) =>
                {
                    UIView.Find("DefaultTooltip")?.Hide();
                    UILoadWindow.Close();
                    Destroy(loadToPosition);
                    MoveItTool.instance.Restore(fileNameLabel.text);
                };
            }
            else
            {
                loadToPosition = null;
            }

            saveLoadButton.eventClicked += (c, p) =>
            {
                UIView.Find("DefaultTooltip")?.Hide();
                if (UISaveWindow.instance != null)
                {
                    UISaveWindow.Export(fileNameLabel.text);
                }
                else
                {
                    UILoadWindow.Close();
                    MoveItTool.instance.Import(fileNameLabel.text);
                }
            };

            deleteButton.eventClicked += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete file", "Do you want to delete the file '" + fileNameLabel.text + "' permanently?", (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Delete(fileNameLabel.text);

                        if (UISaveWindow.instance != null)
                        {
                            UISaveWindow.instance.RefreshFileList();
                        }
                        else
                        {
                            UILoadWindow.instance.RefreshFileList();
                        }
                    }
                });
            };

            if (UISaveWindow.instance == null) // Importing
            {
                fileNameLabel.width = loadToPosition.relativePosition.x - 16f;
            }
            else
            {
                fileNameLabel.width = saveLoadButton.relativePosition.x - 16f;
            }
        }
Esempio n. 28
0
        private void SetupControls()
        {
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.gameObject.AddComponent <UICustomControl>();

            panel.backgroundSprite = "UnlockingPanel";
            panel.width            = width - 10;
            panel.height           = height - 75;
            panel.relativePosition = new Vector3(5, 0);

            // Max Speed
            UILabel maxSpeedLabel = panel.AddUIComponent <UILabel>();

            maxSpeedLabel.text             = Translations.Translate("AVO_MOD_OP06");
            maxSpeedLabel.textScale        = 0.8f;
            maxSpeedLabel.relativePosition = new Vector3(15, 14);

            m_maxSpeed = UIUtils.CreateTextField(panel);
            m_maxSpeed.numericalOnly    = true;
            m_maxSpeed.width            = 75;
            m_maxSpeed.tooltip          = Translations.Translate("AVO_MOD_OP07");
            m_maxSpeed.relativePosition = new Vector3(15, 33);

            kmhLabel                  = panel.AddUIComponent <UILabel>();
            kmhLabel.text             = "km/h";
            kmhLabel.textScale        = 0.8f;
            kmhLabel.relativePosition = new Vector3(95, 38);

            // Acceleration
            UILabel accelerationLabel = panel.AddUIComponent <UILabel>();

            accelerationLabel.text             = Translations.Translate("AVO_MOD_OP08");
            accelerationLabel.textScale        = 0.8f;
            accelerationLabel.relativePosition = new Vector3(160, 13);

            m_acceleration = UIUtils.CreateTextField(panel);
            m_acceleration.numericalOnly    = true;
            m_acceleration.allowFloats      = true;
            m_acceleration.width            = 60;
            m_acceleration.tooltip          = Translations.Translate("AVO_MOD_OP09");
            m_acceleration.relativePosition = new Vector3(160, 33);

            // Braking
            m_braking = UIUtils.CreateTextField(panel);
            m_braking.numericalOnly    = true;
            m_braking.allowFloats      = true;
            m_braking.width            = 60;
            m_braking.tooltip          = Translations.Translate("AVO_MOD_OP10");
            m_braking.relativePosition = new Vector3(230, 33);

            // Turning
            m_turning = UIUtils.CreateTextField(panel);
            m_turning.numericalOnly    = true;
            m_turning.allowFloats      = true;
            m_turning.width            = 60;
            m_turning.tooltip          = Translations.Translate("AVO_MOD_OP11");
            m_turning.relativePosition = new Vector3(300, 33);

            // Springs
            UILabel springsLabel = panel.AddUIComponent <UILabel>();

            springsLabel.text             = Translations.Translate("AVO_MOD_OP12");
            springsLabel.textScale        = 0.8f;
            springsLabel.relativePosition = new Vector3(15, 66);

            m_springs = UIUtils.CreateTextField(panel);
            m_springs.numericalOnly    = true;
            m_springs.allowFloats      = true;
            m_springs.width            = 60;
            m_springs.tooltip          = Translations.Translate("AVO_MOD_OP13");
            m_springs.relativePosition = new Vector3(15, 85);

            // Dampers
            m_dampers = UIUtils.CreateTextField(panel);
            m_dampers.numericalOnly    = true;
            m_dampers.allowFloats      = true;
            m_dampers.width            = 60;
            m_dampers.tooltip          = Translations.Translate("AVO_MOD_OP14");
            m_dampers.relativePosition = new Vector3(85, 85);

            // LeanMultiplier
            UILabel leanMultiplierLabel = panel.AddUIComponent <UILabel>();

            leanMultiplierLabel.text             = Translations.Translate("AVO_MOD_OP15");
            leanMultiplierLabel.textScale        = 0.8f;
            leanMultiplierLabel.relativePosition = new Vector3(160, 66);

            m_leanMultiplier = UIUtils.CreateTextField(panel);
            m_leanMultiplier.numericalOnly    = true;
            m_leanMultiplier.allowFloats      = true;
            m_leanMultiplier.width            = 60;
            m_leanMultiplier.tooltip          = Translations.Translate("AVO_MOD_OP16");
            m_leanMultiplier.relativePosition = new Vector3(160, 85);

            // NodMultiplier
            m_nodMultiplier = UIUtils.CreateTextField(panel);
            m_nodMultiplier.numericalOnly    = true;
            m_nodMultiplier.allowFloats      = true;
            m_nodMultiplier.width            = 60;
            m_nodMultiplier.tooltip          = Translations.Translate("AVO_MOD_OP17");
            m_nodMultiplier.relativePosition = new Vector3(230, 85);

            // Colors
            m_useColors                  = UIUtils.CreateCheckBox(panel);
            m_useColors.text             = Translations.Translate("AVO_MOD_OP18");
            m_useColors.isChecked        = true;
            m_useColors.width            = width - 40;
            m_useColors.tooltip          = Translations.Translate("AVO_MOD_OP19");
            m_useColors.relativePosition = new Vector3(15, 116);

            m_color0                      = UIUtils.CreateColorField(panel);
            m_color0.name                 = "AVO-color0";
            m_color0.popupTopmostRoot     = false;
            m_color0.relativePosition     = new Vector3(35, 135);
            m_color0_hex                  = UIUtils.CreateTextField(panel);
            m_color0_hex.maxLength        = 6;
            m_color0_hex.relativePosition = new Vector3(80, 137);

            m_color1                      = UIUtils.CreateColorField(panel);
            m_color1.name                 = "AVO-color1";
            m_color1.popupTopmostRoot     = false;
            m_color1.relativePosition     = new Vector3(35, 160);
            m_color1_hex                  = UIUtils.CreateTextField(panel);
            m_color1_hex.maxLength        = 6;
            m_color1_hex.relativePosition = new Vector3(80, 162);

            m_color2                      = UIUtils.CreateColorField(panel);
            m_color2.name                 = "AVO-color2";
            m_color2.popupTopmostRoot     = false;
            m_color2.relativePosition     = new Vector3(182, 135);
            m_color2_hex                  = UIUtils.CreateTextField(panel);
            m_color2_hex.maxLength        = 6;
            m_color2_hex.relativePosition = new Vector3(225, 137);

            m_color3                      = UIUtils.CreateColorField(panel);
            m_color3.name                 = "AVO-color3";
            m_color3.popupTopmostRoot     = false;
            m_color3.relativePosition     = new Vector3(182, 160);
            m_color3_hex                  = UIUtils.CreateTextField(panel);
            m_color3_hex.maxLength        = 6;
            m_color3_hex.relativePosition = new Vector3(225, 162);

            m_useColorsLabel = panel.AddUIComponent <UILabel>();
            m_useColorsLabel.Hide();
            m_useColorsLabel.textScale        = 0.8f;
            m_useColorsLabel.text             = Translations.Translate("AVO_MOD_OP20");
            m_useColorsLabel.relativePosition = new Vector3(15, 116);

            // Enable & BackEngine
            m_enabled                  = UIUtils.CreateCheckBox(panel);
            m_enabled.text             = Translations.Translate("AVO_MOD_OP21");
            m_enabled.isChecked        = true;
            m_enabled.width            = width - 40;
            m_enabled.tooltip          = Translations.Translate("AVO_MOD_OP22");
            m_enabled.relativePosition = new Vector3(15, 195);

            m_addBackEngine                  = UIUtils.CreateCheckBox(panel);
            m_addBackEngine.text             = Translations.Translate("AVO_MOD_OP23");
            m_addBackEngine.isChecked        = false;
            m_addBackEngine.width            = width - 40;
            m_addBackEngine.tooltip          = Translations.Translate("AVO_MOD_OP24");
            m_addBackEngine.relativePosition = new Vector3(15, 215);

            // LargeVehicle Setting for NoBigTruck Delivery Mod
            m_isLargeVehicle                  = UIUtils.CreateCheckBox(panel);
            m_isLargeVehicle.text             = Translations.Translate("AVO_MOD_OP25");
            m_isLargeVehicle.width            = width - 40;
            m_isLargeVehicle.tooltip          = Translations.Translate("AVO_MOD_OP26");
            m_isLargeVehicle.relativePosition = new Vector3(15, 215);

            // Capacity
            UIPanel capacityPanel = panel.AddUIComponent <UIPanel>();

            capacityPanel.size             = Vector2.zero;
            capacityPanel.relativePosition = new Vector3(15, 240);

            capacityLabel                  = capacityPanel.AddUIComponent <UILabel>();
            capacityLabel.text             = Translations.Translate("AVO_MOD_CAPA");
            capacityLabel.textScale        = 0.8f;
            capacityLabel.relativePosition = new Vector3(0, 2);

            m_capacity = UIUtils.CreateTextField(capacityPanel);
            m_capacity.numericalOnly    = true;
            m_capacity.maxLength        = 8;
            m_capacity.width            = 100;
            m_capacity.tooltip          = Translations.Translate("AVO_MOD_OP27");
            m_capacity.relativePosition = new Vector3(0, 21);

            m_planesize                  = capacityPanel.AddUIComponent <UILabel>();
            m_planesize.textScale        = 0.8f;
            m_planesize.relativePosition = new Vector3(170, 2);

            // Special Capacity
            specialcapacityLabel = capacityPanel.AddUIComponent <UILabel>();
            specialcapacityLabel.Hide();
            specialcapacityLabel.text             = Translations.Translate("AVO_MOD_OP28");
            specialcapacityLabel.textScale        = 0.8f;
            specialcapacityLabel.relativePosition = new Vector3(160, 2);

            m_specialcapacity = UIUtils.CreateTextField(capacityPanel);
            m_specialcapacity.Hide();
            m_specialcapacity.numericalOnly    = true;
            m_specialcapacity.maxLength        = 8;
            m_specialcapacity.width            = 100;
            m_specialcapacity.tooltip          = Translations.Translate("AVO_MOD_OP29");
            m_specialcapacity.relativePosition = new Vector3(160, 21);

            // Userguide Special Capacity Button
            m_userguidespecialcapacity = UIUtils.CreateButton(capacityPanel);
            m_userguidespecialcapacity.Hide();
            m_userguidespecialcapacity.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespecialcapacity.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespecialcapacity.size             = new Vector2(14f, 14f);
            m_userguidespecialcapacity.tooltip          = Translations.Translate("AVO_MOD_OP30");
            m_userguidespecialcapacity.relativePosition = new Vector3(265, 24);

            // Transport Line Overview Button
            m_lineoverview = UIUtils.CreateButton(panel);
            m_lineoverview.Hide();
            m_lineoverview.textScale             = 0.8f;
            m_lineoverview.height                = 18;
            m_lineoverview.textVerticalAlignment = UIVerticalAlignment.Bottom;
            m_lineoverview.text             = Translations.Translate("AVO_MOD_OP31");
            m_lineoverview.width            = 335;
            m_lineoverview.tooltip          = Translations.Translate("AVO_MOD_OP32");
            m_lineoverview.relativePosition = new Vector3(15, 194);

            // Userguide Spawn Button
            m_userguidespawn = UIUtils.CreateButton(panel);
            m_userguidespawn.Hide();
            m_userguidespawn.normalBgSprite   = "EconomyMoreInfo";
            m_userguidespawn.hoveredBgSprite  = "EconomyMoreInfoHovered";
            m_userguidespawn.size             = new Vector2(14f, 14f);
            m_userguidespawn.tooltip          = Translations.Translate("AVO_MOD_OP33");
            m_userguidespawn.relativePosition = new Vector3(355, 195);

            // Buslabel
            bustrailerLabel                  = panel.AddUIComponent <UILabel>();
            bustrailerLabel.textScale        = 0.8f;
            bustrailerLabel.text             = Translations.Translate("AVO_MOD_OP34");
            bustrailerLabel.relativePosition = new Vector3(15, 194);

            // Restore default
            m_restore                  = UIUtils.CreateButton(panel);
            m_restore.text             = Translations.Translate("AVO_MOD_OP35");
            m_restore.width            = 120;
            m_restore.tooltip          = Translations.Translate("AVO_MOD_OP36");
            m_restore.relativePosition = new Vector3(250, height - 45);

            // Remove Vehicles
            m_removeLabel                  = this.AddUIComponent <UILabel>();
            m_removeLabel.text             = Translations.Translate("AVO_MOD_OP37");
            m_removeLabel.textScale        = 0.8f;
            m_removeLabel.relativePosition = new Vector3(10, height - 65);

            m_clearVehicles                  = UIUtils.CreateButton(this);
            m_clearVehicles.text             = Translations.Translate("AVO_MOD_OP38");
            m_clearVehicles.width            = 120;
            m_clearVehicles.tooltip          = Translations.Translate("AVO_MOD_OP39");
            m_clearVehicles.relativePosition = new Vector3(5, height - 45);

            m_clearParked                  = UIUtils.CreateButton(this);
            m_clearParked.text             = Translations.Translate("AVO_MOD_OP40");
            m_clearParked.width            = 120;
            m_clearParked.tooltip          = Translations.Translate("AVO_MOD_OP41");
            m_clearParked.relativePosition = new Vector3(130, height - 45);

            panel.BringToFront();

            // Event handlers
            m_maxSpeed.eventTextSubmitted       += OnMaxSpeedSubmitted;
            m_acceleration.eventTextSubmitted   += OnAccelerationSubmitted;
            m_braking.eventTextSubmitted        += OnBrakingSubmitted;
            m_turning.eventTextSubmitted        += OnTurningSubmitted;
            m_springs.eventTextSubmitted        += OnSpringsSubmitted;
            m_dampers.eventTextSubmitted        += OnDampersSubmitted;
            m_leanMultiplier.eventTextSubmitted += OnleanMultiplierSubmitted;
            m_nodMultiplier.eventTextSubmitted  += OnnodMultiplierSubmitted;

            m_useColors.eventCheckChanged += OnCheckChanged;

            MouseEventHandler mousehandler = (c, p) => { if (m_initialized)
                                                         {
                                                             (parent as UIMainPanel).ChangePreviewColor((c as UIColorField).selectedColor);
                                                         }
            };

            m_color0.eventMouseEnter += mousehandler;
            m_color1.eventMouseEnter += mousehandler;
            m_color2.eventMouseEnter += mousehandler;
            m_color3.eventMouseEnter += mousehandler;

            m_color0_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color0.selectedColor);
                                                        }
            };
            m_color1_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color1.selectedColor);
                                                        }
            };
            m_color2_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color2.selectedColor);
                                                        }
            };
            m_color3_hex.eventMouseEnter += (c, p) => { if (m_initialized)
                                                        {
                                                            (parent as UIMainPanel).ChangePreviewColor(m_color3.selectedColor);
                                                        }
            };

            m_color0.eventSelectedColorChanged += OnColorChanged;
            m_color1.eventSelectedColorChanged += OnColorChanged;
            m_color2.eventSelectedColorChanged += OnColorChanged;
            m_color3.eventSelectedColorChanged += OnColorChanged;

            m_color0_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color1_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color2_hex.eventTextSubmitted += OnColorHexSubmitted;
            m_color3_hex.eventTextSubmitted += OnColorHexSubmitted;

            m_enabled.eventCheckChanged        += OnCheckChanged;
            m_addBackEngine.eventCheckChanged  += OnCheckChanged;
            m_isLargeVehicle.eventCheckChanged += OnCheckChanged;

            m_capacity.eventTextSubmitted        += OnCapacitySubmitted;
            m_specialcapacity.eventTextSubmitted += OnSpecialCapacitySubmitted;

            m_restore.eventClick += (c, p) =>
            {
                m_initialized = false;
                bool isEnabled = m_options.enabled;
                DefaultOptions.Restore(m_options.prefab);
                VehicleOptions.UpdateTransfertVehicles();

                VehicleOptions.prefabUpdateEngine = m_options.prefab;
                VehicleOptions.prefabUpdateUnits  = m_options.prefab;
                SimulationManager.instance.AddAction(VehicleOptions.UpdateBackEngines);
                SimulationManager.instance.AddAction(VehicleOptions.UpdateCapacityUnits);

                Show(m_options);

                if (m_options.enabled != isEnabled)
                {
                    eventEnableCheckChanged(this, m_options.enabled);
                }
            };

            m_clearVehicles.eventClick            += OnClearVehicleClicked;
            m_clearParked.eventClick              += OnClearVehicleClicked;
            m_lineoverview.eventClick             += OnlineoverviewClicked;
            m_userguidespawn.eventClick           += OnUserGuideSpawnClicked;
            m_userguidespecialcapacity.eventClick += OnUserGuideSpecialCapacityClicked;
        }
Esempio n. 29
0
        private void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "IconAssetBuilding";
            m_title.title      = "Mesh Info " + MeshInfo.version;

            // Type DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(15f, offset + 5f);
            label.text             = "Type :";

            m_prefabType       = UIUtils.CreateDropDown(this);
            m_prefabType.width = 110;
            m_prefabType.AddItem("Building");
            m_prefabType.AddItem("Prop");
            m_prefabType.AddItem("Tree");
            m_prefabType.AddItem("Vehicle");
            m_prefabType.selectedIndex    = 0;
            m_prefabType.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_prefabType.eventSelectedIndexChanged += (c, t) =>
            {
                m_prefabType.enabled = false;
                m_isSorted           = false;
                PopulateList();
                m_prefabType.enabled = true;
            };

            // Sorting DropDown
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_prefabType.relativePosition + new Vector3(130f, 0f);
            label.text             = "Sort by :";

            m_sorting       = UIUtils.CreateDropDown(this);
            m_sorting.width = 125;
            m_sorting.AddItem("Name");
            m_sorting.AddItem("Triangles");
            m_sorting.AddItem("LOD Triangles");
            m_sorting.AddItem("Weight");
            m_sorting.AddItem("LOD Weight");
            m_sorting.AddItem("Texture");
            m_sorting.AddItem("LOD Texture");
            m_sorting.selectedIndex    = 0;
            m_sorting.relativePosition = label.relativePosition + new Vector3(60f, 0f);

            m_sorting.eventSelectedIndexChanged += (c, t) =>
            {
                m_sorting.enabled = false;
                m_isSorted        = false;
                PopulateList();
                m_sorting.enabled = true;
            };

            // Sorting direction
            m_sortDirection                  = AddUIComponent <UISprite>();
            m_sortDirection.atlas            = UIUtils.GetAtlas("Ingame");
            m_sortDirection.spriteName       = "IconUpArrow";
            m_sortDirection.relativePosition = m_sorting.relativePosition + new Vector3(130f, 0f);

            m_sortDirection.eventClick += (c, t) =>
            {
                m_sortDirection.flip = (m_sortDirection.flip == UISpriteFlip.None) ? UISpriteFlip.FlipVertical : UISpriteFlip.None;
                m_isSorted           = false;
                PopulateList();
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 150f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.relativePosition = new Vector3(width - m_search.width - 15f, offset + 5f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = "Search :";


            m_search.eventTextChanged += (c, t) => PopulateList();

            // Labels
            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Name";
            label.relativePosition = new Vector3(15f, offset + 50f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Texture";
            label.relativePosition = new Vector3(width - 135f, offset + 50f);

            UILabel label2 = AddUIComponent <UILabel>();

            label2.textScale        = 0.9f;
            label2.text             = "Weight";
            label2.relativePosition = label.relativePosition - new Vector3(125f, 0f);

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.9f;
            label.text             = "Triangles";
            label.relativePosition = label2.relativePosition - new Vector3(115f, 0f);

            // Item List
            m_itemList                  = UIFastList.Create <UIPrefabItem>(this);
            m_itemList.rowHeight        = 40f;
            m_itemList.backgroundSprite = "UnlockingPanel";
            m_itemList.width            = width - 10;
            m_itemList.height           = height - offset - 75;
            m_itemList.relativePosition = new Vector3(5f, offset + 70f);
        }
Esempio n. 30
0
        private void Initialise()
        {
            Panel                  = UIView.GetAView().AddUIComponent(typeof(UIPanel)) as UIPanel;
            Panel.name             = "MoveIt_MoveToPanel";
            Panel.atlas            = ResourceLoader.GetAtlas("Ingame");
            Panel.backgroundSprite = "MenuPanel2";
            Panel.size             = new Vector2(190, 185);
            Panel.absolutePosition = new Vector3(Panel.GetUIView().GetScreenResolution().x - 220, Panel.GetUIView().GetScreenResolution().y - 600);
            Panel.clipChildren     = true;
            Panel.isVisible        = false;
            Panel.anchor           = UIAnchorStyle.None;

            TitleContainer          = Panel.AddUIComponent <UISlicedSprite>();
            TitleContainer.position = new Vector3(0, 0);
            TitleContainer.size     = new Vector2(Panel.width, 40);

            TitleIcon = TitleContainer.AddUIComponent(typeof(UISprite)) as UISprite;
            TitleIcon.relativePosition = new Vector3(4, 4);
            TitleIcon.size             = new Vector2(32, 32);
            TitleIcon.atlas            = UIMoveItButton.GetAtlas(new string[] { "MoveIt" });
            TitleIcon.spriteName       = "MoveIt";

            TitleCaption        = TitleContainer.AddUIComponent <UILabel>();
            TitleCaption.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
            TitleCaption.size   = new Vector2(Panel.width, 40);
            TitleCaption.text   = Str.setpos_Title;

            TitleDrag = TitleContainer.AddUIComponent(typeof(UIDragHandle)) as UIDragHandle;
            TitleDrag.relativePosition = new Vector3(0, 0);
            TitleDrag.size             = new Vector2(Panel.width, 40);
            TitleDrag.target           = Panel;

            TitleClose                  = TitleContainer.AddUIComponent <UIButton>();
            TitleClose.atlas            = ResourceLoader.GetAtlas("Ingame");
            TitleClose.normalBgSprite   = "buttonclose";
            TitleClose.pressedBgSprite  = "buttonclosepressed";
            TitleClose.hoveredBgSprite  = "buttonclosehover";
            TitleClose.size             = new Vector2(32, 32);
            TitleClose.relativePosition = new Vector3(Panel.width - 36, 4);
            TitleClose.eventClicked    += (UIComponent c, UIMouseEventParameter p) =>
            {
                MoveItTool.instance.DeactivateTool();
            };

            XLabel = Panel.AddUIComponent <UILabel>();
            XLabel.relativePosition = new Vector3(8, 52);
            XLabel.text             = "X:";
            XInput = UIUtils.CreateTextField(Panel);
            XInput.relativePosition    = new Vector3(30, 48);
            XInput.size                = new Vector2(148, 24);
            XInput.horizontalAlignment = UIHorizontalAlignment.Left;
            XInput.tabIndex            = 0;
            XInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(XInput); };

            ZLabel = Panel.AddUIComponent <UILabel>();
            ZLabel.relativePosition = new Vector3(8, 86);
            ZLabel.text             = "Y:";
            ZInput = UIUtils.CreateTextField(Panel);
            ZInput.relativePosition    = new Vector3(30, 82);
            ZInput.size                = new Vector2(148, 24);
            ZInput.horizontalAlignment = UIHorizontalAlignment.Left;
            ZInput.tabIndex            = 1;
            ZInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(ZInput); };

            YLabel = Panel.AddUIComponent <UILabel>();
            YLabel.relativePosition = new Vector3(8, 120);
            YLabel.text             = "H:";
            YLabel.tooltip          = Str.setpos_H_Tooltip;
            YInput = UIUtils.CreateTextField(Panel);
            YInput.relativePosition    = new Vector3(30, 116);
            YInput.size                = new Vector2(148, 24);
            YInput.horizontalAlignment = UIHorizontalAlignment.Left;
            YInput.tabIndex            = 2;
            YInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(YInput); };

            ALabel = Panel.AddUIComponent <UILabel>();
            ALabel.relativePosition = new Vector3(8, 154);
            ALabel.text             = "A:";
            ALabel.tooltip          = Str.setpos_A_Tooltip;
            AInput = UIUtils.CreateTextField(Panel);
            AInput.relativePosition    = new Vector3(30, 150);
            AInput.size                = new Vector2(100, 24);
            AInput.horizontalAlignment = UIHorizontalAlignment.Left;
            AInput.tabIndex            = 3;
            AInput.eventLostFocus     += (UIComponent c, UIFocusEventParameter f) => { Validate(AInput); };

            Submit = UIUtils.CreateButton(Panel);
            Submit.relativePosition = new Vector3(138, 146);
            Submit.size             = new Vector2(40, 30);
            Submit.text             = Str.setpos_Go;
            Submit.tabIndex         = 4;
            Submit.eventClicked    += (UIComponent c, UIMouseEventParameter p) =>
            {
                Go();
            };
        }