コード例 #1
0
 /// <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));
 }
コード例 #2
0
        protected override void OnSubModuleLoad()
        {
            try
            {
                FileDatabase.Initialise(ModuleFolderName);

                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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: SettingsDatabase.cs プロジェクト: mm9696911/ModLib
        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);
        }
コード例 #5
0
 /// <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)
 {
     return(FileDatabase.SaveToFile(settingsInstance.ModuleFolderName, settingsInstance, FileDatabase.Location.Configs));
 }