Make Extras ClassicAPI-first
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
local hooksecurefunc = ShaguTweaks.hooksecurefunc
|
local hooksecurefunc = ShaguTweaks.hooksecurefunc
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
@@ -26,8 +26,7 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function ShiftDown()
|
local function ShiftDown()
|
||||||
if API.IsShiftKeyDown then return API.IsShiftKeyDown() end
|
return API.IsShiftKeyDown()
|
||||||
return IsShiftKeyDown()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Interception is intentional here: the feature must be able to suppress the
|
-- Interception is intentional here: the feature must be able to suppress the
|
||||||
@@ -44,7 +43,7 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
elseif IsAuctionBrowsing() and not ShiftDown() then
|
elseif IsAuctionBrowsing() and not ShiftDown() then
|
||||||
-- search item in auction house
|
-- search item in auction house
|
||||||
local link = GetContainerItemLink(bag, slot)
|
local link = API.GetContainerItemLink(bag, slot)
|
||||||
local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or ""
|
local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or ""
|
||||||
BrowseName:SetText(name)
|
BrowseName:SetText(name)
|
||||||
AuctionFrameBrowse_Search()
|
AuctionFrameBrowse_Search()
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Bag Search Bar"],
|
title = T["Bag Search Bar"],
|
||||||
@@ -52,13 +52,13 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function GetContainerItemName(bag, slot)
|
local function GetContainerItemName(bag, slot)
|
||||||
if API.GetContainerItemID and API.GetItemNameByID then
|
local itemID = API.GetContainerItemID(bag, slot)
|
||||||
local itemID = API.GetContainerItemID(bag, slot)
|
local name = itemID and API.GetItemNameByID(itemID)
|
||||||
local name = itemID and API.GetItemNameByID(itemID)
|
if name then return name end
|
||||||
if name then return name end
|
|
||||||
end
|
|
||||||
|
|
||||||
local link = GetContainerItemLink(bag, slot)
|
-- The bridge uses C_Container.GetContainerItemInfo().hyperlink first and
|
||||||
|
-- falls back to Vanilla only when ClassicAPI cannot provide the link.
|
||||||
|
local link = API.GetContainerItemLink(bag, slot)
|
||||||
if not link then return "" end
|
if not link then return "" end
|
||||||
|
|
||||||
local startPos = string.find(link, "%[")
|
local startPos = string.find(link, "%[")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
local libspell = ShaguTweaks.libspell
|
local libspell = ShaguTweaks.libspell
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
@@ -27,12 +27,10 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function GetMacroData(actionSlot, cache)
|
local function GetMacroData(actionSlot, cache)
|
||||||
if API.GetActionInfo then
|
local actionType, id = API.GetActionInfo(actionSlot)
|
||||||
local actionType, id = API.GetActionInfo(actionSlot)
|
if actionType == "macro" and id then
|
||||||
if actionType == "macro" and id then
|
local _, _, body = GetMacroInfo(id)
|
||||||
local _, _, body = GetMacroInfo(id)
|
if body then return id, body end
|
||||||
if body then return id, body end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local macroName = GetActionText(actionSlot)
|
local macroName = GetActionText(actionSlot)
|
||||||
@@ -83,8 +81,8 @@ module.enable = function(self)
|
|||||||
-- ClassicAPI already resolves and caches the macro's primary spell.
|
-- ClassicAPI already resolves and caches the macro's primary spell.
|
||||||
-- This is the correct modern behavior for a bare "#showtooltip" line and
|
-- This is the correct modern behavior for a bare "#showtooltip" line and
|
||||||
-- also covers /castsequence, CastSpellByName and CastSpellNoToggle.
|
-- also covers /castsequence, CastSpellByName and CastSpellNoToggle.
|
||||||
if macroSlot and type(_G.GetMacroSpell) == "function" then
|
if macroSlot then
|
||||||
local spell, rank = _G.GetMacroSpell(macroSlot)
|
local spell, rank = API.GetMacroSpell(macroSlot)
|
||||||
if spell then
|
if spell then
|
||||||
return spell, rank ~= "" and rank or nil
|
return spell, rank ~= "" and rank or nil
|
||||||
end
|
end
|
||||||
|
|||||||
+12
-22
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Macro Tweaks"],
|
title = T["Macro Tweaks"],
|
||||||
@@ -57,16 +57,14 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function GetBagItemName(bag, slot)
|
local function GetBagItemName(bag, slot)
|
||||||
if API.GetContainerItemID and API.GetItemNameByID then
|
local itemID = API.GetContainerItemID(bag, slot)
|
||||||
local itemID = API.GetContainerItemID(bag, slot)
|
local name = itemID and API.GetItemNameByID(itemID)
|
||||||
local name = itemID and API.GetItemNameByID(itemID)
|
if name then return name end
|
||||||
if name then return name end
|
|
||||||
end
|
|
||||||
|
|
||||||
local itemLink = GetContainerItemLink(bag, slot)
|
local itemLink = API.GetContainerItemLink(bag, slot)
|
||||||
if not itemLink then return end
|
local linkedID = itemLink and API.GetItemIDFromLink(itemLink)
|
||||||
local _, _, itemID = string.find(itemLink, "item:(%d+)")
|
local itemName = linkedID and API.GetItemInfo(linkedID)
|
||||||
return itemID and GetItemInfo(itemID) or nil
|
return itemName
|
||||||
end
|
end
|
||||||
|
|
||||||
local function FindItem(item)
|
local function FindItem(item)
|
||||||
@@ -114,27 +112,19 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
RegisterSlashAlias("SHAGUTWEAKS_STARTATTACK", "/startattack", function(msg)
|
RegisterSlashAlias("SHAGUTWEAKS_STARTATTACK", "/startattack", function(msg)
|
||||||
if type(_G.StartAttack) == "function" then
|
API.StartAttack(TrimUnit(msg))
|
||||||
_G.StartAttack(TrimUnit(msg))
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterSlashAlias("SHAGUTWEAKS_STOPATTACK", "/stopattack", function()
|
RegisterSlashAlias("SHAGUTWEAKS_STOPATTACK", "/stopattack", function()
|
||||||
if type(_G.StopAttack) == "function" then
|
API.StopAttack()
|
||||||
_G.StopAttack()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterSlashAlias("SHAGUTWEAKS_FOCUS", "/focus", function(msg)
|
RegisterSlashAlias("SHAGUTWEAKS_FOCUS", "/focus", function(msg)
|
||||||
if type(_G.FocusUnit) == "function" then
|
API.FocusUnit(TrimUnit(msg))
|
||||||
_G.FocusUnit(TrimUnit(msg))
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterSlashAlias("SHAGUTWEAKS_CLEARFOCUS", "/clearfocus", function()
|
RegisterSlashAlias("SHAGUTWEAKS_CLEARFOCUS", "/clearfocus", function()
|
||||||
if type(_G.ClearFocus) == "function" then
|
API.ClearFocus()
|
||||||
_G.ClearFocus()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function EquipOrUse(msg)
|
local function EquipOrUse(msg)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Show Dispel Indicators"],
|
title = T["Show Dispel Indicators"],
|
||||||
@@ -71,15 +71,7 @@ module.enable = function(self)
|
|||||||
for dtype in pairs(debuffs) do frame.affected[dtype] = nil end
|
for dtype in pairs(debuffs) do frame.affected[dtype] = nil end
|
||||||
|
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
local dtype
|
local dtype = API.GetDebuffType(frame.unitstr, i)
|
||||||
if API.aurapositional and API.UnitDebuff then
|
|
||||||
local _, _, _, debuffType = API.UnitDebuff(frame.unitstr, i)
|
|
||||||
dtype = debuffType
|
|
||||||
else
|
|
||||||
local _, _, debuffType = UnitDebuff(frame.unitstr, i)
|
|
||||||
dtype = debuffType
|
|
||||||
end
|
|
||||||
|
|
||||||
if dtype then frame.affected[dtype] = true end
|
if dtype then frame.affected[dtype] = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+6
-15
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Enable Raid Frames"],
|
title = T["Enable Raid Frames"],
|
||||||
@@ -72,19 +72,10 @@ end
|
|||||||
local UnitInRange = function(unitstr)
|
local UnitInRange = function(unitstr)
|
||||||
if not unitstr then return false end
|
if not unitstr then return false end
|
||||||
|
|
||||||
-- Prefer positional range data whenever the client exposes UnitPosition
|
-- ClassicAPI provides a reach-aware 40-yard range check. Any compatibility
|
||||||
-- (SuperWoW or another compatibility layer), then fall back to Vanilla.
|
-- fallback is centralized in ShaguTweaks.API rather than duplicated here.
|
||||||
if type(UnitPosition) == "function" then
|
local inRange, checked = API.UnitInRange(unitstr)
|
||||||
local x1, y1, z1 = UnitPosition("player")
|
return checked and inRange or false
|
||||||
local x2, y2, z2 = UnitPosition(unitstr)
|
|
||||||
|
|
||||||
if x1 and y1 and z1 and x2 and y2 and z2 then
|
|
||||||
local distance = ((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)^.5
|
|
||||||
if distance < 40 then return true end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return CheckInteractDistance(unitstr, 4) and true or false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Unit Frames
|
-- Unit Frames
|
||||||
@@ -610,7 +601,7 @@ module.enable = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
raid.toggle:SetScript("OnMouseDown", function()
|
raid.toggle:SetScript("OnMouseDown", function()
|
||||||
local shift = API.IsShiftKeyDown and API.IsShiftKeyDown() or IsShiftKeyDown()
|
local shift = API.IsShiftKeyDown()
|
||||||
if shift then
|
if shift then
|
||||||
this.dragging = true
|
this.dragging = true
|
||||||
this:SetScript("OnUpdate", UpdateToggleDrag)
|
this:SetScript("OnUpdate", UpdateToggleDrag)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Show Bags"],
|
title = T["Show Bags"],
|
||||||
@@ -58,8 +58,8 @@ module.enable = function(self)
|
|||||||
bagframe:RegisterEvent("PLAYER_ENTERING_WORLD")
|
bagframe:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
|
||||||
bagframe:SetScript("OnDragStart", function()
|
bagframe:SetScript("OnDragStart", function()
|
||||||
local shift = API.IsShiftKeyDown and API.IsShiftKeyDown() or IsShiftKeyDown()
|
local shift = API.IsShiftKeyDown()
|
||||||
local control = API.IsControlKeyDown and API.IsControlKeyDown() or IsControlKeyDown()
|
local control = API.IsControlKeyDown()
|
||||||
if not shift or not control then return end
|
if not shift or not control then return end
|
||||||
this:StartMoving()
|
this:StartMoving()
|
||||||
end)
|
end)
|
||||||
@@ -73,8 +73,8 @@ module.enable = function(self)
|
|||||||
if this.modifierTimer < .05 then return end
|
if this.modifierTimer < .05 then return end
|
||||||
this.modifierTimer = 0
|
this.modifierTimer = 0
|
||||||
|
|
||||||
local shift = API.IsShiftKeyDown and API.IsShiftKeyDown() or IsShiftKeyDown()
|
local shift = API.IsShiftKeyDown()
|
||||||
local control = API.IsControlKeyDown and API.IsControlKeyDown() or IsControlKeyDown()
|
local control = API.IsControlKeyDown()
|
||||||
if MouseIsOver(this) and shift and control then
|
if MouseIsOver(this) and shift and control then
|
||||||
if not this.mousedisabled then
|
if not this.mousedisabled then
|
||||||
-- disable mouse events on all frames
|
-- disable mouse events on all frames
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _G = ShaguTweaks.GetGlobalEnv()
|
local _G = ShaguTweaks.GetGlobalEnv()
|
||||||
local T = ShaguTweaks.T
|
local T = ShaguTweaks.T
|
||||||
local API = ShaguTweaks.API or {}
|
local API = ShaguTweaks.API
|
||||||
|
|
||||||
local module = ShaguTweaks:register({
|
local module = ShaguTweaks:register({
|
||||||
title = T["Show Micro Menu"],
|
title = T["Show Micro Menu"],
|
||||||
@@ -59,8 +59,8 @@ module.enable = function(self)
|
|||||||
microframe:RegisterEvent("PLAYER_ENTERING_WORLD")
|
microframe:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
|
|
||||||
microframe:SetScript("OnDragStart", function()
|
microframe:SetScript("OnDragStart", function()
|
||||||
local shift = API.IsShiftKeyDown and API.IsShiftKeyDown() or IsShiftKeyDown()
|
local shift = API.IsShiftKeyDown()
|
||||||
local control = API.IsControlKeyDown and API.IsControlKeyDown() or IsControlKeyDown()
|
local control = API.IsControlKeyDown()
|
||||||
if not shift or not control then return end
|
if not shift or not control then return end
|
||||||
this:StartMoving()
|
this:StartMoving()
|
||||||
end)
|
end)
|
||||||
@@ -74,8 +74,8 @@ module.enable = function(self)
|
|||||||
if this.modifierTimer < .05 then return end
|
if this.modifierTimer < .05 then return end
|
||||||
this.modifierTimer = 0
|
this.modifierTimer = 0
|
||||||
|
|
||||||
local shift = API.IsShiftKeyDown and API.IsShiftKeyDown() or IsShiftKeyDown()
|
local shift = API.IsShiftKeyDown()
|
||||||
local control = API.IsControlKeyDown and API.IsControlKeyDown() or IsControlKeyDown()
|
local control = API.IsControlKeyDown()
|
||||||
if MouseIsOver(this) and shift and control then
|
if MouseIsOver(this) and shift and control then
|
||||||
if not this.mousedisabled then
|
if not this.mousedisabled then
|
||||||
-- disable mouse events on all frames
|
-- disable mouse events on all frames
|
||||||
|
|||||||
Reference in New Issue
Block a user