Add startup message

This commit is contained in:
NGnius (Graham) 2021-05-12 12:58:38 -04:00
parent 7c304c8bdc
commit 037a653eca
2 changed files with 72 additions and 26 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -19,6 +20,11 @@ namespace CLre
public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
internal static Harmony harmonyInstance = null; internal static Harmony harmonyInstance = null;
internal static bool _isInidicatorActive = true;
internal static string _indicatorMsg = " CLre loading...";
// called when Cardlife shuts down // called when Cardlife shuts down
public override void OnApplicationQuit() public override void OnApplicationQuit()
{ {
@ -46,6 +52,8 @@ namespace CLre
// misc // misc
LogIPAPlugins(); LogIPAPlugins();
Fixes.BugfixAttributeUtility.LogBugfixes(); Fixes.BugfixAttributeUtility.LogBugfixes();
BuildIndicatorMessage();
API.App.Client.MenuReady += (_, __) => { _isInidicatorActive = false; }; // dismiss CLre msg
// Log info // Log info
API.Utility.Logging.MetaLog($"{Name} init complete."); API.Utility.Logging.MetaLog($"{Name} init complete.");
@ -103,12 +111,36 @@ namespace CLre
sb.AppendFormat("-----------------------------\n"); sb.AppendFormat("-----------------------------\n");
API.Utility.Logging.Log(sb.ToString()); 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() 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();
} }
} }
} }

View file

@ -29,30 +29,17 @@ namespace CLre.Fixes
internal static class BugfixAttributeUtility internal static class BugfixAttributeUtility
{ {
public static int Count { get; private set; }
public static void LogBugfixes() public static void LogBugfixes()
{ {
List<uint> keys = new List<uint>(); API.Utility.Logging.Log(BugfixMessage());
Dictionary<uint, BugfixStruct> fixes = new Dictionary<uint, BugfixStruct>(); }
foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
{ public static string BugfixMessage()
BugfixAttribute b = t.GetCustomAttribute<BugfixAttribute>(true); {
if (b != null) Dictionary<uint, BugfixStruct> fixes = Bugfixes();
{ List<uint> keys = new List<uint>(fixes.Keys);
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;
}
}
}
keys.Sort(); keys.Sort();
//keys.Sort((u, u1) => u.CompareTo(u1)); //keys.Sort((u, u1) => u.CompareTo(u1));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -64,10 +51,37 @@ namespace CLre.Fixes
sb.Append("\n"); sb.Append("\n");
} }
sb.AppendFormat("-----------------------------\n"); sb.AppendFormat("-----------------------------\n");
API.Utility.Logging.Log(sb.ToString()); return sb.ToString();
} }
private struct BugfixStruct public static Dictionary<uint, BugfixStruct> Bugfixes()
{
Dictionary<uint, BugfixStruct> fixes = new Dictionary<uint, BugfixStruct>();
foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
{
BugfixAttribute b = t.GetCustomAttribute<BugfixAttribute>(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 name;
public string description; public string description;