From 897c5a80e1cdf6f52b81bfc6732bb6e312bcf02c Mon Sep 17 00:00:00 2001 From: OrekiWoof Date: Wed, 18 Mar 2026 00:07:23 +0100 Subject: [PATCH] scaffold --- .gitignore | 18 +++ .timetracker | 10 ++ .vscode/launch.json | 11 ++ .vscode/tasks.json | 39 ++++++ ButterflyPins.slnx | 9 ++ .../ButterflyPins/ButterflyPins.csproj | 90 +++++++++++++ .../Core/ButterflyPinsModSystem.cs | 11 ++ .../Properties/launchSettings.json | 10 ++ ButterflyPins/ButterflyPins/modinfo.json | 15 +++ ButterflyPins/ZZCakeBuild/CakeBuild.csproj | 34 +++++ ButterflyPins/ZZCakeBuild/Program.cs | 122 ++++++++++++++++++ ButterflyPins/build.ps1 | 2 + ButterflyPins/build.sh | 1 + 13 files changed, 372 insertions(+) create mode 100644 .gitignore create mode 100644 .timetracker create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 ButterflyPins.slnx create mode 100644 ButterflyPins/ButterflyPins/ButterflyPins.csproj create mode 100644 ButterflyPins/ButterflyPins/Core/ButterflyPinsModSystem.cs create mode 100644 ButterflyPins/ButterflyPins/Properties/launchSettings.json create mode 100644 ButterflyPins/ButterflyPins/modinfo.json create mode 100644 ButterflyPins/ZZCakeBuild/CakeBuild.csproj create mode 100644 ButterflyPins/ZZCakeBuild/Program.cs create mode 100644 ButterflyPins/build.ps1 create mode 100644 ButterflyPins/build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a09a90 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +[Dd]ebug/ +[Rr]elease/ +[Rr]eleases/ +[Bb]in/ +[Oo]bj/ +.vs/ +.idea/ +.history/ +*.user +*.rsuser +*.suo +*.nupkg +*.snupkg +*.code-workspace +.vscode/* +!.vscode/launch.json +!.vscode/tasks.json +!.vscode/settings.json diff --git a/.timetracker b/.timetracker new file mode 100644 index 0000000..f9eb966 --- /dev/null +++ b/.timetracker @@ -0,0 +1,10 @@ +{ + "total": 123, + "sessions": [ + { + "begin": "2026-03-17T23:54:43+01:00", + "end": "2026-03-17T23:56:46+01:00", + "duration": 123 + } + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..03c01b0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Vintage Story Client", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}/ButterflyPins/ButterflyPins/ButterflyPins.csproj" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..8a7610e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,39 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "check env", + "type": "shell", + "command": "[ -n \"$VINTAGE_STORY\" ] || { echo 'ERROR: VINTAGE_STORY is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA\" ] || { echo 'ERROR: VINTAGE_STORY_DATA is not set'; exit 1; }", + "windows": { + "command": "if (-not $env:VINTAGE_STORY) { Write-Host 'ERROR: VINTAGE_STORY is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA) { Write-Host 'ERROR: VINTAGE_STORY_DATA is not set'; exit 1 }" + }, + "problemMatcher": [] + }, + { + "label": "build mod", + "command": "dotnet", + "type": "process", + "dependsOn": ["check env"], + "dependsOrder": "sequence", + "args": [ + "build", + "${workspaceFolder}/ButterflyPins/ButterflyPins/ButterflyPins.csproj", + "-c", + "${input:buildConfig}", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + } + ], + "inputs": [ + { + "id": "buildConfig", + "type": "pickString", + "description": "Build configuration", + "options": ["Debug", "Release", "Version22"], + "default": "Debug" + } + ] +} diff --git a/ButterflyPins.slnx b/ButterflyPins.slnx new file mode 100644 index 0000000..c96646c --- /dev/null +++ b/ButterflyPins.slnx @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ButterflyPins/ButterflyPins/ButterflyPins.csproj b/ButterflyPins/ButterflyPins/ButterflyPins.csproj new file mode 100644 index 0000000..d61234a --- /dev/null +++ b/ButterflyPins/ButterflyPins/ButterflyPins.csproj @@ -0,0 +1,90 @@ + + + + net8.0 + false + bin\$(Configuration)\Mods\mod + enable + Debug;Release;Version22 + $([System.Environment]::GetEnvironmentVariable('VS_CONFIGLIB')) + true + $(DefineConstants);CONFIGLIB + + + + net10.0 + $(VINTAGE_STORY_22) + $(VINTAGE_STORY_DATA_22) + + + + --dataPath "$(VINTAGE_STORY_DATA)" + + + + + $(VINTAGE_STORY)/VintagestoryAPI.dll + false + + + $(VINTAGE_STORY)/Mods/VSSurvivalMod.dll + False + + + $(VINTAGE_STORY)/Mods/VSEssentials.dll + False + + + $(VINTAGE_STORY)/Mods/VSCreativeMod.dll + False + + + $(VINTAGE_STORY)/Lib/Newtonsoft.Json.dll + False + + + $(VINTAGE_STORY)/Lib/0Harmony.dll + False + + + $(VINTAGE_STORY)/VintagestoryLib.dll + false + + + $(VINTAGE_STORY)/Lib/protobuf-net.dll + False + + + $(VINTAGE_STORY)/Lib/cairo-sharp.dll + False + + + $(VINTAGE_STORY)/Lib/Microsoft.Data.Sqlite.dll + False + + + + + + $(VS_CONFIGLIB) + False + + + + + + + + + + PreserveNewest + + + + + + PreserveNewest + + + + diff --git a/ButterflyPins/ButterflyPins/Core/ButterflyPinsModSystem.cs b/ButterflyPins/ButterflyPins/Core/ButterflyPinsModSystem.cs new file mode 100644 index 0000000..74d1751 --- /dev/null +++ b/ButterflyPins/ButterflyPins/Core/ButterflyPinsModSystem.cs @@ -0,0 +1,11 @@ +using Vintagestory.API.Common; + +namespace ButterflyPins.Core; + +public class ButterflyPinsModSystem : ModSystem +{ + public override void Start(ICoreAPI api) + { + api.Logger.Notification("ButterflyPins loaded"); + } +} diff --git a/ButterflyPins/ButterflyPins/Properties/launchSettings.json b/ButterflyPins/ButterflyPins/Properties/launchSettings.json new file mode 100644 index 0000000..bb5efd9 --- /dev/null +++ b/ButterflyPins/ButterflyPins/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Client": { + "commandName": "Executable", + "executablePath": "dotnet", + "commandLineArgs": "\"$(VINTAGE_STORY)/Vintagestory.dll\" --tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\" --addOrigin \"$(ProjectDir)/assets\"$(VintageStoryDataPathArgs)", + "workingDirectory": "$(VINTAGE_STORY)" + } + } +} diff --git a/ButterflyPins/ButterflyPins/modinfo.json b/ButterflyPins/ButterflyPins/modinfo.json new file mode 100644 index 0000000..aa3334c --- /dev/null +++ b/ButterflyPins/ButterflyPins/modinfo.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://moddbcdn.vintagestory.at/schema/modinfo.latest.json", + "type": "Code", + "modid": "butterflypins", + "name": "Butterfly Pins", + "authors": [ + "OrekiWoof" + ], + "description": "ButterflyPins mod.", + "version": "1.0.0", + "dependencies": { + "game": "1.21.0" + }, + "side": "Universal" +} diff --git a/ButterflyPins/ZZCakeBuild/CakeBuild.csproj b/ButterflyPins/ZZCakeBuild/CakeBuild.csproj new file mode 100644 index 0000000..208214e --- /dev/null +++ b/ButterflyPins/ZZCakeBuild/CakeBuild.csproj @@ -0,0 +1,34 @@ + + + Exe + net8.0 + $(MSBuildProjectDirectory) + Debug;Release;Version22 + $([System.Environment]::GetEnvironmentVariable('VS_CONFIGLIB')) + true + $(DefineConstants);CONFIGLIB + + + + + + + + + + + $(VINTAGE_STORY)/VintagestoryAPI.dll + + + + + + $(VS_CONFIGLIB) + False + + + + + + + diff --git a/ButterflyPins/ZZCakeBuild/Program.cs b/ButterflyPins/ZZCakeBuild/Program.cs new file mode 100644 index 0000000..d1601f8 --- /dev/null +++ b/ButterflyPins/ZZCakeBuild/Program.cs @@ -0,0 +1,122 @@ +using Cake.Common; +using Cake.Common.IO; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Clean; +using Cake.Common.Tools.DotNet.Publish; +using Cake.Core; +using Cake.Frosting; +using Cake.Json; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.IO; +using System.Linq; +using Vintagestory.API.Common; + +namespace CakeBuild; + +public static class Program +{ + public static int Main(string[] args) + { + return new CakeHost() + .UseContext() + .Run(args); + } +} + +public class BuildContext : FrostingContext +{ + public const string PROJECT_NAME = "ButterflyPins"; + public string BuildConfiguration { get; } + public string Version { get; } + public string Name { get; } + public bool SkipJsonValidation { get; } + public string GameVersion { get; } + + public BuildContext(ICakeContext context) + : base(context) + { + BuildConfiguration = context.Argument("configuration", "Release"); + SkipJsonValidation = context.Argument("skipJsonValidation", false); + var modInfo = context.DeserializeJsonFromFile($"../{PROJECT_NAME}/modinfo.json"); + Version = modInfo.Version; + Name = modInfo.ModID; + GameVersion = modInfo.Dependencies.First(x => x.ModID == "game").Version; + } +} + +[TaskName("ValidateJson")] +public sealed class ValidateJsonTask : FrostingTask +{ + public override void Run(BuildContext context) + { + if (context.SkipJsonValidation) + { + return; + } + var jsonFiles = context.GetFiles($"../{BuildContext.PROJECT_NAME}/assets/**/*.json"); + foreach (var file in jsonFiles) + { + try + { + var json = File.ReadAllText(file.FullPath); + JToken.Parse(json); + } + catch (JsonException ex) + { + throw new Exception($"Validation failed for JSON file: {file.FullPath}{Environment.NewLine}{ex.Message}", ex); + } + } + } +} + +[TaskName("Build")] +[IsDependentOn(typeof(ValidateJsonTask))] +public sealed class BuildTask : FrostingTask +{ + public override void Run(BuildContext context) + { + context.DotNetClean($"../{BuildContext.PROJECT_NAME}/{BuildContext.PROJECT_NAME}.csproj", + new DotNetCleanSettings + { + Configuration = context.BuildConfiguration + }); + + + context.DotNetPublish($"../{BuildContext.PROJECT_NAME}/{BuildContext.PROJECT_NAME}.csproj", + new DotNetPublishSettings + { + Configuration = context.BuildConfiguration + }); + } +} + +[TaskName("Package")] +[IsDependentOn(typeof(BuildTask))] +public sealed class PackageTask : FrostingTask +{ + public override void Run(BuildContext context) + { + context.EnsureDirectoryExists("../Releases"); + context.CleanDirectory("../Releases"); + context.EnsureDirectoryExists($"../Releases/{context.Name}"); + context.CopyFiles($"../{BuildContext.PROJECT_NAME}/bin/{context.BuildConfiguration}/Mods/mod/publish/*", $"../Releases/{context.Name}"); + if (context.DirectoryExists($"../{BuildContext.PROJECT_NAME}/assets")) + { + context.CopyDirectory($"../{BuildContext.PROJECT_NAME}/assets", $"../Releases/{context.Name}/assets"); + } + context.CopyFile($"../{BuildContext.PROJECT_NAME}/modinfo.json", $"../Releases/{context.Name}/modinfo.json"); + if (context.FileExists($"../{BuildContext.PROJECT_NAME}/modicon.png")) + { + context.CopyFile($"../{BuildContext.PROJECT_NAME}/modicon.png", $"../Releases/{context.Name}/modicon.png"); + } + context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_v{context.Version}-v{context.GameVersion}.zip"); + } +} + +[TaskName("Default")] +[IsDependentOn(typeof(PackageTask))] +public class DefaultTask : FrostingTask +{ +} diff --git a/ButterflyPins/build.ps1 b/ButterflyPins/build.ps1 new file mode 100644 index 0000000..2a3616b --- /dev/null +++ b/ButterflyPins/build.ps1 @@ -0,0 +1,2 @@ +dotnet run --project ZZCakeBuild/CakeBuild.csproj -- $args +exit $LASTEXITCODE; diff --git a/ButterflyPins/build.sh b/ButterflyPins/build.sh new file mode 100644 index 0000000..1a40ae7 --- /dev/null +++ b/ButterflyPins/build.sh @@ -0,0 +1 @@ +dotnet run --project ./ZZCakeBuild/CakeBuild.csproj -- "$@"