Browse Source

Add startup message

tags/v0.0.2
NGnius (Graham) 3 years ago
parent
commit
037a653eca
2 changed files with 63 additions and 17 deletions
  1. +34
    -2
      CLre/CLre.cs
  2. +29
    -15
      CLre/Fixes/BugfixAttribute.cs

+ 34
- 2
CLre/CLre.cs View File

@@ -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();
}
}
}


+ 29
- 15
CLre/Fixes/BugfixAttribute.cs View File

@@ -29,9 +29,33 @@ namespace CLre.Fixes

internal static class BugfixAttributeUtility
{
public static int Count { get; private set; }

public static void LogBugfixes()
{
List<uint> keys = new List<uint>();
API.Utility.Logging.Log(BugfixMessage());
}

public static string BugfixMessage()
{
Dictionary<uint, BugfixStruct> fixes = Bugfixes();
List<uint> keys = new List<uint>(fixes.Keys);
keys.Sort();
//keys.Sort((u, u1) => u.CompareTo(u1));
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Applying {0} CLre fixes\n", keys.Count);
sb.AppendFormat("-----------------------------\n");
foreach (uint i in keys)
{
sb.Append(fixes[i].ToString());
sb.Append("\n");
}
sb.AppendFormat("-----------------------------\n");
return sb.ToString();
}

public static Dictionary<uint, BugfixStruct> Bugfixes()
{
Dictionary<uint, BugfixStruct> fixes = new Dictionary<uint, BugfixStruct>();
foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
{
@@ -43,7 +67,6 @@ namespace CLre.Fixes
BugfixStruct bugfixStruct = new BugfixStruct{id = b.id};
bugfixStruct.Merge(b);
fixes[b.id] = bugfixStruct;
keys.Add(b.id);
}
else
{
@@ -53,21 +76,12 @@ namespace CLre.Fixes
}
}
}
keys.Sort();
//keys.Sort((u, u1) => u.CompareTo(u1));
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Applying {0} CLre fixes\n", keys.Count);
sb.AppendFormat("-----------------------------\n");
foreach (uint i in keys)
{
sb.Append(fixes[i].ToString());
sb.Append("\n");
}
sb.AppendFormat("-----------------------------\n");
API.Utility.Logging.Log(sb.ToString());

Count = fixes.Count;
return fixes;
}

private struct BugfixStruct
public struct BugfixStruct
{
public string name;
public string description;


Loading…
Cancel
Save