Example #1
0
        private static bool LoadLegacy(SavedString oldFile)
        {
            string serializedInfo = oldFile.value;

            if (!string.IsNullOrEmpty(serializedInfo))
            {
                TLMUtils.doLog("Loading palettes - separator: {1} ; save Value: {0}", serializedInfo, SERIALIZER_ITEM_SEPARATOR);
                string[] items = serializedInfo.Split(SERIALIZER_ITEM_SEPARATOR);
                foreach (string item in items)
                {
                    TLMUtils.doLog("Loading palette {0}", items);
                    AutoColorPalette acp = AutoColorPalette.parseFromString_Legacy(item);
                    if (acp != null)
                    {
                        m_palettes.Add(acp.name, acp);
                    }
                }
            }
            else
            {
                return(false);
            }
            foreach (AutoColorPalette p in defaultPaletteArray)
            {
                m_palettes[p.name] = p;
            }
            return(true);
        }
 void Start()
 {
     settings = new SavedString[13];
     for (short i = 0; i < 13; i++)
     {
         settings[i] = new SavedString(propIdentifiers[i], RailwayMod.SETTINGS_FILENAME, defaultProps[i], true);
     }
     var allProps = Resources.FindObjectsOfTypeAll<PropInfo>();
     LoadReplacementProps(allProps);
     // replace props on load
     for (ushort i = 0; i < 13; i++)
     {
         // check if prop exists
         try
         {
             allProps.Single(prop => prop.name == settings[i].value);
             SetProp(allProps.Single(prop => prop.name == settings[i].value), i);
         }
         catch (InvalidOperationException)
         {
             var p = allProps.Single(prop => prop.name == defaultProps[i]);
             SetProp(p, i);
             settings[i].value = p.name;
             Debug.Log("[RailwayMod] [ReplacementProps] The prop of type " + propTypes[i] + " saved in the settings doesn't exist anymore : setting default.");
         }
     }
     Debug.Log("[RailwayMod] [ReplacementProps] Loading ended.");
 }
Example #3
0
 private SavedString GetSavedString(T i)
 {
     if (!cachedStringSaved.ContainsKey(i))
     {
         cachedStringSaved[i] = new SavedString(i.ToString(), thisFileName, getDefaultStringValueForProperty(i), true);
     }
     return(cachedStringSaved[i]);
 }
Example #4
0
        public void Awake()
        {
            Debug.LogWarningFormat("TLMRv" + TLMSingleton.majorVersion + " LOADING TLM ");
            SettingsFile tlmSettings = new SettingsFile
            {
                fileName = TLMConfigWarehouse.CONFIG_FILENAME
            };

            Debug.LogWarningFormat("TLMRv" + TLMSingleton.majorVersion + " SETTING FILES");
            try
            {
                GameSettings.AddSettingsFile(tlmSettings);
            }
            catch (Exception e)
            {
                SettingsFile tryLoad = GameSettings.FindSettingsFileByName(TLMConfigWarehouse.CONFIG_FILENAME);
                if (tryLoad == null)
                {
                    Debug.LogErrorFormat("TLMRv" + majorVersion + " SETTING FILES FAIL!!! ");
                    Debug.LogError(e.Message);
                    Debug.LogError(e.StackTrace);
                }
                else
                {
                    tlmSettings = tryLoad;
                }
            }
            Debug.LogWarningFormat("TLMRv" + TLMSingleton.majorVersion + " LOADING VARS ");

            m_savedPalettes = new SavedString("savedPalettesTLM", Settings.gameSettingsFile, "", true);
            m_savedShowNearLinesInCityServicesWorldInfoPanel  = new SavedBool("showNearLinesInCityServicesWorldInfoPanel", Settings.gameSettingsFile, true, true);
            m_savedShowNearLinesInZonedBuildingWorldInfoPanel = new SavedBool("showNearLinesInZonedBuildingWorldInfoPanel", Settings.gameSettingsFile, false, true);
            m_savedOverrideDefaultLineInfoPanel = new SavedBool("TLMOverrideDefaultLineInfoPanel", Settings.gameSettingsFile, true, true);
            m_debugMode  = new SavedBool("TLMdebugMode", Settings.gameSettingsFile, false, true);
            m_betaMapGen = new SavedBool("TLMbetaMapGen", Settings.gameSettingsFile, false, true);
            m_showDistanceInLinearMap = new SavedBool("TLMshowDistanceInLinearMap", Settings.gameSettingsFile, true, true);

            if (m_debugMode.value)
            {
                TLMUtils.doLog("currentSaveVersion.value = {0}, fullVersion = {1}", currentSaveVersion.value, fullVersion);
            }
            if (currentSaveVersion.value != fullVersion)
            {
                needShowPopup = true;
            }
            toggleOverrideDefaultLineInfoPanel(m_savedOverrideDefaultLineInfoPanel.value);
            LocaleManager.eventLocaleChanged += new LocaleManager.LocaleChangedHandler(this.autoLoadTLMLocale);
            if (instance != null)
            {
                GameObject.Destroy(instance);
            }
            loadTLMLocale(false);
            onAwake?.Invoke();
        }
Example #5
0
 public static void ConvertLegacyPalettes(SavedString oldFile)
 {
     if (m_palettes == null)
     {
         init();
     }
     if (LoadLegacy(oldFile))
     {
         TLMUtils.doLog("Converting Palettes");
         SaveAll();
     }
 }
Example #6
0
        protected void setToFile(T i, string value)
        {
            SavedString data = GetSavedString(i);

            if (value == null)
            {
                data.Delete();
            }
            else
            {
                data.value = value;
            }

            eventOnPropertyChanged?.Invoke(i, null, null, value);
        }
Example #7
0
        public TransportLinesManagerMod()
        {
            Debug.LogWarningFormat("TLMv" + TransportLinesManagerMod.majorVersion + " LOADING TLM ");
            SettingsFile tlmSettings = new SettingsFile();

            tlmSettings.fileName = TLMConfigWarehouse.CONFIG_FILENAME;
            Debug.LogWarningFormat("TLMv" + TransportLinesManagerMod.majorVersion + " SETTING FILES");
            try
            {
                GameSettings.AddSettingsFile(tlmSettings);
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("TLMv" + TransportLinesManagerMod.majorVersion + " SETTING FILES FAIL!!! ");
                Debug.LogError(e.Message);
                Debug.LogError(e.StackTrace);
            }
            Debug.LogWarningFormat("TLMv" + TransportLinesManagerMod.majorVersion + " LOADING VARS ");

            m_savedPalettes        = new SavedString("savedPalettesTLM", Settings.gameSettingsFile, "", true);
            m_IPTCompatibilityMode = new SavedBool("TLM_IPTCompabilityMode", Settings.gameSettingsFile, false, true);
            m_savedShowNearLinesInCityServicesWorldInfoPanel  = new SavedBool("showNearLinesInCityServicesWorldInfoPanel", Settings.gameSettingsFile, true, true);
            m_savedShowNearLinesInZonedBuildingWorldInfoPanel = new SavedBool("showNearLinesInZonedBuildingWorldInfoPanel", Settings.gameSettingsFile, false, true);
            m_savedOverrideDefaultLineInfoPanel = new SavedBool("TLMOverrideDefaultLineInfoPanel", Settings.gameSettingsFile, true, true);
            m_debugMode  = new SavedBool("TLMdebugMode", Settings.gameSettingsFile, false, true);
            m_betaMapGen = new SavedBool("TLMbetaMapGen", Settings.gameSettingsFile, false, true);

            if (m_debugMode.value)
            {
                TLMUtils.doLog("currentSaveVersion.value = {0}, fullVersion = {1}", currentSaveVersion.value, fullVersion);
            }
            if (currentSaveVersion.value != fullVersion)
            {
                needShowPopup = true;
            }
            toggleOverrideDefaultLineInfoPanel(m_savedOverrideDefaultLineInfoPanel.value);
            loadTLMLocale(false);
            LocaleManager.eventLocaleChanged += new LocaleManager.LocaleChangedHandler(this.autoLoadTLMLocale);
            instance = this;
        }
Example #8
0
        private void InitializeDependencies()
        {
            var configurationFileFullName = Path.Combine(DataLocation.localApplicationData, SystemName + ".xml");

            _configurationService    = new ConfigurationService <ConfigurationDto>(configurationFileFullName);
            _languageResourceService = new LanguageResourceService <LanguageResourceDto>(
                SystemName,
                WorkshopId,
                PluginManager.instance
                );

            _configuration = File.Exists(_configurationService.ConfigurationFileFullName)
                ? new Configuration(_configurationService, _configurationService.Load())
                : new Configuration(_configurationService, new ConfigurationDto());

            var playerLanguage = new SavedString(Settings.localeID, Settings.gameSettingsFile, DefaultSettings.localeID);

            LocaleManager.defaultLanguage = playerLanguage; //necessary because LocaleManager.Constructor will use that value lol.
            LocaleManager.Ensure();
            _languageResource = LanguageResource.Create(_languageResourceService, playerLanguage, _fallbackLanguageTwoLetterCode);

            LocaleManager.eventUIComponentLocaleChanged += LocaleManager_eventUIComponentLocaleChanged;
        }
Example #9
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            var config = Configuration <JapaneseTrafficLightsConfiguration> .Load();

            // 多言語対応
            Globalization globalText  = new Globalization();
            SavedString   currentLang = new SavedString("localeID", "gameSettings");

            string displayLang;

            if (currentLang.value.Contains("ja"))
            {
                displayLang = "ja";
            }
            else
            {
                displayLang = currentLang.value;
            }

            string style  = globalText.GetString(displayLang, Globalization.StringKeys.OptionStyleText);
            string enable = globalText.GetString(displayLang, Globalization.StringKeys.OptionEnableText);

            string[] styles = new string[] {
                globalText.GetString(displayLang, Globalization.StringKeys.StyleWhite),
                globalText.GetString(displayLang, Globalization.StringKeys.StyleBrown),
                globalText.GetString(displayLang, Globalization.StringKeys.StyleBrown2)
            };

            // オプションページ
            UIHelperBase GroupHeader = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.HeaderText));

            UIHelperBase GroupGlobal = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.GlobalText));

            GroupGlobal.AddDropdown(style, styles, config.Global, Global);

            UIHelperBase GroupTinyRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.TinyRoadsText));

            GroupTinyRoads.AddDropdown(style, styles, config.TinyRoads, TinyRoads);

            UIHelperBase GroupSmallRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.SmallRoadsText));

            GroupSmallRoads.AddDropdown(style, styles, config.SmallRoads, SmallRoads);

            UIHelperBase GroupSmallHeavyRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.SmallHeavyRoadsText));

            GroupSmallHeavyRoads.AddDropdown(style, styles, config.SmallHeavyRoads, SmallHeavyRoads);

            UIHelperBase GroupMediumRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.MediumRoadsText));

            GroupMediumRoads.AddDropdown(style, styles, config.MediumRoads, MediumRoads);

            UIHelperBase GroupLargeRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.LargeRoadsText));

            GroupLargeRoads.AddDropdown(style, styles, config.LargeRoads, LargeRoads);

            UIHelperBase GroupWideRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.WideRoadsText));

            GroupWideRoads.AddDropdown(style, styles, config.WideRoads, WideRoads);

            UIHelperBase GroupHighways = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.HighwaysText));

            GroupHighways.AddDropdown(style, styles, config.Highways, Highways);

            UIHelperBase GroupPedestrianRoads = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.PedestrianRoadsText));

            GroupPedestrianRoads.AddDropdown(style, styles, config.PedestrianRoads, PedestrianRoads);
            GroupPedestrianRoads.AddCheckbox(globalText.GetString(displayLang, Globalization.StringKeys.OptionPedRoadsText), config.HidePedRoadsSignal, IsPedRoadsSignal);
            GroupPedestrianRoads.AddCheckbox(globalText.GetString(displayLang, Globalization.StringKeys.OptionPromenadeText), config.HidePromenadeSignal, IsPromenadeSignal);

            /* 芝と街路樹のオプションがあれば必要性が薄いため、UIは非公開
             * UIHelperBase GroupBus = helper.AddGroup("[Beta]Road with Bus Lanes(except some roads)");
             * GroupBus.AddDropdown("Style", styles, config.Bus, Bus);
             * GroupBus.AddCheckbox("Enable", config.EnableBus, IsBusOption);*/

            UIHelperBase GroupMonorail = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.MonorailText));

            GroupMonorail.AddDropdown(style, styles, config.Monorail, Monorail);
            GroupMonorail.AddCheckbox(enable, config.EnableMonorail, IsMonorailOption);

            UIHelperBase GroupGrass = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.GrassText));

            GroupGrass.AddDropdown(style, styles, config.Grass, Grass);
            GroupGrass.AddCheckbox(enable, config.EnableGrass, IsGrassOption);

            UIHelperBase GroupTrees = helper.AddGroup(globalText.GetString(displayLang, Globalization.StringKeys.TreesText));

            GroupTrees.AddDropdown(style, styles, config.Trees, Trees);
            GroupTrees.AddCheckbox(enable, config.EnableTrees, IsTreesOption);
        }
 private void OnEnable()
 {
     File        = new SavedString($"{GetType()}.File", string.Empty);
     PrettyPrint = new SavedBool($"{GetType()}.PrettyPrint", true);
 }