Skip to content

Commit 011f1c5

Browse files
updated to UI settings
1 parent 4f6a977 commit 011f1c5

File tree

4 files changed

+16
-74
lines changed

4 files changed

+16
-74
lines changed

HalgarisRPGLoot/ArmorAnalyzer.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace HalgarisRPGLoot
1515
{
1616
public class ArmorAnalyzer
1717
{
18-
private Settings Settings = new Settings();
18+
private Settings Settings = Program.Settings;
1919

2020
public IPatcherState<ISkyrimMod, ISkyrimModGetter> State { get; set; }
2121
public ILeveledItemGetter[] AllLeveledLists { get; set; }
@@ -39,35 +39,6 @@ public ArmorAnalyzer(IPatcherState<ISkyrimMod, ISkyrimModGetter> state)
3939

4040
{
4141
State = state;
42-
LoadSettings();
43-
}
44-
45-
private void LoadSettings()
46-
{
47-
const string path = "Data/ArmorSettings.json";
48-
if (!File.Exists(path))
49-
{
50-
// Ensure the default settings are saved
51-
Settings.InitializeDefault();
52-
SaveSettings();
53-
return;
54-
}
55-
using (var file = File.OpenText(path))
56-
{
57-
var serializer = new JsonSerializer();
58-
Settings = (Settings)serializer.Deserialize(file, typeof(Settings));
59-
}
60-
}
61-
62-
private void SaveSettings()
63-
{
64-
const string path = "Data/ArmorSettings.json";
65-
Directory.CreateDirectory(Path.GetDirectoryName(path));
66-
using (var file = File.CreateText(path))
67-
{
68-
var serializer = new JsonSerializer();
69-
serializer.Serialize(file, Settings);
70-
}
7142
}
7243

7344
public void Analyze()

HalgarisRPGLoot/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ namespace HalgarisRPGLoot
1010
{
1111
class Program
1212
{
13+
static Lazy<Settings> _LazySettings = null!;
14+
public static Settings Settings => _LazySettings.Value;
1315
static async Task<int> Main(string[] args)
1416
{
1517
return await SynthesisPipeline.Instance
16-
.SetTypicalOpen(GameRelease.SkyrimSE, "HalgariRpgLoot.esp")
1718
.AddPatch<ISkyrimMod, ISkyrimModGetter>(RunPatch)
19+
.SetAutogeneratedSettings(
20+
nickname: "Settings",
21+
path: "settings.json",
22+
out _LazySettings)
23+
.SetTypicalOpen(GameRelease.SkyrimSE, "HalgariRpgLoot.esp")
1824
.Run(args);
1925
}
2026

HalgarisRPGLoot/Settings.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
using System;
1+
using Mutagen.Bethesda;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

56
namespace HalgarisRPGLoot
67
{
7-
[System.Serializable]
8-
public class Settings
8+
public record Settings
99
{
10-
public int VarietyCountPerItem;
11-
public List<Rarity> Rarities = new List<Rarity>();
12-
public bool UseRNGRarities;
13-
14-
public void InitializeDefault()
15-
{
16-
UseRNGRarities = true;
17-
VarietyCountPerItem = 8;
18-
Rarities = new List<Rarity>() {
10+
public int VarietyCountPerItem = 8;
11+
public List<Rarity> Rarities = new List<Rarity>() {
1912
new Rarity() { Label= "Magical", NumEnchantments=1, LLEntries=80 },
2013
new Rarity() { Label= "Rare", NumEnchantments=2, LLEntries=13 },
2114
new Rarity() { Label= "Epic", NumEnchantments=3, LLEntries=5 },
2215
new Rarity() { Label= "Legendary", NumEnchantments=4, LLEntries=2 },
2316
};
24-
}
17+
public bool UseRNGRarities = true;
18+
2519
}
2620

2721
[System.Serializable]

HalgarisRPGLoot/WeaponAnalyer.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace HalgarisRPGLoot
1414
{
1515
public class WeaponAnalyzer
1616
{
17-
private Settings Settings = new Settings();
17+
private Settings Settings = Program.Settings;
1818

1919
public IPatcherState<ISkyrimMod, ISkyrimModGetter> State { get; set; }
2020
public ILeveledItemGetter[] AllLeveledLists { get; set; }
@@ -38,35 +38,6 @@ public WeaponAnalyzer(IPatcherState<ISkyrimMod, ISkyrimModGetter> state)
3838

3939
{
4040
State = state;
41-
LoadSettings();
42-
}
43-
44-
private void LoadSettings()
45-
{
46-
const string path = "Data/WeaponSettings.json";
47-
if(!File.Exists(path))
48-
{
49-
// Ensure the default settings are saved
50-
Settings.InitializeDefault();
51-
SaveSettings();
52-
return;
53-
}
54-
using (var file = File.OpenText(path))
55-
{
56-
var serializer = new JsonSerializer();
57-
Settings = (Settings)serializer.Deserialize(file, typeof(Settings));
58-
}
59-
}
60-
61-
private void SaveSettings()
62-
{
63-
const string path = "Data/WeaponSettings.json";
64-
Directory.CreateDirectory(Path.GetDirectoryName(path));
65-
using (var file = File.CreateText(path))
66-
{
67-
var serializer = new JsonSerializer();
68-
serializer.Serialize(file, Settings);
69-
}
7041
}
7142

7243
public void Analyze()

0 commit comments

Comments
 (0)