Skip to content

Commit

Permalink
Merge branch 'Client-Mode' into Bridged-ModeSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejGolian committed Oct 31, 2024
2 parents 6753e87 + 159d8ea commit 700f2d2
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 75 deletions.
100 changes: 63 additions & 37 deletions Lib/Config.ahk
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()
}
}

}
60 changes: 22 additions & 38 deletions Lib/ReaHotkey.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Class ReaHotkey {
Static StandaloneHotkeyOverrides := Array()

Static __New() {
OnError ReaHotkey.HandleError
ReaHotkey.TurnPluginHotkeysOff()
ReaHotkey.TurnStandaloneHotkeysOff()
ReaHotkey.InitConfig()
OnError ReaHotkey.HandleError
ScriptReloaded := False
For Arg In A_Args
If Arg = "Reload" {
Expand Down Expand Up @@ -165,6 +166,16 @@ Class ReaHotkey {
Return False
}

Static InitConfig() {
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "CheckScreenResolutionOnStartup", 1, "Check screen resolution on startup")
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "CheckForUpdatesOnStartup", 1, "Check for updates on startup")
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "WarnIfWinCovered", 1, "Warn if another window may be covering the interface in specific cases", ReaHotkey.ManageWinCovered)
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "UseImageSearchForEngine2PluginDetection", 1, "Use image search for Engine 2 plug-in detection")
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "AutomaticallyCloseLibrariBrowsersInKontaktAndKKPlugins", 1, "Automatically close library browsers in Kontakt and Komplete Kontrol plug-ins")
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "AutomaticallyCloseLibrariBrowsersInKontaktAndKKStandalones", 1, "Automatically close library browsers in Kontakt and Komplete Kontrol standalone applications")
ReaHotkey.Config.Add("ReaHotkey.ini", "Config", "AutomaticallyDetectLibrariesInKontaktAndKKPlugins", 1, "Automatically detect libraries in Kontakt and Komplete Kontrol plug-ins")
}

Static InPluginControl(ControlToCheck) {
If ReaHotkey.PluginWinCriteria And WinActive(ReaHotkey.PluginWinCriteria) {
PluginControl := ReaHotkey.GetPluginControl()
Expand Down Expand Up @@ -683,6 +694,15 @@ Class ReaHotkey {
}
}

Class ManageWinCovered {
Static Call(Setting) {
If Setting.Value
SetTimer ReaHotkey.CheckIfWinCovered, 10000
Else
SetTimer ReaHotkey.CheckIfWinCovered, 0
}
}

Class Quit {
Static Call(*) {
ExitApp
Expand Down Expand Up @@ -722,43 +742,7 @@ Class ReaHotkey {

Class ShowConfigBox {
Static Call(*) {
Static ConfigBox := False, ConfigBoxWinID := ""
If ConfigBox = False {
ConfigBox := Gui(, "ReaHotkey Configuration")
SettingBoxes := Map()
For Index, Setting In ReaHotkey.Config.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
ReaHotkey.Config.set(KeyName, SettingBox.Value)
If ReaHotkey.Config.Get("WarnIfWinCovered")
SetTimer ReaHotkey.CheckIfWinCovered, 10000
Else
SetTimer ReaHotkey.CheckIfWinCovered, 0
CloseConfigBox()
}
ReaHotkey.Config.ShowBox("ReaHotkey Configuration")
}
}

Expand Down

0 comments on commit 700f2d2

Please sign in to comment.