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

            TLMLineUtils.GetEffectiveExtensionForLine(lineID).ClearTicketPricesOfLine(lineID);
            TLMTicketConfigTab.Instance.RebuildList(lineID);
        }
Exemplo n.º 2
0
        private void ActionDelete()
        {
            ushort lineID = UVMPublicTransportWorldInfoPanel.GetLineID();

            TLMLineUtils.GetEffectiveExtensionForLine(lineID).RemoveAllBudgetMultipliersOfLine(lineID);
            UVMBudgetConfigTab.Instance.RebuildList(lineID);
        }
Exemplo n.º 3
0
        public void SetRandomBuilding(ref TransportSystemDefinition tsd, ushort lineId, ref ushort currentId)
        {
            Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            List <ushort> allowedDepots       = config.GetAllowedDepots(ref tsd, lineId);

            if (allowedDepots.Count == 0 || allowedDepots.Contains(currentId))
            {
                if (TransportLinesManagerMod.DebugMode)
                {
                    TLMUtils.doLog("allowedDepots.Count --{0}-- == 0||  allowedDepots.Contains({1}): --{2}--  ", allowedDepots.Count, currentId, string.Join(",", allowedDepots.Select(x => x.ToString()).ToArray()));
                }

                return;
            }
            var r = new Randomizer(new System.Random().Next());

            if (TransportLinesManagerMod.DebugMode)
            {
                TLMUtils.doLog("DEPOT POSSIBLE VALUES FOR {2} LINE {1}: {0} ", string.Join(",", allowedDepots.Select(x => x.ToString()).ToArray()), lineId, tsd);
            }

            currentId = allowedDepots[r.Int32(0, allowedDepots.Count - 1)];
            if (TransportLinesManagerMod.DebugMode)
            {
                TLMUtils.doLog("DEPOT FOR {2} LINE {1}: {0} ", currentId, lineId, tsd);
            }
        }
Exemplo n.º 4
0
        private static VehicleInfo DoModelDraw(ushort lineId)
        {
            Interfaces.IBasicExtension extension = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            VehicleInfo randomInfo = extension.GetAModel(lineId);

            return(randomInfo);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        private void AddEntry()
        {
            ushort lineId = UVMPublicTransportWorldInfoPanel.GetLineID();

            Interfaces.IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(lineId);
            config.SetTicketPriceToLine(lineId, 0, 0);
            RebuildList(UVMPublicTransportWorldInfoPanel.GetLineID());
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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;
                }
            }
        public void OnSetTarget(Type source)
        {
            if (source == GetType())
            {
                return;
            }

            TransportSystemDefinition tsd = TransportSystem;

            if (!tsd.HasVehicles())
            {
                MainPanel.isVisible = false;
                return;
            }
            m_isLoading = true;
            LogUtils.DoLog("tsd = {0}", tsd);
            IBasicExtension config = TLMLineUtils.GetEffectiveExtensionForLine(GetLineID());

            if (TransportSystem != m_lastSystem)
            {
                m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssetsForLine(0);
                UIPanel[] depotChecks = m_checkboxTemplateList.SetItemCount(m_defaultAssets.Count);

                LogUtils.DoLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
                for (int i = 0; i < m_defaultAssets.Count; i++)
                {
                    string     assetName = m_defaultAssets.Keys.ElementAt(i);
                    UICheckBox checkbox  = depotChecks[i].GetComponentInChildren <UICheckBox>();
                    checkbox.objectUserData = assetName;
                    UITextField capacityEditor = depotChecks[i].GetComponentInChildren <UITextField>();
                    capacityEditor.text = VehicleUtils.GetCapacity(PrefabCollection <VehicleInfo> .FindLoaded(assetName)).ToString("0");
                    if (checkbox.label.objectUserData == null)
                    {
                        checkbox.eventCheckChanged += (x, y) =>
                        {
                            if (m_isLoading)
                            {
                                return;
                            }

                            ushort          lineId    = GetLineID();
                            IBasicExtension extension = TLMLineUtils.GetEffectiveExtensionForLine(lineId);

                            LogUtils.DoLog($"checkbox event: {x.objectUserData} => {y} at {extension}[{lineId}]");
                            if (y)
                            {
                                extension.AddAssetToLine(lineId, x.objectUserData.ToString());
                            }
                            else
                            {
                                extension.RemoveAssetFromLine(lineId, x.objectUserData.ToString());
                            }
                        };
                        CreateModelCheckBox(checkbox);
                        KlyteMonoUtils.LimitWidthAndBox(checkbox.label, 280);
                        capacityEditor.eventTextSubmitted += CapacityEditor_eventTextSubmitted;;

                        capacityEditor.eventMouseEnter += (x, y) =>
                        {
                            m_lastInfo = PrefabCollection <VehicleInfo> .FindLoaded(checkbox.objectUserData.ToString());

                            RedrawModel();
                        };
                        checkbox.label.objectUserData = true;
                    }
                    checkbox.text = m_defaultAssets[assetName];
                }
                m_lastSystem = TransportSystem;
            }
            else
            {
                List <string> allowedAssets = config.GetAssetListForLine(GetLineID());
                for (int i = 0; i < m_checkboxTemplateList.items.Count; i++)
                {
                    UICheckBox checkbox = m_checkboxTemplateList.items[i].GetComponentInChildren <UICheckBox>();
                    checkbox.isChecked = allowedAssets.Contains(checkbox.objectUserData.ToString());
                }
            }

            if (TransportLinesManagerMod.DebugMode)
            {
                List <string> allowedAssets = config.GetAssetListForLine(GetLineID());
                LogUtils.DoLog($"selectedAssets Size = {allowedAssets?.Count} ({ string.Join(",", allowedAssets?.ToArray() ?? new string[0])}) {config?.GetType()}");
            }

            if (config is TLMTransportLineConfiguration)
            {
                m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE"), TLMLineUtils.GetLineStringId(GetLineID()));
            }
            else
            {
                int prefix = (int)TLMPrefixesUtils.GetPrefix(GetLineID());
                m_title.text = string.Format(Locale.Get("K45_TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? NumberingUtils.GetStringFromNumber(TLMPrefixesUtils.GetStringOptionsForPrefix(tsd), prefix + 1) : Locale.Get("K45_TLM_UNPREFIXED"), tsd.GetTransportName());
            }

            m_isLoading = false;
        }