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 Nov 1, 2024
2 parents 700f2d2 + 403ce94 commit a309110
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 70 deletions.
67 changes: 0 additions & 67 deletions Lib/Config.ahk

This file was deleted.

118 changes: 118 additions & 0 deletions Lib/Configuration.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#Requires AutoHotkey v2.0

Class Configuration {

DefaultTab := ""
PrevIousTab := False
Settings := Array()
Tabs := Array()
Title := ""

__New(Title := "Configuration", DefaultTab := "General") {
This.Title := Title
This.DefaultTab := DefaultTab
}

Add(FileName, SectionName, KeyName, DefaultValue, Label := False, Tab := False, FuncOnSet := False) {
If Not This.PrevIousTab
This.PrevIousTab := This.DefaultTab
If Not Tab
Tab := This.PrevIousTab
Else
This.PrevIousTab := Tab
Setting := {FileName: FileName, SectionName: SectionName, KeyName: KeyName, DefaultValue: DefaultValue, Label: Label, Tab: Tab, FuncOnSet: FuncOnSet}
Setting.Value := IniRead(FileName, SectionName, KeyName, DefaultValue)
IniWrite(Setting.Value, FileName, SectionName, KeyName)
This.Settings.Push(Setting)
For Value In This.Tabs
If Setting.Tab = Value
Return
This.Tabs.Push(Setting.Tab)
}

Get(KeyNameOrNumber) {
If KeyNameOrNumber Is Integer And KeyNameOrNumber >= 1 And KeyNameOrNumber <= This.Settings.Length
Return This.Settings[KeyNameOrNumber].Value
If KeyNameOrNumber Is String
For Setting In This.Settings
If Setting.KeyName = KeyNameOrNumber
Return Setting.Value
}

Set(KeyNameOrNumber, Value) {
If KeyNameOrNumber Is Integer And KeyNameOrNumber >= 1 And KeyNameOrNumber <= This.Settings.Length {
Setting := This.Settings[KeyNameOrNumber]
SetValue(Setting)
Return
}
If KeyNameOrNumber Is String
For Setting In This.Settings
If Setting.KeyName = KeyNameOrNumber {
SetValue(Setting)
Return
}
SetValue(Setting) {
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)
}
}

ShowBox() {
Static ConfigBox := False, ConfigBoxWinID := ""
If ConfigBox = False {
ConfigBox := Gui(, This.Title)
LabelledSettings := Array()
SettingBoxes := Map()
TabsUsed := Map()
For Index, Setting In This.Settings {
If Setting.Label
LabelledSettings.Push(Setting)
TabsUsed.Set(Setting.Tab, False)
}
If LabelledSettings.Length = 0
ConfigBox.AddText("Section", "No settings available.")
If LabelledSettings.Length > 0 And This.Tabs.Length > 1
TabBox := ConfigBox.AddTab3("Section", This.Tabs)
For Index, Setting In LabelledSettings {
Checked := ""
If Setting.Value = 1
Checked := "Checked"
If IsSet(TabBox)
TabBox.UseTab(Setting.Tab)
If Not TabsUsed[Setting.Tab]
FirstControl := True
Else
FirstControl := False
TabsUsed[Setting.Tab] := True
If FirstControl
SettingBoxes[Setting.KeyName] := ConfigBox.AddCheckBox("Section " . Checked, Setting.Label)
Else
SettingBoxes[Setting.KeyName] := ConfigBox.AddCheckBox("XS " . Checked, Setting.Label)
}
If IsSet(TabBox)
TabBox.UseTab()
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()
}
}

}
6 changes: 3 additions & 3 deletions Lib/ReaHotkey.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ Class ReaHotkey {
}

Static InitConfig() {
ReaHotkey.Config := Configuration("ReaHotkey Configuration")
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", "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")
Expand Down Expand Up @@ -742,7 +743,7 @@ Class ReaHotkey {

Class ShowConfigBox {
Static Call(*) {
ReaHotkey.Config.ShowBox("ReaHotkey Configuration")
ReaHotkey.Config.ShowBox()
}
}

Expand Down Expand Up @@ -810,7 +811,6 @@ Class ReaHotkey {
}
}

#Include <Config>
#Include <Update>

}
1 change: 1 addition & 0 deletions ReaHotkey.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SetTitleMatchMode "RegEx"
#Include <AccessibleMenu>
#Include <AccessiblePluginMenu>
#Include <AccessibleStandaloneMenu>
#Include <Configuration>
#Include <JXON>
#Include <OCR>
#Include <Program>
Expand Down

0 comments on commit a309110

Please sign in to comment.