diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 0241080..57945be 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -4,7 +4,7 @@ on: pull_request: # Re-run the version calculation when labels are added or when new commits are pushed types: [opened, synchronize, labeled, reopened, edited] - branches: [main] + branches: [main, dev] permissions: pull-requests: write diff --git a/.github/workflows/release-zip.yml b/.github/workflows/release-zip.yml index f4cc563..9f6e453 100644 --- a/.github/workflows/release-zip.yml +++ b/.github/workflows/release-zip.yml @@ -118,8 +118,8 @@ jobs: exit 0 fi - echo "DEBUG: Previous tag: $prev" - echo "DEBUG: Current commit: $current" + echo "Previous tag: $prev" + echo "Current commit: $current" diff=$(git diff --name-only "$prev" "$current") echo "diff_files=$diff" >> $GITHUB_OUTPUT @@ -134,7 +134,7 @@ jobs: if: steps.api_check.outputs.changed == 'true' run: | dotnet restore StarMap.API/StarMap.API.csproj - dotnet pack \ + dotnet pack StarMap.API/StarMap.API.csproj \ -c Release \ -o ./nupkg \ /p:PackageVersion=${{ steps.version.outputs.new }} \ diff --git a/README.md b/README.md index 76885dc..ac40813 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It makes use of Assembly Load Contexts to ensure mod dependencies are managed se - Download and unzip release from [Releases](https://github.com/StarMapLoader/StarMap/releases/latest). - Run StarMap.exe, this will fail and create a StarMapConfig.json. - Open StarMapConfig.json and set the location of your KSA installation. - - `GameLocation` should be set to the location of your KSA.dll, pointing directly to that file (e.g. `C:\\games\\Kitten Space Agency\\KSA.dll`) + - `GameLocation` should be set to the location where Kitten Space Agency was installed, pointing directly to that folder (e.g. `C:\\games\\Kitten Space Agency\\`) - `RepositoryLocation` can be kept empty - Run StarMap.exe again, this should launch KSA and load your mods. diff --git a/StarMap.Core/StarMapCore.cs b/StarMap.Core/StarMapCore.cs index f625fd4..702b31a 100644 --- a/StarMap.Core/StarMapCore.cs +++ b/StarMap.Core/StarMapCore.cs @@ -25,6 +25,8 @@ public StarMapCore(AssemblyLoadContext coreAssemblyLoadContext) public void Init() { _harmony.PatchAll(); + // Currently needed to force patch in release mode + Harmony.GetAllPatchedMethods(); } public void DeInit() diff --git a/StarMap.Types/LoaderConfig.cs b/StarMap.Types/LoaderConfig.cs index 370b273..f7646b6 100644 --- a/StarMap.Types/LoaderConfig.cs +++ b/StarMap.Types/LoaderConfig.cs @@ -13,27 +13,39 @@ public class LoaderConfig public bool TryLoadConfig() { - if (!File.Exists("./StarMapConfig.json")) { + if (!File.Exists("./StarMapConfig.json")) + { Console.WriteLine("Please fill the StarMapConfig.json and restart the program"); - File.Create("./StarMapConfig.json").Dispose(); - File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig())); - Console.ReadLine(); + File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig(), new JsonSerializerOptions { WriteIndented = true })); return false; } - + var jsonString = File.ReadAllText("./StarMapConfig.json"); var config = JsonSerializer.Deserialize(jsonString); - + if (config is null) return false; - - if (string.IsNullOrEmpty(config.GameLocation) || !File.Exists(config.GameLocation)) + + if (string.IsNullOrEmpty(config.GameLocation)) { Console.WriteLine("The 'GameLocation' property in StarMapConfig.json is either empty or points to a non-existing file."); - Console.ReadLine(); return false; } - - GameLocation = config.GameLocation; + + string path = config.GameLocation; + + if (Directory.Exists(path)) + { + path = Path.Combine(path, "KSA.dll"); + } + + if (!File.Exists(path)) + { + Console.WriteLine("Could not find KSA.dll. Make sure the folder or file path is correct:"); + Console.WriteLine(path); + return false; + } + + GameLocation = path; return true; }