From 418c64f2b4297228c1ad1e789c0ba4e7a6be1030 Mon Sep 17 00:00:00 2001 From: KlaasWhite <45828001+KlaasWhite@users.noreply.github.com> Date: Sun, 2 Aug 2026 23:06:46 +0200 Subject: [PATCH 1/2] Fix: Ensure arguments passed to KSA are read from both input args and settings (#84) --- StarMap/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarMap/Program.cs b/StarMap/Program.cs index 05f51f7..7629222 100644 --- a/StarMap/Program.cs +++ b/StarMap/Program.cs @@ -18,7 +18,7 @@ static async Task Main(string[] args) AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.GetFullPath("./0Harmony.dll")); var gameAssemblyContext = new CoreAssemblyLoadContext(gameConfig.GameLocation); - using var gameSurveyer = new GameSurveyer(gameAssemblyContext, gameConfig.GameLocation, args); + using var gameSurveyer = new GameSurveyer(gameAssemblyContext, gameConfig.GameLocation, [.. args, ..gameConfig.GameArguments]); if (!gameSurveyer.TryLoadCoreAndGame()) { Console.WriteLine("StarMap - Unable to load mod manager and game."); From 4dc60f8dfeb1d9b035d44af2601d09115c16d2aa Mon Sep 17 00:00:00 2001 From: KlaasWhite <45828001+KlaasWhite@users.noreply.github.com> Date: Tue, 15 Sep 2026 21:34:27 +0200 Subject: [PATCH 2/2] Update KSA ref, fix restart popup and dependency loading (#86) --- StarMap.API/StarMap.API.csproj | 4 ++-- StarMap.Core/ModRepository/RuntimeMod.cs | 13 ++++++----- StarMap.Core/StarMap.Core.csproj | 4 ++-- .../UI/ConfirmRestart/ConfirmRestart.cs | 2 +- .../UI/ConfirmRestart/ConfirmRestartPopup.cs | 22 ++++++++++--------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/StarMap.API/StarMap.API.csproj b/StarMap.API/StarMap.API.csproj index 62c4121..70c3f45 100644 --- a/StarMap.API/StarMap.API.csproj +++ b/StarMap.API/StarMap.API.csproj @@ -20,14 +20,14 @@ - + compile; build; analyzers all - + compile; build; analyzers all diff --git a/StarMap.Core/ModRepository/RuntimeMod.cs b/StarMap.Core/ModRepository/RuntimeMod.cs index 1cb09b8..ae242ce 100644 --- a/StarMap.Core/ModRepository/RuntimeMod.cs +++ b/StarMap.Core/ModRepository/RuntimeMod.cs @@ -18,10 +18,11 @@ internal class RuntimeMod public required string ModId { get; init; } public required ModAssemblyLoadContext ModAssemblyLoadContext { get; init; } - public required Type ModType { get; init; } public required StarMapConfig Config { get; init; } + public required Assembly ModAssembly { get; init; } public bool Initialized { get; set; } = false; + public Type? ModType { get; set; } public object? ModInstance { get; set; } = null; public HashSet ExportedAssemblies { get; set; } = []; @@ -61,14 +62,11 @@ public static bool TryCreateMod(ModEntry manifestEntry, AssemblyLoadContext core var modLoadContext = new ModAssemblyLoadContext(manifestEntry.Id, modAssemblyFile, coreALC); var modAssembly = modLoadContext.LoadFromAssemblyName(new AssemblyName() { Name = starMapConfig.EntryAssembly }); - var modClass = modAssembly.GetTypes().FirstOrDefault(type => type.GetCustomAttributes().Any(attr => attr.GetType().Name == typeof(StarMapModAttribute).Name)); - if (modClass is null) return false; - runtimeMod = new RuntimeMod { ModId = manifestEntry.Id, ModAssemblyLoadContext = modLoadContext, - ModType = modClass, + ModAssembly = modAssembly, Config = starMapConfig, }; @@ -130,6 +128,11 @@ private static IEnumerable CalculateUseableAssemblies(RuntimeMod depende public bool InitializeMod(ModRegistry modRegistry) { + var modClass = ModAssembly.GetTypes().FirstOrDefault(type => type.GetCustomAttributes().Any(attr => attr.GetType().Name == typeof(StarMapModAttribute).Name)); + if (modClass is null) return false; + + ModType = modClass; + var modObject = Activator.CreateInstance(ModType); if (modObject is null) return false; ModInstance = modObject; diff --git a/StarMap.Core/StarMap.Core.csproj b/StarMap.Core/StarMap.Core.csproj index 7abfbb0..1ec9d02 100644 --- a/StarMap.Core/StarMap.Core.csproj +++ b/StarMap.Core/StarMap.Core.csproj @@ -25,13 +25,13 @@ - + runtime - + runtime diff --git a/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs b/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs index 339f8c1..17cadde 100644 --- a/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs +++ b/StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs @@ -32,7 +32,7 @@ public void DrawUi() { if (!Show) return; - ImGuiHelper.BlankBackground(); + ImGuiHelper.BlankBackground(ImGuiHelper.GetMainOverlayDrawList()); Popup.DrawAll(); } diff --git a/StarMap.Core/UI/ConfirmRestart/ConfirmRestartPopup.cs b/StarMap.Core/UI/ConfirmRestart/ConfirmRestartPopup.cs index 03b22eb..a21a8e7 100644 --- a/StarMap.Core/UI/ConfirmRestart/ConfirmRestartPopup.cs +++ b/StarMap.Core/UI/ConfirmRestart/ConfirmRestartPopup.cs @@ -1,10 +1,13 @@ using Brutal.ImGuiApi; +using Brutal.Numerics; using KSA; namespace StarMap.Core.UI.ConfirmRestart { internal class ConfirmRestartPopup : Popup { + private static readonly float2 SIZE_UV = new float2(0.32f, 0.213333f); + private readonly string _title; public ConfirmRestart UI { get; } private static readonly PopupButton PopupButtonContinue = CreateButton("Continue", (Action)(popup => @@ -20,7 +23,7 @@ internal class ConfirmRestartPopup : Popup popup.UI.Show = false; })); - private static readonly IPopupWidget[] ButtonMatrix = [ + private static readonly PopupButton[] ButtonMatrix = [ PopupButtonContinue, PopupButtonRestart ]; @@ -35,15 +38,14 @@ private ConfirmRestartPopup(ConfirmRestart ui) protected override void OnDrawUi() { - ImGui.OpenPopup((ImString)_title); - ImGui.BeginPopup((ImString)_title, ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.Popup); - ImGuiHelper.SetCurrentWindowToCenter(); - var text1 = new ImString(60, 1); - text1.AppendLiteral("New mods have been enabled after starting KSA.\nThe game needs to be restarted for these mods to be loaded in StarMap.".AsSpan()); - ImGui.TextWrapped(text1); - ImGui.Separator(); - DrawUi(this, ButtonMatrix); - ImGui.EndPopup(); + if (!BeginConsoleModal(WindowId.AsSpan(), _title.AsSpan(), SIZE_UV)) + return; + ConsoleStyle.BeginBody(); + ConsoleStyle.PushWidgetStyle(); + CenteredWrappedText("New mods have been enabled after starting KSA.\nThe game needs to be restarted for these mods to be loaded in StarMap.".AsSpan()); + EndConsoleBody(); + DrawConsoleButtonRow(this, ButtonMatrix); + EndConsoleModal(); } } }