From cf9634f622069c028a04f394838b0091c053ffc8 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 29 Jul 2018 22:30:21 -0500 Subject: [PATCH] Documented some stuff --- IllusionInjector/IllusionInjector.csproj | 1 + .../BeatSaber/IEnhancedBeatSaberPlugin.cs | 3 ++ IllusionPlugin/IPA/IEnhancedPlugin.cs | 3 ++ IllusionPlugin/IPA/IGenericEnhancedPlugin.cs | 6 +++ IllusionPlugin/IniFile.cs | 3 +- IllusionPlugin/Logger.cs | 44 +++++++++++++++++-- IllusionPlugin/ModPrefs.cs | 12 +++++ 7 files changed, 67 insertions(+), 5 deletions(-) diff --git a/IllusionInjector/IllusionInjector.csproj b/IllusionInjector/IllusionInjector.csproj index acee2e3f..7008659c 100644 --- a/IllusionInjector/IllusionInjector.csproj +++ b/IllusionInjector/IllusionInjector.csproj @@ -43,6 +43,7 @@ ..\Libs\UnityEngine.CoreModule.dll + False diff --git a/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs b/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs index a8575c41..dfbd4f9f 100644 --- a/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs +++ b/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs @@ -4,6 +4,9 @@ using System.Text; namespace IllusionPlugin { + /// + /// An enhanced version of a standard BeatSaber plugin. + /// public interface IEnhancedBeatSaberPlugin : IBeatSaberPlugin, IGenericEnhancedPlugin { } diff --git a/IllusionPlugin/IPA/IEnhancedPlugin.cs b/IllusionPlugin/IPA/IEnhancedPlugin.cs index 0ba8d5fb..ac925b2e 100644 --- a/IllusionPlugin/IPA/IEnhancedPlugin.cs +++ b/IllusionPlugin/IPA/IEnhancedPlugin.cs @@ -4,6 +4,9 @@ using System.Text; namespace IllusionPlugin { + /// + /// An enhanced version of the standard IPA plugin. + /// [Obsolete("When building plugins for Beat Saber, use IEnhancedBeatSaberPlugin")] public interface IEnhancedPlugin : IPlugin, IGenericEnhancedPlugin { diff --git a/IllusionPlugin/IPA/IGenericEnhancedPlugin.cs b/IllusionPlugin/IPA/IGenericEnhancedPlugin.cs index 6beb8bea..80327f5c 100644 --- a/IllusionPlugin/IPA/IGenericEnhancedPlugin.cs +++ b/IllusionPlugin/IPA/IGenericEnhancedPlugin.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace IllusionPlugin { + /// + /// A generic interface for the modification for enhanced plugins. + /// public interface IGenericEnhancedPlugin { /// @@ -14,6 +17,9 @@ namespace IllusionPlugin /// { "PlayClub", "PlayClubStudio" } string[] Filter { get; } + /// + /// Called after Update. + /// void OnLateUpdate(); } } diff --git a/IllusionPlugin/IniFile.cs b/IllusionPlugin/IniFile.cs index cf60a61e..b8f47bce 100644 --- a/IllusionPlugin/IniFile.cs +++ b/IllusionPlugin/IniFile.cs @@ -62,7 +62,7 @@ namespace IllusionPlugin /// /// INIFile Constructor. /// - /// + /// public IniFile(string iniPath) { IniFileInfo = new FileInfo(iniPath); @@ -88,7 +88,6 @@ namespace IllusionPlugin /// /// /// - /// /// public string IniReadValue(string Section, string Key) { diff --git a/IllusionPlugin/Logger.cs b/IllusionPlugin/Logger.cs index 15079c97..6f4a356b 100644 --- a/IllusionPlugin/Logger.cs +++ b/IllusionPlugin/Logger.cs @@ -7,6 +7,9 @@ using System.Threading; using IllusionPlugin; namespace IllusionPlugin { + /// + /// A general purpose logging class for any plugin to use. + /// public class Logger { private static BlockingCollection _logQueue; private static Thread _watcherThread; @@ -47,12 +50,20 @@ namespace IllusionPlugin { } } + /// + /// Creates a logger with the specified name. + /// + /// the name of the logger public Logger(string modName = "Default") { SetupStatic(); _logFile = GetPath(modName); _logFile.Create().Close(); } + /// + /// Creates a logger for the specified plugin. + /// + /// the plugin to associate the logger with public Logger(IBeatSaberPlugin plugin) { SetupStatic(); @@ -60,24 +71,40 @@ namespace IllusionPlugin { _logFile.Create().Close(); } + /// + /// Sends a message to the log. + /// + /// the message to send public void Log(string msg) { if(!_watcherThread.IsAlive) throw new Exception("Logger is Closed!"); //_logQueue.Add(new logMessage($"[LOG @ {DateTime.Now:HH:mm:ss} | {ModName}] {msg}", WarningLevel.Log)); _logQueue.Add(new logMessage(msg, this, DateTime.Now, WarningLevel.Log)); } - + + /// + /// Sends an error to the log. + /// + /// the message to send public void Error(string msg) { if(!_watcherThread.IsAlive) throw new Exception("Logger is Closed!"); //_logQueue.Add(new logMessage($"[ERROR @ {DateTime.Now:HH:mm:ss} | {ModName}] {msg}", WarningLevel.Error)); _logQueue.Add(new logMessage(msg, this, DateTime.Now, WarningLevel.Error)); } - + + /// + /// Sends an exception to the log. + /// + /// the message to send public void Exception(string msg) { if(!_watcherThread.IsAlive) throw new Exception("Logger is Closed!"); //_logQueue.Add(new logMessage($"[EXCEPTION @ {DateTime.Now:HH:mm:ss} | {ModName}] {msg}", WarningLevel.Exception)); _logQueue.Add(new logMessage(msg, this, DateTime.Now, WarningLevel.Exception)); } + /// + /// Sends a warning to the log. + /// + /// the message to send public void Warning(string msg) { if(!_watcherThread.IsAlive) throw new Exception("Logger is Closed!"); //_logQueue.Add(new logMessage($"[WARNING @ {DateTime.Now:HH:mm:ss} | {ModName}] {msg}", WarningLevel.Warning)); @@ -114,7 +141,10 @@ namespace IllusionPlugin { kvp.Value.Dispose(); } } - + + /// + /// Stops the logger background thread. + /// public static void Stop() { _threadRunning = false; _watcherThread.Join(); @@ -144,7 +174,15 @@ namespace IllusionPlugin { } } + /// + /// + /// public static class LoggerExtensions { + /// + /// Gets a logger for the provided plugin. + /// + /// the plugin to get a logger for + /// a Logger instance public static Logger GetLogger(this IBeatSaberPlugin plugin) { return new Logger(plugin); } diff --git a/IllusionPlugin/ModPrefs.cs b/IllusionPlugin/ModPrefs.cs index e3423a17..4f49e3ee 100644 --- a/IllusionPlugin/ModPrefs.cs +++ b/IllusionPlugin/ModPrefs.cs @@ -15,6 +15,10 @@ namespace IllusionPlugin private IniFile Instance; + /// + /// Constructs a ModPrefs object for the provide plugin. + /// + /// the plugin to get the preferences file for public ModPrefs(IBeatSaberPlugin plugin) { Instance = new IniFile(Path.Combine(Environment.CurrentDirectory, $"UserData/ModPrefs/{plugin.Name}.ini")); ModPrefses.Add(plugin, this); @@ -159,7 +163,15 @@ namespace IllusionPlugin } + /// + /// An extension class for IBeatSaberPlugins. + /// public static class ModPrefsExtensions { + /// + /// Gets the ModPrefs object for the provided plugin. + /// + /// the plugin wanting the prefrences + /// the ModPrefs object public static ModPrefs GetModPrefs(this IBeatSaberPlugin plugin) { return ModPrefs.ModPrefses.First(o => o.Key == plugin).Value; }