From 27e592bead9e84b52881951e87e154d22f36d273 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Wed, 31 Aug 2016 04:09:34 +0200 Subject: [PATCH] green_t refactoring --- core/tooltip.lua | 2 +- gui/auction_listing.lua | 14 ++++---- gui/core.lua | 4 +-- gui/listing.lua | 10 +++--- tabs/auctions/core.lua | 4 +-- tabs/bids/core.lua | 6 ++-- tabs/search/frame.lua | 2 +- tabs/search/results.lua | 2 +- tabs/search/saved.lua | 8 ++--- util/info.lua | 78 ++++++++++++++++++++--------------------- 10 files changed, 65 insertions(+), 65 deletions(-) diff --git a/core/tooltip.lua b/core/tooltip.lua index c5f204d..a166ddf 100644 --- a/core/tooltip.lua +++ b/core/tooltip.lua @@ -12,7 +12,7 @@ function LOAD() hook(name, GameTooltip, function(...) temp=arg inside_hook = true game_tooltip_money = 0 - local ret = {orig[GameTooltip][name](unpack(arg))} + local ret = temp-ret(orig[GameTooltip][name](unpack(arg))) inside_hook = false f(unpack(arg)) return unpack(ret) diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index 4a36195..504bf88 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -996,10 +996,10 @@ function public.CreateAuctionResultsTable(parent, config) local numRows = 16 rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows rt.scrollDisabled = nil - rt.expanded = {} - rt.handlers = {} - rt.sorts = {} - rt.records = {} + rt.expanded = t + rt.handlers = t + rt.sorts = t + rt.records = t rt.rowInfo = {numDisplayRows=0} for name, func in methods do @@ -1045,7 +1045,7 @@ function public.CreateAuctionResultsTable(parent, config) _G[scrollBar:GetName()..'ScrollDownButton']:Hide() -- create the header cells - rt.headCells = {} + rt.headCells = t for i, column_config in rt.config do local cell = CreateFrame('Button', nil, rt.contentFrame) cell:SetHeight(HEAD_HEIGHT) @@ -1088,7 +1088,7 @@ function public.CreateAuctionResultsTable(parent, config) end -- create the rows - rt.rows = {} + rt.rows = t for i = 1, numRows do local row = CreateFrame('Frame', nil, rt.contentFrame) row:SetHeight(rt.ROW_HEIGHT) @@ -1106,7 +1106,7 @@ function public.CreateAuctionResultsTable(parent, config) row.highlight = highlight row.rt = rt - row.cells = {} + row.cells = t for j=1, getn(rt.config) do local cell = CreateFrame('Button', nil, row) local text = cell:CreateFontString() diff --git a/gui/core.lua b/gui/core.lua index dec4a8f..b3a8a41 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -14,7 +14,7 @@ function LOAD() aux_background:SetAllPoints(DropDownList1Backdrop) blizzard_backdrop = DropDownList1Backdrop:GetBackdrop() hook('ToggleDropDownMenu', function(...) temp=arg - local ret = {orig.ToggleDropDownMenu(unpack(arg)) } + local ret = temp-ret(orig.ToggleDropDownMenu(unpack(arg))) local dropdown = _G[arg[4] or ''] or this:GetParent() if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then set_aux_dropdown_style(dropdown) @@ -290,7 +290,7 @@ do local self = { _frame = parent, _orientation = orientation, - _tabs = {}, + _tabs = t, } return setmetatable(self, mt) end diff --git a/gui/listing.lua b/gui/listing.lua index eb91c36..9b6b72b 100644 --- a/gui/listing.lua +++ b/gui/listing.lua @@ -445,11 +445,11 @@ function public.CreateScrollingTable(parent) -- setup default values st.isTSMScrollingTable = true - st.sizes = {} - st.headCols = {} - st.rows = {} - st.handlers = {} - st.sortInfo = {enabled=nil} + st.sizes = t + st.headCols = t + st.rows = t + st.handlers = t + st.sortInfo = t st.colInfo = DEFAULT_COL_INFO return st diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index c8b1e7a..04d2fe7 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -1,6 +1,6 @@ aux 'auctions_tab' local scan = aux.scan -auction_records = {} +auction_records = t function LOAD() create_frames() @@ -29,7 +29,7 @@ function public.scan_auctions() update_listing() scan.start{ type = 'owner', - queries = {{ blizzard_query = {} }}, + queries = {{blizzard_query = t}}, on_page_loaded = function(page, total_pages) status_bar:update_status(100 * (page - 1) / total_pages, 0) status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages)) diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index c514251..b86fa20 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -1,6 +1,6 @@ aux 'bids_tab' local scan = aux.scan -auction_records = {} +auction_records = t function LOAD() create_frames() @@ -29,7 +29,7 @@ function public.scan_bids() update_listing() scan.start{ type = 'bidder', - queries = {{ blizzard_query = {} }}, + queries = {{blizzard_query=t}}, on_page_loaded = function(page, total_pages) status_bar:update_status(100 * (page - 1) / total_pages, 0) status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages)) @@ -58,7 +58,7 @@ end do local scan_id = 0 - local IDLE, SEARCHING, FOUND = {}, {}, {} + local IDLE, SEARCHING, FOUND = 1, 2, 3 local state = IDLE local found_index diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 4f59f5d..3d6257f 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -517,7 +517,7 @@ function create_frames() if filter_util.filters[text] and filter_util.filters[text].input_type ~= '' then local _, _, suggestions = filter_util.parse_filter_string(text..'/') filter_parameter_input:SetNumeric(filter_util.filters[text].input_type == 'number') - filter_parameter_input.complete = completion.complete(function() return suggestions or {} end) + filter_parameter_input.complete = completion.complete(function() return suggestions or O end) filter_parameter_input:Show() else filter_parameter_input:Hide() diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 534ce37..2f7436a 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -346,7 +346,7 @@ function public.execute(resume, real_time) end new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';')) else - current_search.records = {} + current_search.records = t current_search.table:SetDatabase(current_search.records) if current_search.real_time ~= real_time then current_search.table:Reset() diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index b5dd2bf..923256f 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -1,10 +1,10 @@ aux 'search_tab' -_G.aux_favorite_searches = {} -_G.aux_recent_searches = {} +_G.aux_favorite_searches = t +_G.aux_recent_searches = t function update_search_listings() - local favorite_search_rows = {} + local favorite_search_rows = t for i, favorite_search in _G.aux_favorite_searches do local name = strsub(favorite_search.prettified, 1, 250) tinsert(favorite_search_rows, { @@ -15,7 +15,7 @@ function update_search_listings() end favorite_searches_listing:SetData(favorite_search_rows) - local recent_search_rows = {} + local recent_search_rows = t for i, recent_search in _G.aux_recent_searches do local name = strsub(recent_search.prettified, 1, 250) tinsert(recent_search_rows, { diff --git a/util/info.lua b/util/info.lua index 09265c5..5c94051 100644 --- a/util/info.lua +++ b/util/info.lua @@ -111,49 +111,49 @@ function public.auction(index, query_type) local blizzard_bid = high_bid > 0 and high_bid or start_price local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price - return { - item_id = item_id, - suffix_id = suffix_id, - unique_id = unique_id, - enchant_id = enchant_id, + return T( + 'item_id', item_id, + 'suffix_id', suffix_id, + 'unique_id', unique_id, + 'enchant_id', enchant_id, - link = link, - itemstring = item_info.itemstring, - item_key = item_id..':'..suffix_id, - search_signature = join(temp-{item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _G.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'), - sniping_signature = join(temp-{item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _G.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), + 'link', link, + 'itemstring', item_info.itemstring, + 'item_key', item_id..':'..suffix_id, + 'search_signature', join(temp-{item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _G.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'), + 'sniping_signature', join(temp-{item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _G.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), - name = name, - texture = texture, - level = item_info.level, - type = item_info.type, - subtype = item_info.subtype, - slot = item_info.slot, - quality = quality, - max_stack = item_info.max_stack, + 'name', name, + 'texture', texture, + 'level', item_info.level, + 'type', item_info.type, + 'subtype', item_info.subtype, + 'slot', item_info.slot, + 'quality', quality, + 'max_stack', item_info.max_stack, - count = count, - start_price = start_price, - high_bid = high_bid, - min_increment = min_increment, - blizzard_bid = blizzard_bid, - bid_price = bid_price, - buyout_price = buyout_price, - unit_blizzard_bid = blizzard_bid / aux_quantity, - unit_bid_price = bid_price / aux_quantity, - unit_buyout_price = buyout_price / aux_quantity, - high_bidder = high_bidder, - owner = owner, - sale_status = sale_status, - duration = duration, - usable = usable, + 'count', count, + 'start_price', start_price, + 'high_bid', high_bid, + 'min_increment', min_increment, + 'blizzard_bid', blizzard_bid, + 'bid_price', bid_price, + 'buyout_price', buyout_price, + 'unit_blizzard_bid', blizzard_bid / aux_quantity, + 'unit_bid_price', bid_price / aux_quantity, + 'unit_buyout_price', buyout_price / aux_quantity, + 'high_bidder', high_bidder, + 'owner', owner, + 'sale_status', sale_status, + 'duration', duration, + 'usable', usable, - tooltip = tooltip, - tooltip_money = tooltip_money, - max_charges = max_charges, - charges = charges, - aux_quantity = aux_quantity, - } + 'tooltip', tooltip, + 'tooltip_money', tooltip_money, + 'max_charges', max_charges, + 'charges', charges, + 'aux_quantity', aux_quantity + ) end end