added right click support where you could drag before, cleaned up the static database interface a bit
This commit is contained in:
+3
-5
@@ -6,10 +6,8 @@ do
|
||||
function m.sorted_item_names()
|
||||
if not sorted_item_names then
|
||||
sorted_item_names = {}
|
||||
for key, value in Aux.static.auctionable_items do
|
||||
if type(key) == 'number' then
|
||||
tinsert(sorted_item_names, value.name)
|
||||
end
|
||||
for _, item_info in ipairs(Aux.static.items()) do
|
||||
tinsert(sorted_item_names, item_info.name)
|
||||
end
|
||||
sort(sorted_item_names, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
@@ -33,7 +31,7 @@ function m:complete()
|
||||
current_filter = current_filter or {}
|
||||
|
||||
if current_filter.name
|
||||
and Aux.static.auctionable_items[strupper(current_filter.name)]
|
||||
and Aux.static.item_id(strupper(current_filter.name))
|
||||
and not current_filter.min_level
|
||||
and not current_filter.max_level
|
||||
and not current_filter.class
|
||||
|
||||
@@ -169,8 +169,8 @@ function Aux.setup_hooks()
|
||||
Aux.orig.SetItemRef = SetItemRef
|
||||
SetItemRef = Aux.SetItemRef
|
||||
|
||||
Aux.orig.ContainerFrameItemButton_OnClick = ContainerFrameItemButton_OnClick
|
||||
ContainerFrameItemButton_OnClick = Aux.ContainerFrameItemButton_OnClick
|
||||
Aux.orig.UseContainerItem = UseContainerItem
|
||||
UseContainerItem = Aux.UseContainerItem
|
||||
|
||||
Aux.orig.AuctionFrameAuctions_OnEvent = AuctionFrameAuctions_OnEvent
|
||||
AuctionFrameAuctions_OnEvent = Aux.AuctionFrameAuctions_OnEvent
|
||||
@@ -287,26 +287,28 @@ function Aux.SetItemRef(itemstring, text, button)
|
||||
return Aux.orig.SetItemRef(itemstring, text, button)
|
||||
end
|
||||
|
||||
function Aux.ContainerFrameItemButton_OnClick(button)
|
||||
local bag, slot = this:GetParent():GetID(), this:GetID()
|
||||
local item_info = Aux.info.container_item(bag, slot)
|
||||
|
||||
-- if AuxFrame:IsVisible() and button == 'LeftButton' and item_info then
|
||||
-- if IsAltKeyDown() then
|
||||
-- if Aux.active_panel ~= 1 then
|
||||
-- Aux.on_tab_click(1)
|
||||
-- end
|
||||
--
|
||||
-- Aux.control.as_soon_as(function() return Aux.active_panel == 1 end, function()
|
||||
-- AuxItemSearchFrameItemItemInputBox:Hide()
|
||||
-- Aux.item_search_frame.set_item(item_info.item_id)
|
||||
-- end)
|
||||
--
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
function Aux.UseContainerItem(bag, slot)
|
||||
|
||||
return Aux.orig.ContainerFrameItemButton_OnClick(button)
|
||||
if arg1 == 'RightButton' then
|
||||
if AuxSearchFrame:IsVisible() then
|
||||
local item_info = Aux.info.container_item(bag, slot)
|
||||
item_info = item_info and Aux.static.item_info(item_info.item_id)
|
||||
if item_info then
|
||||
Aux.search_frame.start_search(strlower(item_info.name)..'/exact')
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if AuxPostFrame:IsVisible() then
|
||||
local item_info = Aux.info.container_item(bag, slot)
|
||||
if item_info then
|
||||
Aux.post_frame.select_item(item_info.item_key)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return Aux.orig.UseContainerItem(bag, slot)
|
||||
end
|
||||
|
||||
function Aux.quality_color(code)
|
||||
|
||||
+10
-6
@@ -68,6 +68,15 @@ function private.selected_auction()
|
||||
return selected_item and existing_auctions[selected_item.key] and existing_auctions[selected_item.key].selected
|
||||
end
|
||||
|
||||
function public.select_item(item_key)
|
||||
for _, inventory_record in ipairs(Aux.util.filter(inventory_records, function(record) return record.aux_quantity > 0 end)) do
|
||||
if inventory_record.key == item_key then
|
||||
private.set_item(inventory_record)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
|
||||
Aux.gui.vertical_line(AuxPostFrameContent, 219)
|
||||
@@ -76,12 +85,7 @@ function public.on_load()
|
||||
AuxSellParametersItem:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item()
|
||||
if item_info then
|
||||
for _, inventory_record in ipairs(Aux.util.filter(inventory_records, function(record) return record.aux_quantity > 0 end)) do
|
||||
if inventory_record.key == item_info.item_key then
|
||||
private.set_item(inventory_record)
|
||||
break
|
||||
end
|
||||
end
|
||||
public.select_item(item_info.item_key)
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
|
||||
+3
-3
@@ -188,7 +188,7 @@ function m.filter_from_string(filter_term)
|
||||
or filter.quality
|
||||
or filter.usable
|
||||
or not filter.name
|
||||
or not Aux.static.auctionable_items[strupper(filter.name)]
|
||||
or not Aux.static.item_id(strupper(filter.name))
|
||||
then
|
||||
return false, 'Erroneous Exact Only Modifier'
|
||||
end
|
||||
@@ -262,8 +262,8 @@ function m.blizzard_query(filter)
|
||||
|
||||
local item_info
|
||||
if filter.exact then
|
||||
local item_id = Aux.static.auctionable_items[strupper(filter.name)]
|
||||
item_info = Aux.static.auctionable_items[item_id]
|
||||
local item_id = Aux.static.item_id(strupper(filter.name))
|
||||
item_info = Aux.static.item_info(item_id)
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
+2
-3
@@ -168,7 +168,7 @@ function private.prettify_search(search)
|
||||
while true do
|
||||
local _, _, name, in_between = strfind(search, item_pattern)
|
||||
if name then
|
||||
search = gsub(search, item_pattern, private.display_name(Aux.static.auctionable_items[strupper(name)])..in_between, 1)
|
||||
search = gsub(search, item_pattern, private.display_name(Aux.static.item_id(strupper(name)))..in_between, 1)
|
||||
else
|
||||
return Aux.gui.inline_color({216, 225, 211, 1})..search..'|r'
|
||||
end
|
||||
@@ -240,8 +240,7 @@ function public.on_load()
|
||||
editbox:SetScript('OnReceiveDrag', function()
|
||||
local item_info = Aux.cursor_item() and Aux.static.item_info(Aux.cursor_item().item_id)
|
||||
if item_info then
|
||||
this:SetText(strlower(item_info.name)..'/exact')
|
||||
public.start_search()
|
||||
public.start_search(strlower(item_info.name)..'/exact')
|
||||
end
|
||||
ClearCursor()
|
||||
end)
|
||||
|
||||
+24
-10
@@ -3,31 +3,45 @@ Aux.static = public
|
||||
|
||||
aux_auctionable_items = nil
|
||||
|
||||
function public.item_ids()
|
||||
local ids = {}
|
||||
function public.items()
|
||||
local items = {}
|
||||
|
||||
local cache = aux_auctionable_items or public.auctionable_items
|
||||
|
||||
for key, _ in pairs(cache) do
|
||||
for key, value in pairs(aux_auctionable_items or private.auctionable_items) do
|
||||
if type(key) == 'number' then
|
||||
tinsert(ids, key)
|
||||
tinsert(items, value)
|
||||
end
|
||||
end
|
||||
|
||||
return ids
|
||||
return items
|
||||
end
|
||||
|
||||
function public.item_id(item_name)
|
||||
if type(item_name) ~= 'string' then
|
||||
return
|
||||
end
|
||||
|
||||
if aux_auctionable_items and aux_auctionable_items[item_name] then
|
||||
return aux_auctionable_items[item_name]
|
||||
else
|
||||
return private.auctionable_items[item_name]
|
||||
end
|
||||
end
|
||||
|
||||
function public.item_info(item_id)
|
||||
if type(item_id) ~= 'number' then
|
||||
return
|
||||
end
|
||||
|
||||
if aux_auctionable_items and aux_auctionable_items[item_id] then
|
||||
return aux_auctionable_items[item_id]
|
||||
else
|
||||
return public.auctionable_items[item_id]
|
||||
return private.auctionable_items[item_id]
|
||||
end
|
||||
end
|
||||
|
||||
function public.generate_cache()
|
||||
local ids = {}
|
||||
for id, _ in pairs(public.auctionable_items) do
|
||||
for id, _ in pairs(private.auctionable_items) do
|
||||
tinsert(ids, id)
|
||||
end
|
||||
local n = getn(ids)
|
||||
@@ -96,7 +110,7 @@ function public.find_auctionable_items() -- requires a full wdb item cache
|
||||
helper(1)
|
||||
end
|
||||
|
||||
public.auctionable_items = {
|
||||
private.auctionable_items = {
|
||||
[7932] = {
|
||||
["max_stack"] = 1,
|
||||
["id"] = 7932,
|
||||
|
||||
Reference in New Issue
Block a user