diff --git a/SonsGameManager/ModManagerUi.cs b/SonsGameManager/ModManagerUi.cs index 111055c..0bc3763 100644 --- a/SonsGameManager/ModManagerUi.cs +++ b/SonsGameManager/ModManagerUi.cs @@ -99,6 +99,11 @@ internal static void Create() scroll.Add(ModCard(data)); } + foreach (var report in SonsSdk.ModReport.ModReports) + { + scroll.Add(ModReportCard(report)); + } + AddModsButton(); panel.Active(false); @@ -149,6 +154,18 @@ private static SContainerOptions ModCard(ModCardData data) return container; } + + private static SContainerOptions ModReportCard(ModReport.ModReportInfo data) + { + var container = SContainer.Background(Color.black.WithAlpha(0.5f), EBackground.None).PHeight(100) + - SLabel.RichText($"{data.ModId}").FontSize(22) + .Font(EFont.RobotoRegular) + .Dock(EDockType.Fill).Alignment(TextAlignmentOptions.MidlineLeft).Margin(50, 0, 0, 0) + - SLabel.Text(data.Message).Alignment(TextAlignmentOptions.MidlineRight).Pivot(1).Anchor(AnchorType.MiddleRight) + .FontSize(15).Position(-250).FontColor("#dcdcaa"); + + return container; + } private static SContainerOptions ModLoaderCard() { diff --git a/SonsLoaderPlugin/Core.cs b/SonsLoaderPlugin/Core.cs index 9f4f002..784f75f 100644 --- a/SonsLoaderPlugin/Core.cs +++ b/SonsLoaderPlugin/Core.cs @@ -36,15 +36,18 @@ private ResolvedMelons Resolver(MelonAssembly melonAssembly) if (manifest.Platform == "Client" && LoaderEnvironment.IsDedicatedServer) { RLog.Error($"Mod {assembly.FullName} is a client mod and cannot be loaded on a dedicated server."); + ModReport.ReportMod(manifest.Id, "Client mod cannot be loaded on a dedicated server."); } else if (manifest.Platform == "Server" && !LoaderEnvironment.IsDedicatedServer) { RLog.Error($"Mod {assembly.FullName} is a server mod and cannot be loaded on a client."); + ModReport.ReportMod(manifest.Id, "Server mod cannot be loaded on a client."); } - else if (!string.IsNullOrEmpty(manifest.LoaderVersion) && LoaderUtils.IsCompatible(manifest.LoaderVersion)) + else if (!string.IsNullOrEmpty(manifest.LoaderVersion) && !LoaderUtils.IsCompatible(manifest.LoaderVersion)) { RLog.Error($"Mod {assembly.FullName} requires a different version of RedLoader."); - LoaderUtils.ShowMessageBox($"Mod {manifest.Id} requires a newer version of RedLoader."); + //LoaderUtils.ShowMessageBox($"Mod {manifest.Id} requires a newer version of RedLoader."); + ModReport.ReportMod(manifest.Id, $"Requires RedLoader >={manifest.LoaderVersion}"); } else if (InitMod(melonAssembly, manifest, out var mod)) { @@ -58,6 +61,7 @@ private ResolvedMelons Resolver(MelonAssembly melonAssembly) else { RLog.Error($"{assembly.FullName} does not have a manifest.json file."); + ModReport.ReportMod(assembly.GetName().Name, "Missing manifest.json"); } return new ResolvedMelons(melons.ToArray(), rottenMelons.ToArray()); diff --git a/SonsSdk/ModReport.cs b/SonsSdk/ModReport.cs new file mode 100644 index 0000000..91a7561 --- /dev/null +++ b/SonsSdk/ModReport.cs @@ -0,0 +1,21 @@ +namespace SonsSdk; + +public static class ModReport +{ + internal static List ModReports = new(); + + public static void ReportMod(string modId, string message) + { + ModReports.Add(new ModReportInfo() + { + ModId = modId, + Message = message + }); + } + + public class ModReportInfo + { + public string ModId; + public string Message; + } +} \ No newline at end of file