From 037a653eca05252bc9e9546b05f8aa730136330d Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Wed, 12 May 2021 12:58:38 -0400 Subject: [PATCH] Add startup message --- CLre/CLre.cs | 36 ++++++++++++++++++-- CLre/Fixes/BugfixAttribute.cs | 62 +++++++++++++++++++++-------------- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/CLre/CLre.cs b/CLre/CLre.cs index 47b618b..b12c6cb 100644 --- a/CLre/CLre.cs +++ b/CLre/CLre.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -19,6 +20,11 @@ namespace CLre public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); internal static Harmony harmonyInstance = null; + + internal static bool _isInidicatorActive = true; + + internal static string _indicatorMsg = " CLre loading..."; + // called when Cardlife shuts down public override void OnApplicationQuit() { @@ -46,6 +52,8 @@ namespace CLre // misc LogIPAPlugins(); Fixes.BugfixAttributeUtility.LogBugfixes(); + BuildIndicatorMessage(); + API.App.Client.MenuReady += (_, __) => { _isInidicatorActive = false; }; // dismiss CLre msg // Log info API.Utility.Logging.MetaLog($"{Name} init complete."); @@ -103,12 +111,36 @@ namespace CLre sb.AppendFormat("-----------------------------\n"); API.Utility.Logging.Log(sb.ToString()); } + + private void BuildIndicatorMessage() + { + int fixCount = Fixes.BugfixAttributeUtility.Count; + int modCount = IllusionInjector.PluginManager.Plugins.Count(); + StringBuilder sb = new StringBuilder(); + sb.AppendFormat(" {0} {1}\n", Name, Version); + sb.AppendFormat("{0} bugfixes, {1} plugins, no frills", fixCount, modCount); +#if DEBUG + sb.AppendFormat(" DEBUG version\n"); +#endif +#if RELEASE + sb.AppendFormat(" RELEASE version\n"); +#endif + sb.AppendFormat(" Starting up...\n"); + _indicatorMsg = sb.ToString(); + } public override void OnGUI() { - if (GUI.Button(new Rect(10, 10, 50, 50), "TEST")) + // CLre startup inidicator + if (_isInidicatorActive) { - + GUILayout.BeginVertical(); + GUILayout.Label(_indicatorMsg); + if (GUILayout.Button("Hide")) + { + _isInidicatorActive = false; + } + GUILayout.EndVertical(); } } } diff --git a/CLre/Fixes/BugfixAttribute.cs b/CLre/Fixes/BugfixAttribute.cs index f406374..fc2d1da 100644 --- a/CLre/Fixes/BugfixAttribute.cs +++ b/CLre/Fixes/BugfixAttribute.cs @@ -29,30 +29,17 @@ namespace CLre.Fixes internal static class BugfixAttributeUtility { + public static int Count { get; private set; } + public static void LogBugfixes() { - List keys = new List(); - Dictionary fixes = new Dictionary(); - foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) - { - BugfixAttribute b = t.GetCustomAttribute(true); - if (b != null) - { - if (!fixes.ContainsKey(b.id)) - { - BugfixStruct bugfixStruct = new BugfixStruct{id = b.id}; - bugfixStruct.Merge(b); - fixes[b.id] = bugfixStruct; - keys.Add(b.id); - } - else - { - BugfixStruct bugfixStruct = fixes[b.id]; - bugfixStruct.Merge(b); - fixes[b.id] = bugfixStruct; - } - } - } + API.Utility.Logging.Log(BugfixMessage()); + } + + public static string BugfixMessage() + { + Dictionary fixes = Bugfixes(); + List keys = new List(fixes.Keys); keys.Sort(); //keys.Sort((u, u1) => u.CompareTo(u1)); StringBuilder sb = new StringBuilder(); @@ -64,10 +51,37 @@ namespace CLre.Fixes sb.Append("\n"); } sb.AppendFormat("-----------------------------\n"); - API.Utility.Logging.Log(sb.ToString()); + return sb.ToString(); } - private struct BugfixStruct + public static Dictionary Bugfixes() + { + Dictionary fixes = new Dictionary(); + foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) + { + BugfixAttribute b = t.GetCustomAttribute(true); + if (b != null) + { + if (!fixes.ContainsKey(b.id)) + { + BugfixStruct bugfixStruct = new BugfixStruct{id = b.id}; + bugfixStruct.Merge(b); + fixes[b.id] = bugfixStruct; + } + else + { + BugfixStruct bugfixStruct = fixes[b.id]; + bugfixStruct.Merge(b); + fixes[b.id] = bugfixStruct; + } + } + } + + Count = fixes.Count; + return fixes; + } + + public struct BugfixStruct { public string name; public string description;