diff --git a/panels/search/core.lua b/panels/search/core.lua index 8ecbed9..919126d 100644 --- a/panels/search/core.lua +++ b/panels/search/core.lua @@ -47,6 +47,18 @@ StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = { timeout = 0, hideOnEscape = 1, } +StaticPopupDialogs['AUX_SEARCH_AUTO_SNIPING'] = { + text = 'Do you want to activate automatic buyout for sniping?', + button1 = 'Yes', + button2 = 'No', + OnAccept = function() + private.snipe_button.auto = true + local color = RED_FONT_COLOR + private.snipe_button:GetFontString():SetTextColor(color.r, color.g, color.b) + end, + timeout = 0, + hideOnEscape = 1, +} private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3 @@ -244,7 +256,11 @@ function private.snipe(query, search) end, on_auction = function(auction_record) if not ignore_page then - sniping_map[auction_record.sniping_signature] = auction_record + if private.snipe_button.auto then + PlaceAuctionBid('list', auction_record.index, auction_record.buyout_price) + else + sniping_map[auction_record.sniping_signature] = auction_record + end end end, on_complete = function() diff --git a/panels/search/frames.lua b/panels/search/frames.lua index 91bc0c3..9f6961b 100644 --- a/panels/search/frames.lua +++ b/panels/search/frames.lua @@ -5,20 +5,31 @@ function Aux.search_frame.create_frames(private, public) btn:SetWidth(70) btn:SetHeight(25) btn:SetText('Snipe') + btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp') btn:SetScript('OnClick', function() - this.enabled = not this.enabled - if this.enabled then - this:LockHighlight() - else - this:UnlockHighlight() - end - if private.current_search().continuation and private.current_search().snipe == private.snipe_button.enabled then - private.enable_resume() - else - private.disable_resume() + if arg1 == 'LeftButton' then + this.enabled = not this.enabled + if this.enabled then + this:LockHighlight() + else + this:UnlockHighlight() + end + if private.current_search().continuation and private.current_search().snipe == private.snipe_button.enabled then + private.enable_resume() + else + private.disable_resume() + end + elseif arg1 == 'RightButton' then + if this.auto then + this.auto = false + this:GetFontString():SetTextColor(unpack(Aux.gui.config.text_color.enabled)) + else + StaticPopup_Show('AUX_SEARCH_AUTO_SNIPING') + end end end) btn.enabled = false + btn.auto = false private.snipe_button = btn end Aux.gui.vertical_line(AuxSearchFrame, 80, nil, 408)