-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathConfiguration.cs
69 lines (46 loc) · 1.95 KB
/
Configuration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using Dalamud.Configuration;
using Dalamud.Plugin;
using Newtonsoft.Json;
namespace PriceInsight;
[Serializable]
public class Configuration : IPluginConfiguration {
public int Version { get; set; } = 2;
public bool ShowRegion { get; set; } = false;
public bool ShowDatacenter { get; set; } = true;
public bool ShowWorld { get; set; } = true;
public bool ShowStackSalePrice { get; set; } = false;
public bool ShowMostRecentPurchase { get; set; } = false;
public bool ShowMostRecentPurchaseRegion { get; set; } = false;
public bool ShowMostRecentPurchaseWorld { get; set; } = true;
public int ShowDailySaleVelocityIn { get; set; } = 1;
public int ShowAverageSalePriceIn { get; set; } = 0;
public bool UseCurrentWorld { get; set; } = false;
public bool RefreshWithAlt { get; set; } = true;
public bool PrefetchInventory { get; set; } = true;
public bool ShowAge { get; set; } = true;
public bool ShowDatacenterOnCrossWorlds { get; set; } = true;
public bool ShowBothNqAndHq { get; set; } = true;
[JsonExtensionData]
public Dictionary<string, object> AdditionalData { get; set; } = new();
// the below exist just to make saving less cumbersome
[NonSerialized] private IDalamudPluginInterface pluginInterface = null!;
public static Configuration Get(IDalamudPluginInterface pluginInterface) {
var config = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
config.pluginInterface = pluginInterface;
config.Migrate();
return config;
}
private void Migrate() {
if (Version < 2) {
ShowAverageSalePriceIn = Equals(AdditionalData.GetValueOrDefault("ShowAverageSalePrice"), true) ? 1 : 0;
AdditionalData.Clear();
Version = 2;
Save();
}
}
public void Save() {
pluginInterface.SavePluginConfig(this);
}
}