Skip to content

Commit ae11ab3

Browse files
authored
Feature/confirm reload (#78)
* Changes * Changes
1 parent 886035e commit ae11ab3

34 files changed

Lines changed: 336 additions & 1077 deletions

.github/workflows/pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
env:
2020
DOTNET_VERSION: 9.0
21-
PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
21+
PROJECT: StarMap/StarMap.csproj
2222
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
2323

2424
steps:

.github/workflows/rc-build.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ on:
66

77
env:
88
DOTNET_VERSION: 10.0
9-
STANDALONE_PROJECT: StarMap.Loader/StarMap.Loader.csproj
10-
LAUNCHER_PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
9+
PROJECT: StarMap/StarMap.csproj
1110
API_PROJECT: StarMap.API/StarMap.API.csproj
12-
STANDALONE_OUTPUT_PATH: ./publish/standalone
13-
LAUNCHER_OUTPUT_PATH: ./publish/launcher
1411
OUTPUT_PATH: ./publish
1512
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
1613
EXCLUDE: "*.pdb *.xml"
@@ -75,35 +72,18 @@ jobs:
7572
--store-password-in-clear-text \
7673
--name github "${{ env.NUGET_SOURCE }}"
7774
78-
- name: Build launcher
75+
- name: Build
7976
run: |
80-
dotnet publish ${{ env.LAUNCHER_PROJECT }} \
77+
dotnet publish ${{ env.PROJECT }} \
8178
-c Release \
82-
-o ${{ env.LAUNCHER_OUTPUT_PATH }} \
79+
-o ${{ env.OUTPUT_PATH }} \
8380
-r win-x64 \
8481
--self-contained false \
8582
/p:PackageVersion=${{ steps.version.outputs.hash_version }} \
8683
/p:Version=${{ steps.version.outputs.new_version }} \
8784
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
8885
/p:FileVersion=${{ steps.version.outputs.new_version }}
8986
90-
- name: Build standalone
91-
run: |
92-
dotnet publish ${{ env.STANDALONE_PROJECT }} \
93-
-c Release \
94-
-o ${{ env.STANDALONE_OUTPUT_PATH }} \
95-
-r win-x64 \
96-
--self-contained false \
97-
/p:PackageVersion=${{ steps.version.outputs.hash_version }} \
98-
/p:Version=${{ steps.version.outputs.new_version }} \
99-
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
100-
/p:FileVersion=${{ steps.version.outputs.new_version }}
101-
102-
- name: Rename executables
103-
run: |
104-
mv ${{ env.LAUNCHER_OUTPUT_PATH }}/StarMap.Launcher.exe ${{ env.LAUNCHER_OUTPUT_PATH }}/StarMap.exe
105-
mv ${{ env.STANDALONE_OUTPUT_PATH }}/StarMap.Loader.exe ${{ env.STANDALONE_OUTPUT_PATH }}/StarMap.exe
106-
10787
- name: Write version file
10888
run: echo "${{ steps.version.outputs.hash_version }}" > version.txt
10989

@@ -112,8 +92,7 @@ jobs:
11292
with:
11393
name: rc-build
11494
path: |
115-
${{ env.LAUNCHER_OUTPUT_PATH }}
116-
${{ env.STANDALONE_OUTPUT_PATH }}
95+
${{ env.OUTPUT_PATH }}
11796
version.txt
11897
retention-days: 1
11998

@@ -176,16 +155,10 @@ jobs:
176155
sudo apt-get update -y
177156
sudo apt-get install -y zip
178157
179-
- name: Package launcher ZIP
180-
run: |
181-
cd ./build_artifacts/${{ env.LAUNCHER_OUTPUT_PATH }}
182-
zip -r $GITHUB_WORKSPACE/StarMapLauncher-RC.zip . -x ${{ env.EXCLUDE }}
183-
cd -
184-
185-
- name: Package standalone ZIP
158+
- name: Package ZIP
186159
run: |
187-
cd ./build_artifacts/${{ env.STANDALONE_OUTPUT_PATH }}
188-
zip -r $GITHUB_WORKSPACE/StarMapStandalone-RC.zip . -x ${{ env.EXCLUDE }}
160+
cd ./build_artifacts/${{ env.OUTPUT_PATH }}
161+
zip -r $GITHUB_WORKSPACE/StarMap-RC.zip . -x ${{ env.EXCLUDE }}
189162
cd -
190163
191164
- name: Update RC GitHub release
@@ -195,8 +168,7 @@ jobs:
195168
name: Release Candidate
196169
prerelease: true
197170
files: |
198-
StarMapLauncher-RC.zip
199-
StarMapStandalone-RC.zip
171+
StarMap-RC.zip
200172
./build_artifacts/version.txt
201173
env:
202174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ on:
77

88
env:
99
DOTNET_VERSION: 10.0
10-
STANDALONE_PROJECT: StarMap.Loader/StarMap.Loader.csproj
11-
LAUNCHER_PROJECT: StarMap.Launcher/StarMap.Launcher.csproj
10+
PROJECT: StarMap/StarMap.csproj
1211
API_PROJECT: StarMap.API/StarMap.API.csproj
13-
STANDALONE_OUTPUT_PATH: ./publish/standalone
14-
LAUNCHER_OUTPUT_PATH: ./publish/launcher
1512
OUTPUT_PATH: ./publish
1613
NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
1714
EXCLUDE: "*.pdb *.xml"
@@ -86,42 +83,24 @@ jobs:
8683
--store-password-in-clear-text \
8784
--name github "${{ env.NUGET_SOURCE }}"
8885
89-
- name: Build launcher
90-
run: |
91-
dotnet publish ${{ env.LAUNCHER_PROJECT }} \
92-
-c Release \
93-
-o ${{ env.LAUNCHER_OUTPUT_PATH }} \
94-
-r win-x64 \
95-
--self-contained false \
96-
/p:PackageVersion=${{ steps.version.outputs.new_version }} \
97-
/p:Version=${{ steps.version.outputs.new_version }} \
98-
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
99-
/p:FileVersion=${{ steps.version.outputs.new_version }}
100-
10186
- name: Build standalone
10287
run: |
103-
dotnet publish ${{ env.STANDALONE_PROJECT }} \
88+
dotnet publish ${{ env.PROJECT }} \
10489
-c Release \
105-
-o ${{ env.STANDALONE_OUTPUT_PATH }} \
90+
-o ${{ env.OUTPUT_PATH }} \
10691
-r win-x64 \
10792
--self-contained false \
10893
/p:PackageVersion=${{ steps.version.outputs.new_version }} \
10994
/p:Version=${{ steps.version.outputs.new_version }} \
11095
/p:AssemblyVersion=${{ steps.version.outputs.new_version }} \
11196
/p:FileVersion=${{ steps.version.outputs.new_version }}
11297
113-
- name: Rename executables
114-
run: |
115-
mv ${{ env.LAUNCHER_OUTPUT_PATH }}/StarMap.Launcher.exe ${{ env.LAUNCHER_OUTPUT_PATH }}/StarMap.exe
116-
mv ${{ env.STANDALONE_OUTPUT_PATH }}/StarMap.Loader.exe ${{ env.STANDALONE_OUTPUT_PATH }}/StarMap.exe
117-
11898
- name: Upload build artifacts
11999
uses: actions/upload-artifact@v4
120100
with:
121101
name: publish
122102
path: |
123-
${{ env.LAUNCHER_OUTPUT_PATH }}
124-
${{ env.STANDALONE_OUTPUT_PATH }}
103+
${{ env.OUTPUT_PATH }}
125104
version.txt
126105
retention-days: 1
127106

@@ -216,16 +195,10 @@ jobs:
216195
sudo apt-get update -y
217196
sudo apt-get install -y zip
218197
219-
- name: Package launcher ZIP
220-
run: |
221-
cd ./build_artifacts/${{ env.LAUNCHER_OUTPUT_PATH }}
222-
zip -r $GITHUB_WORKSPACE/StarMapLauncher-${{ needs.build.outputs.new_version }}.zip . -x ${{ env.EXCLUDE }}
223-
cd -
224-
225-
- name: Package standalone ZIP
198+
- name: Package ZIP
226199
run: |
227-
cd ./build_artifacts/${{ env.STANDALONE_OUTPUT_PATH }}
228-
zip -r $GITHUB_WORKSPACE/StarMapStandalone-${{ needs.build.outputs.new_version }}.zip . -x ${{ env.EXCLUDE }}
200+
cd ./build_artifacts/${{ env.OUTPUT_PATH }}
201+
zip -r $GITHUB_WORKSPACE/StarMap-${{ needs.build.outputs.new_version }}.zip . -x ${{ env.EXCLUDE }}
229202
cd -
230203
231204
- name: Create GitHub Release
@@ -237,8 +210,7 @@ jobs:
237210
Automated release for version ${{ needs.build.outputs.new_version }}
238211
Triggered by PR #${{ github.event.pull_request.number }}
239212
files: |
240-
StarMapLauncher-${{ needs.build.outputs.new_version }}.zip
241-
StarMapStandalone-${{ needs.build.outputs.new_version }}.zip
213+
StarMap-${{ needs.build.outputs.new_version }}.zip
242214
243215
build-release-installer:
244216
runs-on: windows-latest

StarMap.API/StarMap.API.csproj

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,31 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8-
<NoWarn>1591</NoWarn>
8+
<NoWarn>1591;CS1734</NoWarn>
99
<PackageReadmeFile>README.md</PackageReadmeFile>
10+
<Configurations>Debug;Release;SourceNuget</Configurations>
1011
</PropertyGroup>
1112

1213
<ItemGroup>
1314
<None Include="README.md" Pack="true" PackagePath="\" />
1415
</ItemGroup>
1516

16-
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
17-
<Reference Include="..\..\Import\KSA.dll" />
18-
</ItemGroup>
17+
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
18+
<Reference Include="..\..\Import\KSA.dll" />
19+
<Reference Include="..\..\Import\Brutal.*.dll" />
20+
</ItemGroup>
1921

20-
<ItemGroup Condition="'$(Configuration)' != 'Debug'">
21-
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.22">
22-
<IncludeAssets>compile; build; analyzers</IncludeAssets>
23-
<PrivateAssets>all</PrivateAssets>
24-
</PackageReference>
25-
</ItemGroup>
22+
<ItemGroup Condition="'$(Configuration)' == 'SourceNuget'">
23+
<PackageReference Include="RocketWerkz.KSA" Version="2026.7.6.4939">
24+
<IncludeAssets>compile; build; analyzers</IncludeAssets>
25+
<PrivateAssets>all</PrivateAssets>
26+
</PackageReference>
27+
</ItemGroup>
28+
29+
<ItemGroup Condition="'$(Configuration)' == 'Release'">
30+
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.7.6.4939">
31+
<IncludeAssets>compile; build; analyzers</IncludeAssets>
32+
<PrivateAssets>all</PrivateAssets>
33+
</PackageReference>
34+
</ItemGroup>
2635
</Project>

StarMap.Core/ModRepository/ModLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private void PrepareMods()
6060
{
6161
if (!mod.Enabled)
6262
{
63-
Console.WriteLine($"StarMap - Nod loading mod: {mod.Id} because it is disable in manifest");
63+
Console.WriteLine($"StarMap - Not loading mod: {mod.Id} because it is disable in manifest");
6464
continue;
6565
}
6666

StarMap.Core/Patches/ModLibraryPatches.cs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
using HarmonyLib;
1+
using Brutal.Collections;
2+
using HarmonyLib;
23
using KSA;
34
using StarMap.API;
45
using StarMap.Core.ModRepository;
6+
using StarMap.Core.UI;
7+
using StarMap.Core.UI.ConfirmRestart;
8+
using System.ComponentModel.Design;
9+
using System.Diagnostics;
10+
using System.Reflection;
511

612
namespace StarMap.Core.Patches
713
{
@@ -20,5 +26,53 @@ public static void AfterLoad()
2026
method.Invoke(@object, []);
2127
}
2228
}
29+
30+
[HarmonyPatch(nameof(ModLibrary.PrepareAll))]
31+
[HarmonyPrefix]
32+
public static void BeforePrepareAll()
33+
{
34+
static bool wereNewModsEnabled()
35+
{
36+
foreach (var mod in ModLibrary.Manifest.Mods)
37+
{
38+
if (mod.New && mod.Enabled)
39+
return true;
40+
}
41+
return false;
42+
}
43+
44+
if (ModLibrary.HasNewMods() && wereNewModsEnabled())
45+
{
46+
var confirmRestart = new ConfirmRestart();
47+
while(confirmRestart.Show)
48+
{
49+
confirmRestart.OnFrame();
50+
}
51+
52+
if (confirmRestart.Restart)
53+
{
54+
Console.WriteLine("StarMap - RESTARTING");
55+
Console.WriteLine("======================================");
56+
57+
var mainModule = Process.GetCurrentProcess().MainModule;
58+
if (mainModule is null || Path.GetDirectoryName(mainModule.FileName) is not string starMapInstallLocation)
59+
{
60+
Console.WriteLine("Unable to get StarMap install location for restart.");
61+
}
62+
else {
63+
var startInfo = new ProcessStartInfo
64+
{
65+
FileName = mainModule.FileName,
66+
Arguments = "--restarted",
67+
WorkingDirectory = starMapInstallLocation,
68+
};
69+
70+
Process.Start(startInfo);
71+
}
72+
73+
Environment.Exit(0);
74+
}
75+
}
76+
}
2377
}
2478
}

StarMap.Core/StarMap.Core.csproj

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<Configurations>Debug;Release;SourceNuget</Configurations>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
</PropertyGroup>
29

3-
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
8-
9-
<ItemGroup>
10-
<PackageReference Include="Lib.Harmony" Version="2.4.2" />
11-
<PackageReference Include="Samboy063.Tomlet" Version="6.1.0">
12-
<ExcludeAssets>runtime</ExcludeAssets>
13-
</PackageReference>
14-
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Lib.Harmony" Version="2.4.2" />
12+
<PackageReference Include="Samboy063.Tomlet" Version="6.1.0">
13+
<ExcludeAssets>runtime</ExcludeAssets>
14+
</PackageReference>
15+
</ItemGroup>
1516

16-
<ItemGroup>
17-
<ProjectReference Include="..\StarMap.API\StarMap.API.csproj" />
18-
<ProjectReference Include="..\StarMap.Types\StarMap.Types.csproj" />
19-
</ItemGroup>
17+
<ItemGroup>
18+
<ProjectReference Include="..\StarMap.API\StarMap.API.csproj" />
19+
<ProjectReference Include="..\StarMap.Types\StarMap.Types.csproj" />
20+
</ItemGroup>
2021

2122
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
2223
<Reference Include="..\..\Import\KSA.dll" />
24+
<Reference Include="..\..\Import\Brutal.*.dll" />
25+
</ItemGroup>
26+
27+
<ItemGroup Condition="'$(Configuration)' == 'SourceNuget'">
28+
<PackageReference Include="RocketWerkz.KSA" Version="2026.7.6.4939">
29+
<ExcludeAssets>runtime</ExcludeAssets>
30+
</PackageReference>
2331
</ItemGroup>
2432

25-
<ItemGroup Condition="'$(Configuration)' != 'Debug'">
26-
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.22">
33+
<ItemGroup Condition="'$(Configuration)' == 'Release'">
34+
<PackageReference Include="RocketWerkz.KSA.Ref" Version="2026.7.6.4939">
2735
<ExcludeAssets>runtime</ExcludeAssets>
2836
</PackageReference>
2937
</ItemGroup>

0 commit comments

Comments
 (0)