annotate Frames.lua @ 144:12a8ea5af671

Added a ?remove? button to the crafting queue. When removing an item from the queue or when it is finished casting (when using the Inventorium queue processer), items are moved to the ?unqueuables? window. Fixed auction price checking. Now resetting filters before scanning the tradeskill recipes.
author Zerotorescue
date Wed, 19 Jan 2011 23:21:16 +0100
parents 5ed50feddeb0
children 6a52272a0e5a
rev   line source
Zerotorescue@101 1 local addon = select(2, ...);
Zerotorescue@101 2
Zerotorescue@101 3 local function ShowTooltip(self)
Zerotorescue@101 4 -- If this function is called from a widget, self is the widget and self.frame the actual frame
Zerotorescue@101 5 local this = self.frame or self;
Zerotorescue@101 6
Zerotorescue@132 7 if not this.tooltipTitle or addon.db.profile.defaults.hideHelp then return; end
Zerotorescue@106 8
Zerotorescue@101 9 GameTooltip:SetOwner(this, "ANCHOR_NONE");
Zerotorescue@104 10 if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then
Zerotorescue@104 11 GameTooltip:SetPoint("TOP", this, "BOTTOM");
Zerotorescue@101 12 else
Zerotorescue@101 13 GameTooltip:SetPoint("BOTTOM", this, "TOP");
Zerotorescue@101 14 end
Zerotorescue@101 15 GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1);
Zerotorescue@101 16
Zerotorescue@101 17 if type(this.tooltip) == "string" then
Zerotorescue@101 18 GameTooltip:AddLine(this.tooltip, 1, 1, 1, 1);
Zerotorescue@101 19 end
Zerotorescue@101 20
Zerotorescue@101 21 GameTooltip:Show();
Zerotorescue@101 22 end
Zerotorescue@101 23
Zerotorescue@101 24 local function HideTooltip()
Zerotorescue@101 25 GameTooltip:Hide();
Zerotorescue@101 26 end
Zerotorescue@101 27
Zerotorescue@110 28 function addon:CreateMoverFrame()
Zerotorescue@132 29 if InventoriumItemMover then
Zerotorescue@132 30 return;
Zerotorescue@132 31 end
Zerotorescue@132 32
Zerotorescue@101 33 local frameWidth = 400;
Zerotorescue@101 34
Zerotorescue@101 35 -- Main window
Zerotorescue@101 36 local frame = CreateFrame("Frame", "InventoriumItemMover", UIParent);
Zerotorescue@101 37 -- Hide by default
Zerotorescue@101 38 frame:Hide();
Zerotorescue@101 39 -- Center the frame (will be adjusted later)
Zerotorescue@101 40 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
Zerotorescue@101 41 -- Put in front of other windows
Zerotorescue@101 42 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@101 43 frame:SetToplevel(true);
Zerotorescue@101 44 -- Give it a size
Zerotorescue@101 45 frame:SetWidth(frameWidth);
Zerotorescue@101 46 frame:SetHeight(175);
Zerotorescue@101 47 -- Background
Zerotorescue@101 48 frame:SetBackdrop({
Zerotorescue@101 49 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@101 50 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@104 51 edgeSize = 20,
Zerotorescue@101 52 insets = {
Zerotorescue@101 53 left = 5,
Zerotorescue@101 54 right = 5,
Zerotorescue@101 55 top = 5,
Zerotorescue@101 56 bottom = 5,
Zerotorescue@101 57 },
Zerotorescue@101 58 });
Zerotorescue@101 59 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@101 60 -- Mouse functions
Zerotorescue@101 61 frame:EnableMouse();
Zerotorescue@101 62 frame:SetMovable(true);
Zerotorescue@101 63 frame:SetResizable(true);
Zerotorescue@101 64 frame:SetMinResize(300, 175);
Zerotorescue@101 65 -- Set event handlers
Zerotorescue@101 66 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@101 67 frame:SetScript("OnShow", function(this)
Zerotorescue@104 68 if not tContains(StaticPopup_DisplayedFrames, this) then
Zerotorescue@104 69 -- 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 70 local lastFrame = StaticPopup_DisplayedFrames[#StaticPopup_DisplayedFrames];
Zerotorescue@104 71 if lastFrame then
Zerotorescue@104 72 this:SetPoint("TOP", lastFrame, "BOTTOM", 0, 0);
Zerotorescue@104 73 else
Zerotorescue@104 74 this:SetPoint("TOP", UIParent, "TOP", 0, -135);
Zerotorescue@104 75 end
Zerotorescue@104 76
Zerotorescue@104 77 -- Position other static popups below this
Zerotorescue@104 78 tinsert(StaticPopup_DisplayedFrames, this);
Zerotorescue@101 79 end
Zerotorescue@101 80
Zerotorescue@101 81 this:AdjustScrollTableRows();
Zerotorescue@101 82
Zerotorescue@101 83 PlaySound("OrcExploration");
Zerotorescue@101 84 end);
Zerotorescue@110 85 frame:SetScript("OnHide", function(this)
Zerotorescue@110 86 StaticPopup_CollapseTable(this);
Zerotorescue@110 87 end);
Zerotorescue@101 88
Zerotorescue@101 89 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@101 90 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 91 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 92 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@101 93 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@101 94 titleBackground:SetWidth(150);
Zerotorescue@101 95 titleBackground:SetHeight(40);
Zerotorescue@119 96
Zerotorescue@119 97 frame.titleBackground = titleBackground;
Zerotorescue@119 98
Zerotorescue@101 99 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 100 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 101 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@101 102 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@101 103 titleBackgroundLeft:SetWidth(30);
Zerotorescue@101 104 titleBackgroundLeft:SetHeight(40);
Zerotorescue@101 105
Zerotorescue@101 106 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 107 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 108 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@101 109 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@101 110 titleBackgroundRight:SetWidth(30);
Zerotorescue@101 111 titleBackgroundRight:SetHeight(40);
Zerotorescue@101 112
Zerotorescue@101 113 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@101 114 frmTitle:EnableMouse(true);
Zerotorescue@101 115 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@101 116 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@101 117 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@101 118
Zerotorescue@101 119 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@101 120 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@110 121
Zerotorescue@110 122 frame.lblTitle = lblTitle;
Zerotorescue@101 123
Zerotorescue@101 124 -- Resizer (vertical only)
Zerotorescue@101 125 local frmResizer = CreateFrame("Frame", nil, frame);
Zerotorescue@101 126 frmResizer:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, -10);
Zerotorescue@101 127 frmResizer:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -10);
Zerotorescue@101 128 frmResizer:SetHeight(20);
Zerotorescue@101 129 frmResizer:EnableMouse();
Zerotorescue@101 130 frmResizer:SetScript("OnMouseDown", function(this) this:GetParent():StartSizing("BOTTOM"); end);
Zerotorescue@101 131 frmResizer:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@101 132
Zerotorescue@101 133 -- Description
Zerotorescue@101 134 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@106 135 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27);
Zerotorescue@104 136 lblDescription:SetWidth(frameWidth - 15 - 15); -- 10 margin left & 10 margin right
Zerotorescue@101 137 lblDescription:SetJustifyH("LEFT");
Zerotorescue@101 138 lblDescription:SetJustifyV("TOP");
Zerotorescue@101 139
Zerotorescue@101 140 frame.lblDescription = lblDescription;
Zerotorescue@101 141
Zerotorescue@101 142 -- Buttons
Zerotorescue@132 143 -- Proceed
Zerotorescue@132 144 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate");
Zerotorescue@132 145 btnProceed:SetHeight(21);
Zerotorescue@132 146 btnProceed:SetWidth(125);
Zerotorescue@132 147 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11);
Zerotorescue@132 148 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 149 btnProceed:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 150 btnProceed:SetScript("OnLeave", HideTooltip);
Zerotorescue@101 151
Zerotorescue@132 152 frame.btnProceed = btnProceed;
Zerotorescue@101 153
Zerotorescue@101 154 -- Cancel
Zerotorescue@101 155 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate");
Zerotorescue@101 156 btnCancel:SetHeight(21);
Zerotorescue@101 157 btnCancel:SetWidth(125);
Zerotorescue@104 158 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11);
Zerotorescue@110 159 btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@101 160 btnCancel:SetScript("OnEnter", ShowTooltip);
Zerotorescue@101 161 btnCancel:SetScript("OnLeave", HideTooltip);
Zerotorescue@101 162
Zerotorescue@101 163 frame.btnCancel = btnCancel;
Zerotorescue@101 164
Zerotorescue@101 165 -- 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 166 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@106 167 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@106 168 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@104 169 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@101 170
Zerotorescue@101 171 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@101 172
Zerotorescue@101 173 -- Scrolling table with a list of items to be moved
Zerotorescue@101 174 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 175 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 176 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 177 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 178 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@106 179 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 180 scrollTable:RegisterEvents({
Zerotorescue@101 181 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@106 182 if row and realrow then
Zerotorescue@106 183 -- Data row
Zerotorescue@106 184
Zerotorescue@112 185 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@106 186 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@106 187 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@112 188 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@106 189 GameTooltip:Show();
Zerotorescue@106 190 end
Zerotorescue@106 191 else
Zerotorescue@106 192 -- Header row
Zerotorescue@106 193
Zerotorescue@106 194 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@106 195 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@106 196 if cols[column].tooltip then
Zerotorescue@106 197 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@106 198 else
Zerotorescue@106 199 cellFrame.tooltip = nil;
Zerotorescue@106 200 end
Zerotorescue@106 201
Zerotorescue@106 202 ShowTooltip(cellFrame);
Zerotorescue@106 203 end
Zerotorescue@101 204 end
Zerotorescue@101 205 end,
Zerotorescue@101 206 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@106 207 HideTooltip();
Zerotorescue@101 208 end,
Zerotorescue@141 209 ["OnClick"] = function() end,
Zerotorescue@101 210 });
Zerotorescue@101 211
Zerotorescue@132 212 frame.scrollTable = scrollTable;
Zerotorescue@110 213
Zerotorescue@106 214 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@106 215 frame.AdjustScrollTableRows = function(this)
Zerotorescue@106 216 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@110 217 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@106 218
Zerotorescue@106 219 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@106 220 end;
Zerotorescue@106 221 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@101 222 end
Zerotorescue@101 223
Zerotorescue@101 224 function addon:SetMoverFrameData(data)
Zerotorescue@101 225 InventoriumItemMover.scrollTable:SetData(data);
Zerotorescue@101 226
Zerotorescue@101 227 InventoriumItemMover:Show();
Zerotorescue@101 228 end
Zerotorescue@110 229
Zerotorescue@132 230 function addon:SetMoverFrameSettings(title, description, proceed, cancel, headers)
Zerotorescue@110 231 local frame = InventoriumItemMover;
Zerotorescue@110 232
Zerotorescue@110 233 frame.lblTitle:SetText(title);
Zerotorescue@119 234 -- Adjust size for the title background
Zerotorescue@119 235 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin
Zerotorescue@110 236
Zerotorescue@110 237 frame.lblDescription:SetText(description);
Zerotorescue@110 238
Zerotorescue@132 239 frame.btnProceed:SetText(proceed.text);
Zerotorescue@132 240 frame.btnProceed.tooltipTitle = proceed.tooltipTitle;
Zerotorescue@132 241 frame.btnProceed.tooltip = proceed.tooltip;
Zerotorescue@132 242 frame.btnProceed.OnClick = proceed.onClick;
Zerotorescue@110 243
Zerotorescue@110 244 frame.btnCancel:SetText(cancel.text);
Zerotorescue@110 245 frame.btnCancel.tooltipTitle = cancel.tooltipTitle;
Zerotorescue@110 246 frame.btnCancel.tooltip = cancel.tooltip;
Zerotorescue@110 247 frame.btnCancel.OnClick = cancel.onClick;
Zerotorescue@110 248
Zerotorescue@110 249 frame.scrollTable:SetDisplayCols(headers);
Zerotorescue@110 250 end
Zerotorescue@132 251
Zerotorescue@132 252 function addon:CreateQueueFrame()
Zerotorescue@132 253 if InventoriumQueuer then
Zerotorescue@132 254 return;
Zerotorescue@132 255 end
Zerotorescue@132 256
Zerotorescue@132 257 do
Zerotorescue@132 258 local frameWidth = 400;
Zerotorescue@132 259
Zerotorescue@132 260 -- Main window
Zerotorescue@132 261 local frame = CreateFrame("Frame", "InventoriumQueuer", UIParent);
Zerotorescue@132 262 -- Hide by default
Zerotorescue@132 263 frame:Hide();
Zerotorescue@132 264 -- Center the frame (will be adjusted later)
Zerotorescue@132 265 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
Zerotorescue@132 266 -- Put in front of other windows
Zerotorescue@132 267 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@132 268 frame:SetToplevel(true);
Zerotorescue@132 269 -- Give it a size
Zerotorescue@132 270 frame:SetWidth(frameWidth);
Zerotorescue@132 271 frame:SetHeight(430);
Zerotorescue@132 272 -- Background
Zerotorescue@132 273 frame:SetBackdrop({
Zerotorescue@132 274 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@132 275 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@132 276 edgeSize = 20,
Zerotorescue@132 277 insets = {
Zerotorescue@132 278 left = 5,
Zerotorescue@132 279 right = 5,
Zerotorescue@132 280 top = 5,
Zerotorescue@132 281 bottom = 5,
Zerotorescue@132 282 },
Zerotorescue@132 283 });
Zerotorescue@132 284 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@132 285 -- Mouse functions
Zerotorescue@132 286 frame:EnableMouse();
Zerotorescue@132 287 frame:SetMovable(true);
Zerotorescue@132 288 -- Set event handlers
Zerotorescue@132 289 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@132 290 frame:SetScript("OnShow", function(this)
Zerotorescue@132 291 this:AdjustScrollTableRows();
Zerotorescue@132 292 end);
Zerotorescue@132 293
Zerotorescue@132 294 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@132 295 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 296 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 297 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@132 298 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@132 299 titleBackground:SetWidth(150);
Zerotorescue@132 300 titleBackground:SetHeight(40);
Zerotorescue@132 301
Zerotorescue@132 302 frame.titleBackground = titleBackground;
Zerotorescue@132 303
Zerotorescue@132 304 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 305 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 306 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@132 307 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@132 308 titleBackgroundLeft:SetWidth(30);
Zerotorescue@132 309 titleBackgroundLeft:SetHeight(40);
Zerotorescue@132 310
Zerotorescue@132 311 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 312 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 313 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@132 314 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@132 315 titleBackgroundRight:SetWidth(30);
Zerotorescue@132 316 titleBackgroundRight:SetHeight(40);
Zerotorescue@132 317
Zerotorescue@132 318 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@132 319 frmTitle:EnableMouse(true);
Zerotorescue@132 320 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@132 321 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@132 322 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@132 323
Zerotorescue@132 324 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 325 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@132 326
Zerotorescue@132 327 frame.lblTitle = lblTitle;
Zerotorescue@132 328
Zerotorescue@132 329 -- Expand button
Zerotorescue@132 330 local btnExpander = CreateFrame("Button", "$parentExpander", frame);
Zerotorescue@132 331 btnExpander:SetWidth(32);
Zerotorescue@132 332 btnExpander:SetHeight(32);
Zerotorescue@132 333 btnExpander:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -10, -10);
Zerotorescue@132 334 btnExpander:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
Zerotorescue@132 335 btnExpander:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down");
Zerotorescue@132 336 btnExpander:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
Zerotorescue@132 337 btnExpander:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD");
Zerotorescue@132 338 btnExpander.tooltipTitle = "Show unqueueables";
Zerotorescue@132 339 btnExpander.tooltip = "Click to show a list of all unqueueable but tracked items.";
Zerotorescue@132 340 btnExpander:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 341 btnExpander:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 342 btnExpander:SetScript("OnClick", function(this)
Zerotorescue@132 343 if this.Expanded then
Zerotorescue@132 344 -- Collapsing
Zerotorescue@132 345 this.Expanded = nil;
Zerotorescue@132 346 InventoriumQueuerUnqueueables:Hide();
Zerotorescue@132 347 PlaySound("igCharacterInfoClose");
Zerotorescue@132 348
Zerotorescue@132 349 -- Next is an expand
Zerotorescue@132 350 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
Zerotorescue@132 351 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down");
Zerotorescue@132 352 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
Zerotorescue@132 353 else
Zerotorescue@132 354 -- Expanding
Zerotorescue@132 355 this.Expanded = true;
Zerotorescue@132 356
Zerotorescue@132 357 -- Position the frame against the queuer window
Zerotorescue@132 358 InventoriumQueuerUnqueueables:ClearAllPoints();
Zerotorescue@132 359 InventoriumQueuerUnqueueables:SetPoint("TOPLEFT", this:GetParent(), "TOPRIGHT", 0, 0);
Zerotorescue@132 360 InventoriumQueuerUnqueueables:SetPoint("BOTTOMLEFT", this:GetParent(), "BOTTOMLEFT", 0, 0);
Zerotorescue@132 361 InventoriumQueuerUnqueueables:Show();
Zerotorescue@132 362 PlaySound("igCharacterInfoOpen");
Zerotorescue@132 363
Zerotorescue@132 364 -- Next is a collapse
Zerotorescue@132 365 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up");
Zerotorescue@132 366 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down");
Zerotorescue@132 367 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled");
Zerotorescue@132 368 end
Zerotorescue@132 369 end);
Zerotorescue@132 370
Zerotorescue@132 371 -- Description
Zerotorescue@132 372 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 373 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27);
Zerotorescue@132 374 lblDescription:SetPoint("RIGHT", btnExpander, "LEFT", -15, 0);
Zerotorescue@132 375 lblDescription:SetJustifyH("LEFT");
Zerotorescue@132 376 lblDescription:SetJustifyV("TOP");
Zerotorescue@132 377 lblDescription:SetWidth(frameWidth - 70);
Zerotorescue@132 378
Zerotorescue@132 379 frame.lblDescription = lblDescription;
Zerotorescue@132 380
Zerotorescue@132 381 -- Buttons
Zerotorescue@132 382 -- Proceed
Zerotorescue@132 383 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate");
Zerotorescue@132 384 btnProceed:SetHeight(21);
Zerotorescue@132 385 btnProceed:SetWidth(125);
Zerotorescue@132 386 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11);
Zerotorescue@132 387 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 388 btnProceed:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 389 btnProceed:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 390
Zerotorescue@132 391 frame.btnProceed = btnProceed;
Zerotorescue@132 392
Zerotorescue@132 393 -- Cancel
Zerotorescue@132 394 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate");
Zerotorescue@132 395 btnCancel:SetHeight(21);
Zerotorescue@132 396 btnCancel:SetWidth(125);
Zerotorescue@132 397 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11);
Zerotorescue@132 398 btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 399 btnCancel:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 400 btnCancel:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 401
Zerotorescue@132 402 frame.btnCancel = btnCancel;
Zerotorescue@132 403
Zerotorescue@132 404 -- 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 405 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 406 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 407 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 408 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 409
Zerotorescue@132 410 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 411
Zerotorescue@132 412 -- Scrolling table with a list of items to be queued
Zerotorescue@132 413 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 414 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 415 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 416 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 417 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 418 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 419 scrollTable:RegisterEvents({
Zerotorescue@144 420 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column)
Zerotorescue@132 421 if row and realrow then
Zerotorescue@132 422 -- Data row
Zerotorescue@132 423
Zerotorescue@144 424 if cols[column].name == "X" then
Zerotorescue@144 425 cellFrame.tooltipTitle = "Remove";
Zerotorescue@144 426 cellFrame.tooltip = "Remove this item from the queue.";
Zerotorescue@144 427 cellFrame.tooltipLocation = "BOTTOM";
Zerotorescue@144 428
Zerotorescue@144 429 ShowTooltip(cellFrame);
Zerotorescue@144 430 elseif data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 431 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 432 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 433 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 434 GameTooltip:Show();
Zerotorescue@132 435 end
Zerotorescue@132 436 else
Zerotorescue@132 437 -- Header row
Zerotorescue@132 438
Zerotorescue@132 439 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 440 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 441 if cols[column].tooltip then
Zerotorescue@132 442 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 443 else
Zerotorescue@132 444 cellFrame.tooltip = nil;
Zerotorescue@132 445 end
Zerotorescue@132 446
Zerotorescue@132 447 ShowTooltip(cellFrame);
Zerotorescue@132 448 end
Zerotorescue@132 449 end
Zerotorescue@132 450 end,
Zerotorescue@144 451 ["OnLeave"] = function()
Zerotorescue@132 452 HideTooltip();
Zerotorescue@132 453 end,
Zerotorescue@144 454 ["OnClick"] = function(rowFrame, cellFrame, data, cols, row, realrow, column)
Zerotorescue@144 455 if row and realrow then
Zerotorescue@144 456 -- Data row
Zerotorescue@144 457
Zerotorescue@144 458 if cols[column].name == "X" then
Zerotorescue@144 459 cols[column].onClick(data[realrow].rowData);
Zerotorescue@144 460
Zerotorescue@144 461 return true; -- cancel default event
Zerotorescue@144 462 end
Zerotorescue@144 463 end
Zerotorescue@144 464 end,
Zerotorescue@132 465 });
Zerotorescue@144 466 scrollTable:EnableSelection(true);
Zerotorescue@132 467
Zerotorescue@132 468 frame.scrollTable = scrollTable;
Zerotorescue@132 469
Zerotorescue@132 470 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 471 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 472 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 473 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 474
Zerotorescue@132 475 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 476 end;
Zerotorescue@132 477 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 478 end
Zerotorescue@132 479 do
Zerotorescue@132 480 local frameWidth = 300;
Zerotorescue@132 481
Zerotorescue@132 482 -- Main window
Zerotorescue@132 483 local frame = CreateFrame("Frame", "InventoriumQueuerUnqueueables", InventoriumQueuer);
Zerotorescue@132 484 -- Hide by default
Zerotorescue@132 485 frame:Hide();
Zerotorescue@132 486 -- Position the frame against the queuer window
Zerotorescue@132 487 frame:SetPoint("TOPLEFT", InventoriumQueuer, "TOPRIGHT", 0, 0);
Zerotorescue@132 488 frame:SetPoint("BOTTOMLEFT", InventoriumQueuer, "BOTTOMLEFT", 0, 0);
Zerotorescue@132 489 -- Put in front of other windows
Zerotorescue@132 490 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@132 491 frame:SetToplevel(true);
Zerotorescue@132 492 -- Give it a size
Zerotorescue@132 493 frame:SetWidth(frameWidth);
Zerotorescue@132 494 -- Background
Zerotorescue@132 495 frame:SetBackdrop({
Zerotorescue@132 496 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@132 497 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@132 498 edgeSize = 20,
Zerotorescue@132 499 insets = {
Zerotorescue@132 500 left = 5,
Zerotorescue@132 501 right = 5,
Zerotorescue@132 502 top = 5,
Zerotorescue@132 503 bottom = 5,
Zerotorescue@132 504 },
Zerotorescue@132 505 });
Zerotorescue@132 506 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@132 507 -- Mouse functions
Zerotorescue@132 508 frame:EnableMouse();
Zerotorescue@132 509 frame:SetMovable(true);
Zerotorescue@132 510 -- Set event handlers
Zerotorescue@132 511 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@132 512 frame:SetScript("OnShow", function(this)
Zerotorescue@132 513 this:AdjustScrollTableRows();
Zerotorescue@132 514 end);
Zerotorescue@132 515
Zerotorescue@132 516 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@132 517 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 518 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 519 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@132 520 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@132 521 titleBackground:SetWidth(90);
Zerotorescue@132 522 titleBackground:SetHeight(40);
Zerotorescue@132 523
Zerotorescue@132 524 frame.titleBackground = titleBackground;
Zerotorescue@132 525
Zerotorescue@132 526 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 527 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 528 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@132 529 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@132 530 titleBackgroundLeft:SetWidth(30);
Zerotorescue@132 531 titleBackgroundLeft:SetHeight(40);
Zerotorescue@132 532
Zerotorescue@132 533 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 534 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 535 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@132 536 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@132 537 titleBackgroundRight:SetWidth(30);
Zerotorescue@132 538 titleBackgroundRight:SetHeight(40);
Zerotorescue@132 539
Zerotorescue@132 540 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@132 541 frmTitle:EnableMouse(true);
Zerotorescue@132 542 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@132 543 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@132 544 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@132 545
Zerotorescue@132 546 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 547 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@132 548 lblTitle:SetText("Unqueueables");
Zerotorescue@132 549
Zerotorescue@132 550 -- 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 551 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 552 frmMeasureDummy:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 553 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 554
Zerotorescue@132 555 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 556
Zerotorescue@132 557 -- Scrolling table with a list of items to be queued
Zerotorescue@132 558 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 559 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 560 scrollTable.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 561 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 562 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 563 scrollTable:RegisterEvents({
Zerotorescue@132 564 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 565 if row and realrow then
Zerotorescue@132 566 -- Data row
Zerotorescue@132 567
Zerotorescue@132 568 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 569 if column == 1 then
Zerotorescue@132 570 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 571 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 572 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 573 GameTooltip:Show();
Zerotorescue@132 574 else
Zerotorescue@132 575 GameTooltip:SetOwner(cellFrame, "ANCHOR_NONE");
Zerotorescue@132 576 GameTooltip:SetPoint("TOPLEFT", cellFrame, "BOTTOMLEFT");
Zerotorescue@132 577 GameTooltip:SetText(data[realrow].rowData.reason[1]);
Zerotorescue@132 578 GameTooltip:AddLine(data[realrow].rowData.reason[2], 1, 1, 1, 1);
Zerotorescue@132 579 GameTooltip:Show();
Zerotorescue@132 580 end
Zerotorescue@132 581 end
Zerotorescue@132 582 else
Zerotorescue@132 583 -- Header row
Zerotorescue@132 584
Zerotorescue@132 585 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 586 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 587 if cols[column].tooltip then
Zerotorescue@132 588 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 589 else
Zerotorescue@132 590 cellFrame.tooltip = nil;
Zerotorescue@132 591 end
Zerotorescue@132 592
Zerotorescue@132 593 ShowTooltip(cellFrame);
Zerotorescue@132 594 end
Zerotorescue@132 595 end
Zerotorescue@132 596 end,
Zerotorescue@132 597 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 598 HideTooltip();
Zerotorescue@132 599 end,
Zerotorescue@141 600 ["OnClick"] = function() end,
Zerotorescue@132 601 });
Zerotorescue@132 602
Zerotorescue@132 603 frame.scrollTable = scrollTable;
Zerotorescue@132 604
Zerotorescue@132 605 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 606 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 607 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 608 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 609
Zerotorescue@132 610 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 611 end;
Zerotorescue@132 612 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 613 end
Zerotorescue@132 614 end
Zerotorescue@132 615
Zerotorescue@132 616 function addon:SetQueueFrameData(queueable, unqueueables)
Zerotorescue@132 617 InventoriumQueuer.scrollTable:SetData(queueable);
Zerotorescue@132 618 InventoriumQueuerUnqueueables.scrollTable:SetData(unqueueables);
Zerotorescue@132 619
Zerotorescue@132 620 InventoriumQueuer:Show();
Zerotorescue@132 621 end
Zerotorescue@132 622
Zerotorescue@132 623 function addon:SetQueueFrameSettings(title, description, proceed, cancel, headers, unqueueablesHeaders)
Zerotorescue@132 624 local frame = InventoriumQueuer;
Zerotorescue@132 625
Zerotorescue@132 626 frame.lblTitle:SetText(title);
Zerotorescue@132 627 -- Adjust size for the title background
Zerotorescue@132 628 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin
Zerotorescue@132 629
Zerotorescue@132 630 frame.lblDescription:SetText(description);
Zerotorescue@132 631
Zerotorescue@132 632 frame.btnProceed:SetText(proceed.text);
Zerotorescue@132 633 frame.btnProceed.tooltipTitle = proceed.tooltipTitle;
Zerotorescue@132 634 frame.btnProceed.tooltip = proceed.tooltip;
Zerotorescue@132 635 frame.btnProceed.OnClick = proceed.onClick;
Zerotorescue@132 636
Zerotorescue@132 637 frame.btnCancel:SetText(cancel.text);
Zerotorescue@132 638 frame.btnCancel.tooltipTitle = cancel.tooltipTitle;
Zerotorescue@132 639 frame.btnCancel.tooltip = cancel.tooltip;
Zerotorescue@132 640 frame.btnCancel.OnClick = cancel.onClick;
Zerotorescue@132 641
Zerotorescue@132 642 frame.scrollTable:SetDisplayCols(headers);
Zerotorescue@132 643
Zerotorescue@132 644 InventoriumQueuerUnqueueables.scrollTable:SetDisplayCols(unqueueablesHeaders);
Zerotorescue@132 645 end