public DropDownColorSelector(UIComponent parent, Color initialColor, int id = 0) { this.id = 0; m_parent = parent; m_uiPanel = m_parent.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; m_uiPanel.name = "DropDownColorSelector"; m_uiPanel.height = 40; m_uiPanel.width = 280; m_uiPanel.autoLayoutDirection = LayoutDirection.Horizontal; m_uiPanel.autoLayoutStart = LayoutStart.TopLeft; m_uiPanel.autoFitChildrenVertically = true; m_title = m_uiPanel.Find <UILabel>("Label"); m_title.autoSize = false; m_title.height = 28; m_title.width = 60; m_title.textAlignment = UIHorizontalAlignment.Center; m_title.padding = new RectOffset(5, 5, 5, 5); m_r = m_uiPanel.Find <UIDropDown>("Dropdown"); this.m_g = m_uiPanel.AttachUIComponent(GameObject.Instantiate(m_r.gameObject)) as UIDropDown; m_b = m_uiPanel.AttachUIComponent(GameObject.Instantiate(m_r.gameObject)) as UIDropDown; InitializeDropDown(ref m_b); InitializeDropDown(ref m_r); InitializeDropDown(ref m_g); m_r.color = new Color32(255, 0, 0, 255); m_g.color = new Color32(0, 255, 0, 255); m_b.color = new Color32(0, 0, 255, 255); m_displayColor = GameObject.Instantiate(m_uiPanel.Find <UILabel>("Label").gameObject, m_uiPanel.transform).GetComponent <UILabel>(); m_displayColor.autoSize = false; m_displayColor.name = "Color result"; m_displayColor.relativePosition += new Vector3(0, 160, 0); m_displayColor.text = ""; m_displayColor.height = 28; m_displayColor.width = 100; m_displayColor.textAlignment = UIHorizontalAlignment.Center; m_displayColor.backgroundSprite = "EmptySprite"; m_displayColor.useOutline = true; m_displayColor.outlineColor = Color.black; m_displayColor.textColor = Color.white; m_displayColor.padding = new RectOffset(5, 5, 5, 5); m_remove = m_uiPanel.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kButtonTemplate)) as UIButton; m_remove.text = "x"; m_remove.autoSize = false; m_remove.height = 27; m_remove.width = 27; m_remove.textPadding = new RectOffset(0, 0, 0, 0); m_remove.textHorizontalAlignment = UIHorizontalAlignment.Center; m_remove.eventClick += delegate(UIComponent c, UIMouseEventParameter sel) { Disable(); eventOnRemove?.Invoke(); }; SetSelectedColor(initialColor); }
private static void AddNewStopTemplate() { var go = new GameObject(); UIPanel panel = go.AddComponent <UIPanel>(); panel.size = new Vector2(36, 36); UIButton button = UITemplateManager.Get <UIButton>("StopButton"); panel.AttachUIComponent(button.gameObject); button.relativePosition = Vector2.zero; button.name = "StopButton"; UILabel uilabel = button.Find <UILabel>("PassengerCount"); panel.AttachUIComponent(uilabel.gameObject); uilabel.relativePosition = new Vector3(32, 12); uilabel.processMarkup = true; uilabel.isVisible = true; uilabel.minimumSize = new Vector2(180, 50); uilabel.verticalAlignment = UIVerticalAlignment.Middle; UIPanel connectionPanel = panel.AddUIComponent <UIPanel>(); connectionPanel.name = "ConnectionPanel"; connectionPanel.relativePosition = new Vector3(-50, 5); connectionPanel.size = new Vector3(50, 40); connectionPanel.autoLayout = true; connectionPanel.wrapLayout = true; connectionPanel.autoLayoutDirection = LayoutDirection.Vertical; connectionPanel.autoLayoutStart = LayoutStart.TopRight; UILabel distLabel = panel.AddUIComponent <UILabel>(); distLabel.name = "Distance"; distLabel.relativePosition = new Vector3(-12, 37); distLabel.textAlignment = UIHorizontalAlignment.Center; distLabel.textScale = 0.65f; distLabel.suffix = "m"; distLabel.useOutline = true; distLabel.minimumSize = new Vector2(60, 0); distLabel.outlineColor = Color.black; KlyteMonoUtils.CreateUIElement(out UITextField lineNameField, panel.transform, "StopNameField", new Vector4(uilabel.relativePosition.x, uilabel.relativePosition.y, 180, 50)); lineNameField.maxLength = 256; lineNameField.isVisible = false; lineNameField.verticalAlignment = UIVerticalAlignment.Middle; lineNameField.horizontalAlignment = UIHorizontalAlignment.Left; lineNameField.selectionSprite = "EmptySprite"; lineNameField.builtinKeyNavigation = true; lineNameField.textScale = uilabel.textScale; lineNameField.padding.top = 14; lineNameField.padding.bottom = 24; KlyteMonoUtils.InitButtonFull(lineNameField, false, "TextFieldPanel"); TLMUiTemplateUtils.GetTemplateDict()["StopButtonPanel"] = panel; }
private void Awake() { parent = GetComponentInParent <UIComponent>(); var group15 = new UIHelperExtension(parent.GetComponentInChildren <UIScrollablePanel>()); ((UIScrollablePanel)group15.Self).autoLayoutDirection = LayoutDirection.Horizontal; ((UIScrollablePanel)group15.Self).wrapLayout = true; ((UIScrollablePanel)group15.Self).width = 730; group15.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_AREAS")); group15.AddSpace(1); group15.AddLabel(Locale.Get("K45_TLM_AUTO_NAME_SETTINGS_PUBLIC_TRANSPORT_DESC")); group15.AddSpace(15); foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.extraAutoNameCategories) { UICheckBox checkbox = TLMConfigOptions.instance.generateCheckboxConfig(group15, TLMConfigWarehouse.GetNameForServiceType(ci), TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | ci, 200); UIPanel textFieldPanel = TLMConfigOptions.instance.generateTextFieldConfig(group15, Locale.Get("K45_TLM_PREFIX_OPTIONAL"), TLMConfigWarehouse.ConfigIndex.AUTO_NAMING_REF_TEXT | ci).GetComponentInParent <UIPanel>(); textFieldPanel.autoLayoutDirection = LayoutDirection.Horizontal; textFieldPanel.autoFitChildrenVertically = true; UILabel title = textFieldPanel.GetComponentInChildren <UILabel>(); title.textAlignment = UIHorizontalAlignment.Center; KlyteMonoUtils.LimitWidthAndBox(title, 220, true); textFieldPanel.AttachUIComponent(checkbox.gameObject); checkbox.eventVisibilityChanged += (x, y) => { if (x) { checkbox.zOrder = 0; } }; group15.AddSpace(2); } }
private void HookGUI() { //m_distictName = UIView.Find<UITextField>("DistrictName"); Debug.Print("Hooking"); m_panel = (UIPanel)UIView.Find <UITextField>("DistrictName").parent.parent; if (m_panel == null) { throw new DistrictRCIException("DistrictRCI couldn't hook GUI"); } //m_panel = UIView.Find<UIPanel>("(Library) ZonedBuildingWorldInfoPanel"); Debug.Print(m_panel.cachedName); m_demandSprite = (UISlicedSprite)GameObject.Instantiate(UIView.Find <UISlicedSprite>("DemandBack")); m_demandSprite.name = "DistrictRCIDemand"; m_demandSprite.cachedName = "DistrictRCIDemand"; m_demandSprite.Show(); m_panel.AttachUIComponent(m_demandSprite.gameObject); m_demandSprite.relativePosition = new Vector3(m_panel.width - m_demandSprite.width - 10f, m_panel.height - m_demandSprite.height - 24f); m_panel.eventVisibilityChanged += (component, value) => { Update(); }; //m_panel.eventAnchorChanged += (component, value) => {Update();}; //m_panel.eventPositionChanged += (component, value) => {Update();}; //m_panel.eventMouseMove += (component, value) => {Update();}; UIView.Find <UITextField>("DistrictName").eventTextChanged += (component, value) => { Update(); }; }
public TextList(UIComponent parent, Dictionary <T, string> initiaItemList, int width, int height, string name) { this.name = name; m_parent = parent; ((UIPanel)parent).autoFitChildrenVertically = true; ((UIPanel)parent).padding = new RectOffset(20, 20, 20, 20); UIPanel panelListing = m_parent.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; panelListing.name = "TextList"; panelListing.height = height; panelListing.width = width; panelListing.autoLayoutDirection = LayoutDirection.Vertical; panelListing.autoLayoutStart = LayoutStart.TopLeft; panelListing.autoFitChildrenVertically = true; panelListing.wrapLayout = true; panelListing.padding = new RectOffset(0, 0, 0, 0); panelListing.clipChildren = true; panelListing.pivot = UIPivotPoint.MiddleCenter; panelListing.relativePosition = Vector2.zero; foreach (Transform t in panelListing.transform) { GameObject.Destroy(t.gameObject); } GameObject scrollObj = new GameObject("Lines Listing Scroll", new Type[] { typeof(UIScrollablePanel) }); // DebugOutputPanel.AddMessage (PluginManager.MessageType.Message, "SCROLL LOADED"); linesListPanel = scrollObj.GetComponent <UIScrollablePanel>(); linesListPanel.autoLayout = false; linesListPanel.width = width; linesListPanel.height = height; linesListPanel.useTouchMouseScroll = true; linesListPanel.scrollWheelAmount = 20; linesListPanel.eventMouseWheel += (UIComponent component, UIMouseEventParameter eventParam) => { linesListPanel.scrollPosition -= new Vector2(0, eventParam.wheelDelta * linesListPanel.scrollWheelAmount); }; panelListing.AttachUIComponent(linesListPanel.gameObject); linesListPanel.autoLayout = true; linesListPanel.autoLayoutDirection = LayoutDirection.Vertical; linesListPanel.useTouchMouseScroll = true; linesListPanel.scrollWheelAmount = 20; linesListPanel.eventMouseWheel += (UIComponent component, UIMouseEventParameter eventParam) => { linesListPanel.scrollPosition -= new Vector2(0, eventParam.wheelDelta * linesListPanel.scrollWheelAmount); eventParam.Use(); }; foreach (Transform t in linesListPanel.transform) { GameObject.Destroy(t.gameObject); } itemsList = initiaItemList; }
public TextList(UIComponent parent, Dictionary <T, string> initiaItemList, int width, int height, string name) { this.name = name; this.m_parent = parent; ((UIPanel)parent).autoFitChildrenVertically = true; ((UIPanel)parent).padding = new RectOffset(20, 20, 20, 20); UIPanel uIPanel = this.m_parent.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate)) as UIPanel; uIPanel.name = "TextList"; uIPanel.height = (float)height; uIPanel.width = (float)width; uIPanel.autoLayoutDirection = LayoutDirection.Vertical; uIPanel.autoLayoutStart = LayoutStart.TopLeft; uIPanel.autoFitChildrenVertically = true; uIPanel.wrapLayout = true; uIPanel.padding = new RectOffset(0, 0, 0, 0); uIPanel.clipChildren = true; uIPanel.pivot = UIPivotPoint.MiddleCenter; uIPanel.relativePosition = Vector2.zero; foreach (Transform transform in uIPanel.transform) { UnityEngine.Object.Destroy(transform.gameObject); } GameObject gameObject = new GameObject("Lines Listing Scroll", new Type[] { typeof(UIScrollablePanel) }); this.linesListPanel = gameObject.GetComponent <UIScrollablePanel>(); this.linesListPanel.autoLayout = false; this.linesListPanel.width = (float)width; this.linesListPanel.height = (float)height; this.linesListPanel.useTouchMouseScroll = true; this.linesListPanel.scrollWheelAmount = 20; this.linesListPanel.eventMouseWheel += delegate(UIComponent component, UIMouseEventParameter eventParam) { this.linesListPanel.scrollPosition -= new Vector2(0f, eventParam.wheelDelta * (float)this.linesListPanel.scrollWheelAmount); }; uIPanel.AttachUIComponent(this.linesListPanel.gameObject); this.linesListPanel.autoLayout = true; this.linesListPanel.autoLayoutDirection = LayoutDirection.Vertical; this.linesListPanel.useTouchMouseScroll = true; this.linesListPanel.scrollWheelAmount = 20; this.linesListPanel.eventMouseWheel += delegate(UIComponent component, UIMouseEventParameter eventParam) { this.linesListPanel.scrollPosition -= new Vector2(0f, eventParam.wheelDelta * (float)this.linesListPanel.scrollWheelAmount); eventParam.Use(); }; foreach (Transform transform2 in this.linesListPanel.transform) { UnityEngine.Object.Destroy(transform2.gameObject); } this.itemsList = initiaItemList; }
public void Update() { try { if (m_tries < 5) { UIPanel frtPanel = UIView.GetAView().FindUIComponent <UIPanel>("FRT_ToolOptionsPanel"); if (frtPanel != null) { DebugUtils.Log("Fine Road Tool window found"); frtPanel.height += m_panel.height + 8; frtPanel.AttachUIComponent(m_panel.gameObject); m_panel.relativePosition = new Vector3(8, frtPanel.height - m_panel.height - 8); m_panel.width = frtPanel.width - 16; frtPanel.GetComponentInChildren <UIDragHandle>().height = frtPanel.height; m_tries = 5; } m_tries++; } else if (m_tries == 5) { DebugUtils.Log("Fine Road Tool window not found"); UIMainWindow window = UIView.GetAView().AddUIComponent(typeof(UIMainWindow)) as UIMainWindow; window.AttachUIComponent(m_panel.gameObject); window.size = new Vector2(228, 180); m_panel.relativePosition = new Vector3(8, 28); m_panel.width = window.width - 16; window.height = 36 + m_panel.height; m_tries++; } } catch (Exception e) { m_tries = 6; DebugUtils.Log("Update failed"); DebugUtils.LogException(e); } }
private UICheckBox AddCheckboxLocale(string text, bool defaultValue, IdAndWeight idAndWeight, Action <UICheckBox, bool> eventCallback = null) { var uICheckBox = m_parent.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kCheckBoxTemplate)) as UICheckBox; uICheckBox.isChecked = defaultValue; uICheckBox.label.text = text; if (eventCallback != null) { uICheckBox.eventCheckChanged += delegate(UIComponent c, bool isChecked) { eventCallback(c as UICheckBox, isChecked); }; } uICheckBox.objectUserData = idAndWeight; return(uICheckBox); }
/// <summary> /// Switch the clicked budget icon to the selected or unselected box. /// </summary> /// <param name="component">The clicked budget icon.</param> /// <param name="eventParam">Unused</param> private void toggleSprite(UIComponent component, UIMouseEventParameter eventParam) { if (_containerUnselected.Find <UISprite>(component.name) != null) { _containerSelected.AttachUIComponent(component.gameObject); _containerUnselected.RemoveUIComponent(component); _spriteArrow.spriteName = "ArrowRightFocused"; _spriteArrow.relativePosition = new Vector3(163, 100); } else if (_containerSelected.Find <UISprite>(component.name) != null) { _containerUnselected.AttachUIComponent(component.gameObject); _containerSelected.RemoveUIComponent(component); _spriteArrow.spriteName = "ArrowLeftFocused"; _spriteArrow.relativePosition = new Vector3(175, 100); } }
public static void AddScale(UIPanel displaySettings) { if (displaySettings.Find <UIPanel>("RefreshRate") is UIPanel refreshRate) { refreshRate.relativePosition = new Vector2(260f, 107f); } if (displaySettings.Find <UIPanel>("Fullscreen") is UIPanel fullscreen) { fullscreen.relativePosition = new Vector2(14f, 107f); } if (displaySettings.Find <UIButton>("Apply") is UIButton apply) { apply.textPadding = new RectOffset(8, 8, 8, 8); } var uiScale = displaySettings.AttachUIComponent(UITemplateManager.GetAsGameObject("OptionsSliderTemplate")) as UIPanel; uiScale.height = 72f; uiScale.name = "UIScale"; uiScale.relativePosition = new Vector2(503f, 35f); UIScaleSlider = uiScale.Find <UISlider>("Slider"); UIScaleSlider.name = nameof(UIScaleSlider); UIScaleSlider.relativePosition = new Vector2(0f, 34f); UIScaleSlider.minValue = 0.5f; UIScaleSlider.maxValue = 2f; UIScaleSlider.stepSize = 0.1f; UIScaleLabel = uiScale.Find <UILabel>("Label"); UIScaleLabel.name = nameof(UIScaleLabel); UIScaleLabel.relativePosition = new Vector2(0f, 2f); UIScaleSlider.eventValueChanged += ScaleChanged; UIScaleSlider.value = SelectedUIScale; }
private void createInfoView() { //line info painel TLMUtils.createUIElement <UIPanel>(ref lineInfoPanel, m_controller.mainRef.transform); lineInfoPanel.Hide(); lineInfoPanel.relativePosition = new Vector3(394.0f, 0.0f); lineInfoPanel.width = 650; lineInfoPanel.height = 290; lineInfoPanel.zOrder = 50; lineInfoPanel.color = new Color32(255, 255, 255, 255); lineInfoPanel.backgroundSprite = "MenuPanel2"; lineInfoPanel.name = "LineInfoPanel"; lineInfoPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); lineInfoPanel.autoLayout = false; lineInfoPanel.useCenter = true; lineInfoPanel.wrapLayout = false; lineInfoPanel.canFocus = true; TLMUtils.createDragHandle(lineInfoPanel, lineInfoPanel, 35f); lineInfoPanel.eventVisibilityChanged += (component, value) => { if (m_linearMap != null) { m_linearMap.isVisible = value; } }; TLMUtils.createUIElement <UILabel>(ref lineTransportIconTypeLabel, lineInfoPanel.transform); lineTransportIconTypeLabel.autoSize = false; lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.width = 30; lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.name = "LineTransportIcon"; lineTransportIconTypeLabel.clipChildren = true; TLMUtils.createDragHandle(lineTransportIconTypeLabel, lineInfoPanel); GameObject lpddgo = GameObject.Instantiate(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate).GetComponent <UIPanel>().Find <UIDropDown>("Dropdown").gameObject); linePrefixDropDown = lpddgo.GetComponent <UIDropDown>(); lineInfoPanel.AttachUIComponent(linePrefixDropDown.gameObject); linePrefixDropDown.isLocalized = false; linePrefixDropDown.autoSize = false; linePrefixDropDown.horizontalAlignment = UIHorizontalAlignment.Center; linePrefixDropDown.text = ""; linePrefixDropDown.width = 40; linePrefixDropDown.height = 35; linePrefixDropDown.name = "LinePrefixDropDown"; linePrefixDropDown.textScale = 1.6f; linePrefixDropDown.itemHeight = 35; linePrefixDropDown.itemPadding = new RectOffset(2, 2, 2, 2); linePrefixDropDown.textFieldPadding = new RectOffset(2, 2, 2, 2); linePrefixDropDown.eventSelectedIndexChanged += saveLineNumber; linePrefixDropDown.relativePosition = new Vector3(70f, 3f); TLMUtils.createUIElement <UITextField>(ref lineNumberLabel, lineInfoPanel.transform); lineNumberLabel.autoSize = false; lineNumberLabel.relativePosition = new Vector3(80f, 3f); lineNumberLabel.horizontalAlignment = UIHorizontalAlignment.Center; lineNumberLabel.text = ""; lineNumberLabel.width = 75; lineNumberLabel.height = 35; lineNumberLabel.name = "LineNumberLabel"; lineNumberLabel.normalBgSprite = "EmptySprite"; lineNumberLabel.textScale = 1.6f; lineNumberLabel.padding = new RectOffset(5, 5, 5, 5); lineNumberLabel.color = new Color(0, 0, 0, 1); TLMUtils.uiTextFieldDefaults(lineNumberLabel); lineNumberLabel.numericalOnly = true; lineNumberLabel.maxLength = 4; lineNumberLabel.eventLostFocus += saveLineNumber; lineNumberLabel.zOrder = 10; TLMUtils.createUIElement <UITextField>(ref lineNameField, lineInfoPanel.transform); lineNameField.autoSize = false; lineNameField.relativePosition = new Vector3(190f, 10f); lineNameField.horizontalAlignment = UIHorizontalAlignment.Center; lineNameField.text = "NOME"; lineNameField.width = 450; lineNameField.height = 25; lineNameField.name = "LineNameLabel"; lineNameField.maxLength = 256; lineNameField.textScale = 1.5f; TLMUtils.uiTextFieldDefaults(lineNameField); lineNameField.eventGotFocus += (component, eventParam) => { lastLineName = lineNameField.text; }; lineNameField.eventLostFocus += (component, eventParam) => { if (lastLineName != lineNameField.text) { saveLineName(lineNameField); } lineNameField.text = m_controller.tm.GetLineName(m_lineIdSelecionado.TransportLine); }; TLMUtils.createUIElement <UILabel>(ref lineLenghtLabel, lineInfoPanel.transform); lineLenghtLabel.autoSize = false; lineLenghtLabel.relativePosition = new Vector3(10f, 60f); lineLenghtLabel.textAlignment = UIHorizontalAlignment.Left; lineLenghtLabel.text = ""; lineLenghtLabel.width = 550; lineLenghtLabel.height = 25; lineLenghtLabel.prefix = ""; lineLenghtLabel.suffix = ""; lineLenghtLabel.name = "LineLenghtLabel"; lineLenghtLabel.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref detailedStatsLabel, lineInfoPanel.transform); detailedStatsLabel.autoSize = false; detailedStatsLabel.relativePosition = new Vector3(10f, 75f); detailedStatsLabel.textAlignment = UIHorizontalAlignment.Left; detailedStatsLabel.width = 550; detailedStatsLabel.height = 25; detailedStatsLabel.name = "ExtraInfoLabel"; detailedStatsLabel.textScale = 0.8f; detailedStatsLabel.prefix = Locale.Get("TLM_LINE_EFFECTIVE_BUDGET") + ": "; TLMUtils.createUIElement <UILabel>(ref veiculosLinhaLabel, lineInfoPanel.transform); veiculosLinhaLabel.autoSize = false; veiculosLinhaLabel.relativePosition = new Vector3(10f, 90); veiculosLinhaLabel.textAlignment = UIHorizontalAlignment.Left; veiculosLinhaLabel.text = ""; veiculosLinhaLabel.width = 550; veiculosLinhaLabel.height = 25; veiculosLinhaLabel.name = "VehiclesLineLabel"; veiculosLinhaLabel.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref viagensEvitadasLabel, lineInfoPanel.transform); viagensEvitadasLabel.autoSize = false; viagensEvitadasLabel.relativePosition = new Vector3(10f, 105); viagensEvitadasLabel.textAlignment = UIHorizontalAlignment.Left; viagensEvitadasLabel.text = ""; viagensEvitadasLabel.width = 250; viagensEvitadasLabel.height = 25; viagensEvitadasLabel.name = "AvoidedTravelsLabel"; viagensEvitadasLabel.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref passageirosEturistasLabel, lineInfoPanel.transform); passageirosEturistasLabel.autoSize = false; passageirosEturistasLabel.relativePosition = new Vector3(10f, 120f); passageirosEturistasLabel.textAlignment = UIHorizontalAlignment.Left; passageirosEturistasLabel.text = ""; passageirosEturistasLabel.width = 350; passageirosEturistasLabel.height = 25; passageirosEturistasLabel.name = "TouristAndPassagersLabel"; passageirosEturistasLabel.textScale = 0.8f; //TLMUtils.createUIElement<UILabel>(ref generalDebugLabel, lineInfoPanel.transform); //generalDebugLabel.autoSize = false; //generalDebugLabel.relativePosition = new Vector3(10f, 185f); //generalDebugLabel.textAlignment = UIHorizontalAlignment.Left; //generalDebugLabel.prefix = "DEBUG: DATA AVAIL = "; //generalDebugLabel.width = 350; //generalDebugLabel.height = 100; //generalDebugLabel.name = "CustosLabel"; //generalDebugLabel.textScale = 0.8f; //generalDebugLabel.wordWrap = true; //generalDebugLabel.clipChildren = false; //generalDebugLabel.enabled = false && TransportLinesManagerMod.debugMode.value; TLMUtils.createUIElement <UILabel>(ref vehicleQuantitySetLabel, lineInfoPanel.transform); vehicleQuantitySetLabel.autoSize = false; vehicleQuantitySetLabel.relativePosition = new Vector3(10f, 135f); vehicleQuantitySetLabel.textAlignment = UIHorizontalAlignment.Left; vehicleQuantitySetLabel.localeID = "TLM_SET_FIXED_VEHICLE_NUMBER_LINE"; vehicleQuantitySetLabel.isLocalized = true; vehicleQuantitySetLabel.width = 300; vehicleQuantitySetLabel.height = 40; vehicleQuantitySetLabel.name = "FixedVehiclesLabel"; vehicleQuantitySetLabel.textScale = 0.8f; vehicleQuantitySetLabel.clipChildren = false; vehicleQuantitySetLabel.zOrder = 0; vehicleQuantitySet = UITextField.Instantiate(lineNumberLabel); vehicleQuantitySet.transform.SetParent(lineInfoPanel.transform); vehicleQuantitySet.relativePosition = new Vector3(120f, 165f); vehicleQuantitySet.size = new Vector2(50, 30); vehicleQuantitySet.padding = new RectOffset(0, 0, 0, 0); vehicleQuantitySet.textScale = 0.8f; vehicleQuantitySet.numericalOnly = true; vehicleQuantitySet.eventLostFocus += (x, y) => { TLMVehiclesLineManager.instance[this.lineIdSelecionado.TransportLine] = int.Parse(vehicleQuantitySet.text); }; TLMUtils.createUIElement <UILabel>(ref m_autoNameLabel, lineInfoPanel.transform); m_autoNameLabel.autoSize = false; m_autoNameLabel.relativePosition = new Vector3(10f, 180f); m_autoNameLabel.textAlignment = UIHorizontalAlignment.Left; m_autoNameLabel.prefix = Locale.Get("TLM_GENERATED_AUTO_NAME") + ": "; m_autoNameLabel.width = 350; m_autoNameLabel.height = 100; m_autoNameLabel.name = "AutoNameLabel"; m_autoNameLabel.textScale = 0.8f; m_autoNameLabel.wordWrap = true; m_autoNameLabel.clipChildren = false; lineColorPicker = GameObject.Instantiate(PublicTransportWorldInfoPanel.FindObjectOfType <UIColorField>().gameObject).GetComponent <UIColorField>(); // lineInfoPanel.AttachUIComponent(lineColorPicker.gameObject); lineColorPicker.name = "LineColorPicker"; lineColorPicker.relativePosition = new Vector3(50f, 10f); lineColorPicker.enabled = true; lineColorPicker.anchor = UIAnchorStyle.Top & UIAnchorStyle.Left; lineColorPicker.eventSelectedColorChanged += (UIComponent component, Color value) => { TLMUtils.setLineColor(m_lineIdSelecionado.TransportLine, value); updateLineUI(value); }; lineTime = UIHelperExtension.CloneBasicDropDown(Locale.Get("TRANSPORT_LINE_ACTIVITY"), new string[] { Locale.Get("TRANSPORT_LINE_DAYNNIGHT"), Locale.Get("TRANSPORT_LINE_DAY"), Locale.Get("TRANSPORT_LINE_NIGHT"), Locale.Get("TLM_TRANSPORT_LINE_DISABLED") }, changeLineTime, lineInfoPanel, out lineTimeTitle); lineTime.parent.relativePosition = new Vector3(120f, 220f); UIButton deleteLine = null; TLMUtils.createUIElement <UIButton>(ref deleteLine, lineInfoPanel.transform); deleteLine.relativePosition = new Vector3(10f, lineInfoPanel.height - 40f); deleteLine.localeID = "LINE_DELETE"; deleteLine.isLocalized = true; deleteLine.autoSize = true; deleteLine.textPadding = new RectOffset(3, 3, 3, 3); TLMUtils.initButton(deleteLine, true, "ButtonMenu"); deleteLine.name = "DeleteLineButton"; deleteLine.color = new Color(1, 0, 0, 1); deleteLine.eventClick += (UIComponent component, UIMouseEventParameter eventParam) => { Singleton <SimulationManager> .instance.AddAction(delegate { Singleton <TransportManager> .instance.ReleaseLine(m_lineIdSelecionado.TransportLine); }); closeLineInfo(component, eventParam); }; UIButton voltarButton2 = null; TLMUtils.createUIElement <UIButton>(ref voltarButton2, lineInfoPanel.transform); voltarButton2.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 40f); voltarButton2.localeID = "CLOSE"; voltarButton2.isLocalized = true; voltarButton2.width = 240; voltarButton2.height = 30; TLMUtils.initButton(voltarButton2, true, "ButtonMenu"); voltarButton2.name = "LineInfoCloseButton"; voltarButton2.eventClick += closeLineInfo; UIButton autoName = null; TLMUtils.createUIElement <UIButton>(ref autoName, lineInfoPanel.transform); autoName.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 80f); autoName.localeID = "TLM_USE_AUTO_NAME"; autoName.isLocalized = true; autoName.width = 240; autoName.height = 30; TLMUtils.initButton(autoName, true, "ButtonMenu"); autoName.name = "AutoNameButton"; autoName.eventClick += (component, eventParam) => { lineNameField.text = m_linearMap.autoName; saveLineName(lineNameField); }; UIButton autoColor = null; TLMUtils.createUIElement <UIButton>(ref autoColor, lineInfoPanel.transform); autoColor.relativePosition = new Vector3(lineInfoPanel.width - 250f, lineInfoPanel.height - 120f); autoColor.localeID = "TLM_PICK_COLOR_FROM_PALETTE"; autoColor.isLocalized = true; autoColor.tooltipLocaleID = "TLM_PICK_COLOR_FROM_PALETTE_TOOLTIP"; autoColor.width = 240; autoColor.height = 30; TLMUtils.initButton(autoColor, true, "ButtonMenu"); autoColor.name = "AutoNameButton"; autoColor.eventMouseUp += (component, eventParam) => { lineColorPicker.selectedColor = m_controller.AutoColor(m_lineIdSelecionado.TransportLine); updateLineUI(lineColorPicker.selectedColor); }; agesPanel = new TLMAgesChartPanel(this); m_linearMap = new TLMLinearMap(this); }
private bool CreateButton(UIComponent districtOptionPanel) { String[] iconNames = { "RoadArrowIcon", "Base", "BaseFocused", "BaseHovered", "BasePressed", "BaseDisabled", }; // Create Hierarchy view = UIView.GetAView(); panel = (UIPanel)view.AddUIComponent(typeof(UIPanel)); newGO = new GameObject(BUTTON_NAME); button = newGO.AddComponent <UIMultiStateButton>(); panel.AttachUIComponent(newGO); // Panel attributes panel.relativePosition = panelPos; panel.width = panelWidth; panel.name = PANEL_NAME; panel.isVisible = false; // Button attributes button.relativePosition = buttonPos; button.size = buttonSize; button.playAudioEvents = true; button.name = BUTTON_NAME; button.tooltip = "Display Zones"; button.isTooltipLocalized = false; button.spritePadding = new RectOffset(); button.activeStateIndex = 1; button.atlas = CreateTextureAtlas("icons.png", BUTTON_NAME + "Atlas", panel.atlas.material, 36, 36, iconNames); UIMultiStateButton.SpriteSet backgroundSpriteSet0 = button.backgroundSprites[0]; backgroundSpriteSet0.normal = "Base"; backgroundSpriteSet0.disabled = "Base"; backgroundSpriteSet0.hovered = "BaseHovered"; backgroundSpriteSet0.pressed = "Base"; backgroundSpriteSet0.focused = "Base"; button.backgroundSprites.AddState(); UIMultiStateButton.SpriteSet backgroundSpriteSet1 = button.backgroundSprites[1]; backgroundSpriteSet1.normal = "BaseFocused"; backgroundSpriteSet1.disabled = "BaseFocused"; backgroundSpriteSet1.hovered = "BaseFocused"; backgroundSpriteSet1.pressed = "BaseFocused"; backgroundSpriteSet1.focused = "BaseFocused"; UIMultiStateButton.SpriteSet foregroundSpriteSet0 = button.foregroundSprites[0]; foregroundSpriteSet0.normal = "RoadArrowIcon"; foregroundSpriteSet0.disabled = "RoadArrowIcon"; foregroundSpriteSet0.hovered = "RoadArrowIcon"; foregroundSpriteSet0.pressed = "RoadArrowIcon"; foregroundSpriteSet0.focused = "RoadArrowIcon"; button.foregroundSprites.AddState(); UIMultiStateButton.SpriteSet foregroundSpriteSet1 = button.foregroundSprites[1]; foregroundSpriteSet1.normal = "RoadArrowIcon"; foregroundSpriteSet1.disabled = "RoadArrowIcon"; foregroundSpriteSet1.hovered = "RoadArrowIcon"; foregroundSpriteSet1.pressed = "RoadArrowIcon"; foregroundSpriteSet1.focused = "RoadArrowIcon"; // Districts Panel Listener districtOptionPanel.eventVisibilityChanged += districtOptionPanel_eventVisibilityChanged; // Button Listener button.eventActiveStateIndexChanged += button_eventActiveStateIndexChanged; return(true); }
protected void CreateSoundSlider(UIHelperBase helper, ISound sound) { // Initialize variables var configuration = Mod.Instance.Settings.GetSoundsByCategoryId <string>(sound.CategoryId); var customAudioFiles = SoundPacksManager.instance.AudioFiles.Where(kvp => kvp.Key.StartsWith(string.Format("{0}.{1}", sound.CategoryId, sound.Id))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); float volume = 0; if (configuration.ContainsKey(sound.Id)) { volume = configuration[sound.Id].Volume; } else { Mod.Instance.Log.Info("No volume configuration found for {0}.{1}, using default value", sound.CategoryId, sound.Id); volume = sound.DefaultVolume; } // Add UI components UISlider uiSlider = null; UIPanel uiPanel = null; UILabel uiLabel = null; UIDropDown uiDropDown = null; var maxVolume = sound.MaxVolume; if (customAudioFiles.Count > 0 && configuration.ContainsKey(sound.Id) && !string.IsNullOrEmpty(configuration[sound.Id].SoundPack)) { // Custom sound, determine custom max volume var audioFile = SoundPacksManager.instance.GetAudioFileByName(sound.CategoryId, sound.Id, configuration[sound.Id].SoundPack); maxVolume = Mathf.Max(audioFile.AudioInfo.MaxVolume, audioFile.AudioInfo.Volume); } uiSlider = (UISlider)helper.AddSlider(sound.Name, 0, maxVolume, 0.01f, volume, v => this.SoundVolumeChanged(sound, v)); uiPanel = (UIPanel)uiSlider.parent; uiLabel = uiPanel.Find <UILabel>("Label"); if (customAudioFiles.Count > 0) { uiDropDown = uiPanel.AttachUIComponent(GameObject.Instantiate((UITemplateManager.Peek(UITemplateDefs.ID_OPTIONS_DROPDOWN_TEMPLATE) as UIPanel).Find <UIDropDown>("Dropdown").gameObject)) as UIDropDown; uiDropDown.items = new[] { "Default" }.Union(customAudioFiles.Select(kvp => kvp.Value.Name)).ToArray(); uiDropDown.height = 28; uiDropDown.textFieldPadding.top = 4; if (configuration.ContainsKey(sound.Id) && !string.IsNullOrEmpty(configuration[sound.Id].SoundPack)) { uiDropDown.selectedValue = configuration[sound.Id].SoundPack; } else { uiDropDown.selectedIndex = 0; } uiDropDown.eventSelectedIndexChanged += (c, i) => this.SoundPackChanged(sound, i > 0 ? ((UIDropDown)c).items[i] : null, uiSlider); this.soundSelections[string.Format("{0}.{1}", sound.CategoryId, sound.Id)] = uiDropDown; } // Configure UI components uiPanel.autoLayout = false; uiLabel.anchor = UIAnchorStyle.Left | UIAnchorStyle.CenterVertical; uiLabel.width = 250; uiSlider.anchor = UIAnchorStyle.CenterVertical; uiSlider.builtinKeyNavigation = false; uiSlider.width = 207; uiSlider.relativePosition = new Vector3(uiLabel.relativePosition.x + uiLabel.width + 20, 0); if (customAudioFiles.Count > 0) { uiDropDown.anchor = UIAnchorStyle.CenterVertical; uiDropDown.width = 180; uiDropDown.relativePosition = new Vector3(uiSlider.relativePosition.x + uiSlider.width + 20, 0); uiPanel.size = new Vector2(uiDropDown.relativePosition.x + uiDropDown.width, 32); } else { uiPanel.size = new Vector2(uiSlider.relativePosition.x + uiSlider.width, 32); } }
public override void Start() { base.Start(); _checkBox = AddUIComponent<UICustomCheckbox>(); _colorFieldPanel = AddUIComponent<UIPanel>(); _colorFieldPanel.size = new Vector2(17, 17); _colorFieldPanel.relativePosition = new Vector3(22, 0); _color = Instantiate(FindObjectOfType<UIColorField>().gameObject).GetComponent<UIColorField>(); _colorFieldPanel.AttachUIComponent(_color.gameObject); _color.name = "ColorPickerLine" + LineID; _color.size = new Vector2(17, 17); _color.relativePosition = new Vector3(0, 0); _color.pickerPosition = UIColorField.ColorPickerPosition.RightAbove; _color.eventSelectedColorChanged += (component, value) => TransportUtil.SetLineColor(LineID, value); _name = AddUIComponent<UILabel>(); _stops = AddUIComponent<UILabel>(); _passengers = AddUIComponent<UILabel>(); _trips = AddUIComponent<UILabel>(); _vehicles = AddUIComponent<UILabel>(); _deleteButton = AddUIComponent<UIButton>(); _deleteButton.size = new Vector2(17, 17); _deleteButton.tooltip = "Delete line"; _deleteButton.normalFgSprite = "buttonclose"; _deleteButton.pressedFgSprite = "buttonclosepressed"; _deleteButton.hoveredFgSprite = "buttonclosehover"; _deleteButton.isVisible = true; _checkBox.relativePosition = new Vector3(5, 0); _name.relativePosition = new Vector3(43, 0); _stops.relativePosition = new Vector3(170, 0); _passengers.relativePosition = new Vector3(225, 0); _trips.relativePosition = new Vector3(320, 0); _vehicles.relativePosition = new Vector3(401, 0); _deleteButton.relativePosition = new Vector3(435, 0); _name.textColor = new Color32(185, 221, 254, 255); _stops.textColor = new Color32(185, 221, 254, 255); _passengers.textColor = new Color32(185, 221, 254, 255); _trips.textColor = new Color32(185, 221, 254, 255); _vehicles.textColor = new Color32(185, 221, 254, 255); _checkBox.size = new Vector2(12, 12); // event handler _checkBox.eventClick += (component, param) => { _checkBox.IsChecked = !_checkBox.IsChecked; if (!_checkBox.IsChecked) TransportUtil.HideTransportLine(LineID); else TransportUtil.ShowTransportLine(LineID); }; _name.eventClick += (component, param) => WorldInfoPanel.Show<PublicTransportWorldInfoPanel>(TransportUtil.GetFirstLineStop(LineID), InstanceID); _name.eventMouseHover += (component, param) => { TransportUtil.SelectTransportLine(LineID); _name.textColor = TransportUtil.GetLineColor(LineID); }; _name.eventMouseLeave += (component, param) => { TransportUtil.DeselectTransportLine(LineID); _name.textColor = new Color32(185, 221, 254, 255); }; _deleteButton.eventClick += (component, param) => Singleton<TransportManager>.instance.ReleaseLine(LineID); // scale label texts _name.textScale = 0.8f; _stops.textScale = 0.8f; _passengers.textScale = 0.8f; _trips.textScale = 0.8f; _vehicles.textScale = 0.8f; _deleteButton.textScale = 0.8f; // zebra stripes background backgroundSprite = "GenericPanelLight"; if (IsOdd) color = new Color32(150, 150, 150, 255); else color = new Color32(130, 130, 130, 255); // center elements in row UIComponent[] children = GetComponentsInChildren<UIComponent>(); foreach (UIComponent child in children) { if (child == this) continue; child.pivot = UIPivotPoint.MiddleLeft; child.transformPosition = new Vector3(child.transformPosition.x, GetBounds().center.y, 0); } }
private void HookGUI() { //m_distictName = UIView.Find<UITextField>("DistrictName"); Debug.Print("Hooking"); m_panel = (UIPanel)UIView.Find<UITextField>("DistrictName").parent.parent; //m_panel = UIView.Find<UIPanel>("(Library) ZonedBuildingWorldInfoPanel"); Debug.Print (m_panel.cachedName); m_demandSprite = (UISlicedSprite)GameObject.Instantiate(UIView.Find<UISlicedSprite> ("DemandBack")); m_demandSprite.name = "DistrictRCIDemand"; m_demandSprite.cachedName = "DistrictRCIDemand"; m_demandSprite.Show(); m_panel.AttachUIComponent(m_demandSprite.gameObject); m_demandSprite.relativePosition = new Vector3(m_panel.width - m_demandSprite.width - 10f,m_panel.height - m_demandSprite.height - 24f); m_panel.eventVisibilityChanged += (component, value) => {Update();}; //m_panel.eventAnchorChanged += (component, value) => {Update();}; //m_panel.eventPositionChanged += (component, value) => {Update();}; //m_panel.eventMouseMove += (component, value) => {Update();}; UIView.Find<UITextField> ("DistrictName").eventTextChanged += (component, value) => {Update();}; }
private void createInfoView() { //line info painel TLMUtils.createUIElement <UIPanel>(ref depotInfoPanel, m_controller.mainRef.transform); depotInfoPanel.Hide(); depotInfoPanel.relativePosition = new Vector3(394.0f, 0.0f); depotInfoPanel.width = 650; depotInfoPanel.height = 290; depotInfoPanel.zOrder = 50; depotInfoPanel.color = new Color32(255, 255, 255, 255); depotInfoPanel.backgroundSprite = "MenuPanel2"; depotInfoPanel.name = "DepotInfoPanel"; depotInfoPanel.autoLayoutPadding = new RectOffset(5, 5, 10, 10); depotInfoPanel.autoLayout = false; depotInfoPanel.useCenter = true; depotInfoPanel.wrapLayout = false; depotInfoPanel.canFocus = true; TLMUtils.createDragHandle(depotInfoPanel, depotInfoPanel, 35f); TLMUtils.createUIElement <UILabel>(ref lineTransportIconTypeLabel, depotInfoPanel.transform); lineTransportIconTypeLabel.autoSize = false; lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.width = 30; lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.name = "DepotTransportIcon"; lineTransportIconTypeLabel.clipChildren = true; TLMUtils.createDragHandle(lineTransportIconTypeLabel, depotInfoPanel); TLMUtils.createUIElement <UITextField>(ref depotNameField, depotInfoPanel.transform); depotNameField.autoSize = false; depotNameField.relativePosition = new Vector3(160f, 10f); depotNameField.horizontalAlignment = UIHorizontalAlignment.Center; depotNameField.text = "NOME"; depotNameField.width = 450; depotNameField.height = 25; depotNameField.name = "DepotNameLabel"; depotNameField.maxLength = 256; depotNameField.textScale = 1.5f; TLMUtils.uiTextFieldDefaults(depotNameField); depotNameField.eventGotFocus += (component, eventParam) => { lastDepotName = depotNameField.text; }; depotNameField.eventLostFocus += (component, eventParam) => { if (lastDepotName != depotNameField.text) { saveDepotName(depotNameField); } depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(m_buildingIdSelecionado.Building, default(InstanceID)); }; TLMUtils.createUIElement <UILabel>(ref vehiclesInUseLabel, depotInfoPanel.transform); vehiclesInUseLabel.autoSize = false; vehiclesInUseLabel.relativePosition = new Vector3(10f, 60f); vehiclesInUseLabel.textAlignment = UIHorizontalAlignment.Left; vehiclesInUseLabel.text = ""; vehiclesInUseLabel.width = 550; vehiclesInUseLabel.height = 25; vehiclesInUseLabel.name = "VehiclesInUseLabel"; vehiclesInUseLabel.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref passengersLastWeek, depotInfoPanel.transform); passengersLastWeek.autoSize = false; passengersLastWeek.relativePosition = new Vector3(10f, 90); passengersLastWeek.textAlignment = UIHorizontalAlignment.Left; passengersLastWeek.text = ""; passengersLastWeek.width = 550; passengersLastWeek.height = 25; passengersLastWeek.name = "PassengersLastWeek"; passengersLastWeek.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref upkeepCost, depotInfoPanel.transform); upkeepCost.autoSize = false; upkeepCost.relativePosition = new Vector3(10f, 75); upkeepCost.textAlignment = UIHorizontalAlignment.Left; upkeepCost.width = 250; upkeepCost.height = 25; upkeepCost.name = "AvoidedTravelsLabel"; upkeepCost.textScale = 0.8f; TLMUtils.createUIElement <UILabel>(ref prefixesSpawned, depotInfoPanel.transform); prefixesSpawned.autoSize = false; prefixesSpawned.relativePosition = new Vector3(10f, 120f); prefixesSpawned.textAlignment = UIHorizontalAlignment.Left; prefixesSpawned.localeID = "TLM_PREFIXES_SPAWNED_DEPOT"; prefixesSpawned.suffix = ":"; prefixesSpawned.width = 350; prefixesSpawned.height = 25; prefixesSpawned.name = "TouristAndPassagersLabel"; prefixesSpawned.textScale = 0.8f; UIPanel prefixesPanel = null; TLMUtils.createUIElement <UIPanel>(ref prefixesPanel, depotInfoPanel.transform); prefixesPanel.autoSize = false; prefixesPanel.relativePosition = new Vector3(10f, 135f); prefixesPanel.width = 630; prefixesPanel.height = 100; prefixesPanel.name = "Prefixes Panel"; prefixesPanel.autoLayout = true; prefixesPanel.wrapLayout = true; prefixesCheckboxes = new Dictionary <uint, UICheckBox>(); for (uint i = 0; i <= 65; i++) { prefixesCheckboxes[i] = prefixesPanel.AttachUIComponent(UITemplateManager.GetAsGameObject("OptionsCheckBoxTemplate")) as UICheckBox; prefixesCheckboxes[i].text = i == 0 ? Locale.Get("TLM_UNPREFIXED") : i == 65 ? Locale.Get("TLM_REGIONAL") : i.ToString(); prefixesCheckboxes[i].width = 50; prefixesCheckboxes[i].GetComponentInChildren <UILabel>().relativePosition = new Vector3(20, 2); uint j = i; prefixesCheckboxes[i].eventCheckChanged += (x, y) => { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("prefixesCheckboxes[i].eventCheckChanged; j = {0}; check = {1}; loading = {2}", j, y, isLoading); } if (!isLoading) { togglePrefix(j, y); } }; } prefixesCheckboxes[0].width = prefixesPanel.width / 2.1f; prefixesCheckboxes[65].width = prefixesPanel.width / 2.1f; prefixesCheckboxes[65].zOrder = 0; UIButton voltarButton2 = null; TLMUtils.createUIElement <UIButton>(ref voltarButton2, depotInfoPanel.transform); voltarButton2.relativePosition = new Vector3(depotInfoPanel.width - 33f, 5f); voltarButton2.width = 28; voltarButton2.height = 28; TLMUtils.initButton(voltarButton2, true, "DeleteLineButton"); voltarButton2.name = "LineInfoCloseButton"; voltarButton2.eventClick += closeDepotInfo; workerChart = new TLMWorkerChartPanel(this, new Vector3(400f, 60f)); UIButton addAllPrefixesButton = null; TLMUtils.createUIElement(ref addAllPrefixesButton, transform); addAllPrefixesButton.relativePosition = new Vector3(300, 100f); addAllPrefixesButton.localeID = "TLM_ADD_ALL"; addAllPrefixesButton.isLocalized = true; addAllPrefixesButton.textScale = 0.6f; addAllPrefixesButton.width = 80; addAllPrefixesButton.height = 15; addAllPrefixesButton.tooltipLocaleID = "TLM_ADD_ALL_PREFIX_TOOLTIP"; TLMUtils.initButton(addAllPrefixesButton, true, "ButtonMenu"); addAllPrefixesButton.name = "AddAll"; addAllPrefixesButton.isVisible = true; addAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.addAllPrefixesToDepot(m_buildingIdSelecionado.Building); updateCheckboxes(); }; UIButton removeAllPrefixesButton = null; TLMUtils.createUIElement <UIButton>(ref removeAllPrefixesButton, transform); removeAllPrefixesButton.relativePosition = new Vector3(300, 120f); removeAllPrefixesButton.localeID = "TLM_REMOVE_ALL"; removeAllPrefixesButton.isLocalized = true; removeAllPrefixesButton.textScale = 0.6f; removeAllPrefixesButton.width = 80; removeAllPrefixesButton.height = 15; removeAllPrefixesButton.tooltipLocaleID = "TLM_REMOVE_ALL_PREFIX_TOOLTIP"; TLMUtils.initButton(removeAllPrefixesButton, true, "ButtonMenu"); removeAllPrefixesButton.name = "RemoveAll"; removeAllPrefixesButton.isVisible = true; removeAllPrefixesButton.eventClick += (component, eventParam) => { TLMDepotAI.removeAllPrefixesFromDepot(m_buildingIdSelecionado.Building); updateCheckboxes(); }; }
public override void Start() { base.Start(); _checkBox = AddUIComponent <UICustomCheckbox>(); _colorFieldPanel = AddUIComponent <UIPanel>(); _colorFieldPanel.size = new Vector2(17, 17); _colorFieldPanel.relativePosition = new Vector3(22, 0); _color = Instantiate(FindObjectOfType <UIColorField>().gameObject).GetComponent <UIColorField>(); _colorFieldPanel.AttachUIComponent(_color.gameObject); _color.name = "ColorPickerLine" + LineID; _color.size = new Vector2(17, 17); _color.relativePosition = new Vector3(0, 0); _color.pickerPosition = UIColorField.ColorPickerPosition.RightAbove; _color.eventSelectedColorChanged += (component, value) => TransportUtil.SetLineColor(LineID, value); _name = AddUIComponent <UILabel>(); _stops = AddUIComponent <UILabel>(); _passengers = AddUIComponent <UILabel>(); _trips = AddUIComponent <UILabel>(); _vehicles = AddUIComponent <UILabel>(); _dayOnly = AddUIComponent <UICustomCheckbox>(); _nightOnly = AddUIComponent <UICustomCheckbox>(); _deleteButton = AddUIComponent <UIButton>(); _deleteButton.size = new Vector2(17, 17); _deleteButton.tooltip = "Delete line"; _deleteButton.normalFgSprite = "buttonclose"; _deleteButton.pressedFgSprite = "buttonclosepressed"; _deleteButton.hoveredFgSprite = "buttonclosehover"; _deleteButton.isVisible = true; _checkBox.relativePosition = new Vector3(5, 0); _name.relativePosition = new Vector3(43, 0); _stops.relativePosition = new Vector3(170, 0); _passengers.relativePosition = new Vector3(225, 0); _trips.relativePosition = new Vector3(320, 0); _vehicles.relativePosition = new Vector3(401, 0); _dayOnly.relativePosition = new Vector3(455, 0); _nightOnly.relativePosition = new Vector3(490, 0); _deleteButton.relativePosition = new Vector3(515, 0); _name.textColor = new Color32(185, 221, 254, 255); _stops.textColor = new Color32(185, 221, 254, 255); _passengers.textColor = new Color32(185, 221, 254, 255); _trips.textColor = new Color32(185, 221, 254, 255); _vehicles.textColor = new Color32(185, 221, 254, 255); _checkBox.size = new Vector2(12, 12); _dayOnly.size = new Vector2(12, 12); _nightOnly.size = new Vector2(12, 12); //init the day/night checkboxes _dayOnly.IsChecked = TransportUtil.GetDay(LineID); _nightOnly.IsChecked = TransportUtil.GetNight(LineID); // event handler for on/off of the line _checkBox.eventClick += (component, param) => { _checkBox.IsChecked = !_checkBox.IsChecked; if (!_checkBox.IsChecked) { TransportUtil.HideTransportLine(LineID); } else { TransportUtil.ShowTransportLine(LineID); } }; // event handler for on/off of day _dayOnly.eventClick += (component, param) => { _dayOnly.IsChecked = !_dayOnly.IsChecked; TransportUtil.SetDay(LineID, _dayOnly.IsChecked); }; // event handler for on/off of night _nightOnly.eventClick += (component, param) => { _nightOnly.IsChecked = !_nightOnly.IsChecked; TransportUtil.SetNight(LineID, _nightOnly.IsChecked); }; _name.eventClick += (component, param) => WorldInfoPanel.Show <PublicTransportWorldInfoPanel>(TransportUtil.GetFirstLineStop(LineID), InstanceID); _name.eventMouseHover += (component, param) => { TransportUtil.SelectTransportLine(LineID); _name.textColor = TransportUtil.GetLineColor(LineID); }; _name.eventMouseLeave += (component, param) => { TransportUtil.DeselectTransportLine(LineID); _name.textColor = new Color32(185, 221, 254, 255); }; _deleteButton.eventClick += (component, param) => Singleton <TransportManager> .instance.ReleaseLine(LineID); // scale label texts _name.textScale = 0.8f; _stops.textScale = 0.8f; _passengers.textScale = 0.8f; _trips.textScale = 0.8f; _vehicles.textScale = 0.8f; _deleteButton.textScale = 0.8f; // zebra stripes background backgroundSprite = "GenericPanelLight"; if (IsOdd) { color = new Color32(150, 150, 150, 255); } else { color = new Color32(130, 130, 130, 255); } // center elements in row UIComponent[] children = GetComponentsInChildren <UIComponent>(); foreach (UIComponent child in children) { if (child == this) { continue; } child.pivot = UIPivotPoint.MiddleLeft; child.transformPosition = new Vector3(child.transformPosition.x, GetBounds().center.y, 0); } }