WoWInterface SVN BrokerFactions

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 54 to Rev 53
    Reverse comparison

Rev 54 → Rev 53

trunk/Broker_Factions/libs/LibQTipClick-1.1/LibQTipClick-1.1.lua New file
0,0 → 1,135
local MAJOR = "LibQTipClick-1.1"
local MINOR = 3
assert(LibStub, MAJOR.." requires LibStub")
 
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
if not lib then return end -- No upgrade needed
 
local QTip = LibStub:GetLibrary("LibQTip-1.0")
assert(QTip, MAJOR.." requires LibQTip-1.0")
 
local CBH = LibStub:GetLibrary("CallbackHandler-1.0")
assert(CBH, MAJOR.." requires CallbackHandler-1.0")
 
-------------------------------------------------------------------------------
-- Local variables
-------------------------------------------------------------------------------
lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider = QTip:CreateCellProvider(QTip.LabelProvider)
local cell_provider, cell_prototype, cell_base = lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider
 
-------------------------------------------------------------------------------
-- Public library API
-------------------------------------------------------------------------------
local highlighter = CreateFrame("Frame", nil, UIParent)
highlighter:SetFrameStrata("TOOLTIP")
highlighter:Hide()
 
local cell_highlight = highlighter:CreateTexture(nil, "OVERLAY")
cell_highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
cell_highlight:SetBlendMode("ADD")
cell_highlight:SetAllPoints(highlighter)
 
function lib.OnEnter(event, cell, arg)
highlighter:SetAllPoints(cell)
highlighter:SetFrameLevel(cell:GetFrameLevel())
highlighter:Show()
end
 
function lib.OnLeave(event, cell, arg)
highlighter:ClearAllPoints()
highlighter:Hide()
end
 
function lib.OnMouseDown(event, cell, arg, button) PlaySound("igMainMenuOpen") end
function lib.OnMouseUp(event, cell, arg, button) end
 
local function Cell_OnEnter(cell) cell.callbacks:Fire("OnEnter", cell, cell.arg) end
local function Cell_OnLeave(cell) cell.callbacks:Fire("OnLeave", cell, cell.arg) end
local function Cell_OnMouseDown(cell, button) cell.callbacks:Fire("OnMouseDown", cell, cell.arg, button) end
local function Cell_OnMouseUp(cell, button) cell.callbacks:Fire("OnMouseUp", cell, cell.arg, button) end
 
function cell_prototype:InitializeCell() cell_base.InitializeCell(self) end
 
function cell_prototype:SetupCell(tooltip, value, justification, font, arg, ...)
local width, height = cell_base.SetupCell(self, tooltip, value, justification, font, ...)
self:EnableMouse(true)
self.arg = arg
self.callbacks = tooltip.callbacks
self:SetScript("OnEnter", Cell_OnEnter)
self:SetScript("OnLeave", Cell_OnLeave)
self:SetScript("OnMouseDown", Cell_OnMouseDown)
self:SetScript("OnMouseUp", Cell_OnMouseUp)
 
return width, height
end
 
function cell_prototype:ReleaseCell()
self:EnableMouse(false)
self:SetScript("OnEnter", nil)
self:SetScript("OnLeave", nil)
self:SetScript("OnMouseDown", nil)
self:SetScript("OnMouseUp", nil)
self.arg = nil
self.callbacks = nil
end
 
-------------------------------------------------------------------------------
-- LibQTip wrapper API
-------------------------------------------------------------------------------
local function AddNormalLine(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:AddLine(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
 
local function AddNormalHeader(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:AddHeader(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
 
local function SetNormalCell(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:SetCell(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
 
function lib:Acquire(key, ...)
local tooltip = QTip:Acquire(key, ...)
tooltip:EnableMouse(true)
 
tooltip.callbacks = CBH:New(tooltip, "SetCallback", "UnSetCallback", "UnSetAllCallbacks" or false)
tooltip:SetCallback("OnEnter", self.OnEnter)
tooltip:SetCallback("OnLeave", self.OnLeave)
tooltip:SetCallback("OnMouseDown", self.OnMouseDown)
tooltip:SetCallback("OnMouseUp", self.OnMouseUp)
 
tooltip.AddNormalLine = AddNormalLine
tooltip.AddNormalHeader = AddNormalHeader
tooltip.SetNormalCell = SetNormalCell
tooltip:SetDefaultProvider(cell_provider)
return tooltip
end
 
function lib:IsAcquired(key) return QTip:IsAcquired(key) end
 
function lib:Release(tooltip)
if not tooltip then return end
tooltip:EnableMouse(false)
tooltip:UnSetAllCallbacks(tooltip)
tooltip.callbacks = nil
tooltip["SetCallback"] = nil
tooltip["UnSetCallback"] = nil
tooltip["UnSetAllCallbacks"] = nil
QTip:Release(tooltip)
end
 
function lib:IterateTooltips() return QTip:IterateTooltips() end
function lib:CreateCellProvider(baseProvider) return QTip:CreateCellProvider(baseProvider) end
trunk/Broker_Factions/Broker_Factions.lua
4,7 → 4,7
 
-- Embeds & stuff, create DO etc...
local BRFaction = CreateFrame("Frame", "Broker_Factions")
local tooltip = LibStub("LibQTip-1.0")
local tooltip = LibStub("LibQTipClick-1.1")
local L = LibStub("AceLocale-3.0"):GetLocale("Broker_Factions", true)
BRFaction.obj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Broker_Factions", {type = "data source", label = "Broker Factions", icon = "Interface\\Icons\\INV_Misc_TabardPVP_03", text = "|cffffff9a"..L["No Faction"].."|r"})
LibStub("AceTimer-3.0"):Embed(BRFaction)
418,7 → 418,7
end
end
 
local function ClickHandlerFunc(cell, arg1, button)
function BRFaction:ClickHandlerFunc(event, cell, arg1, button)
-- Obligatory sanity checks
if not arg1 or type(arg1)~= "table" then return end
if not arg1[1] or not arg1[2] or not arg1[3] or not arg1[4] or not arg1[5] then return end
431,7 → 431,7
-- Handlers
if button == "LeftButton" and (Header == 0 or (Header == 1 and Rep == 1)) and not IsControlKeyDown() and not IsShiftKeyDown() then
Broker_FactionsConfig.MonitoredFaction = FactionName
BRFaction:Update()
self:Update()
elseif button == "LeftButton" and (Header == 0 or (Header == 1 and Rep == 1)) and not Broker_FactionsConfig.UseBlizzMonitor and IsControlKeyDown() then
-- toggle Blizzard watched faction according to our watched faction
local watched = GetWatchedFactionInfo()
443,7 → 443,8
elseif button == "LeftButton" and (Header == 0 or (Header == 1 and Rep == 1)) and IsShiftKeyDown() then
if ChatFrameEditBox:IsVisible() then
-- construct proper faction label from name
local factionlabel = BRFaction:CreateFactionLabel(IndexID)
local factionlabel = nil
factionlabel = self:CreateFactionLabel(IndexID)
if not factionlabel then return end -- safeguard: something went horribly wrong and the faction label was never created
-- remove color codes *sigh*
local tmpstr, line, normalized
469,7 → 470,7
ExpandFactionHeader(IndexID)
end
tt:Clear()
BRFaction:Drawtooltip()
self:Drawtooltip()
end
end
 
678,10 → 679,10
 
-- Draw tooltip
local colcount = tt:GetColumnCount()
local templine = tt:AddLine("")
tt:SetCell(templine, 1, _G["HIGHLIGHT_FONT_COLOR_CODE"].."Broker Factions", nil, "CENTER", colcount)
tt:AddLine(" ")
tt:AddHeader(unpack(headers,1,colcount))
local templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, _G["HIGHLIGHT_FONT_COLOR_CODE"].."Broker Factions", nil, "CENTER", colcount)
tt:AddNormalLine(" ")
tt:AddNormalHeader(unpack(headers,1,colcount))
 
-- Iterate through faction index
for i = 1, num do
711,7 → 712,7
else
display[colnum] = "|cffffffff"..name.."|r"
end
tt:AddLine(" ")
tt:AddNormalLine(" ")
end
 
-- insert empty column so that the actual 2nd column isn't too near faction names
759,7 → 760,7
display[colnum] = _G["NORMAL_FONT_COLOR_CODE"].." "..string.format("%s", barMax - barValue)
end
 
templine = tt:AddLine(unpack(display, 1, colcount))
templine = tt:AddLine()
-- Construct the return table here
-- Structure: returnarg = { <Faction Name>, <isHeader>, <hasRep>, <isCollapsed>, <IndexID>}
-- Faction Name : string, eg "Kirin Tor"
773,15 → 774,20
if hasRep then returnarg[3] = 1 else returnarg[3] = 0 end
if isCollapsed then returnarg[4] = 1 else returnarg[4] = 0 end
returnarg[5] = i
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg)
tt:SetCell(templine, 1, display[1], returnarg)
if colcount > 1 then
for j = 2, colcount do
tt:SetNormalCell(templine, j, display[j])
end
end
nonheaderset = true
end
else
-- We have a header folks !
if not isCollapsed then
tt:AddLine(" ")
tt:AddNormalLine(" ")
HeaderLine = "|cffffffff"..name.."|r"
templine = tt:AddLine(HeaderLine)
templine = tt:AddLine()
-- Construct the return table here
returnarg = {}
returnarg[1] = name
789,15 → 795,15
if hasRep then returnarg[3] = 1 else returnarg[3] = 0 end
if isCollapsed then returnarg[4] = 1 else returnarg[4] = 0 end
returnarg[5] = i
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg)
tt:SetCell(templine, 1, HeaderLine, returnarg)
elseif isCollapsed and Broker_FactionsConfig.ShowCollapsedHeadersTip then
tt:AddLine(" ")
tt:AddNormalLine(" ")
if Broker_FactionsConfig.ShowCollapsedSuffixTip then
HeaderLine = "|cffffffff"..name.."|r".." ".._G["RED_FONT_COLOR_CODE"].."(+)".."|r"
else
HeaderLine = "|cffffffff"..name.."|r"
end
templine = tt:AddLine(HeaderLine)
templine = tt:AddLine()
-- Construct the return table here
returnarg = {}
returnarg[1] = name
805,31 → 811,31
if hasRep then returnarg[3] = 1 else returnarg[3] = 0 end
if isCollapsed then returnarg[4] = 1 else returnarg[4] = 0 end
returnarg[5] = i
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg)
tt:SetCell(templine, 1, HeaderLine, returnarg)
end
end
end
-- Tooltip Hint
if not Broker_FactionsConfig.HideHintTip then
tt:AddLine(" ")
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fLeft Click|r |cff19ff19on plugin to open Blizzard's Reputation tab."], nil, "LEFT", colcount)
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fLeft Click|r |cff19ff19on faction name to watch on the button/block."], nil, "LEFT", colcount)
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fRight Click|r |cff19ff19on plugin to open Configuration Menu."], nil, "LEFT", colcount)
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fRight Click|r |cff19ff19on faction header to expand or collapse it."], nil, "LEFT", colcount)
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fShift+Left Click|r |cff19ff19to paste Reputation info into chat."], nil, "LEFT", colcount)
templine = tt:AddLine("")
tt:SetCell(templine, 1, L["|cffeda55fCtrl+Left Click|r |cff19ff19to toggle Reputation bar watch."], nil, "LEFT", colcount)
tt:AddNormalLine(" ")
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fLeft Click|r |cff19ff19on plugin to open Blizzard's Reputation tab."], nil, "LEFT", colcount)
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fLeft Click|r |cff19ff19on faction name to watch on the button/block."], nil, "LEFT", colcount)
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fRight Click|r |cff19ff19on plugin to open Configuration Menu."], nil, "LEFT", colcount)
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fRight Click|r |cff19ff19on faction header to expand or collapse it."], nil, "LEFT", colcount)
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fShift+Left Click|r |cff19ff19to paste Reputation info into chat."], nil, "LEFT", colcount)
templine = tt:AddNormalLine("")
tt:SetNormalCell(templine, 1, L["|cffeda55fCtrl+Left Click|r |cff19ff19to toggle Reputation bar watch."], nil, "LEFT", colcount)
end
 
if not nonheaderset then
-- hide column header titles since we have no real faction data
for i=1, colcount do
tt:SetCell(3, i, "")
tt:SetNormalCell(3, i, "")
end
end
 
893,8 → 899,9
tt:SmartAnchorTo(self)
tt:Clear()
tt:SetScale(Broker_FactionsConfig.ToolTipScale or 1)
tt.SetCallback(BRFaction, "OnMouseDown", "ClickHandlerFunc")
BRFaction:Drawtooltip()
tt:SetBackdropBorderColor(1, 1, 1, 1)
BRFaction:Drawtooltip()
tt:Show()
end
 
trunk/Broker_Factions/Broker_Factions.toc
2,9 → 2,9
## Title: Broker [Factions]
## Author: Tristanian
## Notes: Minimalistic LDB plugin that allows faction reputation monitoring.
## OptionalDeps: Ace3, LibQTip-1.0
## OptionalDeps: Ace3, LibQTip-1.0, LibQTipClick-1.1
## SavedVariablesPerCharacter: Broker_FactionsConfig
## X-Embeds: Ace3, LibQTip-1.0
## X-Embeds: Ace3, LibQTip-1.0, LibQTipClick-1.1
## X-Category: Miscellaneous
## Version: 3.1
## X-WoWI-ID: 11020
trunk/Broker_Factions/embeds.xml
9,4 → 9,5
<Include file="libs\AceHook-3.0\AceHook-3.0.xml"/>
<Include file="libs\AceTimer-3.0\AceTimer-3.0.xml"/>
<Script file="libs\LibQTip-1.0\LibQTip-1.0.lua"/>
<Script file="libs\LibQTipClick-1.1\LibQTipClick-1.1.lua"/>
</Ui>
\ No newline at end of file