This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.py
72 lines (65 loc) · 1.91 KB
/
Config.py
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
# Module to load and make config whenever needed
import json
class Config:
Path = "config.json"
Layout = {
"HunterPy" : {
"Update" : {
"Enabled" : True,
"Branch" : "master"
}
},
"Overlay" : {
"Enabled" : False,
"Position": [0, 0],
"MonstersComponent" : {
"Enabled" : True,
"Position": [0, 0]
},
"HarvestBoxComponent" : {
"Enabled" : True,
"Position" : [1160, 30]
},
"PrimaryMantle" : {
"Enabled" : True,
"Position" : [1170, 500]
},
"SecondaryMantle" : {
"Enabled" : True,
"Position" : [1170, 540]
}
},
"RichPresence" : {
"Enabled" : True
}
}
def __init__(self):
self.ValidateJson()
self.Config = None
def ValidateJson(self):
self.LoadConfig()
for key in Config.Layout:
if key not in self.Config:
self.Config[key] = {}
for subkey in Config.Layout[key]:
if subkey not in self.Config[key]:
self.Config[key][subkey] = Config.Layout[key][subkey]
self.SaveConfig()
def LoadConfig(self):
try:
file = open(Config.Path, 'r')
self.Config = json.load(file)
file.close()
except FileNotFoundError:
self.MakeConfig()
self.LoadConfig()
except json.decoder.JSONDecodeError:
pass
def MakeConfig(self):
file = open(Config.Path, 'w')
json.dump(Config.Layout, file, indent=4)
file.close()
def SaveConfig(self):
file = open(Config.Path, 'w')
json.dump(self.Config, file, indent=4)
file.close()