-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54b4128
commit 159d8ea
Showing
2 changed files
with
85 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,67 @@ | ||
#Requires AutoHotkey v2.0 | ||
|
||
Class Config { | ||
|
||
Static Settings := Array() | ||
|
||
Static __New() { | ||
This.Add("ReaHotkey.ini", "Config", "CheckScreenResolutionOnStartup", 1, "Check screen resolution on startup") | ||
This.Add("ReaHotkey.ini", "Config", "CheckForUpdatesOnStartup", 1, "Check for updates on startup") | ||
This.Add("ReaHotkey.ini", "Config", "WarnIfWinCovered", 1, "Warn if another window may be covering the interface in specific cases") | ||
This.Add("ReaHotkey.ini", "Config", "UseImageSearchForEngine2PluginDetection", 1, "Use image search for Engine 2 plug-in detection") | ||
This.Add("ReaHotkey.ini", "Config", "AutomaticallyCloseLibrariBrowsersInKontaktAndKKPlugins", 1, "Automatically close library browsers in Kontakt and Komplete Kontrol plug-ins") | ||
This.Add("ReaHotkey.ini", "Config", "AutomaticallyCloseLibrariBrowsersInKontaktAndKKStandalones", 1, "Automatically close library browsers in Kontakt and Komplete Kontrol standalone applications") | ||
This.Add("ReaHotkey.ini", "Config", "AutomaticallyDetectLibrariesInKontaktAndKKPlugins", 1, "Automatically detect libraries in Kontakt and Komplete Kontrol plug-ins") | ||
} | ||
|
||
Static Add(FileName, SectionName, KeyName, DefaultValue, Label, FuncOnSet := False) { | ||
Setting := {FileName: FileName, SectionName: SectionName, KeyName: KeyName, DefaultValue: DefaultValue, Label: Label, FuncOnSet: FuncOnSet} | ||
Setting.Value := IniRead(FileName, SectionName, KeyName, DefaultValue) | ||
IniWrite(Setting.Value, FileName, SectionName, KeyName) | ||
This.Settings.Push(Setting) | ||
} | ||
|
||
Static Get(KeyName) { | ||
For Setting In This.Settings | ||
If Setting.KeyName = KeyName | ||
Return Setting.Value | ||
} | ||
|
||
Static Set(KeyName, Value) { | ||
For Setting In This.Settings | ||
If Setting.KeyName = KeyName { | ||
Setting.Value := Value | ||
IniWrite(Setting.Value, Setting.FileName, Setting.SectionName, Setting.KeyName) | ||
If Setting.FuncOnSet Is Object And Setting.FuncOnSet.HasMethod("Call") | ||
Setting.FuncOnSet.Call(Setting) | ||
Return | ||
} | ||
} | ||
|
||
|
||
Static Settings := Array() | ||
|
||
Static Add(FileName, SectionName, KeyName, DefaultValue, Label, FuncOnSet := False) { | ||
Setting := {FileName: FileName, SectionName: SectionName, KeyName: KeyName, DefaultValue: DefaultValue, Label: Label, FuncOnSet: FuncOnSet} | ||
Setting.Value := IniRead(FileName, SectionName, KeyName, DefaultValue) | ||
IniWrite(Setting.Value, FileName, SectionName, KeyName) | ||
This.Settings.Push(Setting) | ||
} | ||
|
||
Static Get(KeyName) { | ||
For Setting In This.Settings | ||
If Setting.KeyName = KeyName | ||
Return Setting.Value | ||
} | ||
|
||
Static Set(KeyName, Value) { | ||
For Setting In This.Settings | ||
If Setting.KeyName = KeyName { | ||
Setting.Value := Value | ||
IniWrite(Setting.Value, Setting.FileName, Setting.SectionName, Setting.KeyName) | ||
If Setting.FuncOnSet Is Object And Setting.FuncOnSet.HasMethod("Call") | ||
Setting.FuncOnSet.Call(Setting) | ||
Return | ||
} | ||
} | ||
|
||
Static ShowBox(Title := "Configuration") { | ||
Static ConfigBox := False, ConfigBoxWinID := "" | ||
If ConfigBox = False { | ||
ConfigBox := Gui(, Title) | ||
SettingBoxes := Map() | ||
For Index, Setting In This.Settings { | ||
Checked := "" | ||
If Setting.Value = 1 | ||
Checked := "Checked" | ||
If Index = 1 | ||
SettingBoxes[Setting.KeyName] := ConfigBox.AddCheckBox(Checked, Setting.Label) | ||
Else | ||
SettingBoxes[Setting.KeyName] := ConfigBox.AddCheckBox("XS " . Checked, Setting.Label) | ||
} | ||
ConfigBox.AddButton("Section XS Default", "OK").OnEvent("Click", SaveConfig) | ||
ConfigBox.AddButton("YS", "Cancel").OnEvent("Click", CloseConfigBox) | ||
ConfigBox.OnEvent("Close", CloseConfigBox) | ||
ConfigBox.OnEvent("Escape", CloseConfigBox) | ||
ConfigBox.Show() | ||
ConfigBoxWinID := WinGetID("A") | ||
} | ||
Else { | ||
WinActivate(ConfigBoxWinID) | ||
} | ||
CloseConfigBox(*) { | ||
ConfigBox.Destroy() | ||
ConfigBox := False | ||
ConfigBoxWinID := "" | ||
} | ||
SaveConfig(*) { | ||
For KeyName, SettingBox In SettingBoxes | ||
This.set(KeyName, SettingBox.Value) | ||
CloseConfigBox() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters