Skip to content

Commit

Permalink
Improve 'Generic Plug-in' focusing behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejGolian committed Dec 21, 2023
1 parent 8644abf commit b04ed76
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Includes/Overlays/GenericPlugin.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,25 @@ Class GenericPlugin {
}

Static DetectPlugin() {
ReaHotkey.AutoFocusPluginOverlay := False
If FindImage("Images/Engine/Engine.png", GetPluginXCoordinate(), GetPluginYCoordinate()) Is Array {
If ReaHotkey.FoundPlugin Is Plugin And ReaHotkey.FoundPlugin.Name != "Engine"
GenericPlugin.Load(ReaHotkey.FoundPlugin.InstanceNumber, "Engine", ReaHotkey.FoundPlugin.ControlClass)
ReaHotkey.FoundPlugin := GenericPlugin.Load(ReaHotkey.FoundPlugin.InstanceNumber, "Engine", ReaHotkey.FoundPlugin.ControlClass)
}
Else {
If ReaHotkey.FoundPlugin Is Plugin And ReaHotkey.FoundPlugin.Name != "Generic Plug-in"
GenericPlugin.Unload(ReaHotkey.FoundPlugin.InstanceNumber)
ReaHotkey.FoundPlugin := GenericPlugin.Unload(ReaHotkey.FoundPlugin.InstanceNumber)
}
}

Static Load(InstanceNumber, PluginName, ControlClass) {
If Plugin.FindName(PluginName) > 0 {
ReaHotkey.TurnPluginTimersOff("Generic Plug-in")
GenericPlugin.OverridePluginInstance(InstanceNumber, Plugin.Instantiate(PluginName, ControlClass))
NewInstance := GenericPlugin.OverridePluginInstance(InstanceNumber, Plugin.Instantiate(PluginName, ControlClass))
ReaHotkey.TurnPluginTimersOn(PluginName)
Return True
If NewInstance Is Plugin
NewInstance.Overlay.Focus()
Return NewInstance
}
Return False
}
Expand All @@ -56,12 +59,12 @@ Class GenericPlugin {
If NewInstance Is Plugin {
For InstanceIndex, PluginInstance In Plugin.Instances
If PluginInstance Is Plugin And PluginInstance.InstanceNumber = InstanceNumber {
NewInstance := NewInstance.Clone()
NewInstance := NewInstance.Clone()
NewInstance.InstanceNumber := InstanceNumber
NewInstance.PluginNumber := PluginInstance.PluginNumber
Plugin.Instances[InstanceIndex] := NewInstance
GenericPlugin.AddTimers(NewInstance.Name)
Return True
Return NewInstance
}
}
Return False
Expand All @@ -77,8 +80,7 @@ Class GenericPlugin {
NewInstance := Plugin("Generic Plug-in", PluginInstance.ControlClass)
NewInstance.InstanceNumber := InstanceNumber
Plugin.Instances[InstanceIndex] := NewInstance
ReaHotkey.FoundPlugin := NewInstance
Return True
Return NewInstance
}
Return False
}
Expand Down

0 comments on commit b04ed76

Please sign in to comment.