diff --git a/NeoQOLPack/Mod.cs b/NeoQOLPack/Mod.cs index 52a747d..6416539 100644 --- a/NeoQOLPack/Mod.cs +++ b/NeoQOLPack/Mod.cs @@ -6,6 +6,7 @@ using GDWeave.Godot.Variants; using NeoQOLPack.Mods; using Serilog; +using System.IO; namespace NeoQOLPack; @@ -15,7 +16,7 @@ public class Mod : IMod public Config Config; public ILogger Logger; - private static readonly string versionTag = "v1.0.2"; + private static string versionTag = "v0"; private static readonly string repo = "neomoth/NeoQOLPack"; private bool injectUpdateNotice = false; @@ -45,6 +46,30 @@ public Mod(IModInterface modInterface) { private async Task GetVersion() { modInterface.Logger.Information("Neo's QOL Pack loaded!! :3"); + + try + { + string? currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + if (currentDir is null) + throw new NullReferenceException( + "if this gets thrown i have no fucking idea how you managed to do that."); + string jsonPath = Path.Combine(currentDir, "mod.json"); + if (!File.Exists(jsonPath)) + throw new FileNotFoundException("mod.json was not found in the mod's directory."); + string jsonContent = File.ReadAllText(jsonPath); + JsonDocument document = JsonDocument.Parse(jsonContent); + if (document.RootElement.TryGetProperty("version", out JsonElement version)) + { + string? versionAsString = version.GetString(); + if (versionAsString is not null) versionTag = $"v{versionAsString}"; + } + else throw new Exception("'version' property not found in mod.json."); + } + catch (Exception e) + { + Logger.Error(e.Message); + } + try { JsonDocument? githubInfoRaw = await GetLatestRelease(modInterface.Logger); diff --git a/NeoQOLPack/NeoQOLPack.csproj b/NeoQOLPack/NeoQOLPack.csproj index 048bd3f..0a7be03 100644 --- a/NeoQOLPack/NeoQOLPack.csproj +++ b/NeoQOLPack/NeoQOLPack.csproj @@ -13,6 +13,7 @@ + diff --git a/NeoQOLPack/manifest.json b/NeoQOLPack/manifest.json index 193c487..0ff873a 100644 --- a/NeoQOLPack/manifest.json +++ b/NeoQOLPack/manifest.json @@ -1,4 +1,9 @@ { - "Id": "NeoQOLPack", - "AssemblyPath": "NeoQOLPack.dll" -} + "Id": "NeoQOLPack", + "PackPath": "NeoQOLPack.pck", + "AssemblyPath": "NeoQOLPack.dll", + "Dependencies": + [ + "Sulayre.Lure" + ] +} \ No newline at end of file diff --git a/NeoQOLPack/mod.json b/NeoQOLPack/mod.json new file mode 100644 index 0000000..9985010 --- /dev/null +++ b/NeoQOLPack/mod.json @@ -0,0 +1,6 @@ +{ + "name": "NeoQOLPack", + "version": "1.0.3", + "description": "A collection of Quality of Life patches", + "author": "neomoth" +} \ No newline at end of file diff --git a/mod.json b/mod.json index a204420..9985010 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { "name": "NeoQOLPack", - "version": "1.0.2", + "version": "1.0.3", "description": "A collection of Quality of Life patches", "author": "neomoth" -} +} \ No newline at end of file