public void redrawLine() { ushort lineID = parent.CurrentSelectedId; TransportLine t = TLMController.instance.tm.m_lines.m_buffer[(int)lineID]; int stopsCount = t.CountStops(lineID); int vehicleCount = t.CountVehicles(lineID); Color lineColor = TLMController.instance.tm.GetLineColor(lineID); setLinearMapColor(lineColor); clearStations(); updateSubIconLayer(); setLineNumberCircle(lineID); if (lineID == 0) { var tsd = TransportSystemDefinition.from(parent.CurrentTransportInfo); if (tsd != default(TransportSystemDefinition)) { linearMapLineNumberFormat.backgroundSprite = TLMLineUtils.GetIconForIndex(tsd.toConfigIndex()); } lineStationsPanel.width = 0; return; } ItemClass.SubService ss = TLMCW.getDefinitionForLine(lineID).subService; linearMapLineNumberFormat.backgroundSprite = TLMLineUtils.getIconForLine(lineID); m_autoName = TLMLineUtils.calculateAutoName(lineID, true); linearMapLineNumber.tooltip = m_autoName; string stationName; Vector3 local; string airport, taxi, harbor, regionalStation, cableCarStation; string namePrefix; bool isComplete = (Singleton <TransportManager> .instance.m_lines.m_buffer[TLMController.instance.CurrentSelectedId].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None; bool simmetric = TLMLineUtils.CalculateSimmetry(ss, stopsCount, t, out int middle); float addedWidth = 0; lineStationsPanel.width = 0; if (t.Info.m_transportType != TransportInfo.TransportType.Bus && t.Info.m_transportType != TransportInfo.TransportType.Tram && simmetric && !showExtraStopInfo) { int maxIt = middle + stopsCount / 2; for (int j = middle; j <= maxIt; j++) { ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); addedWidth = addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, false) + (j == middle + stopsCount / 2 ? 5 : 0); lineStationsPanel.width += addedWidth; } } else { int minI = 0, maxI = stopsCount; if (simmetric) { minI = middle + 1; maxI = stopsCount + middle + 1; } if (showExtraStopInfo) { int j = (minI - 1 + stopsCount) % stopsCount; ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); lineStationsPanel.width += addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, true); } else if (TLMSingleton.showDistanceInLinearMap || parent.ForceShowStopsDistances) { minI--; } for (int i = minI; i < maxI; i++) { int j = (i + stopsCount) % stopsCount; ushort stationId = t.GetStop(j); local = getStation(lineID, stationId, ss, out stationName, out List <ushort> intersections, out airport, out harbor, out taxi, out regionalStation, out cableCarStation, out namePrefix); addedWidth = addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, cableCarStation, stationId, ss, lineColor, false); lineStationsPanel.width += addedWidth; } } lineStationsPanel.width -= addedWidth; if (showExtraStopInfo) { vehiclesOnStation.Clear(); for (int v = 0; v < vehicleCount; v++) { ushort vehicleId = t.GetVehicle(v); AddVehicleToLinearMap(lineColor, vehicleId); } } }
private void updateUI(bool syncFromInput = false) { TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab); TLMLineUtils.GetNamingRulesFromTSD(out ModoNomenclatura prefixo, out Separador sep, out ModoNomenclatura sufixo, out ModoNomenclatura nonPrefix, out bool zeros, out bool invertPrefixSuffix, tsd); if (syncFromInput) { String value = "0" + lineNumberTxtBox.text; int valPrefixo = linePrefixDropDown.selectedIndex; ushort num = ushort.Parse(value); if (prefixo != ModoNomenclatura.Nenhum) { num = (ushort)(valPrefixo * 1000 + (num % 1000)); } if (nextLineNumber + 1 != num) { nextLineNumber = (ushort)(num - 1); } } var configIdx = tsd.toConfigIndex(); Color color; if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED)) { color = TLMUtils.CalculateAutoColor((ushort)(nextLineNumber + 1), TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab), true); } else { color = TLMConfigWarehouse.getColorForTransportType(configIdx); } lineNumberTxtBox.color = color; lineFormat.color = color; lineFormat.backgroundSprite = TLMLineUtils.GetIconForIndex(configIdx); lineNumber.text = TLMUtils.getString(prefixo, sep, sufixo, nonPrefix, (nextLineNumber + 1) & 0xFFFF, zeros, invertPrefixSuffix); lineNumber.textColor = TLMUtils.contrastColor(color); int txtLen = lineNumber.text.Length; switch (txtLen) { case 1: lineNumber.textScale = 4; break; case 2: lineNumber.textScale = 3; break; case 3: lineNumber.textScale = 2.25f; break; case 4: lineNumber.textScale = 1.75f; break; case 5: lineNumber.textScale = 1.5f; break; case 6: lineNumber.textScale = 1.35f; break; case 7: lineNumber.textScale = 1.2f; break; case 8: lineNumber.textScale = 1.1f; break; default: lineNumber.textScale = 1f; break; } }