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; }
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; }
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; }
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 }
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(); }; }
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; } }
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(); }
public override void Start() { base.Start(); atlas = UIUtils.GetAtlas("Ingame"); backgroundSprite = "MenuPanel"; color = new Color32(58, 88, 104, 255); isVisible = false; canFocus = true; isInteractive = true; clipChildren = true; width = 400; height = 380; relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2)); // Title Bar m_title = AddUIComponent <UITitleBar>(); m_title.title = "New Shortcut"; m_title.isModal = true; // Name UILabel label = AddUIComponent <UILabel>(); label.text = "Shortcut name:"; label.autoHeight = true; label.relativePosition = new Vector2(20, 60); m_name = UIUtils.CreateTextField(this); m_name.size = new Vector2(width - 40, 30); m_name.relativePosition = label.relativePosition + new Vector3(0, label.height + 5); m_name.textScale = 1.1f; m_name.padding.top = 6; m_name.useDropShadow = true; m_name.eventTextChanged += (c, s) => { m_ok.isEnabled = !s.IsNullOrWhiteSpace(); }; // Component Name label = AddUIComponent <UILabel>(); label.text = "Button name:"; label.autoHeight = true; label.relativePosition = m_name.relativePosition + new Vector3(0, m_name.height + 15); m_componentName = UIUtils.CreateTextField(this); m_componentName.size = new Vector2(width - 40, 30); m_componentName.relativePosition = label.relativePosition + new Vector3(0, label.height + 5); m_componentName.textScale = 1.1f; m_componentName.padding.top = 6; m_componentName.useDropShadow = true; m_componentName.isEnabled = false; // Binding label = AddUIComponent <UILabel>(); label.text = "Key binding:"; label.autoHeight = true; label.relativePosition = m_componentName.relativePosition + new Vector3(0, m_componentName.height + 15); m_binding = OptionsKeymapping.GetKeymapping(this, null); m_binding.width = width - 40; m_binding.relativePosition = label.relativePosition + new Vector3(0, label.height + 5); // Use Path m_usePath = UIUtils.CreateCheckBox(this); m_usePath.label.text = "Use button's full path"; m_usePath.tooltip = "If checked, the full path to the button is used rather than the name alone.\nThis ensure the button is unique."; m_usePath.relativePosition = m_binding.relativePosition + new Vector3(0, m_binding.height + 15); m_usePath.eventCheckChanged += (c, state) => { shortcut.usePath = state; }; // Only visible m_onlyVisible = UIUtils.CreateCheckBox(this); m_onlyVisible.label.text = "Trigger only if visible"; m_onlyVisible.tooltip = "If checked, the button is only triggered if visible.\nUseful for buttons with the same name but only one visible at a time."; m_onlyVisible.relativePosition = m_usePath.relativePosition + new Vector3(0, m_usePath.height + 10); m_onlyVisible.eventCheckChanged += (c, state) => { shortcut.onlyVisible = state; }; // Ok m_ok = UIUtils.CreateButton(this); m_ok.text = "OK"; m_ok.relativePosition = new Vector2(20, height - m_ok.height - 20); m_ok.isEnabled = false; m_ok.eventClick += (c, p) => { if (isVisible) { if (m_name.text != shortcut.name) { shortcut.name = Shortcut.GetUniqueName(m_name.text); } shortcut.usePath = m_usePath.isChecked; shortcut.onlyVisible = m_onlyVisible.isChecked; shortcut.inputKey = ((Shortcut)m_binding.objectUserData).inputKey; Shortcut.AddShortcut(shortcut); Shortcut.SaveShorcuts(); OptionsKeymapping.RefreshShortcutsList(); UIView.PopModal(); Hide(); } }; // Cancel m_cancel = UIUtils.CreateButton(this); m_cancel.text = "Cancel"; m_cancel.relativePosition = new Vector2(width - m_cancel.width - 20, height - m_cancel.height - 20); m_cancel.eventClick += (c, p) => { if (isVisible) { UIView.PopModal(); Hide(); } }; isVisible = false; }
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; } }
/*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); } }; }
public override void Start() { name = "CCX_SaveLoadWindow"; atlas = UIUtils.GetAtlas("Ingame"); backgroundSprite = "SubcategoriesPanel"; size = new Vector2(465, 180); 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) => { isVisible = false; Destroy(gameObject); }; UILabel label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = "Save/Load Path"; 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); // Save saveButton = UIUtils.CreateButton(savePanel); saveButton.name = "CCX_SaveButton"; saveButton.text = "Save"; 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 = UIFastList.Create <UISaveLoadFileRow>(this); fastList.backgroundSprite = "UnlockingPanel"; fastList.width = width - 16; fastList.height = 46 * 5; 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 (!fileNameInput.text.IsNullOrWhiteSpace()) { CameraDirector.cameraPath.Serialize(filename); fileNameInput.text = ""; RefreshFileList(); } }; height = fastList.relativePosition.y + fastList.height + 8; dragHandle.size = size; absolutePosition = new Vector3(savedWindowX.value, savedWindowY.value); MakePixelPerfect(); RefreshFileList(); fileNameInput.Focus(); }
private void SetupControls() { float offset = 40f; //Beta Testing Timestamp //DateTime now = DateTime.Now; //m_title.title = "Advanced Vehicle Options " + ModInfo.version + " " + now; // 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 = 175; 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 = "Actions for Vehicle Configuration:"; configLabel.textScale = 0.8f; configLabel.relativePosition = new Vector3(16, height - 65); m_import = UIUtils.CreateButton(this); m_import.text = "Import"; m_import.width = 80; m_import.tooltip = "Import the configuration"; m_import.relativePosition = new Vector3(10, height - 45); m_export = UIUtils.CreateButton(this); m_export.text = "Export"; m_export.width = 80; m_export.tooltip = "Export the configuration"; m_export.relativePosition = new Vector3(95, height - 45); m_resetall = UIUtils.CreateButton(this); m_resetall.text = "Reset all"; m_resetall.width = 80; m_resetall.tooltip = "Reset full configuration"; m_resetall.relativePosition = new Vector3(180, height - 45); // 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 = "Click here to cycle through the existing vehicles of that type.\nHold Shift Key down for zooming directly to vehicle."; 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 = "Click here to remove the selected vehicle."; 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(); AdvancedVehicleOptionsUID.ImportConfig(); optionList = AdvancedVehicleOptionsUID.config.options; }; m_export.eventClick += (c, t) => AdvancedVehicleOptionsUID.ExportConfig(); m_resetall.eventClick += (c, t) => { ConfirmPanel.ShowModal("Confirm Reset Configuration", "Customized settings for all vehicles will be reset.\n\n" + "Proceed with Configuration reset ?", (comp, ret) => { if (ret != 1) { return; } DefaultOptions.RestoreAll(); AdvancedVehicleOptionsUID.ResetConfig(); optionList = AdvancedVehicleOptionsUID.config.options; ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel"); resetpanel.SetMessage("Advanced Vehicle Options", "All vehicle configuration and customized settings\n" + "have been reset to the Game Defaults.", 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); } }; }
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, 14); 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, 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 = "Acceleration/Brake/Turning:"; 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 = "Change the vehicle acceleration factor"; 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 = "Change the vehicle braking factor"; 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 = "Change the vehicle turning factor;\nDefines how well the car corners"; m_turning.relativePosition = new Vector3(300, 33); // Springs UILabel springsLabel = panel.AddUIComponent <UILabel>(); springsLabel.text = "Springs/Dampers:"; 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 = "Change the vehicle spring factor;\nDefines how much the suspension moves"; 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 = "Change the vehicle damper factor;\nDefines how quickly the suspension returns to the default state"; m_dampers.relativePosition = new Vector3(85, 85); // LeanMultiplier UILabel leanMultiplierLabel = panel.AddUIComponent <UILabel>(); leanMultiplierLabel.text = "Lean/Nod Multiplier:"; 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 = "Change the vehicle lean multiplication factor;\nDefines how much the vehicle leans to the sides when turning"; 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 = "Change the vehicle nod multiplication factor;\nDefines how much the vehicle nods forward/backward when braking or accelerating"; m_nodMultiplier.relativePosition = new Vector3(230, 85); // Colors m_useColors = UIUtils.CreateCheckBox(panel); m_useColors.text = "Enable 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, 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 = "Colors are managed by Vehicle Color Expander"; m_useColorsLabel.relativePosition = new Vector3(15, 116); // 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, 195);; 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, 215); // LargeVehicle Setting for NoBigTruck Delivery Mod m_isLargeVehicle = UIUtils.CreateCheckBox(panel); m_isLargeVehicle.text = "Flag as Large Vehicle"; m_isLargeVehicle.width = width - 40; m_isLargeVehicle.tooltip = "Prevent vehicles with trailer to deliver to small buildings\n\nNeeds No Big Trucks mod to work"; 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 = "Capacity: "; 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 = "Change the capacity of the vehicle"; m_capacity.relativePosition = new Vector3(0, 21); // Special Capacity specialcapacityLabel = capacityPanel.AddUIComponent <UILabel>(); specialcapacityLabel.Hide(); specialcapacityLabel.text = "Special Capacity: "; 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 = "Change special parameters of the vehicle"; 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 = "If you do not know, what this value is:\nDo not touch it!\n\nClick for User Guide: Special Capacity"; 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 = "Manage Spawning in Transport Line Overview"; m_lineoverview.width = 335; m_lineoverview.tooltip = "Open the Transport Line Overview and manage the vehicle spawning"; 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 = "Click for User Guide: Spawn Control"; m_userguidespawn.relativePosition = new Vector3(355, 195); // Buslabel bustrailerLabel = panel.AddUIComponent <UILabel>(); bustrailerLabel.textScale = 0.8f; bustrailerLabel.text = "Bus trailers spawning is controlled by the main\n" + "Bus vehicle. Settings must be configured from\n" + "the Transport Line Overview panel."; bustrailerLabel.relativePosition = new Vector3(15, 194); // Restore default m_restore = UIUtils.CreateButton(panel); m_restore.text = "Default Values"; m_restore.width = 120; m_restore.tooltip = "Restore all values to default"; m_restore.relativePosition = new Vector3(250, height - 45); // Remove Vehicles m_removeLabel = this.AddUIComponent <UILabel>(); m_removeLabel.text = "Global Actions for: "; m_removeLabel.textScale = 0.8f; m_removeLabel.relativePosition = new Vector3(10, height - 65); m_clearVehicles = UIUtils.CreateButton(this); m_clearVehicles.text = "Remove Driving"; m_clearVehicles.width = 120; m_clearVehicles.tooltip = "Remove all driving vehicles of that type\nHold the SHIFT key to remove all types"; m_clearVehicles.relativePosition = new Vector3(5, height - 45); m_clearParked = UIUtils.CreateButton(this); m_clearParked.text = "Remove Parked"; m_clearParked.width = 120; m_clearParked.tooltip = "Remove all parked vehicles of that type\nHold the SHIFT key to remove all types"; 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; 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; m_lineoverview.eventClick += OnlineoverviewClicked; m_userguidespawn.eventClick += OnUserGuideSpawnClicked; m_userguidespecialcapacity.eventClick += OnUserGuideSpecialCapacityClicked; }
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; }
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); } }; }
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(); }; }
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 }
public override void Start() { name = "CCX_MainWindow"; atlas = UIUtils.GetAtlas("Ingame"); backgroundSprite = "SubcategoriesPanel"; size = new Vector2(465, 180); isVisible = false; UIDragHandle dragHandle = AddUIComponent <UIDragHandle>(); dragHandle.target = parent; dragHandle.relativePosition = Vector3.zero; UIButton 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) => { if (isVisible) { CameraDirector.ToggleUI(); } }; // Control panel UILabel label = AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = "Cinematic Camera Extended"; label.relativePosition = new Vector2(8, 8); label.SendToBack(); UIPanel controlPanel = AddUIComponent <UIPanel>(); controlPanel.atlas = atlas; controlPanel.backgroundSprite = "GenericPanel"; controlPanel.color = new Color32(206, 206, 206, 255); controlPanel.size = new Vector2(width - 16, 46); controlPanel.relativePosition = new Vector2(8, 28); addKnotButton = UIUtils.CreateButton(controlPanel); addKnotButton.name = "CCX_AddKnot"; addKnotButton.textScale = 1.5f; addKnotButton.text = "+"; addKnotButton.size = new Vector2(40f, 30f); addKnotButton.relativePosition = new Vector3(8, 8); addKnotButton.tooltip = "Add a new point to the path"; playButton = UIUtils.CreateButton(controlPanel); playButton.name = "CCX_Play"; playButton.textScale = 1.5f; playButton.text = ">"; playButton.size = new Vector2(40f, 30f); playButton.playAudioEvents = false; playButton.relativePosition = new Vector3(controlPanel.width - playButton.width - 8, 8); playButton.tooltip = "Play the current path"; playSpeedDropDown = UIUtils.CreateDropDown(controlPanel); playSpeedDropDown.width = 75; playSpeedDropDown.items = new string[] { "x 1/16", "x 1/8", "x 1/4", "x 1/2", "x 1", "x 2", "x 4", "x 8", "x 16" }; playSpeedDropDown.selectedValue = "x 1"; playSpeedDropDown.relativePosition = new Vector3(playButton.relativePosition.x - playSpeedDropDown.width - 8, 8); playSpeedDropDown.tooltip = "Playback speed"; timelineSlider = controlPanel.AddUIComponent <UISlider>(); timelineSlider.name = "CCX_TimelineSlider"; timelineSlider.size = new Vector2(playSpeedDropDown.relativePosition.x - addKnotButton.relativePosition.x - addKnotButton.width - 20, 18); timelineSlider.relativePosition = new Vector2(addKnotButton.relativePosition.x + addKnotButton.width + 10, 14); UISlicedSprite bgSlider = timelineSlider.AddUIComponent <UISlicedSprite>(); bgSlider.atlas = atlas; bgSlider.spriteName = "BudgetSlider"; bgSlider.size = new Vector2(timelineSlider.width, 9); bgSlider.relativePosition = new Vector2(0, 4); bgSlider.tooltip = "Drag the slider to preview the animation"; UISlicedSprite thumb = timelineSlider.AddUIComponent <UISlicedSprite>(); thumb.atlas = atlas; thumb.spriteName = "SliderBudget"; timelineSlider.thumbObject = thumb; timelineSlider.minValue = 0f; timelineSlider.maxValue = 1f; timelineSlider.stepSize = 0; timelineSlider.value = 0; // FOV panel UIPanel fovPanel = AddUIComponent <UIPanel>(); fovPanel.atlas = atlas; fovPanel.backgroundSprite = "GenericPanel"; fovPanel.color = new Color32(206, 206, 206, 255); fovPanel.size = new Vector2(width - 120 - 8 * 3, 46); fovPanel.relativePosition = new Vector2(8, controlPanel.relativePosition.y + controlPanel.height + 8); label = fovPanel.AddUIComponent <UILabel>(); label.textScale = 0.9f; label.text = "Fov:"; label.autoSize = false; label.height = 30; label.verticalAlignment = UIVerticalAlignment.Middle; label.relativePosition = new Vector2(8, 8); fovInput = UIUtils.CreateTextField(fovPanel); fovInput.name = "CCX_MainFovInput"; fovInput.size = new Vector2(45f, 26); fovInput.text = (2f * CameraDirector.camera.fieldOfView).ToString(); fovInput.numericalOnly = true; fovInput.allowFloats = true; fovInput.padding.top = 6; fovInput.relativePosition = new Vector3(fovPanel.width - fovInput.width - 8, 10); fovInput.tooltip = "Field of view in degrees"; fovSlider = fovPanel.AddUIComponent <UISlider>(); fovSlider.name = "CCX_TimelineSlider"; fovSlider.size = new Vector2(fovInput.relativePosition.x - label.relativePosition.x - label.width - 20, 18); fovSlider.relativePosition = new Vector2(label.relativePosition.x + label.width + 10, 14); bgSlider = fovSlider.AddUIComponent <UISlicedSprite>(); bgSlider.atlas = atlas; bgSlider.spriteName = "BudgetSlider"; bgSlider.size = new Vector2(fovSlider.width, 9); bgSlider.relativePosition = new Vector2(0, 4); bgSlider.tooltip = "Drag the slider to change the field of view"; thumb = fovSlider.AddUIComponent <UISlicedSprite>(); thumb.atlas = atlas; thumb.spriteName = "SliderBudget"; fovSlider.thumbObject = thumb; fovSlider.minValue = 20f; fovSlider.maxValue = 179f; fovSlider.stepSize = 1f; fovSlider.value = CameraDirector.camera.fieldOfView * 2f; // FPS panel UIPanel fpsPanel = AddUIComponent <UIPanel>(); fpsPanel.atlas = atlas; fpsPanel.backgroundSprite = "GenericPanel"; fpsPanel.color = new Color32(206, 206, 206, 255); fpsPanel.size = new Vector2(120, 46); fpsPanel.relativePosition = new Vector2(fovPanel.relativePosition.x + fovPanel.width + 8, fovPanel.relativePosition.y); fpsInput = UIUtils.CreateTextField(fpsPanel); fpsInput.name = "CCX_FpsInput"; fpsInput.size = new Vector2(45f, 26); fpsInput.text = CameraDirector.fps.ToString(); fpsInput.numericalOnly = true; fpsInput.allowFloats = true; fpsInput.padding.top = 6; fpsInput.relativePosition = new Vector3(fpsPanel.width - fpsInput.width - 8, 10); fpsInput.tooltip = "Fps"; fpsInput.tooltip = "Sync the camera and the simulation at a set frame rate"; fpsCheckBox = UIUtils.CreateCheckBox(fpsPanel); fpsCheckBox.text = "Fps:"; fpsCheckBox.isChecked = false; fpsCheckBox.width = fpsPanel.width - fpsInput.width - 24; fpsCheckBox.relativePosition = new Vector2(8, 16); fpsCheckBox.tooltip = "Sync the camera and the simulation at a set frame rate"; // Hide UI checkbox hideUICheckBox = UIUtils.CreateCheckBox(this); hideUICheckBox.name = "CCX_HideUICheckBox"; hideUICheckBox.text = "Hide UI during playback"; hideUICheckBox.isChecked = true; hideUICheckBox.width = width - 16; hideUICheckBox.relativePosition = new Vector2(8, fovPanel.relativePosition.y + fovPanel.height + 8); // Start simulation checkbox startSimCheckBox = UIUtils.CreateCheckBox(this); startSimCheckBox.name = "CCX_StartSimCheckBox"; startSimCheckBox.text = "Unpause simulation"; startSimCheckBox.isChecked = false; startSimCheckBox.width = (width - 16) / 2; startSimCheckBox.relativePosition = new Vector2(8, hideUICheckBox.relativePosition.y + hideUICheckBox.height + 8); // FastList fastList = UIFastList.Create <UIKnotsListRow>(this); fastList.backgroundSprite = "UnlockingPanel"; fastList.width = width - 16; fastList.height = 46 * 5; fastList.canSelect = true; fastList.relativePosition = new Vector3(8, startSimCheckBox.relativePosition.y + startSimCheckBox.height + 8); fastList.rowHeight = 46f; fastList.rowsData = CameraDirector.cameraPath.knots; // Load/Save saveLoadButton = UIUtils.CreateButton(this); saveLoadButton.name = "CCX_SaveLoadButton"; saveLoadButton.text = "Save/Load"; saveLoadButton.size = new Vector2(100f, 30f); saveLoadButton.relativePosition = new Vector3(width - saveLoadButton.width - 8, fastList.relativePosition.y + fastList.height + 8); saveLoadButton.tooltip = "Work in progress"; height = saveLoadButton.relativePosition.y + saveLoadButton.height + 8; dragHandle.size = size; absolutePosition = new Vector3(savedWindowX.value, savedWindowY.value); MakePixelPerfect(); addKnotButton.eventClicked += (c, p) => { int i = CameraDirector.cameraPath.AddKnot(); fastList.DisplayAt(i); timelineSlider.minValue = 0f; float duration = CameraDirector.cameraPath.CalculateTotalDuraction(); if (duration <= 0f) { duration = 1f; } timelineSlider.maxValue = duration; }; playButton.eventClicked += (c, p) => { CameraDirector.cameraPath.Play(); }; timelineSlider.eventMouseDown += (c, p) => { CameraPath.currentTransfrom = new Knot(); }; timelineSlider.eventValueChanged += (c, p) => { CameraDirector.cameraPath.SetToTime(p); }; hideUICheckBox.eventCheckChanged += (c, p) => { CameraDirector.freeCamera = p; }; startSimCheckBox.eventCheckChanged += (c, p) => { CameraDirector.startSimulation = p; }; fovSlider.eventValueChanged += (c, p) => { CameraDirector.camera.fieldOfView = p / 2f; fovInput.text = p.ToString(); }; fovInput.eventTextSubmitted += (c, p) => { float value; if (float.TryParse(p, out value)) { CameraDirector.camera.fieldOfView = Mathf.Clamp(value, 20f, 179f) / 2f; if (fovSlider.value != value) { fovSlider.value = value; } } fovInput.text = (2f * CameraDirector.camera.fieldOfView).ToString(); }; fovInput.eventMouseWheel += (c, p) => { if (!p.used) { fovSlider.value += p.wheelDelta; p.Use(); } }; fpsCheckBox.eventCheckChanged += (c, p) => { CameraDirector.useFps = p; }; fpsInput.eventTextSubmitted += (c, p) => { float value; if (float.TryParse(p, out value)) { CameraDirector.fps = Mathf.Max(0, value); } fpsInput.text = CameraDirector.fps.ToString(); }; fpsInput.eventMouseWheel += (c, p) => { if (!p.used) { CameraDirector.fps = Mathf.Max(0, CameraDirector.fps + p.wheelDelta); fpsInput.text = CameraDirector.fps.ToString(); p.Use(); } }; saveLoadButton.eventClicked += (c, p) => { if (saveLoadWindow == null) { saveLoadWindow = (UISaveLoadWindow)GetUIView().AddUIComponent(typeof(UISaveLoadWindow)); } else { Destroy(saveLoadWindow); } }; DebugUtils.Log("UIMainWindow created"); }