From 37e789184b979fc53f9ca7155abbe40a4becf367 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Fri, 19 Aug 2016 16:03:29 +0200 Subject: [PATCH] editbox changes --- components/cache.lua | 82 ++++---- components/scan.lua | 4 +- components/slash.lua | 58 +++--- components/tooltip.lua | 16 +- core.lua | 6 +- gui.lua | 50 +++-- init.lua | 20 +- module.lua | 21 ++- tables/auction_listing.lua | 62 +++--- tables/item_listing.lua | 2 +- tabs/post/frames.lua | 74 ++++---- tabs/search/core.lua | 2 +- tabs/search/frames.lua | 376 ++++++++++++++++++------------------- tabs/search/results.lua | 8 +- tabs/search/saved.lua | 14 +- util/filter.lua | 4 +- util/info.lua | 21 +-- util/persistence.lua | 6 +- 18 files changed, 422 insertions(+), 404 deletions(-) diff --git a/components/cache.lua b/components/cache.lua index 8b9c773..8c9ed48 100644 --- a/components/cache.lua +++ b/components/cache.lua @@ -6,27 +6,27 @@ MAX_ITEM_ID = 30000 items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}} merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'} } -_G.aux_items = {} -_G.aux_item_ids = {} -_G.aux_auctionable_items = {} -_G.aux_merchant_buy = {} -_G.aux_merchant_sell = {} -_G.aux_characters = {} +g.aux_items = {} +g.aux_item_ids = {} +g.aux_auctionable_items = {} +g.aux_merchant_buy = {} +g.aux_merchant_sell = {} +g.aux_characters = {} -function m.LOAD() - m.scan_wdb() +function LOAD() + scan_wdb() - aux.control.event_listener('MERCHANT_SHOW', m.on_merchant_show) - aux.control.event_listener('MERCHANT_CLOSED', m.on_merchant_closed) - aux.control.event_listener('MERCHANT_UPDATE', m.on_merchant_update) - aux.control.event_listener('BAG_UPDATE', m.on_bag_update) + aux.control.event_listener('MERCHANT_SHOW', on_merchant_show) + aux.control.event_listener('MERCHANT_CLOSED', on_merchant_closed) + aux.control.event_listener('MERCHANT_UPDATE', on_merchant_update) + aux.control.event_listener('BAG_UPDATE', on_bag_update) - CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', m.merchant_on_update) + CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update) aux.control.event_listener('NEW_AUCTION_UPDATE', function() for _, info in {aux.info.auction_sell_item()} do for _, item_id in {aux.cache.item_id(info.name)} do - _G.aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count) + g.aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count) end end end) @@ -36,8 +36,8 @@ do local sell_scan_countdown, incomplete_buy_data function on_merchant_show() - m.merchant_sell_scan() - incomplete_buy_data = not m.merchant_buy_scan() + merchant_sell_scan() + incomplete_buy_data = not merchant_buy_scan() end function on_merchant_closed() @@ -47,7 +47,7 @@ do function on_merchant_update() if incomplete_buy_data then - incomplete_buy_data = not m.merchant_buy_scan() + incomplete_buy_data = not merchant_buy_scan() end end @@ -60,7 +60,7 @@ do function merchant_on_update() if sell_scan_countdown == 0 then sell_scan_countdown = nil - m.merchant_sell_scan() + merchant_sell_scan() elseif sell_scan_countdown then sell_scan_countdown = sell_scan_countdown - 1 end @@ -78,17 +78,17 @@ end function public.merchant_info(item_id) local buy_info - if _G.aux_merchant_buy[item_id] then - buy_info = aux.persistence.read(m.merchant_buy_schema, _G.aux_merchant_buy[item_id]) + if g.aux_merchant_buy[item_id] then + buy_info = aux.persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id]) end - return _G.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited + return g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited end function public.item_info(item_id) - local data_string = _G.aux_items[item_id] + local data_string = g.aux_items[item_id] if data_string then - local cached_data = aux.persistence.read(m.items_schema, data_string) + local cached_data = aux.persistence.read(items_schema, data_string) return { name = cached_data.name, itemstring = 'item:'..item_id..':0:0:0', @@ -104,7 +104,7 @@ function public.item_info(item_id) end function public.item_id(item_name) - return _G.aux_item_ids[strlower(item_name)] + return g.aux_item_ids[strlower(item_name)] end function merchant_buy_scan() @@ -116,8 +116,8 @@ function merchant_buy_scan() if link then local item_id = aux.info.parse_link(link) local new_unit_price, new_limited = price / count, stock >= 0 - if _G.aux_merchant_buy[item_id] then - local buy_info = aux.persistence.read(m.merchant_buy_schema, _G.aux_merchant_buy[item_id]) + if g.aux_merchant_buy[item_id] then + local buy_info = aux.persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id]) local unit_price if buy_info.limited and not new_limited then @@ -128,12 +128,12 @@ function merchant_buy_scan() unit_price = min(buy_info.unit_price, new_unit_price) end - _G.aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, { + g.aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, { unit_price = unit_price, limited = buy_info.limited and new_limited, }) else - _G.aux_merchant_buy[item_id] = aux.persistence.write(m.merchant_buy_schema, { + g.aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, { unit_price = new_unit_price, limited = new_limited, }) @@ -150,21 +150,21 @@ function merchant_sell_scan() for slot in aux.util.inventory() do local item_info = aux.info.container_item(unpack(slot)) if item_info then - _G.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity + g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity end end end function scan_wdb(item_id) - item_id = item_id or m.MIN_ITEM_ID + item_id = item_id or MIN_ITEM_ID local processed = 0 - while processed <= 100 and item_id <= m.MAX_ITEM_ID do + while processed <= 100 and item_id <= MAX_ITEM_ID do local itemstring = 'item:'..item_id local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring) - if name and not _G.aux_item_ids[strlower(name)] then - _G.aux_item_ids[strlower(name)] = item_id - _G.aux_items[item_id] = aux.persistence.write(m.items_schema, { + if name and not g.aux_item_ids[strlower(name)] then + g.aux_item_ids[strlower(name)] = item_id + g.aux_items[item_id] = aux.persistence.write(items_schema, { name = name, quality = quality, level = level, @@ -176,25 +176,25 @@ function scan_wdb(item_id) }) local tooltip = aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end) if aux.info.auctionable(tooltip, quality) then - tinsert(_G.aux_auctionable_items, strlower(name)) + tinsert(g.aux_auctionable_items, strlower(name)) end processed = processed + 1 end item_id = item_id + 1 end - if item_id <= m.MAX_ITEM_ID then + if item_id <= MAX_ITEM_ID then local t0 = GetTime() - aux.control.thread(aux.control.when, function() return GetTime() - t0 > 0.1 end, m.scan_wdb, item_id) + aux.control.thread(aux.control.when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id) else - sort(_G.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end) + sort(g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end) end end function public.populate_wdb(item_id) - item_id = item_id or m.MIN_ITEM_ID + item_id = item_id or MIN_ITEM_ID - if item_id > m.MAX_ITEM_ID then + if item_id > MAX_ITEM_ID then aux.log('Cache populated.') return end @@ -204,5 +204,5 @@ function public.populate_wdb(item_id) AuxTooltip:SetHyperlink('item:'..item_id) end - aux.control.thread(m.populate_wdb, item_id + 1) + aux.control.thread(populate_wdb, item_id + 1) end \ No newline at end of file diff --git a/components/scan.lua b/components/scan.lua index 5cc9b20..2a4d093 100644 --- a/components/scan.lua +++ b/components/scan.lua @@ -145,7 +145,7 @@ function scan_page(i) end local auction_info = aux.info.auction(i, state.params.type) - if auction_info and (auction_info.owner or state.params.ignore_owner or _G.aux_ignore_owner) then + if auction_info and (auction_info.owner or state.params.ignore_owner or g.aux_ignore_owner) then auction_info.index = i auction_info.page = state.page auction_info.blizzard_query = query.blizzard_query @@ -216,7 +216,7 @@ function wait_for_list_results(send_signal, signal_received) last_update = GetTime() updated = true end) - local ignore_owner = state.params.ignore_owner or _G.aux_ignore_owner + local ignore_owner = state.params.ignore_owner or g.aux_ignore_owner return aux.control.thread(aux.control.when, function() -- short circuiting order important, owner_data_complete must be called iif an update has happened. local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5 diff --git a/components/slash.lua b/components/slash.lua index 7b1f4ac..6653873 100644 --- a/components/slash.lua +++ b/components/slash.lua @@ -9,71 +9,71 @@ function SlashCmdList.AUX(command) aux.persistence.load_dataset().post = nil aux.log 'Post settings cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then - _G.aux_datasets = {} + g.aux_datasets = {} aux.log 'Datasets cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then - _G.aux_merchant_buy = {} + g.aux_merchant_buy = {} aux.log 'Merchant buy prices cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then - _G.aux_merchant_sell = {} + g.aux_merchant_sell = {} aux.log 'Merchant sell prices cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then - _G.aux_items = {} - _G.aux_item_ids = {} - _G.aux_auctionable_items = {} + g.aux_items = {} + g.aux_item_ids = {} + g.aux_auctionable_items = {} aux.log 'Item cache cleared.' elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then aux.cache.populate_wdb() elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then - _G.aux_tooltip_value = not _G.aux_tooltip_value - aux.log('Historical value in tooltip '..(_G.aux_tooltip_value and 'enabled' or 'disabled')..'.') + g.aux_tooltip_value = not g.aux_tooltip_value + aux.log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then - _G.aux_tooltip_daily = not _G.aux_tooltip_daily - aux.log('Market value in tooltip '..(_G.aux_tooltip_daily and 'enabled' or 'disabled')..'.') + g.aux_tooltip_daily = not g.aux_tooltip_daily + aux.log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then - _G.aux_tooltip_vendor_buy = not _G.aux_tooltip_vendor_buy - aux.log('Vendor buy price in tooltip '..(_G.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.') + g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy + aux.log('Vendor buy price in tooltip '..(g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then - _G.aux_tooltip_vendor_sell = not _G.aux_tooltip_vendor_sell - aux.log('Vendor sell price in tooltip '..(_G.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.') + g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell + aux.log('Vendor sell price in tooltip '..(g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then - _G.aux_tooltip_disenchant_value = not _G.aux_tooltip_disenchant_value - aux.log('Disenchant value in tooltip '..(_G.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.') + g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value + aux.log('Disenchant value in tooltip '..(g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then - _G.aux_tooltip_disenchant_distribution = not _G.aux_tooltip_disenchant_distribution - aux.log('Disenchant distribution in tooltip '..(_G.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.') + g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution + aux.log('Disenchant distribution in tooltip '..(g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then - _G.aux_tooltip_disenchant_source = not _G.aux_tooltip_disenchant_source - aux.log('Disenchant source in tooltip '..(_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.') + g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source + aux.log('Disenchant source in tooltip '..(g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then - _G.aux_ignore_owner = not _G.aux_ignore_owner - aux.log('Ignoring of owner '..(_G.aux_ignore_owner and 'enabled' or 'disabled')..'.') + g.aux_ignore_owner = not g.aux_ignore_owner + aux.log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'chars' and arguments[2] == 'add' then local realm = GetCVar 'realmName' - _G.aux_characters[realm] = _G.aux_characters[realm] or {} + g.aux_characters[realm] = g.aux_characters[realm] or {} for i=3,getn(arguments) do local name = string.gsub(strlower(arguments[i]), '^%l', strupper) - if not _G.aux_characters[realm][name] then - _G.aux_characters[realm][name] = true + if not g.aux_characters[realm][name] then + g.aux_characters[realm][name] = true aux.log('Character "'..name..'" added.') end end elseif arguments[1] == 'chars' and arguments[2] == 'remove' then local realm = GetCVar 'realmName' - if not _G.aux_characters[realm] then + if not g.aux_characters[realm] then return end for i=3,getn(arguments) do local name = string.gsub(strlower(arguments[i]), '^%l', strupper) - if _G.aux_characters[realm][name] then - _G.aux_characters[realm][name] = nil + if g.aux_characters[realm][name] then + g.aux_characters[realm][name] = nil aux.log('Character "'..name..'" removed.') end end elseif arguments[1] == 'chars' then local realm = GetCVar 'realmName' local chars = {} - for name, _ in _G.aux_characters[realm] or {} do + for name, _ in g.aux_characters[realm] or {} do tinsert(chars, name) end if getn(chars) > 0 then diff --git a/components/tooltip.lua b/components/tooltip.lua index bdabd64..6327603 100644 --- a/components/tooltip.lua +++ b/components/tooltip.lua @@ -1,6 +1,6 @@ aux.module 'tooltip' -_G.aux_tooltip_value = true +g.aux_tooltip_value = true game_tooltip_hooks = {} hooked_setter = nil @@ -47,7 +47,7 @@ function extend_tooltip(tooltip, link, quantity) local item_id, suffix_id = aux.info.parse_link(link) quantity = IsShiftKeyDown() and quantity or 1 - if _G.aux_tooltip_disenchant_source then + if g.aux_tooltip_disenchant_source then local color = {r=0.7, g=0.7, b=0.7} local type, range = aux.disenchant.source(item_id) @@ -69,7 +69,7 @@ function extend_tooltip(tooltip, link, quantity) if getn(distribution) > 0 then - if _G.aux_tooltip_disenchant_distribution then + if g.aux_tooltip_disenchant_distribution then local color = {r=0.8, g=0.8, b=0.2} tooltip:AddLine('Disenchants into:', color.r, color.g, color.b) @@ -79,7 +79,7 @@ function extend_tooltip(tooltip, link, quantity) end end - if _G.aux_tooltip_disenchant_value then + if g.aux_tooltip_disenchant_value then local color = {r=0.1, g=0.6, b=0.6} local disenchant_value = aux.disenchant.value(item_info.slot, item_info.quality, item_info.level) @@ -88,7 +88,7 @@ function extend_tooltip(tooltip, link, quantity) end end - if _G.aux_tooltip_vendor_buy then + if g.aux_tooltip_vendor_buy then local color = {r=0.8, g=0.5, b=0.1} local _, price, limited = aux.cache.merchant_info(item_id) @@ -96,7 +96,7 @@ function extend_tooltip(tooltip, link, quantity) tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..aux.money.to_string2(price * quantity), color.r, color.g, color.b) end end - if _G.aux_tooltip_vendor_sell then + if g.aux_tooltip_vendor_sell then local color = {r=0.8, g=0.5, b=0.1} local price = aux.cache.merchant_info(item_id) @@ -112,10 +112,10 @@ function extend_tooltip(tooltip, link, quantity) local value = aux.history.value(item_key) if auctionable then - if _G.aux_tooltip_value then + if g.aux_tooltip_value then tooltip:AddLine('Value: '..(value and aux.money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b) end - if _G.aux_tooltip_daily then + if g.aux_tooltip_daily then local market_value = aux.history.market_value(item_key) tooltip:AddLine('Today: '..(market_value and aux.money.to_string2(market_value * quantity)..' ('..aux.auction_listing.percentage_historical(aux.util.round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b) end diff --git a/core.lua b/core.lua index 6331b97..71a7992 100644 --- a/core.lua +++ b/core.lua @@ -1,4 +1,4 @@ -aux.module '' +aux.module 'core' public.bids_loaded = false public.current_owner_page = nil @@ -258,7 +258,7 @@ function public.hook(name, handler, object) m.orig[object] = m.orig[object] or {} orig = m.orig[object] else - object = _G + object = g orig = m.orig end if orig[name] then @@ -407,7 +407,7 @@ end function public.is_player(name, current) local realm = GetCVar 'realmName' - return not current and m.index(_G.aux_characters, realm, name) or UnitName 'player' == name + return not current and m.index(g.aux_characters, realm, name) or UnitName 'player' == name end function public.modified() diff --git a/gui.lua b/gui.lua index 2b86dcb..cd8f8dd 100644 --- a/gui.lua +++ b/gui.lua @@ -373,11 +373,25 @@ function public.editbox(parent) editbox:SetHeight(24) editbox:SetFont(config.font, config.medium_font_size) editbox:SetTextColor(0, 0, 0, 0) --- editbox:SetShadowColor(0, 0, 0, 0) set_content_style(editbox) - editbox:SetScript('OnEditFocusGained', aux.C(editbox.HighlightText, aux._this)) - editbox:SetScript('OnEditFocusLost', aux.C(editbox.HighlightText, aux._this, 0, 0)) editbox:SetScript('OnEscapePressed', aux.C(editbox.ClearFocus, aux._this)) + editbox:SetScript('OnEditFocusGained', function() + this.last_change = GetTime() + this:HighlightText() + this:SetScript('OnUpdate', function() + this.cursor:SetAlpha(mod(floor((GetTime()-this.last_change) * 2 + 1), 2)) + end) + end) + editbox:SetScript('OnEditFocusLost', function() + this.cursor:SetAlpha(0) + this:HighlightText(0, 0) + this:SetScript('OnUpdate', nil) + end) + editbox:SetScript('OnTextChanged', function() + this.last_change = GetTime() + this.text:SetText(aux.call(this.formatter, this:GetText()) or this:GetText()) + this.cursor:SetPoint('LEFT', this.text, 'LEFT', max(0, this.text:GetStringWidth() - 2), 1) + end) do local last_click editbox:SetScript('OnMouseDown', function() @@ -391,10 +405,6 @@ function public.editbox(parent) last_click = {t=GetTime(), x=x, y=y} end) end - editbox:SetScript('OnTextChanged', function() - this.overlay:SetJustifyH(this:GetJustifyH()) - this.overlay:SetText(aux.call(this.formatter, this:GetText()) or this:GetText()) - end) function editbox:Enable() editbox:EnableMouse(true) editbox:SetTextColor(color.text.enabled()) @@ -404,14 +414,18 @@ function public.editbox(parent) editbox:SetTextColor(color.text.disabled()) editbox:ClearFocus() end - local overlay = aux.gui.label(editbox, config.medium_font_size) - overlay:SetPoint('LEFT', 1, 0) - overlay:SetPoint('RIGHT', -2, 0) - overlay:SetTextColor(aux.gui.color.text.enabled()) - editbox.overlay = overlay - local cursor = CreateFrame 'Frame' - cursor:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]]} - cursor:SetBackdropColor(aux.gui.color.text.enabled()) + local text = aux.gui.label(editbox, config.medium_font_size) + text:SetPoint('LEFT', 1, 0) + text:SetPoint('RIGHT', -2, 0) + text:SetJustifyH 'LEFT' + text:SetTextColor(color.text.enabled()) + editbox.text = text + local cursor = aux.gui.label(editbox, config.large_font_size) + cursor:SetJustifyH 'LEFT' + cursor:SetText '|' + cursor:SetTextColor(color.text.enabled()) + cursor:SetAlpha(0) + editbox.cursor = cursor return editbox end @@ -566,7 +580,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) @@ -582,7 +596,7 @@ function public.slider(parent) local label = slider:CreateFontString(nil, 'OVERLAY') label:SetPoint('BOTTOMLEFT', slider, 'TOPLEFT', -3, 8) label:SetPoint('BOTTOMRIGHT', slider, 'TOPRIGHT', 6, 8) - label:SetJustifyH('LEFT') + label:SetJustifyH 'LEFT' label:SetHeight(13) label:SetFont(config.font, config.small_font_size) label:SetTextColor(color.label.enabled()) @@ -591,7 +605,7 @@ function public.slider(parent) editbox:SetPoint('LEFT', slider, 'RIGHT', 5, 0) editbox:SetWidth(45) editbox:SetHeight(18) - editbox:SetJustifyH('CENTER') + editbox:SetJustifyH 'CENTER' editbox:SetFont(config.font, 17) slider.label = label diff --git a/init.lua b/init.lua index 44e5f1c..2805bab 100644 --- a/init.lua +++ b/init.lua @@ -5,19 +5,19 @@ public.version = '4.0.0' module_envs = {} function public.module(path) local env - if path == '' then + if path == 'core' then env = getfenv() - elseif m.module_envs[path] then - env = m.module_envs[path] + elseif module_envs[path] then + env = module_envs[path] else local prefix for name in string.gfind(path, '[%a_][%w_]*') do local qualified_name = prefix and prefix..'.'..name or name - env = m.module_envs[qualified_name] + env = module_envs[qualified_name] if not env then - (prefix and m.module_envs[prefix].public or public)[name], env = (function() return aux_module(), getfenv() end)() + (prefix and module_envs[prefix].public or public)[name], env = (function() return aux_module(), getfenv() end)() env.LOAD = nil - m.module_envs[qualified_name] = env + module_envs[qualified_name] = env end prefix = qualified_name end @@ -32,18 +32,18 @@ end ADDON_LOADED = {} event_frame:SetScript('OnEvent', function() if event == 'ADDON_LOADED' then - if m.ADDON_LOADED[arg1] then - m.ADDON_LOADED[arg1]() + if ADDON_LOADED[arg1] then + ADDON_LOADED[arg1]() end else m[event]() if event == 'VARIABLES_LOADED' then - for _, env in m.module_envs do + for _, env in module_envs do if env.m.LOAD then env.m.LOAD() end end - m.log('v'..m.version..' loaded.') + log('v'..version..' loaded.') end end end) diff --git a/module.lua b/module.lua index 05c7e2f..add6a7c 100644 --- a/module.lua +++ b/module.lua @@ -1,9 +1,16 @@ -local mask, _G = bit.band, getfenv(0) +local setfenv, rawget, rawset, setmetatable, mask, g = setfenv, rawget, rawset, setmetatable, bit.band, getfenv(0) local DECLARED, ACCESSOR, MUTABLE, PUBLIC = 1, 2, 4, 8 local ACCESSOR_KEY, MUTABLE_KEY, PUBLIC_KEY = 'accessor', 'mutable', 'public' local PROPERTY = {[ACCESSOR_KEY]=ACCESSOR, [MUTABLE_KEY]=MUTABLE, [PUBLIC_KEY]=PUBLIC} local _data, _metadata, _modifier_properties = {}, {}, {} -local metadata_mt = {__index=function() return 0 end} + +local metadata_mt = { + __index=function() return 0 end, + __newindex=function(self, key, value) + if rawget(self, key) then error('Duplicate key "'..key..'".', 2) end + rawset(self, key, value) + end, +} local env_mt = { __metatable = false, __index = function(self, key) @@ -13,7 +20,7 @@ local env_mt = { elseif mask(ACCESSOR, properties) == ACCESSOR then return value(key) else - return _G[key] or error('No key "'..key..'".', 2) + return g[key] or error('No key "'..key..'".', 2) end end, __newindex = function(self, key, value) @@ -42,7 +49,6 @@ local interface_mt = { } local modifier_mt = { __metatable = false, - __call = function() end, __index = function(self, key) local property = PROPERTY[key] if not property then error('Unsupported modifier "'..key..'".', 2) end @@ -51,17 +57,16 @@ local modifier_mt = { return self end, __newindex = function(self, key, value) - if _metadata[self][key] ~= 0 then error('Duplicate key "'..key..'".', 2) end _data[self][key] = value _metadata[self][key] = _modifier_properties[self] end, } -function _G.aux_module() +function g.aux_module() local data, metadata, modifier, env, interface modifier = setmetatable({}, modifier_mt) env = setmetatable({}, env_mt) interface = setmetatable({}, interface_mt) local function modifier_accessor(key) _modifier_properties[modifier] = DECLARED+PROPERTY[key] return modifier end - data = {_G=_G, m=env, [ACCESSOR_KEY]=modifier_accessor, [MUTABLE_KEY]=modifier_accessor, [PUBLIC_KEY]=modifier_accessor} - metadata = setmetatable({_G=DECLARED, m=DECLARED, [ACCESSOR_KEY]=ACCESSOR, [MUTABLE_KEY]=ACCESSOR, [PUBLIC_KEY]=ACCESSOR}, metadata_mt) + data = {g=g, m=env, [ACCESSOR_KEY]=modifier_accessor, [MUTABLE_KEY]=modifier_accessor, [PUBLIC_KEY]=modifier_accessor} + metadata = setmetatable({g=DECLARED, m=DECLARED, [ACCESSOR_KEY]=ACCESSOR, [MUTABLE_KEY]=ACCESSOR, [PUBLIC_KEY]=ACCESSOR}, metadata_mt) _data[modifier], _data[env], _data[interface] = data, data, data _metadata[modifier], _metadata[env], _metadata[interface] = metadata, metadata, metadata diff --git a/tables/auction_listing.lua b/tables/auction_listing.lua index 8c7c3fb..5ffb442 100644 --- a/tables/auction_listing.lua +++ b/tables/auction_listing.lua @@ -1,6 +1,6 @@ aux.module 'auction_listing' -_G.aux_price_per_unit = false +g.aux_price_per_unit = false local RT_COUNT = 1 local HEAD_HEIGHT = 27 @@ -164,24 +164,24 @@ public.search_config = { end local price if record.high_bidder then - price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price + price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price end cell:SetText(aux.money.to_string(price, true, false, nil, color)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price + price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price end local price_b if record_b.high_bidder then - price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price + price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price end return aux.sorting.compare(price_a, price_b, desc) end, @@ -192,12 +192,12 @@ public.search_config = { align = 'RIGHT', isPrice = true, set = function(cell, record) - local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and aux.money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) @@ -306,24 +306,24 @@ public.auctions_config = { set = function(cell, record) local price if record.high_bidder then - price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = _G.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price + price = g.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price end cell:SetText(aux.money.to_string(price, true, false)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = _G.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price + price_a = g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price end local price_b if record_b.high_bidder then - price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = _G.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price + price_b = g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price end return aux.sorting.compare(price_a, price_b, desc) end, @@ -334,12 +334,12 @@ public.auctions_config = { align = 'RIGHT', isPrice = true, set = function(cell, record) - local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and aux.money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) @@ -459,24 +459,24 @@ public.bids_config = { set = function(cell, record) local price if record.high_bidder then - price = _G.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = _G.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price + price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price end cell:SetText(aux.money.to_string(price)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = _G.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = _G.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price + price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price end local price_b if record_b.high_bidder then - price_b = _G.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = _G.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price + price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price end return aux.sorting.compare(price_a, price_b, desc) end, @@ -487,12 +487,12 @@ public.bids_config = { align = 'RIGHT', isPrice = true, set = function(cell, record) - local price = _G.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and aux.money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = _G.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = _G.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge) price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge) @@ -565,10 +565,10 @@ local methods = { if rt.disabled then return end if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then - _G.aux_price_per_unit = not _G.aux_price_per_unit + g.aux_price_per_unit = not g.aux_price_per_unit for _, cell in rt.headCells do if cell.info.isPrice then - cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2]) + cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2]) end end rt:SetSort() @@ -1007,7 +1007,7 @@ function public.CreateAuctionResultsTable(parent, config) rt:SetScript('OnShow', function() for _, cell in this.headCells do if cell.info.isPrice then - cell:SetText(cell.info.title[_G.aux_price_per_unit and 1 or 2]) + cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2]) end end end) diff --git a/tables/item_listing.lua b/tables/item_listing.lua index ca99fbb..94928c5 100644 --- a/tables/item_listing.lua +++ b/tables/item_listing.lua @@ -37,7 +37,7 @@ function public.render(item_listing) end function public.create(parent, on_click, selected) - local name = '_G.aux_item_list' + local name = 'g.aux_item_list' local id = 1 while getglobal(name..id) do diff --git a/tabs/post/frames.lua b/tabs/post/frames.lua index e295c7d..9102de2 100644 --- a/tabs/post/frames.lua +++ b/tabs/post/frames.lua @@ -30,7 +30,7 @@ function create_frames() local checkbox = aux.gui.checkbox(frame.inventory) checkbox:SetPoint('TOPLEFT', 49, -16) checkbox:SetScript('OnClick', function() - m.refresh = true + refresh = true end) local label = aux.gui.label(checkbox, aux.gui.config.small_font_size) label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) @@ -105,17 +105,17 @@ function create_frames() btn:SetText('Refresh') btn:SetScript('OnClick', function() aux.scan.abort(scan_id) - m.refresh_entries() - m.refresh = true + refresh_entries() + refresh = true end) refresh_button = btn end do - item = aux.gui.item(m.frame.parameters) + item = aux.gui.item(frame.parameters) item:SetPoint('TOPLEFT', 10, -6) item.button:SetScript('OnEnter', function() - if m.selected_item then - aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT') + if selected_item then + aux.info.set_tooltip(selected_item.itemstring, this, 'ANCHOR_RIGHT') end end) item.button:SetScript('OnLeave', function() @@ -123,7 +123,7 @@ function create_frames() end) end do - local slider = aux.gui.slider(m.frame.parameters) + local slider = aux.gui.slider(frame.parameters) slider:SetValueStep(1) slider:SetPoint('TOPLEFT', 13, -74) slider:SetWidth(190) @@ -134,18 +134,18 @@ function create_frames() slider:SetValue(this:GetNumber()) quantity_update(true) if selected_item then - local settings = m.read_settings() + local settings = read_settings() settings.stack_size = this:GetNumber() - m.write_settings(settings) + write_settings(settings) end end) slider.editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - m.unit_buyout_price:SetFocus() - elseif m.stack_count_slider.editbox:IsVisible() then - m.stack_count_slider.editbox:SetFocus() + unit_buyout_price:SetFocus() + elseif stack_count_slider.editbox:IsVisible() then + stack_count_slider.editbox:SetFocus() else - m.unit_start_price:SetFocus() + unit_start_price:SetFocus() end end) slider.editbox:SetNumeric(true) @@ -154,22 +154,22 @@ function create_frames() stack_size_slider = slider end do - local slider = aux.gui.slider(m.frame.parameters) + local slider = aux.gui.slider(frame.parameters) slider:SetValueStep(1) - slider:SetPoint('TOPLEFT', m.stack_size_slider, 'BOTTOMLEFT', 0, -32) + slider:SetPoint('TOPLEFT', stack_size_slider, 'BOTTOMLEFT', 0, -32) slider:SetWidth(190) slider:SetScript('OnValueChanged', function() - m.quantity_update() + quantity_update() end) slider.editbox:SetScript('OnTextChanged', function() slider:SetValue(this:GetNumber()) - m.quantity_update() + quantity_update() end) slider.editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - m.stack_size_slider.editbox:SetFocus() + stack_size_slider.editbox:SetFocus() else - m.unit_start_price:SetFocus() + unit_start_price:SetFocus() end end) slider.editbox:SetNumeric(true) @@ -177,42 +177,42 @@ function create_frames() stack_count_slider = slider end do - local dropdown = aux.gui.dropdown(m.frame.parameters) - dropdown:SetPoint('TOPLEFT', m.stack_count_slider, 'BOTTOMLEFT', 0, -19) + local dropdown = aux.gui.dropdown(frame.parameters) + dropdown:SetPoint('TOPLEFT', stack_count_slider, 'BOTTOMLEFT', 0, -19) dropdown:SetWidth(90) local label = aux.gui.label(dropdown, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetText('Duration') - UIDropDownMenu_Initialize(dropdown, m.initialize_duration_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_duration_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_duration_dropdown) + UIDropDownMenu_Initialize(this, initialize_duration_dropdown) end) duration_dropdown = dropdown end do - local label = aux.gui.label(m.frame.parameters, aux.gui.config.medium_font_size) - label:SetPoint('LEFT', m.duration_dropdown, 'RIGHT', 25, 0) + local label = aux.gui.label(frame.parameters, aux.gui.config.medium_font_size) + label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0) deposit = label end do - local checkbox = aux.gui.checkbox(m.frame.parameters) + local checkbox = aux.gui.checkbox(frame.parameters) checkbox:SetPoint('TOPRIGHT', -83, -6) checkbox:SetScript('OnClick', function() - local settings = m.read_settings() + local settings = read_settings() settings.hidden = this:GetChecked() - m.write_settings(settings) - m.refresh = true + write_settings(settings) + refresh = true end) local label = aux.gui.label(checkbox, aux.gui.config.small_font_size) label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1) - label:SetText('Hide this item') + label:SetText 'Hide this item' hide_checkbox = checkbox end do local frame = CreateFrame('Frame', nil, frame.parameters) start_price_frame = frame aux.gui.set_content_style(frame) - frame:SetPoint('TOPRIGHT', frame.parameters, 'TOPRIGHT', -71, -60) + frame:SetPoint('TOPRIGHT', m.frame.parameters, 'TOPRIGHT', -71, -60) frame:SetWidth(180) frame:SetHeight(22) local editbox = aux.gui.editbox(frame) @@ -246,18 +246,18 @@ function create_frames() editbox.pretty = aux.gui.label(frame, 17) editbox.pretty:SetPoint('LEFT', 1, 0) editbox.pretty:SetPoint('RIGHT', -2, 0) - editbox.pretty:SetJustifyH('RIGHT') + editbox.pretty:SetJustifyH 'RIGHT' editbox.pretty:SetTextColor(unpack(aux.gui.color.text.enabled)) do local label = aux.gui.label(frame, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', frame, 'TOPLEFT', -2, 1) - label:SetText('Unit Starting Price') + label:SetText 'Unit Starting Price' end do local label = aux.gui.label(frame, 14) label:SetPoint('LEFT', frame, 'RIGHT', 8, 0) label:SetWidth(50) - label:SetJustifyH('CENTER') + label:SetJustifyH 'CENTER' start_price_percentage = label end unit_start_price = editbox @@ -301,8 +301,8 @@ function create_frames() editbox.pretty = aux.gui.label(frame, 17) editbox.pretty:SetPoint('LEFT', 1, 0) editbox.pretty:SetPoint('RIGHT', -2, 0) - editbox.pretty:SetJustifyH('RIGHT') - editbox.pretty:SetTextColor(unpack(aux.gui.color.text.enabled)) + editbox.pretty:SetJustifyH 'RIGHT' + editbox.pretty:SetTextColor(aux.gui.color.text.enabled()) do local label = aux.gui.label(frame, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', frame, 'TOPLEFT', -2, 1) @@ -321,7 +321,7 @@ function create_frames() local btn = aux.gui.button(frame.parameters, 14) btn:SetPoint('TOPRIGHT', -10, -146) aux.gui.set_size(btn, 150, 20) - btn:GetFontString():SetJustifyH('RIGHT') + btn:GetFontString():SetJustifyH 'RIGHT' btn:GetFontString():SetPoint('RIGHT', -2, 0) btn:SetScript('OnClick', function() if this.amount then diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 65c9fc8..45ed6ad 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -20,7 +20,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = { } do local function action() - _G.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() + g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() m.update_auto_buy_filter() end diff --git a/tabs/search/frames.lua b/tabs/search/frames.lua index e97f088..1c989d6 100644 --- a/tabs/search/frames.lua +++ b/tabs/search/frames.lua @@ -4,40 +4,40 @@ FILTER_SPACING = 28.5 function create_frames() frame = CreateFrame('Frame', nil, aux.frame) - m.frame:SetAllPoints() - m.frame:SetScript('OnUpdate', m.on_update) - m.frame:Hide() + frame:SetAllPoints() + frame:SetScript('OnUpdate', on_update) + frame:Hide() - m.frame.filter = aux.gui.panel(m.frame) - m.frame.filter:SetAllPoints(aux.frame.content) + frame.filter = aux.gui.panel(frame) + frame.filter:SetAllPoints(aux.frame.content) - m.frame.results = aux.gui.panel(m.frame) - m.frame.results:SetAllPoints(aux.frame.content) + frame.results = aux.gui.panel(frame) + frame.results:SetAllPoints(aux.frame.content) - m.frame.saved = CreateFrame('Frame', nil, m.frame) - m.frame.saved:SetAllPoints(aux.frame.content) + frame.saved = CreateFrame('Frame', nil, frame) + frame.saved:SetAllPoints(aux.frame.content) - m.frame.saved.favorite = aux.gui.panel(m.frame.saved) - m.frame.saved.favorite:SetWidth(378.5) - m.frame.saved.favorite:SetPoint('TOPLEFT', 0, 0) - m.frame.saved.favorite:SetPoint('BOTTOMLEFT', 0, 0) + frame.saved.favorite = aux.gui.panel(frame.saved) + frame.saved.favorite:SetWidth(378.5) + frame.saved.favorite:SetPoint('TOPLEFT', 0, 0) + frame.saved.favorite:SetPoint('BOTTOMLEFT', 0, 0) - m.frame.saved.recent = aux.gui.panel(m.frame.saved) - m.frame.saved.recent:SetWidth(378.5) - m.frame.saved.recent:SetPoint('TOPRIGHT', 0, 0) - m.frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0) + frame.saved.recent = aux.gui.panel(frame.saved) + frame.saved.recent:SetWidth(378.5) + frame.saved.recent:SetPoint('TOPRIGHT', 0, 0) + frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0) do - local btn = aux.gui.button(m.frame) + local btn = aux.gui.button(frame) btn:SetPoint('TOPLEFT', 0, 0) btn:SetWidth(42) btn:SetHeight(42) btn:SetScript('OnClick', function() if this.open then - m.settings:Hide() - m.controls:Show() + settings:Hide() + controls:Show() else - m.settings:Show() - m.controls:Hide() + settings:Show() + controls:Hide() end this.open = not this.open end) @@ -52,34 +52,34 @@ function create_frames() settings_button = btn end do - local panel = CreateFrame('Frame', nil, m.frame) + local panel = CreateFrame('Frame', nil, frame) panel:SetBackdrop{bgFile=[[Interface\Buttons\WHITE8X8]]} panel:SetBackdropColor(unpack(aux.gui.color.content.background)) - panel:SetPoint('LEFT', m.settings_button, 'RIGHT', 0, 0) + panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0) panel:SetPoint('RIGHT', 0, 0) panel:SetHeight(42) panel:Hide() settings = panel end do - local panel = CreateFrame('Frame', nil, m.frame) - panel:SetPoint('LEFT', m.settings_button, 'RIGHT', 0, 0) + local panel = CreateFrame('Frame', nil, frame) + panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0) panel:SetPoint('RIGHT', 0, 1) panel:SetHeight(40) controls = panel end do - local editbox = aux.gui.editbox(m.settings) + local editbox = aux.gui.editbox(settings) editbox:SetPoint('LEFT', 75, 0) editbox:SetWidth(50) editbox:SetNumeric(true) editbox:SetMaxLetters(nil) editbox:SetScript('OnTabPressed', function() - m.last_page_input:SetFocus() + last_page_input:SetFocus() end) editbox:SetScript('OnEnterPressed', function() this:ClearFocus() - m.execute() + execute() end) editbox:SetScript('OnTextChanged', function() local page = tonumber(this:GetText()) @@ -87,7 +87,7 @@ function create_frames() if this:GetText() ~= valid_input then this:SetText(valid_input) end - if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then + if blizzard_page_index(this:GetText()) and not real_time_button:GetChecked() then this:SetBackdropColor(unpack(aux.gui.color.state.enabled)) else this:SetBackdropColor(unpack(aux.gui.color.state.disabled)) @@ -100,17 +100,17 @@ function create_frames() first_page_input = editbox end do - local editbox = aux.gui.editbox(m.settings) - editbox:SetPoint('LEFT', m.first_page_input, 'RIGHT', 10, 0) + local editbox = aux.gui.editbox(settings) + editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 10, 0) editbox:SetWidth(50) editbox:SetNumeric(true) editbox:SetMaxLetters(nil) editbox:SetScript('OnTabPressed', function() - m.first_page_input:SetFocus() + first_page_input:SetFocus() end) editbox:SetScript('OnEnterPressed', function() this:ClearFocus() - m.execute() + execute() end) editbox:SetScript('OnTextChanged', function() local page = tonumber(this:GetText()) @@ -118,7 +118,7 @@ function create_frames() if this:GetText() ~= valid_input then this:SetText(valid_input) end - if m.blizzard_page_index(this:GetText()) and not m.real_time_button:GetChecked() then + if blizzard_page_index(this:GetText()) and not real_time_button:GetChecked() then this:SetBackdropColor(unpack(aux.gui.color.state.enabled)) else this:SetBackdropColor(unpack(aux.gui.color.state.disabled)) @@ -131,23 +131,23 @@ function create_frames() last_page_input = editbox end do - local btn = aux.gui.checkbutton(m.settings) + local btn = aux.gui.checkbutton(settings) btn:SetPoint('LEFT', 230, 0) btn:SetWidth(140) btn:SetHeight(25) btn:SetText('Real Time Mode') btn:SetScript('OnClick', function() this:SetChecked(not this:GetChecked()) - this = m.first_page_input - m.first_page_input:GetScript('OnTextChanged')() - this = m.last_page_input - m.last_page_input:GetScript('OnTextChanged')() + this = first_page_input + first_page_input:GetScript('OnTextChanged')() + this = last_page_input + last_page_input:GetScript('OnTextChanged')() end) public.real_time_button = btn end do - local btn = aux.gui.checkbutton(m.settings) - btn:SetPoint('LEFT', m.real_time_button, 'RIGHT', 15, 0) + local btn = aux.gui.checkbutton(settings) + btn:SetPoint('LEFT', real_time_button, 'RIGHT', 15, 0) btn:SetWidth(140) btn:SetHeight(25) btn:SetText('Auto Buyout Mode') @@ -161,17 +161,17 @@ function create_frames() auto_buy_button = btn end do - local btn = aux.gui.checkbutton(m.settings) - btn:SetPoint('LEFT', m.auto_buy_button, 'RIGHT', 15, 0) + local btn = aux.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) - _G.aux_auto_buy_filter = nil + g.aux_auto_buy_filter = nil this.prettified = nil - m.auto_buy_validator = nil + auto_buy_validator = nil else StaticPopup_Show('AUX_SEARCH_AUTO_BUY_FILTER') end @@ -189,25 +189,25 @@ function create_frames() auto_buy_filter_button = btn end do - local btn = aux.gui.button(m.controls, 25) + local btn = aux.gui.button(controls, 25) btn:SetPoint('LEFT', 5, 0) btn:SetWidth(30) btn:SetHeight(25) btn:SetText('<') - btn:SetScript('OnClick', m.previous_search) + btn:SetScript('OnClick', previous_search) previous_button = btn end do - local btn = aux.gui.button(m.controls, 25) - btn:SetPoint('LEFT', m.previous_button, 'RIGHT', 4, 0) + local btn = aux.gui.button(controls, 25) + btn:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0) btn:SetWidth(30) btn:SetHeight(25) btn:SetText('>') - btn:SetScript('OnClick', m.next_search) + btn:SetScript('OnClick', next_search) next_button = btn end do - local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size) + local btn = aux.gui.button(controls, aux.gui.config.huge_font_size) btn:SetPoint('RIGHT', -5, 0) btn:SetWidth(70) btn:SetHeight(25) @@ -215,40 +215,40 @@ function create_frames() btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp') btn:SetScript('OnClick', function() if arg1 == 'RightButton' then - m.set_filter(m.current_search().filter_string) + set_filter(current_search().filter_string) end - m.execute() + execute() end) start_button = btn end do - local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size) + local btn = aux.gui.button(controls, aux.gui.config.huge_font_size) btn:SetPoint('RIGHT', -5, 0) btn:SetWidth(70) btn:SetHeight(25) btn:SetText('Stop') btn:SetScript('OnClick', function() - aux.scan.abort(m.search_scan_id) + aux.scan.abort(search_scan_id) end) stop_button = btn end do - local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size) - btn:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0) + local btn = aux.gui.button(controls, aux.gui.config.huge_font_size) + btn:SetPoint('RIGHT', start_button, 'LEFT', -4, 0) btn:SetWidth(70) btn:SetHeight(25) btn:SetText(aux.gui.color.green 'Resume') btn:SetScript('OnClick', function() - m.execute(true) + execute(true) end) resume_button = btn end do - local editbox = aux.gui.editbox(m.controls) + local editbox = aux.gui.editbox(controls) editbox:SetMaxLetters(nil) editbox:EnableMouse(1) editbox.complete = aux.completion.complete_filter - editbox:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0) + editbox:SetPoint('RIGHT', start_button, 'LEFT', -4, 0) editbox:SetHeight(25) editbox:SetScript('OnChar', function() this:complete() @@ -256,49 +256,49 @@ function create_frames() editbox:SetScript('OnTabPressed', function() this:HighlightText(0, 0) end) - editbox:SetScript('OnEnterPressed', m.execute) + editbox:SetScript('OnEnterPressed', execute) search_box = editbox end do - aux.gui.horizontal_line(m.frame, -40) + aux.gui.horizontal_line(frame, -40) end do - local btn = aux.gui.button(m.frame, aux.gui.config.large_font_size2) + local btn = aux.gui.button(frame, aux.gui.config.large_font_size2) btn:SetPoint('BOTTOMLEFT', aux.frame.content, 'TOPLEFT', 10, 8) btn:SetWidth(243) btn:SetHeight(22) btn:SetText('Search Results') - btn:SetScript('OnClick', function() m.update_tab(m.RESULTS) end) + btn:SetScript('OnClick', function() update_tab(RESULTS) end) search_results_button = btn end do - local btn = aux.gui.button(m.frame, aux.gui.config.large_font_size2) - btn:SetPoint('TOPLEFT', m.search_results_button, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame, aux.gui.config.large_font_size2) + btn:SetPoint('TOPLEFT', search_results_button, 'TOPRIGHT', 5, 0) btn:SetWidth(243) btn:SetHeight(22) btn:SetText('Saved Searches') - btn:SetScript('OnClick', function() m.update_tab(m.SAVED) end) + btn:SetScript('OnClick', function() update_tab(SAVED) end) saved_searches_button = btn end do - local btn = aux.gui.button(m.frame, aux.gui.config.large_font_size2) - btn:SetPoint('TOPLEFT', m.saved_searches_button, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame, aux.gui.config.large_font_size2) + btn:SetPoint('TOPLEFT', saved_searches_button, 'TOPRIGHT', 5, 0) btn:SetWidth(243) btn:SetHeight(22) btn:SetText('Filter Builder') - btn:SetScript('OnClick', function() m.update_tab(m.FILTER) end) + btn:SetScript('OnClick', function() update_tab(FILTER) end) new_filter_button = btn end do - local frame = CreateFrame('Frame', nil, m.frame) + local frame = CreateFrame('Frame', nil, frame) frame:SetWidth(265) frame:SetHeight(25) frame:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6) status_bar_frame = frame end do - local btn = aux.gui.button(m.frame.results, 16) - btn:SetPoint('TOPLEFT', m.status_bar_frame, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame.results, 16) + btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) btn:SetText('Bid') @@ -306,8 +306,8 @@ function create_frames() bid_button = btn end do - local btn = aux.gui.button(m.frame.results, 16) - btn:SetPoint('TOPLEFT', m.bid_button, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame.results, 16) + btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) btn:SetText('Buyout') @@ -315,42 +315,42 @@ function create_frames() buyout_button = btn end do - local btn = aux.gui.button(m.frame.results, 16) - btn:SetPoint('TOPLEFT', m.buyout_button, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame.results, 16) + btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) btn:SetText('Clear') btn:SetScript('OnClick', function() - while tremove(m.current_search().records) do end - m.current_search().table:SetDatabase() + while tremove(current_search().records) do end + current_search().table:SetDatabase() end) end do - local btn = aux.gui.button(m.frame.saved, 16) - btn:SetPoint('TOPLEFT', m.status_bar_frame, 'TOPRIGHT', 5, 0) + local btn = aux.gui.button(frame.saved, 16) + btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn:SetWidth(80) btn:SetHeight(24) btn:SetText('Favorite') btn:SetScript('OnClick', function() - local filters = aux.filter.queries(m.search_box:GetText()) + local filters = aux.filter.queries(search_box:GetText()) if filters then - tinsert(_G.aux_favorite_searches, 1, { - filter_string = m.search_box:GetText(), + tinsert(g.aux_favorite_searches, 1, { + filter_string = search_box:GetText(), prettified = table.concat(aux.util.map(filters, function(filter) return filter.prettified end), ';'), }) end - m.update_search_listings() + update_search_listings() end) end do - local btn1 = aux.gui.button(m.frame.filter, 16) - btn1:SetPoint('TOPLEFT', m.status_bar_frame, 'TOPRIGHT', 5, 0) + local btn1 = aux.gui.button(frame.filter, 16) + btn1:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0) btn1:SetWidth(80) btn1:SetHeight(24) btn1:SetText('Search') btn1:SetScript('OnClick', function() - m.export_query_string() - m.execute() + export_query_string() + execute() end) local btn2 = aux.gui.button(frame.filter, 16) @@ -369,7 +369,7 @@ function create_frames() end do local editbox = aux.gui.editbox(frame.filter) - editbox.complete_item = aux.completion.complete(function() return _G.aux_auctionable_items end) + editbox.complete_item = aux.completion.complete(function() return g.aux_auctionable_items end) editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING) editbox:SetWidth(260) editbox:SetScript('OnChar', function() @@ -404,24 +404,24 @@ function create_frames() exact_checkbox = checkbox end do - local editbox = aux.gui.editbox(m.frame.filter) - editbox:SetPoint('TOPLEFT', m.name_input, 'BOTTOMLEFT', 0, -m.FILTER_SPACING) + local editbox = aux.gui.editbox(frame.filter) + editbox:SetPoint('TOPLEFT', name_input, 'BOTTOMLEFT', 0, -FILTER_SPACING) editbox:SetWidth(125) editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - m.name_input:SetFocus() + name_input:SetFocus() else - m.max_level_input:SetFocus() + max_level_input:SetFocus() end end) editbox:SetScript('OnEnterPressed', aux.C(editbox.ClearFocus, editbox)) editbox:SetScript('OnTextChanged', function() - local valid_level = m.valid_level(this:GetText()) + local valid_level = valid_level(this:GetText()) if tostring(valid_level) ~= this:GetText() then this:SetText(valid_level or '') end - m.update_form() + update_form() end) local label = aux.gui.label(editbox, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1) @@ -429,24 +429,24 @@ function create_frames() min_level_input = editbox end do - local editbox = aux.gui.editbox(m.frame.filter) - editbox:SetPoint('TOPLEFT', m.min_level_input, 'TOPRIGHT', 10, 0) + local editbox = aux.gui.editbox(frame.filter) + editbox:SetPoint('TOPLEFT', min_level_input, 'TOPRIGHT', 10, 0) editbox:SetWidth(125) editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - m.min_level_input:SetFocus() + min_level_input:SetFocus() else - m.name_input:SetFocus() + name_input:SetFocus() end end) editbox:SetScript('OnEnterPressed', aux.C(editbox.ClearFocus, editbox)) editbox:SetScript('OnTextChanged', function() - local valid_level = m.valid_level(this:GetText()) + local valid_level = valid_level(this:GetText()) if tostring(valid_level) ~= this:GetText() then this:SetText(valid_level or '') end - m.update_form() + update_form() end) local label = aux.gui.label(editbox, aux.gui.config.medium_font_size) label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0) @@ -454,74 +454,74 @@ function create_frames() max_level_input = editbox end do - local checkbox = aux.gui.checkbox(m.frame.filter) - checkbox:SetPoint('TOPLEFT', m.max_level_input, 'TOPRIGHT', 16, 0) - checkbox:SetScript('OnClick', m.update_form) + local checkbox = aux.gui.checkbox(frame.filter) + checkbox:SetPoint('TOPLEFT', max_level_input, 'TOPRIGHT', 16, 0) + checkbox:SetScript('OnClick', update_form) local label = aux.gui.label(checkbox, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1) label:SetText('Usable') usable_checkbox = checkbox end do - local dropdown = aux.gui.dropdown(m.frame.filter) + local dropdown = aux.gui.dropdown(frame.filter) class_dropdown = dropdown - dropdown:SetPoint('TOPLEFT', m.min_level_input, 'BOTTOMLEFT', 0, 5 - m.FILTER_SPACING) + dropdown:SetPoint('TOPLEFT', min_level_input, 'BOTTOMLEFT', 0, 5 - FILTER_SPACING) dropdown:SetWidth(300) local label = aux.gui.label(dropdown, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetText('Item Class') - UIDropDownMenu_Initialize(dropdown, m.initialize_class_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_class_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_class_dropdown) + UIDropDownMenu_Initialize(this, initialize_class_dropdown) end) end do - local dropdown = aux.gui.dropdown(m.frame.filter) + local dropdown = aux.gui.dropdown(frame.filter) subclass_dropdown = dropdown - dropdown:SetPoint('TOPLEFT', m.class_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING) + dropdown:SetPoint('TOPLEFT', class_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING) dropdown:SetWidth(300) local label = aux.gui.label(dropdown, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetText('Item Subclass') - UIDropDownMenu_Initialize(dropdown, m.initialize_subclass_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_subclass_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_subclass_dropdown) + UIDropDownMenu_Initialize(this, initialize_subclass_dropdown) end) end do - local dropdown = aux.gui.dropdown(m.frame.filter) + local dropdown = aux.gui.dropdown(frame.filter) slot_dropdown = dropdown - dropdown:SetPoint('TOPLEFT', m.subclass_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING) + dropdown:SetPoint('TOPLEFT', subclass_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING) dropdown:SetWidth(300) local label = aux.gui.label(dropdown, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetText('Item Slot') - UIDropDownMenu_Initialize(dropdown, m.initialize_slot_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_slot_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_slot_dropdown) + UIDropDownMenu_Initialize(this, initialize_slot_dropdown) end) end do - local dropdown = aux.gui.dropdown(m.frame.filter) + local dropdown = aux.gui.dropdown(frame.filter) quality_dropdown = dropdown - dropdown:SetPoint('TOPLEFT', m.slot_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING) + dropdown:SetPoint('TOPLEFT', slot_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING) dropdown:SetWidth(300) local label = aux.gui.label(dropdown, aux.gui.config.small_font_size) label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -3) label:SetText('Min Quality') - UIDropDownMenu_Initialize(dropdown, m.initialize_quality_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_quality_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_quality_dropdown) + UIDropDownMenu_Initialize(this, initialize_quality_dropdown) end) end - aux.gui.vertical_line(m.frame.filter, 332) + aux.gui.vertical_line(frame.filter, 332) do - local dropdown = aux.gui.dropdown(m.frame.filter) + local dropdown = aux.gui.dropdown(frame.filter) dropdown:SetPoint('TOPRIGHT', -174.5, -10) dropdown:SetWidth(150) - UIDropDownMenu_Initialize(dropdown, m.initialize_filter_dropdown) + UIDropDownMenu_Initialize(dropdown, initialize_filter_dropdown) dropdown:SetScript('OnShow', function() - UIDropDownMenu_Initialize(this, m.initialize_filter_dropdown) + UIDropDownMenu_Initialize(this, initialize_filter_dropdown) end) getglobal(dropdown:GetName()..'Text'):Hide() local label = aux.gui.label(dropdown, aux.gui.config.medium_font_size) @@ -530,11 +530,11 @@ function create_frames() filter_dropdown = dropdown end do - local input = aux.gui.editbox(m.frame.filter) - input:SetPoint('CENTER', m.filter_dropdown, 'CENTER', 0, 0) + local input = aux.gui.editbox(frame.filter) + input:SetPoint('CENTER', filter_dropdown, 'CENTER', 0, 0) input:SetWidth(150) input:SetScript('OnTabPressed', function() - m.filter_parameter_input:SetFocus() + filter_parameter_input:SetFocus() end) input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(aux.util.keys(aux.filter.filters))} end) input:SetScript('OnChar', function() @@ -544,38 +544,38 @@ function create_frames() local filter = this:GetText() if aux.filter.filters[filter] and aux.filter.filters[filter].input_type ~= '' then local _, _, suggestions = aux.filter.parse_query_string(filter..'/') - m.filter_parameter_input:SetNumeric(aux.filter.filters[filter].input_type == 'number') - m.filter_parameter_input.complete = aux.completion.complete(function() return suggestions or {} end) - m.filter_parameter_input:Show() + filter_parameter_input:SetNumeric(aux.filter.filters[filter].input_type == 'number') + filter_parameter_input.complete = aux.completion.complete(function() return suggestions or {} end) + filter_parameter_input:Show() else - m.filter_parameter_input:Hide() + filter_parameter_input:Hide() end end) input:SetScript('OnEnterPressed', function() - if m.filter_parameter_input:IsVisible() then - m.filter_parameter_input:SetFocus() + if filter_parameter_input:IsVisible() then + filter_parameter_input:SetFocus() else - m.add_post_filter() + add_post_filter() end end) filter_input = input end do - local input = aux.gui.editbox(m.frame.filter) - input:SetPoint('LEFT', m.filter_dropdown, 'RIGHT', 10, 0) + local input = aux.gui.editbox(frame.filter) + input:SetPoint('LEFT', filter_dropdown, 'RIGHT', 10, 0) input:SetWidth(150) input:SetScript('OnTabPressed', function() - m.filter_input:SetFocus() + filter_input:SetFocus() end) input:SetScript('OnChar', function() this:complete() end) - input:SetScript('OnEnterPressed', m.add_post_filter) + input:SetScript('OnEnterPressed', add_post_filter) input:Hide() filter_parameter_input = input end do - local scroll_frame = CreateFrame('ScrollFrame', nil, m.frame.filter) + local scroll_frame = CreateFrame('ScrollFrame', nil, frame.filter) scroll_frame:SetWidth(395) scroll_frame:SetHeight(270) scroll_frame:SetPoint('TOPLEFT', 348.5, -50) @@ -584,7 +584,7 @@ function create_frames() scroll_frame:SetScript('OnMouseWheel', function() local child = this:GetScrollChild() child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.util.bound(11, 23, aux.util.select(2, child:GetFont()) + arg1*2)) - m.update_filter_display() + update_filter_display() end) scroll_frame:RegisterForDrag('LeftButton') scroll_frame:SetScript('OnDragStart', function() @@ -596,7 +596,7 @@ function create_frames() local new_x_offset = this.x_offset + x - this.x local new_y_offset = this.y_offset + y - this.y - m.set_filter_display_offset(new_x_offset - this.x_extra, new_y_offset - this.y_extra) + set_filter_display_offset(new_x_offset - this.x_extra, new_y_offset - this.y_extra) this.x_extra = max(this.x_extra, new_x_offset) this.y_extra = min(this.y_extra, new_y_offset) @@ -612,7 +612,7 @@ function create_frames() scroll_child:SetTextColor('p', aux.gui.color.label.enabled()) scroll_child:SetWidth(1) scroll_child:SetHeight(1) - scroll_child:SetScript('OnHyperlinkClick', m.data_link_click) + scroll_child:SetScript('OnHyperlinkClick', data_link_click) -- scroll_child:SetHyperlinkFormat("format") scroll_child.measure = scroll_child:CreateFontString() filter_display = scroll_child @@ -621,60 +621,60 @@ function create_frames() status_bars = {} tables = {} for _=1,5 do - local status_bar = aux.gui.status_bar(m.frame) - status_bar:SetAllPoints(m.status_bar_frame) + local status_bar = aux.gui.status_bar(frame) + status_bar:SetAllPoints(status_bar_frame) status_bar:Hide() - tinsert(m.status_bars, status_bar) + tinsert(status_bars, status_bar) - local table = aux.auction_listing.CreateAuctionResultsTable(m.frame.results, aux.auction_listing.search_config) + local table = aux.auction_listing.CreateAuctionResultsTable(frame.results, aux.auction_listing.search_config) table:SetHandler('OnCellClick', function(cell, button) - if IsAltKeyDown() and m.current_search().table:GetSelection().record == cell.row.data.record then - if button == 'LeftButton' and m.buyout_button:IsEnabled() then - m.buyout_button:Click() - elseif button == 'RightButton' and m.bid_button:IsEnabled() then - m.bid_button:Click() + if IsAltKeyDown() and current_search().table:GetSelection().record == cell.row.data.record then + if button == 'LeftButton' and buyout_button:IsEnabled() then + buyout_button:Click() + elseif button == 'RightButton' and bid_button:IsEnabled() then + bid_button:Click() end end end) table:SetHandler('OnSelectionChanged', function(rt, datum) if not datum then return end - m.find_auction(datum.record) + find_auction(datum.record) end) table:Hide() - tinsert(m.tables, table) + tinsert(tables, table) end local handlers = { OnClick = function(st, data, _, button) if not data then return end if button == 'LeftButton' and IsShiftKeyDown() then - m.search_box:SetText(data.search.filter_string) + search_box:SetText(data.search.filter_string) elseif button == 'RightButton' and IsShiftKeyDown() then - m.add_filter(data.search.filter_string) + add_filter(data.search.filter_string) elseif button == 'LeftButton' and IsControlKeyDown() then - if st == m.favorite_searches_listing and data.index > 1 then - local temp = _G.aux_favorite_searches[data.index - 1] - _G.aux_favorite_searches[data.index - 1] = data.search - _G.aux_favorite_searches[data.index] = temp - m.update_search_listings() + if st == favorite_searches_listing and data.index > 1 then + local temp = g.aux_favorite_searches[data.index - 1] + g.aux_favorite_searches[data.index - 1] = data.search + g.aux_favorite_searches[data.index] = temp + update_search_listings() end elseif button == 'RightButton' and IsControlKeyDown() then - if st == m.favorite_searches_listing and data.index < getn(_G.aux_favorite_searches) then - local temp = _G.aux_favorite_searches[data.index + 1] - _G.aux_favorite_searches[data.index + 1] = data.search - _G.aux_favorite_searches[data.index] = temp - m.update_search_listings() + if st == favorite_searches_listing and data.index < getn(g.aux_favorite_searches) then + local temp = g.aux_favorite_searches[data.index + 1] + g.aux_favorite_searches[data.index + 1] = data.search + g.aux_favorite_searches[data.index] = temp + update_search_listings() end elseif button == 'LeftButton' then - m.search_box:SetText(data.search.filter_string) - m.execute() + search_box:SetText(data.search.filter_string) + execute() elseif button == 'RightButton' then - if st == m.recent_searches_listing then - tinsert(_G.aux_favorite_searches, 1, data.search) - elseif st == m.favorite_searches_listing then - tremove(_G.aux_favorite_searches, data.index) + if st == recent_searches_listing then + tinsert(g.aux_favorite_searches, 1, data.search) + elseif st == favorite_searches_listing then + tremove(g.aux_favorite_searches, data.index) end - m.update_search_listings() + update_search_listings() end end, OnEnter = function(st, data, self) @@ -689,19 +689,19 @@ function create_frames() end } - recent_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.recent) - m.recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}} - m.recent_searches_listing:EnableSorting(false) - m.recent_searches_listing:DisableSelection(true) - m.recent_searches_listing:SetHandler('OnClick', handlers.OnClick) - m.recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter) - m.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave) + recent_searches_listing = aux.listing.CreateScrollingTable(frame.saved.recent) + 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) + recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter) + recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave) - favorite_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.favorite) - m.favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}} - m.favorite_searches_listing:EnableSorting(false) - m.favorite_searches_listing:DisableSelection(true) - m.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick) - m.favorite_searches_listing:SetHandler('OnEnter', handlers.OnEnter) - m.favorite_searches_listing:SetHandler('OnLeave', handlers.OnLeave) + favorite_searches_listing = aux.listing.CreateScrollingTable(frame.saved.favorite) + 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) + favorite_searches_listing:SetHandler('OnEnter', handlers.OnEnter) + favorite_searches_listing:SetHandler('OnLeave', handlers.OnLeave) end \ No newline at end of file diff --git a/tabs/search/results.lua b/tabs/search/results.lua index a6066ff..f4f581a 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -1,6 +1,6 @@ aux.module 'search_tab' -_G.aux_auto_buy_filter = '' +g.aux_auto_buy_filter = '' search_scan_id = 0 auto_buy_validator = nil @@ -114,8 +114,8 @@ function update_start_stop() end function update_auto_buy_filter() - if _G.aux_auto_buy_filter ~= '' then - local queries = aux.filter.queries(_G.aux_auto_buy_filter) + if g.aux_auto_buy_filter ~= '' then + local queries = aux.filter.queries(g.aux_auto_buy_filter) if queries then if getn(queries) > 1 then aux.log('Error: The automatic buyout filter may contain only one query') @@ -129,7 +129,7 @@ function update_auto_buy_filter() end end end - _G.aux_auto_buy_filter = '' + g.aux_auto_buy_filter = '' end function start_real_time_scan(query, search, continuation) diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index bd512d8..d72cec7 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -1,11 +1,11 @@ aux.module 'search_tab' -_G.aux_favorite_searches = {} -_G.aux_recent_searches = {} +g.aux_favorite_searches = {} +g.aux_recent_searches = {} function update_search_listings() local favorite_search_rows = {} - for i, favorite_search in _G.aux_favorite_searches do + for i, favorite_search in g.aux_favorite_searches do local name = strsub(favorite_search.prettified, 1, 250) tinsert(favorite_search_rows, { cols = {{value=name}}, @@ -16,7 +16,7 @@ function update_search_listings() m.favorite_searches_listing:SetData(favorite_search_rows) local recent_search_rows = {} - for i, recent_search in _G.aux_recent_searches do + for i, recent_search in g.aux_recent_searches do local name = strsub(recent_search.prettified, 1, 250) tinsert(recent_search_rows, { cols = {{value=name}}, @@ -28,12 +28,12 @@ function update_search_listings() end function new_recent_search(filter_string, prettified) - tinsert(_G.aux_recent_searches, 1, { + tinsert(g.aux_recent_searches, 1, { filter_string = filter_string, prettified = prettified, }) - while getn(_G.aux_recent_searches) > 50 do - tremove(_G.aux_recent_searches) + while getn(g.aux_recent_searches) > 50 do + tremove(g.aux_recent_searches) end m.update_search_listings() end \ No newline at end of file diff --git a/util/filter.lua b/util/filter.lua index d922a36..aaf50a4 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -292,7 +292,7 @@ function public.parse_query_string(str) if input_type ~= '' then if not parts[i + 1] or not m.parse_parameter(input_type, parts[i + 1]) then if parts[i] == 'item' then - return nil, 'Invalid item name', _G.aux_auctionable_items + return nil, 'Invalid item name', g.aux_auctionable_items elseif type(input_type) == 'table' then return nil, 'Invalid choice for '..parts[i], input_type else @@ -423,7 +423,7 @@ function suggestions(components) -- item names if aux.util.size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then - for _, name in _G.aux_auctionable_items do + for _, name in g.aux_auctionable_items do tinsert(suggestions, name..'/exact') end end diff --git a/util/info.lua b/util/info.lua index e992ad5..c15387f 100644 --- a/util/info.lua +++ b/util/info.lua @@ -40,13 +40,13 @@ end function public.container_item(bag, slot) for link in aux.util.present(GetContainerItemLink(bag, slot)) do - local item_id, suffix_id, unique_id, enchant_id = m.parse_link(link) + local item_id, suffix_id, unique_id, enchant_id = parse_link(link) local item_info = m.item(item_id, suffix_id, unique_id, enchant_id) local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working? local tooltip, tooltip_money = m.tooltip(function(tt) tt:SetBagItem(bag, slot) end) - local max_charges = m.max_item_charges(item_id) - local charges = max_charges and m.item_charges(tooltip) + local max_charges = max_item_charges(item_id) + local charges = max_charges and item_charges(tooltip) local aux_quantity = charges or count return { @@ -99,8 +99,7 @@ function public.auction(index, query_type) query_type = query_type or 'list' for link in aux.util.present(GetAuctionItemLink(query_type, index)) do - - local item_id, suffix_id, unique_id, enchant_id = m.parse_link(link) + local item_id, suffix_id, unique_id, enchant_id = parse_link(link) local item_info = m.item(item_id, suffix_id, unique_id, enchant_id) local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index) @@ -122,8 +121,8 @@ function public.auction(index, query_type) link = link, itemstring = item_info.itemstring, item_key = item_id..':'..suffix_id, - search_signature = table.concat({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 (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'), - sniping_signature = table.concat({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _G.aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), + search_signature = table.concat({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 (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'), + sniping_signature = table.concat({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, g.aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), name = name, texture = texture, @@ -167,7 +166,7 @@ function public.bid_update(auction_record) auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity auction_record.high_bidder = 1 - auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, _G.aux_ignore_owner and (aux.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') + auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, g.aux_ignore_owner and (aux.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') end function public.set_tooltip(itemstring, owner, anchor) @@ -176,7 +175,7 @@ function public.set_tooltip(itemstring, owner, anchor) end function public.set_shopping_tooltip(slot) - local index1, index2 = m.inventory_index(slot) + local index1, index2 = inventory_index(slot) local tooltips = {} if index1 then local tooltip = m.tooltip(function(tt) tt:SetInventoryItem('player', index1) end) @@ -192,7 +191,7 @@ function public.set_shopping_tooltip(slot) end if tooltips[1] then - tinsert(tooltips[1], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } }) + tinsert(tooltips[1], 1, {left_text='Currently Equipped', left_color={ 0.5, 0.5, 0.5 }}) ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT') m.load_tooltip(ShoppingTooltip1, tooltips[1]) ShoppingTooltip1:Show() @@ -200,7 +199,7 @@ function public.set_shopping_tooltip(slot) end if tooltips[2] then - tinsert(tooltips[2], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } }) + tinsert(tooltips[2], 1, {left_text='Currently Equipped', left_color={ 0.5, 0.5, 0.5 }}) ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT') m.load_tooltip(ShoppingTooltip2, tooltips[2]) ShoppingTooltip2:Show() diff --git a/util/persistence.lua b/util/persistence.lua index 77cbb83..03ece8b 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -1,6 +1,6 @@ aux.module 'persistence' -_G.aux_datasets = {} +g.aux_datasets = {} do local realm, faction @@ -17,8 +17,8 @@ end function public.load_dataset() local dataset_key = m.get_dataset_key() - _G.aux_datasets[dataset_key] = _G.aux_datasets[dataset_key] or {} - return _G.aux_datasets[dataset_key] + g.aux_datasets[dataset_key] = g.aux_datasets[dataset_key] or {} + return g.aux_datasets[dataset_key] end function public.read(schema, str)