forked from Chinzilla00/AncientsAwakened
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAAConfig.cs
86 lines (74 loc) · 2.54 KB
/
AAConfig.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Terraria.ModLoader.Config;
using System.IO;
using Terraria;
using Terraria.IO;
using Terraria.ModLoader;
using System.ComponentModel;
using System.Collections.Generic;
namespace AAMod
{
public class AAConfigClient : ModConfig
{
public override ConfigScope Mode => ConfigScope.ClientSide;
public static AAConfigClient Instance; // See ExampleConfigServer.Instance for info.
[Label("$Mods.AAMod.Common.AATownNPC")]
[Tooltip("$Mods.AAMod.Common.AATownNPCInfo")]
public bool NoAATownNPC;
[Label("$Mods.AAMod.Common.DisableBossDialogue")]
[Tooltip("$Mods.AAMod.Common.DisableBossDialogueInfo")]
public bool NoBossDialogue;
[DefaultValue(false)]
[Label("$Mods.AAMod.Common.AAStyleMainPage")]
[Tooltip("$Mods.AAMod.Common.AAStyleMainPageInfo")]
public bool AAStyleMainPage;
}
public static class Config
{
public static void Load()
{
if (!ReadConfig())
{
SetDefaults();
ModContent.GetInstance<AAMod>().Logger.Warn("Couldn't find config file! Creating a new one...");
}
SaveConfig();
}
private static readonly string ConfigPath = Path.Combine(Main.SavePath, "Mod Configs", "AAConfig.json");
private static readonly Preferences Configuration = new Preferences(ConfigPath, false, false);
public static void SetDefaults()
{
LuckyOre = new Dictionary<int, int>();
LuckyPotion = new Dictionary<int, int>();
ListRareNpc = new List<int>();
}
public static bool ReadConfig()
{
if (Configuration.Load())
{
try
{
Configuration.Get("LuckyOreMine", ref LuckyOre);
Configuration.Get("LuckyPotionGet", ref LuckyPotion);
Configuration.Get("RareNpcList", ref ListRareNpc);
}
catch
{
return false;
}
return true;
}
return false;
}
public static void SaveConfig()
{
Configuration.Clear();
Configuration.Put("LuckyOreMine", LuckyOre);
Configuration.Put("LuckyPotionGet", LuckyPotion);
Configuration.Put("RareNpcList", ListRareNpc);
Configuration.Save(true);
}
public static Dictionary<int, int> LuckyOre = new Dictionary<int, int>();
public static Dictionary<int, int> LuckyPotion = new Dictionary<int, int>();
public static List<int> ListRareNpc = new List<int>();
}
}