Create a New INI file to store or load data
Пример #1
0
        public SettingsObject(String path)
        {
            //iniPath = Path.Combine(Path.GetTempPath(), "SimpleEpub2") + "\\Resources\\settings.ini";
            iniPath = path;
            ini = new INIFile(iniPath);

            coverFirstPage = false;
            coverNoTOC = false;
            verticalText = false;
            replaceNumByHan = false;
            StT = false;
            TtS = false;
            embedFontSubset = false;
            generateMOBI = false;
            bookNameFont = "微软雅黑";
            authorNameFont = "微软雅黑";
            pageColor = Color.Empty;
            marginT = 0;
            marginB = 0;
            marginL = 0;
            marginR = 0;
            titleFont = "微软雅黑";
            titleColor = Color.SteelBlue;
            bodyFont = "微软雅黑";
            bodyColor = Color.Black;
            lineSpacing = 130;
            addParagraphSpacing = true;
            dropCap = false;
            stickupCap = false;
            fileLocation = Application.StartupPath;
            deleteTempFiles = true;
            autoUpdate = true;
            language = "null";
        }
Пример #2
0
        public void LoadWeaponData(string DirectoryPath)
        {
            DirectoryInfo WeaponDirectory = new DirectoryInfo(DirectoryPath);

            foreach (var File in WeaponDirectory.EnumerateFiles("*.ini"))
            {
                const string WeaponSection = "Weapon";
                INIFile WeaponFile = new INIFile(File.FullName);

                WeaponData NewWeapon = new WeaponData();

                if(WeaponFile.TryLoading(WeaponSection, "ProjectileDamage"))
                    NewWeapon.ProjectileDamage = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileForce"))
                    NewWeapon.ProjectileForce = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileExplosionRadius"))
                    NewWeapon.ProjectileExplosionRadius = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileMass"))
                    NewWeapon.ProjectileMass = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileSpeed"))
                    NewWeapon.ProjectileSpeed = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileLifeTime"))
                    NewWeapon.ProjectileLifeTime = float.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "ChargeTime"))
                    NewWeapon.ChargeTime = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeSpeedBonusStart"))
                    NewWeapon.ChargeSpeedBonusStart = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeDamageBonusStart"))
                    NewWeapon.ChargeDamageBonusStart = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeInaccuracyBonusUncharged"))
                    NewWeapon.ChargeInaccuracyBonusUncharged = float.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "SelfDamage"))
                    NewWeapon.SelfDamage = bool.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "FirendlyFire"))
                    NewWeapon.FirendlyFire = bool.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "WeaponTexture"))
                    NewWeapon.WeaponTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileTexture"))
                    NewWeapon.ProjectileTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "FireInterval"))
                    NewWeapon.FireInterval = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "Recoil"))
                    NewWeapon.Recoil = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "MagazineSize"))
                    NewWeapon.MagazineSize = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ReloadTime"))
                    NewWeapon.ReloadTime = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "Inaccuracy"))
                    NewWeapon.Inaccuracy = float.Parse(WeaponFile.LastLoadedData());

                NewWeapon.Name = File.Name.Substring(0, File.Name.LastIndexOf('.'));

                if (NewWeapon.WeaponTexture != null && NewWeapon.ProjectileTexture != null)
                {
                    Weapons.Add(NewWeapon.Name, NewWeapon);
                }

            }
        }
Пример #3
0
 private static String getINILanguage()
 {
     INIFile ini = new INIFile(settingsPath);
     return ini.INIReadValue("Tab_4", "Language");
 }
Пример #4
0
        public void LoadConfiguration(string LevelDirectory)
        {
            const string GENERAL_CONFIG = "General";

            string INIPath = System.IO.Path.Combine(LevelDirectory, "Config.ini");
            if(System.IO.File.Exists(INIPath))
            {
                INIFile ConfigFile = new INIFile(INIPath);

                cGravity.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityX"));
                cGravity.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityY"));

                cLifeMaximum = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeMaximum"));
                cLifeStart = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeStarting"));

                cWormMass = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormMass"));
                cWormSize.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeX"));
                cWormSize.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeY"));
                cWormSpeed = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSpeed"));
                cWormJumpVelocityBonus.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityX"));
                cWormJumpVelocityBonus.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityY"));

                cExplosionGroundDestructionPercent = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "ExplosionGroundDestructionPercent"));

                LoadWeaponData(System.IO.Path.Combine(LevelDirectory, "Weapons"));

                string DefaultWeapon = ConfigFile.IniReadValue(GENERAL_CONFIG, "DefaultWeapon");
                if(!string.IsNullOrEmpty(DefaultWeapon))
                {
                    if (Weapons.ContainsKey(DefaultWeapon))
                    {
                        cStartingWeapon = Weapons[DefaultWeapon];
                    }
                    else Console.WriteLine("Error loading data - default weapon not found."); //
                }
                else Console.WriteLine("Error loading data - default weapon string not found."); //

            }
            else
            {
                Console.WriteLine("Can't find file " + Path.GetFileName("Config.ini") + " from " + LevelName  + ". Loading default configuration."); //
            }
        }