libtipscan: add new tooltip scanning library

This commit is contained in:
Road-block
2018-07-31 21:23:01 +02:00
committed by shagu
parent 1cebe52e29
commit 44ffb10024
14 changed files with 260 additions and 110 deletions
+8 -16
View File
@@ -72,8 +72,7 @@ pfUI:RegisterModule("actionbar", function ()
-- reagent counter
local reagentslots = { }
local reagentscan = CreateFrame("GameTooltip", "pfReagentScanner", UIParent, "GameTooltipTemplate")
reagentscan:SetOwner(UIParent, "ANCHOR_NONE")
local scanner = libtipscan:GetScanner("actionbar")
hooksecurefunc("ActionButton_OnEvent", function()
if event == "BAG_UPDATE" and arg1 < 5 then
@@ -81,25 +80,18 @@ pfUI:RegisterModule("actionbar", function ()
end
end)
local reagent_capture = SPELL_REAGENTS.."(.+)"
local oldIsConsumableAction = IsConsumableAction
_G.IsConsumableAction = function(slot)
if oldIsConsumableAction(slot) then return true end
if this and this.GetParent and ActionButton_GetPagedID(this) == slot then
reagentslots[slot] = nil
reagentscan:SetAction(slot)
if (reagentscan:NumLines() ~=0) then
for i=1,reagentscan:NumLines() do
local line = getglobal("pfReagentScannerTextLeft" .. i)
if line then
line = line:GetText()
local _, start = strfind(line,SPELL_REAGENTS,1)
if start then
reagentslots[slot] = strsub(line,start+1)
this:RegisterEvent("BAG_UPDATE")
return true
end
end
end
scanner:SetAction(slot)
local _, reagents = scanner:Find(reagent_capture)
if reagents then
reagentslots[slot] = reagents
this:RegisterEvent("BAG_UPDATE")
return true
end
this:UnregisterEvent("BAG_UPDATE")
+4 -5
View File
@@ -1,18 +1,17 @@
pfUI:RegisterModule("feigndeath", function ()
local cache = { }
local healthscan = CreateFrame("GameTooltip", "pfHpScanner", UIParent, "GameTooltipTemplate")
healthscan:SetOwner(healthscan,"ANCHOR_NONE")
local healthbar = healthscan:GetChildren()
local scanner = libtipscan:GetScanner("feigndeath")
local healthbar = scanner:GetChildren()
local cache_update = CreateFrame("Frame")
cache_update:RegisterEvent("UNIT_HEALTH")
cache_update:RegisterEvent("PLAYER_TARGET_CHANGED")
cache_update:SetScript("OnEvent", function()
if event == "PLAYER_TARGET_CHANGED" and UnitIsDead("target") then
healthscan:SetUnit("target")
scanner:SetUnit("target")
cache[UnitName("target")] = healthbar:GetValue()
elseif event == "UNIT_HEALTH" and UnitIsDead(arg1) and UnitName(arg1) then
healthscan:SetUnit(arg1)
scanner:SetUnit(arg1)
cache[UnitName(arg1)] = healthbar:GetValue()
elseif event == "UNIT_HEALTH" and UnitName(arg1) then
cache[UnitName(arg1)] = nil
+6 -7
View File
@@ -3,8 +3,7 @@ pfUI:RegisterModule("hunterbar", function ()
if class ~= "HUNTER" or C.bars.hunterbar == "0" then return end
pfUI.hunterbar = CreateFrame("Frame", "pfHunterBar", UIParent)
pfUI.hunterbar.scanner = CreateFrame("GameTooltip", "pfHunterBarScanner", UIParent, "GameTooltipTemplate")
pfUI.hunterbar.scanner:SetOwner(pfUI.hunterbar, "ANCHOR_NONE")
local scanner = libtipscan:GetScanner("hunterbar")
pfUI.hunterbar.melee = nil
pfUI.hunterbar.ranged = nil
@@ -19,13 +18,13 @@ pfUI:RegisterModule("hunterbar", function ()
for i=1,120 do
if pfUI.hunterbar.melee and pfUI.hunterbar.ranged then return end
pfUI.hunterbar.scanner:ClearLines()
pfUI.hunterbar.scanner:SetAction(i)
scanner:SetAction(i)
if pfHunterBarScannerTextLeft1 and pfHunterBarScannerTextLeft1:GetText() then
if pfHunterBarScannerTextLeft1:GetText() == L["hunterpaging"]["MELEE"] then
local left = scanner:Line(1)
if left then
if left == L["hunterpaging"]["MELEE"] then
pfUI.hunterbar.melee = i
elseif pfHunterBarScannerTextLeft1:GetText() == L["hunterpaging"]["RANGED"] then
elseif left == L["hunterpaging"]["RANGED"] then
pfUI.hunterbar.ranged = i
end
end
-9
View File
@@ -586,15 +586,6 @@ pfUI:RegisterModule("nameplates", function ()
end
end
-- debuff detection
local pfNameplateDebuffNameScan = CreateFrame('GameTooltip', "pfNameplateDebuffNameScan", UIParent, "GameTooltipTemplate")
local function GetDebuffName(unit, index)
pfNameplateDebuffNameScan:SetOwner(UIParent, "ANCHOR_NONE")
pfNameplateDebuffNameScan:SetUnitDebuff(unit, index)
local text = getglobal("pfNameplateDebuffNameScanTextLeft1")
return ( text ) and text:GetText() or ""
end
pfUI.nameplates:RegisterEvent("PLAYER_TARGET_CHANGED")
pfUI.nameplates:RegisterEvent("UNIT_AURA")
pfUI.nameplates:SetScript("OnEvent", function()
+12 -23
View File
@@ -318,7 +318,8 @@ pfUI:RegisterModule("panel", function()
widget.slotnames = { "Head", "Shoulder", "Chest", "Wrist",
"Hands", "Waist", "Legs", "Feet", "MainHand", "SecondaryHand", "Ranged", }
widget.totalRep = 0
widget.scantip = CreateFrame('GameTooltip', "pfRepairToolTip", this, "GameTooltipTemplate")
widget.scantip = libtipscan:GetScanner("panel")
widget.duracapture = string.gsub(DURABILITY_TEMPLATE, "%%[^%s]+", "(.+)")
widget.Click = function() ToggleCharacter("PaperDollFrame") end
widget.Tooltip = function()
if widget.totalRep > 0 then
@@ -339,28 +340,17 @@ pfUI:RegisterModule("panel", function()
wipe(widget.itemLines)
for i,slotName in pairs(widget.slotnames) do
local id, _ = GetInventorySlotInfo(slotName.. "Slot")
pfRepairToolTip:Hide()
pfRepairToolTip:SetOwner(this, "ANCHOR_LEFT")
local hasItem, _, repCost = pfRepairToolTip:SetInventoryItem("player", id)
if (not hasItem) then
pfRepairToolTip:ClearLines()
else
local hasItem, _, repCost = widget.scantip:SetInventoryItem("player", id)
if (hasItem) then
widget.totalRep = widget.totalRep + repCost
for i=1, 32, 1 do
local tmpText = _G["pfRepairToolTipTextLeft"..i]
if (tmpText ~= nil) and (tmpText:GetText()) then
local searchstr = string.gsub(DURABILITY_TEMPLATE, "%%[^%s]+", "(.+)")
local _, _, lval, rval = string.find(tmpText:GetText(), searchstr, 1)
if (lval and rval) then
repPercent = math.floor(lval / rval * 100)
if repPercent < 100 then
local link = GetInventoryItemLink("player",id)
local r,g,b,hex = GetColorGradient(repPercent/100, 1,0,0, 1,1,0, 0,1,0) -- red to green through yellow
local cPercent = string.format("%s%s%%|r",hex,repPercent)
widget.itemLines[table.getn(widget.itemLines)+1]={link, cPercent}
end
break
end
local line, lval, rval = widget.scantip:Find(widget.duracapture)
if (lval and rval) then
repPercent = math.floor(lval / rval * 100)
if repPercent < 100 then
local link = GetInventoryItemLink("player",id)
local r,g,b,hex = GetColorGradient(repPercent/100, 1,0,0, 1,1,0, 0,1,0) -- red to green through yellow
local cPercent = string.format("%s%s%%|r",hex,repPercent)
widget.itemLines[table.getn(widget.itemLines)+1]={link, cPercent}
end
end
end
@@ -368,7 +358,6 @@ pfUI:RegisterModule("panel", function()
lowestPercent = repPercent
end
end
pfRepairToolTip:Hide()
pfUI.panel:OutputPanel("durability", lowestPercent .. "% " .. ARMOR, widget.Tooltip, widget.Click)
end)