Skip to content

Commit

Permalink
reuse Frames
Browse files Browse the repository at this point in the history
  • Loading branch information
ollidiemaus authored Oct 6, 2023
1 parent 95a114f commit ebeffbb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AutoPotion.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 100107
## Interface-Classic: 11404
## Interface-WOTLKC: 30402
## Version: 3.2.0
## Version: 3.2.1
## Title: Auto Potion
## Author: ollidiemaus
## Notes: Updates the Macro AutoPotion to use either Healthstone or the highest Potion found in Bags
Expand Down
74 changes: 59 additions & 15 deletions FrameXML/InterfaceOptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ local PADDING_HORIZONTAL = 200
local PADDING_PRIO_CATEGORY = 130
local classButtons = {}
local prioFrames = {}
local prioTextures = {}
local prioFramesCounter = 0
local firstIcon = nil
local positionx = 0
local currentPrioTitle = nil

function panel:OnEvent(event, addOnName)
Expand Down Expand Up @@ -55,33 +58,74 @@ local function createPrioFrame(parentPanel, id, iconTexture, positionx, isSpell)
icon:SetPoint("TOPLEFT", firstIcon, positionx, 0)
end
icon:Show()
table.insert(prioFrames, icon)
table.insert(prioTextures, texture)
prioFramesCounter = prioFramesCounter + 1
return icon
end

local function updatePrio(parentPanel)
if next(prioFrames) ~= nil then
--remove drawn frames
for i, frame in pairs(prioFrames) do
frame:Hide()
end
end
ham.updateHeals()
local positionx = 0
local spellCounter = 0
local itemCounter = 0

for i, frame in pairs(prioFrames) do
frame:Hide()
end

if next(ham.spellIDs) ~= nil then
for i, id in ipairs(ham.spellIDs) do
local name, rank, iconTexture, castTime, minRange, maxRange = GetSpellInfo(id)
local icon = createPrioFrame(parentPanel, id, iconTexture, positionx, true)
table.insert(prioFrames, icon)
positionx = positionx + (ICON_SIZE + (ICON_SIZE / 2))
local currentFrame = prioFrames[i]
local currentTexture = prioTextures[i]
if currentFrame ~= nil then
currentFrame:SetScript("OnEnter", nil)
currentFrame:SetScript("OnLeave", nil)
currentFrame:HookScript("OnEnter", function(_, btn, down)
GameTooltip:SetOwner(currentFrame, "ANCHOR_TOPRIGHT")
GameTooltip:SetSpellByID(id)
GameTooltip:Show()
end)
currentFrame:HookScript("OnLeave", function(_, btn, down)
GameTooltip:Hide()
end)
currentTexture:SetTexture(iconTexture)
currentTexture:SetAllPoints(currentFrame)
currentFrame.texture = currentTexture
currentFrame:Show()
else
createPrioFrame(parentPanel, id, iconTexture, positionx, true)
positionx = positionx + (ICON_SIZE + (ICON_SIZE / 2))
end
spellCounter = spellCounter + 1
end
end
if next(ham.itemIdList) ~= nil then
for i, id in ipairs(ham.itemIdList) do
local itemID, itemType, itemSubType, itemEquipLoc, iconTexture, classID, subclassID = GetItemInfoInstant(
id)
local icon = createPrioFrame(parentPanel, id, iconTexture, positionx, false)
table.insert(prioFrames, icon)
positionx = positionx + (ICON_SIZE + (ICON_SIZE / 2))
local itemID, itemType, itemSubType, itemEquipLoc, iconTexture, classID, subclassID = GetItemInfoInstant(id)
local currentFrame = prioFrames[i + spellCounter]
local currentTexture = prioTextures[i + spellCounter]

if currentFrame ~= nil then
currentFrame:SetScript("OnEnter", nil)
currentFrame:SetScript("OnLeave", nil)
currentFrame:HookScript("OnEnter", function(_, btn, down)
GameTooltip:SetOwner(currentFrame, "ANCHOR_TOPRIGHT")
GameTooltip:SetItemByID(id)
GameTooltip:Show()
end)
currentFrame:HookScript("OnLeave", function(_, btn, down)
GameTooltip:Hide()
end)
currentTexture:SetTexture(iconTexture)
currentTexture:SetAllPoints(currentFrame)
currentFrame.texture = currentTexture
currentFrame:Show()
else
createPrioFrame(parentPanel, id, iconTexture, positionx, false)
positionx = positionx + (ICON_SIZE + (ICON_SIZE / 2))
end
itemCounter = itemCounter + 1
end
end
end
Expand Down

0 comments on commit ebeffbb

Please sign in to comment.