示例#1
0
        private void saveLineNumber()
        {
            String           value      = "0" + lineNumberLabel.text;
            int              valPrefixo = linePrefixDropDown.selectedIndex;
            ModoNomenclatura sufixo;
            ModoNomenclatura prefixo;
            ModoNomenclatura nonPrefix;
            Separador        sep;
            bool             zeros;
            bool             invertPrefixSuffix;

            TLMLineUtils.getLineNamingParameters(m_lineIdSelecionado.TransportLine, out prefixo, out sep, out sufixo, out nonPrefix, out zeros, out invertPrefixSuffix);
            ushort num = ushort.Parse(value);

            if (prefixo != ModoNomenclatura.Nenhum)
            {
                num = (ushort)(valPrefixo * 1000 + (num % 1000));
            }
            bool numeroUsado = isNumeroUsado(num, m_lineIdSelecionado.TransportLine);

            if (num < 1)
            {
                lineNumberLabel.textColor = new Color(1, 0, 0, 1);
                return;
            }

            if (numeroUsado)
            {
                lineNumberLabel.textColor = new Color(1, 0, 0, 1);
            }
            else
            {
                lineNumberLabel.textColor = new Color(1, 1, 1, 1);
                m_controller.tm.m_lines.m_buffer[(int)m_lineIdSelecionado.TransportLine].m_lineNumber = num;
                m_linearMap.setLineNumberCircle(num, prefixo, sep, sufixo, nonPrefix, zeros, invertPrefixSuffix);
                m_autoNameLabel.text = m_linearMap.autoName;

                if (prefixo != ModoNomenclatura.Nenhum)
                {
                    lineNumberLabel.text             = (num % 1000).ToString();
                    linePrefixDropDown.selectedIndex = (num / 1000);
                }
                else
                {
                    lineNumberLabel.text = (num % 10000).ToString();
                }
            }
        }
        public void RefreshData(bool colors, bool visible)
        {
            if (Singleton <TransportManager> .exists)
            {
                bool isRowVisible;

                if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed)
                {
                    //this.m_DayLine.isVisible = (!isZeroed);
                    //this.m_NightLine.isVisible = (!isZeroed);
                    //this.m_DayNightLine.isVisible = (!isZeroed);
                    //this.m_DisabledLine.isVisible = (!isZeroed);
                    //this.m_noBudgetWarn.isVisible = (isZeroed);

                    bool isZeroed;
                    bool dayActive;
                    bool nightActive;

                    TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID], out dayActive, out nightActive, out isZeroed);
                    if (!isZeroed)
                    {
                        if (!dayActive || !nightActive)
                        {
                            m_LineColor.normalBgSprite = dayActive ? "DayIcon" : nightActive ? "NightIcon" : "DisabledIcon";
                        }
                        else
                        {
                            m_LineColor.normalBgSprite = "";
                        }
                    }
                    else
                    {
                        m_LineColor.normalBgSprite = "NoBudgetIcon";
                        //m_noBudgetWarn.relativePosition = new Vector3(615, 2);
                    }
                    this.m_DayLine.isChecked        = (dayActive && !nightActive);
                    this.m_NightLine.isChecked      = (nightActive && !dayActive);
                    this.m_DayNightLine.isChecked   = (dayActive && nightActive);
                    this.m_DisabledLine.isChecked   = (!dayActive && !nightActive);
                    m_DisabledLine.relativePosition = new Vector3(730, 8);
                    isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(dayActive, nightActive) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber);
                }
                else
                {
                    m_LineColor.normalBgSprite = "DisabledIcon";
                    isRowVisible = TLMPublicTransportDetailPanel.instance.isActivityVisible(false, false) && TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_LineNumber);
                }
                if (!isRowVisible)
                {
                    GetComponent <UIComponent>().isVisible = false;
                    return;
                }
                GetComponent <UIComponent>().isVisible = true;
                this.m_LineName.text = Singleton <TransportManager> .instance.GetLineName(this.m_LineID);

                m_LineNumber             = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_lineNumber;
                this.m_LineStops.text    = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountStops(this.m_LineID).ToString("N0");
                this.m_LineVehicles.text = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].CountVehicles(this.m_LineID).ToString("N0");
                uint          prefix = 0;
                TransportInfo info   = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info;
                if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
                {
                    prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u;
                }

                float overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f;

                float prefixMultiplier = TLMUtils.getExtensionFromConfigIndex(TLMCW.getConfigIndexForTransportInfo(info)).getBudgetMultiplierForHour(prefix, (int)Singleton <SimulationManager> .instance.m_currentDayTimeHour) / 100f;

                this.m_budgetEffective.text = string.Format("{0:0%}", overallBudget * prefixMultiplier);//585+1/7 = frames/week

                string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES"));


                this.m_LineVehicles.tooltip = vehTooltip;


                int averageCount  = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_residentPassengers.m_averageCount;
                int averageCount2 = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_passengers.m_touristPassengers.m_averageCount;
                this.m_LinePassengers.text = (averageCount + averageCount2).ToString("N0");


                //   this.m_LineEarnings.text = string.Format("~₡ {0:0.00}", (averageCount + averageCount2) / 50f);
                //    m_LineEarnings.relativePosition = m_LinePassengers.relativePosition + new Vector3(0, 20, 0);


                this.m_LinePassengers.tooltip = string.Format("{0}", LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[]
                {
                    averageCount,
                    averageCount2
                }));
                ModoNomenclatura prefixMode;
                Separador        sep;
                ModoNomenclatura suffix;
                ModoNomenclatura nonPrefix;
                bool             zerosEsquerda;
                bool             invertPrefixSuffix;
                string           bgSprite;
                TLMLineUtils.getLineNamingParameters(lineID, out prefixMode, out sep, out suffix, out nonPrefix, out zerosEsquerda, out invertPrefixSuffix, out bgSprite);
                TLMLineUtils.setLineNumberCircleOnRef(lineNumber, prefixMode, sep, suffix, nonPrefix, zerosEsquerda, m_LineNumberFormatted, invertPrefixSuffix, 0.8f);
                m_LineColor.normalFgSprite = bgSprite;

                m_budgetEffective.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN"), TLMCW.getNameForTransportType(TLMCW.getConfigIndexForTransportInfo(info)), TLMUtils.getStringOptionsForPrefix(prefixMode, true)[prefix + 1], overallBudget, prefixMultiplier, overallBudget * prefixMultiplier);

                this.m_PassengerCount = averageCount + averageCount2;
                if (colors)
                {
                    this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID);
                }
                if (visible)
                {
                    this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None);
                }


                m_budgetEffective.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0);
            }
        }
示例#3
0
        public void redrawLine()
        {
            ushort        lineID       = lineInfoPanel.lineIdSelecionado.TransportLine;
            TransportLine t            = lineInfoPanel.controller.tm.m_lines.m_buffer[(int)lineID];
            int           stopsCount   = t.CountStops(lineID);
            int           vehicleCount = t.CountVehicles(lineID);
            Color         lineColor    = lineInfoPanel.controller.tm.GetLineColor(lineID);

            setLinearMapColor(lineColor);
            clearStations();
            String bgSprite;

            ItemClass.SubService ss = TLMLineUtils.getLineNamingParameters(lineID, out prefix, out sep, out suffix, out nonPrefix, out zerosEsquerda, out invertPrefixSuffix, out bgSprite).subService;
            linearMapLineNumberFormat.backgroundSprite = bgSprite;


            bool day, night, zeroed;

            TLMLineUtils.getLineActive(ref t, out day, out night, out zeroed);
            if (zeroed)
            {
                linearMapLineTime.backgroundSprite = "NoBudgetIcon";
            }
            else
            {
                if (!day || !night)
                {
                    linearMapLineTime.backgroundSprite = day ? "DayIcon" : night ? "NightIcon" : "DisabledIcon";
                }
                else
                {
                    linearMapLineTime.backgroundSprite = "";
                }
            }

            setLineNumberCircle(t.m_lineNumber, prefix, sep, suffix, nonPrefix, zerosEsquerda, invertPrefixSuffix);

            m_autoName = TLMUtils.calculateAutoName(lineID);
            string  stationName = null;
            Vector3 local;
            string  airport, taxi, harbor, regionalStation;
            int     middle;
            string  namePrefix;
            bool    simmetric = TLMUtils.CalculateSimmetry(ss, stopsCount, t, out middle);

            if (t.Info.m_transportType != TransportInfo.TransportType.Bus && t.Info.m_transportType != TransportInfo.TransportType.Tram && simmetric && !showExtraStopInfo)
            {
                lineStationsPanel.width = 5;
                for (int j = middle; j <= middle + stopsCount / 2; j++)
                {
                    List <ushort> intersections;
                    ushort        stationId = t.GetStop(j);
                    local = getStation(lineID, stationId, ss, out stationName, out intersections, out airport, out harbor, out taxi, out regionalStation, out namePrefix);
                    lineStationsPanel.width += addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, stationId, ss) + (j == middle + stopsCount / 2 ? 5 : 0);
                }
            }
            else
            {
                lineStationsPanel.width = 5;
                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);
                    List <ushort> intersections;
                    local = getStation(lineID, stationId, ss, out stationName, out intersections, out airport, out harbor, out taxi, out regionalStation, out namePrefix);
                    lineStationsPanel.width += addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, stationId, ss, true);
                }
                for (int i = minI; i < maxI; i++)
                {
                    int           j = i % stopsCount;
                    List <ushort> intersections;
                    ushort        stationId = t.GetStop(j);
                    local = getStation(lineID, stationId, ss, out stationName, out intersections, out airport, out harbor, out taxi, out regionalStation, out namePrefix);
                    lineStationsPanel.width += addStationToLinearMap(namePrefix, stationName, local, lineStationsPanel.width, intersections, airport, harbor, taxi, regionalStation, stationId, ss) + (j == stopsCount - (showExtraStopInfo ? 0 : 1) ? 5 : 0);
                }
            }
            if (showExtraStopInfo)
            {
                vehiclesOnStation.Clear();
                for (int v = 0; v < vehicleCount; v++)
                {
                    ushort vehicleId = t.GetVehicle(v);

                    AddVehicleToLinearMap(lineColor, vehicleId);
                }
            }
        }