Skip to content

Commit

Permalink
Fix #4: Anchor to other frames
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian committed Aug 14, 2024
1 parent 9cdf833 commit b907e54
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions ConfigOptions.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
local ConfigOptions = {}

-- Enumerate available frames to anchor to
local function EnumerateFrames()
local frames = {}
local framesToCheck = {
["UIParent"] = "UIParent",
["PlayerFrame"] = "PlayerFrame",
["Minimap"] = "Minimap",
["MainMenuBarBackpackButton"] = "BagBar"
}
for f, s in pairs(framesToCheck) do
if _G[f] then
frames[f] = s
end
end
return frames
end

G_RLF.defaults = {
profile = {},
global = {
relativePoint = "UIParent",
anchorPoint = "BOTTOMLEFT",
xOffset = 720,
yOffset = 375,
Expand Down Expand Up @@ -53,6 +71,15 @@ G_RLF.options = {
name = "Positioning",
order = 1
},
relativeTo = {
type = "select",
name = "Anchor Relative To",
desc = "Select a frame to anchor the loot feed to",
get = "GetRelativeTo",
set = "SetRelativeTo",
values = EnumerateFrames(),
order = 1.1
},
anchorPoint = {
type = "select",
name = "Anchor Point",
Expand Down Expand Up @@ -185,6 +212,15 @@ G_RLF.options = {
}
}

function ConfigOptions:SetRelativeTo(info, value)
G_RLF.db.global.relativePoint = value
G_RLF.LootDisplay:UpdatePosition()
end

function ConfigOptions:GetRelativeTo(info)
return G_RLF.db.global.relativePoint
end

function ConfigOptions:SetRelativePosition(info, value)
G_RLF.db.global.anchorPoint = value
G_RLF.LootDisplay:UpdatePosition()
Expand Down
4 changes: 2 additions & 2 deletions LootDisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function LootDisplay:Initialize()

frame = CreateFrame("Frame", "LootDisplayFrame", UIParent)
frame:SetSize(config.feedWidth, getFrameHeight())
frame:SetPoint(config.anchorPoint, UIParent, config.xOffset, config.yOffset)
frame:SetPoint(config.anchorPoint, _G[config.relativePoint], config.xOffset, config.yOffset)

frame:SetClipsChildren(true) -- Enable clipping of child elements

Expand All @@ -72,7 +72,7 @@ end

function LootDisplay:UpdatePosition()
frame:ClearAllPoints()
frame:SetPoint(config.anchorPoint, config.relativePoint, config.xOffset, config.yOffset)
frame:SetPoint(config.anchorPoint, _G[config.relativePoint], config.xOffset, config.yOffset)
end

function LootDisplay:UpdateRowStyles()
Expand Down

0 comments on commit b907e54

Please sign in to comment.