protected override void OnSubModuleLoad() { try { FileDatabase.Initialise(ModuleFolderName); SettingsDatabase.RegisterSettings(FileDatabase.Get <Settings>(Settings.SettingsInstanceID)); var harmony = new Harmony("mod.modlib.mipen"); harmony.PatchAll(); Module.CurrentModule.AddInitialStateOption(new InitialStateOption("ModOptionsMenu", new TextObject("Mod Options"), 9990, () => { ScreenManager.PushScreen(new ModOptionsGauntletScreen()); }, false)); } catch (Exception ex) { ModDebug.ShowError($"An error occurred whilst initialising ModLib", "Error during initialisation", ex); } }
internal static void LoadSettingsFromType(Type t) { SettingsBase defaultSB = (SettingsBase)Activator.CreateInstance(t); SettingsBase sb = FileDatabase.Get <SettingsBase>(defaultSB.ID); if (sb == null) { string path = Path.Combine(FileDatabase.GetPathForModule(defaultSB.ModuleFolderName, FileDatabase.Location.Configs), FileDatabase.GetFileNameFor(defaultSB)); if (File.Exists(path)) { FileDatabase.LoadFromFile(path); sb = FileDatabase.Get <SettingsBase>(defaultSB.ID); } if (sb == null) { sb = defaultSB; } } RegisterSettings(sb); }