diff --git a/Aux-AddOn.toc b/Aux-AddOn.toc
index e850170..1323378 100644
--- a/Aux-AddOn.toc
+++ b/Aux-AddOn.toc
@@ -1,18 +1,21 @@
## Interface: 11200
## Title: Aux
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches
-## SavedVariables: aux_datasets, aux_post_mode, aux_price_per_unit, aux_tooltip_daily, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
+## SavedVariables: aux_datasets, aux_items, aux_auctionable_items, aux_post_mode, aux_price_per_unit, aux_tooltip_daily, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
slash.lua
core.xml
gui.lua
control.xml
persistence.lua
+item_cache.lua
+merchant.lua
disenchant.lua
tooltip.lua
util.lua
sort.lua
money.lua
+info.lua
scan.lua
scan_util.lua
@@ -22,7 +25,6 @@ listing.lua
auction_listing.lua
item_listing.lua
history.lua
-info.xml
completion.xml
search_frame.xml
@@ -30,8 +32,6 @@ post_frame.xml
auctions_frame.xml
bids_frame.xml
-static.xml
-
test.lua
diff --git a/core.lua b/core.lua
index 7545602..fc6bdd6 100644
--- a/core.lua
+++ b/core.lua
@@ -47,7 +47,7 @@ function Aux.on_load()
end)
end
- Aux.static.on_load()
+ Aux.item_cache.on_load()
Aux.persistence.on_load()
Aux.tooltip.on_load()
Aux.search_frame.on_load()
diff --git a/core.xml b/core.xml
index d475ce0..bdeffb5 100644
--- a/core.xml
+++ b/core.xml
@@ -18,6 +18,14 @@
+
+
+
+ this.money = arg1
+
+
+
+
diff --git a/info.lua b/info.lua
index 28ef705..f30aba2 100644
--- a/info.lua
+++ b/info.lua
@@ -275,23 +275,23 @@ end
function public.tooltip(setter)
for i = 1, TOOLTIP_LENGTH do
- getglobal('AuxInfoTooltipTextLeft'..i):SetText()
- getglobal('AuxInfoTooltipTextRight'..i):SetText()
+ getglobal('AuxTooltipTextLeft'..i):SetText()
+ getglobal('AuxTooltipTextRight'..i):SetText()
end
- AuxInfoTooltip:SetOwner(UIParent, 'ANCHOR_NONE')
- AuxInfoTooltip.money = 0
- setter(AuxInfoTooltip)
- AuxInfoTooltip:Show()
-
- local tooltip = { money=AuxInfoTooltip.money }
+ AuxTooltip:SetOwner(UIParent, 'ANCHOR_NONE')
+ AuxTooltip.money = 0
+ setter(AuxTooltip)
+ AuxTooltip:Show()
+
+ local tooltip = { money=AuxTooltip.money }
for i = 1, TOOLTIP_LENGTH do
- local left_text = getglobal('AuxInfoTooltipTextLeft'..i):GetText()
- local left_color = { getglobal('AuxInfoTooltipTextLeft'..i):GetTextColor() }
+ local left_text = getglobal('AuxTooltipTextLeft'..i):GetText()
+ local left_color = { getglobal('AuxTooltipTextLeft'..i):GetTextColor() }
- local right_text = getglobal('AuxInfoTooltipTextRight'..i):GetText()
- local right_color = { getglobal('AuxInfoTooltipTextRight'..i):GetTextColor() }
+ local right_text = getglobal('AuxTooltipTextRight'..i):GetText()
+ local right_color = { getglobal('AuxTooltipTextRight'..i):GetTextColor() }
if left_text or right_text then
tinsert(tooltip, {
@@ -304,8 +304,8 @@ function public.tooltip(setter)
end
for i = 1, TOOLTIP_LENGTH do
- getglobal('AuxInfoTooltipTextLeft'..i):SetText()
- getglobal('AuxInfoTooltipTextRight'..i):SetText()
+ getglobal('AuxTooltipTextLeft'..i):SetText()
+ getglobal('AuxTooltipTextRight'..i):SetText()
end
return tooltip
diff --git a/info.xml b/info.xml
deleted file mode 100644
index 3f6382f..0000000
--- a/info.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
- Aux.info.reanchor_tooltip()
-
-
- this.money = arg1
-
-
-
-
\ No newline at end of file
diff --git a/item_cache.lua b/item_cache.lua
new file mode 100644
index 0000000..4c7d1bf
--- /dev/null
+++ b/item_cache.lua
@@ -0,0 +1,69 @@
+local private, public = {}, {}
+Aux.item_cache = public
+
+local MIN_ITEM_ID, MAX_ITEM_ID = 1, 30000
+
+aux_items = {}
+aux_auctionable_items = {}
+
+function public.on_load()
+ private.find_auctionable_items()
+end
+
+function public.item_id(item_name)
+ return aux_items[strlower(item_name)]
+end
+
+function private.find_auctionable_items()
+
+ local function helper(item_id)
+ local processed = 0
+ while processed <= 100 and item_id <= MAX_ITEM_ID do
+ local itemstring = 'item:'..item_id
+ local name, _, quality = GetItemInfo(itemstring)
+ name = name and strlower(name)
+ if name and not aux_items[name] then
+ aux_items[name] = item_id
+ local tooltip = Aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
+ if Aux.info.auctionable(tooltip, quality) then
+ tinsert(aux_auctionable_items, name)
+ end
+ processed = processed + 1
+ end
+ item_id = item_id + 1
+ end
+
+ if item_id <= MAX_ITEM_ID then
+ local t0 = GetTime()
+ Aux.control.as_soon_as(function() return GetTime() - t0 > 0.1 end, function()
+ return helper(item_id)
+ end)
+ else
+ sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
+ end
+ end
+
+ helper(MIN_ITEM_ID)
+end
+
+function public.populate_wdb()
+
+ local function helper(item_id)
+ if item_id > MAX_ITEM_ID then
+ Aux.log('Cache populated.')
+ return
+ end
+
+ if not GetItemInfo('item:'..item_id) then
+ Aux.log('Fetching item '..item_id..'.')
+ AuxTooltip:SetHyperlink('item:'..item_id)
+ end
+
+ local t0 = GetTime()
+ Aux.control.as_soon_as(function() return GetItemInfo('item:'..item_id) or GetTime() - t0 > 0.1 end, function()
+ return helper(item_id + 1)
+ end)
+ end
+
+ helper(MIN_ITEM_ID)
+end
\ No newline at end of file
diff --git a/scan_util.lua b/scan_util.lua
index fc76f17..9e6d508 100644
--- a/scan_util.lua
+++ b/scan_util.lua
@@ -40,7 +40,7 @@ m.filters = {
arity = 1,
test = function(name)
if not name then
- return false, Aux.static.sorted_item_names(), 'Erroneous Item Modifier'
+ return false, aux_auctionable_items, 'Erroneous Item Modifier'
end
return function(auction_record)
@@ -529,7 +529,7 @@ function m.filter_from_string(filter_term)
then
return false, {}, 'Erroneous Exact Only Modifier'
else
- prettified:prepend(Aux.info.display_name(Aux.static.item_id(blizzard_filter.name)) or '['..blizzard_filter.name..']')
+ prettified:prepend(Aux.info.display_name(Aux.item_cache.item_id(blizzard_filter.name)) or Aux.gui.inline_color({216, 225, 211, 1})..'['..blizzard_filter.name..']|r')
end
elseif blizzard_filter.name then
if blizzard_filter.name == '' then
@@ -606,7 +606,7 @@ function m.suggestions(blizzard_filter, num_parts)
-- item names
if num_parts == 1 and blizzard_filter.name == '' then
- for _, name in ipairs(Aux.static.sorted_item_names()) do
+ for _, name in ipairs(Aux.item_cache.sorted_auctionable_items()) do
tinsert(suggestions, name..'/exact')
end
end
@@ -618,7 +618,7 @@ function m.blizzard_query(filter)
local item_info, class_index, subclass_index, slot_index
if filter.exact then
- local item_id = Aux.static.item_id(filter.name)
+ local item_id = Aux.item_cache.item_id(filter.name)
item_info = Aux.info.item(item_id)
class_index = item_info and Aux.item_class_index(item_info.class)
subclass_index = class_index and item_info.subclass and Aux.item_subclass_index(class_index, item_info.subclass)
diff --git a/search_frame.lua b/search_frame.lua
index c597dcb..59466e0 100644
--- a/search_frame.lua
+++ b/search_frame.lua
@@ -351,7 +351,7 @@ function public.on_load()
end
do
local editbox = Aux.gui.editbox(AuxSearchFrameFilter, '$parentNameInputBox')
- editbox.complete_item = Aux.completion.completor(Aux.static.sorted_item_names)
+ editbox.complete_item = Aux.completion.completor(function() return aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -20)
editbox:SetWidth(260)
editbox:SetScript('OnChar', function()
diff --git a/slash.lua b/slash.lua
index b2591a5..27b2335 100644
--- a/slash.lua
+++ b/slash.lua
@@ -9,12 +9,12 @@ function SlashCmdList.AUX(parameter)
elseif parameter == 'clear' then
aux_datasets = {}
Aux.log('Database cleared.')
- elseif parameter == 'generate item cache' then
- Aux.static.generate_cache()
- elseif parameter == 'delete item cache' then
- aux_auctionable_items = nil
- aux_auctionable_item_ids = nil
- Aux.log('Item cache deleted; falling back to the default.')
+ elseif parameter == 'clear item cache' then
+ aux_items = {}
+ aux_auctionable_items = {}
+ Aux.log('Item cache cleared.')
+ elseif parameter == 'populate wdb' then
+ Aux.item_cache.populate_wdb()
elseif parameter == 'tooltip daily' then
aux_tooltip_daily = not aux_tooltip_daily
Aux.log('Market value in tooltip '..(aux_tooltip_daily and 'enabled' or 'disabled')..'.')
diff --git a/static.lua b/static.lua
deleted file mode 100644
index 3e17a80..0000000
--- a/static.lua
+++ /dev/null
@@ -1,101 +0,0 @@
-local private, public = {}, {}
-Aux.static = public
-
-local auctionable_items = {}
-local sorted_item_names
-
-function public.on_load()
- private.find_auctionable_items()
-end
-
-function public.sorted_item_names()
- if not sorted_item_names then
- sorted_item_names = {}
- for name, _ in auctionable_items do
- tinsert(sorted_item_names, name)
- end
- sort(sorted_item_names, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
- end
- return sorted_item_names
-end
-
-function public.item_id(item_name)
- return auctionable_items[strlower(item_name)]
-end
-
-function public.item_info(item_id)
- local data_string
-
- if aux_auctionable_items then
- data_string = aux_auctionable_items[item_id]
- else
- data_string = private.auctionable_items[item_id]
- end
-
- return data_string and private.read_item_info(data_string)
-end
-
---function public.generate_cache()
--- local ids = {}
--- for id, _ in pairs(private.auctionable_items) do
--- if type(id) == 'number' then
--- tinsert(ids, id)
--- end
--- end
--- local n = getn(ids)
---
--- local function helper(index)
--- if index > n then
--- Aux.log('Cache generated.')
--- return
--- end
---
--- local id = ids[index]
--- if not GetItemInfo(id) then
--- Aux.log('Fetching item '..id..' ...')
--- AuxStaticTooltip:SetHyperlink('item:'..id)
--- end
--- local t0 = time()
--- Aux.control.as_soon_as(function() return GetItemInfo(id) or time() > t0 + 3 end, function()
--- local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(id)
--- if name then
--- local class_index = Aux.item_class_index(class)
--- local subclass_index = class_index and Aux.item_subclass_index(class_index, subclass)
---
--- Aux.log('Adding item '..id..' ...')
---
--- aux_auctionable_item_ids[strupper(name)] = id
--- aux_auctionable_items[id] = Aux.util.join({id or '', name or '', quality or '', level or '', class_index or '', subclass_index or '', slot or '', max_stack or '', texture or ''}, '#')
--- end
--- return helper(index + 1)
--- end)
--- end
---
--- aux_auctionable_items = {}
--- aux_auctionable_item_ids = {}
--- helper(1)
---end
-
-function private.find_auctionable_items() -- requires a full wdb item cache
- local function helper(i)
- for item_id=i,i+200 do
- local name, _, quality = GetItemInfo('item:'..item_id)
- if name then
- local item_id = item_id
- local tooltip = Aux.info.tooltip(function(tt) tt:SetHyperlink('item:'..item_id) end)
- if Aux.info.auctionable(tooltip, quality) then
- auctionable_items[strlower(name)] = item_id
- sorted_item_names = nil
- end
- end
- end
- if i+200 <= 30000 then
- local t0 = GetTime()
- Aux.control.as_soon_as(function() return GetTime() - t0 > 0.2 end, function()
- return helper(i+200)
- end)
- end
- end
-
- helper(1)
-end
\ No newline at end of file
diff --git a/static.xml b/static.xml
deleted file mode 100644
index 2acb387..0000000
--- a/static.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-