self:UpdateReport() |
end |
|
function RollWatcher:SetupFrames() |
local f = GameFontNormal:GetFont() |
local spacing = 5 |
|
-- Create outer frame with backdrop |
report = CreateFrame("Frame", "RollWatcherFrame", UIParent) |
report:Hide() |
self:SetupSizes() |
report:SetToplevel(true) |
report:SetWidth(report.totalwidth) |
report:SetHeight(report.totalheight) |
report:SetScale(self.db.profile.scale) |
report:EnableMouse(true) |
report:SetMovable(true) |
report:RegisterForDrag("LeftButton") |
report:SetScript("OnDragStart", function() this:StartMoving() end) |
report:SetScript("OnDragStop", function() this:StopMovingOrSizing() end) |
|
-- Tooltip Information Formatting |
-- QTip Shiz |
report:SetScript('OnEnter', anchor_OnEnter) |
report:SetScript('OnLeave', anchor_OnLeave) |
|
report:SetBackdrop({ |
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
insets = {left = 4, right = 4, top = 4, bottom = 4}, |
}) |
report:SetBackdropBorderColor(.5, .5, .5) |
report:SetBackdropColor(0,0,0) |
report:ClearAllPoints() |
report:SetPoint("CENTER") |
|
-- Create player namelist, anchored to outer frame with room at top for icons |
local namelist = report:CreateFontString(nil, "OVERLAY") |
namelist:SetFont(f, fontsize) |
namelist:SetWidth(self.db.profile.namelistwidth) |
namelist:SetHeight(report.namelistheight) |
namelist:SetJustifyV("TOP") |
namelist:SetJustifyH("LEFT") |
namelist:SetText("") |
namelist:ClearAllPoints() |
namelist:SetPoint("TOPLEFT", report, "TOPLEFT", report.spacing, -(report.spacing * 2 + iconheight)) |
report.namelist = namelist |
|
-- Create invisible frame around choice lists, for anchoring purposes |
local itemgroup = CreateFrame("Frame", nil, report) |
itemgroup:SetWidth(self.db.profile.nitems * (self.db.profile.namelistwidth + report.spacing) - report.spacing) |
itemgroup:SetHeight(report.namelistheight) |
itemgroup:ClearAllPoints() |
itemgroup:SetPoint("TOPLEFT", namelist, "TOPRIGHT", report.spacing, 0) |
report.itemgroup = itemgroup |
|
-- Create icons and choice lists for each item column |
report.choices = {} |
report.icons = {} |
for i = 1,self.db.profile.nitems do |
self:SetupItemFrames(i) |
end |
|
-- Create text at bottom and page buttons |
local bottomtext = report:CreateFontString(nil, "OVERLAY") |
bottomtext:SetFont(f, fontsize) |
bottomtext:SetWidth(report.bottomtextwidth) |
bottomtext:SetText("") |
bottomtext:ClearAllPoints() |
bottomtext:SetPoint("TOP", itemgroup, "BOTTOM", 0, -report.spacing) |
report.bottomtext = bottomtext |
|
local leftbutton = CreateFrame("Button", nil, report) |
leftbutton:SetWidth(32) |
leftbutton:SetHeight(32) |
leftbutton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up") |
leftbutton:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down") |
leftbutton:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled") |
leftbutton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD") |
leftbutton:ClearAllPoints() |
leftbutton:SetPoint("RIGHT", bottomtext, "LEFT", -report.spacing, 0) |
leftbutton:SetScript("OnClick", function() self:PageLeft() end) |
report.leftbutton = leftbutton |
|
local rightbutton = CreateFrame("Button", nil, report) |
rightbutton:SetWidth(32) |
rightbutton:SetHeight(32) |
rightbutton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up") |
rightbutton:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down") |
rightbutton:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled") |
rightbutton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD") |
rightbutton:ClearAllPoints() |
rightbutton:SetPoint("LEFT", bottomtext, "RIGHT", report.spacing, 0) |
rightbutton:SetScript("OnClick", function() self:PageRight() end) |
report.rightbutton = rightbutton |
|
report.firstitem = 1 |
end |
|
function RollWatcher:ResizeFrames() |
self:SetupSizes() |
report:SetWidth(report.totalwidth) |
report:SetHeight(report.totalheight) |
report.namelist:SetWidth(self.db.profile.namelistwidth) |
report.namelist:SetHeight(report.namelistheight) |
report.itemgroup:SetWidth(self.db.profile.nitems * (self.db.profile.namelistwidth + report.spacing) - report.spacing) |
report.itemgroup:SetHeight(report.namelistheight) |
report.bottomtext:SetWidth(report.bottomtextwidth) |
for i = 1, self.db.profile.nitems do |
if not report.choices[i] then |
self:SetupItemFrames(i) |
else |
local choices = report.choices[i] |
choices:SetWidth(self.db.profile.namelistwidth) |
choices:SetHeight(report.namelistheight) |
choices:ClearAllPoints() |
choices:SetPoint("TOPLEFT", report.itemgroup, "TOPLEFT", (i - 1) * (self.db.profile.namelistwidth + report.spacing), 0) |
end |
end |
-- Hide any extra item frames we might have |
for i = self.db.profile.nitems + 1, table.maxn(report.choices) do |
report.choices[i]:Hide() |
report.icons[i]:Hide() |
end |
self:UpdateReport() |
end |
|
function RollWatcher:SetupItemFrames(i) |
local f = GameFontNormal:GetFont() |
local choices = report.itemgroup:CreateFontString(nil, "OVERLAY") |
|
choices:SetFont(f, fontsize) |
choices:SetWidth(self.db.profile.namelistwidth) |
choices:SetHeight(report.namelistheight) |
choices:SetJustifyV("TOP") |
choices:SetJustifyH("LEFT") |
choices:SetText("") |
choices:ClearAllPoints() |
choices:SetPoint("TOPLEFT", report.itemgroup, "TOPLEFT", (i - 1) * (self.db.profile.namelistwidth + report.spacing), 0) |
report.choices[i] = choices |
|
local icon = CreateFrame("Button", "RollWatcherIcon" .. i, report.itemgroup, "ItemButtonTemplate") |
icon:ClearAllPoints() |
icon:SetPoint("BOTTOMLEFT", choices, "TOPLEFT", 0, report.spacing) |
icon:Hide() |
icon:SetScript("OnEnter", function() self:IconEntered(i) end) |
icon:SetScript("OnLeave", function() GameTooltip:Hide() end) |
icon:SetScript("OnClick", function() self:IconClicked(i) end) |
report.icons[i] = icon |
end |
|
function RollWatcher:IconEntered(i) |
local sorted = self:SortRollids() |
local count = self:CountItems() |
local ind = report.firstitem + i - 1 |
|
if ind <= count then |
local rollid = sorted[ind] |
GameTooltip:SetOwner(report.icons[i], "ANCHOR_RIGHT") |
GameTooltip:SetHyperlink(items[rollid].link) |
end |
end |
|
function RollWatcher:IconClicked(i) |
local sorted = self:SortRollids() |
local count = self:CountItems() |
local ind = report.firstitem + i - 1 |
|
if ind <= count then |
local rollid = sorted[ind] |
if (IsControlKeyDown()) then |
items[rollid] = nil |
self:UpdateReport() |
self:IconEntered(i) |
else |
HandleModifiedItemClick(items[rollid].link) |
end |
end |
end |
|
-- Compute sizes based on the number of players in the party/raid |
function RollWatcher:SetupSizes() |
local nplayers = self:GetNumPlayers() |
|
report.namelistheight = (nplayers + 2) * fontsize + 5 -- font sizes aren't quite integers; leave some wiggle room |
report.spacing = 10 |
report.totalwidth = report.spacing + (self.db.profile.nitems + 1) * (self.db.profile.namelistwidth + report.spacing) |
report.totalheight = report.spacing * 4 + iconheight + report.namelistheight + fontsize |
if self.db.profile.nitems == 1 then |
report.bottomtextwidth = 10 |
else |
report.bottomtextwidth = self.db.profile.namelistwidth |
end |
end |
|
function RollWatcher:PageLeft() |
report.firstitem = report.firstitem - self.db.profile.nitems |
if report.firstitem < 1 then |