diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 3551bb4..fa5ca66 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9e0dc88..0455aca 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,18 @@ - + + + + + + + + + @@ -59,8 +67,8 @@ @@ -68,41 +76,11 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -111,8 +89,8 @@ - - + + @@ -121,28 +99,18 @@ - - + + - - + + - - - - - - - - - - - - + + @@ -151,18 +119,58 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -181,17 +189,16 @@ @@ -227,7 +234,7 @@ - + @@ -248,7 +255,7 @@ - + @@ -258,12 +265,6 @@ - - - - - - @@ -272,6 +273,27 @@ + + + + + + - - - + + + + + localhost @@ -361,14 +415,11 @@ - - - - - 1445044678361 - 1445044678361 + + 1445635607102 + 1445635607102 @@ -376,29 +427,29 @@ - - - - - - + + + + + + - - - + + + - - - - - + + + + + - + - - - + + + @@ -421,202 +472,98 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - + - - + + - + - - - - - - - - - + - + - - + + + + + + + + + + - - + + - + - - + + - + - - + + + + + + + + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/buy.lua b/buy.lua index ff41e1b..f50c7c4 100644 --- a/buy.lua +++ b/buy.lua @@ -432,6 +432,8 @@ function Aux.buy.exit() end function Aux.buy.on_open() + AuxBuySearchButton:Show() + AuxBuyStopButton:Hide() update_sheet() end @@ -825,18 +827,20 @@ end function AuxBuyQualityDropDown_Initialize() + local function on_click() + UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value) + end + UIDropDownMenu_AddButton{ text = ALL, value = -1, - func = AuxBuyQualityDropDown_OnClick, + func = on_click, } for i=0,getn(ITEM_QUALITY_COLORS)-2 do UIDropDownMenu_AddButton{ text = getglobal("ITEM_QUALITY"..i.."_DESC"), value = i, - func = function() - UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value) - end, + func = on_click, } end end diff --git a/buy.xml b/buy.xml index 75c8e12..f67e820 100644 --- a/buy.xml +++ b/buy.xml @@ -40,247 +40,8 @@ - - - - - - - - - - - - this:SetBackdropBorderColor(0.4, 0.4, 0.4) - this:RegisterForDrag('LeftButton') - - - this:StartMoving() - - - this:StopMovingOrSizing() - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - this:SetBackdropBorderColor(0.4, 0.4, 0.4) - this:SetBackdropColor(0.15, 0.15, 0.15) - - - - - - - - - - - - - - - - - - - Aux.log_frame_load() - - - Aux.log_frame_update(arg1) - - - ChatFrame_OnHyperlinkShow(arg1) - - - if arg1 == 1 then - this:ScrollUp() - elseif arg1 == -1 then - this:ScrollDown() - end - - - - - - - - - - - @@ -579,7 +340,7 @@ local sort_order = Aux.util.map(Aux.buy.modes[1].sort_order, function(column_order) return { column = Aux.buy.modes[1].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave) + this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].row_setter, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave) @@ -591,7 +352,7 @@ local sort_order = Aux.util.map(Aux.buy.modes[2].sort_order, function(column_order) return { column = Aux.buy.modes[2].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, Aux.buy.modes[2].columns, sort_order, Aux.buy.modes[2].on_cell_click, Aux.buy.modes[2].on_cell_enter, Aux.buy.modes[2].on_cell_leave) + this.sheet = Aux.sheet.create(this, Aux.buy.modes[2].columns, sort_order, Aux.buy.modes[2].row_setter, Aux.buy.modes[2].on_cell_click, Aux.buy.modes[2].on_cell_enter, Aux.buy.modes[2].on_cell_leave) @@ -603,7 +364,7 @@ local sort_order = Aux.util.map(Aux.buy.modes[3].sort_order, function(column_order) return { column = Aux.buy.modes[3].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, Aux.buy.modes[3].columns, sort_order, Aux.buy.modes[3].on_cell_click, Aux.buy.modes[3].on_cell_enter, Aux.buy.modes[3].on_cell_leave) + this.sheet = Aux.sheet.create(this, Aux.buy.modes[3].columns, sort_order, Aux.buy.modes[3].row_setter, Aux.buy.modes[3].on_cell_click, Aux.buy.modes[3].on_cell_enter, Aux.buy.modes[3].on_cell_leave) @@ -617,7 +378,7 @@ - + @@ -673,7 +434,7 @@ - + @@ -683,7 +444,7 @@ - + SmallMoneyFrame_OnLoad() @@ -700,7 +461,7 @@ + @@ -94,4 +169,173 @@ + + + + + + + + + + + this:SetBackdropBorderColor(0.4, 0.4, 0.4) + this:RegisterForDrag('LeftButton') + + + this:StartMoving() + + + this:StopMovingOrSizing() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this:SetBackdropBorderColor(0.4, 0.4, 0.4) + this:SetBackdropColor(0.15, 0.15, 0.15) + + + + + + + + + + + + + + + + + + + Aux.log_frame_load() + + + Aux.log_frame_update(arg1) + + + ChatFrame_OnHyperlinkShow(arg1) + + + if arg1 == 1 then + this:ScrollUp() + elseif arg1 == -1 then + this:ScrollDown() + end + + + + + + + + \ No newline at end of file diff --git a/info.lua b/info.lua index 34b24a9..33ac224 100644 --- a/info.lua +++ b/info.lua @@ -2,7 +2,7 @@ local TOOLTIP_LENGTH = 30 Aux.info = {} -local hyperlink_item, item_id, item_charges +local hyperlink_item, item_id, item_charges, item_signature, parse_item_signature, parse_hyperlink function Aux.info.container_item(bag, slot) local hyperlink = GetContainerItemLink(bag, slot) @@ -12,15 +12,16 @@ function Aux.info.container_item(bag, slot) end local container_item = hyperlink_item(hyperlink) - - local texture, count, locked, quality, readable, lootable, hyperlink = GetContainerItemInfo(bag, slot) + container_item.item_signature = item_signature(hyperlink) + + local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) container_item.texture = texture container_item.count = count container_item.locked = locked container_item.readable = readable container_item.lootable = lootable container_item.hyperlink = hyperlink - + container_item.tooltip = Aux.info.tooltip(function(tt) tt:SetBagItem(bag, slot) end) container_item.charges = item_charges(container_item.tooltip) @@ -154,6 +155,16 @@ function item_charges(tooltip) end end +function item_signature(hyperlink) + local item_id, suffix_id = parse_hyperlink(hyperlink) + return item_id..':'..suffix_id +end + +function parse_item_signature(item_signature) + local _, _, item_id, suffix_id = strfind(item_signature, '^(%d+):(%d+)$') + return item_id, suffix_id +end + function item_id(hyperlink) local _, _, id_string = strfind(hyperlink, "^.-:(%d*).*") return tonumber(id_string) diff --git a/list.lua b/list.lua index b20c76c..25c7e70 100644 --- a/list.lua +++ b/list.lua @@ -44,6 +44,9 @@ function Aux.sheet.render(sheet) for i, row in ipairs(rows) do local direction, rowR, rowG, rowB, rowA1, rowA2 = "Horizontal", 1, 1, 1, 0, 0 --row level coloring used for gradients local datum = data[i + offset] + if sheet.row_setter then + sheet.row_setter(row, datum) + end for j, column in sheet.columns do local cell = row[j] if datum then @@ -57,7 +60,7 @@ function Aux.sheet.render(sheet) end end -function Aux.sheet.create(frame, columns, sort_order, on_cell_click, on_cell_enter, on_cell_leave) +function Aux.sheet.create(frame, columns, sort_order, row_setter, on_cell_click, on_cell_enter, on_cell_leave) local sheet local name = (frame:GetName() or '')..'ScrollSheet' @@ -192,6 +195,7 @@ function Aux.sheet.create(frame, columns, sort_order, on_cell_click, on_cell_ent columns = columns, data = {}, sort_order = sort_order, + row_setter = row_setter, on_cell_click = on_cell_click, on_cell_enter = on_cell_enter, on_cell_leave = on_cell_leave, @@ -254,7 +258,7 @@ function Aux.list.sort(sheet, column_index) local column = sheet.columns[column_index] - if sheet.sort_order[1].column == column then + if sheet.sort_order[1] and sheet.sort_order[1].column == column then sheet.sort_order[1].sort_ascending = not sheet.sort_order[1].sort_ascending else sheet.sort_order = Aux.util.filter(sheet.sort_order, function(sort_info) return not sort_info.column == column end) diff --git a/options.xml b/options.xml index 5dd57fe..b703553 100644 --- a/options.xml +++ b/options.xml @@ -19,7 +19,11 @@ - Aux.options.show() + if AuxFrame:IsVisible() then + AuxFrame:Hide() + else + AuxFrame:Show() + end diff --git a/sell.lua b/sell.lua index 94485ef..5defc01 100644 --- a/sell.lua +++ b/sell.lua @@ -2,15 +2,192 @@ Aux.sell = {} auxSellEntries = {} -- persisted ------------------------------------------ +local inventory_data local bestPriceOurStackSize local current_auction ------------------------------------------ +local set_auction, update_auction_listing, update_inventory_listing, record_auction, undercut, item_class_index, item_subclass_index, report, select_entry, update_recommendation, refresh_entries, auction_candidates, charge_classes, get_stack_size_slider_value -local record_auction, undercut, item_class_index, item_subclass_index, set_message, report, select_entry, update_recommendation, refresh_entries, availability, charge_classes, get_stack_size_slider_value +Aux.sell.inventory_listing_config = { + on_cell_click = function (sheet, row_index, column_index) + local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) + set_auction(sheet.data[data_index]) + end, + + on_cell_enter = function (sheet, row_index, column_index) + sheet.rows[row_index].highlight:SetAlpha(.5) + end, + + on_cell_leave = function (sheet, row_index, column_index) + local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) + if not (current_auction and sheet.data[data_index] == current_auction) then + sheet.rows[row_index].highlight:SetAlpha(0) + end + end, + + row_setter = function(row, datum) + if current_auction and datum == current_auction then + row.highlight:SetAlpha(.5) + else + row.highlight:SetAlpha(0) + end + end, + + columns = { + { + title = 'Item', + width = 175, + comparator = function(row1, row2) return Aux.util.compare(row1.name, row2.name, Aux.util.GT) end, + cell_initializer = function(cell) + local icon = CreateFrame('Button', nil, cell) + local icon_texture = icon:CreateTexture(nil, 'BORDER') + icon_texture:SetAllPoints(icon) + icon.icon_texture = icon_texture + local normal_texture = icon:CreateTexture(nil) + normal_texture:SetPoint('CENTER', 0, 0) + normal_texture:SetWidth(22) + normal_texture:SetHeight(22) + normal_texture:SetTexture('Interface\\Buttons\\UI-Quickslot2') + icon:SetNormalTexture(normal_texture) + icon:SetPoint('LEFT', cell) + icon:SetWidth(12) + icon:SetHeight(12) + icon:SetNormalTexture('Interface\\Buttons\\UI-Quickslot2') + icon:SetPushedTexture('Interface\\Buttons\\UI-Quickslot-Depress') + icon:SetHighlightTexture('Interface\\Buttons\\ButtonHilight-Square') + local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall') + text:SetPoint("LEFT", icon, "RIGHT", 1, 0) + text:SetPoint('TOPRIGHT', cell) + text:SetPoint('BOTTOMRIGHT', cell) + text:SetJustifyV('TOP') + text:SetJustifyH('LEFT') + text:SetTextColor(0.8, 0.8, 0.8) + cell.text = text + cell.icon = icon + end, + cell_setter = function(cell, datum) + cell.icon.icon_texture:SetTexture(datum.texture) + cell.text:SetText('['..datum.name..']') + local color = ITEM_QUALITY_COLORS[datum.quality] + cell.text:SetTextColor(color.r, color.g, color.b) + end, + }, + { + title = 'Qty', + width = 23, + comparator = function(datum1, datum2) return Aux.util.compare(datum1.aux_quantity, datum2.aux_quantity, Aux.util.LT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, datum) + cell.text:SetText(datum.aux_quantity) + end, + }, + }, + sort_order = {{column = 1, order = 'ascending' }}, +} + +Aux.sell.auction_listing_config = { + on_cell_click = function (sheet, row_index, column_index) + local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) + AuxSellEntry_OnClick(sheet.data[data_index]) + end, + + on_cell_enter = function (sheet, row_index, column_index) + sheet.rows[row_index].highlight:SetAlpha(.5) + end, + + on_cell_leave = function (sheet, row_index, column_index) + local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) + if not (current_auction and auxSellEntries[current_auction.name] and sheet.data[data_index] == auxSellEntries[current_auction.name].selected) then + sheet.rows[row_index].highlight:SetAlpha(0) + end + end, + + row_setter = function(row, datum) + if datum and current_auction and auxSellEntries[current_auction.name] and auxSellEntries[current_auction.name].selected == datum then + row.highlight:SetAlpha(.5) + else + row.highlight:SetAlpha(0) + end + end, + + columns = { + { + title = 'Avail', + width = 40, + comparator = function(row1, row2) return Aux.util.compare(row1.count, row2.count, Aux.util.LT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, row) + cell.text:SetText(row.count) + end, + }, + { + title = 'Yours', + width = 40, + comparator = function(row1, row2) return Aux.util.compare(row1.yours, row2.yours, Aux.util.LT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, row) + cell.text:SetText(row.yours) + end, + }, + { + title = 'Max Left', + width = 55, + comparator = function(row1, row2) return Aux.util.compare(row1.max_time_left, row2.max_time_left, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('CENTER'), + cell_setter = function(cell, datum) + local text + if datum.max_time_left == 1 then + text = '30m' + elseif datum.max_time_left == 2 then + text = '2h' + elseif datum.max_time_left == 3 then + text = '8h' + elseif datum.max_time_left == 4 then + text = '24h' + end + cell.text:SetText(text) + end, + }, + { + title = 'Buy/ea', + width = 70, + comparator = function(row1, row2) return Aux.util.compare(row1.unit_buyout_price, row2.unit_buyout_price, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, row) + cell.text:SetText(Aux.util.money_string(row.unit_buyout_price)) + end, + }, + { + title = 'Qty', + width = 23, + comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, row) + cell.text:SetText(row.stack_size) + end, + }, + { + title = 'Buy', + width = 70, + comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'), + cell_setter = function(cell, row) + cell.text:SetText(Aux.util.money_string(row.buyout_price)) + end, + }, + }, + sort_order = {{column = 2, order = 'ascending' }, {column = 4, order = 'ascending'}}, +} + +function update_inventory_listing() + Aux.list.populate(AuxSellInventoryListing.sheet, inventory_data) +end + +function update_auction_listing() + Aux.list.populate(AuxSellAuctionsListing.sheet, current_auction and auxSellEntries[current_auction.name] or {}) +end function Aux.sell.on_open() AuxSellStackSizeSlider:SetValueStep(1) @@ -20,6 +197,11 @@ function Aux.sell.on_open() AuxSellStackCountSliderText:SetText('Stack Count') Aux.sell.validate_parameters() + + inventory_data = auction_candidates() + + update_inventory_listing() + update_auction_listing() end function Aux.sell.duration_radio_button_on_click(index) @@ -71,8 +253,8 @@ end ----------------------------------------- function Aux.sell.post_auctions() - if current_auction and PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.sell.index then - local name, stack_size, buyout_price, stack_count = current_auction.name, get_stack_size_slider_value(), MoneyInputFrame_GetCopper(AuxSellParametersBuyoutPrice), AuxSellStackCountSlider:GetValue() + if current_auction then + local name, hyperlink, stack_size, buyout_price, stack_count = current_auction.name, current_auction.hyperlink, get_stack_size_slider_value(), MoneyInputFrame_GetCopper(AuxSellParametersBuyoutPrice), AuxSellStackCountSlider:GetValue() local duration if AuctionFrameAuctions.duration == 120 then duration = 2 @@ -101,11 +283,9 @@ function Aux.sell.post_auctions() end end Aux.sell.clear_auction() - report(name, stack_size, buyout_price, posted) + report(hyperlink, stack_size, buyout_price, posted) end ) - else - Aux.orig.AuctionsCreateAuctionButton_OnClick() end end @@ -115,16 +295,6 @@ function Aux.sell.AuctionSellItemButton_OnEvent() Aux.orig.AuctionSellItemButton_OnEvent() end ------------------------------------------ - -function set_message(msg) - Aux_HideElems(Aux.tabs.sell.recommendationElements) - AuxMessage:SetText(msg) - AuxMessage:Show() -end - ------------------------------------------ - function select_entry() if current_auction and auxSellEntries[current_auction.name] and not auxSellEntries[current_auction.name].selected then @@ -134,11 +304,11 @@ function select_entry() ----- find the best price per stacksize and overall ----- for _,auxEntry in ipairs(auxSellEntries[current_auction.name]) do - if not bestPrice[auxEntry.stackSize] or bestPrice[auxEntry.stackSize].itemPrice >= auxEntry.itemPrice then - bestPrice[auxEntry.stackSize] = auxEntry + if not bestPrice[auxEntry.stack_size] or bestPrice[auxEntry.stack_size].unit_buyout_price >= auxEntry.unit_buyout_price then + bestPrice[auxEntry.stack_size] = auxEntry end - if not absoluteBest or absoluteBest.itemPrice > auxEntry.itemPrice then + if not absoluteBest or absoluteBest.unit_buyout_price > auxEntry.unit_buyout_price then absoluteBest = auxEntry end end @@ -155,7 +325,7 @@ end ----------------------------------------- function get_stack_size_slider_value() - if current_auction.has_charges then + if current_auction.charges then return AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider:GetValue()] else return AuxSellStackSizeSlider:GetValue() @@ -188,9 +358,9 @@ function update_recommendation() if not current_auction then AuxSellRefreshButton:Disable() - AuxSellItem:SetNormalTexture(nil) - AuxSellItemName:SetText() - AuxSellItemCount:SetText() + AuxSellParametersItemIconTexture:SetTexture(nil) + AuxSellParametersItemCount:SetText() + AuxSellParametersItemName:SetText() MoneyInputFrame_SetCopper(AuxSellParametersBuyoutPrice, 0) MoneyInputFrame_SetCopper(AuxSellParametersStartPrice, 0) @@ -199,24 +369,24 @@ function update_recommendation() AuxSellStackSize:SetNumber(0) AuxSellStackCountSlider:SetMinMaxValues(0,0) AuxSellStackCount:SetNumber(0) - - set_message("Drag an item to the Auction Item area\n\nto see recommended pricing information") else AuxSellStackSize:SetNumber(AuxSellStackSizeSlider:GetValue()) AuxSellStackCount:SetNumber(AuxSellStackCountSlider:GetValue()) - AuxSellItem:SetNormalTexture(current_auction.texture) - AuxSellItemName:SetText(current_auction.name) + AuxSellParametersItemIconTexture:SetTexture(current_auction.texture) + AuxSellParametersItemName:SetText(current_auction.name) + local color = ITEM_QUALITY_COLORS[current_auction.quality] + AuxSellParametersItemName:SetTextColor(color.r, color.g, color.b) if get_stack_size_slider_value() > 1 then - AuxSellItemCount:SetText(get_stack_size_slider_value()) - AuxSellItemCount:Show() + AuxSellParametersItemCount:SetText(get_stack_size_slider_value()) + AuxSellParametersItemCount:Show() else - AuxSellItemCount:Hide() + AuxSellParametersItemCount:Hide() end AuxSellRefreshButton:Enable() - MoneyFrame_Update("AuctionsDepositMoneyFrame", floor(current_auction.vendor_price_per_unit * current_auction.deposit_factor * (current_auction.has_charges and 1 or get_stack_size_slider_value())) * AuxSellStackCountSlider:GetValue() * AuctionFrameAuctions.duration / 120) + MoneyFrame_Update("AuctionsDepositMoneyFrame", floor(current_auction.vendor_price_per_unit * current_auction.deposit_factor * (current_auction.charges and 1 or get_stack_size_slider_value())) * AuxSellStackCountSlider:GetValue() * AuctionFrameAuctions.duration / 120) if auxSellEntries[current_auction.name] and auxSellEntries[current_auction.name].selected then if not auxSellEntries[current_auction.name].created or GetTime() - auxSellEntries[current_auction.name].created > 1800 then @@ -224,47 +394,46 @@ function update_recommendation() AuxRecommendStaleText:Show() end - local newBuyoutPrice = auxSellEntries[current_auction.name].selected.itemPrice * get_stack_size_slider_value() + local newBuyoutPrice = auxSellEntries[current_auction.name].selected.unit_buyout_price * get_stack_size_slider_value() - if auxSellEntries[current_auction.name].selected.numYours == 0 then + if auxSellEntries[current_auction.name].selected.yours == 0 then newBuyoutPrice = undercut(newBuyoutPrice) end local newStartPrice = newBuyoutPrice * 0.95 - AuxMessage:Hide() Aux_ShowElems(Aux.tabs.sell.recommendationElements) - AuxRecommendText:SetText("Recommended Buyout Price") - AuxRecommendPerStackText:SetText("for a stack of "..get_stack_size_slider_value()) +-- AuxRecommendText:SetText("Recommended Buyout Price") +-- AuxRecommendPerStackText:SetText("for a stack of "..get_stack_size_slider_value()) - AuxRecommendItemTex:SetNormalTexture(current_auction.texture) - if AuxSellStackSize:GetNumber() > 1 then - AuxRecommendItemTexCount:SetText(get_stack_size_slider_value()) - AuxRecommendItemTexCount:Show() - else - AuxRecommendItemTexCount:Hide() - end +-- AuxRecommendItemTex:SetNormalTexture(current_auction.texture) +-- if AuxSellStackSize:GetNumber() > 1 then +-- AuxRecommendItemTexCount:SetText(get_stack_size_slider_value()) +-- AuxRecommendItemTexCount:Show() +-- else +-- AuxRecommendItemTexCount:Hide() +-- end - MoneyFrame_Update("AuxRecommendPerItemPrice", Aux_Round(get_stack_size_slider_value() > 0 and newBuyoutPrice / get_stack_size_slider_value() or 0)) - MoneyFrame_Update("AuxRecommendPerStackPrice", Aux_Round(newBuyoutPrice)) +-- MoneyFrame_Update("AuxRecommendPerItemPrice", Aux_Round(get_stack_size_slider_value() > 0 and newBuyoutPrice / get_stack_size_slider_value() or 0)) +-- MoneyFrame_Update("AuxRecommendPerStackPrice", Aux_Round(newBuyoutPrice)) MoneyInputFrame_SetCopper(AuxSellParametersBuyoutPrice, Aux_Round(newBuyoutPrice)) MoneyInputFrame_SetCopper(AuxSellParametersStartPrice, Aux_Round(newStartPrice)) - if auxSellEntries[current_auction.name].selected.stackSize == auxSellEntries[current_auction.name][1].stackSize and auxSellEntries[current_auction.name].selected.buyoutPrice == auxSellEntries[current_auction.name][1].buyoutPrice then - AuxRecommendBasisText:SetText("(based on cheapest)") - elseif bestPriceOurStackSize and auxSellEntries[current_auction.name].selected.stackSize == bestPriceOurStackSize.stackSize and auxSellEntries[current_auction.name].selected.buyoutPrice == bestPriceOurStackSize.buyoutPrice then - AuxRecommendBasisText:SetText("(based on cheapest stack of the same size)") - else - AuxRecommendBasisText:SetText("(based on auction selected below)") - end +-- if auxSellEntries[current_auction.name].selected.stack_size == auxSellEntries[current_auction.name][1].stack_size and auxSellEntries[current_auction.name].selected.buyout_price == auxSellEntries[current_auction.name][1].buyout_price then +-- AuxRecommendBasisText:SetText("(based on cheapest)") +-- elseif bestPriceOurStackSize and auxSellEntries[current_auction.name].selected.stack_size == bestPriceOurStackSize.stack_size and auxSellEntries[current_auction.name].selected.buyout_price == bestPriceOurStackSize.buyout_price then +-- AuxRecommendBasisText:SetText("(based on cheapest stack of the same size)") +-- else +-- AuxRecommendBasisText:SetText("(based on auction selected below)") +-- end elseif auxSellEntries[current_auction.name] then - set_message("No auctions were found for \n\n"..current_auction.name) + Aux.log("No auctions were found for "..current_auction.name) auxSellEntries[current_auction.name] = nil else - Aux_HideElems(Aux.tabs.sell.shownElements) + -- Aux_HideElems(Aux.tabs.sell.shownElements) end end @@ -273,7 +442,7 @@ end function Aux.sell.quantity_update() if current_auction then - AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.has_charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider.GetValue()]] or floor(current_auction.availability[0] / get_stack_size_slider_value())) + AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider.GetValue()]] or floor(current_auction.availability[0] / get_stack_size_slider_value())) end select_entry() update_recommendation() @@ -289,51 +458,33 @@ end ----------------------------------------- -function Aux.sell.set_auction(bag, slot) - - local container_item = Aux.info.container_item(bag, slot) - - if container_item then - - ClearCursor() - PickupContainerItem(bag,slot) - ClickAuctionSellItemButton() - local auction_sell_item = Aux.info.auction_sell_item() - ClearCursor() - ClickAuctionSellItemButton() - ClearCursor() - - if auction_sell_item then +function set_auction(auction_candidate) - Aux.scan.abort(function() - - current_auction = { - name = container_item.name, - texture = container_item.texture, - class = container_item.type, - subclass = container_item.subtype, - deposit_factor = auction_sell_item.deposit_factor, - vendor_price_per_unit = auction_sell_item.vendor_price_per_unit, - has_charges = container_item.charges ~= nil, - availability = availability(container_item.name) - } + Aux.scan.abort(function() + + current_auction = auction_candidate + + local charge_classes = charge_classes(current_auction.availability) + AuxSellStackSizeSlider.charge_classes = charge_classes + local stack_size_slider_max = current_auction.charges and getn(charge_classes) or min(current_auction.max_stack, current_auction.availability[0]) + AuxSellStackSizeSlider:SetMinMaxValues(1, stack_size_slider_max) + + AuxSellStackSizeSlider:SetValue(stack_size_slider_max) + AuxSellStackCountSlider:SetValue(1) + + Aux.sell.quantity_update() + + if not auxSellEntries[current_auction.name] then + refresh_entries() + end + + select_entry() + update_recommendation() + update_auction_listing() + update_inventory_listing() + + end) - AuxSellStackSizeSlider.charge_classes = charge_classes(current_auction.availability) - AuxSellStackSizeSlider:SetMinMaxValues(1, current_auction.has_charges and getn(charge_classes(current_auction.availability)) or min(container_item.max_stack, current_auction.availability[0])) - AuxSellStackSizeSlider:SetValue(current_auction.has_charges and Aux.util.index_of(container_item.charges, charge_classes(current_auction.availability)) or container_item.count) - AuxSellStackCountSlider:SetValue(1) - Aux.sell.quantity_update() - - if not auxSellEntries[current_auction.name] then - refresh_entries() - end - - select_entry() - update_recommendation() - - end) - end - end end function charge_classes(availability) @@ -345,20 +496,66 @@ function charge_classes(availability) return charge_classes end -function availability(name) - local availability = {} - for bag = 0, 4 do - if GetBagName(bag) then - for slot = 1, GetContainerNumSlots(bag) do - local item_info = Aux.info.container_item(bag, slot) - if item_info and item_info.name == name then - local charge_class = item_info.charges or 0 - availability[charge_class] = (availability[charge_class] or 0) + item_info.count +function auction_candidates() + + local auction_candidate_map = {} + + Aux.util.without_sound(function() + Aux.util.without_errors(function() + + for bag = 0, 4 do + if GetBagName(bag) then + for slot = 1, GetContainerNumSlots(bag) do + local item_info = Aux.info.container_item(bag, slot) + + if item_info then + + local charge_class = item_info.charges or 0 + + ClearCursor() + PickupContainerItem(bag,slot) + ClickAuctionSellItemButton() + local auction_sell_item = Aux.info.auction_sell_item() + ClearCursor() + ClickAuctionSellItemButton() + ClearCursor() + + if auction_sell_item then + if not auction_candidate_map[item_info.item_signature] then + + auction_candidate_map[item_info.item_signature] = { + hyperlink = item_info.hyperlink, + name = item_info.name, + texture = item_info.texture, + quality = item_info.quality, + class = item_info.type, + subclass = item_info.subtype, + deposit_factor = auction_sell_item.deposit_factor, + vendor_price_per_unit = auction_sell_item.vendor_price_per_unit, + charges = item_info.charges, + aux_quantity = item_info.charges or item_info.count, + max_stack = item_info.max_stack, + availability = { [charge_class]=item_info.count }, + } + else + local candidate = auction_candidate_map[item_info.item_signature] + candidate.availability[charge_class] = (candidate.availability[charge_class] or 0) + item_info.count + candidate.aux_quantity = candidate.aux_quantity + (item_info.charges or item_info.count) + end + end + end + end end end - end + + end) + end) + + local auction_candidates = {} + for _, auction_candidate in pairs(auction_candidate_map) do + tinsert(auction_candidates, auction_candidate) end - return availability + return auction_candidates end function refresh_entries() @@ -372,7 +569,7 @@ function refresh_entries() -- local class_index = item_class_index(current_auction.class) -- local subclass_index = item_subclass_index(class_index, current_auction.subclass) - set_message('Scanning auctions ...') + Aux.log('Scanning auctions ...') Aux.scan.start{ query = { name = name, @@ -381,7 +578,7 @@ function refresh_entries() }, page = 0, on_start_page = function(page, total_pages) - set_message('Scanning auctions: page ' .. page + 1 .. (total_pages > 0 and ' out of ' .. total_pages or '') .. ' ...') + Aux.log('Scanning page ' .. page + 1 .. (total_pages > 0 and ' out of ' .. total_pages or '') .. ' ...') end, on_read_auction = function(i) local auction_item = Aux.info.auction_item(i) @@ -408,98 +605,92 @@ function refresh_entries() end end ------------------------------------------ - function Aux.sell.scrollbar_update() - local numrows - if not current_auction or not auxSellEntries[current_auction.name] then - numrows = 0 - else - numrows = getn(auxSellEntries[current_auction.name]) - end +-- local numrows +-- if not current_auction or not auxSellEntries[current_auction.name] then +-- numrows = 0 +-- else +-- numrows = getn(auxSellEntries[current_auction.name]) +-- end - FauxScrollFrame_Update(AuxScrollFrame, numrows, 12, 16) + -- FauxScrollFrame_Update(AuxScrollFrame, numrows, 12, 16) - for line = 1, 12 do +-- for line = 1, 12 do - local dataOffset = line + FauxScrollFrame_GetOffset(AuxScrollFrame) - local lineEntry = getglobal("AuxSellEntry"..line) +-- local dataOffset = 1 -- line + FauxScrollFrame_GetOffset(AuxScrollFrame) +-- local lineEntry = getglobal("AuxSellEntry"..line) +-- +-- if numrows <= 12 then +-- lineEntry:SetWidth(603) +-- else +-- lineEntry:SetWidth(585) +-- end +-- +-- lineEntry:SetID(dataOffset) - if numrows <= 12 then - lineEntry:SetWidth(603) - else - lineEntry:SetWidth(585) - end - - lineEntry:SetID(dataOffset) - - if current_auction and dataOffset <= numrows and auxSellEntries[current_auction.name] then - - local entry = auxSellEntries[current_auction.name][dataOffset] - - if auxSellEntries[current_auction.name].selected and entry.itemPrice == auxSellEntries[current_auction.name].selected.itemPrice and entry.stackSize == auxSellEntries[current_auction.name].selected.stackSize then - lineEntry:LockHighlight() - else - lineEntry:UnlockHighlight() - end - - local lineEntry_stacks = getglobal("AuxSellEntry"..line.."_Stacks") - local lineEntry_time = getglobal("AuxSellEntry"..line.."_Time") - - if entry.maxTimeLeft == 1 then - lineEntry_time:SetText("Short") - elseif entry.maxTimeLeft == 2 then - lineEntry_time:SetText("Medium") - elseif entry.maxTimeLeft == 3 then - lineEntry_time:SetText("Long") - elseif entry.maxTimeLeft == 4 then - lineEntry_time:SetText("Very Long") - end - - if entry.stackSize == get_stack_size_slider_value() then - lineEntry_stacks:SetTextColor(0.2, 0.9, 0.2) - else - lineEntry_stacks:SetTextColor(1.0, 1.0, 1.0) - end - - local own - if entry.numYours == 0 then - own = "" - elseif - entry.numYours == entry.count then - own = "(yours)" - else - own = "(yours: "..entry.numYours..")" - end - - local tx = string.format("%i %s of %i %s", entry.count, Aux_PluralizeIf("stack", entry.count), entry.stackSize, own) - lineEntry_stacks:SetText(tx) - - MoneyFrame_Update("AuxSellEntry"..line.."_UnitPrice", Aux_Round(entry.buyoutPrice/entry.stackSize)) - MoneyFrame_Update("AuxSellEntry"..line.."_TotalPrice", Aux_Round(entry.buyoutPrice)) - - lineEntry:Show() - else - lineEntry:Hide() - end - end +-- if current_auction and dataOffset <= numrows and auxSellEntries[current_auction.name] then +-- +-- local entry = auxSellEntries[current_auction.name][dataOffset] +-- +-- if auxSellEntries[current_auction.name].selected and entry.unit_buyout_price == auxSellEntries[current_auction.name].selected.unit_buyout_price and entry.stack_size == auxSellEntries[current_auction.name].selected.stack_size then +-- lineEntry:LockHighlight() +-- else +-- lineEntry:UnlockHighlight() +-- end +-- +-- local lineEntry_stacks = getglobal("AuxSellEntry"..line.."_Stacks") +-- local lineEntry_time = getglobal("AuxSellEntry"..line.."_Time") +-- +-- if entry.max_time_left == 1 then +-- lineEntry_time:SetText("Short") +-- elseif entry.max_time_left == 2 then +-- lineEntry_time:SetText("Medium") +-- elseif entry.max_time_left == 3 then +-- lineEntry_time:SetText("Long") +-- elseif entry.max_time_left == 4 then +-- lineEntry_time:SetText("Very Long") +-- end +-- +-- if entry.stack_size == get_stack_size_slider_value() then +-- lineEntry_stacks:SetTextColor(0.2, 0.9, 0.2) +-- else +-- lineEntry_stacks:SetTextColor(1.0, 1.0, 1.0) +-- end +-- +-- local own +-- if entry.yours == 0 then +-- own = "" +-- elseif +-- entry.yours == entry.count then +-- own = "(yours)" +-- else +-- own = "(yours: "..entry.yours..")" +-- end +-- +-- local tx = string.format("%i %s of %i %s", entry.count, Aux_PluralizeIf("stack", entry.count), entry.stack_size, own) +-- lineEntry_stacks:SetText(tx) +-- +-- MoneyFrame_Update("AuxSellEntry"..line.."_UnitPrice", Aux_Round(entry.buyout_price/entry.stack_size)) +-- MoneyFrame_Update("AuxSellEntry"..line.."_TotalPrice", Aux_Round(entry.buyout_price)) +-- +-- lineEntry:Show() +-- else +-- lineEntry:Hide() +-- end +-- end end ------------------------------------------ +function AuxSellEntry_OnClick(entry) -function AuxSellEntry_OnClick() - local entryIndex = this:GetID() - - auxSellEntries[current_auction.name].selected = auxSellEntries[current_auction.name][entryIndex] + auxSellEntries[current_auction.name].selected = entry + update_auction_listing() update_recommendation() PlaySound("igMainMenuOptionCheckBoxOn") end ------------------------------------------ - function AuxSellRefreshButton_OnClick() Aux.scan.abort(function() refresh_entries() @@ -523,25 +714,25 @@ function record_auction(name, stack_size, buyout_price, duration, owner) auxSellEntries[name] = auxSellEntries[name] or { created = GetTime() } local entry for _, existingEntry in ipairs(auxSellEntries[name]) do - if existingEntry.buyoutPrice == buyout_price and existingEntry.stackSize == stack_size then + if existingEntry.buyout_price == buyout_price and existingEntry.stack_size == stack_size then entry = existingEntry end end if entry then entry.count = entry.count + 1 - entry.numYours = entry.numYours + (owner == UnitName("player") and 1 or 0) - entry.maxTimeLeft = max(entry.maxTimeLeft, duration) + entry.yours = entry.yours + (owner == UnitName("player") and 1 or 0) + entry.max_time_left = max(entry.max_time_left, duration) else entry = { - stackSize = stack_size, - buyoutPrice = buyout_price, - itemPrice = buyout_price / stack_size, - maxTimeLeft = duration, - count = 1, - numYours = owner == UnitName("player") and 1 or 0, + stack_size = stack_size, + buyout_price = buyout_price, + unit_buyout_price = buyout_price / stack_size, + max_time_left = duration, + count = 1, + yours = owner == UnitName("player") and 1 or 0, } tinsert(auxSellEntries[name], entry) - table.sort(auxSellEntries[name], function(a,b) return a.itemPrice < b.itemPrice end) + table.sort(auxSellEntries[name], function(a,b) return a.unit_buyout_price < b.unit_buyout_price end) end end end @@ -574,30 +765,12 @@ end ----------------------------------------- -function report(item_name, stack_size, buyout_price, posted) - AuxSellReportHTML:SetText(string.format( - [[ - - -

Aux Sell Report

-
-

- %i auctions of %s posted -

- Stack size: %i -
- Stack price: %s -

- - - ]], - posted, - item_name, - stack_size, - Aux.util.format_money(buyout_price) +function report(hyperlink, stack_size, buyout_price, posted) + Aux.log(string.format( + '%i auctions of %s x %i posted for %s each)', + posted, + hyperlink, + stack_size, + Aux.util.money_string(buyout_price) )) - - AuxSellReportHTML:SetSpacing(3) - - AuxSellReport:Show() end diff --git a/sell.xml b/sell.xml index 2131f2d..869f364 100644 --- a/sell.xml +++ b/sell.xml @@ -1,379 +1,63 @@ -