Mercurial > wow > inventory
diff Frames.lua @ 110:67bd5057ecb7
Implemented vendor restocking with the mover. Comitting so I can always review this working version, but I?ll be disabling all part of it as it is not going to work properly without seriously compromising the code structure.
Debug messages are now appended with ?Inventorium? (my MailOpener addon was making stuff difficult).
Now properly removing the refill window from the displayed static popup windows list so new popups won?t be aligned at odd locations.
Changed ?CreateMoverFrame? to not contain any scenario-specific info. All settings can be set with SetFrameSettings.
Items that belong to speciality bags are now put there. Other items now ignore spaciality bags.
Implemented test code for mailbox refill support. It has been disabled due to some issues but may be introduced later.
The guild withdrawal limit is now taken into consideration.
Queue is now reset before scanning again.
author | Zerotorescue |
---|---|
date | Fri, 14 Jan 2011 23:25:05 +0100 |
parents | d3fbb5676a5e |
children | 9765bc3b3d6b |
line wrap: on
line diff
--- a/Frames.lua Wed Jan 12 22:48:25 2011 +0100 +++ b/Frames.lua Fri Jan 14 23:25:05 2011 +0100 @@ -25,7 +25,7 @@ GameTooltip:Hide(); end -function addon:CreateMoverFrame(onAccept, onCancel) +function addon:CreateMoverFrame() local frameWidth = 400; -- Main window @@ -78,6 +78,9 @@ PlaySound("OrcExploration"); end); + frame:SetScript("OnHide", function(this) + StaticPopup_CollapseTable(this); + end); -- Title (AceGUI frame-widget-title used as example) local titleBackground = frame:CreateTexture(nil, "OVERLAY"); @@ -109,7 +112,8 @@ local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); - lblTitle:SetText("Inventorium Bank Refill"); + + frame.lblTitle = lblTitle; -- Resizer (vertical only) local frmResizer = CreateFrame("Frame", nil, frame); @@ -126,7 +130,6 @@ lblDescription:SetWidth(frameWidth - 15 - 15); -- 10 margin left & 10 margin right lblDescription:SetJustifyH("LEFT"); lblDescription:SetJustifyV("TOP"); - lblDescription:SetText("The items listed below can be refilled from this location, do you wish to move them to your bags?"); frame.lblDescription = lblDescription; @@ -137,11 +140,9 @@ btnMove:SetWidth(125); btnMove:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); btnMove:SetText("Move Items"); - btnMove:SetScript("OnClick", onAccept); + btnMove:SetScript("OnClick", function(this) this.OnClick(this); end); btnMove:SetScript("OnEnter", ShowTooltip); btnMove:SetScript("OnLeave", HideTooltip); - btnMove.tooltipTitle = (not addon.db.profile.defaults.hideHelp and "Move Items"); - btnMove.tooltip = (not addon.db.profile.defaults.hideHelp and "Start moving these items from the bank."); frame.btnMove = btnMove; @@ -150,12 +151,9 @@ btnCancel:SetHeight(21); btnCancel:SetWidth(125); btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11); - btnCancel:SetText("Cancel"); - btnCancel:SetScript("OnClick", onCancel); + btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end); btnCancel:SetScript("OnEnter", ShowTooltip); btnCancel:SetScript("OnLeave", HideTooltip); - btnCancel.tooltipTitle = (not addon.db.profile.defaults.hideHelp and "Cancel"); - btnCancel.tooltip = (not addon.db.profile.defaults.hideHelp and "Do not move anything and close the window."); frame.btnCancel = btnCancel; @@ -168,61 +166,11 @@ frame.frmMeasureDummy = frmMeasureDummy; -- Scrolling table with a list of items to be moved - local scrollTableWidth = ( frame.frmMeasureDummy:GetWidth() - 30 ); -- adjust width by the scrollbar size - local headers = { - { - ["name"] = "Item", - ["width"] = (scrollTableWidth * .60), - ["defaultsort"] = "asc", - ["comparesort"] = function(this, aRow, bRow, column) - local aName, _, aRarity = GetItemInfo(this:GetRow(aRow).rowData.id); - local bName, _, bRarity = GetItemInfo(this:GetRow(bRow).rowData.id); - local template = "%d%s"; - aName = template:format((10 - (aRarity or 10)), (aName or ""):lower()); - bName = template:format((10 - (bRarity or 10)), (bName or ""):lower()); - - if this.cols[column].sort == "dsc" then - return aName > bName; - else - return aName < bName; - end - end, - ["sort"] = "asc", -- when the data is set, use this column so sort the default data - ["tooltipTitle"] = (not addon.db.profile.defaults.hideHelp and "Item"), - ["tooltip"] = (not addon.db.profile.defaults.hideHelp and "Click to sort the list by item quality then item name."), - }, - { - ["name"] = "Moving", - ["width"] = (scrollTableWidth * .15), - ["align"] = "RIGHT", - ["defaultsort"] = "dsc", - ["sortnext"] = 1, - ["tooltipTitle"] = (not addon.db.profile.defaults.hideHelp and "Moving"), - ["tooltip"] = (not addon.db.profile.defaults.hideHelp and "Click to sort the list by the amount of movable items."), - }, - { - ["name"] = "Available", - ["width"] = (scrollTableWidth * .25), - ["align"] = "RIGHT", - ["defaultsort"] = "dsc", - ["sortnext"] = 1, - ["comparesort"] = function(this, aRow, bRow, column) - local aAvailablePercent = (this:GetRow(aRow).rowData.available / this:GetRow(aRow).rowData.missing); - local bAvailablePercent = (this:GetRow(bRow).rowData.available / this:GetRow(bRow).rowData.missing); - - if this.cols[column].sort == "dsc" then - return aAvailablePercent > bAvailablePercent; - else - return aAvailablePercent < bAvailablePercent; - end - end, - ["tooltipTitle"] = (not addon.db.profile.defaults.hideHelp and "Item"), - ["tooltip"] = (not addon.db.profile.defaults.hideHelp and "Click to sort the list by the availibility percentage."), - }, - }; - local ScrollingTable = LibStub("ScrollingTable"); - local table = ScrollingTable:CreateST(headers, 3, 15, nil, frame); + local table = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings + table.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); + table.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); + table.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); -- When moving over a row, provide a tooltip for the item table:RegisterEvents({ ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) @@ -256,14 +204,11 @@ }); frame.scrollTable = table; - table.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); - table.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); - table.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); - + -- Change the amount of displayed rows based on the size of the frame frame.AdjustScrollTableRows = function(this) local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); - newRows = (newRows < 3 and 3) or newRows; + newRows = (newRows < 4 and 4) or newRows; this.scrollTable:SetDisplayRows(newRows, 15); end; @@ -275,3 +220,23 @@ InventoriumItemMover:Show(); end + +function addon:SetFrameSettings(title, description, proceed, cancel, headers) + local frame = InventoriumItemMover; + + frame.lblTitle:SetText(title); + + frame.lblDescription:SetText(description); + + frame.btnMove:SetText(proceed.text); + frame.btnMove.tooltipTitle = proceed.tooltipTitle; + frame.btnMove.tooltip = proceed.tooltip; + frame.btnMove.OnClick = proceed.onClick; + + frame.btnCancel:SetText(cancel.text); + frame.btnCancel.tooltipTitle = cancel.tooltipTitle; + frame.btnCancel.tooltip = cancel.tooltip; + frame.btnCancel.OnClick = cancel.onClick; + + frame.scrollTable:SetDisplayCols(headers); +end