private void Unload() { try { this.Settings.SaveConfig(this.SettingsFilename); } catch (Exception ex) { this.Log.Warning("An error occured while saving the settings, the settings are not saved: {0}", ex); } CustomPlayClickSound.UnDetour(); // Actually, to be consistent and nice, we should also revert the other sound patching here. // But since that sounds are only patched in-game, and closing that game conveniently resets the other sounds, it's not really needed. // If it's needed at some point in the future, we can add that logic here. }
private void Load() { // We have to properly migrate the outdated XML configuration file try { string oldXmlSettingsFilename = Path.Combine(Path.GetDirectoryName(this.SettingsFilename), Path.GetFileNameWithoutExtension(this.SettingsFilename)) + ".xml"; if (File.Exists(oldXmlSettingsFilename) && !File.Exists(this.SettingsFilename)) { this.Settings = Configuration.LoadConfig(oldXmlSettingsFilename, new ConfigurationMigrator()); this.Settings.SaveConfig(this.SettingsFilename); File.Delete(oldXmlSettingsFilename); } else { this.Settings = Configuration.LoadConfig(this.SettingsFilename, new ConfigurationMigrator()); } } catch (Exception ex) { this.Log.Warning("An error occured while loading the settings, default values will be used instead: {0}", ex); this.Settings = new Configuration(); } this.Log.EnableDebugLogging = this.Settings.ExtraDebugLogging; if (this.Settings.ExtraDebugLogging) { this.Log.Warning("Extra debug logging is enabled, please use this only to get more information while hunting for bugs; don't use this when playing normally!"); } // Initialize sounds SoundManager.instance.InitializeSounds(); // Load sound packs SoundPacksManager.instance.InitSoundPacks(); //verify config ValidateSettings(); // Detour UI click sounds CustomPlayClickSound.Detour(); }