forked from g0nzo83/EVE-X-Preview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.ahk
154 lines (131 loc) · 5.05 KB
/
Main.ahk
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#Requires AutoHotkey v2.0
#Include <DefaultJSON> ; The Default Settings Values
#Include <JSON>
#Include <LiveThumb>
#Include <../src/Main_Class>
#Include <../src/ThumbWindow>
#Include <../src/TrayMenu>
#Include <../src/Propertys>
#Include <../src/Settings_Gui>
#SingleInstance Force
Persistent
ListLines False
KeyHistory 0
CoordMode "Mouse", "Screen" ; to track Window Mouse possition while DragMoving the thumbnails
SetWinDelay -1
FileEncoding("UTF-8") ; Encoding for JSSON file
SetTitleMatchMode 3
A_MaxHotKeysPerInterval := 10000
/*
TODO #########################
*/
;@Ahk2Exe-Let U_version = 1.0.4.
;@Ahk2Exe-SetVersion %U_version%
;@Ahk2Exe-SetFileVersion %U_version%
;@Ahk2Exe-SetCopyright gonzo83
;@Ahk2Exe-SetDescription EVE-X-Preview
;@Ahk2Exe-SetProductName EVE-X-Preview
;@Ahk2Exe-ExeName EVE-X-Preview
;@Ahk2Exe-AddResource icon.ico, 160 ; Replaces 'H on blue'
;@Ahk2Exe-AddResource icon-suspend.ico, 206 ; Replaces 'S on green'
;@Ahk2Exe-AddResource icon.ico, 207 ; Replaces 'H on red'
;@Ahk2Exe-AddResource icon-suspend.ico, 208 ; Replaces 'S on red'
;@Ahk2Exe-SetMainIcon icon.ico
if !(A_IsCompiled)
TraySetIcon("icon.ico",,true)
; Catch all unhandled Errors to prevent the Script from stopping
OnError(Error_Handler)
Call := Main_Class()
Load_JSON() {
DJSON := JSON.Load(default_JSON)
if !(FileExist("EVE-X-Preview.json")) {
FileAppend(JSON.Dump(DJSON,," " ), "EVE-X-Preview.json")
_JSON := JSON.Load(FileRead("EVE-X-Preview.json"))
return _JSON
}
else {
Try {
if (FileExist("EVE-X-Preview.json")) {
;if needed because of Backward combativity from the alpha versions
MergeJson()
}
_JSON := JsonMergeNoOverwrite(
DJSON,
JSON.Load(FileRead("EVE-X-Preview.json"))
)
FileDelete("EVE-X-Preview.json")
FileAppend(JSON.Dump(_JSON,," " ), "EVE-X-Preview.json")
}
catch as e {
value := MsgBox("The settings file is corrupted. Do you want to create a new one?",,"OKCancel")
if (value = "Cancel")
ExitApp()
FileDelete("EVE-X-Preview.json")
FileAppend(JSON.Dump(DJSON,, " "), "EVE-X-Preview.json")
_JSON := JSON.Load(FileRead("EVE-X-Preview.json"))
}
}
return _JSON
}
;Compare the User json wit the default Json to check if any key changed for possible future updates.
JsonMergeNoOverwrite(obj1, obj2) {
for key, value in obj1 {
if (obj2.Has(key)) {
if (IsObject(value) && IsObject(obj2[key]))
obj2[key] := JsonMergeNoOverwrite(value, obj2[key])
} else {
obj2[key] := value
}
}
return obj2
}
;THis function is only used to merge the Json from old versions into the new one
MergeJson(Settingsfile := "EVE-X-Preview.json", dJson := JSON.Load(default_JSON)) {
;Load the content from the existing Json File
fileObj := FileOpen(Settingsfile,"r", "Utf-8")
JsonRaw := fileObj.Read(), fileObj.Close()
OldJson := JSON.Load(JsonRaw)
savetofile := 0
for Profiles, settings in OldJson["_Profiles"] {
if (Profiles = "Default") {
continue
}
dJson["_Profiles"][Profiles] := Map()
for k, v in settings {
if (OldJson["_Profiles"][Profiles].Has("ClientPossitions")) {
savetofile := 1
if (k = "ClientPossitions")
dJson["_Profiles"][Profiles]["Client Possitions"] := v
else if (k = "ClientSettings")
dJson["_Profiles"][Profiles]["Client Settings"] := v
else if (k = "ThumbnailSettings")
dJson["_Profiles"][Profiles]["Thumbnail Settings"] := v
else if (k = "ThumbnailPositions")
dJson["_Profiles"][Profiles]["Thumbnail Positions"] := v
else if (k = "Thumbnail_visibility")
dJson["_Profiles"][Profiles]["Thumbnail Visibility"] := v
else if (k = "Custom_Colors")
dJson["_Profiles"][Profiles]["Custom Colors"] := dJson["_Profiles"]["Default"]["Custom Colors"]
else if (k = "Hotkey_Groups")
dJson["_Profiles"][Profiles]["Hotkey Groups"] := v
else if (k = "Hotkeys") {
if (Type(v) = "Map") {
Arr := []
for char, hotkey in v
Arr.Push(Map(char, hotkey))
dJson["_Profiles"][Profiles]["Hotkeys"] := Arr
}
}
}
}
}
if savetofile {
dJson["global_Settings"] := OldJson["global_Settings"]
fileObj := FileOpen(Settingsfile,"w", "Utf-8")
fileObj.Write(JSON.Dump(dJson,, " ")), fileObj.Close()
}
}
; Hanles unmanaged Errors
Error_Handler(Thrown, Mode) {
return -1
}