public Color AutoColor(ushort i) { TransportLine t = tm.m_lines.m_buffer[(int)i]; try { TLMCW.ConfigIndex transportType = TLMCW.getDefinitionForLine(i).toConfigIndex(); bool prefixBased = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_PREFIX_BASED); bool randomOnOverflow = TLMCW.getCurrentConfigBool(transportType | TLMCW.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW); string pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_SUBLINE); ushort num = t.m_lineNumber; if (num >= 1000 && TLMCW.getCurrentConfigInt(transportType | TLMCW.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum) { pal = TLMCW.getCurrentConfigString(transportType | TLMCW.ConfigIndex.PALETTE_MAIN); if (prefixBased) { num /= 1000; } else { num %= 1000; } } Color c = TLMAutoColorPalettes.getColor(num, pal, randomOnOverflow); TLMUtils.setLineColor(i, c); return(c); } catch (Exception e) { TLMUtils.doErrorLog("ERRO!!!!! " + e.Message); TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false); return(Color.clear); } }
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 void OnColorChanged(UIComponent comp, Color color) { TLMUtils.setLineColor(this.m_LineID, color); }