From 5fb208f5aecc92390e5889490e56c55bd068a181 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 30 Jan 2016 13:12:32 +0100 Subject: [PATCH] more progress on the new filter tab --- Aux-AddOn.toc | 2 +- auctions_frame.lua | 14 ++- bids_frame.lua | 14 ++- core.lua | 34 +++---- filter_search_frame.lua | 171 ++++++++++++++++++++--------------- filter_search_frame.xml | 79 ++++++---------- groups.lua | 13 +++ gui.lua | 196 ++++++++++++++++++++++++++-------------- item_search_frame.lua | 4 +- scan_util.lua | 33 ++++--- 10 files changed, 326 insertions(+), 234 deletions(-) diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc index bc96d34..febc735 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_recently_searched, aux_recent_searches, aux_favorite_searches, aux_bid, aux_view, AUX_AUCTION_DURATION +## SavedVariablesPerCharacter: aux_recently_searched, aux_recent_searches, aux_favorite_searches, aux_view, AUX_AUCTION_DURATION ## SavedVariables: aux_database, aux_auctionable_items slash.lua diff --git a/auctions_frame.lua b/auctions_frame.lua index f64d3b6..f76b6df 100644 --- a/auctions_frame.lua +++ b/auctions_frame.lua @@ -132,10 +132,20 @@ function public.on_load() btn:Disable() private.cancel_button = btn end + do + local btn = Aux.gui.button(AuxAuctionsFrame, 16) + btn:SetPoint('TOPLEFT', private.cancel_button, 'TOPRIGHT', 5, 0) + btn:SetWidth(80) + btn:SetHeight(24) + btn:SetText('Refresh') + btn:SetScript('OnClick', function() + public.scan_auctions() + end) + end end function public.on_open() - public.update_auction_records() + public.scan_auctions() refresh = true end @@ -143,7 +153,7 @@ function public.on_close() private.clear_selection() end -function public.update_auction_records() +function public.scan_auctions() private.status_bar:update_status(0,0) private.status_bar:set_text('Scanning auctions...') diff --git a/bids_frame.lua b/bids_frame.lua index c772227..a450f0e 100644 --- a/bids_frame.lua +++ b/bids_frame.lua @@ -147,10 +147,20 @@ function public.on_load() btn:Disable() private.bid_button = btn end + do + local btn = Aux.gui.button(AuxBidsFrame, 16) + btn:SetPoint('TOPLEFT', private.bid_button, 'TOPRIGHT', 5, 0) + btn:SetWidth(80) + btn:SetHeight(24) + btn:SetText('Refresh') + btn:SetScript('OnClick', function() + public.scan_bids() + end) + end end function public.on_open() - public.update_bid_records() + public.scan_bids() refresh = true end @@ -158,7 +168,7 @@ function public.on_close() private.clear_selection() end -function public.update_bid_records() +function public.scan_bids() private.status_bar:update_status(0,0) private.status_bar:set_text('Scanning auctions...') diff --git a/core.lua b/core.lua index 65eb021..e06a5c2 100644 --- a/core.lua +++ b/core.lua @@ -62,22 +62,6 @@ function Aux_OnLoad() tab_group.on_select = Aux.on_tab_click Aux.tab_group = tab_group end - do - local btn = Aux.gui.button(AuxFrame, 12) - btn:SetPoint('TOPRIGHT', 0, 0) - btn:SetWidth(60) - btn:SetHeight(17) - btn:SetText('Default UI') - btn:SetScript('OnClick',function() - if AuctionFrame:IsVisible() then - Aux.blizzard_ui_shown = false - HideUIPanel(AuctionFrame) - else - Aux.blizzard_ui_shown = true - ShowUIPanel(AuctionFrame) - end - end) - end do local btn = Aux.gui.button(AuxFrame, 16) @@ -88,6 +72,24 @@ function Aux_OnLoad() btn:SetScript('OnClick',function() HideUIPanel(this:GetParent()) end) + Aux.close_button = btn + end + + do + local btn = Aux.gui.button(AuxFrame, 16) + btn:SetPoint('RIGHT', Aux.close_button, 'LEFT' , -5, 0) + btn:SetWidth(65) + btn:SetHeight(24) + btn:SetText('Default UI') + btn:SetScript('OnClick',function() + if AuctionFrame:IsVisible() then + Aux.blizzard_ui_shown = false + HideUIPanel(AuctionFrame) + else + Aux.blizzard_ui_shown = true + ShowUIPanel(AuctionFrame) + end + end) end Aux.item_search_frame.on_load() diff --git a/filter_search_frame.lua b/filter_search_frame.lua index bb1561f..cdb74e2 100644 --- a/filter_search_frame.lua +++ b/filter_search_frame.lua @@ -95,6 +95,9 @@ end function public.on_open() private.update_search_listings() private.update_tab(SAVED) + + AuxFilterSearchFrameResults:SetWidth(985) + AuxFrame:SetWidth(991) end function public.on_load() @@ -117,7 +120,7 @@ function public.on_load() columns = { { width = 900, - comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.LT) end, + comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.GT) end, cell_initializer = Aux.sheet.default_cell_initializer('LEFT'), cell_setter = function(cell, filter_string) cell.text:SetText(filter_string) @@ -145,7 +148,7 @@ function public.on_load() columns = { { width = 900, - comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.LT) end, + comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.GT) end, cell_initializer = Aux.sheet.default_cell_initializer('LEFT'), cell_setter = function(cell, filter_string) cell.text:SetText(filter_string) @@ -155,7 +158,7 @@ function public.on_load() sort_order = {{ column = 1, order = 'ascending' }}, } private.results_config = { - frame = AuxFilterSearchFrameResultsBuyListing, + frame = AuxFilterSearchFrameResultsListing, on_row_click = function(sheet, row_index) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) private.on_row_click(sheet.data[data_index], true) @@ -301,7 +304,7 @@ function public.on_load() end do local btn = Aux.gui.button(AuxFilterSearchFrame, 22) - btn:SetPoint('TOPRIGHT', -5, -3) + btn:SetPoint('TOPRIGHT', -5, -6) btn:SetWidth(60) btn:SetHeight(25) btn:SetText('Search') @@ -310,7 +313,7 @@ function public.on_load() end do local btn = Aux.gui.button(AuxFilterSearchFrame, 22) - btn:SetPoint('TOPRIGHT', -5, -3) + btn:SetPoint('TOPRIGHT', -5, -6) btn:SetWidth(60) btn:SetHeight(25) btn:SetText('Stop') @@ -320,8 +323,8 @@ function public.on_load() end do local editbox = Aux.gui.editbox(AuxFilterSearchFrame) - editbox:SetPoint('TOPLEFT', 5, -3) - editbox:SetPoint('TOPRIGHT', private.search_button, 'TOPLEFT', -4, -5) + editbox:SetPoint('TOPLEFT', 5, -6) + editbox:SetPoint('RIGHT', private.search_button, 'LEFT', -4, 0) editbox:SetWidth(400) editbox:SetHeight(25) -- editbox:SetScript('OnTabPressed', function() @@ -341,13 +344,13 @@ function public.on_load() private.search_box = editbox end do - Aux.gui.horizontal_line(AuxFilterSearchFrame, -35) + Aux.gui.horizontal_line(AuxFilterSearchFrame, -37) end do local btn = Aux.gui.button(AuxFilterSearchFrame, 18) - btn:SetPoint('TOPLEFT', 10, -40) - btn:SetWidth(330) - btn:SetHeight(24) + btn:SetPoint('TOPLEFT', 10, -49) + btn:SetWidth(310) + btn:SetHeight(22) btn:SetText('Search Results') btn:SetScript('OnClick', function() private.update_tab(RESULTS) end) private.search_results_button = btn @@ -355,8 +358,8 @@ function public.on_load() do local btn = Aux.gui.button(AuxFilterSearchFrame, 18) btn:SetPoint('TOPLEFT', private.search_results_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(330) - btn:SetHeight(24) + btn:SetWidth(310) + btn:SetHeight(22) btn:SetText('Saved Searches') btn:SetScript('OnClick', function() private.update_tab(SAVED) end) private.saved_searches_button = btn @@ -364,12 +367,24 @@ function public.on_load() do local btn = Aux.gui.button(AuxFilterSearchFrame, 18) btn:SetPoint('TOPLEFT', private.saved_searches_button, 'TOPRIGHT', 5, 0) - btn:SetWidth(330) - btn:SetHeight(24) + btn:SetWidth(310) + btn:SetHeight(22) btn:SetText('New Filter') btn:SetScript('OnClick', function() private.update_tab(FILTER) end) private.new_filter_button = btn end + do + local line = Aux.gui.horizontal_line(AuxFilterSearchFrameSavedRecent, -25) + local label = Aux.gui.label(AuxFilterSearchFrameSavedRecent, 13) + label:SetPoint('BOTTOM', line, 'TOP', 0, 5) + label:SetText('Recent Searches') + end + do + local line = Aux.gui.horizontal_line(AuxFilterSearchFrameSavedFavorite, -25) + local label = Aux.gui.label(AuxFilterSearchFrameSavedFavorite, 13) + label:SetPoint('BOTTOM', line, 'TOP', 0, 5) + label:SetText('Favorite Searches') + end do local editbox = Aux.gui.editbox(private.elements[FILTER].item_filter) local function add_item_filter(item_id) @@ -489,14 +504,32 @@ function public.on_load() label:SetText('Name') end do - local label = Aux.gui.label(AuxFilterSearchFrameFiltersCategoryDropDown, 13) - label:SetPoint('BOTTOMLEFT', AuxFilterSearchFrameFiltersCategoryDropDown, 'TOPLEFT', -2, -4) + local dropdown = Aux.gui.dropdown(private.elements[FILTER].filters) + dropdown:SetPoint('TOPLEFT', 14, -53) + dropdown:SetWidth(250) + dropdown:SetHeight(10) + local label = Aux.gui.label(dropdown, 13) + label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4) label:SetText('Category') + private.category_dropdown = dropdown + UIDropDownMenu_Initialize(dropdown, AuxFilterSearchFrameFiltersCategoryDropDown_Initialize) + dropdown:SetScript('OnShow', function() + UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersQualityDropDown_Initialize) + end) end do - local label = Aux.gui.label(AuxFilterSearchFrameFiltersQualityDropDown, 13) - label:SetPoint('BOTTOMLEFT', AuxFilterSearchFrameFiltersQualityDropDown, 'TOPLEFT', -2, -4) - label:SetText('Rarity') + local dropdown = Aux.gui.dropdown(private.elements[FILTER].filters) + dropdown:SetPoint('TOPLEFT', 14, -93) + dropdown:SetWidth(250) + dropdown:SetHeight(10) + local label = Aux.gui.label(dropdown, 13) + label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4) + label:SetText('Min Rarity') + private.quality_dropdown = dropdown + UIDropDownMenu_Initialize(dropdown, AuxFilterSearchFrameFiltersQualityDropDown_Initialize) + dropdown:SetScript('OnShow', function() + UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersQualityDropDown_Initialize) + end) end do local editbox = Aux.gui.editbox(private.elements[FILTER].filters, '$parentMinLevel') @@ -634,28 +667,29 @@ function public.on_load() -- TODO replace with real gui dropdown -- CreateFrame('Frame', '$parentCategoryDropDown', AuxFilterSearchFrameFilters, 'UIDropDownMenuTemplate') -- local dropdown = CreateFrame('Frame', '$parentQualityDropDown', AuxFilterSearchFrameFilters, 'UIDropDownMenuTemplate') - for _, dropdown in ipairs({AuxFilterSearchFrameFiltersCategoryDropDown, AuxFilterSearchFrameFiltersQualityDropDown}) do - dropdown:SetWidth(250) - dropdown:SetHeight(10) - dropdown:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=Aux.gui.config.edge_size, insets={top=5,bottom=5}}) - dropdown:SetBackdropColor(unpack(Aux.gui.config.content_color)) - dropdown:SetBackdropBorderColor(unpack(Aux.gui.config.content_border_color)) - local left = getglobal(dropdown:GetName()..'Left'):Hide() - local middle = getglobal(dropdown:GetName()..'Middle'):Hide() - local right = getglobal(dropdown:GetName()..'Right'):Hide() - local button = getglobal(dropdown:GetName()..'Button') --- button:RegisterForClicks('AnyUp') - button:ClearAllPoints() - button:SetPoint('RIGHT', dropdown, 0, 0) - - local text = getglobal(dropdown:GetName()..'Text') - text:ClearAllPoints() - text:SetPoint('RIGHT', button, 'LEFT', -2, 0) - text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0) - text:SetFont(Aux.gui.config.content_font, 13) - text:SetShadowColor(0, 0, 0, 0) - end +-- for _, dropdown in ipairs({AuxFilterSearchFrameFiltersCategoryDropDown, AuxFilterSearchFrameFiltersQualityDropDown}) do +-- dropdown:SetWidth(250) +-- dropdown:SetHeight(10) +-- dropdown:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=Aux.gui.config.edge_size, insets={top=5,bottom=5}}) +-- dropdown:SetBackdropColor(unpack(Aux.gui.config.content_color)) +-- dropdown:SetBackdropBorderColor(unpack(Aux.gui.config.content_border_color)) +-- local left = getglobal(dropdown:GetName()..'Left'):Hide() +-- local middle = getglobal(dropdown:GetName()..'Middle'):Hide() +-- local right = getglobal(dropdown:GetName()..'Right'):Hide() +-- +-- local button = getglobal(dropdown:GetName()..'Button') +---- button:RegisterForClicks('AnyUp') +-- button:ClearAllPoints() +-- button:SetPoint('RIGHT', dropdown, 0, 0) +-- +-- local text = getglobal(dropdown:GetName()..'Text') +-- text:ClearAllPoints() +-- text:SetPoint('RIGHT', button, 'LEFT', -2, 0) +-- text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0) +-- text:SetFont(Aux.gui.config.content_font, 13) +-- text:SetShadowColor(0, 0, 0, 0) +-- end end function public.stop_search() @@ -668,11 +702,6 @@ function private.update_listing() return end - AuxFilterSearchFrameResultsBuyListing:Hide() - AuxFilterSearchFrameResultsBidListing:Hide() - AuxFilterSearchFrameResultsFullListing:Hide() - - 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.sheet.populate(private.listings.results, auctions and Aux.util.group_by(buyout_auctions, function(a1, a2) return a1.item_id == a2.item_id @@ -683,34 +712,12 @@ function private.update_listing() and a1.bid_price == a2.bid_price and a1.owner == a2.owner end) or {}) - AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsBuyListing:GetWidth() + 40) - AuxFrame:SetWidth(AuxFilterSearchFrameResults:GetWidth() + 15) end function public.start_search() - tinsert(aux_recent_searches, 1, private.search_box:GetText()) - while getn(aux_recent_searches) > 50 do - tremove(aux_recent_searches) - end - private.update_search_listings() - Aux.scan.abort(function() - private.update_tab(RESULTS) - - private.clear_selection() - - private.status_bar:update_status(0,0) - private.status_bar:set_text('Scanning auctions...') - - private.search_button:Hide() - private.stop_button:Show() - - auctions = nil - - refresh = true - local tooltip_patterns = {} for i=1,4 do local tooltip_pattern = getglobal('AuxFilterSearchFrameFiltersTooltipInputBox'..i):GetText() @@ -719,8 +726,6 @@ function public.start_search() end end - local group = Aux.groups.parse_group(Aux.groups.test_group) - local queries -- queries = { private.create_filter_query() } @@ -738,6 +743,22 @@ function public.start_search() return end + tinsert(aux_recent_searches, 1, private.search_box:GetText()) + while getn(aux_recent_searches) > 50 do + tremove(aux_recent_searches) + end + private.update_search_listings() + + private.clear_selection() + private.search_button:Hide() + private.stop_button:Show() + auctions = nil + refresh = true + + private.update_tab(RESULTS) + + private.status_bar:update_status(0,0) + private.status_bar:set_text('Scanning auctions...') Aux.scan.start{ queries = queries, @@ -857,7 +878,7 @@ end function private.create_auction_record(auction_info) local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil - local unit_buyout_price = buyout_price and Aux.round(auction_info.buyout_price / auction_info.aux_quantity) + local unit_buyout_price = buyout_price and auction_info.buyout_price / auction_info.aux_quantity local status if auction_info.current_bid == 0 then status = 'No Bid' @@ -889,7 +910,7 @@ function private.create_auction_record(auction_info) hyperlink = auction_info.hyperlink, itemstring = auction_info.itemstring, bid_price = auction_info.bid_price, - unit_bid_price = Aux.round(auction_info.bid_price / auction_info.aux_quantity), + unit_bid_price = auction_info.bid_price / auction_info.aux_quantity, owner = auction_info.owner, duration = auction_info.duration, usable = auction_info.usable, @@ -967,15 +988,15 @@ function AuxFilterSearchFrameFiltersCategoryDropDown_OnClick() end end - UIDropDownMenu_SetSelectedValue(AuxFilterSearchFrameFiltersCategoryDropDown, this.value) - UIDropDownMenu_SetText(qualified_name, AuxFilterSearchFrameFiltersCategoryDropDown) + UIDropDownMenu_SetSelectedValue(private.category_dropdown, this.value) + UIDropDownMenu_SetText(qualified_name, private.category_dropdown) CloseDropDownMenus(1) end function AuxFilterSearchFrameFiltersQualityDropDown_Initialize() local function on_click() - UIDropDownMenu_SetSelectedValue(AuxFilterSearchFrameFiltersQualityDropDown, this.value) + UIDropDownMenu_SetSelectedValue(private.quality_dropdown, this.value) end UIDropDownMenu_AddButton{ diff --git a/filter_search_frame.xml b/filter_search_frame.xml index 232b41b..38dd4fa 100644 --- a/filter_search_frame.xml +++ b/filter_search_frame.xml @@ -12,39 +12,15 @@ - + - - - - - - UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersCategoryDropDown_Initialize) - - - UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersCategoryDropDown_Initialize) - - - - - - - - - UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersQualityDropDown_Initialize) - - - UIDropDownMenu_Initialize(this, AuxFilterSearchFrameFiltersQualityDropDown_Initialize) - - - - + - + @@ -52,41 +28,42 @@ - + - + - + - - - - - - - - - - - - - - + + - - + + - - + + + + + + + + + - - - + + + + + + + + + diff --git a/groups.lua b/groups.lua index 79f21ff..96e5149 100644 --- a/groups.lua +++ b/groups.lua @@ -17,4 +17,17 @@ m.test_group = '13127;9510;4438;16254;12006;13131;13012;4413;1482' function m.test() local array = Aux.persistence.deserialize(';', ';') snipe.log(getn(array)) +end + +function on_char() + for _, data in ipairs(TSM.db.global.savedSearches) do + if data.searchMode == "normal" then + local prevSearch = strlower(data.filter) + if strsub(prevSearch, 1, textLen) == text then + self:SetText(prevSearch) + self:HighlightText(textLen, -1) + break + end + end + end end \ No newline at end of file diff --git a/gui.lua b/gui.lua index faad725..75637d3 100644 --- a/gui.lua +++ b/gui.lua @@ -370,80 +370,101 @@ function m.vertical_line(parent, x_offset, inverted_color) return texture end -function m.dropdown() - local count = AceGUI:GetNextWidgetNum(Type) +do + local id = 0 + function m.dropdown(parent) + id = id + 1 - local frame = CreateFrame("Frame", nil, UIParent) - local dropdown = CreateFrame("Frame", "TSMDropDown"..count, frame, "UIDropDownMenuTemplate") + -- local frame = CreateFrame("Frame", nil, UIParent) + local dropdown = CreateFrame('Frame', 'aux_dropdown'..id, parent, 'UIDropDownMenuTemplate') - frame:SetScript("OnHide", Dropdown_OnHide) + dropdown:SetBackdrop({bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=Aux.gui.config.edge_size, insets={top=5,bottom=5}}) + dropdown:SetBackdropColor(unpack(Aux.gui.config.content_color)) + dropdown:SetBackdropBorderColor(unpack(Aux.gui.config.content_border_color)) + local left = getglobal(dropdown:GetName()..'Left'):Hide() + local middle = getglobal(dropdown:GetName()..'Middle'):Hide() + local right = getglobal(dropdown:GetName()..'Right'):Hide() - dropdown:ClearAllPoints() - dropdown:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -7, 0) - dropdown:SetScript("OnHide", nil) - dropdown:SetScript("OnEnter", Control_OnEnter) - dropdown:SetScript("OnLeave", Control_OnLeave) - dropdown:SetScript("OnMouseUp", function(self, button) Dropdown_TogglePullout(self.obj.button, button) end) - TSMAPI.Design:SetContentColor(dropdown) + local button = getglobal(dropdown:GetName()..'Button') + button:ClearAllPoints() + button:SetPoint('RIGHT', dropdown, 0, 0) - local left = _G[dropdown:GetName().."Left"] - local middle = _G[dropdown:GetName().."Middle"] - local right = _G[dropdown:GetName().."Right"] + local text = getglobal(dropdown:GetName()..'Text') + text:ClearAllPoints() + text:SetPoint('RIGHT', button, 'LEFT', -2, 0) + text:SetPoint('LEFT', dropdown, 'LEFT', 8, 0) + text:SetFont(Aux.gui.config.content_font, 13) + text:SetShadowColor(0, 0, 0, 0) - middle:ClearAllPoints() - right:ClearAllPoints() + -- frame:SetScript("OnHide", Dropdown_OnHide) + -- + -- dropdown:ClearAllPoints() + -- dropdown:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -7, 0) + -- dropdown:SetScript("OnHide", nil) + -- dropdown:SetScript("OnEnter", Control_OnEnter) + -- dropdown:SetScript("OnLeave", Control_OnLeave) + -- dropdown:SetScript("OnMouseUp", function(self, button) Dropdown_TogglePullout(self.obj.button, button) end) + -- TSMAPI.Design:SetContentColor(dropdown) + -- + -- local left = _G[dropdown:GetName().."Left"] + -- local middle = _G[dropdown:GetName().."Middle"] + -- local right = _G[dropdown:GetName().."Right"] + -- + -- middle:ClearAllPoints() + -- right:ClearAllPoints() + -- + -- middle:SetPoint("LEFT", left, "RIGHT", 0, 0) + -- middle:SetPoint("RIGHT", right, "LEFT", 0, 0) + -- right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17) + -- + -- local button = _G[dropdown:GetName().."Button"] + -- button:RegisterForClicks("AnyUp") + -- button:SetScript("OnEnter", Control_OnEnter) + -- button:SetScript("OnLeave", Control_OnLeave) + -- button:SetScript("OnClick", Dropdown_TogglePullout) + -- button:ClearAllPoints() + -- button:SetPoint("RIGHT", dropdown, 0, 0) + -- + -- local text = _G[dropdown:GetName().."Text"] + -- text:ClearAllPoints() + -- text:SetPoint("RIGHT", button, "LEFT", -2, 0) + -- text:SetPoint("LEFT", dropdown, "LEFT", 8, 0) + -- text:SetFont(TSMAPI.Design:GetContentFont("normal")) + -- text:SetShadowColor(0, 0, 0, 0) + -- + -- local label = frame:CreateFontString(nil, "OVERLAY") + -- label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) + -- label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, 0) + -- label:SetJustifyH("LEFT") + -- label:SetHeight(18) + -- label:SetFont(TSMAPI.Design:GetContentFont("small")) + -- label:SetShadowColor(0, 0, 0, 0) + -- label:Hide() + -- + -- left:Hide() + -- middle:Hide() + -- right:Hide() + -- + -- local widget = { + -- frame = frame, + -- label = label, + -- dropdown = dropdown, + -- text = text, + -- button = button, + -- count = count, + -- alignoffset = 30, + -- type = Type, + -- } + -- for method, func in pairs(methods) do + -- widget[method] = func + -- end + -- frame.obj = widget + -- dropdown.obj = widget + -- text.obj = widget + -- button.obj = widget - middle:SetPoint("LEFT", left, "RIGHT", 0, 0) - middle:SetPoint("RIGHT", right, "LEFT", 0, 0) - right:SetPoint("TOPRIGHT", dropdown, "TOPRIGHT", 0, 17) - - local button = _G[dropdown:GetName().."Button"] - button:RegisterForClicks("AnyUp") - button:SetScript("OnEnter", Control_OnEnter) - button:SetScript("OnLeave", Control_OnLeave) - button:SetScript("OnClick", Dropdown_TogglePullout) - button:ClearAllPoints() - button:SetPoint("RIGHT", dropdown, 0, 0) - - local text = _G[dropdown:GetName().."Text"] - text:ClearAllPoints() - text:SetPoint("RIGHT", button, "LEFT", -2, 0) - text:SetPoint("LEFT", dropdown, "LEFT", 8, 0) - text:SetFont(TSMAPI.Design:GetContentFont("normal")) - text:SetShadowColor(0, 0, 0, 0) - - local label = frame:CreateFontString(nil, "OVERLAY") - label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) - label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, 0) - label:SetJustifyH("LEFT") - label:SetHeight(18) - label:SetFont(TSMAPI.Design:GetContentFont("small")) - label:SetShadowColor(0, 0, 0, 0) - label:Hide() - - left:Hide() - middle:Hide() - right:Hide() - - local widget = { - frame = frame, - label = label, - dropdown = dropdown, - text = text, - button = button, - count = count, - alignoffset = 30, - type = Type, - } - for method, func in pairs(methods) do - widget[method] = func + return dropdown end - frame.obj = widget - dropdown.obj = widget - text.obj = widget - button.obj = widget - - return AceGUI:RegisterAsWidget(widget) end function m.slider(frame, name) @@ -533,4 +554,43 @@ function m.slider(frame, name) slider.label = label slider.editbox = editbox return slider -end \ No newline at end of file +end + +--function m.checkbox() +-- local frame = CreateFrame('Button', nil, UIParent) +-- frame:Hide() +-- frame:EnableMouse(true) +-- frame:SetScript("OnEnter", Control_OnEnter) +-- frame:SetScript("OnLeave", Control_OnLeave) +-- frame:SetScript("OnMouseDown", CheckBox_OnMouseDown) +-- frame:SetScript("OnMouseUp", CheckBox_OnMouseUp) +-- +-- local checkbox = CreateFrame('Button', nil, frame) +-- checkbox:EnableMouse(false) +-- checkbox:SetWidth(16) +-- checkbox:SetHeight(16) +-- checkbox:SetPoint('TOPLEFT', 4, -4) +-- checkbox:SetBackdrop({ bgFile='Interface\\Buttons\\WHITE8X8', edgeFile='Interface\\Buttons\\WHITE8X8', edgeSize=m.config.edge_size }) +-- checkbox:SetBackdropColor(unpack(m.config.content_color)) +-- checkbox:SetBackdropBorderColor(unpack(m.config.content_border_color)) +-- local highlight = checkbox:CreateTexture(nil, 'HIGHLIGHT') +-- highlight:SetAllPoints() +-- highlight:SetTexture(1, 1, 1, .2) +-- highlight:SetBlendMode('BLEND') +-- +-- local check = checkbox:CreateTexture(nil, 'OVERLAY') +-- check:SetTexture([[Interface\Buttons\UI-CheckBox-Check]]) +-- check:SetTexCoord(.12, .88, .12, .88) +-- check:SetBlendMode('BLEND') +-- check:SetPoint('BOTTOMRIGHT') +-- +-- local text = frame:CreateFontString(nil, 'OVERLAY') +-- text:SetJustifyH('LEFT') +-- text:SetHeight(18) +-- text:SetPoint('LEFT', checkbox, 'RIGHT') +-- text:SetPoint('RIGHT') +-- text:SetFont(m.config.content_font, m.config.normal_font_size) +-- +-- checkbox.text = text +-- return checkbox +--end \ No newline at end of file diff --git a/item_search_frame.lua b/item_search_frame.lua index 2f7f4bd..f695e11 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -462,7 +462,7 @@ end function private.create_auction_record(auction_info) local buyout_price = auction_info.buyout_price > 0 and auction_info.buyout_price or nil - local unit_buyout_price = buyout_price and Aux.round(auction_info.buyout_price / auction_info.aux_quantity) + local unit_buyout_price = buyout_price and auction_info.buyout_price / auction_info.aux_quantity local status if auction_info.current_bid == 0 then status = 'No Bid' @@ -492,7 +492,7 @@ function private.create_auction_record(auction_info) quality = auction_info.quality, hyperlink = auction_info.hyperlink, bid_price = auction_info.bid_price, - unit_bid_price = Aux.round(auction_info.bid_price / auction_info.aux_quantity), + unit_bid_price = auction_info.bid_price / auction_info.aux_quantity, owner = auction_info.owner, duration = auction_info.duration, usable = auction_info.usable, diff --git a/scan_util.lua b/scan_util.lua index c5934c2..ead9665 100644 --- a/scan_util.lua +++ b/scan_util.lua @@ -55,13 +55,13 @@ function m.create_item_filter(item_id) local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) return { + exact_only = true, name = item_info.name, min_level = item_info.level, min_level = item_info.level, slot = item_info.slot, class = class_index, subclass = subclass_index, - subclass = item_info.subclass, quality = item_info.quality, usable = item_info.usable, } @@ -87,22 +87,17 @@ function m.parse_filter_string(filter_string) local filters = {} for _, str in ipairs(parts) do str = Aux.util.trim(str) --- if tonumber(str) then --- local filter = m.create_item_filter(tonumber(str)) --- if filter then --- tinsert(filters, filter) --- end --- else + local filter, error = m.filter_from_string(str) if not filter then Aux.log('Invalid filter: '..error) + return elseif filter.name and strlen(filter.name) > 63 then else tinsert(filters, filter) end --- end end return filters @@ -159,8 +154,12 @@ function m.filter_from_string(filter_term) else return false, 'Invalid Even Only Filter' end --- elseif Aux.money.from_string(str) then --- filter.min_profit = Aux.money.from_string(str) + elseif Aux.money.from_string(str) > 0 then + if not filter.max_price then + filter.max_price = Aux.money.from_string(str) + else + return false, 'Invalid Max Price Filter' + end elseif i == 1 then filter.name = str else @@ -174,7 +173,9 @@ function m.filter_from_string(filter_term) end for id, info in pairs(Aux.static.auctionable_items) do if info.name == filter.name then - return m.create_item_filter(id) + local item_filter = m.create_item_filter(id) + item_filter.even_only = filter.even_only + return item_filter end end return false, 'Invalid Exact Only Filter' @@ -237,23 +238,21 @@ end function m.validator(filter) return function(record) - if filter.exact_only and record.name ~= filter.name then return end - - if filter.even_only and rem(record.aux_quantity, 5) ~= 0 then + if filter.even_only and mod(record.aux_quantity, 5) ~= 0 then return end - if filter.min_level and record.level < filter.min_level then return end - if filter.max_level and record.level > filter.max_level then return end - + if filter.max_price and record.buyout_price > filter.max_price then + return + end return true end end \ No newline at end of file