From 80c415f6fa3ab6e975ec11059a833e2ea4d4a3ad Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Fri, 18 Mar 2016 19:15:08 +0100 Subject: [PATCH] small scan refactoring --- core.lua | 2 +- history.lua | 2 +- scan.lua | 25 ++++++++++++------------- search_frame.lua | 26 +++++++------------------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/core.lua b/core.lua index a8a628b..07e58fe 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,5 @@ Aux = { - version = '2.6.19', + version = '2.7.0', blizzard_ui_shown = false, orig = {}, } diff --git a/history.lua b/history.lua index 376ff96..287abf9 100644 --- a/history.lua +++ b/history.lua @@ -88,7 +88,7 @@ function public.value(item_key) local weighted_values = {} local total_weight = 0 for _, data_point in item_record.data_points do - local weight = 0.95^Aux.round((data_point.time - item_record.data_points[1].time) / (60*60*24)) + local weight = 0.99^Aux.round((data_point.time - item_record.data_points[1].time) / (60*60*24)) total_weight = total_weight + weight tinsert(weighted_values, {value = data_point.market_value, weight = weight}) end diff --git a/scan.lua b/scan.lua index 7e62ac5..5fb14ab 100644 --- a/scan.lua +++ b/scan.lua @@ -107,18 +107,18 @@ function private.owner_data_complete() return true end -function private.wait_for_callback(args) -- the arguments must not be nil! +function private.wait_for_callback(...) local ok = true - local f = tremove(args, 1) - local k = tremove(args) + local f = tremove(arg, 1) + local k = tremove(arg) if f then - tinsert(args, { + tinsert(arg, { suspend = function() ok = false end, resume = function() ok = true end, }) - f(unpack(args)) + f(unpack(arg)) end if ok then @@ -128,17 +128,16 @@ function private.wait_for_callback(args) -- the arguments must not be nil! end end - function private.scan() local start_query_index = private.current_thread().params.start_query_index or 1 local next_query_index = private.current_thread().params.next_query_index or function(query_index) return query_index + 1 end private.current_thread().query_index = private.current_thread().query_index and next_query_index(private.current_thread().query_index) or start_query_index if private.current_query() then - private.wait_for_callback{private.current_thread().params.on_start_query or Aux.util.pass, private.current_thread().query_index, function() + private.wait_for_callback(private.current_thread().params.on_start_query, private.current_thread().query_index, function() private.current_thread().page = private.current_query().start_page return private.process_query() - end} + end) else local on_complete = private.current_thread().params.on_complete threads[private.current_thread().params.type] = nil @@ -156,7 +155,7 @@ function private.process_query() private.scan_auctions(count, function() - private.wait_for_callback{private.current_thread().params.on_page_scanned or Aux.util.pass, function() + private.wait_for_callback(private.current_thread().params.on_page_scanned, function() if private.current_query().next_page then private.current_thread().page = private.current_query().next_page(private.current_thread().page, private.current_thread().total_pages) else @@ -168,7 +167,7 @@ function private.process_query() else return private.scan() end - end} + end) end) end) end @@ -196,7 +195,7 @@ function private.scan_auctions_helper(i, n, k) Aux.history.process_auction(auction_info) if not private.current_query().validator or private.current_query().validator(auction_info) then - return private.wait_for_callback{private.current_thread().params.on_read_auction or Aux.util.pass, auction_info, recurse} + return private.wait_for_callback(private.current_thread().params.on_read_auction, auction_info, recurse) end end @@ -231,9 +230,9 @@ function private.submit_query(k) local _, total_count = GetNumAuctionItems(private.current_thread().params.type) private.current_thread().total_pages = math.ceil(total_count / PAGE_SIZE) if private.current_thread().total_pages >= private.current_thread().page + 1 then - private.wait_for_callback{private.current_thread().params.on_page_loaded or Aux.util.pass, private.current_thread().page, private.current_thread().total_pages, function() + private.wait_for_callback(private.current_thread().params.on_page_loaded, private.current_thread().page, private.current_thread().total_pages, function() return k() - end} + end) else return k() end diff --git a/search_frame.lua b/search_frame.lua index bdbfcc9..b74f46d 100644 --- a/search_frame.lua +++ b/search_frame.lua @@ -699,6 +699,10 @@ function public.on_load() elseif button == 'LeftButton' and IsAltKeyDown() then private.popup_info.rename = data.search StaticPopup_Show('AUX_SEARCH_SAVED_RENAME') + elseif button == 'RightButton' and IsAltKeyDown() then + -- unused + elseif button == 'LeftButton' and IsControlKeyDown() and st == private.favorite_searches_listing then + elseif button == 'RightButton' and IsControlKeyDown() and st == private.favorite_searches_listing then elseif button == 'LeftButton' then private.search_box:SetText(data.search.filter_string) public.start_search() @@ -713,25 +717,9 @@ function public.on_load() 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() --- GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') --- GameTooltip:AddLine(data.search, 1, 1, 1, true) --- GameTooltip:AddLine("") --- local color = TSMAPI.Design:GetInlineColor("link") --- if st == private.frame.saved.recentST then --- GameTooltip:AddLine(color..'Left-Click to run this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Shift-Left-Click to export this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Ctrl-Left-Click to rename this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Right-Click to favorite this recent search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Shift-Right-Click to remove this recent search.', 1, 1, 1, true) --- elseif st == private.frame.saved.favoriteST then --- GameTooltip:AddLine(color..'Left-Click to run this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Shift-Left-Click to export this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Ctrl-Left-Click to rename this search.', 1, 1, 1, true) --- GameTooltip:AddLine(color..'Right-Click to remove from favorite searches.', 1, 1, 1, true) --- end + GameTooltip_SetDefaultAnchor(GameTooltip, UIParent) + GameTooltip:AddLine(gsub(data.search.prettified, ';', '\n\n'), 255/255, 254/255, 250/255, true) + GameTooltip:Show() GameTooltip:Show() end, OnLeave = function()