diff --git a/HalgarisRPGLoot/ArmorAnalyzer.cs b/HalgarisRPGLoot/ArmorAnalyzer.cs index f496ef2..a337cbb 100644 --- a/HalgarisRPGLoot/ArmorAnalyzer.cs +++ b/HalgarisRPGLoot/ArmorAnalyzer.cs @@ -15,7 +15,7 @@ namespace HalgarisRPGLoot { public class ArmorAnalyzer { - private Settings Settings = new Settings(); + private ArmorSettings Settings = Program.Settings.ArmorSettings; public IPatcherState State { get; set; } public ILeveledItemGetter[] AllLeveledLists { get; set; } @@ -39,35 +39,6 @@ public ArmorAnalyzer(IPatcherState state) { State = state; - LoadSettings(); - } - - private void LoadSettings() - { - const string path = "Data/ArmorSettings.json"; - if (!File.Exists(path)) - { - // Ensure the default settings are saved - Settings.InitializeDefault(); - SaveSettings(); - return; - } - using (var file = File.OpenText(path)) - { - var serializer = new JsonSerializer(); - Settings = (Settings)serializer.Deserialize(file, typeof(Settings)); - } - } - - private void SaveSettings() - { - const string path = "Data/ArmorSettings.json"; - Directory.CreateDirectory(Path.GetDirectoryName(path)); - using (var file = File.CreateText(path)) - { - var serializer = new JsonSerializer(); - serializer.Serialize(file, Settings); - } } public void Analyze() diff --git a/HalgarisRPGLoot/Extensions.cs b/HalgarisRPGLoot/Extensions.cs index 1d414fd..ec8c122 100644 --- a/HalgarisRPGLoot/Extensions.cs +++ b/HalgarisRPGLoot/Extensions.cs @@ -8,7 +8,7 @@ namespace HalgarisRPGLoot { public static class Extensions { - public static Random Random { get; set; } = new Random(42); + public static Random Random { get; set; } = new Random(Program.Settings.RandomSeed); public static T RandomItem(this T[] itms) { diff --git a/HalgarisRPGLoot/Program.cs b/HalgarisRPGLoot/Program.cs index e67b0db..953fb1d 100644 --- a/HalgarisRPGLoot/Program.cs +++ b/HalgarisRPGLoot/Program.cs @@ -10,11 +10,18 @@ namespace HalgarisRPGLoot { class Program { + static Lazy _LazySettings = null!; + public static Settings Settings => _LazySettings.Value; + static async Task Main(string[] args) { return await SynthesisPipeline.Instance - .SetTypicalOpen(GameRelease.SkyrimSE, "HalgariRpgLoot.esp") .AddPatch(RunPatch) + .SetAutogeneratedSettings( + nickname: "Settings", + path: "Settings.json", + out _LazySettings) + .SetTypicalOpen(GameRelease.SkyrimSE, "HalgariRpgLoot.esp") .Run(args); } diff --git a/HalgarisRPGLoot/Rarity.cs b/HalgarisRPGLoot/Rarity.cs new file mode 100644 index 0000000..a4c4b22 --- /dev/null +++ b/HalgarisRPGLoot/Rarity.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Mutagen.Bethesda.Synthesis.Settings; +/* +namespace HalgarisRPGLoot +{ + [System.Serializable] + public class Rarity + { + public string Label; + public int NumEnchantments; + public int LLEntries; + } +} +*/ \ No newline at end of file diff --git a/HalgarisRPGLoot/Settings.cs b/HalgarisRPGLoot/Settings.cs index 38a00bc..cd9277f 100644 --- a/HalgarisRPGLoot/Settings.cs +++ b/HalgarisRPGLoot/Settings.cs @@ -1,34 +1,68 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; +using System.Threading.Tasks; +using Mutagen.Bethesda.Synthesis.Settings; namespace HalgarisRPGLoot { - [System.Serializable] public class Settings { - public int VarietyCountPerItem; - public List Rarities = new List(); - public bool UseRNGRarities; + public int RandomSeed = 42; - public void InitializeDefault() - { - UseRNGRarities = true; - VarietyCountPerItem = 8; - Rarities = new List() { + public ArmorSettings ArmorSettings = new ArmorSettings(); + public WeaponSettings WeaponSettings = new WeaponSettings(); + + } + public class ArmorSettings + { + [SynthesisSettingName("Number of variations per Item")] + [SynthesisTooltip("This determines how many different versions\n" + + "of the same Armor you can find.")] + public int VarietyCountPerItem = 50; + [SynthesisSettingName("Rarity Levels")] + [SynthesisTooltip("Custom defineable rarity levels")] + public List Rarities = new List() { + new Rarity() { Label= "Magical", NumEnchantments=1, LLEntries=80 }, + new Rarity() { Label= "Rare", NumEnchantments=2, LLEntries=13 }, + new Rarity() { Label= "Epic", NumEnchantments=3, LLEntries=5 }, + new Rarity() { Label= "Legendary", NumEnchantments=4, LLEntries=2 }, + }; + [SynthesisSettingName("Use RNGRarity")] + [SynthesisTooltip("With this set to true the number of variations\n" + + "per item will be randomised.")] + public bool UseRNGRarities = true; + } + + public class WeaponSettings + { + [SynthesisSettingName("Number of variations per Item")] + [SynthesisTooltip("This determines how many different versions\n" + + "of the same Weapon you can find.")] + public int VarietyCountPerItem = 50; + [SynthesisSettingName("Rarity Levels")] + [SynthesisTooltip("Custom defineable rarity levels")] + public List Rarities = new List() { new Rarity() { Label= "Magical", NumEnchantments=1, LLEntries=80 }, new Rarity() { Label= "Rare", NumEnchantments=2, LLEntries=13 }, new Rarity() { Label= "Epic", NumEnchantments=3, LLEntries=5 }, new Rarity() { Label= "Legendary", NumEnchantments=4, LLEntries=2 }, }; - } + [SynthesisSettingName("Use RNGRarity")] + [SynthesisTooltip("With this set to true the number of variations\n" + + "per item will be randomised.")] + public bool UseRNGRarities = true; } - [System.Serializable] public class Rarity { + [SynthesisSettingName("Rarity Label")] public string Label; + [SynthesisSettingName("Number of Enchantments")] public int NumEnchantments; + [SynthesisSettingName("Number of LevedList Entries")] + [SynthesisTooltip("The higher the number the more common it is.")] public int LLEntries; } } diff --git a/HalgarisRPGLoot/WeaponAnalyer.cs b/HalgarisRPGLoot/WeaponAnalyer.cs index d74b6bd..a393b16 100644 --- a/HalgarisRPGLoot/WeaponAnalyer.cs +++ b/HalgarisRPGLoot/WeaponAnalyer.cs @@ -14,7 +14,7 @@ namespace HalgarisRPGLoot { public class WeaponAnalyzer { - private Settings Settings = new Settings(); + private WeaponSettings Settings = Program.Settings.WeaponSettings; public IPatcherState State { get; set; } public ILeveledItemGetter[] AllLeveledLists { get; set; } @@ -38,35 +38,6 @@ public WeaponAnalyzer(IPatcherState state) { State = state; - LoadSettings(); - } - - private void LoadSettings() - { - const string path = "Data/WeaponSettings.json"; - if(!File.Exists(path)) - { - // Ensure the default settings are saved - Settings.InitializeDefault(); - SaveSettings(); - return; - } - using (var file = File.OpenText(path)) - { - var serializer = new JsonSerializer(); - Settings = (Settings)serializer.Deserialize(file, typeof(Settings)); - } - } - - private void SaveSettings() - { - const string path = "Data/WeaponSettings.json"; - Directory.CreateDirectory(Path.GetDirectoryName(path)); - using (var file = File.CreateText(path)) - { - var serializer = new JsonSerializer(); - serializer.Serialize(file, Settings); - } } public void Analyze()