示例#1
0
        public static bool Save(string filename)
        {
            try
            {
                var configFile = new ConfigFile();

                // Game
                configFile.SetValue("game", "options", Game.Options);
                configFile.SetValue("game", "graphic_data_usage", Game.GraphicDataUsage);
                configFile.SetValue("game", "sound_data_usage", Game.SoundDataUsage);
                configFile.SetValue("game", "music_data_usage", Game.MusicDataUsage);


                // Audio
                configFile.SetValue("audio", "music", Audio.Music ? 1 : 0);
                configFile.SetValue("audio", "sound", Audio.Sound ? 1 : 0);
                configFile.SetValue("audio", "volume", Audio.Volume.ToString(System.Globalization.CultureInfo.InvariantCulture));


                // Video
                configFile.SetValue("video", "resolution_width", Video.ResolutionWidth);
                configFile.SetValue("video", "resolution_height", Video.ResolutionHeight);
                configFile.SetValue("video", "fullscreen", Video.Fullscreen ? "1" : "0");


                return(configFile.Save(filename));
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
        protected void Save(ConfigFile file)
        {
            string str = name + " " + number;

            foreach (var value in values)
            {
                file.SetValue(str, value.Key, value.Value.Value);
            }

            foreach (var writer in sections)
            {
                writer.Save(file);
            }
        }
示例#3
0
        public static bool Save(string filename)
        {
            try
            {
                var configFile = new ConfigFile();

                // Game
                const string game = "game";
                configFile.SetValue(game, "options", Game.Options);
                configFile.SetValue(game, "graphic_data_usage", Game.GraphicDataUsage);
                configFile.SetValue(game, "sound_data_usage", Game.SoundDataUsage);
                configFile.SetValue(game, "music_data_usage", Game.MusicDataUsage);

                // Audio
                const string audio = "audio";
                configFile.SetValue(audio, "music", Audio.Music);
                configFile.SetValue(audio, "sound", Audio.Sound);
                configFile.SetValue(audio, "volume", Audio.Volume);

                // Video
                const string video = "video";
                configFile.SetValue(video, "resolution_width", Video.ResolutionWidth);
                configFile.SetValue(video, "resolution_height", Video.ResolutionHeight);
                configFile.SetValue(video, "fullscreen", Video.Fullscreen);

                // Logging
                const string logging = "logging";
                configFile.SetValue(logging, "level", Logging.LogLevel);
                configFile.SetValue(logging, "max_log_size", Logging.MaxLogSize);
                configFile.SetValue(logging, "log_file", Logging.LogFileName);
                configFile.SetValue(logging, "log_to_console", Logging.LogToConsole);

                return(configFile.Save(filename));
            }
            catch
            {
                return(false);
            }
        }