Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
Robin Hüskes | b574c120af | |
Robin Hüskes | 63d61f708f | |
Robin Hüskes | 65d1651374 | |
Robin Hüskes | cb567af2e2 | |
Robin Hüskes | 4f8b3430d0 | |
Robin Hüskes | 6c5ab4a3b0 | |
Robin Hüskes | 9896d06a9d | |
Robin Hüskes | 9f2a53d9c9 | |
Robin Hüskes | ef1fadf665 | |
Robin Hüskes | 8032532c51 |
|
@ -1,5 +1,5 @@
|
|||
--[[ $Id: CallbackHandler-1.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 7
|
||||
--[[ $Id: CallbackHandler-1.0.lua 26 2022-12-12 15:09:39Z nevcairiel $ ]]
|
||||
local MAJOR, MINOR = "CallbackHandler-1.0", 8
|
||||
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
|
||||
|
||||
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}
|
||||
|
||||
-- Lua APIs
|
||||
local error = error
|
||||
local securecallfunction, error = securecallfunction, error
|
||||
local setmetatable, rawget = setmetatable, rawget
|
||||
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 index, method = next(handlers)
|
||||
if not method then return end
|
||||
repeat
|
||||
xpcall(method, errorhandler, ...)
|
||||
securecallfunction(method, ...)
|
||||
index, method = next(handlers, index)
|
||||
until not method
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
--@curseforge-project-slug: libdbicon-1-0@
|
||||
-----------------------------------------------------------------------
|
||||
-- LibDBIcon-1.0
|
||||
--
|
||||
|
@ -6,7 +6,7 @@
|
|||
--
|
||||
|
||||
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
|
||||
local ldb = LibStub("LibDataBroker-1.1", true)
|
||||
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.db = db
|
||||
button:SetFrameStrata("MEDIUM")
|
||||
if button.SetFixedFrameStrata then -- Classic support
|
||||
button:SetFixedFrameStrata(true)
|
||||
end
|
||||
button:SetFixedFrameStrata(true)
|
||||
button:SetFrameLevel(8)
|
||||
if button.SetFixedFrameLevel then -- Classic support
|
||||
button:SetFixedFrameLevel(true)
|
||||
end
|
||||
button:SetFixedFrameLevel(true)
|
||||
button:SetSize(31, 31)
|
||||
button:RegisterForClicks("anyUp")
|
||||
button:RegisterForDrag("LeftButton")
|
||||
button:SetHighlightTexture(136477) --"Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight"
|
||||
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
|
||||
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
|
||||
local overlay = button:CreateTexture(nil, "OVERLAY")
|
||||
overlay:SetSize(50, 50)
|
||||
overlay:SetTexture(136430) --"Interface\\Minimap\\MiniMap-TrackingBorder"
|
||||
overlay:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
|
||||
local background = button:CreateTexture(nil, "BACKGROUND")
|
||||
background:SetSize(24, 24)
|
||||
background:SetTexture(136467) --"Interface\\Minimap\\UI-Minimap-Background"
|
||||
background:SetPoint("CENTER", button, "CENTER", 0, 1)
|
||||
local icon = button:CreateTexture(nil, "ARTWORK")
|
||||
icon:SetSize(18, 18)
|
||||
icon:SetTexture(object.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
|
||||
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()
|
||||
icon:SetVertexColor(object.iconR or r, object.iconG or g, object.iconB or b)
|
||||
|
||||
icon.UpdateCoord = updateCoord
|
||||
icon:UpdateCoord()
|
||||
button.icon.UpdateCoord = updateCoord
|
||||
button.icon:UpdateCoord()
|
||||
|
||||
button:SetScript("OnEnter", onEnter)
|
||||
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
|
||||
local config = LibStub:GetLibrary("zzConfig")
|
||||
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
||||
lib['addons'] = lib['addons'] or {}
|
||||
lib['managerframe'] = lib['managerframe'] or CreateFrame("FRAME")
|
||||
lib['events'] = lib['events'] or CreateFrame("FRAME")
|
||||
local function errormsg(err)
|
||||
print(format("|cffff0000Error:|r %s",err))
|
||||
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(...)
|
||||
lib['callbacks']:Fire(...)
|
||||
end
|
||||
|
@ -103,6 +104,44 @@ end
|
|||
function lib:IsRetail()
|
||||
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
|
||||
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)
|
||||
local specs = self['specs']
|
||||
local childName = specs['name']
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local lib = LibStub:NewLibrary("zzLDB", 5)
|
||||
local lib = LibStub:NewLibrary("zzLDB", 6)
|
||||
if not lib then return end
|
||||
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
|
||||
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
|
||||
|
@ -25,7 +25,8 @@ function lib:DefaultOnClick(_, button, addon, childName)
|
|||
if(not InCombatLockdown()) then
|
||||
if(SettingsPanel) then
|
||||
if(SettingsPanel:IsVisible()) then
|
||||
SettingsPanel:Hide()
|
||||
HideUIPanel(SettingsPanel)
|
||||
HideUIPanel(GameMenuFrame)
|
||||
else
|
||||
Settings.OpenToCategory(childName)
|
||||
end
|
||||
|
|
79
broker.lua
79
broker.lua
|
@ -69,7 +69,8 @@ local function OnClick(self, button)
|
|||
if(not InCombatLockdown()) then
|
||||
if(SettingsPanel) then
|
||||
if(SettingsPanel:IsVisible()) then
|
||||
SettingsPanel:Hide()
|
||||
HideUIPanel(SettingsPanel)
|
||||
HideUIPanel(GameMenuFrame)
|
||||
else
|
||||
Settings.OpenToCategory(childName)
|
||||
end
|
||||
|
@ -114,24 +115,45 @@ end
|
|||
local function toggleColor(col,col1,col2)
|
||||
return col == col1 and col2 or col1
|
||||
end
|
||||
local function computelatency()
|
||||
return select(3,GetNetStats())
|
||||
local function compute_colorpick(name, val)
|
||||
local color = db[format('%scolor', name)]
|
||||
if(db[format('%slow', name)] and tonumber(db[format('%slow', name)]) > 0 and val <= tonumber(db[format('%slow', name)])) then
|
||||
color = db[format('%slowcolor', name)]
|
||||
end
|
||||
if(db[format('%smedium', name)] and tonumber(db[format('%smedium', name)]) > 0 and val >= tonumber(db[format('%smedium', name)])) then
|
||||
color = db[format('%smediumcolor', name)]
|
||||
end
|
||||
if(db[format('%shigh', name)] and tonumber(db[format('%shigh', name)]) > 0 and val >= tonumber(db[format('%shigh', name)])) then
|
||||
color = db[format('%shighcolor', name)]
|
||||
end
|
||||
return color
|
||||
end
|
||||
local function compute()
|
||||
local c = date(db['clockstring'])
|
||||
local d = date(db['datestring'])
|
||||
for k in pairs(replaces) do
|
||||
if(k ~= L[k]) then
|
||||
d = d:gsub(k, L[k])
|
||||
end
|
||||
end
|
||||
local h, w = computelatency()
|
||||
local h, w = select(3,GetNetStats())
|
||||
local l = db['latencystring']
|
||||
l = l:gsub("%%world", w)
|
||||
l = l:gsub("%%local", h)
|
||||
local f = db['fpsstring']
|
||||
f = f:gsub("%%fps",floor(GetFramerate()))
|
||||
return c,d,l,f
|
||||
local fr = floor(GetFramerate())
|
||||
f = f:gsub("%%fps", fr)
|
||||
return {
|
||||
['clockstring'] = date(db['clockstring']),
|
||||
['datestring'] = d,
|
||||
['latencystring'] = l,
|
||||
['latencycolor'] = compute_colorpick('latency', w),
|
||||
['latencyvalue'] = w,
|
||||
['latencyhomevalue'] = h,
|
||||
['latencyhomecolor'] = compute_colorpick('latency', h),
|
||||
['fpscolor'] = compute_colorpick('fps', fr),
|
||||
['fpsstring'] = f,
|
||||
['fpsvalue'] = fr
|
||||
}
|
||||
end
|
||||
local function sortTab(a,b)
|
||||
return a['mem'] > b['mem']
|
||||
|
@ -147,13 +169,13 @@ local function OnTooltipShow(tip)
|
|||
child['lastainfo'] = GetTime() + ainfodelay
|
||||
end
|
||||
local ainfo = child['ainfo']
|
||||
local c,d,l,f = compute()
|
||||
local com = compute()
|
||||
tip:AddLine(childName)
|
||||
local col = "00ff00"
|
||||
if(db['expert']) then
|
||||
tip:AddLine(child:colorize(d,col))
|
||||
tip:AddLine(child:colorize(com['datestring'], col))
|
||||
else
|
||||
tip:AddLine(child:colorize(format("%s, %s.%s",L[date("%A")],date("%d"),L[date("%B")]),col))
|
||||
tip:AddLine(child:colorize(format("%s, %s.%s",L[date("%A")],date("%d"),L[date("%B")]), col))
|
||||
end
|
||||
col = toggleColor(col,"ffffff","00ff00")
|
||||
if(db["12-Hours"]) then
|
||||
|
@ -162,9 +184,9 @@ local function OnTooltipShow(tip)
|
|||
tip:AddDoubleLine(child:colorize(L['Time'],col),child:colorize(date("%H:%M:%S"),toggleColor(col,"ffffff","00ff00")))
|
||||
end
|
||||
col = toggleColor(col,"ffffff","00ff00")
|
||||
tip:AddDoubleLine(child:colorize(L['Latency'],col),child:colorize(format("%s ms",select(3,GetNetStats())),toggleColor(col,"ffffff","00ff00")))
|
||||
tip:AddDoubleLine(child:colorize(L['Latency'],col),child:colorize(format("%s ms", com['latencyvalue']), toggleColor(col,"ffffff","00ff00")))
|
||||
col = toggleColor(col,"ffffff","00ff00")
|
||||
tip:AddDoubleLine(child:colorize(L['FPS'],col),child:colorize(format("%i fps",floor(GetFramerate())),toggleColor(col,"ffffff","00ff00")))
|
||||
tip:AddDoubleLine(child:colorize(L['FPS'],col),child:colorize(format("%i fps",com['fpsvalue']),toggleColor(col,"ffffff","00ff00")))
|
||||
col = toggleColor(col,"ffffff","00ff00")
|
||||
tip:AddDoubleLine(child:colorize(L['AddOn Memory'],col),child:colorize(format("%i MB",floor(collectgarbage('count')/1024)),toggleColor(col,"ffffff","00ff00")))
|
||||
tip:AddLine(" ")
|
||||
|
@ -203,34 +225,13 @@ end
|
|||
local function OnDataUpdate()
|
||||
local line = childName
|
||||
if(db['expert']) then
|
||||
local c,d,l,f = compute()
|
||||
local com = compute()
|
||||
line = db['ldbstring']
|
||||
line = line:gsub("%%clock", child:colorize(c,db['clockcolor']))
|
||||
line = line:gsub("%%date", child:colorize(d,db['datecolor']))
|
||||
local fpscolor = db['fpscolor']
|
||||
local fr = floor(GetFramerate())
|
||||
if(db['fpslow'] and tonumber(db['fpslow']) > 0 and tonumber(fr) <= tonumber(db['fpslow'])) then
|
||||
fpscolor = db['fpslowcolor']
|
||||
end
|
||||
if(db['fpsmedium'] and tonumber(db['fpsmedium']) > 0 and tonumber(fr) >= tonumber(db['fpsmedium'])) then
|
||||
fpscolor = db['fpsmediumcolor']
|
||||
end
|
||||
if(db['fpshigh'] and tonumber(db['fpshigh']) > 0 and tonumber(fr) >= tonumber(db['fpshigh'])) then
|
||||
fpscolor = db['fpshighcolor']
|
||||
end
|
||||
line = line:gsub("%%fps", child:colorize(f,fpscolor))
|
||||
local latencycolor = db['latencycolor']
|
||||
local h, w = computelatency()
|
||||
if(db['latencylow'] and tonumber(db['latencylow']) > 0 and tonumber(w) <= tonumber(db['latencylow'])) then
|
||||
latencycolor = db['latencylowcolor']
|
||||
end
|
||||
if(db['latencymedium'] and tonumber(db['latencymedium']) > 0 and tonumber(w) >= tonumber(db['latencymedium'])) then
|
||||
latencycolor = db['latencymediumcolor']
|
||||
end
|
||||
if(db['latencyhigh'] and tonumber(db['latencyhigh']) > 0 and tonumber(w) >= tonumber(db['latencyhigh'])) then
|
||||
fpscolor = db['latencyhighcolor']
|
||||
end
|
||||
line = line:gsub("%%latency", child:colorize(l,latencycolor))
|
||||
line = line:gsub("%%clock", child:colorize(com['clockstring'], db['clockcolor']))
|
||||
line = line:gsub("%%date", child:colorize(com['datestring'], db['datecolor']))
|
||||
line = line:gsub("%%fps", child:colorize(com['fpsvalue'], com['fpscolor']))
|
||||
line = line:gsub("%%latency", child:colorize(com['latencyvalue'], com['latencycolor']))
|
||||
line = line:gsub("%%home", child:colorize(com['latencyhomevalue'], com['latencyhomecolor']))
|
||||
else
|
||||
line = ''
|
||||
if(db["showClock"]) then
|
||||
|
|
|
@ -75,7 +75,7 @@ if L then
|
|||
%% is replaced by %.]=]
|
||||
L["Latencystring"] = "%world %local"
|
||||
L['fpsstring'] = "%fps"
|
||||
L['ldbstring'] = "%clock %date %fps %latency"
|
||||
L['ldbstring'] = "%clock %date %fps %latency %home"
|
||||
L["%i kB"] = "%i kB"
|
||||
L["%i ms"] = "%i ms"
|
||||
L["AddOns"] = "AddOns"
|
||||
|
|
|
@ -75,7 +75,7 @@ if L then
|
|||
%% is replaced by %.]=]
|
||||
L["Latencystring"] = "%world %local"
|
||||
L['fpsstring'] = "%fps"
|
||||
L['ldbstring'] = "%clock %date %fps %latency"
|
||||
L['ldbstring'] = "%clock %date %fps %latency %home"
|
||||
L["%i kB"] = "%i kB"
|
||||
L["%i ms"] = "%i ms"
|
||||
L["AddOns"] = "AddOns"
|
||||
|
|
Loading…
Reference in New Issue