Exemple #1
0
        internal static void InitConfig()
        {
            VERSION = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            if (!File.Exists(FILENAME))
            {
                UnityEngine.Debug.Log($"[{PROGRAM_NAME}] Warning! Configuration file is missing. Creating a new one.");

                Helper.CreateDefaultConfigFile(FILENAME, PROGRAM_NAME, VERSION, DEFAULT_CONFIG);

                var configParser = new Parser(FILENAME);

                foreach (string language in Languages)
                {
                    if (!configParser.AddNewSection(language))
                    {
                        continue;
                    }

                    foreach (string item in SECTION_LANGUAGE)
                    {
                        configParser.SetKeyValueInSection(language, item, "");
                    }
                }
            }

            ReadConfig();
            ReadLanguageText();
            InitColorNames();
        }
Exemple #2
0
        internal static void CreateDefaultConfigFile()
        {
            SNLogger.Log($"[{PROGRAM_NAME}] Warning! Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                Helper.CreateDefaultConfigFile(FILENAME, PROGRAM_NAME, PROGRAM_VERSION, DEFAULT_CONFIG);

                var configParser = new Parser(FILENAME);

                foreach (string language in Languages)
                {
                    if (!configParser.AddNewSection(language))
                    {
                        continue;
                    }

                    foreach (string item in SECTION_LANGUAGE)
                    {
                        configParser.SetKeyValueInSection(language, item, "");
                    }
                }

                SNLogger.Log($"[{PROGRAM_NAME}] The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Log($"[{PROGRAM_NAME}] An error occured while creating the new configuration file!");
            }
        }
        internal static void Config_CreateDefault()
        {
            SNLogger.Debug("LaserCannon", "Method call: LaserCannonConfig.Config_CreateDefault()");

            SNLogger.Warn("LaserCannon", "Configuration file is missing or wrong version. Trying to create a new one.");

            try
            {
                ParserHelper.CreateDefaultConfigFile(FILENAME, "LaserCannon", PROGRAM_VERSION, DEFAULT_CONFIG);

                var configParser = new Parser(FILENAME);

                foreach (string language in Languages)
                {
                    if (!configParser.AddNewSection(language))
                    {
                        continue;
                    }

                    foreach (string item in SECTION_LANGUAGE)
                    {
                        configParser.SetKeyValueInSection(language, item, "");
                    }
                }

                SNLogger.Log("LaserCannon", "The new configuration file was successfully created.");
            }
            catch
            {
                SNLogger.Error("LaserCannon", "An error occured while creating the new configuration file!");
            }
        }