/// <summary> /// Saves the settings instance to file. /// </summary> /// <param name="settingsInstance">Instance of the settings object to save to file.</param> /// <returns>Return true if the settings object was saved successfully. Returns false if it failed to save.</returns> public static bool SaveSettings(SettingsBase settingsInstance) { if (settingsInstance == null) { throw new ArgumentNullException(nameof(settingsInstance)); } return(FileDatabase.SaveToFile(settingsInstance.ModuleFolderName, settingsInstance, FileDatabase.Location.Configs)); }
internal static TournamentXPSettings GetSettingsFromModLib(bool forceDebug = false) { FileDatabase.Initialise(SettingsHelper.ModuleFolderName); TournamentXPSettingsModLib settings = FileDatabase.Get <TournamentXPSettingsModLib>(TournamentXPSettingsModLib.InstanceID); if (settings == null) { settings = new TournamentXPSettingsModLib(); } SettingsDatabase.RegisterSettings(settings); if (forceDebug) { settings.DebugMode = true; } return(settings.GetSettings()); }
public static bool GetModLibSettings(bool forceDebug = false, bool forceMenu = false) { var modnames = Utilities.GetModulesNames().ToList(); if (modnames.Contains("Bannerlord.MBOptionScreen")) { if (forceMenu) { //Reenable ModLib settings menu option Module.CurrentModule.AddInitialStateOption(new InitialStateOption("ModOptionsMenu", new TextObject("ModLib Options"), 9990, () => { ScreenManager.PushScreen(new ModOptionsGauntletScreen()); }, false)); } } try { FileDatabase.Initialise(SettingsHelper.ModuleFolderName); TournamentXPSettingsModLib settings = FileDatabase.Get <TournamentXPSettingsModLib>(TournamentXPSettingsModLib.InstanceID); if (settings == null) { settings = new TournamentXPSettingsModLib(); } SettingsDatabase.RegisterSettings(settings); if (forceDebug) { settings.DebugMode = true; } TournamentXPSettings.SetSettings(settings.GetSettings()); } catch (Exception ex) { ErrorLog.Log("TournamentsXPanded failed to initialize settings data.\n\n" + ex.ToStringFull()); return(false); } return(true); }