From 4510c0581991dc06d67eb2ad11cfb35e02726a4e Mon Sep 17 00:00:00 2001 From: Jonathan Riedel Date: Wed, 3 Apr 2024 22:10:34 +0200 Subject: [PATCH] Refactored another slightly stupid thing --- SMSModLogOutputAnalyzer/CommandModule.cs | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/SMSModLogOutputAnalyzer/CommandModule.cs b/SMSModLogOutputAnalyzer/CommandModule.cs index 9629cde..fb3dd20 100644 --- a/SMSModLogOutputAnalyzer/CommandModule.cs +++ b/SMSModLogOutputAnalyzer/CommandModule.cs @@ -78,14 +78,14 @@ namespace SMSModLogOutputAnalyzer Log("Initial analysis complete."); - values[":page_facing_up: Game Version"] = new List { lines["[Message:MelonLoader] Game Version: "][0].Item1 }; - values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List { lines["[Message:MelonLoader] Unity Version: "][0].Item1 }; - values[":tools: BepInEx Version"] = new List { lines["[Message: BepInEx] BepInEx "][0].Item1.Split(" - ")[0] }; + values[":page_facing_up: Game Version"] = new List { lines["[Message:MelonLoader] Game Version: "][0].Line }; + values[":diamond_shape_with_a_dot_inside: Unity Version"] = new List { lines["[Message:MelonLoader] Unity Version: "][0].Line }; + values[":tools: BepInEx Version"] = new List { lines["[Message: BepInEx] BepInEx "][0].Line.Split(" - ")[0] }; List 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 filetree = new(); Dictionary depths = new(); - values[":file_folder: Install Directory"] = new List { lines["[Message: File Tree] "][0].Item1 }; + values[":file_folder: Install Directory"] = new List { 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>> FindLines(string[] file, params string[] lines) + public struct FoundLine { - Dictionary>> results = new(); + public string Line; + public int LineNumber; + public FoundLine(string line, int lineNumber) + { + Line = line; + LineNumber = lineNumber; + } + } + public static Dictionary> FindLines(string[] file, params string[] lines) + { + Dictionary> results = new(); int i = 0; foreach (var start in lines) results[start] = new(); foreach (var line in file)