Update LibDBIcon

This commit is contained in:
Robin Hüskes 2022-12-03 17:20:17 +01:00
parent fdd8d7edc3
commit 8ed23ca329
1 changed files with 38 additions and 26 deletions

View File

@ -1,4 +1,4 @@
--@curseforge-project-slug: libdbicon-1-0@
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- LibDBIcon-1.0 -- LibDBIcon-1.0
-- --
@ -6,7 +6,7 @@
-- --
local DBICON10 = "LibDBIcon-1.0" local DBICON10 = "LibDBIcon-1.0"
local DBICON10_MINOR = 44 -- Bump on changes local DBICON10_MINOR = 45 -- Bump on changes
if not LibStub then error(DBICON10 .. " requires LibStub.") end if not LibStub then error(DBICON10 .. " requires LibStub.") end
local ldb = LibStub("LibDataBroker-1.1", true) local ldb = LibStub("LibDataBroker-1.1", true)
if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end
@ -218,37 +218,49 @@ local function createButton(name, object, db)
button.dataObject = object button.dataObject = object
button.db = db button.db = db
button:SetFrameStrata("MEDIUM") button:SetFrameStrata("MEDIUM")
if button.SetFixedFrameStrata then -- Classic support button:SetFixedFrameStrata(true)
button:SetFixedFrameStrata(true)
end
button:SetFrameLevel(8) button:SetFrameLevel(8)
if button.SetFixedFrameLevel then -- Classic support button:SetFixedFrameLevel(true)
button:SetFixedFrameLevel(true)
end
button:SetSize(31, 31) button:SetSize(31, 31)
button:RegisterForClicks("anyUp") button:RegisterForClicks("anyUp")
button:RegisterForDrag("LeftButton") button:RegisterForDrag("LeftButton")
button:SetHighlightTexture(136477) --"Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" button:SetHighlightTexture(136477) --"Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight"
local overlay = button:CreateTexture(nil, "OVERLAY") if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
overlay:SetSize(53, 53) local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder" overlay:SetSize(50, 50)
overlay:SetPoint("TOPLEFT") overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
local background = button:CreateTexture(nil, "BACKGROUND") overlay:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
background:SetSize(20, 20) local background = button:CreateTexture(nil, "BACKGROUND")
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background" background:SetSize(24, 24)
background:SetPoint("TOPLEFT", 7, -5) background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
local icon = button:CreateTexture(nil, "ARTWORK") background:SetPoint("CENTER", button, "CENTER", 0, 1)
icon:SetSize(17, 17) local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetTexture(object.icon) icon:SetSize(18, 18)
icon:SetPoint("TOPLEFT", 7, -6) icon:SetTexture(object.icon)
button.icon = icon icon:SetPoint("CENTER", button, "CENTER", 0, 1)
button.icon = icon
else
local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetSize(53, 53)
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
overlay:SetPoint("TOPLEFT")
local background = button:CreateTexture(nil, "BACKGROUND")
background:SetSize(20, 20)
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
background:SetPoint("TOPLEFT", 7, -5)
local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetSize(17, 17)
icon:SetTexture(object.icon)
icon:SetPoint("TOPLEFT", 7, -6)
button.icon = icon
end
button.isMouseDown = false button.isMouseDown = false
local r, g, b = button.icon:GetVertexColor()
button.icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b)
local r, g, b = icon:GetVertexColor() button.icon.UpdateCoord = updateCoord
icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b) button.icon:UpdateCoord()
icon.UpdateCoord = updateCoord
icon:UpdateCoord()
button:SetScript("OnEnter", onEnter) button:SetScript("OnEnter", onEnter)
button:SetScript("OnLeave", onLeave) button:SetScript("OnLeave", onLeave)