private static void Modify(string id, string oldValue, string newValue)
 {
     try
     {
         Dictionary <Locale.Key, string> dictionary = Utils.GetPrivate <Dictionary <Locale.Key, string> >((object)Utils.GetPrivate <Locale>((object)SingletonLite <LocaleManager> .instance, "m_Locale"), "m_LocalizedStrings");
         Locale.Key key = new Locale.Key()
         {
             m_Identifier = id
         };
         string str;
         if (!dictionary.TryGetValue(key, out str))
         {
             return;
         }
         dictionary[key] = str.Replace(oldValue, newValue);
     }
     catch (Exception ex)
     {
         Utils.LogWarning((object)("Unexpected " + ex.GetType().Name + " updating localization: " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine));
     }
 }
예제 #2
0
        private void Update()
        {
            if (!this._initialized)
            {
                this._cityServiceWorldInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>();
                if (!((UnityEngine.Object) this._cityServiceWorldInfoPanel != (UnityEngine.Object)null))
                {
                    return;
                }
                this.CreateStopsPanel();
                this._initialized = true;
            }
            else
            {
                if (!this._initialized || !this._cityServiceWorldInfoPanel.component.isVisible)
                {
                    return;
                }
                BuildingManager      instance1  = Singleton <BuildingManager> .instance;
                ushort               building   = Utils.GetPrivate <InstanceID>((object)this._cityServiceWorldInfoPanel, "m_InstanceID").Building;
                ItemClass.SubService subService = instance1.m_buildings.m_buffer[(int)building].Info.GetSubService();
                ItemClass.Service    service    = instance1.m_buildings.m_buffer[(int)building].Info.GetService();
                ItemClass.Level      level      = instance1.m_buildings.m_buffer[(int)building].Info.GetClassLevel();

                switch (subService)
                {
                case ItemClass.SubService.PublicTransportBus:
                case ItemClass.SubService.PublicTransportTours:
                case ItemClass.SubService.PublicTransportMetro:
                case ItemClass.SubService.PublicTransportTrain:
                case ItemClass.SubService.PublicTransportShip:
                case ItemClass.SubService.PublicTransportPlane:
                case ItemClass.SubService.PublicTransportMonorail:
                case ItemClass.SubService.PublicTransportTrolleybus:
                    this._vehicleListBox.Hide(); //TODO(earalov): display depot's vehicles? Also, maybe it makes sense to display list of lines served by depot?
                    this._stopsListBox.Show();
                    ushort[] numArray = PanelExtenderCityService.GetStationStops(building);
                    BuildingInfo.SubInfo[] subBuildings = instance1.m_buildings.m_buffer[(int)building].Info.m_subBuildings;
                    if (subBuildings != null && subBuildings.Length != 0)
                    {
                        Vector3 position = instance1.m_buildings.m_buffer[(int)building].m_position;
                        building = instance1.FindBuilding(position, 100f, ItemClass.Service.PublicTransport, ItemClass.SubService.None, Building.Flags.Untouchable, Building.Flags.None);
                        if ((int)building != 0)
                        {
                            ushort[] stationStops = PanelExtenderCityService.GetStationStops(building);
                            if (stationStops.Length != 0)
                            {
                                numArray = ((IEnumerable <ushort>)numArray).Concat <ushort>((IEnumerable <ushort>)stationStops).ToArray <ushort>();
                            }
                        }
                    }
                    int length = numArray.Length;
                    if (length > 0)
                    {
                        this._titleLabel.text = Localization.Get("CITY_SERVICE_PANEL_TITLE_STATION_STOPS");
                        this._listBoxPanel.relativePosition = new Vector3(this._listBoxPanel.parent.width + 1f, VerticalOffset);
                        this._listBoxPanel.Show();
                        if ((int)this._cachedBuildingID != (int)building || this._cachedStopCount != length)
                        {
                            this._stopsListBox.ClearItems();
                            for (int index = 0; index < length; ++index)
                            {
                                this._stopsListBox.AddItem(numArray[index], -1);
                            }
                        }
                    }
                    else
                    {
                        this._listBoxPanel.Hide();
                    }
                    this._cachedStopCount = length;
                    break;

                case ItemClass.SubService.PublicTransportTaxi:
                case ItemClass.SubService.PublicTransportCableCar:
                    this._vehicleListBox.Show();
                    this._stopsListBox.Hide();
                    UIPanel uiPanel = this._cityServiceWorldInfoPanel.Find <UIPanel>("SvsVehicleTypes");
                    if ((UnityEngine.Object)uiPanel != (UnityEngine.Object)null)
                    {
                        this._listBoxPanel.relativePosition = new Vector3((float)((double)this._listBoxPanel.parent.width + (double)uiPanel.width + 2.0), VerticalOffset);
                    }
                    List <ushort> depotVehicles = PanelExtenderCityService.GetDepotVehicles(building);
                    int           count         = depotVehicles.Count;
                    if (count > 0)
                    {
                        this._titleLabel.text = Localization.Get("CITY_SERVICE_PANEL_TITLE_DEPOT_VEHICLES");
                        this._listBoxPanel.Show();
                        if ((int)this._cachedBuildingID != (int)building || this._cachedVehicleCount != count)
                        {
                            this._vehicleListBox.ClearItems();
                            PrefabData[]   prefabs   = VehiclePrefabs.instance.GetPrefabs(service, subService, level);
                            VehicleManager instance2 = Singleton <VehicleManager> .instance;
                            foreach (ushort vehicleID in depotVehicles)
                            {
                                VehicleInfo info = instance2.m_vehicles.m_buffer[(int)vehicleID].Info;
                                for (int index = 0; index < prefabs.Length; ++index)
                                {
                                    PrefabData data = prefabs[index];
                                    if (info.name == data.ObjectName)
                                    {
                                        this._vehicleListBox.AddItem(data, vehicleID);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this._listBoxPanel.Hide();
                    }
                    this._cachedVehicleCount = count;
                    break;

                default:
                    this._listBoxPanel.Hide();
                    break;
                }
                this._cachedBuildingID = building;
            }
        }