protected override void OnSubModuleLoad() { FireLordConfig.Init(); FileDatabase.Initialise(ModuleName); BannerlordConfig.Initialize(); if (BannerlordConfig.Language == "简体中文") { _fireLordSettings = FileDatabase.Get <FireLordSettings>(FireLordSettings.InstanceID); if (_fireLordSettings == null) { _fireLordSettings = new FireLordSettings(); } ((FireLordSettings)_fireLordSettings).Init(); SettingsDatabase.RegisterSettings(_fireLordSettings); } else { _fireLordSettings = FileDatabase.Get <FireLordSettingsEnglish>(FireLordSettings.InstanceID); if (_fireLordSettings == null) { _fireLordSettings = new FireLordSettingsEnglish(); } ((FireLordSettingsEnglish)_fireLordSettings).Init(); SettingsDatabase.RegisterSettings(_fireLordSettings); } }
protected override void OnSubModuleLoad() { if (File.Exists(System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs"))) { File.Delete(System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs")); } string logpath = System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs", "logfile.txt"); if (!Directory.Exists(System.IO.Path.GetDirectoryName(logpath))) { Directory.CreateDirectory(System.IO.Path.GetDirectoryName(logpath)); } ErrorLog.LogPath = logpath; try { FileDatabase.Initialise(ModuleFolderName); BMRandomTweaksConfiguration settings = FileDatabase.Get <BMRandomTweaksConfiguration>(BMRandomTweaksConfiguration.InstanceID); if (settings == null) { settings = new BMRandomTweaksConfiguration(); } SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { ErrorLog.Log("TournamentsXPanded failed to initialize settings data.\n\n" + ex.ToStringFull()); } }
private void InitializeModLib() { try { FileDatabase.Initialise("zLootOverhaul"); SettingsDatabase.RegisterSettings((FileDatabase.Get<LootOverhaulSettings>("zLootOverhaul") ?? new LootOverhaulSettings())); } catch (Exception ex) { MessageBox.Show("ERROR IN LOOT OVERHAUL! " + ex.Message, "ERROR IN LOOT OVERHAUL!"); } }
protected override void OnSubModuleLoad() { SyncObject = (SyncObjectV1)Module.CurrentModule.GetInitialStateOptionWithId(SyncObjectV1.SyncId); if (SyncObject == null) // This is the first mod to initialize MBOptionScreen { try { new Harmony("bannerlord.mboptionscreen").PatchAll(typeof(MBOptionScreenSubModule).Assembly); } catch (Exception ex) { // TODO } // Find the latest implementation among loaded mods // as the game seems to be able to load multiple versions of an // assembly if it has a strong name var version = ApplicationVersionParser.TryParse(Managed.GetVersionStr(), out var v) ? v : default; var modOptionsGauntletScreenType = AttributeHelper.Get <ModuleOptionVersionAttribute>(version); var fileStorageType = AttributeHelper.Get <FileStorageVersionAttribute>(version); var settingsStorageType = AttributeHelper.Get <SettingsStorageVersionAttribute>(version); SyncObject = new SyncObjectV1 { FileStorage = (IFileStorage)Activator.CreateInstance(fileStorageType.Type), SettingsStorage = (ISettingsStorage)Activator.CreateInstance(settingsStorageType.Type), ModOptionScreen = modOptionsGauntletScreenType.Type }; Module.CurrentModule.AddInitialStateOption(SyncObject); // Workaround Module.CurrentModule.AddInitialStateOption(new InitialStateOption("ModOptionsMenu", new TextObject("{=HiZbHGvYG}Mod Options"), 9990, () => { var screen = (ScreenBase)Activator.CreateInstance(SyncObject.ModOptionScreen); ScreenManager.PushScreen(screen); }, false)); FileDatabase.FileDatabase.Initialize("ModOptions"); } var settingsEnumerable = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.DefinedTypes) .Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(SettingsBase)) && t != typeof(Settings)); foreach (var settings in settingsEnumerable) { SettingsDatabase.RegisterSettings((SettingsBase)Activator.CreateInstance(settings)); } }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { FileDatabase.Initialise(ModuleFolderName); SettingsDatabase.RegisterSettings(Settings.Instance); Harmony harmony = new Harmony("mod.bannerlord.mipen"); harmony.PatchAll(); } catch (Exception e) { MessageBox.Show("Error initializing Party Screen Improvements: " + e.Message); } }
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()); }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { FileDatabase.Initialise(ModuleFolderName); SettingsDatabase.RegisterSettings(Settings.Instance, Settings.Instance.ModName); var harmony = new Harmony("mod.bannerlord.mipen"); harmony.PatchAll(); } catch (Exception ex) { MessageBox.Show($"Error Initialising Bannerlord Tweaks:\n\n{ex.ToStringFull()}"); } }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { FileDatabase.Initialise(ModuleFolderName); SettingsDatabase.RegisterSettings(Settings.Instance); //var harmony = new Harmony("mod.bannerlord.splintert"); //harmony.PatchAll(); } catch (Exception ex) { ModDebug.ShowError($"Error Initializing ConfigurableXpMultiplier:\n\n{ex.ToStringFull()}"); } }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { FileDatabase.Initialise(ModuleFolderName); BMBSettings settings = FileDatabase.Get <BMBSettings>(BMBSettings.InstanceID) ?? (BMBSettings) new BMBSettings().SetDefaults(); _settings = settings; SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { LogInMessageLog("BMB Error: " + ex.Message); } }
protected override void OnSubModuleLoad() { try { FileDatabase.Initialise(ModuleFolderName); BMRandomTweaksConfiguration settings = FileDatabase.Get <BMRandomTweaksConfiguration>(BMRandomTweaksConfiguration.InstanceID); if (settings == null) { settings = new BMRandomTweaksConfiguration(); } SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { ErrorLog.Log("TournamentsXPanded failed to initialize settings data.\n\n" + ex.ToStringFull()); } }
protected override void OnSubModuleLoad() { InformationManager.DisplayMessage(new InformationMessage("Loaded Horn On Movement Orders Successfully!")); try { FileDatabase.Initialise("HornOnOrders"); HornOnOrdersSettings settings = FileDatabase.Get <HornOnOrdersSettings>(HornOnOrdersSettings.InstanceID); if (settings == null) { settings = new HornOnOrdersSettings(); } SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { //Handle exceptions } base.OnSubModuleLoad(); }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { Settings settings = FileDatabase.Get <Settings>(Settings.SettingsInstanceID); if (settings == null) { settings = new Settings(); } SettingsDatabase.RegisterSettings(settings); var harmony = new Harmony("mod.modlib.patches.mipen"); harmony.PatchAll(); } catch (Exception ex) { ModDebug.ShowError($"An error occurred whilst initialising ModLib", "Error during initialisation", ex); } }
protected override void OnSubModuleLoad() { var dirpath = System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName); try { if (!Directory.Exists(dirpath)) { Directory.CreateDirectory(dirpath); } } catch { MessageBox.Show("Failed to create config directory. Please manually create this directory: " + dirpath); } base.OnSubModuleLoad(); FileDatabase.Initialise(SettingsHelper.ModuleFolderName); TournamentsXPSettingsModLib settings = FileDatabase.Get <TournamentsXPSettingsModLib>(TournamentsXPSettingsModLib.InstanceID) ?? new TournamentsXPSettingsModLib(); SettingsDatabase.RegisterSettings(settings); }
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); }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); try { base.OnSubModuleLoad(); Harmony.DEBUG = true; FileLog.Reset(); Harmony harmony1 = new Harmony("mod.bannerlord.boostleadership"); harmony1.PatchAll(Assembly.GetExecutingAssembly()); FileDatabase.Initialise("BoostLeadership"); BoostLeadershipSettings settings = FileDatabase.Get <BoostLeadershipSettings>(BoostLeadershipSettings.InstanceID); if (settings == null) { settings = new BoostLeadershipSettings(); } SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { FileLog.Log($"Can't load BoostLeadership sub module : {ex.Message}"); //Handle exceptions } }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); XmlReader reader = XmlReader.Create("../../Modules/BattleStamina/SubModule.xml"); reader.ReadToDescendant("Version"); version = reader.GetAttribute("value"); InitializeSprites(); LoadSprites(); FileDatabase.Initialise("BattleStamina"); StaminaProperties settings = FileDatabase.Get <StaminaProperties>(StaminaProperties.InstanceID); if (settings == null) { settings = new StaminaProperties(); } SettingsDatabase.RegisterSettings(settings); new Harmony("mod.jrzrh.BattleStamina").PatchAll(); _uiExtender.Register(); }
protected override void OnBeforeInitialModuleScreenSetAsRoot() { SettingsDatabase.RegisterSettings(new TestSettings()); }