Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Robin Hüskes | da56c18402 | |
Robin Hüskes | ff37e7abcb | |
robin | 997d689db5 | |
Gnarfoz (Christian Wissel) | 08a7819fcb | |
Robin Hüskes | 77a852053e | |
Robin Hüskes | 0d6ae08f6c | |
Robin Hüskes | 7def31f16a | |
Robin Hüskes | b459d1dcbc | |
Robin Hüskes | 4c5e36588b |
|
@ -1,5 +1,5 @@
|
||||||
--[[ $Id: CallbackHandler-1.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]
|
--[[ $Id: CallbackHandler-1.0.lua 26 2022-12-12 15:09:39Z nevcairiel $ ]]
|
||||||
local MAJOR, MINOR = "CallbackHandler-1.0", 7
|
local MAJOR, MINOR = "CallbackHandler-1.0", 8
|
||||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||||
|
|
||||||
if not CallbackHandler then return end -- No upgrade needed
|
if not CallbackHandler then return end -- No upgrade needed
|
||||||
|
@ -7,21 +7,16 @@ if not CallbackHandler then return end -- No upgrade needed
|
||||||
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
|
||||||
|
|
||||||
-- Lua APIs
|
-- Lua APIs
|
||||||
local error = error
|
local securecallfunction, error = securecallfunction, error
|
||||||
local setmetatable, rawget = setmetatable, rawget
|
local setmetatable, rawget = setmetatable, rawget
|
||||||
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
|
local next, select, pairs, type, tostring = next, select, pairs, type, tostring
|
||||||
|
|
||||||
local xpcall = xpcall
|
|
||||||
|
|
||||||
local function errorhandler(err)
|
|
||||||
return geterrorhandler()(err)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function Dispatch(handlers, ...)
|
local function Dispatch(handlers, ...)
|
||||||
local index, method = next(handlers)
|
local index, method = next(handlers)
|
||||||
if not method then return end
|
if not method then return end
|
||||||
repeat
|
repeat
|
||||||
xpcall(method, errorhandler, ...)
|
securecallfunction(method, ...)
|
||||||
index, method = next(handlers, index)
|
index, method = next(handlers, index)
|
||||||
until not method
|
until not method
|
||||||
end
|
end
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
local lib = LibStub:NewLibrary("zzAddOn", 10)
|
local lib = LibStub:NewLibrary("zzAddOn", 12)
|
||||||
if not lib then return end
|
if not lib then return end
|
||||||
local config = LibStub:GetLibrary("zzConfig")
|
local config = LibStub:GetLibrary("zzConfig")
|
||||||
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
||||||
lib['addons'] = lib['addons'] or {}
|
lib['addons'] = lib['addons'] or {}
|
||||||
|
lib['managerframe'] = lib['managerframe'] or CreateFrame("FRAME")
|
||||||
lib['events'] = lib['events'] or CreateFrame("FRAME")
|
lib['events'] = lib['events'] or CreateFrame("FRAME")
|
||||||
local function errormsg(err)
|
local function errormsg(err)
|
||||||
print(format("|cffff0000Error:|r %s",err))
|
print(format("|cffff0000Error:|r %s",err))
|
||||||
end
|
end
|
||||||
local mixins = {'NewAddOn', 'GetAddOn', 'AddChild', 'HasChild', 'IsChild', 'HasParent', 'GetParent', 'GetOptions', 'RegisterEvent','UnregisterEvent','IsClassic','IsBCC','IsRetail', 'GetSpecs', 'Fire'}
|
local mixins = {'NewAddOn', 'GetAddOn', 'AddChild', 'HasChild', 'IsChild', 'HasParent', 'GetParent', 'GetOptions', 'RegisterEvent','UnregisterEvent','IsClassic','IsBCC','IsRetail', 'GetSpecs', 'Fire', 'RegisterOpen', 'RegisterClose'}
|
||||||
function lib:Fire(...)
|
function lib:Fire(...)
|
||||||
lib['callbacks']:Fire(...)
|
lib['callbacks']:Fire(...)
|
||||||
end
|
end
|
||||||
|
@ -103,6 +104,44 @@ end
|
||||||
function lib:IsRetail()
|
function lib:IsRetail()
|
||||||
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
|
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
|
||||||
end
|
end
|
||||||
|
local function handleManagerFrame(self, event, num)
|
||||||
|
if(event == "PLAYER_INTERACTION_MANAGER_FRAME_SHOW") then
|
||||||
|
lib['callbacks']:Fire(format("show-%i", num))
|
||||||
|
else
|
||||||
|
lib['callbacks']:Fire(format("hide-%i", num))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function addManagerFrame(self, mode, num, globalfunc)
|
||||||
|
if(type(num) == 'table') then
|
||||||
|
for k, v in pairs(num) do
|
||||||
|
local n = k
|
||||||
|
local func = v
|
||||||
|
if(type(v) == 'number') then
|
||||||
|
n = v
|
||||||
|
func = globalfunc
|
||||||
|
end
|
||||||
|
addManagerFrame(self, mode, n, func)
|
||||||
|
end
|
||||||
|
elseif(type(num) == 'number') then
|
||||||
|
lib.RegisterCallback(self, format("%s-%i", mode, num), globalfunc)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function lib:RegisterOpen(num, func)
|
||||||
|
if(not num) then return end
|
||||||
|
if(not lib['managerframe']:IsEventRegistered("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")) then
|
||||||
|
lib['managerframe']:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")
|
||||||
|
lib['managerframe']:SetScript("OnEvent", handleManagerFrame)
|
||||||
|
end
|
||||||
|
addManagerFrame(self, 'show', num, func)
|
||||||
|
end
|
||||||
|
function lib:RegisterClose(num, func)
|
||||||
|
if(not num) then return end
|
||||||
|
if(not lib['managerframe']:IsEventRegistered("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")) then
|
||||||
|
lib['managerframe']:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")
|
||||||
|
lib['managerframe']:SetScript("OnEvent", handleManagerFrame)
|
||||||
|
end
|
||||||
|
addManagerFrame(self, 'hide', num, func)
|
||||||
|
end
|
||||||
function lib:NewAddOn(addonName, addonTable)
|
function lib:NewAddOn(addonName, addonTable)
|
||||||
local specs = self['specs']
|
local specs = self['specs']
|
||||||
local childName = specs['name']
|
local childName = specs['name']
|
||||||
|
|
20
core.lua
20
core.lua
|
@ -27,21 +27,19 @@ local function setPlayerCoords()
|
||||||
child['playerCoords'] = playerCoords
|
child['playerCoords'] = playerCoords
|
||||||
end
|
end
|
||||||
local colorlist = {
|
local colorlist = {
|
||||||
['friendly'] = "00ff00",
|
['arena'] = "ff1919",
|
||||||
['arena'] = "ffff00",
|
['combat'] = "ff1919",
|
||||||
['sanctuary'] = "9999ff",
|
['hostile'] = "ff1919",
|
||||||
|
['friendly'] = "19ff19",
|
||||||
|
['sanctuary'] = "68ccef",
|
||||||
|
['contested'] = "ffb200",
|
||||||
}
|
}
|
||||||
local function pvpColor(txt)
|
local function pvpColor(txt)
|
||||||
local col
|
local pvpType = GetZonePVPInfo()
|
||||||
local pvpType, isFFA, faction = GetZonePVPInfo()
|
|
||||||
if(colorlist[pvpType]) then
|
if(colorlist[pvpType]) then
|
||||||
col = colorlist[pvpType]
|
return child:colorize(txt, colorlist[pvpType])
|
||||||
elseif(pvpType == "hostile" or pvpType == "combat" or pvpType=="contested") then
|
|
||||||
col = faction == select(2,UnitFactionGroup('player')) and "886600" or "ff0000"
|
|
||||||
else
|
|
||||||
return txt
|
|
||||||
end
|
end
|
||||||
return child:colorize(txt, col)
|
return txt
|
||||||
end
|
end
|
||||||
local function OnDataUpdate()
|
local function OnDataUpdate()
|
||||||
setPlayerCoords()
|
setPlayerCoords()
|
||||||
|
|
Loading…
Reference in New Issue