internal string ProblemSummary(Report.ReportFormat reportFormat, string prefix, uint maxLines) { string summary = string.Empty; uint found = 0; for (uint i = 0; i < (uint)ProblemType.Last && found < maxLines; ++i) { if (m_problemCount[i] > 0) { var problemHeadline = ProblemDescription((ProblemType)i, m_problemCount[i]); switch (reportFormat) { case Report.ReportFormat.Gist: summary += "<li>" + problemHeadline + "</li><ul>" + IncidentList((ProblemType)i, "<li>", "</li>", maxLines, ref found) + "</ul>"; break; default: summary += prefix + problemHeadline + "\n"; summary += IncidentList((ProblemType)i, prefix, "\n", maxLines, ref found); break; } } } return(summary); }
internal string ListMissingAssemblies(Report.ReportFormat reportFormat) { string str = string.Empty; foreach (var m in m_missingAssemblies) { switch (reportFormat) { case Report.ReportFormat.Gist: str += $"<li>*missing*: `{m.Name}[{m.Version}]`</li>"; break; default: str += $" [ERR] missing: {m.Name}[{m.Version}]\n"; break; } } return(str); }
internal string Summary(bool brief, Report.ReportFormat reportFormat) { bool isLocal = plugin.publishedFileID == PublishedFileId.invalid; string strEnabled; switch (reportFormat) { case Report.ReportFormat.Gist: strEnabled = plugin.isEnabled ? "x |" : " |"; break; default: strEnabled = plugin.isEnabled ? "*" : " "; break; } string location; if (plugin.isBuiltin) { location = "(built-in)"; } else if (isLocal) { var modDir = new System.IO.DirectoryInfo(plugin.modPath); switch (reportFormat) { case Report.ReportFormat.Gist: location = $"`{modDir.Name}`"; break; default: location = $"'{modDir.Name}'"; break; } } else { if (brief) { location = plugin.publishedFileID.AsUInt64.ToString(); } else { var url = "https://steamcommunity.com/sharedfiles/filedetails/?id=" + plugin.publishedFileID.AsUInt64; switch (reportFormat) { case Report.ReportFormat.Gist: location = $"[`{plugin.publishedFileID.AsUInt64.ToString()}`]({url})"; break; case Report.ReportFormat.SteamForum: location = $"[url={url}]{plugin.publishedFileID.AsUInt64.ToString()}[/url]"; break; default: location = plugin.publishedFileID.AsUInt64.ToString(); break; } } } string harmonyVer = needsHarmony != null ? $"0H: {needsHarmony.ToString()}" : needsNewHarmony != null ? $"CH: {needsNewHarmony.ToString()}" : string.Empty; string harmonyAPI = needsHarmonyAPI != null?needsHarmonyAPI.ToString() : string.Empty; string summaryLines; string problems; string missingAssembliesStr = string.Empty; if (missingAssemblies.Count > 0) { missingAssembliesStr += ListMissingAssemblies(reportFormat); } switch (reportFormat) { case Report.ReportFormat.Gist: problems = ProblemSummary(reportFormat, null, brief ? Report.MAX_PROBLEMS_PER_TYPE_IN_DISPLAY : Report.MAX_PROBLEMS_PER_TYPE_IN_LOG); summaryLines = $"{strEnabled} {location} | `{modType.Max(31)}` |"; if (!string.IsNullOrEmpty(problems) || missingAssemblies.Count > 0) { summaryLines += " <ul>" + problems + missingAssembliesStr + "</ul>"; } summaryLines += $" | {Name.Max(31)} | "; if (!string.IsNullOrEmpty(harmonyVer)) { summaryLines += $"`{harmonyVer}`"; } summaryLines += " | "; if (!string.IsNullOrEmpty(harmonyAPI)) { summaryLines += $"`{harmonyAPI}`"; } summaryLines += "\n"; break; default: problems = ProblemSummary(reportFormat, " [ERR] ", brief ? Report.MAX_PROBLEMS_PER_TYPE_IN_DISPLAY : Report.MAX_PROBLEMS_PER_TYPE_IN_LOG); summaryLines = $"{strEnabled} {location.Max(23),-24} {modType.Max(31),-32} {Name.Max(31),-32} {harmonyVer,-14} {harmonyAPI,-10}\n"; summaryLines += problems + missingAssembliesStr; break; } return(summaryLines); }