Skip to content

Commit

Permalink
Merge pull request #24 from KSP2Community/dev
Browse files Browse the repository at this point in the history
Fix bug when rebuilding cache
  • Loading branch information
jan-bures authored Dec 26, 2023
2 parents 3956b99 + 0cc75c7 commit 6291021
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
permissions: write-all
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install jq
uses: dcarbone/[email protected]
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
dotnet nuget push "$nupkg_path" -s https://nuget.spacewarp.org/v3/index.json -k ${{ secrets.NUGET_SERVER_KEY }}
- name: Upload Zip
uses: actions/upload-release-asset@v1.0.1
uses: shogo82148/actions-upload-release-asset@v1.7.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Binary file removed plugin_template/assets/images/icon.png
Binary file not shown.
8 changes: 4 additions & 4 deletions plugin_template/swinfo.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"spec": "1.3",
"spec": "2.0",
"mod_id": "PatchManager",
"author": "KSP2 Community",
"name": "Patch Manager",
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
"source": "https://github.com/KSP2Community/PatchManager",
"version": "0.7.0",
"version": "0.7.1",
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.1.5",
"min": "0.2.0",
"max": "*"
},
"dependencies": [
{
"id": "com.github.x606.spacewarp",
"version": {
"min": "1.5.0",
"min": "1.7.0",
"max": "*"
}
}
Expand Down
62 changes: 47 additions & 15 deletions src/PatchManager.Core/CoreModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,62 @@ public override void Init()
/// <inheritdoc />
public override void PreLoad()
{
var gameDataModsExists = Directory.Exists(Path.Combine(Paths.GameRootPath, "GameData/Mods"));

// Go here instead so that the static constructor recognizes everything
var disabledPlugins = File.ReadAllText(Path.Combine(Paths.BepInExRootPath, "disabled_plugins.cfg"))
.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

var modFolders = Directory.GetDirectories(Paths.PluginPath, "*", SearchOption.AllDirectories)
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json"))).Select(x =>
(Folder: x,
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))))
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json")))
.Select(x => (
Folder: x,
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))
))
.ToList();
modFolders.AddRange(Directory
.GetDirectories(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*", SearchOption.AllDirectories)
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json"))).Select(x =>
(Folder: x,
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json"))))));

if (gameDataModsExists)
{
modFolders.AddRange(
Directory
.GetDirectories(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*", SearchOption.AllDirectories)
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json")))
.Select(x => (
Folder: x,
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))
)));
}

var gameRoot = new DirectoryInfo(Paths.GameRootPath);

var standalonePatches = Directory.EnumerateFiles(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*.patch",
SearchOption.AllDirectories)
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot)).Select(x => new FileInfo(x)).ToList();
standalonePatches.AddRange(Directory.EnumerateFiles(Paths.PluginPath, "*.patch", SearchOption.AllDirectories)
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot)).Select(x => new FileInfo(x)));
var standalonePatches = Directory.EnumerateFiles(
Paths.PluginPath,
"*.patch",
SearchOption.AllDirectories
)
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot))
.Select(x => new FileInfo(x))
.ToList();

if (gameDataModsExists)
{
standalonePatches.AddRange(
Directory.EnumerateFiles(
Path.Combine(Paths.GameRootPath, "GameData/Mods"),
"*.patch",
SearchOption.AllDirectories
)
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot))
.Select(x => new FileInfo(x))
);
}

PatchingManager.GenerateUniverse(standalonePatches.Select(x =>
x.Directory!.FullName
.MakeRelativePathTo(gameRoot.FullName)
.Replace("\\", "-")
).ToHashSet());

PatchingManager.GenerateUniverse(standalonePatches
.Select(x => x.Directory!.FullName.MakeRelativePathTo(gameRoot.FullName).Replace("\\","-")).ToHashSet());
foreach (var modFolder in modFolders)
{
Logging.LogInfo($"Loading patchers from {modFolder.Folder}");
Expand Down

0 comments on commit 6291021

Please sign in to comment.