WoWInterface SVN zz_BrokerDisplayAlpha

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

zz_BrokerDisplay/pack.xml New file
0,0 → 1,3
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="core.lua"/>
</Ui>
\ No newline at end of file
zz_BrokerDisplay/license.txt New file
0,0 → 1,6
The following license excludes the libraries (Libs) included. See the libraries directory or website.
 
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.
\ No newline at end of file
zz_BrokerDisplay/zz_BrokerDisplay.toc New file
0,0 → 1,11
## Interface:40200
## Title: BrokerDisplay
## Notes: Simple broker display
## Author: Rilgamon
## Version: 40200.wowi:revision
## X-WoWI-ID: 19176
## SavedVariables: zz_BrokerDisplayDB
## OptionalDeps: Ace3, BrokerPack
 
standalone.xml
pack.xml
zz_BrokerDisplay/icon2.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
zz_BrokerDisplay/standalone.xml New file
0,0 → 1,4
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Include file="Libs\embed.xml"/>
<Include file="common\common.xml"/>
</Ui>
\ No newline at end of file
zz_BrokerDisplay/core.lua New file
0,0 → 1,465
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_BrokerDisplay"
addon['childs'] = addon['childs'] or {}
addon['childs'][#addon['childs'] + 1] = childName
local defaults = {
}
local options = {
}
local _G = _G
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub("LibDBIcon-1.0")
local db
local lastbutton = {}
local bpack
local nextUpdate,nextUpdateDelay = GetTime(),1
 
function BrokerDisplay_Toggle()
addon['toggle'](bpack)
end
 
local function showAll() end -- dummy
 
local function cframe()
bpack = CreateFrame("Frame", "BrokerDisplay", UIParent)
bpack:SetPoint("TOPLEFT", UIParent, "TOPLEFT",0,0)
bpack:SetWidth(200); bpack:SetHeight(24)
bpack:SetFrameStrata("DIALOG")
bpack:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
})
bpack:SetBackdropColor(.2,.1,.1,1)
bpack:SetClampedToScreen(true)
local close = CreateFrame("Button","$PARENTCloseButton", bpack, "UIPanelCloseButton")
close:SetPoint("BOTTOMRIGHT",bpack,"TOPRIGHT",4,-8)
local view = CreateFrame("Button","$PARENTCloseButton", bpack)
view:SetPoint("BOTTOMRIGHT",close,"BOTTOMLEFT",0,4)
view:SetWidth(22); view:SetHeight(22)
view:SetScript("OnClick", showAll)
view:SetBackdrop({
bgFile = "Interface/MINIMAP/TRACKING/None",
 
})
do
local function resetLast(n)
local f = CreateFrame("Frame", "BrokerPackAnchor"..n, bpack)
f:SetWidth(1); f:SetHeight(1);
f:SetPoint("TOPLEFT", bpack, "TOPLEFT",8,-8)
f:Hide()
return f
end
local titles = {"Info", "Launcher"}
local prevbutton
local function tabClick(self, button)
PanelTemplates_SetTab(bpack, self:GetID())
for a = 1,#titles do
_G["BrokerPackAnchor"..a]:Hide()
end
_G["BrokerPackAnchor"..self:GetID()]:Show()
end
for a = 1,#titles do
lastbutton[a] = resetLast(a)
local button1 = CreateFrame("BUTTON", "$parentTab"..a,bpack,"CharacterFrameTabButtonTemplate")
button1:SetID(a)
button1:SetText(titles[a])
button1:ClearAllPoints()
if(a == 1) then
button1:SetPoint("TOPLEFT", bpack, "BOTTOMLEFT",0,4)
else
button1:SetPoint("LEFT", prevbutton, "RIGHT",-20,0)
end
button1:SetScript("OnClick", tabClick)
PanelTemplates_TabResize(button1, 0)
prevbutton = button1
end
PanelTemplates_SetNumTabs(bpack, #titles)
PanelTemplates_SetTab(bpack, 1)
BrokerPackAnchor1:Show()
end
end
local buttons = {}
local resizes = {}
local objtypes = {["data source"] = 1, ["launcher"] = 2, ["mb"] = 3}
local lastm = 0
local buttonTypes = {['launcher'] = true, ['data source'] = true, ['mb'] = true,}
addon['inits'] = addon['inits'] or {}
 
 
local function updateDisplay()
for _,v in pairs(objtypes) do
resizes[v] = 0
end
for objname, buttonData in pairs(buttons) do
local button = _G["BrokerDisplay"..objname]
if(not button) then print(objname) end
local fontstring = _G["BrokerDisplay"..objname.."Text"]
if(buttonData['visible']) then
local lb = objtypes[strlower(buttonData['type'])]
resizes[lb] = resizes[lb] + 1
button:ClearAllPoints()
button:SetWidth(32); button:SetHeight(32)
button:SetPoint("TOPLEFT", bpack, "TOPLEFT", 8, -8 - (resizes[lb]-1) * 32)
button:SetBackdrop( {
bgFile = buttonData['icon'],
})
fontstring:SetPoint("TOPLEFT", button, "TOPRIGHT", 0,0)
button:Show()
fontstring:Show()
else
button:Hide()
end
end
local m = 1
for k,v in pairs(resizes) do
if(v > m) then
m = v
end
end
if(m ~= lastm) then
lastm = m
bpack:SetHeight(16 + (m) * 32)
end
end
 
local function checkObj(objname)
local visible = true
-- print(objname,buttons[objname]['displayType'])
if(buttons[objname]['displayType'] == "always") then
visible = true
elseif(buttons[objname]['displayType'] == "never") then
visible = false
elseif(buttons[objname]['displayType'] == "temporary") then
visible = (buttons[objname]['lastChanged'] + buttons[objname]['keepVisible'] > GetTime())
elseif(buttons[objname]['displayType'] == "party") then
if(GetNumPartyMembers() + GetNumRaidMembers() > 0) then
visible = true
else
visible = false
end
elseif(buttons[objname]['displayType'] == "noparty") then
if(GetNumPartyMembers() + GetNumRaidMembers() == 0) then
visible = true
else
visible = false
end
else
visible = true
end
if(visible ~= buttons[objname]['visible']) then
buttons[objname]['visible'] = visible
updateDisplay()
end
end
 
local function updateObj(event, objname, key, value, dataobj)
-- print("update", objname, key, value)
if(not buttons[objname] or not dataobj['type'] or not buttonTypes[strlower(dataobj['type'])]) then return end
buttons[objname][key] = value
buttons[objname]['lastChanged'] = GetTime()
if(key == "text" and buttons[objname]['buttontext']) then
buttons[objname]['buttontext']:SetText(value)
elseif(key == "icon" and buttons[objname]['button']) then
buttons[objname]['button']:SetBackdrop( {
bgFile = dataobj['icon'],
})
end
checkObj(objname)
end
 
local function GameTooltipHide()
GameTooltip:Hide()
end
 
local function GameTooltipShow(button)
GameTooltip_SetDefaultAnchor( GameTooltip, UIParent )
GameTooltip:ClearAllPoints()
GameTooltip:SetPoint("BOTTOMLEFT", button, "TOPRIGHT",0,0)
GameTooltip:ClearLines()
if(buttons[button['objname']] and type(buttons[button['objname']]['obj']['OnTooltipShow']) == 'function') then
buttons[button['objname']]['obj']['OnTooltipShow'](GameTooltip)
else
GameTooltip:AddLine(button['objname'])
GameTooltip:AddLine(buttons[button['objname']]['obj']['type'])
end
GameTooltip:Show()
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 function protoOnEnter(objname, dataobj, self, ...)
--print(objname,type(dataobj['OnEnter']))
GameTooltip_SetDefaultAnchor( GameTooltip, UIParent )
GameTooltip:ClearAllPoints()
GameTooltip:SetPoint("BOTTOMLEFT", self, "TOPRIGHT",0,0)
GameTooltip:ClearLines()
if(type(dataobj['OnEnter']) == 'function') then
dataobj['OnEnter'](self, ...)
elseif(type(dataobj['OnTooltipShow']) == 'function') then
dataobj['OnTooltipShow'](GameTooltip, ...)
else
GameTooltip:AddLine(objname)
GameTooltip:AddLine(dataobj['type'])
end
GameTooltip:Show()
end
 
local function protoOnLeave(objname, dataobj, self, ...)
if(type(dataobj['OnLeave']) == 'function') then
dataobj['OnLeave'](self, ...)
else
GameTooltip:Hide()
end
end
 
local brokerDefaults = {
['displayType'] = "temporary",
['keepVisible'] = 10,
}
 
local function updatePrefs(objname) end -- dummy, real is after get/set
 
local function addObj(event, objname, dataobj)
if(buttonTypes[strlower(dataobj['type'])]) then
local button, fontstring
local lb = objtypes[strlower(dataobj['type'])]
button = CreateFrame("Button",bpack:GetName()..objname,lastbutton[lb])
button:SetBackdrop( {
bgFile = dataobj['icon'],
})
button:SetWidth(32); button:SetHeight(32)
button:EnableMouse(true)
button:RegisterForClicks("AnyUp")
button['objname'] = objname
button:SetScript("OnEnter", function(self,...) protoOnEnter(objname, dataobj, self,...) end)
button:SetScript("OnLeave", function(self,...) protoOnLeave(objname, dataobj, self,...) end)
button:SetScript("OnClick", buttonClick)
fontstring = button:CreateFontString("$PARENTText")
fontstring:SetWidth(200-32 - 16); fontstring:SetHeight(32)
fontstring:SetPoint("TOPLEFT", button, "TOPRIGHT", 0,0)
fontstring:SetFontObject("GameFontNormal")
fontstring:SetJustifyH("LEFT")
fontstring:SetTextColor(1,1,1,1)
fontstring:SetText(dataobj['text'] or dataobj['name'] or "N/A")
db[objname] = db[objname] or CopyTable(brokerDefaults)
buttons[objname] = buttons[objname] or {
['name'] = objname,
['type'] = dataobj['type'],
['obj'] = dataobj,
['icon'] = dataobj['icon'],
['button'] = button,
['buttontext'] = fontstring or nil,
['lastChange'] = 0,
['displayType'] = db[objname]['displayType'] or (dataobj['type'] == "launcher" and "always" or "temporary"),
['keepVisible'] = db[objname]['keepVisible'] or 10,
}
updateObj("create", objname, "lastChange", GetTime(), dataobj)
if(dataobj['type'] ~= 'mb') then
updatePrefs(objname)
end
end
end
 
local function listObj()
for name,dataobj in ldb:DataObjectIterator() do
if(not buttons[name])then
addObj("added",name, dataobj)
end
end
if(true) then return end
local microButtons = {
"Character", "Spellbook", "Talent", "Achievement", "QuestLog","Guild","PVP","LFD","MainMenu","Help"
}
local replace = {
["Talent"] = "Talents",
["QuestLog"] = "Quest",
["Guild"] = "Socials",
["LFD"] = "LFG",
}
local replaceIcon = {
['Character'] = "Interface\\Buttons\\UI-MicroButtonCharacter-Up",
['PVP'] = "Interface\\TargetingFrame\\UI-PVP-"..UnitFactionGroup("player")
}
 
local replaceClick = {
 
['Character'] = function() ToggleCharacter("PaperDollFrame") end,
["Spellbook"] = function() ToggleSpellBook(BOOKTYPE_SPELL) end,
['Talent'] = ToggleTalentFrame,
["Achievement"] = ToggleAchievementFrame,
["QuestLog"] = function() ToggleFrame(QuestLogFrame) end,
["Guild"] = ToggleGuildFrame,
['PVP'] = TogglePVPFrame,
['LFD'] = ToggleLFDParentFrame,
["MainMenu"] = function()
if ( not GameMenuFrame:IsShown() ) then
if ( VideoOptionsFrame:IsShown() ) then
VideoOptionsFrameCancel:Click();
elseif ( AudioOptionsFrame:IsShown() ) then
AudioOptionsFrameCancel:Click();
elseif ( InterfaceOptionsFrame:IsShown() ) then
InterfaceOptionsFrameCancel:Click();
end
CloseMenus();
CloseAllWindows()
PlaySound("igMainMenuOpen");
ShowUIPanel(GameMenuFrame);
else
PlaySound("igMainMenuQuit");
HideUIPanel(GameMenuFrame);
MainMenuMicroButton_SetNormal();
end
end,
["Help"] = ToggleHelpFrame,
}
for k,v in pairs(microButtons) do
-- print(v)
-- local copy = _G[v.."MicroButton"]
-- if(copy:IsEnabled()) then
local button = {
['name'] = v,
['text'] = v,
['type'] = 'mb',
['icon'] = replaceIcon[v] and replaceIcon[v] or ("Interface\\Buttons\\UI-MicroButton-" .. (replace[v] and replace[v] or v ).. "-Up"),
['OnClick'] = replaceClick[v] and replaceClick[v],
['OnTooltipShow'] = nil,
}
addObj(nil, button['name'], button)
end
-- end
end
 
 
 
showAll = function()
for objname, buttonData in pairs(buttons) do
if(buttonData['displayType'] == 'temporary') then
buttons[objname]['lastChanged'] = GetTime()
checkObj(objname)
end
end
end
 
local function onupdate()
if(GetTime() < nextUpdate) then return end
nextUpdate = GetTime() + nextUpdateDelay
for objname, buttonData in pairs(buttons) do
if(buttonData['displayType'] == 'temporary') then
checkObj(objname)
end
end
end
 
local function OnText(message)
addon['OnText'](message, childName)
end
 
local function getPref(info)
-- print("get",info[#info])
-- print(info[#info], info[#info - 1], info[#info-2],db[info[#info-1]][info[#info]])
return db[info[#info-1]][info[#info]]
end
 
local function setPref(info,value)
-- print("set",info[#info],value)
db[info[#info-1]][info[#info]] = value
buttons[info[#info-1]][info[#info]] = value
checkObj(info[#info-1])
updatePrefs(info[#info-1])
end
 
local function typecolor(objname)
if buttons[objname]['displayType'] == 'temporary' then
return addon['colorize'](objname,"ffff00")
elseif buttons[objname]['displayType'] == 'never' then
return addon['colorize'](objname,"ff0000")
else
return addon['colorize'](objname,"ffffff")
end
end
 
updatePrefs = function(objname)
local p = options['args']['Broker']['args']
p[objname] = {
['type'] = 'group',
['name'] = typecolor(objname),
['args'] = {},
}
db[objname] = db[objname] or CopyTable(brokerDefaults)
local s = p[objname]['args']
s['displayType'] = {
['name'] = "Type",
['type'] = "select",
['values'] = {["temporary"] = "temporary", ["always"] = "always", ["never"] = "never", ['party'] = "party", ['noparty'] = "noparty"},
['order'] = 1,
}
if(buttons[objname]['displayType'] == 'temporary') then
s['keepVisible'] = {
['name'] = "Displaytime",
['desc'] = "Keep visible for x seconds after a change.",
['type'] = "range",
['min'] = 1,
['max'] = 3600,
['step'] = 1,
['order'] = 2,
}
else
s['keepVisible'] = nil
end
end
 
local function OnClick(self, button)
local objname = ldb:GetNameByDataObject(self)
addon['db']['global']['ldbicons'] = addon['db']['global']['ldbicons'] or {}
local db = addon['db']['global']['ldbicons']
db[objname] = db[objname] or {
['hide'] = false,
}
if(button == "LeftButton") then
if(IsShiftKeyDown()) then
db[objname]['hide'] = not db[objname]['hide']
addon['ldbiconUpdate'](objname)
else
BrokerDisplay_Toggle()
end
else
InterfaceOptionsFrame_OpenToCategory(objname)
end
end
 
local function init()
-- print("init",childName)
cframe()
addon['addFrameDrag'](bpack)
addon['loadFrame'](bpack)
addon['ldbs'][#addon['ldbs'] + 1] = {
['name'] = childName,
['type'] = "launcher",
['OnClick'] = OnClick,
}
options = addon['setupPrefs'](childName, parentName, addon['db'], defaults, false)
db = addon['db']['profile'][childName]
addon['AddConfigMenu']({
['name'] = "Broker",
['order'] = 2,
['childGroups'] = 'tree',
['menuGet'] = getPref,
['menuSet'] = setPref,
}, options)
 
listObj()
ldb['RegisterCallback'](name.."New", "LibDataBroker_DataObjectCreated", addObj)
ldb['RegisterCallback'](name.."Update", "LibDataBroker_AttributeChanged", updateObj)
 
local f = CreateFrame("Frame", "BrokerPackTime")
f:SetScript("OnUpdate", onupdate)
end
 
addon['inits'][childName] = init
\ No newline at end of file
zz_BrokerDisplay/Bindings.xml New file
0,0 → 1,3
<Bindings>
<Binding name="BROKERDISPLAY_TOGGLE" header="BROKERDISPLAY">BrokerDisplay_Toggle()</Binding>
</Bindings>
zz_BrokerDisplay Property changes : Added: bugtraq:number + true
. Property changes : Added: svn:externals + zz_BrokerDisplay/common svn://svn.wowinterface.com/zzcommon-841/trunk/common zz_BrokerDisplay/Libs svn://svn.wowinterface.com/zzcommon-841/trunk/Libs