From 30d1f40b50ef63f3298d883536d3325a4f7ad3a0 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Wed, 12 Oct 2016 19:51:16 +0200 Subject: [PATCH] auto buy refactoring --- aux-addon.toc | 2 +- core/scan.lua | 7 +- gui/auction_listing.lua | 2 +- gui/core.lua | 71 ++++++----- gui/item_listing.lua | 2 +- tabs/search/core.lua | 21 ++-- tabs/search/frame.lua | 255 +++++++++++----------------------------- tabs/search/results.lua | 60 +--------- tabs/search/saved.lua | 66 ++++++++++- 9 files changed, 183 insertions(+), 303 deletions(-) diff --git a/aux-addon.toc b/aux-addon.toc index 8021e16..663e72f 100644 --- a/aux-addon.toc +++ b/aux-addon.toc @@ -1,7 +1,7 @@ ## Interface: 11200 ## Title: aux ## Description: Auction House AddOn -## SavedVariablesPerCharacter: aux_auto_buy_filter, aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source +## SavedVariablesPerCharacter: aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source ## SavedVariables: aux_datasets, aux_items, aux_item_ids, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell, aux_characters, aux_recent_searches, aux_favorite_searches, aux_ignore_owner, aux_price_per_unit libs\inspect.lua diff --git a/core/scan.lua b/core/scan.lua index 1d885d4..83f2a38 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -156,12 +156,7 @@ function private.scan_page(i) history.process_auction(auction_info) - if (state.params.auto_buy_validator or nop)(auction_info) then - local send_signal, signal_received = signal() - when(signal_received, recurse) - place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, papply(send_signal, true)) - return thread(when, later(GetTime(), 10), send_signal, false) - elseif not query.validator or query.validator(auction_info) then + if not query.validator or query.validator(auction_info) then return wait_for_callback(state.params.on_auction, auction_info, function(removed) if removed then return recurse(true) diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index 1730b71..ce7f820 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -1017,7 +1017,7 @@ function public.CreateAuctionResultsTable(parent, config) rt.contentFrame = contentFrame -- frame to hold the header columns and the rows - local scrollFrame = CreateFrame('ScrollFrame', gui.name, rt, 'FauxScrollFrameTemplate') + local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name, rt, 'FauxScrollFrameTemplate') scrollFrame:SetScript('OnVerticalScroll', function() if not rt.scrollDisabled then FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end) diff --git a/gui/core.lua b/gui/core.lua index 25b2453..c86e046 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -20,7 +20,7 @@ function LOAD() aux_border:SetTexture(1, 1, 1, .02) aux_border:SetPoint('TOPLEFT', DropDownList1Backdrop, 'TOPLEFT', -2, 2) aux_border:SetPoint('BOTTOMRIGHT', DropDownList1Backdrop, 'BOTTOMRIGHT', 1.5, -1.5) - aux_border:SetBlendMode('ADD') + aux_border:SetBlendMode'ADD' aux_background = DropDownList1:CreateTexture(nil, 'OVERLAY') aux_background:SetTexture(color.content.background()) aux_background:SetAllPoints(DropDownList1Backdrop) @@ -76,7 +76,7 @@ function LOAD() text:SetShadowOffset(1, -1) local highlight = _G['DropDownList1Button' .. i..'Highlight'] highlight:SetAllPoints() - highlight:SetDrawLayer('BACKGROUND') + highlight:SetDrawLayer'BACKGROUND' local check = _G['DropDownList1Button' .. i..'Check'] check:SetWidth(24) check:SetHeight(24) @@ -88,30 +88,32 @@ end do local id = 1 - function public.name.get() + function public.unique_name.get() id = id + 1 return 'AuxFrame' .. id end end do - local menu, structure, orig - menu = CreateFrame('Frame', name, UIParent, 'UIMenuTemplate') - orig = menu:GetScript('OnShow') + local menu = CreateFrame('Frame', unique_name, UIParent, 'UIMenuTemplate') + local orig = menu:GetScript'OnShow' + local structure = t menu:SetScript('OnShow', function() UIMenu_Initialize() - for i = 1, getn(structure or empty) do + for i = 1, getn(structure), 2 do UIMenu_AddButton( - structure[i][1], structure[i], - type(structure[i]) == 'string' and structure[element[3]] or element[3] + nil, + structure[i + 1] ) end return orig() end) - function public.menu(menu_structure) - structure = menu_structure - menu:SetPoint('BOTTOMLEFT', GetCursorPosition()) + public.menu = vararg-function(arg) + structure = perm-arg + local x, y = GetCursorPosition() + menu:ClearAllPoints() + menu:SetPoint('BOTTOMLEFT', x + 75, y) menu:Show() end end @@ -172,14 +174,14 @@ function public.button(parent, text_height) local highlight = button:CreateTexture(nil, 'HIGHLIGHT') highlight:SetAllPoints() highlight:SetTexture(1, 1, 1, .2) - highlight:SetBlendMode('BLEND') + highlight:SetBlendMode'BLEND' button.highlight = highlight do local label = button:CreateFontString() label:SetFont(font, text_height) label:SetPoint('CENTER', 0, 0) - label:SetJustifyH('CENTER') - label:SetJustifyV('CENTER') + label:SetJustifyH'CENTER' + label:SetJustifyV'CENTER' label:SetHeight(text_height) label:SetTextColor(color.text.enabled()) button:SetFontString(label) @@ -198,17 +200,12 @@ function public.button(parent, text_height) return button end - -function public.resize_tab(tab, width, padding) - tab:SetWidth(width + padding + 10) -end - do - local mt = { __index=t } + local mt = {__index=t} function mt.__index:create_tab(text) local id = getn(self._tabs) + 1 - local tab = CreateFrame('Button', name, self._frame) + local tab = CreateFrame('Button', unique_name, self._frame) tab.id = id tab.group = self tab:SetHeight(24) @@ -227,14 +224,14 @@ do local highlight = tab:CreateTexture(nil, 'HIGHLIGHT') highlight:SetAllPoints() highlight:SetTexture(1, 1, 1, .2) - highlight:SetBlendMode('BLEND') + highlight:SetBlendMode'BLEND' tab.highlight = highlight tab.text = tab:CreateFontString() tab.text:SetPoint('LEFT', 3, -1) tab.text:SetPoint('RIGHT', -3, -1) - tab.text:SetJustifyH('CENTER') - tab.text:SetJustifyV('CENTER') + tab.text:SetJustifyH'CENTER' + tab.text:SetJustifyV'CENTER' tab.text:SetFont(font, font_size.large) tab:SetFontString(tab.text) @@ -242,7 +239,7 @@ do tab:SetScript('OnClick', function() if this.id ~= this.group.selected then - PlaySound('igCharacterInfoTab') + PlaySound'igCharacterInfoTab' this.group:select(this.id) end end) @@ -261,7 +258,7 @@ do end end - resize_tab(tab, tab:GetFontString():GetStringWidth(), 4) + tab:SetWidth(tab:GetFontString():GetStringWidth() + 14) tinsert(self._tabs, tab) end @@ -358,7 +355,7 @@ function public.editbox(parent) overlay:SetPoint('RIGHT', -1.5, 0) overlay:SetTextColor(color.text.enabled()) editbox.overlay = overlay - editbox:SetAlignment('LEFT') + editbox:SetAlignment'LEFT' editbox:SetFontSize(font_size.medium) return editbox end @@ -370,10 +367,10 @@ function public.status_bar(parent) do -- minor status bar (gray one) local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar') - status_bar:SetOrientation('HORIZONTAL') + status_bar:SetOrientation'HORIZONTAL' status_bar:SetMinMaxValues(0, 100) status_bar:SetAllPoints() - status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]]) + status_bar:SetStatusBarTexture[[Interface\Buttons\WHITE8X8]] status_bar:SetStatusBarColor(.42, .42, .42, .7) status_bar:SetFrameLevel(level + 2) status_bar:SetScript('OnUpdate', function() @@ -388,10 +385,10 @@ function public.status_bar(parent) do -- major status bar (main blue one) local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar') - status_bar:SetOrientation('HORIZONTAL') + status_bar:SetOrientation'HORIZONTAL' status_bar:SetMinMaxValues(0, 100) status_bar:SetAllPoints() - status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]]) + status_bar:SetStatusBarTexture[[Interface\Buttons\WHITE8X8]] status_bar:SetStatusBarColor(.19, .22, .33, .9) status_bar:SetFrameLevel(level + 3) status_bar:SetScript('OnUpdate', function() @@ -429,7 +426,7 @@ end function public.item(parent) local item = CreateFrame('Frame', nil, parent) set_size(item, 260, 40) - local btn = CreateFrame('CheckButton', name, item, 'ActionButtonTemplate') + local btn = CreateFrame('CheckButton', unique_name, item, 'ActionButtonTemplate') item.button = btn btn:SetPoint('LEFT', 2, .5) btn:SetHighlightTexture(nil) @@ -479,7 +476,7 @@ function public.vertical_line(parent, x_offset, top_offset, bottom_offset, inver end function public.dropdown(parent) - local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate') + local dropdown = CreateFrame('Frame', unique_name, parent, 'UIDropDownMenuTemplate') set_content_style(dropdown, 0, 0, 4, 4) _G[dropdown:GetName() .. 'Left']:Hide() @@ -505,7 +502,7 @@ end function public.slider(parent) local slider = CreateFrame('Slider', nil, parent) - slider:SetOrientation('HORIZONTAL') + slider:SetOrientation'HORIZONTAL' slider:SetHeight(6) slider:SetHitRectInsets(0, 0, -12, -12) slider:SetValue(0) @@ -530,7 +527,7 @@ function public.slider(parent) local editbox = editbox(slider) editbox:SetPoint('LEFT', slider, 'RIGHT', 5, 0) set_size(editbox, 45, 18) - editbox:SetAlignment('CENTER') + editbox:SetAlignment'CENTER' editbox:SetFontSize(17) slider.label = label @@ -548,6 +545,6 @@ function public.checkbox(parent) checkbox:GetHighlightTexture():SetAllPoints() checkbox:GetHighlightTexture():SetTexture(1, 1, 1, .2) checkbox:GetCheckedTexture():SetTexCoord(.12, .88, .12, .88) - checkbox:GetHighlightTexture('BLEND') + checkbox:GetHighlightTexture'BLEND' return checkbox end \ No newline at end of file diff --git a/gui/item_listing.lua b/gui/item_listing.lua index a10eba4..294360b 100644 --- a/gui/item_listing.lua +++ b/gui/item_listing.lua @@ -47,7 +47,7 @@ function public.create(parent, on_click, selected) content:SetPoint('TOPLEFT', 0, -51) content:SetPoint('BOTTOMRIGHT', -15, 0) - local scroll_frame = CreateFrame('ScrollFrame', gui.name .. 'ScrollFrame', parent, 'FauxScrollFrameTemplate') + local scroll_frame = CreateFrame('ScrollFrame', gui.unique_name .. 'ScrollFrame', parent, 'FauxScrollFrameTemplate') scroll_frame:SetScript('OnVerticalScroll', function(self, offset) FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end) end) diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 2606a71..05069e2 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -12,16 +12,16 @@ StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = { timeout = 0, hideOnEscape = 1, } -StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = { - text = 'Are you sure you want to activate automatic buyout?', - button1 = 'Yes', - button2 = 'No', - OnAccept = function() - auto_buy_button:SetChecked(true) - end, - timeout = 0, - hideOnEscape = 1, -} +--StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = { +-- text = 'Are you sure you want to activate automatic buyout?', +-- button1 = 'Yes', +-- button2 = 'No', +-- OnAccept = function() +-- auto_buy_button:SetChecked(true) +-- end, +-- timeout = 0, +-- hideOnEscape = 1, +--} private.RESULTS = 1 private.SAVED = 2 @@ -38,7 +38,6 @@ function OPEN() end function CLOSE() - close_settings() current_search.table:SetSelectedRecord() frame:Hide() end diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 32a019a..9a5f6e8 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -24,104 +24,23 @@ frame.saved = CreateFrame('Frame', nil, frame) frame.saved:SetAllPoints(AuxFrame.content) frame.saved.favorite = gui.panel(frame.saved) -frame.saved.favorite:SetWidth(378.5) -frame.saved.favorite:SetPoint('TOPLEFT', 0, 0) -frame.saved.favorite:SetPoint('BOTTOMLEFT', 0, 0) +frame.saved.favorite:SetWidth(252) +frame.saved.favorite:SetPoint('TOP', 0, 0) +frame.saved.favorite:SetPoint('BOTTOM', 0, 0) + +frame.saved.autobuy = gui.panel(frame.saved) +frame.saved.autobuy:SetPoint('TOPRIGHT', frame.saved.favorite, 'TOPLEFT', -2.5, 0) +frame.saved.autobuy:SetPoint('BOTTOMLEFT', 0, 0) frame.saved.recent = gui.panel(frame.saved) -frame.saved.recent:SetWidth(378.5) -frame.saved.recent:SetPoint('TOPRIGHT', 0, 0) +frame.saved.recent:SetPoint('TOPLEFT', frame.saved.favorite, 'TOPRIGHT', 2.5, 0) frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0) do - local btn = gui.button(frame) - btn:SetPoint('TOPLEFT', 0, 0) - btn:SetWidth(42) - btn:SetHeight(42) - btn:SetScript('OnClick', function() - if this.open then - settings:Hide() - controls:Show() - else - settings:Show() - controls:Hide() - end - this.open = not this.open - end) - - for _, offset in temp-A(14, 10, 6) do - local fake_icon_part = btn:CreateFontString() - fake_icon_part:SetFont([[Fonts\FRIZQT__.TTF]], 23) - fake_icon_part:SetPoint('CENTER', 0, offset) - fake_icon_part:SetText('_') - end - - private.settings_button = btn -end -do - local panel = CreateFrame('Frame', nil, frame) - panel:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]]} - panel:SetBackdropColor(color.content.background()) - panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0) - panel:SetPoint('RIGHT', 0, 0) - panel:SetHeight(42) - panel:Hide() - private.settings = panel -end -do - local panel = CreateFrame('Frame', nil, frame) - panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0) - panel:SetPoint('RIGHT', 0, 1) - panel:SetHeight(40) - private.controls = panel -end -do - local function change() - local page = tonumber(this:GetText()) - local valid_input = page and tostring(max(1, page)) or '' - if this:GetText() ~= valid_input then - this:SetText(valid_input) - end - if blizzard_page_index(this:GetText()) and not real_time_button:GetChecked() then - this:SetBackdropColor(color.state.enabled()) - else - this:SetBackdropColor(color.state.disabled()) - end - end - do - local editbox = gui.editbox(settings) - editbox:SetPoint('LEFT', 75, 0) - editbox:SetWidth(50) - editbox:SetNumeric(true) - editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end) - editbox.enter = execute - editbox.change = change - local label = gui.label(editbox, 16) - label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0) - label:SetText'Pages' - label:SetTextColor(color.text.enabled()) - private.first_page_input = editbox - end - do - local editbox = gui.editbox(settings) - editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 10, 0) - editbox:SetWidth(50) - editbox:SetNumeric(true) - editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end) - editbox.enter = execute - editbox.change = change - local label = gui.label(editbox, gui.font_size.medium) - label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0) - label:SetText'-' - label:SetTextColor(color.text.enabled()) - private.last_page_input = editbox - end -end -do - local btn = gui.checkbutton(settings) - btn:SetPoint('LEFT', 230, 0) - btn:SetWidth(140) + local btn = gui.checkbutton(frame) + btn:SetPoint('TOPLEFT', 5, -10) + btn:SetWidth(100) btn:SetHeight(25) - btn:SetText'Real Time Mode' + btn:SetText'Real Time' btn:SetScript('OnClick', function() this:SetChecked(not this:GetChecked()) this = first_page_input @@ -132,51 +51,46 @@ do private.real_time_button = btn end do - local btn = gui.checkbutton(settings) - btn:SetPoint('LEFT', real_time_button, 'RIGHT', 15, 0) - btn:SetWidth(140) - btn:SetHeight(25) - btn:SetText'Auto Buyout Mode' - btn:SetScript('OnClick', function() - if this:GetChecked() then - this:SetChecked(false) - else - StaticPopup_Show'AUX_SEARCH_AUTO_BUY' - end - end) - private.auto_buy_button = btn + local function change() + local page = tonumber(this:GetText()) + local valid_input = page and tostring(max(1, page)) or '' + if this:GetText() ~= valid_input then + this:SetText(valid_input) + end + end + do + local editbox = gui.editbox(frame) + editbox:SetPoint('LEFT', real_time_button, 'RIGHT', 5, 0) + editbox:SetWidth(50) + editbox:SetHeight(25) + editbox:SetNumeric(true) + editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end) + editbox.enter = execute + editbox.change = change + local label = gui.label(editbox, 16) + label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0) + label:SetTextColor(color.text.enabled()) + private.first_page_input = editbox + end + do + local editbox = gui.editbox(frame) + editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 10, 0) + editbox:SetWidth(50) + editbox:SetHeight(25) + editbox:SetNumeric(true) + editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end) + editbox.enter = execute + editbox.change = change + local label = gui.label(editbox, gui.font_size.medium) + label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0) + label:SetText'-' + label:SetTextColor(color.text.enabled()) + private.last_page_input = editbox + end end do - local btn = gui.checkbutton(settings) - btn:SetPoint('LEFT', auto_buy_button, 'RIGHT', 15, 0) - btn:SetWidth(140) - btn:SetHeight(25) - btn:SetText'Auto Buyout Filter' - btn:SetScript('OnClick', function() - if this:GetChecked() then - this:SetChecked(false) - aux_auto_buy_filter = nil - this.prettified = nil - auto_buy_validator = nil - else - StaticPopup_Show'AUX_SEARCH_AUTO_BUY_FILTER' - end - end) - btn:SetScript('OnEnter', function() - if this.prettified then - GameTooltip_SetDefaultAnchor(GameTooltip, UIParent) - GameTooltip:AddLine(gsub(this.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true) - GameTooltip:Show() - end - end) - btn:SetScript('OnLeave', function() - GameTooltip:Hide() - end) - private.auto_buy_filter_button = btn -end -do - local btn = gui.button(controls, 25) - btn:SetPoint('LEFT', 5, 0) + local btn = gui.button(frame, 25) + btn:SetPoint('LEFT', last_page_input, 'RIGHT', 5, 0) btn:SetWidth(30) btn:SetHeight(25) btn:SetText'<' @@ -184,7 +98,7 @@ do private.previous_button = btn end do - local btn = gui.button(controls, 25) + local btn = gui.button(frame, 25) btn:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0) btn:SetWidth(30) btn:SetHeight(25) @@ -193,8 +107,8 @@ do private.next_button = btn end do - local btn = gui.button(controls, gui.font_size.huge) - btn:SetPoint('RIGHT', -5, 0) + local btn = gui.button(frame, gui.font_size.huge) + btn:SetPoint('TOPRIGHT', -5, -10) btn:SetWidth(70) btn:SetHeight(25) btn:SetText'Start' @@ -208,8 +122,8 @@ do private.start_button = btn end do - local btn = gui.button(controls, gui.font_size.huge) - btn:SetPoint('RIGHT', -5, 0) + local btn = gui.button(frame, gui.font_size.huge) + btn:SetPoint('TOPRIGHT', -5, -10) btn:SetWidth(70) btn:SetHeight(25) btn:SetText'Stop' @@ -219,7 +133,7 @@ do private.stop_button = btn end do - local btn = gui.button(controls, gui.font_size.huge) + local btn = gui.button(frame, gui.font_size.huge) btn:SetPoint('RIGHT', start_button, 'LEFT', -4, 0) btn:SetWidth(70) btn:SetHeight(25) @@ -230,7 +144,7 @@ do private.resume_button = btn end do - local editbox = gui.editbox(controls) + local editbox = gui.editbox(frame) editbox:EnableMouse(1) editbox.formatter = function(str) local queries = filter_util.queries(str) @@ -615,53 +529,16 @@ for _ = 1, 5 do tinsert(tables, table) end -local handlers = { - OnClick = function(st, data, _, button) - if not data then return end - if button == 'LeftButton' and IsShiftKeyDown() then - search_box:SetText(data.search.filter_string) - elseif button == 'RightButton' and IsShiftKeyDown() then - add_filter(data.search.filter_string) - elseif button == 'LeftButton' and IsControlKeyDown() then - if st == favorite_searches_listing and data.index > 1 then - local temp = aux_favorite_searches[data.index - 1] - aux_favorite_searches[data.index - 1] = data.search - aux_favorite_searches[data.index] = temp - update_search_listings() - end - elseif button == 'RightButton' and IsControlKeyDown() then - if st == favorite_searches_listing and data.index < getn(aux_favorite_searches) then - local temp = aux_favorite_searches[data.index + 1] - aux_favorite_searches[data.index + 1] = data.search - aux_favorite_searches[data.index] = temp - update_search_listings() - end - elseif button == 'LeftButton' then - search_box:SetText(data.search.filter_string) - execute() - elseif button == 'RightButton' then - if st == recent_searches_listing then - tinsert(aux_favorite_searches, 1, data.search) - elseif st == favorite_searches_listing then - tremove(aux_favorite_searches, data.index) - end - update_search_listings() - end - end, - OnEnter = function(st, data, self) - if not data then return end - GameTooltip_SetDefaultAnchor(GameTooltip, UIParent) - GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true) - GameTooltip:Show() - end, - OnLeave = function() - GameTooltip:ClearLines() - GameTooltip:Hide() - end -} +private.autobuy_listing = listing.CreateScrollingTable(frame.saved.autobuy) +autobuy_listing:SetColInfo{{name='Autobuy Filters', width=1}} +autobuy_listing:EnableSorting(false) +autobuy_listing:DisableSelection(true) +autobuy_listing:SetHandler('OnClick', handlers.OnClick) +autobuy_listing:SetHandler('OnEnter', handlers.OnEnter) +autobuy_listing:SetHandler('OnLeave', handlers.OnLeave) private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent) -recent_searches_listing:SetColInfo{{ name='Recent Searches', width=1 }} +recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}} recent_searches_listing:EnableSorting(false) recent_searches_listing:DisableSelection(true) recent_searches_listing:SetHandler('OnClick', handlers.OnClick) @@ -669,7 +546,7 @@ recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter) recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave) private.favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite) -favorite_searches_listing:SetColInfo{{ name='Favorite Searches', width=1 }} +favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}} favorite_searches_listing:EnableSorting(false) favorite_searches_listing:DisableSelection(true) favorite_searches_listing:SetHandler('OnClick', handlers.OnClick) diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 7a16af5..6b93dff 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -8,39 +8,6 @@ local scan = require 'aux.core.scan' function LOAD() new_search'' current_search.dummy = true - update_auto_buy_filter() -end - -aux_auto_buy_filter = '' - -do - local function action() - aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText() - update_auto_buy_filter() - end - - StaticPopupDialogs.AUX_SEARCH_AUTO_BUY_FILTER = { - text = 'Enter a filter for automatic buyout.', - button1 = 'Accept', - button2 = 'Cancel', - hasEditBox = 1, - OnShow = function() - local edit_box = _G[this:GetName() .. 'EditBox'] - edit_box:SetMaxLetters(nil) - edit_box:SetFocus() - edit_box:HighlightText() - end, - OnAccept = action, - EditBoxOnEnterPressed = function() - action() - this:GetParent():Hide() - end, - EditBoxOnEscapePressed = function() - this:GetParent():Hide() - end, - timeout = 0, - hideOnEscape = 1, - } end do @@ -127,12 +94,6 @@ do end end -function private.close_settings() - if settings_button.open then - settings_button:Click() - end -end - function private.update_continuation() if current_search.continuation then resume_button:Show() @@ -149,7 +110,7 @@ function private.discard_continuation() update_continuation() end -function update_start_stop() +function private.update_start_stop() if current_search.active then stop_button:Show() start_button:Hide() @@ -169,8 +130,6 @@ function private.update_auto_buy_filter() print 'Error: The automatic buyout filter does not support Blizzard filters' else auto_buy_validator = queries[1].validator - auto_buy_filter_button.prettified = queries[1].prettified - auto_buy_filter_button:SetChecked(true) return end else @@ -206,15 +165,9 @@ function private.start_real_time_scan(query, search, continuation) ignore_page = false end end, - on_auction = function(auction_record, ctrl) + on_auction = function(auction_record) if not ignore_page then - if search.auto_buy then - ctrl.suspend() - place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true)) - thread(when, later(GetTime(), 10), ctrl.resume, false) - else - tinsert(new_records, auction_record) - end + tinsert(new_records, auction_record) end end, on_complete = function() @@ -301,11 +254,7 @@ function private.start_search(queries, continuation) current_page = current_page and 0 or start_page - 1 end, on_auction = function(auction_record, ctrl) - if search.auto_buy then - ctrl.suspend() - place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true)) - thread(when, later(GetTime(), 10), ctrl.resume, false) - elseif getn(search.records) < 2000 then + if getn(search.records) < 2000 then tinsert(search.records, auction_record) if getn(search.records) == 2000 then StaticPopup_Show'AUX_SEARCH_TABLE_FULL' @@ -390,7 +339,6 @@ function public.execute(resume, real_time) end end current_search.real_time = real_time_button:GetChecked() - current_search.auto_buy = auto_buy_button:GetChecked() current_search.auto_buy_validator = auto_buy_validator end diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index 5ca41f9..0b53486 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -1,9 +1,21 @@ module 'aux.tabs.search' +aux_autobuy_filters = t aux_favorite_searches = t aux_recent_searches = t function private.update_search_listings() + local autobuy_filter_rows = t + for i, autobuy_filter in aux_autobuy_filters do + local name = strsub(autobuy_filter.prettified, 1, 250) + tinsert(autobuy_filter_rows, { + cols = {{ value=name }}, + search = autobuy_filter, + index = i, + }) + end + autobuy_listing:SetData(autobuy_filter_rows) + local favorite_search_rows = t for i, favorite_search in aux_favorite_searches do local name = strsub(favorite_search.prettified, 1, 250) @@ -36,4 +48,56 @@ function private.new_recent_search(filter_string, prettified) tremove(aux_recent_searches) end update_search_listings() -end \ No newline at end of file +end + +private.handlers = { + OnClick = function(st, data, _, button) + if not data then return end + if button == 'LeftButton' and IsShiftKeyDown() then + search_box:SetText(data.search.filter_string) + elseif button == 'RightButton' and IsShiftKeyDown() then + add_filter(data.search.filter_string) + elseif button == 'LeftButton' and IsControlKeyDown() then + if st == favorite_searches_listing and data.index > 1 then + local temp = aux_favorite_searches[data.index - 1] + aux_favorite_searches[data.index - 1] = data.search + aux_favorite_searches[data.index] = temp + update_search_listings() + end + elseif button == 'RightButton' and IsControlKeyDown() then + if st == favorite_searches_listing and data.index < getn(aux_favorite_searches) then + local temp = aux_favorite_searches[data.index + 1] + aux_favorite_searches[data.index + 1] = data.search + aux_favorite_searches[data.index] = temp + update_search_listings() + end + elseif button == 'RightButton' and IsAltKeyDown() then + if st ~= autobuy_listing then + tinsert(aux_autobuy_filters, 1, data.search) + update_search_listings() + end + elseif button == 'LeftButton' then + search_box:SetText(data.search.filter_string) + execute() + elseif button == 'RightButton' then + if st == autobuy_listing then + tremove(aux_autobuy_filters, data.index) + elseif st == recent_searches_listing then + tinsert(aux_favorite_searches, 1, data.search) + elseif st == favorite_searches_listing then + tremove(aux_favorite_searches, data.index) + end + update_search_listings() + end + end, + OnEnter = function(st, data, self) + if not data then return end + GameTooltip_SetDefaultAnchor(GameTooltip, UIParent) + GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true) + GameTooltip:Show() + end, + OnLeave = function() + GameTooltip:ClearLines() + GameTooltip:Hide() + end +} \ No newline at end of file