Refactored another slightly stupid thing

This commit is contained in:
pan.codes 2024-04-03 22:10:34 +02:00
parent 2b1b787c7f
commit 4510c05819

View file

@ -78,14 +78,14 @@ namespace SMSModLogOutputAnalyzer
Log("Initial analysis complete.");
values[":page_facing_up: Game Version"] = new List<string> { lines["[Message:MelonLoader] Game Version: "][0].Item1 };
values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List<string> { lines["[Message:MelonLoader] Unity Version: "][0].Item1 };
values[":tools: BepInEx Version"] = new List<string> { lines["[Message: BepInEx] BepInEx "][0].Item1.Split(" - ")[0] };
values[":page_facing_up: Game Version"] = new List<string> { lines["[Message:MelonLoader] Game Version: "][0].Line };
values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List<string> { lines["[Message:MelonLoader] Unity Version: "][0].Line };
values[":tools: BepInEx Version"] = new List<string> { lines["[Message: BepInEx] BepInEx "][0].Line.Split(" - ")[0] };
List<string> part = new();
foreach (var mod in lines["[Info : BepInEx] Loading ["])
{
var match = Regex.Match(mod.Item1, "(.+) ((\\d+\\.)+\\d+)\\]");
var match = Regex.Match(mod.Line, "(.+) ((\\d+\\.)+\\d+)\\]");
part.Add("**" + match.Groups[1] + "** " + match.Groups[2]);
}
values[":tools: Loaded BepInEx Mods"] = part;
@ -93,7 +93,7 @@ namespace SMSModLogOutputAnalyzer
foreach (var mod in lines["[Message:MelonLoader] Assembly: "])
{
string line = textLines[mod.Item2 - 1];
string line = textLines[mod.LineNumber - 1];
var match = Regex.Match(line, "\\[.+\\] (.+) v((\\d+\\.)+\\d+).+");
part.Add("**" + match.Groups[1] + "** " + match.Groups[2]);
}
@ -108,11 +108,11 @@ namespace SMSModLogOutputAnalyzer
List<string> filetree = new();
Dictionary<int, string> depths = new();
values[":file_folder: Install Directory"] = new List<string> { lines["[Message: File Tree] "][0].Item1 };
values[":file_folder: Install Directory"] = new List<string> { lines["[Message: File Tree] "][0].Line };
foreach (var lineTuple in lines["[Message: File Tree] "])
{
string line = lineTuple.Item1;
string line = lineTuple.Line;
if (!line.Contains("--")) continue;
int depth = 0;
while (line.StartsWith("| ") || line.StartsWith(" "))
@ -188,9 +188,19 @@ namespace SMSModLogOutputAnalyzer
Log(e.StackTrace);
}
}
public static Dictionary<string, List<Tuple<string, int>>> FindLines(string[] file, params string[] lines)
public struct FoundLine
{
Dictionary<string, List<Tuple<string, int>>> results = new();
public string Line;
public int LineNumber;
public FoundLine(string line, int lineNumber)
{
Line = line;
LineNumber = lineNumber;
}
}
public static Dictionary<string, List<FoundLine>> FindLines(string[] file, params string[] lines)
{
Dictionary<string, List<FoundLine>> results = new();
int i = 0;
foreach (var start in lines) results[start] = new();
foreach (var line in file)