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 float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections, string airport, string harbor, string taxi, string regionalTrainStation, string cableCarStation, ushort stationNodeId, ItemClass.SubService ss, Color lineColor, bool simple)//, out float intersectionPanelHeight) { ushort lineID = parent.CurrentSelectedId; TransportLine t = TLMController.instance.tm.m_lines.m_buffer[(int)lineID]; TransportManager tm = Singleton <TransportManager> .instance; if (stationName == null) { stationName = "???"; } TLMUtils.createUIElement(out UIButton stationButton, lineStationsPanel.transform); stationButton.relativePosition = new Vector3(offsetX - 13, 15f); stationButton.width = 20; stationButton.height = 20; stationButton.color = lineColor; stationButton.name = "Station [" + stationName + "]"; stationButton.atlas = TLMController.taLineNumber; stationButton.tooltip = stationName + "(id:" + stationNodeId + ")"; TLMUtils.initButton(stationButton, true, "LinearStation"); TLMUtils.createUIElement(out DroppableStationInfo dsi, stationButton.transform); dsi.nodeId = stationNodeId; dsi.name = "DSI Station [" + stationName + "] - " + stationNodeId; TLMUtils.createUIElement(out UITextField stationLabel, stationButton.transform); stationLabel.autoSize = true; stationLabel.width = 220; stationLabel.height = 20; stationLabel.useOutline = true; stationLabel.pivot = UIPivotPoint.MiddleLeft; stationLabel.horizontalAlignment = UIHorizontalAlignment.Left; stationLabel.verticalAlignment = UIVerticalAlignment.Middle; stationLabel.name = "Station [" + stationName + "] Name"; stationLabel.relativePosition = new Vector3(23f, -13f); stationLabel.text = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim(); stationLabel.textScale = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length)); TLMUtils.uiTextFieldDefaults(stationLabel); stationLabel.color = new Color(0.3f, 0.3f, 0.3f, 1); stationLabel.textColor = Color.white; stationLabel.cursorWidth = 2; stationLabel.cursorBlinkTime = 100; stationLabel.eventGotFocus += (x, y) => { stationLabel.text = TLMLineUtils.getStationName(stationNodeId, lineID, ss); }; stationLabel.eventTextSubmitted += (x, y) => { TLMLineUtils.setStopName(y, stationNodeId, lineID, () => { stationLabel.text = TLMLineUtils.getFullStationName(stationNodeId, lineID, ss); m_autoName = TLMLineUtils.calculateAutoName(lineID, true); parent.OnRenameStationAction(autoName); }); }; stationButton.gameObject.transform.localPosition = new Vector3(0, 0, 0); stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45); stationButton.eventClick += (component, eventParam) => { GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera"); if (gameObject != null) { var cameraController = gameObject.GetComponent <CameraController>(); InstanceID x = default(InstanceID); x.TransportLine = parent.CurrentSelectedId; cameraController.SetTarget(x, location, false); cameraController.ClearTarget(); } }; if (!simple) { if (!stationOffsetX.ContainsKey(stationNodeId)) { stationOffsetX.Add(stationNodeId, offsetX); } if (showIntersections) { var otherLinesIntersections = TLMLineUtils.SortLines(intersections, t); UILabel distance = null; int intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0) + (cableCarStation != string.Empty ? 1 : 0); if ((TLMSingleton.showDistanceInLinearMap || parent.ForceShowStopsDistances) && offsetX > 0) { NetSegment seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment0]; if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment1]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment2]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment3]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment4]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment5]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment6]; } if (seg.m_endNode != stationNodeId) { seg = Singleton <NetManager> .instance.m_segments.m_buffer[Singleton <NetManager> .instance.m_nodes.m_buffer[stationNodeId].m_segment7]; } if (seg.m_endNode != stationNodeId) { seg = default(NetSegment); } TLMUtils.createUIElement(out UIPanel distContainer, stationButton.transform); distContainer.size = new Vector2(0, 0); distContainer.relativePosition = new Vector3(0, 0, 0); TLMUtils.createUIElement(out distance, distContainer.transform); distance.autoSize = false; distance.useOutline = true; if (seg.Equals(default(NetSegment))) { distance.text = "???"; distance.color = Color.red; } else { distance.text = (int)seg.m_averageLength + "m"; } distance.textScale = 0.7f; distance.textAlignment = UIHorizontalAlignment.Center; distance.verticalAlignment = UIVerticalAlignment.Middle; distance.name = "dist."; distance.font = UIHelperExtension.defaultFontCheckbox; distance.width = 50f; distance.height = 50; distance.relativePosition = new Vector3(-42, 0); distance.transform.localEulerAngles = new Vector3(0, 0, 45); distance.isInteractive = false; } if (intersectionCount > 0) { TLMUtils.createUIElement(out UIPanel intersectionsPanel, stationButton.transform); intersectionsPanel.autoSize = false; intersectionsPanel.autoLayout = false; intersectionsPanel.autoLayoutStart = LayoutStart.TopLeft; intersectionsPanel.autoLayoutDirection = LayoutDirection.Horizontal; intersectionsPanel.relativePosition = new Vector3(-20, 10); intersectionsPanel.wrapLayout = false; intersectionsPanel.autoFitChildrenVertically = true; TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, cableCarStation, intersectionsPanel, otherLinesIntersections); intersectionsPanel.autoLayout = true; intersectionsPanel.wrapLayout = true; intersectionsPanel.width = 55; // return(42f); } else { TLMUtils.initButton(stationButton, true, "LinearHalfStation"); if (offsetX == 0) { stationButton.relativePosition = new Vector3(offsetX - 13, 15f); return(31f); } else if (distance == null) { stationButton.relativePosition = new Vector3(offsetX - 23, 15f); return(21f); } else { return(42f); } } } else if (showExtraStopInfo) { float normalWidth = 42.5f; NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId]; TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out int residents, out int tourists, out int ttb); TLMUtils.createUIElement(out UIPanel stationInfoStatsPanel, stationButton.transform); stationInfoStatsPanel.autoSize = false; stationInfoStatsPanel.autoLayout = false; stationInfoStatsPanel.autoFitChildrenVertically = true; stationInfoStatsPanel.autoLayoutStart = LayoutStart.TopLeft; stationInfoStatsPanel.autoLayoutDirection = LayoutDirection.Horizontal; stationInfoStatsPanel.relativePosition = new Vector3(-20, 10); stationInfoStatsPanel.autoLayout = true; stationInfoStatsPanel.wrapLayout = true; stationInfoStatsPanel.width = normalWidth; TLMUtils.createUIElement(out UILabel residentsWaiting, stationInfoStatsPanel.transform); residentsWaiting.autoSize = false; residentsWaiting.useOutline = true; residentsWaiting.text = residents.ToString(); residentsWaiting.tooltipLocaleID = "TLM_RESIDENTS_WAITING"; residentsWaiting.backgroundSprite = "EmptySprite"; residentsWaiting.color = new Color32(0x12, 0x68, 0x34, 255); residentsWaiting.width = normalWidth; residentsWaiting.padding = new RectOffset(0, 0, 4, 2); residentsWaiting.height = 20; residentsWaiting.textScale = 0.7f; residentsWaiting.textAlignment = UIHorizontalAlignment.Center; residentCounters[stationNodeId] = residentsWaiting; TLMUtils.createUIElement(out UILabel touristsWaiting, stationInfoStatsPanel.transform); touristsWaiting.autoSize = false; touristsWaiting.text = tourists.ToString(); touristsWaiting.tooltipLocaleID = "TLM_TOURISTS_WAITING"; touristsWaiting.useOutline = true; touristsWaiting.width = normalWidth; touristsWaiting.height = 20; touristsWaiting.padding = new RectOffset(0, 0, 4, 2); touristsWaiting.textScale = 0.7f; touristsWaiting.backgroundSprite = "EmptySprite"; touristsWaiting.color = new Color32(0x1f, 0x25, 0x68, 255); touristsWaiting.textAlignment = UIHorizontalAlignment.Center; touristCounters[stationNodeId] = touristsWaiting; TLMUtils.createUIElement(out UILabel timeTilBored, stationInfoStatsPanel.transform); timeTilBored.autoSize = false; timeTilBored.text = tourists.ToString(); timeTilBored.tooltipLocaleID = "TLM_TIME_TIL_BORED"; timeTilBored.useOutline = true; timeTilBored.width = normalWidth; timeTilBored.height = 20; timeTilBored.padding = new RectOffset(0, 0, 4, 2); timeTilBored.textScale = 0.7f; timeTilBored.backgroundSprite = "EmptySprite"; timeTilBored.color = new Color32(0x1f, 0x25, 0x68, 255); timeTilBored.textAlignment = UIHorizontalAlignment.Center; ttbTimers[stationNodeId] = timeTilBored; // return(normalWidth); } else { return(30f); } } else { return(30f); } }
private void createToolbox() { TLMUtils.createUIElement(out mainContainer, m_controller.TransformLinearMap); mainContainer.absolutePosition = new Vector3(2f, TLMController.instance.uiView.fixedHeight - 300f); mainContainer.name = "TLMLineCreationToolbox"; mainContainer.height = 190; mainContainer.width = 180; mainContainer.backgroundSprite = "MenuPanel2"; mainContainer.relativePosition = new Vector3(320f, 57f); uiHelper = new UIHelperExtension(mainContainer); TLMUtils.createUIElement(out UILabel title, mainContainer.transform); title.autoSize = false; title.width = mainContainer.width; title.height = 30; title.color = new Color(1, 0, 0, 1); title.pivot = UIPivotPoint.MiddleLeft; title.textAlignment = UIHorizontalAlignment.Center; title.verticalAlignment = UIVerticalAlignment.Middle; title.name = "Title"; title.relativePosition = new Vector3(0, 5); title.atlas = TLMController.taLineNumber; title.localeID = "TLM_PREFIX_SELECTOR_WIN_TITLE"; TLMUtils.createDragHandle(title, mainContainer); GameObject lpddgo = GameObject.Instantiate(UITemplateManager.GetAsGameObject(UIHelperExtension.kDropdownTemplate).GetComponent <UIPanel>().Find <UIDropDown>("Dropdown").gameObject, mainContainer.transform); linePrefixDropDown = lpddgo.GetComponent <UIDropDown>(); linePrefixDropDown.isLocalized = false; linePrefixDropDown.autoSize = false; linePrefixDropDown.horizontalAlignment = UIHorizontalAlignment.Center; linePrefixDropDown.text = ""; linePrefixDropDown.width = 75; linePrefixDropDown.height = 30; 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 += setNextLinePrefix; linePrefixDropDown.relativePosition = new Vector3(5f, 45f); linePrefixDropDown.normalBgSprite = "OptionsDropboxListbox"; linePrefixDropDown.horizontalAlignment = UIHorizontalAlignment.Center; TLMUtils.createUIElement(out lineNumberTxtBox, mainContainer.transform); lineNumberTxtBox.autoSize = false; lineNumberTxtBox.relativePosition = new Vector3(85f, 45f); lineNumberTxtBox.horizontalAlignment = UIHorizontalAlignment.Center; lineNumberTxtBox.text = ""; lineNumberTxtBox.width = 90; lineNumberTxtBox.height = 30; lineNumberTxtBox.name = "LineNumberLabel"; lineNumberTxtBox.normalBgSprite = "EmptySprite"; lineNumberTxtBox.textScale = 1.6f; lineNumberTxtBox.padding = new RectOffset(0, 0, 0, 0); lineNumberTxtBox.color = new Color(0, 0, 0, 1); TLMUtils.uiTextFieldDefaults(lineNumberTxtBox); lineNumberTxtBox.numericalOnly = true; lineNumberTxtBox.maxLength = 4; lineNumberTxtBox.eventLostFocus += setNextLineNumber;; lineNumberTxtBox.zOrder = 10; lineNumberTxtBox.text = "0"; TLMUtils.createUIElement(out lineFormat, mainContainer.transform); lineFormat.autoSize = false; lineFormat.width = 80; lineFormat.height = 80; lineFormat.color = new Color(1, 0, 0, 1); lineFormat.pivot = UIPivotPoint.MiddleLeft; lineFormat.textAlignment = UIHorizontalAlignment.Center; lineFormat.verticalAlignment = UIVerticalAlignment.Middle; lineFormat.name = "LineFormat"; lineFormat.relativePosition = new Vector3(55f, 80f); lineFormat.atlas = TLMController.taLineNumber; TLMUtils.createDragHandle(lineFormat, mainContainer); TLMUtils.createUIElement(out lineNumber, lineFormat.transform); lineNumber.autoSize = false; lineNumber.width = lineFormat.width; lineNumber.pivot = UIPivotPoint.MiddleCenter; lineNumber.name = "LineNumber"; lineNumber.width = 80; lineNumber.height = 80; lineNumber.relativePosition = new Vector3(-0.5f, 0.5f); lineNumber.autoHeight = false; lineNumber.textAlignment = UIHorizontalAlignment.Center; lineNumber.verticalAlignment = UIVerticalAlignment.Middle; prefixIncrementChk = uiHelper.AddCheckboxLocale("TLM_AUTOINCREMENT_PREFIX", false, delegate(bool value) { if (TLMSingleton.debugMode) { TLMUtils.doLog("Type = " + TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) + "|prop=" + (TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT) + "|valToSet = " + value); } TLMConfigWarehouse.setCurrentConfigBool(TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab) | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT, value); }); prefixIncrementChk.relativePosition = new Vector3(5f, 162.5f); }
private void createInfoView() { //line info painel TLMUtils.createUIElement(out 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(out lineTransportIconTypeLabel, depotInfoPanel.transform); lineTransportIconTypeLabel.autoSize = false; lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f); lineTransportIconTypeLabel.width = 30; lineTransportIconTypeLabel.height = 20; lineTransportIconTypeLabel.name = "DepotTransportIcon"; lineTransportIconTypeLabel.clipChildren = true; lineTransportIconTypeLabel.eventClick += (x, y) => { openDepotInfo(m_buildingIdSelecionado.Building, !m_secondary); }; TLMUtils.createDragHandle(lineTransportIconTypeLabel, depotInfoPanel); TLMUtils.createUIElement(out 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); } }; TLMUtils.createUIElement(out 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(out 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(out 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(out 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; TLMUtils.createUIElement(out UIPanel 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 (TLMSingleton.instance != null && TLMSingleton.debugMode) { TLMUtils.doLog("prefixesCheckboxes[i].eventCheckChanged; j = {0}; check = {1}; loading = {2}", j, y, isLoading); } if (!isLoading) { togglePrefix(j, y, m_secondary); } }; } prefixesCheckboxes[0].width = prefixesPanel.width / 2.1f; prefixesCheckboxes[65].width = prefixesPanel.width / 2.1f; prefixesCheckboxes[65].zOrder = 0; TLMUtils.createUIElement(out UIButton 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.panelTransform, new Vector3(400f, 60f)); TLMUtils.createUIElement(out UIButton addAllPrefixesButton, panelTransform); 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, m_secondary); updateCheckboxes(); }; TLMUtils.createUIElement(out UIButton removeAllPrefixesButton, panelTransform); 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, m_secondary); updateCheckboxes(); }; }
private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections, string airport, string harbor, string taxi, string regionalTrainStation, ushort stationNodeId, ItemClass.SubService ss, bool simple = false)//, out float intersectionPanelHeight) { ushort lineID = lineInfoPanel.lineIdSelecionado.TransportLine; TransportLine t = lineInfoPanel.controller.tm.m_lines.m_buffer[(int)lineID]; TransportManager tm = Singleton <TransportManager> .instance; UIButton stationButton = null; TLMUtils.createUIElement <UIButton>(ref stationButton, lineStationsPanel.transform); stationButton.relativePosition = new Vector3(offsetX, 15f); stationButton.width = 20; stationButton.height = 20; stationButton.name = "Station [" + stationName + "]"; TLMUtils.initButton(stationButton, true, "IconPolicyBaseCircle"); UITextField stationLabel = null; TLMUtils.createUIElement <UITextField>(ref stationLabel, stationButton.transform); stationLabel.autoSize = true; stationLabel.width = 220; stationLabel.height = 20; stationLabel.useOutline = true; stationLabel.pivot = UIPivotPoint.MiddleLeft; stationLabel.horizontalAlignment = UIHorizontalAlignment.Left; stationLabel.verticalAlignment = UIVerticalAlignment.Middle; stationLabel.name = "Station [" + stationName + "] Name"; stationLabel.relativePosition = new Vector3(23f, -13f); stationLabel.text = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim(); stationLabel.textScale = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length)); TLMUtils.uiTextFieldDefaults(stationLabel); stationLabel.color = new Color(0.3f, 0.3f, 0.3f, 1); stationLabel.textColor = Color.white; stationLabel.cursorWidth = 2; stationLabel.cursorBlinkTime = 100; stationLabel.eventGotFocus += (x, y) => { stationLabel.text = TLMUtils.getStationName(stationNodeId, lineID, ss); }; stationLabel.eventTextSubmitted += (x, y) => { TLMUtils.setStopName(y, stationNodeId, lineID, () => { stationLabel.text = TLMUtils.getFullStationName(stationNodeId, lineID, ss); m_autoName = TLMUtils.calculateAutoName(lineID); lineInfoPanel.autoNameLabel.text = autoName; }); }; stationButton.gameObject.transform.localPosition = new Vector3(0, 0, 0); stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45); stationButton.eventClick += (component, eventParam) => { lineInfoPanel.cameraController.SetTarget(lineInfoPanel.lineIdSelecionado, location, false); lineInfoPanel.cameraController.ClearTarget(); }; if (!simple) { stationOffsetX.Add(stationNodeId, offsetX); if (showIntersections) { var otherLinesIntersections = TLMLineUtils.SortLines(intersections, t); int intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0); if (intersectionCount > 0) { UIPanel intersectionsPanel = null; TLMUtils.createUIElement <UIPanel>(ref intersectionsPanel, stationButton.transform); intersectionsPanel.autoSize = false; intersectionsPanel.autoLayout = false; intersectionsPanel.autoLayoutStart = LayoutStart.TopLeft; intersectionsPanel.autoLayoutDirection = LayoutDirection.Horizontal; intersectionsPanel.relativePosition = new Vector3(-20, 10); intersectionsPanel.wrapLayout = false; intersectionsPanel.autoFitChildrenVertically = true; TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, intersectionsPanel, otherLinesIntersections); intersectionsPanel.autoLayout = true; intersectionsPanel.wrapLayout = true; intersectionsPanel.width = 55; // return(42f); } else { return(25f); } } else if (showExtraStopInfo) { float normalWidth = 42.5f; NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId]; int residents, tourists; TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out residents, out tourists); UIPanel stationInfoStatsPanel = null; TLMUtils.createUIElement <UIPanel>(ref stationInfoStatsPanel, stationButton.transform); stationInfoStatsPanel.autoSize = false; stationInfoStatsPanel.autoLayout = false; stationInfoStatsPanel.autoFitChildrenVertically = true; stationInfoStatsPanel.autoLayoutStart = LayoutStart.TopLeft; stationInfoStatsPanel.autoLayoutDirection = LayoutDirection.Horizontal; stationInfoStatsPanel.relativePosition = new Vector3(-20, 10); stationInfoStatsPanel.autoLayout = true; stationInfoStatsPanel.wrapLayout = true; stationInfoStatsPanel.width = normalWidth; UILabel residentsWaiting = null; TLMUtils.createUIElement <UILabel>(ref residentsWaiting, stationInfoStatsPanel.transform); residentsWaiting.autoSize = false; residentsWaiting.useOutline = true; residentsWaiting.text = residents.ToString(); residentsWaiting.tooltipLocaleID = "TLM_RESIDENTS_WAITING"; residentsWaiting.backgroundSprite = "EmptySprite"; residentsWaiting.color = new Color32(0x12, 0x68, 0x34, 255); residentsWaiting.width = normalWidth; residentsWaiting.padding = new RectOffset(0, 0, 4, 2); residentsWaiting.height = 20; residentsWaiting.textScale = 0.7f; residentsWaiting.textAlignment = UIHorizontalAlignment.Center; residentCounters[stationNodeId] = residentsWaiting; UILabel touristsWaiting = null; TLMUtils.createUIElement <UILabel>(ref touristsWaiting, stationInfoStatsPanel.transform); touristsWaiting.autoSize = false; touristsWaiting.text = tourists.ToString(); touristsWaiting.tooltipLocaleID = "TLM_TOURISTS_WAITING"; touristsWaiting.useOutline = true; touristsWaiting.width = normalWidth; touristsWaiting.height = 20; touristsWaiting.padding = new RectOffset(0, 0, 4, 2); touristsWaiting.textScale = 0.7f; touristsWaiting.backgroundSprite = "EmptySprite"; touristsWaiting.color = new Color32(0x1f, 0x25, 0x68, 255); touristsWaiting.textAlignment = UIHorizontalAlignment.Center; touristCounters[stationNodeId] = touristsWaiting; // return(normalWidth); } else { return(25f); } } else { return(30f); } }