/trunk
-- Embeds & stuff, create DO etc... |
local BRFaction = CreateFrame("Frame", "Broker_Factions") |
local tooltip = LibStub("LibQTipClick-1.1") |
local tooltip = LibStub("LibQTip-1.0") |
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) |
end |
end |
function BRFaction:ClickHandlerFunc(event, cell, arg1, button) |
local function ClickHandlerFunc(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 |
-- Handlers |
if button == "LeftButton" and (Header == 0 or (Header == 1 and Rep == 1)) and not IsControlKeyDown() and not IsShiftKeyDown() then |
Broker_FactionsConfig.MonitoredFaction = FactionName |
self:Update() |
BRFaction: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() |
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 = nil |
factionlabel = self:CreateFactionLabel(IndexID) |
local factionlabel = BRFaction: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 |
ExpandFactionHeader(IndexID) |
end |
tt:Clear() |
self:Drawtooltip() |
BRFaction:Drawtooltip() |
end |
end |
-- Draw tooltip |
local colcount = tt:GetColumnCount() |
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)) |
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)) |
-- Iterate through faction index |
for i = 1, num do |
else |
display[colnum] = "|cffffffff"..name.."|r" |
end |
tt:AddNormalLine(" ") |
tt:AddLine(" ") |
end |
-- insert empty column so that the actual 2nd column isn't too near faction names |
display[colnum] = _G["NORMAL_FONT_COLOR_CODE"].." "..string.format("%s", barMax - barValue) |
end |
templine = tt:AddLine() |
templine = tt:AddLine(unpack(display, 1, colcount)) |
-- Construct the return table here |
-- Structure: returnarg = { <Faction Name>, <isHeader>, <hasRep>, <isCollapsed>, <IndexID>} |
-- Faction Name : string, eg "Kirin Tor" |
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:SetCell(templine, 1, display[1], returnarg) |
if colcount > 1 then |
for j = 2, colcount do |
tt:SetNormalCell(templine, j, display[j]) |
end |
end |
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg) |
nonheaderset = true |
end |
else |
-- We have a header folks ! |
if not isCollapsed then |
tt:AddNormalLine(" ") |
tt:AddLine(" ") |
HeaderLine = "|cffffffff"..name.."|r" |
templine = tt:AddLine() |
templine = tt:AddLine(HeaderLine) |
-- Construct the return table here |
returnarg = {} |
returnarg[1] = name |
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:SetCell(templine, 1, HeaderLine, returnarg) |
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg) |
elseif isCollapsed and Broker_FactionsConfig.ShowCollapsedHeadersTip then |
tt:AddNormalLine(" ") |
tt:AddLine(" ") |
if Broker_FactionsConfig.ShowCollapsedSuffixTip then |
HeaderLine = "|cffffffff"..name.."|r".." ".._G["RED_FONT_COLOR_CODE"].."(+)".."|r" |
else |
HeaderLine = "|cffffffff"..name.."|r" |
end |
templine = tt:AddLine() |
templine = tt:AddLine(HeaderLine) |
-- Construct the return table here |
returnarg = {} |
returnarg[1] = name |
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:SetCell(templine, 1, HeaderLine, returnarg) |
tt:SetCellScript(templine, 1, "OnMouseDown", ClickHandlerFunc , returnarg) |
end |
end |
end |
-- Tooltip Hint |
if not Broker_FactionsConfig.HideHintTip then |
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) |
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) |
end |
if not nonheaderset then |
-- hide column header titles since we have no real faction data |
for i=1, colcount do |
tt:SetNormalCell(3, i, "") |
tt:SetCell(3, i, "") |
end |
end |
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 |
## Title: Broker [Factions] |
## Author: Tristanian |
## Notes: Minimalistic LDB plugin that allows faction reputation monitoring. |
## OptionalDeps: Ace3, LibQTip-1.0, LibQTipClick-1.1 |
## OptionalDeps: Ace3, LibQTip-1.0 |
## SavedVariablesPerCharacter: Broker_FactionsConfig |
## X-Embeds: Ace3, LibQTip-1.0, LibQTipClick-1.1 |
## X-Embeds: Ace3, LibQTip-1.0 |
## X-Category: Miscellaneous |
## Version: 3.1 |
## X-WoWI-ID: 11020 |
<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> |