Ejemplo n.º 1
0
        private void ActionDelete()
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            TLMLineUtils.GetEffectiveExtensionForLine(lineID).RemoveAllBudgetMultipliersOfLine(lineID);
            UVMBudgetConfigTab.Instance.RebuildList(lineID);
        }
Ejemplo n.º 2
0
        private IEnumerator ChangeColorCoroutine(ushort id, Color color)
        {
            if (colorChangeCooldown > 0)
            {
                yield break;
            }
            colorChangeCooldown = 3;
            do
            {
                colorChangeCooldown--;
                yield return(0);
            } while (colorChangeCooldown > 0);

            if (Singleton <SimulationManager> .exists)
            {
                AsyncTask <bool> task = Singleton <SimulationManager> .instance.AddAction(Singleton <TransportManager> .instance.SetLineColor(id, color));

                yield return(task.WaitTaskCompleted(this));

                if (UVMPublicTransportWorldInfoPanel.GetLineID() == id)
                {
                    m_colorField.selectedColor = Singleton <TransportManager> .instance.GetLineColor(id);
                }
            }
            yield break;
        }
Ejemplo n.º 3
0
        private void ActionDelete()
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            TLMLineUtils.GetEffectiveExtensionForLine(lineID).ClearTicketPricesOfLine(lineID);
            TLMTicketConfigTab.Instance.RebuildList(lineID);
        }
        public void Awake()
        {
            Instance            = this;
            MainContainer       = GetComponent <UIComponent>();
            m_uiHelperNeighbors = new UIHelperExtension(MainContainer);

            ((UIPanel)m_uiHelperNeighbors.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIPanel)m_uiHelperNeighbors.Self).wrapLayout          = true;
            ((UIPanel)m_uiHelperNeighbors.Self).autoLayout          = true;

            UILabel titleLabel = m_uiHelperNeighbors.AddLabel("");

            titleLabel.autoSize      = true;
            titleLabel.textAlignment = UIHorizontalAlignment.Center;
            titleLabel.wordWrap      = false;
            titleLabel.minimumSize   = new Vector2(MainContainer.width - 10, 0);
            titleLabel.localeID      = "K45_TLM_PER_HOUR_BUDGET_TITLE";

            m_uiHelperNeighbors.AddSpace(5);
            KlyteMonoUtils.CreateElement(out m_clockChart, m_uiHelperNeighbors.Self.transform, "DailyClock");
            m_showAbsoluteCheckbox = m_uiHelperNeighbors.AddCheckboxLocale("K45_TLM_SHOW_ABSOLUTE_VALUE", false, (x) =>
            {
                RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID());
            });
            KlyteMonoUtils.LimitWidthAndBox(m_showAbsoluteCheckbox.label, m_uiHelperNeighbors.Self.width - 40f);
            KlyteMonoUtils.CreateElement(out m_titleContainer, m_uiHelperNeighbors.Self.transform, "Title");
            PopulateTitlePanel(m_titleContainer);
            KlyteMonoUtils.CreateScrollPanel(m_uiHelperNeighbors.Self, out m_entryListContainer, out _, m_uiHelperNeighbors.Self.width - 20f, m_uiHelperNeighbors.Self.height - 150, Vector3.zero);
        }
Ejemplo n.º 5
0
 private void SetFormatPrefix(int value)
 {
     if (!m_isLoading)
     {
         Extension.SetCustomFormat(SelectedPrefix, (LineIconSpriteNames)Enum.Parse(typeof(LineIconSpriteNames), value.ToString()));
         UVMPublicTransportWorldInfoPanel.MarkDirty(GetType());
     }
 }
Ejemplo n.º 6
0
        private void AddEntry()
        {
            ushort lineId = UVMPublicTransportWorldInfoPanel.GetLineID();

            Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            config.SetTicketPriceToLine(lineId, 0, 0);
            RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID());
        }
Ejemplo n.º 7
0
        private void ActionCopy()
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            m_clipboard             = XmlUtils.DefaultXmlSerialize(TLMLineUtils.GetEffectiveExtensionForLine(lineID).GetBudgetsMultiplierForLine(lineID));
            m_pasteButton.isVisible = true;
            UVMBudgetConfigTab.Instance.RebuildList(lineID);
        }
 public void UpdateBindings()
 {
     if (m_isDirty)
     {
         RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID());
         m_isDirty = false;
     }
 }
Ejemplo n.º 9
0
 private void OnPrefixNameChange(string val)
 {
     if (!m_isLoading)
     {
         Extension.SetName(SelectedPrefix, val);
         UVMPublicTransportWorldInfoPanel.MarkDirty(GetType());
     }
 }
Ejemplo n.º 10
0
        private void ActionPaste()
        {
            if (m_clipboard == null)
            {
                return;
            }
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            TLMLineUtils.GetEffectiveExtensionForLine(lineID).SetAllBudgetMultipliersForLine(lineID, XmlUtils.DefaultXmlDeserialize <TimeableList <BudgetEntryXml> >(m_clipboard));
            UVMBudgetConfigTab.Instance.RebuildList(lineID);
        }
        private void AddEntry()
        {
            TimeableList <BudgetEntryXml> config = TLMLineUtils.GetEffectiveConfigForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).BudgetEntries;

            config.Add(new BudgetEntryXml()
            {
                HourOfDay = 0,
                Value     = 100
            });
            RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID());
        }
Ejemplo n.º 12
0
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            if (lineID > 0)
            {
                RebuildList(lineID);
            }
        }
Ejemplo n.º 13
0
 public void Update()
 {
     if (m_container.isVisible)
     {
         ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();
         m_minutePointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour % 1 * -360) + 180);
         m_hourPointer.transform.localEulerAngles   = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour / 24 * -360) + 180);
         var tsd = TransportSystemDefinition.From(lineID);
         Tuple <TicketPriceEntryXml, int> value = TLMLineUtils.GetTicketPriceForLine(ref tsd, lineID);
         m_effectiveLabel.color = value.Second < 0 ? Color.gray : TLMTicketConfigTab.m_colorOrder[value.Second % TLMTicketConfigTab.m_colorOrder.Count];
         m_effectiveLabel.text  = (value.First.Value / 100f).ToString(Settings.moneyFormat, LocaleManager.cultureInfo);
     }
 }
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            if (lineID > 0)
            {
                m_showAbsoluteCheckbox.isVisible = TLMTransportLineExtension.Instance.IsUsingCustomConfig(lineID);
                m_showAbsoluteCheckbox.isChecked = TLMTransportLineExtension.Instance.IsDisplayAbsoluteValues(lineID);
                RebuildList(lineID);
            }
        }
Ejemplo n.º 15
0
 public void Update()
 {
     if (m_container.isVisible)
     {
         ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();
         m_minutePointer.transform.localEulerAngles = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour % 1 * -360) + 180);
         m_hourPointer.transform.localEulerAngles   = new Vector3(0, 0, (SimulationManager.instance.m_currentDayTimeHour / 24 * -360) + 180);
         Tuple <float, int, int, float> value = TLMLineUtils.GetBudgetMultiplierLineWithIndexes(lineID);
         m_effectiveSprite.color         = UVMBudgetConfigTab.m_colorOrder[value.Second % UVMBudgetConfigTab.m_colorOrder.Count];
         m_effectiveSprite.progressColor = UVMBudgetConfigTab.m_colorOrder[value.Third % UVMBudgetConfigTab.m_colorOrder.Count];
         m_effectiveSprite.value         = value.Fourth;
         int currentVehicleCount = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].CountVehicles(lineID);
         int targetVehicleCount  = TransportLineOverrides.NewCalculateTargetVehicleCount(lineID);
         m_effectiveLabel.prefix = (value.First * 100).ToString("0");
         m_effectiveLabel.suffix = $"{currentVehicleCount.ToString("0")}/{targetVehicleCount.ToString("0")}";
     }
 }
Ejemplo n.º 16
0
        private void BindFields(PublicTransportWorldInfoPanel ptwip)
        {
            LogUtils.DoLog("COLOR");
            UIComponent parentToDestroy = ptwip.Find <UILabel>("Color").parent.parent;

            m_lineColorContainer = RebindUI(ptwip.Find <UILabel>("Color").parent);
            m_colorField         = component.Find <UIColorField>("ColorField");
            m_colorFieldButton   = m_colorField.Find <UIButton>("Button");

            LogUtils.DoLog("CHART");
            m_ageChart     = (ptwip.Find <UIRadialChart>("AgeChart"));
            m_childLegend  = (ptwip.Find <UILabel>("ChildAmount"));
            m_teenLegend   = (ptwip.Find <UILabel>("TeenAmount"));
            m_youngLegend  = (ptwip.Find <UILabel>("YoungAmount"));
            m_adultLegend  = (ptwip.Find <UILabel>("AdultAmount"));
            m_seniorLegend = (ptwip.Find <UILabel>("SeniorAmount"));
            UIComponent parentToDestroy2 = m_ageChart.parent.parent;

            m_ageChartContainer = RebindUI(m_ageChart.parent);

            LogUtils.DoLog("TRIP");
            m_tripSaved          = (ptwip.Find <UILabel>("TripSaved"));
            m_tripSavedContainer = RebindUI(m_tripSaved.parent);


            LogUtils.DoLog("TYPE");
            m_type          = (ptwip.Find <UILabel>("Type"));
            m_typeContainer = RebindUI(m_type.parent);

            LogUtils.DoLog("PASSENGERS");
            m_passengers          = (ptwip.Find <UILabel>("Passengers"));
            m_passengersContainer = RebindUI(m_passengers.parent);

            LogUtils.DoLog("LENGTH");
            m_lineLengthLabel = RebindUI(ptwip.Find <UILabel>("LineLengthLabel"));

            LogUtils.DoLog("WALKING");
            m_pullValuePanel     = RebindUI(ptwip.Find <UIPanel>("WalkingTourPullValuePanel"));
            m_pullValue          = (component.Find <UILabel>("PullValue"));
            m_warningTooLongText = (component.Find <UILabel>("WarningTooLongText"));
            m_warningTooLongIcon = (component.Find <UISprite>("WarningTooLongIcon"));

            LogUtils.DoLog("DESTROY");
            UVMPublicTransportWorldInfoPanel.FakeDestroy(parentToDestroy);
            UVMPublicTransportWorldInfoPanel.FakeDestroy(parentToDestroy2);
        }
Ejemplo n.º 17
0
 public void UpdateBindings(bool showDayTime)
 {
     if (m_bg.isVisible)
     {
         List <D> report    = GetReportData(UVMPublicTransportWorldInfoPanel.GetLineID());
         var      totalizer = new D();
         for (int i = 0; i < m_reportLines.Length; i++)
         {
             m_reportLines[i].SetData(report[16 - i], showDayTime, TLMController.IsRealTimeEnabled);
             if (i > 0)
             {
                 AddToTotalizer(ref totalizer, report[16 - i]);
             }
         }
         m_aggregateLine.SetDataTotalizer(totalizer);
     }
 }
Ejemplo n.º 18
0
        public void OnSetTarget(Type source)
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            m_firstStopSelect.items         = TLMLineUtils.getAllStopsFromLine(lineID);
            m_firstStopSelect.selectedIndex = 0;
            if (source == GetType())
            {
                return;
            }

            if (lineID != 0)
            {
                m_colorField.selectedColor = Singleton <TransportManager> .instance.GetLineColor(lineID);

                LineType lineType = UVMPublicTransportWorldInfoPanel.GetLineType(lineID);
                m_weeklyPassengersString   = ((lineType != LineType.WalkingTour) ? "TRANSPORT_LINE_PASSENGERS" : "TRANSPORT_LINE_PASSENGERS_WALKINGTOUR");
                m_ageChart.tooltipLocaleID = ((lineType != LineType.WalkingTour) ? "PUBLICTRANSPORT_PASSENGERAGEGROUPS_TOOLTIP" : "PUBLICTRANSPORT_PASSENGERAGEGROUPS_TOOLTIP_WALKINGTOUR");
                m_tripSaved.isVisible      = (lineType == LineType.Default);
                m_pullValuePanel.isVisible = (lineType == LineType.WalkingTour);
                m_lineLengthLabel.text     = StringUtils.SafeFormat(Locale.Get("LINEINFOPANEL_LINELENGTH"), (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_totalLength / 1000f).ToString("F2", LocaleManager.cultureInfo));

                m_linePrefixDropDown.eventSelectedIndexChanged -= SaveLineNumber;
                m_lineNumberLabel.eventLostFocus -= SaveLineNumber;

                ref TransportLine t          = ref TransportManager.instance.m_lines.m_buffer[lineID];
                ushort            lineNumber = t.m_lineNumber;

                var tsd           = TransportSystemDefinition.GetDefinitionForLine(lineID);
                var transportType = tsd.ToConfigIndex();
                var mnPrefixo     = (ModoNomenclatura)TLMConfigWarehouse.GetCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);

                if (TLMLineUtils.hasPrefix(lineID))
                {
                    m_lineNumberLabel.maxLength  = 3;
                    m_lineNumberLabel.width      = 40;
                    m_lineNumberLabel.text       = (lineNumber % 1000).ToString();
                    m_linePrefixDropDown.enabled = false;

                    string[] temp = TLMUtils.GetStringOptionsForPrefix(tsd, true, true, false);
                    m_linePrefixDropDown.items         = temp;
                    m_linePrefixDropDown.selectedIndex = lineNumber / 1000;
                    m_linePrefixDropDown.enabled       = true;
                    bool invertPrefixSuffix = TLMConfigWarehouse.GetCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX | transportType);
                    if (invertPrefixSuffix)
                    {
                        m_linePrefixDropDown.zOrder = 9999;
                    }
                    else
                    {
                        m_lineNumberLabel.zOrder = 9999;
                    }
                }
                else
                {
                    m_lineNumberLabel.maxLength  = 4;
                    m_lineNumberLabel.width      = 180;
                    m_lineNumberLabel.text       = (lineNumber).ToString();
                    m_linePrefixDropDown.enabled = false;
                }



                m_lineNumberLabel.color = TransportManager.instance.GetLineColor(lineID);



                m_linePrefixDropDown.eventSelectedIndexChanged += SaveLineNumber;
                m_lineNumberLabel.eventLostFocus += SaveLineNumber;
            }
Ejemplo n.º 19
0
 internal void OnColorChanged(UIComponent comp, Color color) => UVMPublicTransportWorldInfoPanel.m_obj.origInstance.StartCoroutine(ChangeColorCoroutine(UVMPublicTransportWorldInfoPanel.GetLineID(), color));
Ejemplo n.º 20
0
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            TransportSystemDefinition tsd = TransportSystem;

            if (!tsd.HasVehicles())
            {
                MainPanel.isVisible = false;
                return;
            }
            m_isLoading = true;

            var           lineId        = GetLineID();
            List <ushort> cityDepotList = TLMDepotUtils.GetAllDepotsFromCity(tsd);

            Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            List <ushort> targetDepotList     = config.GetAllowedDepots(tsd, lineId);

            UIPanel[] depotChecks = m_checkboxTemplateList.SetItemCount(cityDepotList.Count);
            LogUtils.DoLog($"depotChecks = {depotChecks.Length}");
            for (int idx = 0; idx < cityDepotList.Count; idx++)
            {
                ushort     buildingID = cityDepotList[idx];
                UICheckBox uiCheck    = depotChecks[idx].GetComponentInChildren <UICheckBox>();
                uiCheck.objectUserData = buildingID;
                uiCheck.isChecked      = targetDepotList.Contains(buildingID);

                UILabel uilabel = uiCheck.label;

                uilabel.prefix = BuildingUtils.GetBuildingName(buildingID, out _, out _);
                ref Building depotBuilding = ref BuildingManager.instance.m_buildings.m_buffer[buildingID];
                Vector3      sidewalk      = depotBuilding.CalculateSidewalkPosition();
                TransportLinesManagerMod.Controller.ConnectorADR.GetAddressStreetAndNumber(sidewalk, depotBuilding.m_position, out int number, out string streetName);
                byte districtId = DistrictManager.instance.GetDistrict(sidewalk);
                uilabel.text = $"\n<color gray>{streetName}, {number} - {(districtId == 0 ? SimulationManager.instance.m_metaData.m_CityName : DistrictManager.instance.GetDistrictName(districtId))}</color>";



                if (uilabel.objectUserData == null)
                {
                    uiCheck.eventCheckChanged += (x, y) =>
                    {
                        if (!m_isLoading)
                        {
                            if (y)
                            {
                                TLMLineUtils.GetEffectiveExtensionForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).AddDepotForLine(UVMPublicTransportWorldInfoPanel.GetLineID(), (ushort)x.objectUserData);
                            }
                            else
                            {
                                TLMLineUtils.GetEffectiveExtensionForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).RemoveDepotForLine(UVMPublicTransportWorldInfoPanel.GetLineID(), (ushort)x.objectUserData);
                            }
                        }
                    };
                    KlyteMonoUtils.LimitWidthAndBox(uiCheck.label, 280, true);
                    UIButton gotoButton = depotChecks[idx].Find <UIButton>("GoTo");
                    gotoButton.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
                    {
                        ushort buildingId = (ushort)uiCheck.objectUserData;
                        if (buildingId != 0)
                        {
                            Vector3 position = BuildingManager.instance.m_buildings.m_buffer[buildingId].m_position;
                            ToolsModifierControl.cameraController.SetTarget(new InstanceID()
                            {
                                Building = buildingId
                            }, position, true);
                        }
                    };
                    uilabel.objectUserData = true;
                }
            }
Ejemplo n.º 21
0
 internal ushort GetLineID() => UVMPublicTransportWorldInfoPanel.GetLineID();
Ejemplo n.º 22
0
 internal LineType GetLineType(ushort lineID) => UVMPublicTransportWorldInfoPanel.GetLineType(lineID);
        private void RemoveTime(BudgetEntryXml entry)
        {
            TimeableList <BudgetEntryXml> config = TLMLineUtils.GetEffectiveConfigForLine(UVMPublicTransportWorldInfoPanel.GetLineID()).BudgetEntries;

            if (config != default)
            {
                config.RemoveAtHour(entry.HourOfDay ?? -1);
                m_isDirty = true;
            }
        }
Ejemplo n.º 24
0
 public override bool MayBeVisible() => TransportSystemDefinition.From(UVMPublicTransportWorldInfoPanel.GetLineID()).HasVehicles();
Ejemplo n.º 25
0
 public static bool OnLinesOverviewClicked()
 {
     TransportLinesManagerMod.Instance.OpenPanelAtModTab();
     TLMPanel.Instance.OpenAt(TransportSystemDefinition.From(UVMPublicTransportWorldInfoPanel.GetLineID()));
     return(false);
 }