From a6d31cfc2c07fab5a6eca20253c3e81a236a1cd3 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 9 Nov 2015 23:39:56 +0100 Subject: [PATCH 01/31] added shift click linking to the search panels --- filter_search_frame.lua | 4 ++++ item_search_frame.lua | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/filter_search_frame.lua b/filter_search_frame.lua index 64b87ea..a993400 100644 --- a/filter_search_frame.lua +++ b/filter_search_frame.lua @@ -744,6 +744,10 @@ function private.on_row_click(entry) if IsControlKeyDown() then DressUpItemLink(entry.hyperlink) + elseif IsShiftKeyDown() then + if ChatFrameEditBox:IsVisible() then + ChatFrameEditBox:Insert(entry.hyperlink) + end else find_auction(entry, buyout_mode, express_mode) end diff --git a/item_search_frame.lua b/item_search_frame.lua index 3325e06..7311ecd 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -720,6 +720,10 @@ function public.on_row_click(entry) if IsControlKeyDown() then DressUpItemLink(entry.hyperlink) + elseif IsShiftKeyDown() then + if ChatFrameEditBox:IsVisible() then + ChatFrameEditBox:Insert(entry.hyperlink) + end else find_auction(entry, buyout_mode, express_mode) end From d4a2822533a30b09cc1bd48f911b5c2e72c8c87f Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 9 Nov 2015 23:51:17 +0100 Subject: [PATCH 02/31] fixed the quality colors in the inventory listing of the post panel --- info.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.lua b/info.lua index 220c716..a59be78 100644 --- a/info.lua +++ b/info.lua @@ -13,7 +13,7 @@ function public.container_item(bag, slot) local item_id, suffix_id, unique_id, enchant_id = private.parse_hyperlink(hyperlink) local item_info = public.item(item_id, suffix_id, unique_id, enchant_id) - local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) + local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working? local tooltip = public.tooltip(function(tt) tt:SetBagItem(bag, slot) end) return { @@ -31,7 +31,7 @@ function public.container_item(bag, slot) level = item_info.level, type = item_info.type, subtype = item_info.subtype, - quality = quality, + quality = item_info.quality, max_stack = item_info.max_stack, count = count, From 7d271b4a1bf8307d4a583c5dab6d0a51db20fc2f Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 10 Nov 2015 22:14:59 +0100 Subject: [PATCH 03/31] added safety check to buying by confirmation in case some other addon or something changes the page --- filter_search_frame.lua | 26 ++++++++++++++------------ item_search_frame.lua | 26 ++++++++++++++------------ manage_frame.lua | 28 +++++++++++++++------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/filter_search_frame.lua b/filter_search_frame.lua index a993400..e8064a8 100644 --- a/filter_search_frame.lua +++ b/filter_search_frame.lua @@ -696,18 +696,20 @@ function find_auction(entry, buyout_mode, express_mode) Aux.scan.abort() else public.dialog_action = function() - if GetMoney() >= amount then - PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxFilterSearchFrameResultsConfirmationContentBid)) - Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(buyout_mode and amount or MoneyInputFrame_GetCopper(AuxFilterSearchFrameResultsConfirmationContentBid))..'.') - entry.gone = true - refresh = true - else - Aux.log('Not enough money.') - end - Aux.scan.abort() - AuxFilterSearchFrameFiltersSearchButton:Enable() - AuxFilterSearchFrameResultsConfirmation:Hide() - update_sheet() + if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then + if GetMoney() >= amount then + PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxFilterSearchFrameResultsConfirmationContentBid)) + Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(buyout_mode and amount or MoneyInputFrame_GetCopper(AuxFilterSearchFrameResultsConfirmationContentBid))..'.') + entry.gone = true + refresh = true + else + Aux.log('Not enough money.') + end + Aux.scan.abort() + AuxFilterSearchFrameFiltersSearchButton:Enable() + AuxFilterSearchFrameResultsConfirmation:Hide() + update_sheet() + end end AuxFilterSearchFrameResultsConfirmationContentActionButton:Enable() end diff --git a/item_search_frame.lua b/item_search_frame.lua index 7311ecd..59c0551 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -672,18 +672,20 @@ function find_auction(entry, buyout_mode, express_mode) Aux.scan.abort() else public.dialog_action = function() - if GetMoney() >= amount then - PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid)) - Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(buyout_mode and amount or MoneyInputFrame_GetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid))..'.') - entry.gone = true - refresh = true - else - Aux.log('Not enough money.') - end - Aux.scan.abort() - AuxItemSearchFrameItemRefreshButton:Enable() - AuxItemSearchFrameAuctionsConfirmation:Hide() - update_listing() + if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then + if GetMoney() >= amount then + PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid)) + Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(buyout_mode and amount or MoneyInputFrame_GetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid))..'.') + entry.gone = true + refresh = true + else + Aux.log('Not enough money.') + end + Aux.scan.abort() + AuxItemSearchFrameItemRefreshButton:Enable() + AuxItemSearchFrameAuctionsConfirmation:Hide() + update_listing() + end end AuxItemSearchFrameAuctionsConfirmationContentActionButton:Enable() end diff --git a/manage_frame.lua b/manage_frame.lua index 142c46d..0438e5a 100644 --- a/manage_frame.lua +++ b/manage_frame.lua @@ -475,20 +475,22 @@ function private.find_auction(entry, action, express_mode) Aux.scan.abort() else public.dialog_action = function() - if action == 'cancel' then - CancelAuction(auction_info.index) - entry.gone = true - Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity) - elseif GetMoney() >= amount then - PlaceAuctionBid('bidder', auction_info.index, action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount) - Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount)..'.') - entry.gone = true - else - Aux.log('Not enough money.') + if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then + if action == 'cancel' then + CancelAuction(auction_info.index) + entry.gone = true + Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity) + elseif GetMoney() >= amount then + PlaceAuctionBid('bidder', auction_info.index, action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount) + Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount)..'.') + entry.gone = true + else + Aux.log('Not enough money.') + end + Aux.scan.abort() + AuxManageFrameListingDialog:Hide() + public.update_listing() end - Aux.scan.abort() - AuxManageFrameListingDialog:Hide() - public.update_listing() end AuxManageFrameListingDialogContentActionButton:Enable() end From d4774272477d5e08e957f986b18021b916c43a13 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 10 Nov 2015 22:52:05 +0100 Subject: [PATCH 04/31] small bugfix in manage tab --- manage_frame.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_frame.lua b/manage_frame.lua index 0438e5a..7865967 100644 --- a/manage_frame.lua +++ b/manage_frame.lua @@ -475,7 +475,7 @@ function private.find_auction(entry, action, express_mode) Aux.scan.abort() else public.dialog_action = function() - if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then + if private.create_record(Aux.info.auction(auction_info.index, 'bidder')).signature == entry.signature then if action == 'cancel' then CancelAuction(auction_info.index) entry.gone = true From 4f907f9c9e86aaaced62b97016c6635a41bb43cf Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 16 Nov 2015 10:31:16 +0100 Subject: [PATCH 05/31] fixed issue of auctions not showing after posting, setting of view is now shared between the search panels as well as persisted between sessions, tab/shift-tab can now be used to switch between all input fields --- Aux-AddOn.toc | 4 +- core.lua | 12 ++++- filter_search_frame.lua | 24 ++++----- filter_search_frame.xml | 109 +++++++++++++++++++++++++++++++++++---- item_search_frame.lua | 26 +++++----- item_search_frame.xml | 47 ++++++++++++++--- manage_frame.lua | 4 +- manage_frame.xml | 24 +++++++-- post_frame.lua | 12 ++--- post_frame.xml | 26 ++++++++-- list.lua => sheet.lua | 110 +++++++++++++++++----------------------- static.lua | 2 +- 12 files changed, 272 insertions(+), 128 deletions(-) rename list.lua => sheet.lua (70%) diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc index 1951725..6bc391f 100644 --- a/Aux-AddOn.toc +++ b/Aux-AddOn.toc @@ -1,7 +1,7 @@ ## Interface: 11200 ## Title: Aux ## Notes: A lightweight addon designed to help manage auctions -## SavedVariablesPerCharacter: AUX_SELL_SHORTCUT, AUX_BUY_SHORTCUT, AUX_OPEN_SELL, AUX_OPEN_BUY, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION +## SavedVariablesPerCharacter: aux_view, AUX_SELL_SHORTCUT, AUX_BUY_SHORTCUT, AUX_OPEN_SELL, AUX_OPEN_BUY, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION ## SavedVariables: aux_database, aux_recently_searched, aux_auctionable_items core.xml @@ -12,7 +12,7 @@ util.lua scan.lua stack.lua post.lua -list.lua +sheet.lua info.xml completion.xml diff --git a/core.lua b/core.lua index 8017b9b..5008feb 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,5 @@ -AuxVersion = "2.1.0" -AuxAuthors = "shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)" +AuxVersion = '2.1.1' +AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)' local lastRightClickAction = GetTime() @@ -17,8 +17,16 @@ Aux = { }, }, last_picked_up = {}, + view = { + BUYOUT = 1, + BID = 2, + FULL = 3, + }, + last_owner_page_requested = 0, } +aux_view = Aux.view.BUYOUT + function Aux_OnLoad() Aux.log('Aux v'..AuxVersion..' loaded.') Aux.loaded = true diff --git a/filter_search_frame.lua b/filter_search_frame.lua index e8064a8..113233d 100644 --- a/filter_search_frame.lua +++ b/filter_search_frame.lua @@ -18,10 +18,8 @@ function group_alpha_setter(cell, group) cell:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1) end -local BUYOUT, BID, FULL = 1, 2, 3 - public.views = { - [BUYOUT] = { + [Aux.view.BUYOUT] = { name = 'Buyout', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -135,7 +133,7 @@ public.views = { }, sort_order = {{column = 1, order = 'ascending' }, {column = 4, order = 'ascending'}}, }, - [BID] = { + [Aux.view.BID] = { name = 'Bid', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -279,7 +277,7 @@ public.views = { }, sort_order = {{column = 1, order = 'ascending' }, {column = 4, order = 'ascending' }, {column = 6, order = 'ascending'}}, }, - [FULL] = { + [Aux.view.FULL] = { name = 'Full', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -470,7 +468,7 @@ function public.on_close() end function public.on_open() - public.set_view(1) + public.set_view(aux_view) update_sheet() end @@ -491,21 +489,21 @@ function update_sheet() AuxFilterSearchFrameResultsBidListing:Hide() AuxFilterSearchFrameResultsFullListing:Hide() - if private.view == BUYOUT then + if aux_view == Aux.view.BUYOUT then AuxFilterSearchFrameResultsBuyListing:Show() local buyout_auctions = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') and auction.buyout_price end) or {} - Aux.list.populate(AuxFilterSearchFrameResultsBuyListing.sheet, auctions and Aux.util.group_by(buyout_auctions, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {}) + Aux.sheet.populate(AuxFilterSearchFrameResultsBuyListing.sheet, auctions and Aux.util.group_by(buyout_auctions, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {}) AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsBuyListing:GetWidth() + 40) AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15) - elseif private.view == BID then + elseif aux_view == Aux.view.BID then AuxFilterSearchFrameResultsBidListing:Show() local bid_auctions = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') end) or {} - Aux.list.populate(AuxFilterSearchFrameResultsBidListing.sheet, bid_auctions) + Aux.sheet.populate(AuxFilterSearchFrameResultsBidListing.sheet, bid_auctions) AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsBidListing:GetWidth() + 40) AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15) - elseif private.view == FULL then + elseif aux_view == Aux.view.FULL then AuxFilterSearchFrameResultsFullListing:Show() - Aux.list.populate(AuxFilterSearchFrameResultsFullListing.sheet, auctions or {}) + Aux.sheet.populate(AuxFilterSearchFrameResultsFullListing.sheet, auctions or {}) AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsFullListing:GetWidth() + 40) AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15) end @@ -521,7 +519,7 @@ function public.set_view(view) for i=1,3 do getglobal('AuxFilterSearchFrameResultsTab'..i):SetAlpha(i == view and 1 or 0.5) end - private.view = view + aux_view = view update_sheet() end diff --git a/filter_search_frame.xml b/filter_search_frame.xml index fe3c947..e873660 100644 --- a/filter_search_frame.xml +++ b/filter_search_frame.xml @@ -37,6 +37,13 @@ this:ClearFocus() + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'TooltipInputBox4'):SetFocus() + else + getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() + end + @@ -110,7 +117,15 @@ this:ClearFocus() + Aux.filter_search_frame.start_search() + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus() + else + getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus() + end + @@ -123,7 +138,15 @@ this:ClearFocus() + Aux.filter_search_frame.start_search() + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() + else + getglobal(this:GetParent():GetName()..'TooltipInputBox1'):SetFocus() + end + @@ -145,6 +168,17 @@ getglobal(this:GetName()..'Label'):SetText('Tooltip') this:SetWidth(150) + + this:ClearFocus() + Aux.filter_search_frame.start_search() + + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus() + else + getglobal(this:GetParent():GetName()..'TooltipInputBox2'):SetFocus() + end + @@ -154,6 +188,17 @@ this:SetWidth(150) + + this:ClearFocus() + Aux.filter_search_frame.start_search() + + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'TooltipInputBox1'):SetFocus() + else + getglobal(this:GetParent():GetName()..'TooltipInputBox3'):SetFocus() + end + @@ -163,6 +208,17 @@ this:SetWidth(150) + + this:ClearFocus() + Aux.filter_search_frame.start_search() + + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'TooltipInputBox2'):SetFocus() + else + getglobal(this:GetParent():GetName()..'TooltipInputBox4'):SetFocus() + end + @@ -172,6 +228,17 @@ this:SetWidth(150) + + this:ClearFocus() + Aux.filter_search_frame.start_search() + + + if IsShiftKeyDown() then + getglobal(this:GetParent():GetName()..'TooltipInputBox3'):SetFocus() + else + getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus() + end + @@ -250,7 +317,7 @@ - getglobal(this:GetName().."Text"):SetText('Buy') + getglobal(this:GetName()..'Text'):SetText('Buy') Aux.filter_search_frame.set_view(this:GetID()) @@ -267,7 +334,7 @@ - getglobal(this:GetName().."Text"):SetText('Bid') + getglobal(this:GetName()..'Text'):SetText('Bid') Aux.filter_search_frame.set_view(this:GetID()) @@ -284,7 +351,7 @@ - getglobal(this:GetName().."Text"):SetText('Full') + getglobal(this:GetName()..'Text'):SetText('Full') Aux.filter_search_frame.set_view(this:GetID()) @@ -299,8 +366,16 @@ local config = Aux.filter_search_frame.views[1] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } @@ -312,8 +387,16 @@ local config = Aux.filter_search_frame.views[2] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } @@ -325,8 +408,16 @@ local config = Aux.filter_search_frame.views[3] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } diff --git a/item_search_frame.lua b/item_search_frame.lua index 59c0551..5009073 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -17,8 +17,6 @@ function group_alpha_setter(cell, group) cell:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1) end -local BUYOUT, BID, FULL = 1, 2, 3 - public.recently_searched_config = { on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -81,7 +79,7 @@ public.recently_searched_config = { sort_order = {}, } public.views = { - [BUYOUT] = { + [Aux.view.BUYOUT] = { name = 'Buyout', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -153,7 +151,7 @@ public.views = { }, sort_order = {{column = 3, order = 'ascending' }}, }, - [BID] = { + [Aux.view.BID] = { name = 'Bid', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -255,7 +253,7 @@ public.views = { }, sort_order = {{column = 3, order = 'ascending'}, {column = 5, order = 'ascending'}}, }, - [FULL] = { + [Aux.view.FULL] = { name = 'Full', on_row_click = function (sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) @@ -414,7 +412,7 @@ function public.on_close() end function public.on_open() - public.set_view(1) + public.set_view(aux_view) public.update_item() private.update_recently_searched() update_listing() @@ -440,21 +438,21 @@ function update_listing() AuxItemSearchFrameAuctionsBidListing:Hide() AuxItemSearchFrameAuctionsFullListing:Hide() - if private.view == BUYOUT then + if aux_view == Aux.view.BUYOUT then AuxItemSearchFrameAuctionsBuyListing:Show() local buy_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') and auction.buyout_price end) or {} - Aux.list.populate(AuxItemSearchFrameAuctionsBuyListing.sheet, auctions and Aux.util.group_by(buy_records, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {}) + Aux.sheet.populate(AuxItemSearchFrameAuctionsBuyListing.sheet, auctions and Aux.util.group_by(buy_records, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {}) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBuyListing:GetWidth() + 40) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) - elseif private.view == BID then + elseif aux_view == Aux.view.BID then AuxItemSearchFrameAuctionsBidListing:Show() local bid_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') end) or {} - Aux.list.populate(AuxItemSearchFrameAuctionsBidListing.sheet, bid_records) + Aux.sheet.populate(AuxItemSearchFrameAuctionsBidListing.sheet, bid_records) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBidListing:GetWidth() + 40) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) - elseif private.view == FULL then + elseif aux_view == Aux.view.FULL then AuxItemSearchFrameAuctionsFullListing:Show() - Aux.list.populate(AuxItemSearchFrameAuctionsFullListing.sheet, auctions or {}) + Aux.sheet.populate(AuxItemSearchFrameAuctionsFullListing.sheet, auctions or {}) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsFullListing:GetWidth() + 40) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) end @@ -470,12 +468,12 @@ function public.set_view(view) for i=1,3 do getglobal('AuxItemSearchFrameAuctionsTab'..i):SetAlpha(i == view and 1 or 0.5) end - private.view = view + aux_view = view update_listing() end function private.update_recently_searched() - Aux.list.populate(AuxItemSearchFrameRecentlySearchedListing.sheet, aux_recently_searched) + Aux.sheet.populate(AuxItemSearchFrameRecentlySearchedListing.sheet, aux_recently_searched) end function public.set_item(item_id) diff --git a/item_search_frame.xml b/item_search_frame.xml index 3b24584..0974860 100644 --- a/item_search_frame.xml +++ b/item_search_frame.xml @@ -152,8 +152,15 @@ local config = Aux.item_search_frame.recently_searched_config - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + } @@ -231,8 +238,16 @@ local config = Aux.item_search_frame.views[1] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } @@ -244,8 +259,16 @@ local config = Aux.item_search_frame.views[2] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } @@ -257,8 +280,16 @@ local config = Aux.item_search_frame.views[3] - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } diff --git a/manage_frame.lua b/manage_frame.lua index 7865967..4adc286 100644 --- a/manage_frame.lua +++ b/manage_frame.lua @@ -351,12 +351,12 @@ function public.update_listing() if public.listing == BIDS then AuxManageFrameListingBidListing:Show() - Aux.list.populate(AuxManageFrameListingBidListing.sheet, bid_records) + Aux.sheet.populate(AuxManageFrameListingBidListing.sheet, bid_records) AuxManageFrameListing:SetWidth(AuxManageFrameListingBidListing:GetWidth() + 40) AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15) elseif public.listing == AUCTIONS then AuxManageFrameListingAuctionListing:Show() - Aux.list.populate(AuxManageFrameListingAuctionListing.sheet, auction_records) + Aux.sheet.populate(AuxManageFrameListingAuctionListing.sheet, auction_records) AuxManageFrameListing:SetWidth(AuxManageFrameListingAuctionListing:GetWidth() + 40) AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15) end diff --git a/manage_frame.xml b/manage_frame.xml index bbd866b..05b1839 100644 --- a/manage_frame.xml +++ b/manage_frame.xml @@ -62,8 +62,16 @@ local config = Aux.manage_frame.bid_listing_config - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } @@ -75,8 +83,16 @@ local config = Aux.manage_frame.auction_listing_config - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave, config.on_row_update) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + on_row_update = config.on_row_update, + } diff --git a/post_frame.lua b/post_frame.lua index 68e3892..1915772 100644 --- a/post_frame.lua +++ b/post_frame.lua @@ -89,16 +89,16 @@ Aux.sell.inventory_listing_config = { } Aux.sell.auction_listing_config = { - on_cell_click = function (sheet, row_index, column_index) + on_row_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) + on_row_enter = function (sheet, row_index, column_index) sheet.rows[row_index].highlight:SetAlpha(.5) end, - on_cell_leave = function (sheet, row_index, column_index) + on_row_leave = function (sheet, row_index, column_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local datum = sheet.data[data_index] if not (datum and current_auction and Aux.util.safe_index{existing_auctions, current_auction.key, 'selected', 'key'} == datum.key) then @@ -175,11 +175,11 @@ Aux.sell.auction_listing_config = { } function update_inventory_listing() - Aux.list.populate(AuxSellInventoryListing.sheet, inventory_data) + Aux.sheet.populate(AuxSellInventoryListing.sheet, inventory_data) end function update_auction_listing() - Aux.list.populate(AuxSellAuctionsListing.sheet, current_auction and existing_auctions[current_auction.key] or {}) + Aux.sheet.populate(AuxSellAuctionsListing.sheet, current_auction and existing_auctions[current_auction.key] or {}) end function Aux.sell.on_open() @@ -604,7 +604,7 @@ function AuxSellEntry_OnClick(entry) update_auction_listing() update_recommendation() - PlaySound("igMainMenuOptionCheckBoxOn") + PlaySound('igMainMenuOptionCheckBoxOn') end function AuxSellParametersRefreshButton_OnClick() diff --git a/post_frame.xml b/post_frame.xml index ef873eb..8449a62 100644 --- a/post_frame.xml +++ b/post_frame.xml @@ -27,8 +27,15 @@ local config = Aux.sell.inventory_listing_config - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_row_click, config.on_row_enter, config.on_row_leave) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + } @@ -222,6 +229,10 @@ + MoneyInputFrame_SetPreviousFocus(getglobal(this:GetParent():GetName()..'StartPrice'), getglobal(this:GetName()..'Copper')) + MoneyInputFrame_SetNextFocus(getglobal(this:GetParent():GetName()..'StartPrice'), getglobal(this:GetName()..'Gold')) + MoneyInputFrame_SetPreviousFocus(this, getglobal(this:GetParent():GetName()..'StartPriceCopper')) + MoneyInputFrame_SetNextFocus(this, getglobal(this:GetParent():GetName()..'StartPriceGold')) MoneyInputFrame_SetOnvalueChangedFunc(this, Aux.sell.validate_parameters) @@ -274,8 +285,15 @@ local config = Aux.sell.auction_listing_config - local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end) - this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_cell_click, config.on_cell_enter, config.on_cell_leave) + this.sheet = Aux.sheet.create{ + frame = this, + columns = config.columns, + sort_order = config.sort_order, + row_setter = config.row_setter, + on_row_click = config.on_row_click, + on_row_enter = config.on_row_enter, + on_row_leave = config.on_row_leave, + } diff --git a/list.lua b/sheet.lua similarity index 70% rename from list.lua rename to sheet.lua index f38ab9e..b74a167 100644 --- a/list.lua +++ b/sheet.lua @@ -1,8 +1,9 @@ -Aux.sheet = {} +local private, public = {}, {} +Aux.sheet = public Aux.list = {} -MoneyTypeInfo["AUX_LIST"] = { +MoneyTypeInfo['AUX_LIST'] = { UpdateFunc = function() return this.staticMoney end, @@ -11,13 +12,13 @@ MoneyTypeInfo["AUX_LIST"] = { showSmallerCoins = 1, } -function Aux.sheet.render(sheet) +function public.render(sheet) for i, column in ipairs(sheet.columns) do local sort_info = sheet.sort_order[1] - if sort_info and sort_info.column == column then - if sort_info.sort_ascending then + if sort_info and sort_info.column == i then + if sort_info.order == 'ascending' then sheet.labels[i].sort_texture:SetTexCoord(0,0.55,0.2,0.9) sheet.labels[i].sort_texture:SetVertexColor(0.2,1,0) sheet.labels[i].sort_texture:Show() @@ -42,7 +43,7 @@ function Aux.sheet.render(sheet) local data = sheet.data 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 direction, rowR, rowG, rowB, rowA1, rowA2 = 'Horizontal', 1, 1, 1, 0, 0 --row level coloring used for gradients local datum = data[i + offset] if datum then @@ -66,9 +67,9 @@ function Aux.sheet.render(sheet) end end -function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, on_row_enter, on_row_leave, on_row_update) +function public.create(params) local sheet - local name = (frame:GetName() or '')..'ScrollSheet' + local name = (params.frame:GetName() or '')..'ScrollSheet' local id = 1 while getglobal(name..id) do @@ -76,22 +77,22 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, end name = name..id - local scroll_frame = CreateFrame("ScrollFrame", name..'ScrollFrame', frame, "FauxScrollFrameTemplate") - scroll_frame:SetScript("OnVerticalScroll", function() - FauxScrollFrame_OnVerticalScroll(16, function() Aux.sheet.render(this.sheet) end) + local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', params.frame, 'FauxScrollFrameTemplate') + scroll_frame:SetScript('OnVerticalScroll', function() + FauxScrollFrame_OnVerticalScroll(16, function() public.render(this.sheet) end) end) - scroll_frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 5, -10) - scroll_frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 5, 19) + scroll_frame:SetPoint('TOPLEFT', params.frame, 'TOPLEFT', 5, -10) + scroll_frame:SetPoint('BOTTOMRIGHT', params.frame, 'BOTTOMRIGHT', 5, 19) - local parent_height = frame:GetHeight() - local content = CreateFrame('Frame', name..'Content', frame) + local parent_height = params.frame:GetHeight() + local content = CreateFrame('Frame', name..'Content', params.frame) content:SetHeight(parent_height - 30) - content:SetPoint("TOPLEFT", scroll_frame, "TOPLEFT", 5, 0) + content:SetPoint('TOPLEFT', scroll_frame, 'TOPLEFT', 5, 0) local total_width = 0 local labels = {} - for i = 1,getn(columns) do + for i = 1,getn(params.columns) do local button = CreateFrame('Button', nil, content) if i == 1 then button:SetPoint('TOPLEFT', content, 'TOPLEFT', 5, 0) @@ -101,15 +102,15 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, total_width = total_width + 3 end local label = content:CreateFontString(nil, 'OVERLAY', 'GameFontHighlight') - label:SetText(columns[i].title) - local column_width = columns[i].width or 30 + label:SetText(params.columns[i].title) + local column_width = params.columns[i].width or 30 total_width = total_width + column_width button:SetWidth(column_width) button:SetHeight(16) button:SetID(i) button:SetHighlightTexture('Interface\\QuestFrame\\UI-QuestTitleHighlight') - button:SetScript("OnMouseDown", function() Aux.list.sort(sheet, this:GetID()) end) + button:SetScript("OnMouseDown", function() Aux.sheet.sort(sheet, this:GetID()) end) button:RegisterForClicks("LeftButtonDown", "RightButtonDown") local texture = content:CreateTexture(nil, 'ARTWORK') @@ -147,17 +148,17 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, labels[i] = label end total_width = total_width + 5 - frame:SetWidth(total_width) + params.frame:SetWidth(total_width) local rows = {} local row_index = 1 local max_height = content:GetHeight() local total_height = 16 while total_height + 14 < max_height do - if getn(columns) > 0 then + if getn(params.columns) > 0 then local row = CreateFrame('Button', nil, content) row:SetPoint('TOPLEFT', labels[1], 'BOTTOMLEFT', 0, -((row_index-1) * 14)) - row:SetPoint('TOPRIGHT', labels[getn(columns)], 'BOTTOMRIGHT', 0, -((row_index-1) * 14)) + row:SetPoint('TOPRIGHT', labels[getn(params.columns)], 'BOTTOMRIGHT', 0, -((row_index-1) * 14)) row:RegisterForClicks("LeftButtonDown", "RightButtonDown") row:SetHeight(14) @@ -168,14 +169,14 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, row:SetScript('OnUpdate', function() if sheet.on_row_update then sheet.on_row_update(sheet, row_idx) end end) row.cells = {} - for i = 1,getn(columns) do + for i = 1,getn(params.columns) do local cell = CreateFrame('Button', nil, content) cell:SetPoint('TOPLEFT', labels[i], 'BOTTOMLEFT', 0, -((row_index-1) * 14)) cell:SetPoint('TOPRIGHT', labels[i], 'BOTTOMRIGHT', 0, -((row_index-1) * 14)) cell:SetHeight(14) - columns[i].cell_initializer(cell) + params.columns[i].cell_initializer(cell) row.cells[i] = cell end @@ -207,28 +208,28 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_row_click, scroll_frame = scroll_frame, labels = labels, rows = rows, - columns = columns, + columns = params.columns, data = {}, - sort_order = sort_order, - row_setter = row_setter, - on_row_click = on_row_click, - on_row_enter = on_row_enter, - on_row_leave = on_row_leave, - on_row_update = on_row_update, + sort_order = params.sort_order, + row_setter = params.row_setter, + on_row_click = params.on_row_click, + on_row_enter = params.on_row_enter, + on_row_leave = params.on_row_leave, + on_row_update = params.on_row_update, } scroll_frame.sheet = sheet return sheet end -function Aux.list.row_comparator(sheet) +function private.row_comparator(sheet) return function(row1, row2) for _, sort_info in ipairs(sheet.sort_order) do - local column = sort_info.column + local column = sheet.columns[sort_info.column] if column.comparator then local ordering = column.comparator(row1, row2) if ordering ~= Aux.util.EQ then - return sort_info.sort_ascending and ordering or Aux.util.invert_order(ordering) + return sort_info.order == 'ascending' and ordering or Aux.util.invert_order(ordering) end end end @@ -236,7 +237,7 @@ function Aux.list.row_comparator(sheet) end end -function Aux.sheet.default_cell_initializer(alignment) +function public.default_cell_initializer(alignment) return function(cell) local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall') text:SetAllPoints(cell) @@ -247,41 +248,24 @@ function Aux.sheet.default_cell_initializer(alignment) end end -function Aux.sheet.initialize(frame) - - local sort_order = {} - for i, column in columns do - if i ~= BUYOUT_UNIT and i ~= NAME then - tinsert(sort_order, { column = column, sort_ascending = true }) - end - end - tinsert(sort_order, 1, { column = columns[BUYOUT_UNIT], sort_ascending = true }) - tinsert(sort_order, 1, { column = columns[NAME], sort_ascending = true }) - -end - -function Aux.list.populate(sheet, data) +function public.populate(sheet, data) sheet.data = data - -- Perform the sort. - Aux.util.merge_sort(sheet.data, Aux.list.row_comparator(sheet)) + Aux.util.merge_sort(sheet.data, private.row_comparator(sheet)) - -- Update the scroll pane. - Aux.sheet.render(sheet) + public.render(sheet) end -function Aux.list.sort(sheet, column_index) - - local column = sheet.columns[column_index] +function Aux.sheet.sort(sheet, column_index) - 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 + if sheet.sort_order[1] and sheet.sort_order[1].column == column_index then + sheet.sort_order[1].order = sheet.sort_order[1].order == 'ascending' and 'descending' or 'ascending' else - sheet.sort_order = Aux.util.filter(sheet.sort_order, function(sort_info) return not sort_info.column == column end) - tinsert(sheet.sort_order, 1, {column=column, sort_ascending=true}) + sheet.sort_order = Aux.util.filter(sheet.sort_order, function(sort_info) return not sort_info.column == column_index end) + tinsert(sheet.sort_order, 1, {column=column_index, order = 'ascending'}) end - Aux.util.merge_sort(sheet.data, Aux.list.row_comparator(sheet)) + Aux.util.merge_sort(sheet.data, private.row_comparator(sheet)) - Aux.sheet.render(sheet) + public.render(sheet) end diff --git a/static.lua b/static.lua index 078727d..3befb38 100644 --- a/static.lua +++ b/static.lua @@ -1,4 +1,4 @@ -private, public = {}, {} +local private, public = {}, {} Aux.static = public aux_auctionable_items = {} From 3f8d78e4fd72f2cafce1cda9940711d85cf6468b Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 16 Nov 2015 10:34:28 +0100 Subject: [PATCH 06/31] small bugfix --- core.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core.lua b/core.lua index 5008feb..a428b82 100644 --- a/core.lua +++ b/core.lua @@ -22,7 +22,6 @@ Aux = { BID = 2, FULL = 3, }, - last_owner_page_requested = 0, } aux_view = Aux.view.BUYOUT @@ -43,7 +42,7 @@ function Aux_OnEvent() elseif event == 'AUCTION_HOUSE_CLOSED' then Aux_OnAuctionHouseClosed() elseif event == 'AUCTION_OWNED_LIST_UPDATE' then - Aux.current_owner_page = Aux.last_owner_page_requested + Aux.current_owner_page = Aux.last_owner_page_requested or 0 end end From 7491b9c7d728bec94d86e67c45ee079fdd5bba1a Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 16 Nov 2015 20:59:44 +0100 Subject: [PATCH 07/31] added sound to recently searched list click --- item_search_frame.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/item_search_frame.lua b/item_search_frame.lua index 5009073..a5aee02 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -19,6 +19,7 @@ end public.recently_searched_config = { on_row_click = function (sheet, row_index) + PlaySound('igMainMenuOptionCheckBoxOn') local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) AuxItemSearchFrameItemItemInputBox:Hide() public.set_item(sheet.data[data_index].item_id) From 5e256bd76c7a35d5905193fc4393e517f8f0e837 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Thu, 19 Nov 2015 19:48:32 +0100 Subject: [PATCH 08/31] fixed bug with canceling auctions --- manage_frame.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_frame.lua b/manage_frame.lua index 4adc286..9e8ee58 100644 --- a/manage_frame.lua +++ b/manage_frame.lua @@ -475,7 +475,7 @@ function private.find_auction(entry, action, express_mode) Aux.scan.abort() else public.dialog_action = function() - if private.create_record(Aux.info.auction(auction_info.index, 'bidder')).signature == entry.signature then + if private.create_record(Aux.info.auction(auction_info.index, action == 'cancel' and 'owner' or 'bidder')).signature == entry.signature then if action == 'cancel' then CancelAuction(auction_info.index) entry.gone = true From c1ef4130e24190b03132d5fa547c119415d72450 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 23 Nov 2015 03:02:36 +0100 Subject: [PATCH 09/31] working on separating bids and auctions --- Aux-AddOn.toc | 3 +- auctions_frame.lua | 372 +++++++++++++++++++++++++++++++++++++++++++++ auctions_frame.xml | 115 ++++++++++++++ core.lua | 10 +- core.xml | 19 ++- manage_frame.lua | 201 +----------------------- manage_frame.xml | 83 +--------- 7 files changed, 525 insertions(+), 278 deletions(-) create mode 100644 auctions_frame.lua create mode 100644 auctions_frame.xml diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc index 6bc391f..119475b 100644 --- a/Aux-AddOn.toc +++ b/Aux-AddOn.toc @@ -19,7 +19,8 @@ completion.xml item_search_frame.xml filter_search_frame.xml post_frame.xml -manage_frame.xml +auctions_frame.xml +bids_frame.xml scan_frame.xml options.xml diff --git a/auctions_frame.lua b/auctions_frame.lua new file mode 100644 index 0000000..7634f30 --- /dev/null +++ b/auctions_frame.lua @@ -0,0 +1,372 @@ +local private, public = {}, {} +Aux.auctions_frame = public + +local auction_records + +public.auction_listing_config = { + on_row_click = function (sheet, row_index) + local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) + public.on_auction_click(sheet.data[data_index]) + end, + + on_row_enter = function (sheet, row_index) + sheet.rows[row_index].highlight:SetAlpha(.5) + end, + + on_row_leave = function (sheet, row_index) + sheet.rows[row_index].highlight:SetAlpha(0) + end, + columns = { + { + title = 'Auction Item', + width = 280, + comparator = function(row1, row2) return Aux.util.compare(row1.tooltip[1][1].text, row2.tooltip[1][1].text, Aux.util.GT) end, + cell_initializer = function(cell) + local icon = CreateFrame('Button', nil, cell) + icon:EnableMouse(false) + 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) + 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(Aux.info.item(datum.item_id).texture) + if not datum.usable then + cell.icon.icon_texture:SetVertexColor(1.0, 0.1, 0.1) + else + cell.icon.icon_texture:SetVertexColor(1.0, 1.0, 1.0) + end + cell.text:SetText('['..datum.tooltip[1][1].text..']') + local color = ITEM_QUALITY_COLORS[datum.quality] + cell.text:SetTextColor(color.r, color.g, color.b) + private.auction_alpha_setter(cell, datum) + end, + }, + { + title = 'Qty', + width = 25, + 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, datum) + cell.text:SetText(datum.aux_quantity) + private.auction_alpha_setter(cell, datum) + end, + }, + { + title = 'Left', + width = 30, + comparator = function(row1, row2) return Aux.util.compare(row1.duration, row2.duration, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('CENTER'), + cell_setter = function(cell, datum) + local text + if datum.duration == 1 then + text = '30m' + elseif datum.duration == 2 then + text = '2h' + elseif datum.duration == 3 then + text = '8h' + elseif datum.duration == 4 then + text = '24h' + end + cell.text:SetText(text) + private.auction_alpha_setter(cell, datum) + end, + }, + { + title = 'Current Bid', + width = 90, + comparator = function(auction1, auction2) return Aux.util.compare(auction1.current_bid, auction2.current_bid, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('CENTER'), + cell_setter = function(cell, auction) + cell.text:SetText(auction.current_bid and Aux.util.money_string(auction.current_bid) or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE) + private.auction_alpha_setter(cell, auction) + end, + }, + { + title = 'Min Bid', + width = 90, + comparator = function(auction1, auction2) return Aux.util.compare(auction1.min_bid, auction2.min_bid, Aux.util.GT) end, + cell_initializer = Aux.sheet.default_cell_initializer('CENTER'), + cell_setter = function(cell, auction) + cell.text:SetText(Aux.util.money_string(auction.min_bid)) + private.auction_alpha_setter(cell, auction) + end, + }, + { + title = 'Buy', + width = 90, + 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, datum) + cell.text:SetText(Aux.util.money_string(datum.buyout_price)) + private.auction_alpha_setter(cell, datum) + end, + }, + }, + sort_order = {{ column = 1, order = 'ascending' }}, +} + +function public.on_open() + public.update_auction_records() + public.update_listing() +end + +function public.on_close() +end + +function private.auction_alpha_setter(cell, auction) + cell:SetAlpha(auction.gone and 0.3 or 1) +end + +function public.update_auction_records() + Aux.log('Scanning auctions ...') + auction_records = {} + Aux.scan.start{ + type = 'owner', + page = 0, + on_page_loaded = function(page, total_pages) + Aux.log('Scanning auction page '..(page+1)..' out of '..total_pages..' ...') + end, + on_read_auction = function(auction_info) + private.create_auction_record(auction_info) + end, + on_complete = function() + Aux.log('Scan complete: '..getn(auction_records)..' auctions found') + public.update_listing() + end, + on_abort = function() + end, + next_page = function(page, total_pages) + local last_page = max(total_pages - 1, 0) + if page < last_page then + return page + 1 + end + end, + } +end + +function public.update_listing() + AuxManageFrameListingAuctionListing:Show() + Aux.sheet.populate(AuxManageFrameListingAuctionListing.sheet, auction_records) + AuxManageFrameListing:SetWidth(AuxManageFrameListingAuctionListing:GetWidth() + 40) + AuxFrame:SetWidth(AuxManageFrameListing:GetWidth() + 15) +end + +function private.create_record(auction_info) + + local aux_quantity = auction_info.charges or auction_info.count + local bid = (auction_info.current_bid > 0 and auction_info.current_bid or auction_info.min_bid) + auction_info.min_increment + local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil + local buyout_price_per_unit = buyout_price and Aux_Round(auction_info.buyout_price / aux_quantity) + + local status + if auction_info.high_bidder then + status = GREEN_FONT_COLOR_CODE..'High Bidder'..FONT_COLOR_CODE_CLOSE + else + status = RED_FONT_COLOR_CODE..'Outbid'..FONT_COLOR_CODE_CLOSE + end + + return { + item_id = auction_info.item_id, + key = auction_info.item_signature, + signature = Aux.auction_signature(auction_info.hyperlink, aux_quantity, bid, auction_info.buyout_price), + + name = auction_info.name, + level = auction_info.level, + tooltip = auction_info.tooltip, + aux_quantity = aux_quantity, + buyout_price = buyout_price, + buyout_price_per_unit = buyout_price_per_unit, + quality = auction_info.quality, + hyperlink = auction_info.hyperlink, + itemstring = auction_info.itemstring, + bid = bid, + bid_per_unit = Aux_Round(bid / aux_quantity), + owner = auction_info.owner, + duration = auction_info.duration, + usable = auction_info.usable, + high_bidder = auction_info.high_bidder, + current_bid = auction_info.current_bid > 0 and auction_info.current_bid or nil, + min_bid = auction_info.min_bid, + status = status, + + EnhTooltip_info = auction_info.EnhTooltip_info, + } +end + +function private.create_auction_record(auction_info) + tinsert(auction_records, private.create_record(auction_info)) +end + +function public.dialog_cancel() + Aux.log('Aborted.') + Aux.scan.abort() + AuxManageFrameListingDialog:Hide() + public.update_listing() +end + +function private.find_auction(entry, action, express_mode) + + if entry.gone then + Aux.log('Auction not available') + return + end + + if action == 'buyout' and not entry.buyout_price then + Aux.log('Auction has no buyout price') + return + end + + local amount + if action == 'buyout' then + amount = entry.buyout_price + elseif action == 'bid' then + amount = entry.bid + end + + Aux.log('Processing '..action..' request for '..entry.hyperlink..' x '..entry.aux_quantity..' at '..Aux.util.money_string(amount)..' ...') + + if not express_mode then + private.show_dialog(action, entry, amount) + end + + PlaySound('igMainMenuOptionCheckBoxOn') + + local found + + Aux.scan.start{ + type = action == 'cancel' and 'owner' or 'bidder', + page = entry.page, + on_read_auction = function(auction_info, ctrl) + + local auction_record = private.create_record(auction_info) + + if entry.signature == auction_record.signature then + ctrl.suspend() + found = true + Aux.log('Matching auction found.'..(express_mode and '' or ' Awaiting confirmation ...')) + + if express_mode then + if action == 'cancel' then + CancelAuction(auction_info.index) + entry.gone = true + Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity) + elseif GetMoney() >= amount then + PlaceAuctionBid('bidder', auction_info.index, amount) + Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(amount)..'.') + entry.gone = true + else + Aux.log((action == 'buyout' and 'Purchase' or 'Bid')..' failed: Not enough money.') + end + Aux.scan.abort() + else + public.dialog_action = function() + if private.create_record(Aux.info.auction(auction_info.index, action == 'cancel' and 'owner' or 'bidder')).signature == entry.signature then + if action == 'cancel' then + CancelAuction(auction_info.index) + entry.gone = true + Aux.log('Canceled'..auction_record.hyperlink..' x '..auction_record.aux_quantity) + elseif GetMoney() >= amount then + PlaceAuctionBid('bidder', auction_info.index, action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount) + Aux.log((action == 'buyout' and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' x '..auction_record.aux_quantity..' at '..Aux.util.money_string(action == 'bid' and MoneyInputFrame_GetCopper(AuxManageFrameListingDialogContentBid) or amount)..'.') + entry.gone = true + else + Aux.log('Not enough money.') + end + Aux.scan.abort() + AuxManageFrameListingDialog:Hide() + public.update_listing() + end + end + AuxManageFrameListingDialogContentActionButton:Enable() + end + end + end, + on_complete = function() + if not found then + Aux.log('No matching auction found. Removing entry from the cache.') + entry.gone = true + public.dialog_cancel() + end + end, + on_abort = function() + public.update_listing() + end, + next_page = function(page, total_pages) + if not page or page == entry.page then + return entry.page - 1 + end + end, + } +end + +function public.on_auction_click(auction_record) + + local express_mode = IsAltKeyDown() + + if IsControlKeyDown() then + DressUpItemLink(auction_record.hyperlink) + else + private.find_auction(auction_record, 'cancel', express_mode) + end +end + +function private.show_dialog(action, entry, amount) + AuxManageFrameListingDialogContentItem.itemstring = Aux.info.itemstring(entry.item_id, entry.suffix_id, entry.unique_id, entry.enchant_id) + AuxManageFrameListingDialogContentItem.EnhTooltip_info = entry.EnhTooltip_info + + AuxManageFrameListingDialogContentActionButton:Disable() + AuxManageFrameListingDialogContentItemIconTexture:SetTexture(Aux.info.item(entry.item_id).texture) + AuxManageFrameListingDialogContentItemName:SetText(entry.name) + local color = ITEM_QUALITY_COLORS[entry.quality] + AuxManageFrameListingDialogContentItemName:SetTextColor(color.r, color.g, color.b) + + if entry.aux_quantity > 1 then + AuxManageFrameListingDialogContentItemCount:SetText(entry.aux_quantity); + AuxManageFrameListingDialogContentItemCount:Show() + else + AuxManageFrameListingDialogContentItemCount:Hide() + end + + if action == 'buyout' then + AuxManageFrameListingDialogContentActionButton:SetText('Buy') + AuxManageFrameListingDialogContentCancelButton:SetText('Cancel') + MoneyFrame_Update('AuxManageFrameListingDialogContentBuyoutPrice', amount) + AuxManageFrameListingDialogContentBid:Hide() + AuxManageFrameListingDialogContentCancelLabel:Hide() + AuxManageFrameListingDialogContentBuyoutPrice:Show() + elseif action == 'bid' then + AuxManageFrameListingDialogContentActionButton:SetText('Bid') + AuxManageFrameListingDialogContentCancelButton:SetText('Cancel') + MoneyInputFrame_SetCopper(AuxManageFrameListingDialogContentBid, amount) + AuxManageFrameListingDialogContentBuyoutPrice:Hide() + AuxManageFrameListingDialogContentCancelLabel:Hide() + AuxManageFrameListingDialogContentBid:Show() + elseif action == 'cancel' then + AuxManageFrameListingDialogContentBid:Hide() + AuxManageFrameListingDialogContentBuyoutPrice:Hide() + AuxManageFrameListingDialogContentCancelLabel:Show() + AuxManageFrameListingDialogContentActionButton:SetText('Yes') + AuxManageFrameListingDialogContentCancelButton:SetText('No') + end + AuxManageFrameListingDialog:Show() +end + + diff --git a/auctions_frame.xml b/auctions_frame.xml new file mode 100644 index 0000000..bf72a4a --- /dev/null +++ b/auctions_frame.xml @@ -0,0 +1,115 @@ + + +