Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions StarMap.API/StarMap.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'SourceNuget'">
<PackageReference Include="RocketWerkz.KSA" Version="2026.7.6.4939">
<PackageReference Include="RocketWerkz.KSA" Version="2026.9.10.5438">
<IncludeAssets>compile; build; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.7.6.4939">
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.9.10.5438">
<IncludeAssets>compile; build; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
13 changes: 8 additions & 5 deletions StarMap.Core/ModRepository/RuntimeMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> ExportedAssemblies { get; set; } = [];
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -130,6 +128,11 @@ private static IEnumerable<string> 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;
Expand Down
4 changes: 2 additions & 2 deletions StarMap.Core/StarMap.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'SourceNuget'">
<PackageReference Include="RocketWerkz.KSA" Version="2026.7.6.4939">
<PackageReference Include="RocketWerkz.KSA" Version="2026.9.10.5438">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.7.6.4939">
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.9.10.5438">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{
if (!Show)
return;
ImGuiHelper.BlankBackground();
ImGuiHelper.BlankBackground(ImGuiHelper.GetMainOverlayDrawList());
Popup.DrawAll();
}

Expand Down Expand Up @@ -73,7 +73,7 @@
RenderPass = Program.MainPass.Pass,
Framebuffer = resources.Framebuffer,
RenderArea = new VkRect2D(this._renderer.Extent),
ClearValues = (VkClearValue*)Program.MainPass.ClearValues.Ptr,

Check warning on line 76 in StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 76 in StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs

View workflow job for this annotation

GitHub Actions / preview-build

Dereference of a possibly null reference.

Check warning on line 76 in StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs

View workflow job for this annotation

GitHub Actions / preview-build

Dereference of a possibly null reference.

Check warning on line 76 in StarMap.Core/UI/ConfirmRestart/ConfirmRestart.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
ClearValueCount = 2
};
commandBuffer.Reset();
Expand Down
22 changes: 12 additions & 10 deletions StarMap.Core/UI/ConfirmRestart/ConfirmRestartPopup.cs
Original file line number Diff line number Diff line change
@@ -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<ConfirmRestartPopup> PopupButtonContinue = CreateButton("Continue", (Action<ConfirmRestartPopup>)(popup =>
Expand All @@ -20,7 +23,7 @@ internal class ConfirmRestartPopup : Popup
popup.UI.Show = false;
}));

private static readonly IPopupWidget<ConfirmRestartPopup>[] ButtonMatrix = [
private static readonly PopupButton<ConfirmRestartPopup>[] ButtonMatrix = [
PopupButtonContinue,
PopupButtonRestart
];
Expand All @@ -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<ConfirmRestartPopup>(this, ButtonMatrix);
EndConsoleModal();
}
}
}
2 changes: 1 addition & 1 deletion StarMap/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
Loading