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