Revision 24

This commit is contained in:
Robin 2021-01-13 14:48:11 +01:00
commit e04876016b
7 changed files with 494 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

11
BrokerDisplayMap.toc Normal file
View File

@ -0,0 +1,11 @@
## Interface: 90002
## X-Repository: https://git.grml.de/rilgamon/BrokerDisplayMap.git
## Title: BrokerDisplayMap
## X-WoWI-ID: 24590
## Notes: Map with included broker display
## SavedVariables: BrokerDisplayMapDB
## OptionalDeps: Ace3, BrokerPack, zzLibCommon
Common\common.xml
minimap.lua
broker.lua
core.lua

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

215
broker.lua Normal file
View File

@ -0,0 +1,215 @@
local name, addon = ...
local db
local buttonTypes = {['launcher'] = true, ['data source'] = true}
local objtypes = {["data source"] = 1, ["launcher"] = 2}
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub("LibDBIcon-1.0")
local buttons = {}
local function updateObj(event, objname, key, value, dataobj)
if(not buttons[objname] or not dataobj['type'] or not buttonTypes[strlower(dataobj['type'])]) then return end
buttons[objname][key] = value
if(key == "text" and buttons[objname]['buttontext']) then
if(db[objname]['showText']) then
buttons[objname]['buttontext']:SetText(value)
else
buttons[objname]['buttontext']:SetText("")
end
elseif(key == "iconCoords" and buttons[objname]['button']) then
buttons[objname]['button']['icon']:SetTexCoord(unpack(buttons[objname][key]))
elseif(key == "icon" and buttons[objname]['button']) then
buttons[objname]['button']['icon']:SetTexture( dataobj['icon'])
end
end
local function buttonClick(self, button, down)
if(buttons[self['objname']] and type(buttons[self['objname']]['obj']['OnClick']) == 'function') then
buttons[self['objname']]['obj']['OnClick'](self, button, down)
end
end
local nextUp,nextDelay = 0,.5
local function tooltipUpdate() end -- dummy
local function ttRefresh(self, res)
self['zzRefresh'] = self['zzRefresh'] - res
if(self['zzRefresh']<0) then
self['zzRefresh'] = 0.3
self['tooltip']:ClearLines()
self['dataObject']['OnTooltipShow'](self['tooltip'])
self['tooltip']:Show()
end
end
local function protoOnEnter(objname,dataobj,self,...)
local tip = GameTooltip
tip:SetOwner(self, "ANCHOR_BOTTOM")
tip:ClearLines()
self['tooltip'] = tip
if(type(dataobj['OnEnter']) == 'function') then
dataobj['OnEnter'](self, ...)
elseif(type(dataobj['OnTooltipShow']) == 'function') then
self['zzRefresh'] = self['zzRefresh'] or 0
self:SetScript("OnUpdate", ttRefresh)
ttRefresh(self, 1)
else
tip:AddLine(objname)
tip:AddLine(dataobj['type'])
end
tip:Show()
end
local function protoOnLeave(objname, dataobj, self)
self:SetScript("OnUpdate", nil)
self['zzRefresh'] = nil
self['tooltip']:Hide()
self['tooltip'] = nil
end
local count = {
['showText'] = 0,
['noText'] = 0,
}
local buttonSize = 16
local maxRow = 8
local function addObj(event, objname, dataobj)
local brokerDefaults = {
['showText'] = (strlower(dataobj['type']) == "data source"),
['active'] = true,
['customTab'] = false,
['custom'] = {
['anchor'] = "CENTER",
['relativTo'] = name,
['parentAnchor'] = "TOP",
['parentXOffset'] = 0,
['parentYOffset'] = 0,
},
}
local customDefaults = {
['anchor'] = "CENTER",
['relativTo'] = name,
['parentAnchor'] = "TOP",
['parentXOffset'] = 0,
['parentYOffset'] = 0,
}
db[objname] = db[objname] or CopyTable(brokerDefaults)
-- db[objname]['custom'] = db[objname]['custom'] or CopyTable(customDefaults)
if(db[objname]['active'] and buttonTypes[strlower(dataobj['type'])]) then
local button, fontstring
local lb = objtypes[strlower(dataobj['type'])]
button = CreateFrame("Button","$parent"..objname,_G[name])
button:SetFrameStrata("MEDIUM")
local tex = button:CreateTexture()
tex:SetAllPoints(button)
tex:SetTexture(dataobj['icon'])
if(dataobj['iconCoords']) then
tex:SetTexCoord(unpack(dataobj['iconCoords']))
end
button['icon'] = tex
button:SetWidth(buttonSize); button:SetHeight(buttonSize)
if(db[objname]['customTab']) then
local tab = db[objname]['custom']
button:SetPoint(tab['anchor'] or "TOPLEFT", tab['relativTo'] or name, tab['parentAnchor'] or"TOPLEFT", tab['parentXOffset'] or 0, tab['parentYOffset'] or -buttonSize * count[strlower(dataobj['type'])])
else
local l = db[objname]['showText'] and 'showText' or 'noText'
if(not db[objname]['showText']) then
-- button:SetPoint("TOPLEFT", name, "TOPLEFT", 12, -30 -buttonSize * count[l])
button:SetPoint("TOPLEFT", name, "TOPLEFT", 12 + buttonSize * floor(count[l]/maxRow), -30 -buttonSize * count[l] + buttonSize*floor(count[l]/maxRow)*maxRow)
else
button:SetPoint("TOPRIGHT", name, "TOPRIGHT", -40, -30 -buttonSize * count[l])
end
count[l] = count[l] + 1
end
button:EnableMouse(true)
button:RegisterForClicks("AnyUp")
button['objname'] = objname
button['dataObject'] = dataobj
if(dataobj['OnEnter']) then
button:SetScript("OnEnter",dataobj['OnEnter'])
if(dataobj['OnLeave']) then
button:SetScript("OnLeave",dataobj['OnLeave'])
end
else
button:SetScript("OnEnter", function(self,...) protoOnEnter(objname, dataobj, self,...) end)
if(dataobj['OnLeave']) then
button:SetScript("OnLeave",dataobj['OnLeave'])
else
button:SetScript("OnLeave", function(self,...) protoOnLeave(objname, dataobj, self,...) end)
end
end
button:SetScript("OnClick", buttonClick)
fontstring = button:CreateFontString("$parentText")
fontstring:SetWidth(400); fontstring:SetHeight(buttonSize)
fontstring:SetPoint("TOPLEFT", button, "TOPRIGHT", 0,0)
fontstring:SetFontObject("GameFontNormalSmall")
fontstring:SetJustifyH("LEFT")
fontstring:SetTextColor(1,1,1,1)
if(db[objname]['showText']) then
fontstring:SetText(dataobj['text'] or dataobj['name'] or "N/A")
end
buttons[objname] = {
['name'] = objname,
['type'] = dataobj['type'],
['obj'] = dataobj,
['icon'] = dataobj['icon'],
['iconCoords'] = dataobj['iconCoords'],
['button'] = button,
['buttontext'] = fontstring,
}
addon['updatePrefs'](objname,brokerDefaults)
elseif(not db[objname]['active'] and buttonTypes[strlower(dataobj['type'])]) then
addon['updatePrefs'](objname,brokerDefaults)
end
end
local function listObj()
for objname,dataobj in ldb:DataObjectIterator() do
if(not buttons[objname])then
addObj("added",objname, dataobj)
end
end
end
function addon:updateBrokerDisplay()
count['showText'] = 0
count['noText'] = 0
for objname,dataobj in ldb:DataObjectIterator() do
if(not buttons[objname])then
addObj("added",objname, dataobj)
end
local button = buttons[objname] and buttons[objname]['button'] or nil
if(button and db[objname]['active']) then
button:ClearAllPoints()
if(db[objname]['customTab']) then
local tab = db[objname]['custom']
button:SetPoint(tab['anchor'] or "TOPLEFT", tab['relativTo'] or name, tab['parentAnchor'] or"TOPLEFT", tab['parentXOffset'] or 0, tab['parentYOffset'] or -buttonSize * count[strlower(dataobj['type'])])
else
local l = db[objname]['showText'] and 'showText' or 'noText'
if(not db[objname]['showText']) then
button:SetPoint("TOPLEFT", name, "TOPLEFT", 12 + buttonSize * floor(count[l]/maxRow), -30 -buttonSize * count[l] + buttonSize*floor(count[l]/maxRow)*maxRow)
buttons[objname]['buttontext']:SetText("")
else
button:SetPoint("TOPRIGHT", name, "TOPRIGHT", -40, -30 -buttonSize * count[l])
buttons[objname]['buttontext']:SetText(buttons[objname]['text'] or objname)
end
count[l] = count[l] + 1
end
-- updateObj(event, objname, 'text', buttons[objname]['text'], dataobj)
button:Show()
elseif(button) then
button:Hide()
end
end
end
function addon:initBroker()
db = addon['db']['profile'][name]
ldb['RegisterCallback'](name.."New", "LibDataBroker_DataObjectCreated", addObj)
ldb['RegisterCallback'](name.."Update", "LibDataBroker_AttributeChanged", updateObj)
listObj()
end

184
core.lua Normal file
View File

@ -0,0 +1,184 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = name
local db
local defaults = {
['zz_Coords'] = {
['customTab'] = true,
['custom'] = {
['anchor'] = "CENTER",
['relativTo'] = name,
['parentAnchor'] = "TOP",
['parentXOffset'] = -80,
['parentYOffset'] = -16,
},
['active'] = true,
['showText'] = true,
},
["zz_Money"] = {
['customTab'] = true,
['custom'] = {
['anchor'] = "CENTER",
['relativTo'] = name,
['parentAnchor'] = "BOTTOM",
['parentXOffset'] = -40,
['parentYOffset'] = 32,
},
['active'] = true,
['showText'] = true,
},
["zz_Infoclock"] = {
['customTab'] = true,
['custom'] = {
['anchor'] = "CENTER",
['relativTo'] = name,
['parentAnchor'] = "BOTTOM",
['parentXOffset'] = -40,
['parentYOffset'] = 16,
},
['active'] = true,
['showText'] = true,
},
}
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(name)
InterfaceOptionsFrame_OpenToCategory(name) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
local function typecolor(objname)
-- print(objname,db[objname]['active'],db[objname]['active'] and "ffffff" or "ff0000")
return addon:colorize(objname,db[objname]['active'] and (db[objname]['customTab'] and "00ffff" or (db[objname]['showText'] and "ffff00" or "ffffff")) or "ff0000")
end
addon['updatePrefs'] = function(objname,brokerDefaults)
local p = addon['options']['args']['Broker']['args']
p[objname] = {
['type'] = 'group',
['childGroups'] = 'tab',
['name'] = typecolor(objname),
['args'] = {},
}
db[objname] = db[objname] or CopyTable(brokerDefaults)
local s = p[objname]['args']
s['active'] = {
['name'] = "Active",
['type'] = "toggle",
['order'] = 1,
}
s['showText'] = {
['name'] = "Show Text",
['type'] = "toggle",
['order'] = 1,
}
s['customTab'] = {
['name'] = "Custom Position",
['type'] = "toggle",
['order'] = 1,
}
s['custom'] = {
['hidden'] = not db[objname]['customTab'],
['type'] = 'group',
['name'] = "Custom Position",
['order'] = 2,
['args'] = {},
}
local positions = {
['TOPLEFT'] = "TOPLEFT",
['TOP'] = "TOP",
['TOPRIGHT'] = "TOPRIGHT",
['LEFT'] = "LEFT",
['CENTER'] = "CENTER",
['RIGHT'] = "RIGHT",
['BOTTOMLEFT'] = "BOTTOMLEFT",
['BOTTOM'] = "BOTTOM",
['BOTTOMRIGHT'] = "BOTTOMRIGHT",
}
local c = s['custom']['args']
c['anchor'] = {
['name'] = "Anchor",
['type'] = "select",
['values'] = positions,
}
c['relativTo'] = {
['name'] = "Relative To Frame",
['type'] = "input",
}
c['parentAnchor'] = {
['name'] = "Parent Anchor",
['type'] = "select",
['values'] = positions,
}
c['parentXOffset'] = {
['name'] = "X-Offset",
['type'] = "range",
['min'] = -400,
['max'] = 400,
['step'] = 1,
['isPercent'] = false,
}
c['parentYOffset'] = {
['name'] = "Y-Offset",
['type'] = "range",
['min'] = -400,
['max'] = 400,
['step'] = 1,
['isPercent'] = false,
}
end
local function getPref(info)
--print("get",info[#info])
-- print(info[#info], info[#info - 1], info[#info-2])
if(info[#info - 1] == 'custom') then
return db[info[#info-2]][info[#info - 1]][info[#info]]
end
return db[info[#info-1]][info[#info]]
end
local function setPref(info,value)
-- print("set",info[#info],value)
if(info[#info - 1] == 'custom') then
db[info[#info-2]][info[#info - 1]][info[#info]] = value
addon['updatePrefs'](info[#info-2])
else
db[info[#info-1]][info[#info]] = value
addon['updatePrefs'](info[#info-1])
end
addon:updateBrokerDisplay()
end
local function init()
addon:InitConfig(name, true, {
['name'] = name,
['type'] = "launcher",
['icon'] = "Interface\\Icons\\INV_Misc_Bag_10_Blue",
['OnClick'] = OnClick,
})
db = addon['db']['profile'][childName]
addon:AddConfigMenu({
['name'] = "Broker",
['order'] = 2,
['childGroups'] = 'tree',
['menuGet'] = getPref,
['menuSet'] = setPref,
}, addon['options'])
addon:initBroker()
addon:initMap()
end
addon:startup(name, childName, init, true, defaults)

80
minimap.lua Normal file
View File

@ -0,0 +1,80 @@
local name, addon = ...
local db
local frame = CreateFrame("FRAME","BrokerDisplayMap",UIParent)
local function updatePosition(self)
self:SetAllPoints(MinimapCluster)
self:Show();
MinimapBorderTop:Hide()
MinimapZoneTextButton:Hide()
GameTimeFrame:Hide()
MinimapBackdrop:Hide()
MinimapCluster:SetWidth(240)
MinimapCluster:SetHeight(200)
Minimap:SetWidth(122)
Minimap:SetHeight(122)
BuffFrame:SetPoint("TOPRIGHT",self,"TOPLEFT",-9,0)
if(ObjectiveTrackerFrame and ObjectiveTrackerFrame:IsVisible() and not ObjectiveTrackerFrame:IsUserPlaced() and not InCombatLockdown()) then
ObjectiveTrackerFrame:SetMovable(true)
ObjectiveTrackerFrame:SetUserPlaced(true)
ObjectiveTrackerFrame:SetPoint("TOPRIGHT",MinimapCluster,"BOTTOMRIGHT")
end
end
frame:HookScript("OnEvent", function(self, event)
if(event == "PLAYER_ENTERING_WORLD") then
updatePosition(self)
elseif(event == "UNIT_AURA") then
BuffFrame:SetPoint("TOPRIGHT", self ,"TOPLEFT",-9,0)
end
end)
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterUnitEvent("UNIT_AURA","player")
function addon:initMap()
Minimap:ClearAllPoints()
Minimap:SetPoint("CENTER")
local mix = BackdropTemplateMixin and "BackdropTemplate" or nil
if(mix) then
Mixin(Minimap, BackdropTemplateMixin)
Mixin(Minimap:GetParent(), BackdropTemplateMixin)
end
Minimap:SetMaskTexture("Interface\\AddOns\\"..name.."\\minimapmask.tga")
Minimap:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
})
Minimap:GetParent():SetBackdrop({bgFile = "Interface/DialogFrame/UI-DialogBox-Background-Dark",
edgeFile = "Interface/DialogFrame/UI-DialogBox-Gold-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
})
updatePosition(frame)
addon['db']['profile'][name][name..'Settings'] = addon['db']['profile'][name][name..'Settings'] or {
[name] = {
['xpos'] = 0,
['ypos'] = 0,
}
}
db = addon['db']['profile'][name][name..'Settings']
-- frame['db'] = db
-- frame['dragAble'] = function() return not addon['db']['profile']['lockwindow'] end
-- MinimapCluster:SetParent(frame)
MinimapCluster['db'] = db
MinimapCluster['dragAble'] = function() return not addon['db']['profile']['lockwindow'] end
addon:CreateSecureFrame(MinimapCluster)
addon:AddConfigEntry(name,'toggle','lockwindow',"Lock","Lock window",1)
end
Minimap:EnableMouseWheel(true)
local ping = Minimap:GetScript("OnMouseUp")
Minimap:SetScript("OnMouseUp", nil)
Minimap:HookScript("OnMouseWheel", function(self, delta)
self:SetZoom(self:GetZoom() + delta);
end)
Minimap:HookScript("OnMouseDown", function(self,button)
if(button == 'RightButton') then
ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self, 0, -5)
else
ping(self, button)
end
end)

BIN
minimapmask.tga Normal file

Binary file not shown.