-
-
Save mooman219/e3208a335091c0941ea840170f9dafc4 to your computer and use it in GitHub Desktop.
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
From 5dd72f6282eb8cdea970398111a584a70392197c Mon Sep 17 00:00:00 2001 | |
From: mooman219 <mooman219@gmail.com> | |
Date: Sun, 16 Oct 2022 21:21:36 -0700 | |
Subject: [PATCH] Button forwarding | |
--- | |
.vscode/settings.json | 3 +++ | |
Clique.lua | 7 +++++-- | |
Utils.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ | |
3 files changed, 51 insertions(+), 2 deletions(-) | |
create mode 100644 .vscode/settings.json | |
diff --git a/.vscode/settings.json b/.vscode/settings.json | |
new file mode 100644 | |
index 0000000..9792498 | |
--- /dev/null | |
+++ b/.vscode/settings.json | |
@@ -0,0 +1,3 @@ | |
+{ | |
+ "editor.formatOnSave": false | |
+} | |
\ No newline at end of file | |
diff --git a/Clique.lua b/Clique.lua | |
index 7e412f2..536f1dc 100644 | |
--- a/Clique.lua | |
+++ b/Clique.lua | |
@@ -211,6 +211,7 @@ function addon:Initialize() | |
end | |
self:RegisterEvent("PLAYER_ENTERING_WORLD", "PlayerEnteringWorld") | |
+ self:RegisterEvent("ACTIONBAR_SLOT_CHANGED", "OnButtonsChanged") | |
-- Register for Clique-based messages for settings updates, etc. | |
self:RegisterMessage("BINDINGS_CHANGED") | |
@@ -549,14 +550,16 @@ function addon:GetClickAttributes(global) | |
rembits[#rembits + 1] = REMATTR(prefix, "type", suffix) | |
rembits[#rembits + 1] = REMATTR(prefix, "spell", suffix) | |
elseif entry.type == "macro" and self.settings.stopcastingfix then | |
- local macrotext = string.format("/click %s\n%s", self.stopbutton.name, entry.macrotext) | |
+ local macrotext = addon:ParseExtendedMacro(entry.macrotext); | |
+ macrotext = string.format("/click %s\n%s", self.stopbutton.name, macrotext) | |
bits[#bits + 1] = ATTR(indent, prefix, "type", suffix, entry.type) | |
bits[#bits + 1] = ATTR(indent, prefix, "macrotext", suffix, macrotext) | |
rembits[#rembits + 1] = REMATTR(prefix, "type", suffix) | |
rembits[#rembits + 1] = REMATTR(prefix, "macrotext", suffix) | |
elseif entry.type == "macro" then | |
+ local macrotext = addon:ParseExtendedMacro(entry.macrotext); | |
bits[#bits + 1] = ATTR(indent, prefix, "type", suffix, entry.type) | |
- bits[#bits + 1] = ATTR(indent, prefix, "macrotext", suffix, entry.macrotext) | |
+ bits[#bits + 1] = ATTR(indent, prefix, "macrotext", suffix, macrotext) | |
rembits[#rembits + 1] = REMATTR(prefix, "type", suffix) | |
rembits[#rembits + 1] = REMATTR(prefix, "macrotext", suffix) | |
else | |
diff --git a/Utils.lua b/Utils.lua | |
index 59e913e..24d67f0 100644 | |
--- a/Utils.lua | |
+++ b/Utils.lua | |
@@ -337,3 +337,46 @@ function addon:GetBindingPrefixSuffix(binding, global) | |
return prefix, suffix | |
end | |
+ | |
+function addon:ParseExtendedMacro(macrotext) | |
+ if string.sub(macrotext, 1, 1) ~= "!" then | |
+ return macrotext; | |
+ end | |
+ local buttonName = string.sub(macrotext, 2, string.len(macrotext)); | |
+ | |
+ local button = _G[buttonName] | |
+ if (button == nil) then | |
+ local exception = string.format("Unable to find button %s", buttonName); | |
+ return string.format("/run print(\"%s\")", exception); | |
+ end | |
+ | |
+ local slot = button:GetAttribute('action'); | |
+ local actionType, actionId, _ = GetActionInfo(slot); | |
+ if (actionType == "spell") then | |
+ -- Use spells | |
+ local spellName, spellSubName, _ = GetSpellInfo(actionId); | |
+ if spellSubName then | |
+ spellName = string.format("%s(%s)", spellName, spellSubName); | |
+ end | |
+ return string.format("/use [@mouseover]%s", spellName); | |
+ elseif (actionType == "item") then | |
+ -- Use items | |
+ local itemName, _ = GetItemInfo(actionId); | |
+ return string.format("/use [@mouseover]%s", itemName); | |
+ elseif(actionType == nil) then | |
+ -- Handle buttons with nothing assigned to them | |
+ local exception = string.format("Nothing is assigned to %s", buttonName); | |
+ return string.format("/run print(\"%s\")", exception); | |
+ else | |
+ -- Click all other buttons | |
+ return string.format("/click %s", buttonName); | |
+ end | |
+end | |
+ | |
+function addon:OnButtonsChanged() | |
+ if InCombatLockdown() == false then | |
+ addon:ClearAttributes(); | |
+ addon:UpdateAttributes(); | |
+ addon:ApplyAttributes(); | |
+ end | |
+end | |
\ No newline at end of file | |
-- | |
2.27.0.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment