public static void doAutomation(ushort lineID, TransportLine.Flags __state)
 {
     TLMUtils.doLog("OLD: " + __state + " ||| NEW: " + Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags);
     if (lineID > 0 && (__state & TransportLine.Flags.Complete) == TransportLine.Flags.None && (__state & TransportLine.Flags.Temporary) == TransportLine.Flags.None)
     {
         if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) != TransportLine.Flags.None &&
             (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & (TransportLine.Flags.Temporary)) == TransportLine.Flags.None)
         {
             if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED))
             {
                 TLMController.instance.AutoColor(lineID);
             }
             if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_NAME_ENABLED))
             {
                 TLMController.instance.AutoName(lineID);
             }
             TLMController.instance.LineCreationToolbox.incrementNumber();
             TLMTransportLineExtension.instance.SafeCleanEntry(lineID);
         }
     }
     if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None &&
         (Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags & TransportLine.Flags.CustomColor) != TransportLine.Flags.None
         )
     {
         Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_flags &= ~TransportLine.Flags.CustomColor;
     }
 }
Exemplo n.º 2
0
 private void loadLinesConfig()
 {
     if (cached_list == null)
     {
         cached_list = getValueFromString(TLMConfigWarehouse.getCurrentConfigString(TLMConfigWarehouse.ConfigIndex.VEHICLE_LINE));
     }
 }
Exemplo n.º 3
0
        private static void saveConfigForTransportType(TransportSystemDefinition tsd, Dictionary <ushort, List <uint> > value)
        {
            string depotList = getConfigStringFromDictionary(value);

            TLMConfigWarehouse.setCurrentConfigString(TLMConfigWarehouse.getConfigDepotPrefix(tsd), depotList);
            cached_lists[tsd] = value;
        }
Exemplo n.º 4
0
 private void saveSubcategoryList(bool global)
 {
     if (global == globalLoaded)
     {
         TLMConfigWarehouse loadedConfig;
         if (global)
         {
             loadedConfig = TLMConfigWarehouse.getConfig(TLMConfigWarehouse.GLOBAL_CONFIG_INDEX, TLMConfigWarehouse.GLOBAL_CONFIG_INDEX);
         }
         else
         {
             loadedConfig = TransportLinesManagerMod.instance.currentLoadedCityConfig;
         }
         var value = string.Join(PREFIX_COMMA, cached_prefixConfigList.Select(x => x.Key.ToString() + PREFIX_SEPARATOR + string.Join(PROPERTY_COMMA, x.Value.Select(y => y.Key.ToString() + PROPERTY_SEPARATOR + y.Value).ToArray())).ToArray());
         if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
         {
             TLMUtils.doLog("NEW VALUE ({0}): {1}", definition.ToString(), value);
         }
         loadedConfig.setString(configKeyForAssets, value);
         if (global)
         {
             cached_prefixConfigListGlobal = cached_prefixConfigList;
         }
         else
         {
             cached_prefixConfigListNonGlobal = cached_prefixConfigList;
         }
     }
     else
     {
         TLMUtils.doErrorLog("Trying to save a different global file subcategory list!!!");
     }
 }
Exemplo n.º 5
0
        public void load()
        {
            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("TLMStopsExtension.load()");
            }
            var file = TLMConfigWarehouse.getCurrentConfigString(CONFIG).Split(COMMA.ToCharArray());

            cached_list = new Dictionary <uint, Dictionary <Property, string> >();
            if (file.Length > 0)
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("TLMStopsExtension.load(): file.Length > 0");
                }
                foreach (string s in file)
                {
                    uint key   = getIndexFromStringArray(s);
                    var  value = TLMUtils.getValueFromStringArray <Property>(s, SEPARATOR, SUBCOMMA, SUBSEPARATOR);
                    cached_list[key] = value;
                }
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("TLMStopsExtension.load(): dic done");
                }
                cached_list.Remove(0);
            }
        }
        private void syncForm()
        {
            TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab);
            var configIdx = tsd.toConfigIndex();

            if (TLMLineUtils.hasPrefix(transportTool.m_prefab))
            {
                linePrefixDropDown.isVisible      = true;
                linePrefixDropDown.items          = TLMUtils.getPrefixesOptions(configIdx, false);
                linePrefixDropDown.selectedIndex  = getCurrentPrefix();
                lineNumberTxtBox.text             = getCurrentNumber().ToString();
                lineNumberTxtBox.width            = 90;
                lineNumberTxtBox.relativePosition = new Vector3(85f, 45f);
                lineNumberTxtBox.maxLength        = 3;
                prefixIncrementChk.isChecked      = TLMConfigWarehouse.getCurrentConfigBool(configIdx | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);
                prefixIncrementChk.isVisible      = true;
            }
            else
            {
                linePrefixDropDown.isVisible      = false;
                lineNumberTxtBox.text             = getCurrentNumber().ToString();
                lineNumberTxtBox.width            = 170;
                lineNumberTxtBox.relativePosition = new Vector3(5f, 45f);
                lineNumberTxtBox.maxLength        = 4;
                prefixIncrementChk.isVisible      = false;
            }
            updateUI();
        }
Exemplo n.º 7
0
        public static void removeAllUnwantedVehicles()
        {
            for (ushort lineId = 1; lineId < Singleton <TransportManager> .instance.m_lines.m_size; lineId++)
            {
                if ((Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].m_flags & TransportLine.Flags.Created) != TransportLine.Flags.None)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: line #{0}", lineId);
                    }
                    TransportLine tl     = Singleton <TransportManager> .instance.m_lines.m_buffer[lineId];
                    uint          prefix = 0;
                    if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(tl.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
                    {
                        prefix = tl.m_lineNumber / 1000u;
                    }
                    VehicleManager instance3 = Singleton <VehicleManager> .instance;
                    VehicleInfo    info      = instance3.m_vehicles.m_buffer[Singleton <TransportManager> .instance.m_lines.m_buffer[lineId].GetVehicle(0)].Info;
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: pre model list; type = {0}", info.GetAI());
                    }
                    var def = TransportSystemDefinition.from(info);
                    if (def == default(TransportSystemDefinition))
                    {
                        if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                        {
                            TLMUtils.doLog("NULL TSysDef! {0}+{1}+{2}", info.GetAI().GetType(), info.m_class.m_subService, info.m_vehicleType);
                        }
                        continue;
                    }
                    var modelList = BasicTransportExtensionSingleton.instance(def).getAssetListForPrefix(prefix);
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("removeAllUnwantedVehicles: models found: {0}", modelList == null ? "?!?" : modelList.Count.ToString());
                    }
                    if (modelList.Count > 0)
                    {
                        Dictionary <ushort, VehicleInfo> vehiclesToRemove = new Dictionary <ushort, VehicleInfo>();
                        for (int i = 0; i < tl.CountVehicles(lineId); i++)
                        {
                            var vehicle = tl.GetVehicle(i);
                            if (vehicle != 0)
                            {
                                VehicleInfo info2 = instance3.m_vehicles.m_buffer[(int)vehicle].Info;
                                if (!modelList.Contains(info2.name))
                                {
                                    vehiclesToRemove[vehicle] = info2;
                                }
                            }
                        }

                        foreach (var item in vehiclesToRemove)
                        {
                            item.Value.m_vehicleAI.SetTransportLine(item.Key, ref instance3.m_vehicles.m_buffer[item.Key], 0);
                        }
                    }
                }
            }
        }
        public void incrementNumber()
        {
            //TLMUtils.doLog("Increment Toolbox num");
            TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab);
            int  num = nextLineNumber;
            bool prefixIncrementVal = TLMConfigWarehouse.getCurrentConfigBool(tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);

            //TLMUtils.doLog("prefixIncrement = " + prefixIncrementVal + "| num = " + num);
            while (((num + 1) & 0xFFFF) == 0 || TLMLineUtils.isNumberUsed((num + 1) & 0xFFFF, tsd, 0))
            {
                if (!TLMLineUtils.hasPrefix(transportTool.m_prefab) || !prefixIncrementVal)
                {
                    num++;
                }
                else
                {
                    num++;
                    num /= 1000;
                    num++;
                    num &= 0x4F;
                    num *= 1000;
                    num--;
                }
            }
            nextLineNumber = (ushort)num;
            syncForm();
        }
 public override void Group9SettingsUI(UIHelperExtension group9)
 {
     group9.AddButton(Locale.Get("K45_TLM_DRAW_CITY_MAP"), TLMMapDrawer.DrawCityMap);
     group9.AddButton("Open generated map folder", () => ColossalFramework.Utils.OpenInFileBrowser(TLMController.ExportedMapsFolder));
     group9.AddSpace(2);
     group9.AddButton(Locale.Get("K45_TLM_RELOAD_DEFAULT_CONFIGURATION"), () =>
     {
         TLMBaseConfigXML.ReloadGlobalFile();
         TLMConfigOptions.instance.ReloadData();
     });
     if (IsCityLoaded)
     {
         group9.AddButton(Locale.Get("K45_TLM_SAVE_CURRENT_CITY_CONFIG_AS_DEFAULT"), () =>
         {
             TLMBaseConfigXML.Instance.ExportAsGlobalConfig();
             TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
             TLMConfigOptions.instance.ReloadData();
         });
         group9.AddButton(Locale.Get("K45_TLM_LOAD_DEFAULT_AS_CURRENT_CITY_CONFIG"), () =>
         {
             TLMBaseConfigXML.Instance.LoadFromGlobal();
             TLMConfigOptions.instance.ReloadData();
         });
     }
     else
     {
         group9.AddButton(Locale.Get("K45_TLM_SAVE_CURRENT_CITY_CONFIG_AS_DEFAULT"), TLMBaseConfigXML.GlobalFile.ExportAsGlobalConfig);
     }
     TLMConfigOptions.instance.ReloadData();
     base.Group9SettingsUI(group9);
 }
Exemplo n.º 10
0
        private void updateSliders()
        {
            if (TLMSingleton.isIPTLoaded)
            {
                m_lineBudgetSlidersTitle.parent.isVisible = false;
                return;
            }


            TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex();
            ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);

            uint[] multipliers;
            IBudgetableExtension bte;
            uint idx;

            var tsdRef = tsd;

            idx         = (uint)SelectedPrefix;
            bte         = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
            multipliers = bte.GetBudgetsMultiplier(idx);

            m_lineBudgetSlidersTitle.text = string.Format(Locale.Get("TLM_BUDGET_MULTIPLIER_TITLE_PREFIX"), idx > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)idx + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsdRef.toConfigIndex()));


            bool budgetPerHourEnabled = multipliers.Length == 8;

            m_disableBudgetPerHour.isVisible = budgetPerHourEnabled;
            m_enableBudgetPerHour.isVisible  = !budgetPerHourEnabled && tsdRef.hasVehicles();
            for (int i = 0; i < m_budgetSliders.Length; i++)
            {
                UILabel budgetSliderLabel = m_budgetSliders[i].transform.parent.GetComponentInChildren <UILabel>();
                if (i == 0)
                {
                    if (multipliers.Length == 1)
                    {
                        budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL_ALL");
                    }
                    else
                    {
                        budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL", 0);
                    }
                }
                else
                {
                    m_budgetSliders[i].isEnabled        = budgetPerHourEnabled;
                    m_budgetSliders[i].parent.isVisible = budgetPerHourEnabled;
                }

                if (i < multipliers.Length)
                {
                    m_budgetSliders[i].value = multipliers[i] / 100f;
                }
            }
        }
Exemplo n.º 11
0
        private void saveStops()
        {
            TLMConfigWarehouse loadedConfig = TransportLinesManagerMod.instance.currentLoadedCityConfig;
            var value = string.Join(COMMA, cached_list.Select(x => x.Key.ToString() + SEPARATOR + string.Join(SUBCOMMA, x.Value.Select(y => string.Format("{0}{1}{2}", y.Key.ToString(), SUBSEPARATOR, y.Value)).ToArray())).ToArray());

            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("saveStops NEW VALUE: {0}", value);
            }
            loadedConfig.setString(TLMConfigWarehouse.ConfigIndex.STOPS_CONFIG, value);
        }
Exemplo n.º 12
0
        private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category)
        {
            TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40));
            var effectiveOffsetY = strip.height;

            TLMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width, parent.height - effectiveOffsetY - 10, category.isScrollable());

            foreach (var kv in TransportSystemDefinition.sysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value);
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }

                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.toConfigIndex();
                String     name      = kv.Value.Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                String   bgIcon    = TLMConfigWarehouse.getBgIconForIndex(configIdx);
                String   fgIcon    = kv.Key.getTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, components);
            }
        }
 private static void redrawMap(ToolStatus __state)
 {
     if (__state.m_lineCurrent > 0 || (Singleton <TransportManager> .instance.m_lines.m_buffer[TLMController.instance.CurrentSelectedId].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None)
     {
         TLMController.instance.setCurrentSelectedId(__state.m_lineCurrent);
         if (__state.m_lineCurrent > 0 && TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED))
         {
             TLMController.instance.AutoColor(__state.m_lineCurrent, true, true);
         }
     }
 }
Exemplo n.º 14
0
 private static Dictionary <ushort, List <uint> > getConfigForTransportType(TransportSystemDefinition tsd)
 {
     if (!cached_lists.ContainsKey(tsd))
     {
         string depotList = TLMConfigWarehouse.getCurrentConfigString(TLMConfigWarehouse.getConfigDepotPrefix(tsd));
         if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
         {
             TLMUtils.doLog("getConfigForTransportType STRING FOR {0}: {1}", tsd.ToString(), depotList);
         }
         cached_lists[tsd] = getDictionaryFromConfigString(depotList, tsd);
     }
     return(cached_lists[tsd]);
 }
Exemplo n.º 15
0
        public override void Group9SettingsUI(UIHelperExtension group9)
        {
            TLMConfigOptions.instance.generateNumberFieldConfig(group9, Locale.Get("K45_TLM_MAXIMUM_VEHICLE_COUNT_FOR_SPECIFIC_LINE_CONFIG"), TLMConfigWarehouse.ConfigIndex.MAX_VEHICLES_SPECIFIC_CONFIG).maxLength = 3;

            group9.AddButton(Locale.Get("K45_TLM_DRAW_CITY_MAP"), TLMMapDrawer.drawCityMap);
            group9.AddButton("Open generated map folder", () => ColossalFramework.Utils.OpenInFileBrowser(TLMController.exportedMapsFolder));
            group9.AddSpace(2);
            group9.AddButton(Locale.Get("K45_TLM_RELOAD_DEFAULT_CONFIGURATION"), () =>
            {
                TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                TLMConfigOptions.instance.ReloadData();
            });
            if (IsCityLoaded)
            {
                group9.AddButton(Locale.Get("K45_TLM_EXPORT_CITY_CONFIG"), () =>
                {
                    string path = TLMConfigOptions.instance.currentLoadedCityConfig.Export();
                    ConfirmPanel.ShowModal(Name, string.Format(Locale.Get("K45_TLM_FILE_EXPORTED_TO_TEMPLATE"), path), (x, y) =>
                    {
                        if (y == 1)
                        {
                            ColossalFramework.Utils.OpenInFileBrowser(path);
                        }
                    });
                });
                group9.AddButton(Locale.Get("K45_TLM_IMPORT_CITY_CONFIG"), () =>
                {
                    ConfirmPanel.ShowModal(Name, string.Format(Locale.Get("K45_TLM_FILE_WILL_BE_IMPORTED_TEMPLATE"), TLMConfigOptions.instance.currentLoadedCityConfig.ThisPath), (x, y) =>
                    {
                        if (y == 1)
                        {
                            TLMConfigOptions.instance.currentLoadedCityConfig.ReloadFromDisk();
                            TLMConfigOptions.instance.ReloadData();
                        }
                    });
                });
                group9.AddButton(Locale.Get("K45_TLM_SAVE_CURRENT_CITY_CONFIG_AS_DEFAULT"), () =>
                {
                    TLMConfigOptions.instance.currentLoadedCityConfig.SaveAsDefault();
                    TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                    TLMConfigOptions.instance.ReloadData();
                });
                group9.AddButton(Locale.Get("K45_TLM_LOAD_DEFAULT_AS_CURRENT_CITY_CONFIG"), () =>
                {
                    TLMConfigOptions.instance.currentLoadedCityConfig.LoadFromDefault();
                    TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                    TLMConfigOptions.instance.ReloadData();
                });
            }
        }
Exemplo n.º 16
0
        public static bool isLineNamingEnabled(this TLMConfigWarehouse.ConfigIndex idx)
        {
            switch (idx)
            {
            case TLMConfigWarehouse.ConfigIndex.ADDRESS_NAME_CONFIG:
                return(true);

            case TLMConfigWarehouse.ConfigIndex.RESIDENTIAL_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.COMMERCIAL_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.INDUSTRIAL_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.NATURAL_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.UNUSED2_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.CITIZEN_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TOURISM_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.OFFICE_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.ROAD_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.ELECTRICITY_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.WATER_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.BEAUTIFICATION_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.GARBAGE_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.HEALTHCARE_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.POLICEDEPARTMENT_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.EDUCATION_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.MONUMENT_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.FIREDEPARTMENT_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_SERVICE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.DISASTER_SERVICE_CONFIG:
                return(TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.USE_FOR_AUTO_NAMING_REF | idx));

            case TLMConfigWarehouse.ConfigIndex.PLANE_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.BUS_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.METRO_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TRAIN_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TRAM_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.CABLE_CAR_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.MONORAIL_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.BLIMP_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.FERRY_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.SHIP_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TAXI_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.BALLOON_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TOUR_BUS_CONFIG:
            case TLMConfigWarehouse.ConfigIndex.TOUR_PED_CONFIG:
                return(TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.PUBLICTRANSPORT_USE_FOR_AUTO_NAMING_REF | idx));

            default:
                return(false);
            }
        }
Exemplo n.º 17
0
        private void CreateTsdTabstrip()
        {
            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false);

            foreach (KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = ReflectionUtils.GetImplementationForGenericType(typeof(UVMLinesPanel <>), kv.Value().GetType());
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }
                TransportSystemDefinition tsd = kv.Key;
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.ToConfigIndex();
                string     name      = kv.Value().GetType().Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true);
                string   fgIcon    = kv.Key.GetTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                m_stripMain.AddTab(name, tab, body, components);
            }
        }
Exemplo n.º 18
0
        public void Awake()
        {
            m_parent = GetComponentInParent <UIComponent>();
            var group72 = new UIHelperExtension(m_parent.GetComponentInChildren <UIScrollablePanel>());

            ((UIScrollablePanel)group72.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIScrollablePanel)group72.Self).wrapLayout          = true;
            ((UIScrollablePanel)group72.Self).width = 730;

            group72.AddLabel(Locale.Get("K45_TLM_DEFAULT_COST_PER_PASSENGER"));
            group72.AddSpace(15);

            foreach (TLMConfigWarehouse.ConfigIndex ci in TLMConfigWarehouse.configurableTicketTransportCategories)
            {
                UITextField textField      = TLMConfigOptions.instance.generateNumberFieldConfig(group72, TLMConfigWarehouse.getNameForTransportType(ci), TLMConfigWarehouse.ConfigIndex.DEFAULT_COST_PER_PASSENGER_CAPACITY | ci);
                UIPanel     textFieldPanel = textField.GetComponentInParent <UIPanel>();
                textFieldPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                textFieldPanel.autoFitChildrenVertically = true;
                UILabel label = textFieldPanel.GetComponentInChildren <UILabel>();
                label.minimumSize = new Vector2(420, 0);
                KlyteMonoUtils.LimitWidth(label);
                if (TLMConfigWarehouse.IsCityLoaded)
                {
                    label.eventVisibilityChanged += (x, y) =>
                    {
                        if (y)
                        {
                            float defaultCost = TLMConfigWarehouse.GetTransportSystemDefinitionForConfigTransport(ci).GetDefaultPassengerCapacityCost();
                            if (defaultCost >= 0)
                            {
                                label.suffix = $" ({(defaultCost).ToString("C3", LocaleManager.cultureInfo)})";
                            }
                            else
                            {
                                label.suffix        = $" (N/A)";
                                textField.isVisible = false;
                            }
                        }
                    };
                }
                group72.AddSpace(2);
            }
        }
        private void loadPrefixes(int sel)
        {
            if (sel == 0)
            {
                m_prefixSelection.isVisible         = false;
                m_prefixSelection.selectedIndex     = 0;
                m_StripAsteriskTab.tabPages.enabled = false;
                return;
            }
            m_prefixSelection.isVisible         = true;
            m_StripAsteriskTab.tabPages.enabled = false;
            TLMConfigWarehouse.ConfigIndex transportIndex = getConfigIndexFromDropDownSelection(sel);
            m_defaultAssets.itemsList  = getBasicAssetListFromDropDownSelection(m_systemTypeDropDown.selectedIndex);
            m_defaultAssets.root.color = TLMConfigWarehouse.getColorForTransportType(transportIndex);
            var m = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(transportIndex | TLMConfigWarehouse.ConfigIndex.PREFIX);

            m_prefixSelection.items         = TLMUtils.getStringOptionsForPrefix(m, true, transportIndex);
            m_prefixSelection.selectedIndex = 0;
        }
Exemplo n.º 20
0
        public Dictionary <uint, Dictionary <T, string> > LoadConfig(TLMConfigWarehouse.ConfigIndex idx, bool global = false)
        {
            var result = new Dictionary <uint, Dictionary <T, string> >();

            if (TLMSingleton.instance != null && TLMSingleton.debugMode)
            {
                TLMUtils.doLog("{0} load()", idx);
            }
            string[] itemListLvl1;
            if (global && !AllowGlobal)
            {
                throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER CARREGADA COMO GLOBAL: " + typeof(U));
            }
            if (global)
            {
                itemListLvl1 = TLMConfigWarehouse.getConfig().getString(idx).Split(ItSepLvl1.ToCharArray());
            }
            else
            {
                itemListLvl1 = TLMConfigWarehouse.getCurrentConfigString(idx).Split(ItSepLvl1.ToCharArray());
            }

            if (itemListLvl1.Length > 0)
            {
                if (TLMSingleton.instance != null && TLMSingleton.debugMode)
                {
                    TLMUtils.doLog("{0} load(): file.Length > 0", idx);
                }
                foreach (string s in itemListLvl1)
                {
                    uint key   = GetIndexFromStringArray(s);
                    var  value = GetValueFromStringArray(s);
                    result[key] = value;
                }
                if (TLMSingleton.instance != null && TLMSingleton.debugMode)
                {
                    TLMUtils.doLog("{0} load(): dic done", idx);
                }
                result.Remove(~0u);
            }
            return(result);
        }
Exemplo n.º 21
0
 private static VehicleInfo doModelDraw(TransportLine t)
 {
     if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(t.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
     {
         uint prefix = t.m_lineNumber / 1000u;
         var  def    = TransportSystemDefinition.from(t.Info.m_class.m_subService, t.Info.m_vehicleType);
         if (def == default(TransportSystemDefinition))
         {
             if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
             {
                 TLMUtils.doLog("NULL TSysDef! {0}+{1}", t.Info.m_class.m_subService, t.Info.m_vehicleType);
             }
             return(null);
         }
         BasicTransportExtension extension = TLMUtils.getExtensionFromTransportSystemDefinition(def);
         var randomInfo = extension.getRandomModel(prefix);
         return(randomInfo);
     }
     return(null);
 }
 private void updateDepotEditShortcutButton(UIComponent parent)
 {
     if (parent != null)
     {
         UIButton depotShortcut = parent.Find <UIButton>("TLMDepotShortcut");
         if (!depotShortcut)
         {
             depotShortcut = initDepotShortcutOnWorldInfoPanel(parent);
         }
         var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic
                                                    | System.Reflection.BindingFlags.Instance);
         ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building;
         if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info.GetAI() is DepotAI ai)
         {
             byte          count = 0;
             List <string> lines = new List <string>();
             if (ai.m_transportInfo != null && ai.m_maxVehicleCount > 0 && TransportSystemDefinition.from(ai.m_transportInfo).isPrefixable())
             {
                 lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_transportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(buildingId, false)));
                 count++;
             }
             if (ai.m_secondaryTransportInfo != null && ai.m_maxVehicleCount2 > 0 && TransportSystemDefinition.from(ai.m_secondaryTransportInfo).isPrefixable())
             {
                 lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_secondaryTransportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(buildingId, true)));
                 count++;
             }
             depotShortcut.isVisible = count > 0;
             if (depotShortcut.isVisible)
             {
                 UILabel label = depotShortcut.GetComponentInChildren <UILabel>();
                 label.text = string.Join("\n", lines.ToArray());
             }
         }
         else
         {
             depotShortcut.isVisible = false;
         }
     }
 }
Exemplo n.º 23
0
        private void Awake()
        {
            instance                      = this;
            mainPanel                     = GetComponent <UIPanel>();
            mainPanel.autoLayout          = true;
            mainPanel.autoLayoutDirection = LayoutDirection.Vertical;
            m_uiHelper                    = new UIHelperExtension(mainPanel);

            var transportType = m_tsd.ToConfigIndex();


            m_uiHelper.AddLabel(string.Format(Locale.Get("K45_TLM_CONFIGS_FOR"), TLMConfigWarehouse.getNameForTransportType(transportType)));
            UIPanel panel = m_uiHelper.Self.GetComponentInParent <UIPanel>();

            ((UIPanel)m_uiHelper.Self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIPanel)m_uiHelper.Self).backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MenuPanel_color);
            ((UIPanel)m_uiHelper.Self).wrapLayout          = true;
            ((UIPanel)m_uiHelper.Self).padding             = new RectOffset(10, 10, 10, 15);
            ((UIPanel)m_uiHelper.Self).color = TLMConfigWarehouse.getColorForTransportType(transportType);
            ((UIPanel)m_uiHelper.Self).width = 730;
            m_uiHelper.AddSpace(30);
            prefixDD           = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_PREFIX"), m_tlmCo.namingOptionsPrefixo, transportType | TLMConfigWarehouse.ConfigIndex.PREFIX);
            separatorContainer = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SEPARATOR"), m_tlmCo.namingOptionsSeparador, transportType | TLMConfigWarehouse.ConfigIndex.SEPARATOR).transform.parent.GetComponent <UIPanel>();
            suffixDD           = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_SUFFIX"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.SUFFIX);
            suffixDDContainer  = suffixDD.transform.parent.GetComponent <UIPanel>();
            nonPrefixDD        = m_tlmCo.generateDropdownConfig(m_uiHelper, Locale.Get("K45_TLM_IDENTIFIER_NON_PREFIXED"), m_tlmCo.namingOptionsSufixo, transportType | TLMConfigWarehouse.ConfigIndex.NON_PREFIX);
            paletteContainer   = m_tlmCo.generateDropdownStringValueConfig(m_uiHelper, Locale.Get("K45_TLM_PALETTE"), TLMAutoColorPalettes.paletteList, transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_MAIN).transform.parent.GetComponent <UIPanel>();
            m_tlmCo.generateDropdownEnumStringValueConfig <LineIconSpriteNames>(m_uiHelper, Locale.Get("K45_TLM_ICON"), TLMLineIconExtension.getDropDownOptions(), transportType | TLMConfigWarehouse.ConfigIndex.TRANSPORT_ICON_TLM);
            zerosContainer          = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LEADING_ZEROS_SUFFIX"), transportType | TLMConfigWarehouse.ConfigIndex.LEADING_ZEROS);
            prefixAsSuffixContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_INVERT_PREFIX_SUFFIX_ORDER"), transportType | TLMConfigWarehouse.ConfigIndex.INVERT_PREFIX_SUFFIX);
            m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_RANDOM_ON_PALETTE_OVERFLOW"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_RANDOM_ON_OVERFLOW);
            autoColorBasedContainer = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_AUTO_COLOR_BASED_ON_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PALETTE_PREFIX_BASED);
            prefixIncrement         = m_tlmCo.generateCheckboxConfig(m_uiHelper, Locale.Get("K45_TLM_LINENUMBERING_BASED_IN_PREFIX"), transportType | TLMConfigWarehouse.ConfigIndex.PREFIX_INCREMENT);

            prefixDD.eventSelectedIndexChanged += OnPrefixOptionChange;
            suffixDD.eventSelectedIndexChanged += OnSuffixOptionChange;
            OnPrefixOptionChange(prefixDD, prefixDD.selectedIndex);
        }
Exemplo n.º 24
0
        protected void SaveConfig(Dictionary <uint, Dictionary <T, string> > target, TLMConfigWarehouse.ConfigIndex idx, bool global = false)
        {
            TLMConfigWarehouse loadedConfig;

            if (global && !AllowGlobal)
            {
                throw new Exception("CONFIGURAÇÂO NÃO GLOBAL TENTOU SER SALVA COMO GLOBAL: " + typeof(U));
            }
            if (global)
            {
                loadedConfig = TLMConfigWarehouse.getConfig(TLMConfigWarehouse.GLOBAL_CONFIG_INDEX, TLMConfigWarehouse.GLOBAL_CONFIG_INDEX);
            }
            else
            {
                loadedConfig = TLMSingleton.instance.currentLoadedCityConfig;
            }
            var value = RecursiveEncode(target);

            if (TLMSingleton.instance != null && TLMSingleton.debugMode)
            {
                TLMUtils.doLog("saveConfig ({0}) NEW VALUE: {1}", idx, value);
            }
            loadedConfig.setString(idx, value);
        }
Exemplo n.º 25
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;
            }
Exemplo n.º 26
0
        public void RefreshData(bool updateColors, bool updateVisibility)
        {
            if (this.m_LineOperation == null || this.m_LineOperation.completedOrFailed)
            {
                TLMLineUtils.getLineActive(ref Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID], out bool dayActive, out bool nightActive);
                bool zeroed;
                unchecked
                {
                    zeroed = (Singleton <TransportManager> .instance.m_lines.m_buffer[m_LineID].m_flags & (TransportLine.Flags)TLMTransportLineFlags.ZERO_BUDGET_CURRENT) != 0;
                }
                if (!dayActive || !nightActive || zeroed)
                {
                    m_LineColor.normalBgSprite = zeroed ? "NoBudgetIcon" : dayActive ? "DayIcon" : nightActive ? "NightIcon" : "DisabledIcon";
                }
                else
                {
                    m_LineColor.normalBgSprite = "";
                }

                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);
            }
            else
            {
                m_LineColor.normalBgSprite = "DisabledIcon";
            }
            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;

            var tsd = Singleton <T> .instance.GetTSD();

            if (TLMConfigWarehouse.getCurrentConfigInt(tsd.toConfigIndex() | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
            {
                prefix = Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_lineNumber / 1000u;
            }


            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_LinePassengers.tooltip = string.Format("{0}", LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[]
            {
                averageCount,
                averageCount2
            }));
            TLMLineUtils.setLineNumberCircleOnRef(lineID, m_LineNumberFormatted, 0.8f);
            m_LineColor.normalFgSprite = TLMLineUtils.getIconForLine(lineID);

            this.m_PassengerCount = averageCount + averageCount2;

            this.m_lineIncompleteWarning.isVisible = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Complete) == TransportLine.Flags.None);

            if (updateColors)
            {
                this.m_LineColor.selectedColor = Singleton <TransportManager> .instance.GetLineColor(this.m_LineID);
            }
            if (updateVisibility)
            {
                this.m_LineIsVisible.isChecked = ((Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_flags & TransportLine.Flags.Hidden) == TransportLine.Flags.None);
            }


            if (tsd.hasVehicles())
            {
                TransportInfo info          = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].Info;
                float         overallBudget = Singleton <EconomyManager> .instance.GetBudget(info.m_class) / 100f;

                string vehTooltip = string.Format("{0} {1}", this.m_LineVehicles.text, Locale.Get("PUBLICTRANSPORT_VEHICLES"));
                this.m_LineVehicles.tooltip = vehTooltip;
                if (!TLMTransportLineExtension.instance.IsUsingCustomConfig(this.lineID) || !TLMTransportLineExtension.instance.IsUsingAbsoluteVehicleCount(this.lineID))
                {
                    this.m_lineBudgetLabel.text = string.Format("{0:0%}", TLMLineUtils.getEffectiveBugdet(lineID));//585+1/7 = frames/week
                    m_lineBudgetLabel.tooltip   = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN_2"),
                                                                TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()),
                                                                overallBudget, Singleton <TransportManager> .instance.m_lines.m_buffer[lineID].m_budget / 100f, TLMLineUtils.getEffectiveBugdet(lineID));
                    m_lineBudgetLabel.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 19, 0);
                    m_lineBudgetLabel.isVisible        = true;
                }
                else
                {
                    m_lineBudgetLabel.isVisible = false;
                }


                bool tlmPerHour = TLMLineUtils.isPerHourBudget(m_LineID);
                m_DayLine.isVisible           = !tlmPerHour;
                m_DayNightLine.isVisible      = !tlmPerHour;
                m_NightLine.isVisible         = !tlmPerHour;
                m_DisabledLine.isVisible      = !tlmPerHour;
                m_perHourBudgetInfo.isVisible = tlmPerHour;

                m_perHourBudgetInfo.relativePosition = new Vector3(615, 2);
            }
            else
            {
                m_DayLine.isVisible      = true;
                m_DayNightLine.isVisible = true;
                m_NightLine.isVisible    = true;
                m_DisabledLine.isVisible = true;
            }
        }
Exemplo n.º 27
0
        public void updateBidings()
        {
            ushort        lineID         = m_lineIdSelecionado.TransportLine;
            TransportLine tl             = Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID];
            TransportInfo info           = tl.Info;
            int           turistas       = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_touristPassengers.m_averageCount;
            int           residentes     = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_residentPassengers.m_averageCount;
            int           residentesPorc = residentes;

            if (residentesPorc == 0)
            {
                residentesPorc = 1;
            }
            int criancas         = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_childPassengers.m_averageCount;
            int adolescentes     = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_teenPassengers.m_averageCount;
            int jovens           = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_youngPassengers.m_averageCount;
            int adultos          = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_adultPassengers.m_averageCount;
            int idosos           = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_seniorPassengers.m_averageCount;
            int motoristas       = (int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)lineID].m_passengers.m_carOwningPassengers.m_averageCount;
            int veiculosLinha    = TLMLineUtils.GetVehiclesCount(lineID);
            int porcCriancas     = (criancas * 100 / residentesPorc);
            int porcAdolescentes = (adolescentes * 100 / residentesPorc);
            int porcJovens       = (jovens * 100 / residentesPorc);
            int porcAdultos      = (adultos * 100 / residentesPorc);
            int porcIdosos       = (idosos * 100 / residentesPorc);
            int soma             = porcCriancas + porcAdolescentes + porcJovens + porcAdultos + porcIdosos;

            if (soma != 0 && soma != 100)
            {
                porcAdultos = 100 - (porcCriancas + porcAdolescentes + porcJovens + porcIdosos);
            }
            agesPanel.SetValues(new int[]
            {
                porcCriancas,
                porcAdolescentes,
                porcJovens,
                porcAdultos,
                porcIdosos
            });
            passageirosEturistasLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_PASSENGERS", new object[]
            {
                residentes,
                turistas
            });

            int viagensSalvas      = 0;
            int coeficienteViagens = 0;

            if (residentes + turistas != 0)
            {
                coeficienteViagens += criancas * 0;
                coeficienteViagens += adolescentes * 5;
                coeficienteViagens += jovens * ((15 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas));
                coeficienteViagens += adultos * ((20 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas));
                coeficienteViagens += idosos * ((10 * residentes + 20 * turistas + (residentes + turistas >> 1)) / (residentes + turistas));
            }
            if (coeficienteViagens != 0)
            {
                viagensSalvas = (int)(((long)motoristas * 10000L + (long)(coeficienteViagens >> 1)) / (long)coeficienteViagens);
                viagensSalvas = Mathf.Clamp(viagensSalvas, 0, 100);
            }
            viagensEvitadasLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_TRIPSAVED", new object[] {
                viagensSalvas
            });

            if (daytimeChange != null && daytimeChange.completedOrFailed)
            {
                linearMap.redrawLine();
                daytimeChange = null;
            }
            else
            {
                linearMap.updateBidings();
            }


            //lines info
            int stopsCount = TLMLineUtils.GetStopsCount(lineID);

            if (lastStopsCount != stopsCount)
            {
                float totalSize = TLMLineUtils.GetLineLength(lineID);
                lineLenghtLabel.text = string.Format(Locale.Get("TLM_LENGHT_AND_STOPS"), totalSize, stopsCount);
                lastStopsCount       = stopsCount;
            }

            //estatisticas novas
            veiculosLinhaLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_VEHICLECOUNT", new object[] { veiculosLinha });

            uint prefix = 0;

            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;

            detailedStatsLabel.text    = string.Format("{0:0%}", overallBudget * prefixMultiplier);
            detailedStatsLabel.tooltip = string.Format(Locale.Get("TLM_LINE_BUDGET_EXPLAIN"),
                                                       TLMCW.getNameForTransportType(TLMCW.getConfigIndexForTransportInfo(info)),
                                                       TLMUtils.getStringOptionsForPrefix((ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(info) | TLMConfigWarehouse.ConfigIndex.PREFIX), true)[prefix + 1],
                                                       overallBudget, prefixMultiplier,
                                                       overallBudget * prefixMultiplier);

            //bool isZeroed = ((int)tl.m_flags & (int)TLMTransportLineFlags.ZERO_BUDGET_SETTED) > 0;
            //lineTime.isVisible = !isZeroed;
            //if (isZeroed)
            //{
            //    lineTimeTitle.localeID = ("TLM_LINE_DISABLED_NO_BUDGET");
            //    lineTimeTitle.tooltipLocaleID = ("TLM_LINE_DISABLED_NO_BUDGET_DESC");
            //}
            //else
            //{
            //    lineTimeTitle.localeID = ("TRANSPORT_LINE_ACTIVITY");
            //    lineTimeTitle.tooltipLocaleID = ("");
            //}

            //generalDebugLabel.enabled = TransportLinesManagerMod.debugMode.value;
            //if (TransportLinesManagerMod.debugMode.value)
            //{
            //    string debugTxt = "!";
            //    var extraDatas = ExtraVehiclesStats.instance.getLineVehiclesData(lineID);
            //    if (extraDatas.Count == 0)
            //    {
            //        debugTxt = "none";
            //    }
            //    else
            //    {
            //        foreach (var item in extraDatas)
            //        {
            //            debugTxt += string.Format("BUS ID {0} - {1} Fill, {2} per lap ||", item.Key, item.Value.avgFill.ToString("0.00%"), string.Format("{0}d {1}h{2}m", item.Value.timeTakenLap.TotalDays, item.Value.timeTakenLap.Hours, item.Value.timeTakenLap.Minutes));
            //        }
            //    }

            //    generalDebugLabel.text = debugTxt;
            //}

            //			//custos da linha
            //			float costVehicles = 0;
            //			ushort nextVehId = tl.m_vehicles;
            //			while (nextVehId >0) {
            //				costVehicles += Singleton<VehicleManager>.instance.m_vehicles.m_buffer [(int)nextVehId].Info.GetMaintenanceCost () ;
            //				nextVehId = Singleton<VehicleManager>.instance.m_vehicles.m_buffer [(int)nextVehId].m_nextLineVehicle;
            //			}
            //			float costStops = 0;
            //			int a = tl.m_stops;
            //			for (int i = 0; i< stopsCount; i++) {
            //				costStops += Singleton<NetManager>.instance.m_nodes.m_buffer [(int)tl.GetStop (i)].Info.GetMaintenanceCost () ;
            //			}
            //			custosLabel.text = String.Format (costsFormat, costVehicles, costStops, costVehicles + costStops);
        }
        private void BindParentChanges()
        {
            m_lineInfo.EventOnLineChanged += (lineId) =>
            {
                TLMUtils.doLog("EventOnLineChanged");
                m_isLoading = true;
                bool isCustomLine             = TLMTransportLineExtension.instance.GetUseCustomConfig(lineId);
                TransportSystemDefinition tsd = TransportSystemDefinition.from(lineId);
                TLMUtils.doLog("tsd = {0}", tsd);
                if (m_lastDef != tsd)
                {
                    foreach (var i in m_checkboxes.Keys)
                    {
                        UnityEngine.Object.Destroy(m_checkboxes[i].gameObject);
                    }
                    m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssets(0);
                    m_checkboxes    = new Dictionary <string, UICheckBox>();

                    TLMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
                    foreach (var i in m_defaultAssets.Keys)
                    {
                        var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) =>
                        {
                            ushort lineIdx = m_lineInfo.CurrentSelectedId;
                            if (m_isLoading)
                            {
                                return;
                            }
                            if (x)
                            {
                                if (TLMTransportLineExtension.instance.GetUseCustomConfig(lineIdx))
                                {
                                    TLMTransportLineExtension.instance.AddAsset(lineIdx, i);
                                }
                                else
                                {
                                    tsd.GetTransportExtension().AddAsset(TLMLineUtils.getPrefix(lineIdx), i);
                                }
                            }
                            else
                            {
                                if (TLMTransportLineExtension.instance.GetUseCustomConfig(lineIdx))
                                {
                                    TLMTransportLineExtension.instance.RemoveAsset(lineIdx, i);
                                }
                                else
                                {
                                    tsd.GetTransportExtension().RemoveAsset(TLMLineUtils.getPrefix(lineIdx), i);
                                }
                            }
                        });
                        CreateModelCheckBox(i, checkbox);
                        checkbox.label.tooltip              = checkbox.label.text;
                        checkbox.label.textScale            = 0.9f;
                        checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1);
                        m_checkboxes[i] = checkbox;
                    }
                }
                m_lastDef = tsd;
                List <string> selectedAssets;
                if (isCustomLine)
                {
                    selectedAssets = TLMTransportLineExtension.instance.GetAssetList(lineId);
                }
                else
                {
                    selectedAssets = tsd.GetTransportExtension().GetAssetList(TLMLineUtils.getPrefix(lineId));
                }
                TLMUtils.doLog("selectedAssets Size = {0} ({1})", selectedAssets?.Count, string.Join(",", selectedAssets?.ToArray() ?? new string[0]));
                foreach (var i in m_checkboxes.Keys)
                {
                    m_checkboxes[i].isChecked = selectedAssets.Contains(i);
                }

                if (isCustomLine)
                {
                    m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE"), TLMLineUtils.getLineStringId(lineId), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()));
                }
                else
                {
                    TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex();
                    ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);
                    var prefix = TLMLineUtils.getPrefix(lineId);
                    m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)prefix + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()));
                }

                m_isLoading = false;
                m_previewPanel.isVisible = false;
            };
        }
Exemplo n.º 29
0
        private void loadAuxiliarVars(bool global, bool force = false)
        {
            if ((global && cached_prefixConfigListGlobal == null) || (!global && cached_prefixConfigListNonGlobal == null) || force)
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("loadAuxiliarVars: IN!");
                }
                string[] file;
                if (global)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("loadAuxiliarVars: IF!");
                    }
                    file = TLMConfigWarehouse.getConfig(TLMConfigWarehouse.GLOBAL_CONFIG_INDEX, TLMConfigWarehouse.GLOBAL_CONFIG_INDEX).getString(configKeyForAssets).Split(PREFIX_COMMA.ToCharArray());
                }
                else
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("loadAuxiliarVars: ELSE!");
                    }
                    file = TLMConfigWarehouse.getCurrentConfigString(configKeyForAssets).Split(PREFIX_COMMA.ToCharArray());
                }
                cached_prefixConfigList = new Dictionary <uint, Dictionary <PrefixConfigIndex, string> >();
                if (file.Length > 0)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("loadAuxiliarVars: file.Length > 0");
                    }
                    foreach (string s in file)
                    {
                        uint key   = getIndexFromStringArray(s);
                        var  value = getValueFromStringArray(s);
                        cached_prefixConfigList[key] = value;
                    }
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("loadAuxiliarVars: dic done");
                    }
                    cached_prefixConfigList.Remove(0xFFFFFFFF);
                }
                else
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("loadAuxiliarVars: file.Length == 0");
                    }
                    cached_prefixConfigList = new Dictionary <uint, Dictionary <PrefixConfigIndex, string> >();
                }
                basicAssetsList = new List <string>();

                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("loadAuxiliarVars: pre prefab read");
                }
                for (uint num = 0u; (ulong)num < (ulong)((long)PrefabCollection <VehicleInfo> .PrefabCount()); num += 1u)
                {
                    VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                    if (!(prefab == null) && definition.isFromSystem(prefab) && !isTrailer(prefab))
                    {
                        basicAssetsList.Add(prefab.name);
                    }
                }
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("loadAuxiliarVars: pre models Check");
                }
                foreach (uint prefix in cached_prefixConfigList.Keys)
                {
                    if (cached_prefixConfigList[prefix].ContainsKey(PrefixConfigIndex.MODELS))
                    {
                        var temp = cached_prefixConfigList[prefix][PrefixConfigIndex.MODELS].Split(PROPERTY_VALUE_COMMA.ToCharArray()).ToList();
                        for (int i = 0; i < temp.Count; i++)
                        {
                            string assetId = temp[i];
                            if (PrefabCollection <VehicleInfo> .FindLoaded(assetId) == null)
                            {
                                temp.RemoveAt(i);
                                i--;
                            }
                        }
                        cached_prefixConfigList[prefix][PrefixConfigIndex.MODELS] = string.Join(PROPERTY_VALUE_COMMA, temp.ToArray());
                    }
                }
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("loadAuxiliarVars: pos models Check");
                }
                saveSubcategoryList(global);
            }
        }
Exemplo n.º 30
0
        private void BindParentChanges()
        {
            TLMTabControllerPrefixList <T> .eventOnPrefixChange += (prefix) =>
            {
                TLMUtils.doLog("EventOnLineChanged");
                TransportSystemDefinition tsd = Singleton <T> .instance.GetTSD();

                if (!tsd.hasVehicles())
                {
                    m_mainPanel.isVisible = false;
                    return;
                }
                m_isLoading = true;
                TLMUtils.doLog("tsd = {0}", tsd);
                if (!loaded)
                {
                    foreach (var i in m_checkboxes.Keys)
                    {
                        UnityEngine.Object.Destroy(m_checkboxes[i].gameObject);
                    }
                    m_defaultAssets = tsd.GetTransportExtension().GetAllBasicAssets(0);
                    m_checkboxes    = new Dictionary <string, UICheckBox>();

                    TLMUtils.doLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
                    foreach (var i in m_defaultAssets.Keys)
                    {
                        var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) =>
                        {
                            if (!m_isLoading)
                            {
                                ushort lineIdx = (ushort)m_parent.SelectedPrefix;
                                if (lineIdx > 100)
                                {
                                    return;
                                }
                                if (x)
                                {
                                    tsd.GetTransportExtension().AddAsset(TLMLineUtils.getPrefix(lineIdx), i);
                                }
                                else
                                {
                                    tsd.GetTransportExtension().RemoveAsset(TLMLineUtils.getPrefix(lineIdx), i);
                                }
                            }
                        });
                        CreateModelCheckBox(i, checkbox);
                        checkbox.label.tooltip              = checkbox.label.text;
                        checkbox.label.textScale            = 0.9f;
                        checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1);
                        m_checkboxes[i] = checkbox;
                    }
                }
                loaded = true;
                List <string> selectedAssets;
                selectedAssets = tsd.GetTransportExtension().GetAssetList((uint)prefix);

                TLMUtils.doLog("selectedAssets Size = {0} ({1})", selectedAssets?.Count, string.Join(",", selectedAssets?.ToArray() ?? new string[0]));
                foreach (var i in m_checkboxes.Keys)
                {
                    m_checkboxes[i].isChecked = selectedAssets.Contains(i);
                }

                TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex();
                ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);
                m_title.text = string.Format(Locale.Get("TLM_ASSET_SELECT_WINDOW_TITLE_PREFIX"), prefix > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)prefix + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsd.toConfigIndex()));

                m_isLoading = false;
            };
            TLMTabControllerPrefixList <T> .eventOnColorChange += (Color x) => m_lastColor = x;
        }