예제 #1
0
파일: Main.cs 프로젝트: waynieoaks/RecovFR
        private static void LoadValuesFromIniFile()
        {
            // string path = "Plugins\\RecovFR.ini";
            InitializationFile ini = new InitializationFile(INIpath);

            ini.Create();

            try
            {
                if (ini.DoesKeyExist("Keybindings", "BackupKey"))
                {
                    BackupKey = ini.ReadEnum <Keys>("Keybindings", "BackupKey", Keys.F12);
                }
                else
                {
                    ini.Write("Keybindings", "BackupKey", "F12");
                    BackupKey = Keys.F12;
                }

                if (ini.DoesKeyExist("Keybindings", "BackupModifierKey"))
                {
                    BackupModifierKey = ini.ReadEnum <Keys>("Keybindings", "BackupModifierKey", Keys.ControlKey);
                }
                else
                {
                    ini.Write("Keybindings", "BackupModifierKey", "ControlKey");
                    BackupModifierKey = Keys.ControlKey;
                }

                if (ini.DoesKeyExist("Keybindings", "RestoreKey"))
                {
                    RestoreKey = ini.ReadEnum <Keys>("Keybindings", "RestoreKey", Keys.F12);
                }
                else
                {
                    ini.Write("Keybindings", "RestoreKey", "F12");
                    RestoreKey = Keys.F12;
                }

                if (ini.DoesKeyExist("Keybindings", "RestoreModifierKey"))
                {
                    RestoreModifierKey = ini.ReadEnum <Keys>("Keybindings", "RestoreModifierKey", Keys.Menu);
                }
                else
                {
                    ini.Write("Keybindings", "RestoreModifierKey", "ControlKey");
                    RestoreModifierKey = Keys.Menu;
                }

                if (ini.DoesKeyExist("Keybindings", "MenuKey"))
                {
                    MenuKey = ini.ReadEnum <Keys>("Keybindings", "MenuKey", Keys.F11);
                }
                else
                {
                    ini.Write("Keybindings", "MenuKey", "F11");
                    MenuKey = Keys.F11;
                }

                if (ini.DoesKeyExist("Keybindings", "MenuModifierKey"))
                {
                    MenuModifierKey = ini.ReadEnum <Keys>("Keybindings", "MenuModifierKey", Keys.None);
                }
                else
                {
                    ini.Write("Keybindings", "MenuModifierKey", "None");
                    MenuModifierKey = Keys.None;
                }

                if (ini.DoesKeyExist("Features", "AutoBackups"))
                {
                    AutoBackups = ini.ReadBoolean("Features", "AutoBackups", false);
                }
                else
                {
                    ini.Write("Features", "AutoBackups", "false");
                    AutoBackups = false;
                }

                if (ini.DoesKeyExist("Features", "AutoBackupInt"))
                {
                    AutoBackupInt = ini.ReadByte("Features", "AutoBackupInt", 60);
                }
                else
                {
                    ini.Write("Features", "AutoBackupInt", "60");
                    AutoBackupInt = 60;
                }

                if (ini.DoesKeyExist("Features", "ShowNotifications"))
                {
                    ShowNotifications = ini.ReadBoolean("Features", "ShowNotifications", false);
                }
                else
                {
                    ini.Write("Features", "ShowNotifications", "false");
                    ShowNotifications = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "PlayerGodMode"))
                {
                    PlayerGodMode = ini.ReadBoolean("RestoreOptions", "PlayerGodMode", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "PlayerGodMode", "False");
                    PlayerGodMode = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "VehicleGodMode"))
                {
                    VehicleGodMode = ini.ReadBoolean("RestoreOptions", "VehicleGodMode", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "VehicleGodMode", "false");
                    VehicleGodMode = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "FreezeWeather"))
                {
                    FreezeWeather = ini.ReadBoolean("RestoreOptions", "FreezeWeather", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "FreezeWeather", "false");
                    FreezeWeather = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "SnowOnGround"))
                {
                    SnowOnGround = ini.ReadBoolean("RestoreOptions", "SnowOnGround", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "SnowOnGround", "false");
                    SnowOnGround = false;
                }

                if (ini.DoesKeyExist("RestoreOptions", "FreezeTime"))
                {
                    FreezeTime = ini.ReadBoolean("RestoreOptions", "FreezeTime", false);
                }
                else
                {
                    ini.Write("RestoreOptions", "FreezeTime", "false");
                    FreezeTime = false;
                }
                Game.LogTrivial("Settings initialisation complete.");
            }
            catch (Exception e)
            {
                ErrorLogger(e, "Initialisation", "Unable to read INI file.");
            }
        }