diff options
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 23 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs | 3 | ||||
-rw-r--r-- | src/SMAPI.Web/Views/LogParser/Index.cshtml | 19 | ||||
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/css/log-parser.css | 6 |
4 files changed, 50 insertions, 1 deletions
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index 1c3b5671..23a1baa4 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -31,6 +31,12 @@ namespace StardewModdingAPI.Web.Framework.LogParsing /// <summary>A regex pattern matching an entry in SMAPI's mod list.</summary> private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + /// <summary>A regex pattern matching the start of SMAPI's content pack list.</summary> + private readonly Regex ContentPackListStartPattern = new Regex(@"^Loaded \d+ content packs:$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + /// <summary>A regex pattern matching an entry in SMAPI's content pack list.</summary> + private readonly Regex ContentPackListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| for (?<for>.+?) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + /********* ** Public methods @@ -62,6 +68,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing LogModInfo smapiMod = new LogModInfo { Name = "SMAPI", Author = "Pathoschild", Description = "" }; IDictionary<string, LogModInfo> mods = new Dictionary<string, LogModInfo>(); bool inModList = false; + bool inContentPackList = false; foreach (LogMessage message in log.Messages) { // collect stats @@ -79,6 +86,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing // update flags if (inModList && !this.ModListEntryPattern.IsMatch(message.Text)) inModList = false; + if (inContentPackList && !this.ContentPackListEntryPattern.IsMatch(message.Text)) + inContentPackList = false; // mod list if (!inModList && message.Level == LogLevel.Info && this.ModListStartPattern.IsMatch(message.Text)) @@ -93,6 +102,20 @@ namespace StardewModdingAPI.Web.Framework.LogParsing mods[name] = new LogModInfo { Name = name, Author = author, Version = version, Description = description }; } + // content pack list + else if (!inContentPackList && message.Level == LogLevel.Info && this.ContentPackListStartPattern.IsMatch(message.Text)) + inContentPackList = true; + else if (inContentPackList) + { + Match match = this.ContentPackListEntryPattern.Match(message.Text); + string name = match.Groups["name"].Value; + string version = match.Groups["version"].Value; + string author = match.Groups["author"].Value; + string description = match.Groups["description"].Value; + string forMod = match.Groups["for"].Value; + mods[name] = new LogModInfo { Name = name, Author = author, Version = version, Description = description, ContentPackFor = forMod }; + } + // platform info line else if (message.Level == LogLevel.Info && this.InfoLinePattern.IsMatch(message.Text)) { diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs index 2005e61f..8c84ab38 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ModInfo.cs @@ -18,6 +18,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models /// <summary>The mod description.</summary> public string Description { get; set; } + /// <summary>The name of the mod for which this is a content pack (if applicable).</summary> + public string ContentPackFor { get; set; } + /// <summary>The number of errors logged by this mod.</summary> public int Errors { get; set; } } diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 8d1abbb1..20e20ee1 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -1,5 +1,10 @@ @{ ViewData["Title"] = "SMAPI log parser"; + + Dictionary<string, LogModInfo[]> contentPacks = Model.ParsedLog?.Mods + ?.GroupBy(mod => mod.ContentPackFor) + .Where(group => group.Key != null) + .ToDictionary(group => group.Key, group => group.ToArray()); } @using Newtonsoft.Json @using StardewModdingAPI.Web.Framework.LogParsing.Models @@ -69,10 +74,22 @@ <span class="notice btn txt" v-on:click="showAllMods" v-if="stats.modsHidden > 0">show all</span> <span class="notice btn txt" v-on:click="hideAllMods" v-if="stats.modsShown > 0 && stats.modsHidden > 0">hide all</span> </caption> - @foreach (var mod in Model.ParsedLog.Mods) + @foreach (var mod in Model.ParsedLog.Mods.Where(p => p.ContentPackFor == null)) { <tr v-on:click="toggleMod('@mod.Name')" class="mod-entry" v-bind:class="{ hidden: !showMods['@mod.Name'] }"> <td><input type="checkbox" v-bind:checked="showMods['@mod.Name']" v-if="anyModsHidden" /></td> + <td> + @mod.Name + @if (contentPacks != null && contentPacks.TryGetValue(mod.Name, out LogModInfo[] contentPackList)) + { + <div class="content-packs"> + @foreach (var contentPack in contentPackList) + { + <text>+@contentPack.Name @contentPack.Version</text> + } + </div> + } + </td> <td>@mod.Version</td> <td>@mod.Author</td> @if (mod.Errors == 0) diff --git a/src/SMAPI.Web/wwwroot/Content/css/log-parser.css b/src/SMAPI.Web/wwwroot/Content/css/log-parser.css index a3be0c85..cbf09ffe 100644 --- a/src/SMAPI.Web/wwwroot/Content/css/log-parser.css +++ b/src/SMAPI.Web/wwwroot/Content/css/log-parser.css @@ -97,6 +97,12 @@ table#mods { opacity: 0.5; } +#mods .content-packs { + margin-left: 1em; + font-size: 0.9em; + font-style: italic; +} + #metadata td:first-child { padding-right: 5px; } |