diff --git a/ExampleMod.cs b/ExampleMod.cs index a2d9b73..ac49161 100644 --- a/ExampleMod.cs +++ b/ExampleMod.cs @@ -102,7 +102,7 @@ public class ExampleMod : Mod { public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) { ExampleMod.Logger = logger; - ExampleMod.Options = ModOptions.Load(info); + ExampleMod.Options = info.LoadOptions(() => new ModOptions()); // loads a texture atlas with the given amount of separate texture regions in the x and y axes // we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed @@ -131,7 +131,7 @@ public class ExampleMod : Mod { CurrentValue = ExampleMod.Options.DarkShirtSpeedIncrease, OnValueChanged = (_, v) => { ExampleMod.Options.DarkShirtSpeedIncrease = v; - ExampleMod.Options.Save(info); + info.SaveOptions(ExampleMod.Options); } }); } diff --git a/ExampleMod.csproj b/ExampleMod.csproj index 229fec5..5466d33 100644 --- a/ExampleMod.csproj +++ b/ExampleMod.csproj @@ -5,7 +5,7 @@ - + diff --git a/ModOptions.cs b/ModOptions.cs index 86b5d45..54b075e 100644 --- a/ModOptions.cs +++ b/ModOptions.cs @@ -1,36 +1,8 @@ -using System.IO; -using Newtonsoft.Json; -using TinyLife; -using TinyLife.Mods; - namespace ExampleMod; -// a simple implementation of custom options for the example mod +// these options are saved and loaded in ExampleMod public class ModOptions { public float DarkShirtSpeedIncrease = 2; - // a simple save method for the mod options, which saves the current instance to the designated options file - public void Save(ModInfo info) { - ExampleMod.Logger.Info($"Saving options to {info.OptionsFile}"); - if (!info.OptionsFile.Directory.Exists) - info.OptionsFile.Directory.Create(); - using var writer = new JsonTextWriter(info.OptionsFile.CreateText()); - SaveHandler.CreateSerializer(null).Serialize(writer, this); - } - - // a simple loader for the mod options, which uses the designated options file given to us by the game - // this method loads an instance of the options using a JSON loader and then returns it to be used in ExampleMod - public static ModOptions Load(ModInfo info) { - ExampleMod.Logger.Info($"Loading options from {info.OptionsFile}"); - if (info.OptionsFile.Exists) { - using var reader = new JsonTextReader(info.OptionsFile.OpenText()); - return SaveHandler.CreateSerializer(null).Deserialize(reader); - } else { - var ret = new ModOptions(); - ret.Save(info); - return ret; - } - } - } diff --git a/build.cake b/build.cake index d41f223..fc3aa7d 100644 --- a/build.cake +++ b/build.cake @@ -8,6 +8,7 @@ var config = Argument("configuration", "Release"); var tinyLifeDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/Tiny Life"; Task("Build").DoesForEach(GetFiles("**/*.csproj"), p => { + DeleteFiles($"bin/{config}/**/*"); DotNetBuild(p.FullPath, new DotNetBuildSettings { Configuration = config }); }); @@ -25,6 +26,7 @@ Task("Run").IsDependentOn("CopyToMods").Does(() => { throw new Exception("Didn't find game directory information. Run the game manually at least once to allow the Run task to be executed."); var exe = $"{System.IO.File.ReadAllText(exeDir)}/Tiny Life"; var process = Process.Start(new ProcessStartInfo(exe) { + Arguments = "-v --skip-splash --skip-preloads", CreateNoWindow = true });