Zerotorescue@101: local addon = select(2, ...); Zerotorescue@101: Zerotorescue@101: local function ShowTooltip(self) Zerotorescue@101: -- If this function is called from a widget, self is the widget and self.frame the actual frame Zerotorescue@101: local this = self.frame or self; Zerotorescue@101: Zerotorescue@132: if not this.tooltipTitle or addon.db.profile.defaults.hideHelp then return; end Zerotorescue@106: Zerotorescue@101: GameTooltip:SetOwner(this, "ANCHOR_NONE"); Zerotorescue@104: if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then Zerotorescue@104: GameTooltip:SetPoint("TOP", this, "BOTTOM"); Zerotorescue@101: else Zerotorescue@101: GameTooltip:SetPoint("BOTTOM", this, "TOP"); Zerotorescue@101: end Zerotorescue@101: GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1); Zerotorescue@101: Zerotorescue@101: if type(this.tooltip) == "string" then Zerotorescue@101: GameTooltip:AddLine(this.tooltip, 1, 1, 1, 1); Zerotorescue@101: end Zerotorescue@101: Zerotorescue@101: GameTooltip:Show(); Zerotorescue@101: end Zerotorescue@101: Zerotorescue@101: local function HideTooltip() Zerotorescue@101: GameTooltip:Hide(); Zerotorescue@101: end Zerotorescue@101: Zerotorescue@110: function addon:CreateMoverFrame() Zerotorescue@132: if InventoriumItemMover then Zerotorescue@132: return; Zerotorescue@132: end Zerotorescue@132: Zerotorescue@101: local frameWidth = 400; Zerotorescue@101: Zerotorescue@101: -- Main window Zerotorescue@101: local frame = CreateFrame("Frame", "InventoriumItemMover", UIParent); Zerotorescue@101: -- Hide by default Zerotorescue@101: frame:Hide(); Zerotorescue@101: -- Center the frame (will be adjusted later) Zerotorescue@101: frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0); Zerotorescue@101: -- Put in front of other windows Zerotorescue@101: frame:SetFrameStrata("FULLSCREEN_DIALOG"); Zerotorescue@101: frame:SetToplevel(true); Zerotorescue@101: -- Give it a size Zerotorescue@101: frame:SetWidth(frameWidth); Zerotorescue@101: frame:SetHeight(175); Zerotorescue@101: -- Background Zerotorescue@101: frame:SetBackdrop({ Zerotorescue@101: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Zerotorescue@101: edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", Zerotorescue@104: edgeSize = 20, Zerotorescue@101: insets = { Zerotorescue@101: left = 5, Zerotorescue@101: right = 5, Zerotorescue@101: top = 5, Zerotorescue@101: bottom = 5, Zerotorescue@101: }, Zerotorescue@101: }); Zerotorescue@101: frame:SetBackdropColor(0, 0, 0, .8); Zerotorescue@101: -- Mouse functions Zerotorescue@101: frame:EnableMouse(); Zerotorescue@101: frame:SetMovable(true); Zerotorescue@101: frame:SetResizable(true); Zerotorescue@101: frame:SetMinResize(300, 175); Zerotorescue@101: -- Set event handlers Zerotorescue@101: frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); Zerotorescue@101: frame:SetScript("OnShow", function(this) Zerotorescue@104: if not tContains(StaticPopup_DisplayedFrames, this) then Zerotorescue@104: -- We wish to display our box at a similar position as the default interface's static popups, so we literally copied the code for these popups Zerotorescue@104: local lastFrame = StaticPopup_DisplayedFrames[#StaticPopup_DisplayedFrames]; Zerotorescue@104: if lastFrame then Zerotorescue@104: this:SetPoint("TOP", lastFrame, "BOTTOM", 0, 0); Zerotorescue@104: else Zerotorescue@104: this:SetPoint("TOP", UIParent, "TOP", 0, -135); Zerotorescue@104: end Zerotorescue@104: Zerotorescue@104: -- Position other static popups below this Zerotorescue@104: tinsert(StaticPopup_DisplayedFrames, this); Zerotorescue@101: end Zerotorescue@101: Zerotorescue@101: this:AdjustScrollTableRows(); Zerotorescue@101: Zerotorescue@101: PlaySound("OrcExploration"); Zerotorescue@101: end); Zerotorescue@110: frame:SetScript("OnHide", function(this) Zerotorescue@110: StaticPopup_CollapseTable(this); Zerotorescue@110: end); Zerotorescue@101: Zerotorescue@101: -- Title (AceGUI frame-widget-title used as example) Zerotorescue@101: local titleBackground = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@101: titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@101: titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63); Zerotorescue@101: titleBackground:SetPoint("TOP", 0, 12); Zerotorescue@101: titleBackground:SetWidth(150); Zerotorescue@101: titleBackground:SetHeight(40); Zerotorescue@119: Zerotorescue@119: frame.titleBackground = titleBackground; Zerotorescue@119: Zerotorescue@101: local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@101: titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@101: titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63); Zerotorescue@101: titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT"); Zerotorescue@101: titleBackgroundLeft:SetWidth(30); Zerotorescue@101: titleBackgroundLeft:SetHeight(40); Zerotorescue@101: Zerotorescue@101: local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@101: titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@101: titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63); Zerotorescue@101: titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT"); Zerotorescue@101: titleBackgroundRight:SetWidth(30); Zerotorescue@101: titleBackgroundRight:SetHeight(40); Zerotorescue@101: Zerotorescue@101: local frmTitle = CreateFrame("Frame", nil, frame); Zerotorescue@101: frmTitle:EnableMouse(true); Zerotorescue@101: frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end); Zerotorescue@101: frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); Zerotorescue@101: frmTitle:SetAllPoints(titleBackground); Zerotorescue@101: Zerotorescue@101: local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); Zerotorescue@101: lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); Zerotorescue@110: Zerotorescue@110: frame.lblTitle = lblTitle; Zerotorescue@101: Zerotorescue@101: -- Resizer (vertical only) Zerotorescue@101: local frmResizer = CreateFrame("Frame", nil, frame); Zerotorescue@101: frmResizer:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, -10); Zerotorescue@101: frmResizer:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -10); Zerotorescue@101: frmResizer:SetHeight(20); Zerotorescue@101: frmResizer:EnableMouse(); Zerotorescue@101: frmResizer:SetScript("OnMouseDown", function(this) this:GetParent():StartSizing("BOTTOM"); end); Zerotorescue@101: frmResizer:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); Zerotorescue@101: Zerotorescue@101: -- Description Zerotorescue@101: local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal"); Zerotorescue@106: lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27); Zerotorescue@104: lblDescription:SetWidth(frameWidth - 15 - 15); -- 10 margin left & 10 margin right Zerotorescue@101: lblDescription:SetJustifyH("LEFT"); Zerotorescue@101: lblDescription:SetJustifyV("TOP"); Zerotorescue@101: Zerotorescue@101: frame.lblDescription = lblDescription; Zerotorescue@101: Zerotorescue@101: -- Buttons Zerotorescue@132: -- Proceed Zerotorescue@132: local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); Zerotorescue@132: btnProceed:SetHeight(21); Zerotorescue@132: btnProceed:SetWidth(125); Zerotorescue@132: btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); Zerotorescue@132: btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end); Zerotorescue@132: btnProceed:SetScript("OnEnter", ShowTooltip); Zerotorescue@132: btnProceed:SetScript("OnLeave", HideTooltip); Zerotorescue@101: Zerotorescue@132: frame.btnProceed = btnProceed; Zerotorescue@101: Zerotorescue@101: -- Cancel Zerotorescue@101: local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); Zerotorescue@101: btnCancel:SetHeight(21); Zerotorescue@101: btnCancel:SetWidth(125); Zerotorescue@104: btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11); Zerotorescue@110: btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end); Zerotorescue@101: btnCancel:SetScript("OnEnter", ShowTooltip); Zerotorescue@101: btnCancel:SetScript("OnLeave", HideTooltip); Zerotorescue@101: Zerotorescue@101: frame.btnCancel = btnCancel; Zerotorescue@101: Zerotorescue@101: -- Because the scrolling table code-behind will change this element's height, we can't rely on that. Make a dummy frame which we can measure Zerotorescue@101: local frmMeasureDummy = CreateFrame("Frame", nil, frame); Zerotorescue@106: frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); Zerotorescue@106: frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0); Zerotorescue@104: frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); Zerotorescue@101: Zerotorescue@101: frame.frmMeasureDummy = frmMeasureDummy; Zerotorescue@101: Zerotorescue@101: -- Scrolling table with a list of items to be moved Zerotorescue@101: local ScrollingTable = LibStub("ScrollingTable"); Zerotorescue@132: local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings Zerotorescue@132: scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); Zerotorescue@132: scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); Zerotorescue@132: scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); Zerotorescue@106: -- When moving over a row, provide a tooltip for the item Zerotorescue@132: scrollTable:RegisterEvents({ Zerotorescue@101: ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@106: if row and realrow then Zerotorescue@106: -- Data row Zerotorescue@106: Zerotorescue@112: if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then Zerotorescue@106: GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE"); Zerotorescue@106: GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT"); Zerotorescue@112: GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId)); Zerotorescue@106: GameTooltip:Show(); Zerotorescue@106: end Zerotorescue@106: else Zerotorescue@106: -- Header row Zerotorescue@106: Zerotorescue@106: if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then Zerotorescue@106: cellFrame.tooltipTitle = cols[column].tooltipTitle; Zerotorescue@106: if cols[column].tooltip then Zerotorescue@106: cellFrame.tooltip = cols[column].tooltip; -- Optional Zerotorescue@106: else Zerotorescue@106: cellFrame.tooltip = nil; Zerotorescue@106: end Zerotorescue@106: Zerotorescue@106: ShowTooltip(cellFrame); Zerotorescue@106: end Zerotorescue@101: end Zerotorescue@101: end, Zerotorescue@101: ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@106: HideTooltip(); Zerotorescue@101: end, Zerotorescue@141: ["OnClick"] = function() end, Zerotorescue@101: }); Zerotorescue@101: Zerotorescue@132: frame.scrollTable = scrollTable; Zerotorescue@110: Zerotorescue@106: -- Change the amount of displayed rows based on the size of the frame Zerotorescue@106: frame.AdjustScrollTableRows = function(this) Zerotorescue@106: local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); Zerotorescue@110: newRows = (newRows < 4 and 4) or newRows; Zerotorescue@106: Zerotorescue@106: this.scrollTable:SetDisplayRows(newRows, 15); Zerotorescue@106: end; Zerotorescue@106: frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows); Zerotorescue@101: end Zerotorescue@101: Zerotorescue@101: function addon:SetMoverFrameData(data) Zerotorescue@101: InventoriumItemMover.scrollTable:SetData(data); Zerotorescue@101: Zerotorescue@101: InventoriumItemMover:Show(); Zerotorescue@101: end Zerotorescue@110: Zerotorescue@132: function addon:SetMoverFrameSettings(title, description, proceed, cancel, headers) Zerotorescue@110: local frame = InventoriumItemMover; Zerotorescue@110: Zerotorescue@110: frame.lblTitle:SetText(title); Zerotorescue@119: -- Adjust size for the title background Zerotorescue@119: frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin Zerotorescue@110: Zerotorescue@110: frame.lblDescription:SetText(description); Zerotorescue@110: Zerotorescue@132: frame.btnProceed:SetText(proceed.text); Zerotorescue@132: frame.btnProceed.tooltipTitle = proceed.tooltipTitle; Zerotorescue@132: frame.btnProceed.tooltip = proceed.tooltip; Zerotorescue@132: frame.btnProceed.OnClick = proceed.onClick; Zerotorescue@110: Zerotorescue@110: frame.btnCancel:SetText(cancel.text); Zerotorescue@110: frame.btnCancel.tooltipTitle = cancel.tooltipTitle; Zerotorescue@110: frame.btnCancel.tooltip = cancel.tooltip; Zerotorescue@110: frame.btnCancel.OnClick = cancel.onClick; Zerotorescue@110: Zerotorescue@110: frame.scrollTable:SetDisplayCols(headers); Zerotorescue@110: end Zerotorescue@132: Zerotorescue@132: function addon:CreateQueueFrame() Zerotorescue@132: if InventoriumQueuer then Zerotorescue@132: return; Zerotorescue@132: end Zerotorescue@132: Zerotorescue@132: do Zerotorescue@132: local frameWidth = 400; Zerotorescue@132: Zerotorescue@132: -- Main window Zerotorescue@132: local frame = CreateFrame("Frame", "InventoriumQueuer", UIParent); Zerotorescue@132: -- Hide by default Zerotorescue@132: frame:Hide(); Zerotorescue@132: -- Center the frame (will be adjusted later) Zerotorescue@132: frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0); Zerotorescue@132: -- Put in front of other windows Zerotorescue@132: frame:SetFrameStrata("FULLSCREEN_DIALOG"); Zerotorescue@132: frame:SetToplevel(true); Zerotorescue@132: -- Give it a size Zerotorescue@132: frame:SetWidth(frameWidth); Zerotorescue@132: frame:SetHeight(430); Zerotorescue@132: -- Background Zerotorescue@132: frame:SetBackdrop({ Zerotorescue@132: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Zerotorescue@132: edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", Zerotorescue@132: edgeSize = 20, Zerotorescue@132: insets = { Zerotorescue@132: left = 5, Zerotorescue@132: right = 5, Zerotorescue@132: top = 5, Zerotorescue@132: bottom = 5, Zerotorescue@132: }, Zerotorescue@132: }); Zerotorescue@132: frame:SetBackdropColor(0, 0, 0, .8); Zerotorescue@132: -- Mouse functions Zerotorescue@132: frame:EnableMouse(); Zerotorescue@132: frame:SetMovable(true); Zerotorescue@132: -- Set event handlers Zerotorescue@132: frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); Zerotorescue@132: frame:SetScript("OnShow", function(this) Zerotorescue@132: this:AdjustScrollTableRows(); Zerotorescue@132: end); Zerotorescue@132: Zerotorescue@132: -- Title (AceGUI frame-widget-title used as example) Zerotorescue@132: local titleBackground = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63); Zerotorescue@132: titleBackground:SetPoint("TOP", 0, 12); Zerotorescue@132: titleBackground:SetWidth(150); Zerotorescue@132: titleBackground:SetHeight(40); Zerotorescue@132: Zerotorescue@132: frame.titleBackground = titleBackground; Zerotorescue@132: Zerotorescue@132: local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63); Zerotorescue@132: titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT"); Zerotorescue@132: titleBackgroundLeft:SetWidth(30); Zerotorescue@132: titleBackgroundLeft:SetHeight(40); Zerotorescue@132: Zerotorescue@132: local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63); Zerotorescue@132: titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT"); Zerotorescue@132: titleBackgroundRight:SetWidth(30); Zerotorescue@132: titleBackgroundRight:SetHeight(40); Zerotorescue@132: Zerotorescue@132: local frmTitle = CreateFrame("Frame", nil, frame); Zerotorescue@132: frmTitle:EnableMouse(true); Zerotorescue@132: frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end); Zerotorescue@132: frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); Zerotorescue@132: frmTitle:SetAllPoints(titleBackground); Zerotorescue@132: Zerotorescue@132: local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); Zerotorescue@132: lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); Zerotorescue@132: Zerotorescue@132: frame.lblTitle = lblTitle; Zerotorescue@132: Zerotorescue@132: -- Expand button Zerotorescue@132: local btnExpander = CreateFrame("Button", "$parentExpander", frame); Zerotorescue@132: btnExpander:SetWidth(32); Zerotorescue@132: btnExpander:SetHeight(32); Zerotorescue@132: btnExpander:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -10, -10); Zerotorescue@132: btnExpander:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"); Zerotorescue@132: btnExpander:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"); Zerotorescue@132: btnExpander:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"); Zerotorescue@132: btnExpander:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD"); Zerotorescue@132: btnExpander.tooltipTitle = "Show unqueueables"; Zerotorescue@132: btnExpander.tooltip = "Click to show a list of all unqueueable but tracked items."; Zerotorescue@132: btnExpander:SetScript("OnEnter", ShowTooltip); Zerotorescue@132: btnExpander:SetScript("OnLeave", HideTooltip); Zerotorescue@132: btnExpander:SetScript("OnClick", function(this) Zerotorescue@132: if this.Expanded then Zerotorescue@132: -- Collapsing Zerotorescue@132: this.Expanded = nil; Zerotorescue@132: InventoriumQueuerUnqueueables:Hide(); Zerotorescue@132: PlaySound("igCharacterInfoClose"); Zerotorescue@132: Zerotorescue@132: -- Next is an expand Zerotorescue@132: this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"); Zerotorescue@132: this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"); Zerotorescue@132: this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"); Zerotorescue@132: else Zerotorescue@132: -- Expanding Zerotorescue@132: this.Expanded = true; Zerotorescue@132: Zerotorescue@132: -- Position the frame against the queuer window Zerotorescue@132: InventoriumQueuerUnqueueables:ClearAllPoints(); Zerotorescue@132: InventoriumQueuerUnqueueables:SetPoint("TOPLEFT", this:GetParent(), "TOPRIGHT", 0, 0); Zerotorescue@132: InventoriumQueuerUnqueueables:SetPoint("BOTTOMLEFT", this:GetParent(), "BOTTOMLEFT", 0, 0); Zerotorescue@132: InventoriumQueuerUnqueueables:Show(); Zerotorescue@132: PlaySound("igCharacterInfoOpen"); Zerotorescue@132: Zerotorescue@132: -- Next is a collapse Zerotorescue@132: this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up"); Zerotorescue@132: this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down"); Zerotorescue@132: this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled"); Zerotorescue@132: end Zerotorescue@132: end); Zerotorescue@132: Zerotorescue@132: -- Description Zerotorescue@132: local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal"); Zerotorescue@132: lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27); Zerotorescue@132: lblDescription:SetPoint("RIGHT", btnExpander, "LEFT", -15, 0); Zerotorescue@132: lblDescription:SetJustifyH("LEFT"); Zerotorescue@132: lblDescription:SetJustifyV("TOP"); Zerotorescue@132: lblDescription:SetWidth(frameWidth - 70); Zerotorescue@132: Zerotorescue@132: frame.lblDescription = lblDescription; Zerotorescue@132: Zerotorescue@132: -- Buttons Zerotorescue@132: -- Proceed Zerotorescue@132: local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); Zerotorescue@132: btnProceed:SetHeight(21); Zerotorescue@132: btnProceed:SetWidth(125); Zerotorescue@132: btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); Zerotorescue@132: btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end); Zerotorescue@132: btnProceed:SetScript("OnEnter", ShowTooltip); Zerotorescue@132: btnProceed:SetScript("OnLeave", HideTooltip); Zerotorescue@132: Zerotorescue@132: frame.btnProceed = btnProceed; Zerotorescue@132: Zerotorescue@132: -- Cancel Zerotorescue@132: local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); Zerotorescue@132: btnCancel:SetHeight(21); Zerotorescue@132: btnCancel:SetWidth(125); Zerotorescue@132: btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11); Zerotorescue@132: btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end); Zerotorescue@132: btnCancel:SetScript("OnEnter", ShowTooltip); Zerotorescue@132: btnCancel:SetScript("OnLeave", HideTooltip); Zerotorescue@132: Zerotorescue@132: frame.btnCancel = btnCancel; Zerotorescue@132: Zerotorescue@132: -- Because the scrolling table code-behind will change the scrolltable element's height, we can't rely on that. Make a dummy frame which we can measure Zerotorescue@132: local frmMeasureDummy = CreateFrame("Frame", nil, frame); Zerotorescue@132: frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); Zerotorescue@132: frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0); Zerotorescue@132: frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); Zerotorescue@132: Zerotorescue@132: frame.frmMeasureDummy = frmMeasureDummy; Zerotorescue@132: Zerotorescue@132: -- Scrolling table with a list of items to be queued Zerotorescue@132: local ScrollingTable = LibStub("ScrollingTable"); Zerotorescue@132: local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings Zerotorescue@132: scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); Zerotorescue@132: scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); Zerotorescue@132: scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); Zerotorescue@132: -- When moving over a row, provide a tooltip for the item Zerotorescue@132: scrollTable:RegisterEvents({ Zerotorescue@132: ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@132: if row and realrow then Zerotorescue@132: -- Data row Zerotorescue@132: Zerotorescue@132: if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then Zerotorescue@132: GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE"); Zerotorescue@132: GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT"); Zerotorescue@132: GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId)); Zerotorescue@132: GameTooltip:Show(); Zerotorescue@132: end Zerotorescue@132: else Zerotorescue@132: -- Header row Zerotorescue@132: Zerotorescue@132: if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then Zerotorescue@132: cellFrame.tooltipTitle = cols[column].tooltipTitle; Zerotorescue@132: if cols[column].tooltip then Zerotorescue@132: cellFrame.tooltip = cols[column].tooltip; -- Optional Zerotorescue@132: else Zerotorescue@132: cellFrame.tooltip = nil; Zerotorescue@132: end Zerotorescue@132: Zerotorescue@132: ShowTooltip(cellFrame); Zerotorescue@132: end Zerotorescue@132: end Zerotorescue@132: end, Zerotorescue@132: ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@132: HideTooltip(); Zerotorescue@132: end, Zerotorescue@141: ["OnClick"] = function() end, Zerotorescue@132: }); Zerotorescue@132: Zerotorescue@132: frame.scrollTable = scrollTable; Zerotorescue@132: Zerotorescue@132: -- Change the amount of displayed rows based on the size of the frame Zerotorescue@132: frame.AdjustScrollTableRows = function(this) Zerotorescue@132: local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); Zerotorescue@132: newRows = (newRows < 4 and 4) or newRows; Zerotorescue@132: Zerotorescue@132: this.scrollTable:SetDisplayRows(newRows, 15); Zerotorescue@132: end; Zerotorescue@132: frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows); Zerotorescue@132: end Zerotorescue@132: do Zerotorescue@132: local frameWidth = 300; Zerotorescue@132: Zerotorescue@132: -- Main window Zerotorescue@132: local frame = CreateFrame("Frame", "InventoriumQueuerUnqueueables", InventoriumQueuer); Zerotorescue@132: -- Hide by default Zerotorescue@132: frame:Hide(); Zerotorescue@132: -- Position the frame against the queuer window Zerotorescue@132: frame:SetPoint("TOPLEFT", InventoriumQueuer, "TOPRIGHT", 0, 0); Zerotorescue@132: frame:SetPoint("BOTTOMLEFT", InventoriumQueuer, "BOTTOMLEFT", 0, 0); Zerotorescue@132: -- Put in front of other windows Zerotorescue@132: frame:SetFrameStrata("FULLSCREEN_DIALOG"); Zerotorescue@132: frame:SetToplevel(true); Zerotorescue@132: -- Give it a size Zerotorescue@132: frame:SetWidth(frameWidth); Zerotorescue@132: -- Background Zerotorescue@132: frame:SetBackdrop({ Zerotorescue@132: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Zerotorescue@132: edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", Zerotorescue@132: edgeSize = 20, Zerotorescue@132: insets = { Zerotorescue@132: left = 5, Zerotorescue@132: right = 5, Zerotorescue@132: top = 5, Zerotorescue@132: bottom = 5, Zerotorescue@132: }, Zerotorescue@132: }); Zerotorescue@132: frame:SetBackdropColor(0, 0, 0, .8); Zerotorescue@132: -- Mouse functions Zerotorescue@132: frame:EnableMouse(); Zerotorescue@132: frame:SetMovable(true); Zerotorescue@132: -- Set event handlers Zerotorescue@132: frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); Zerotorescue@132: frame:SetScript("OnShow", function(this) Zerotorescue@132: this:AdjustScrollTableRows(); Zerotorescue@132: end); Zerotorescue@132: Zerotorescue@132: -- Title (AceGUI frame-widget-title used as example) Zerotorescue@132: local titleBackground = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63); Zerotorescue@132: titleBackground:SetPoint("TOP", 0, 12); Zerotorescue@132: titleBackground:SetWidth(90); Zerotorescue@132: titleBackground:SetHeight(40); Zerotorescue@132: Zerotorescue@132: frame.titleBackground = titleBackground; Zerotorescue@132: Zerotorescue@132: local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63); Zerotorescue@132: titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT"); Zerotorescue@132: titleBackgroundLeft:SetWidth(30); Zerotorescue@132: titleBackgroundLeft:SetHeight(40); Zerotorescue@132: Zerotorescue@132: local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY"); Zerotorescue@132: titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); Zerotorescue@132: titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63); Zerotorescue@132: titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT"); Zerotorescue@132: titleBackgroundRight:SetWidth(30); Zerotorescue@132: titleBackgroundRight:SetHeight(40); Zerotorescue@132: Zerotorescue@132: local frmTitle = CreateFrame("Frame", nil, frame); Zerotorescue@132: frmTitle:EnableMouse(true); Zerotorescue@132: frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end); Zerotorescue@132: frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); Zerotorescue@132: frmTitle:SetAllPoints(titleBackground); Zerotorescue@132: Zerotorescue@132: local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); Zerotorescue@132: lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); Zerotorescue@132: lblTitle:SetText("Unqueueables"); Zerotorescue@132: Zerotorescue@132: -- Because the scrolling table code-behind will change this element's height, we can't rely on that. Make a dummy frame which we can measure Zerotorescue@132: local frmMeasureDummy = CreateFrame("Frame", nil, frame); Zerotorescue@132: frmMeasureDummy:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42); Zerotorescue@132: frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15); Zerotorescue@132: Zerotorescue@132: frame.frmMeasureDummy = frmMeasureDummy; Zerotorescue@132: Zerotorescue@132: -- Scrolling table with a list of items to be queued Zerotorescue@132: local ScrollingTable = LibStub("ScrollingTable"); Zerotorescue@132: local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings Zerotorescue@132: scrollTable.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42); Zerotorescue@132: scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15); Zerotorescue@132: -- When moving over a row, provide a tooltip for the item Zerotorescue@132: scrollTable:RegisterEvents({ Zerotorescue@132: ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@132: if row and realrow then Zerotorescue@132: -- Data row Zerotorescue@132: Zerotorescue@132: if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then Zerotorescue@132: if column == 1 then Zerotorescue@132: GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE"); Zerotorescue@132: GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT"); Zerotorescue@132: GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId)); Zerotorescue@132: GameTooltip:Show(); Zerotorescue@132: else Zerotorescue@132: GameTooltip:SetOwner(cellFrame, "ANCHOR_NONE"); Zerotorescue@132: GameTooltip:SetPoint("TOPLEFT", cellFrame, "BOTTOMLEFT"); Zerotorescue@132: GameTooltip:SetText(data[realrow].rowData.reason[1]); Zerotorescue@132: GameTooltip:AddLine(data[realrow].rowData.reason[2], 1, 1, 1, 1); Zerotorescue@132: GameTooltip:Show(); Zerotorescue@132: end Zerotorescue@132: end Zerotorescue@132: else Zerotorescue@132: -- Header row Zerotorescue@132: Zerotorescue@132: if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then Zerotorescue@132: cellFrame.tooltipTitle = cols[column].tooltipTitle; Zerotorescue@132: if cols[column].tooltip then Zerotorescue@132: cellFrame.tooltip = cols[column].tooltip; -- Optional Zerotorescue@132: else Zerotorescue@132: cellFrame.tooltip = nil; Zerotorescue@132: end Zerotorescue@132: Zerotorescue@132: ShowTooltip(cellFrame); Zerotorescue@132: end Zerotorescue@132: end Zerotorescue@132: end, Zerotorescue@132: ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) Zerotorescue@132: HideTooltip(); Zerotorescue@132: end, Zerotorescue@141: ["OnClick"] = function() end, Zerotorescue@132: }); Zerotorescue@132: Zerotorescue@132: frame.scrollTable = scrollTable; Zerotorescue@132: Zerotorescue@132: -- Change the amount of displayed rows based on the size of the frame Zerotorescue@132: frame.AdjustScrollTableRows = function(this) Zerotorescue@132: local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); Zerotorescue@132: newRows = (newRows < 4 and 4) or newRows; Zerotorescue@132: Zerotorescue@132: this.scrollTable:SetDisplayRows(newRows, 15); Zerotorescue@132: end; Zerotorescue@132: frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows); Zerotorescue@132: end Zerotorescue@132: end Zerotorescue@132: Zerotorescue@132: function addon:SetQueueFrameData(queueable, unqueueables) Zerotorescue@132: InventoriumQueuer.scrollTable:SetData(queueable); Zerotorescue@132: InventoriumQueuerUnqueueables.scrollTable:SetData(unqueueables); Zerotorescue@132: Zerotorescue@132: InventoriumQueuer:Show(); Zerotorescue@132: end Zerotorescue@132: Zerotorescue@132: function addon:SetQueueFrameSettings(title, description, proceed, cancel, headers, unqueueablesHeaders) Zerotorescue@132: local frame = InventoriumQueuer; Zerotorescue@132: Zerotorescue@132: frame.lblTitle:SetText(title); Zerotorescue@132: -- Adjust size for the title background Zerotorescue@132: frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin Zerotorescue@132: Zerotorescue@132: frame.lblDescription:SetText(description); Zerotorescue@132: Zerotorescue@132: frame.btnProceed:SetText(proceed.text); Zerotorescue@132: frame.btnProceed.tooltipTitle = proceed.tooltipTitle; Zerotorescue@132: frame.btnProceed.tooltip = proceed.tooltip; Zerotorescue@132: frame.btnProceed.OnClick = proceed.onClick; Zerotorescue@132: Zerotorescue@132: frame.btnCancel:SetText(cancel.text); Zerotorescue@132: frame.btnCancel.tooltipTitle = cancel.tooltipTitle; Zerotorescue@132: frame.btnCancel.tooltip = cancel.tooltip; Zerotorescue@132: frame.btnCancel.OnClick = cancel.onClick; Zerotorescue@132: Zerotorescue@132: frame.scrollTable:SetDisplayCols(headers); Zerotorescue@132: Zerotorescue@132: InventoriumQueuerUnqueueables.scrollTable:SetDisplayCols(unqueueablesHeaders); Zerotorescue@132: end