fixed bug with stacking
This commit is contained in:
@@ -35,12 +35,14 @@ function Aux.buy.SearchButton_onclick()
|
|||||||
Aux_Buy_ScrollbarUpdate()
|
Aux_Buy_ScrollbarUpdate()
|
||||||
|
|
||||||
local category = UIDropDownMenu_GetSelectedValue(AuxBuyCategoryDropDown)
|
local category = UIDropDownMenu_GetSelectedValue(AuxBuyCategoryDropDown)
|
||||||
|
local tooltip_patterns = Aux.util.set_to_array(tooltip_patterns)
|
||||||
|
|
||||||
search_query = {
|
search_query = {
|
||||||
name = AuxBuySearchBox:GetText(),
|
name = AuxBuyNameInputBox:GetText(),
|
||||||
slot = category and category.slot,
|
slot = category and category.slot,
|
||||||
class = category and category.class,
|
class = category and category.class,
|
||||||
subclass = category and category.subclass,
|
subclass = category and category.subclass,
|
||||||
|
usable = AuxBuyUsableCheckButton:GetChecked()
|
||||||
}
|
}
|
||||||
|
|
||||||
set_message('Scanning auctions ...')
|
set_message('Scanning auctions ...')
|
||||||
@@ -57,7 +59,7 @@ function Aux.buy.SearchButton_onclick()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local stack_size = auction_item.charges or auction_item.count
|
local stack_size = auction_item.charges or auction_item.count
|
||||||
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(Aux.util.set_to_array(tooltip_patterns), auction_item.tooltip) then
|
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(tooltip_patterns, auction_item.tooltip) then
|
||||||
record_auction(
|
record_auction(
|
||||||
auction_item.name,
|
auction_item.name,
|
||||||
auction_item.tooltip,
|
auction_item.tooltip,
|
||||||
@@ -100,100 +102,17 @@ end
|
|||||||
|
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
function AuxBuyBuySelectedButton_OnClick()
|
|
||||||
|
|
||||||
-- local order = createOrder(selectedEntries)
|
|
||||||
-- local orderedCount = Aux.util.set_size(selectedEntries)
|
|
||||||
|
|
||||||
-- entries = nil
|
|
||||||
-- selectedEntries = {}
|
|
||||||
|
|
||||||
-- Aux_Buy_ScrollbarUpdate()
|
|
||||||
-- AuxBuySearchButton:Disable()
|
|
||||||
-- AuxBuyBuySelectedButton:Disable()
|
|
||||||
|
|
||||||
-- local progress = {
|
|
||||||
-- auctions = 0,
|
|
||||||
-- units = 0,
|
|
||||||
-- expense = 0,
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- set_message('Scanning auctions ...')
|
|
||||||
-- Aux.scan.start{
|
|
||||||
-- query = search_query,
|
|
||||||
-- start_page = 0,
|
|
||||||
-- on_start_page = function(i)
|
|
||||||
-- set_message('Scanning auctions: page ' .. i + 1 .. ' ...')
|
|
||||||
-- end,
|
|
||||||
-- on_read_auction = function(i)
|
|
||||||
-- local auction_item = Aux.info.auction_item(i)
|
|
||||||
|
|
||||||
-- if not auction_item then
|
|
||||||
-- return
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local stack_size = auction_item.charges or auction_item.count
|
|
||||||
|
|
||||||
-- if not auction_item.name or not stack_size or not auction_item.buyout_price then
|
|
||||||
-- return
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_item.buyout_price)
|
|
||||||
-- if order[key] then
|
|
||||||
|
|
||||||
-- if GetMoney() >= auction_item.buyout_price then
|
|
||||||
-- PlaceAuctionBid("list", i, auction_item.buyout_price)
|
|
||||||
-- progress.auctions = progress.auctions + 1
|
|
||||||
-- progress.units = progress.units + stack_size
|
|
||||||
-- progress.expense = progress.expense + auction_item.buyout_price
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- if order[key] > 1 then
|
|
||||||
-- order[key] = order[key] - 1
|
|
||||||
-- else
|
|
||||||
-- order[key] = nil
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
-- on_complete = function()
|
|
||||||
-- entries = entries or {}
|
|
||||||
-- Aux_Buy_ScrollbarUpdate()
|
|
||||||
-- AuxBuySearchButton:Enable()
|
|
||||||
-- report(true, search_query.name, orderedCount, progress)
|
|
||||||
-- end,
|
|
||||||
-- on_abort = function()
|
|
||||||
-- entries = nil
|
|
||||||
-- AuxBuySearchButton:Enable()
|
|
||||||
-- report(false, search_query.name, orderedCount, progress)
|
|
||||||
-- end,
|
|
||||||
-- next_page = function(page, auctions)
|
|
||||||
-- if auctions == Aux.scan.MAX_AUCTIONS_PER_PAGE then
|
|
||||||
-- return page + 1
|
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
-- }
|
|
||||||
end
|
|
||||||
|
|
||||||
-----------------------------------------
|
|
||||||
|
|
||||||
function AuxBuyEntry_OnClick()
|
function AuxBuyEntry_OnClick()
|
||||||
|
AuxBuySearchButton:Disable()
|
||||||
|
|
||||||
local i = this:GetID()
|
local i = this:GetID()
|
||||||
local entry = entries[i]
|
local entry = entries[i]
|
||||||
|
|
||||||
-- if Aux.util.set_contains(selectedEntries, entry) then
|
PlaySound("igMainMenuOptionCheckBoxOn")
|
||||||
-- Aux.util.set_remove(selectedEntries, entry)
|
|
||||||
-- else
|
|
||||||
-- Aux.util.set_add(selectedEntries, entry)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- Aux_Buy_ScrollbarUpdate()
|
|
||||||
|
|
||||||
-- PlaySound("igMainMenuOptionCheckBoxOn")
|
|
||||||
|
|
||||||
local found
|
local found
|
||||||
local order_key = Aux.auction_key(entry.tooltip, entry.stack_size, entry.buyout_price)
|
local order_key = Aux.auction_key(entry.tooltip, entry.stack_size, entry.buyout_price)
|
||||||
|
|
||||||
Aux.log('starting' .. entry.page .. ' - ' .. current_page)
|
|
||||||
Aux.scan.start{
|
Aux.scan.start{
|
||||||
query = search_query,
|
query = search_query,
|
||||||
start_page = entry.page ~= current_page and entry.page,
|
start_page = entry.page ~= current_page and entry.page,
|
||||||
@@ -213,22 +132,24 @@ function AuxBuyEntry_OnClick()
|
|||||||
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_item.buyout_price)
|
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_item.buyout_price)
|
||||||
if key == order_key then
|
if key == order_key then
|
||||||
found = true
|
found = true
|
||||||
Aux.log('found')
|
|
||||||
if GetMoney() >= auction_item.buyout_price then
|
if GetMoney() >= auction_item.buyout_price then
|
||||||
|
|
||||||
PlaceAuctionBid("list", i, auction_item.buyout_price)
|
PlaceAuctionBid("list", i, auction_item.buyout_price)
|
||||||
|
tremove(entries,i)
|
||||||
|
|
||||||
-- TODO remove
|
Aux.scan.abort()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_complete = function()
|
on_complete = function()
|
||||||
if not found then
|
if not found then
|
||||||
-- TODO remove
|
tremove(entries,i)
|
||||||
end
|
end
|
||||||
|
AuxBuySearchButton:Enable()
|
||||||
Aux_Buy_ScrollbarUpdate()
|
Aux_Buy_ScrollbarUpdate()
|
||||||
end,
|
end,
|
||||||
on_abort = function()
|
on_abort = function()
|
||||||
|
AuxBuySearchButton:Enable()
|
||||||
Aux_Buy_ScrollbarUpdate()
|
Aux_Buy_ScrollbarUpdate()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
@@ -464,12 +385,12 @@ function AuxBuySlotDropDown_OnClick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function AuxBuyTooltipAddButton_OnClick()
|
function AuxBuyTooltipButton_OnClick()
|
||||||
local pattern = AuxBuyTooltipEdit:GetText()
|
local pattern = AuxBuyTooltipInputBox:GetText()
|
||||||
if pattern ~= '' then
|
if pattern ~= '' then
|
||||||
Aux.util.set_add(tooltip_patterns, pattern)
|
Aux.util.set_add(tooltip_patterns, pattern)
|
||||||
end
|
end
|
||||||
AuxBuyTooltipEdit:SetText('')
|
AuxBuyTooltipInputBox:SetText('')
|
||||||
if DropDownList1:IsVisible() then
|
if DropDownList1:IsVisible() then
|
||||||
Aux.buy.toggle_tooltip_dropdown()
|
Aux.buy.toggle_tooltip_dropdown()
|
||||||
end
|
end
|
||||||
@@ -477,8 +398,8 @@ function AuxBuyTooltipAddButton_OnClick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function AuxBuyTooltipRemoveButton_OnClick()
|
function AuxBuyTooltipRemoveButton_OnClick()
|
||||||
Aux.util.set_remove(tooltip_patterns, AuxBuyTooltipEdit:GetText())
|
Aux.util.set_remove(tooltip_patterns, AuxBuyTooltipInputBox:GetText())
|
||||||
AuxBuyTooltipEdit:SetText('')
|
AuxBuyTooltipInputBox:SetText('')
|
||||||
if DropDownList1:IsVisible() then
|
if DropDownList1:IsVisible() then
|
||||||
Aux.buy.toggle_tooltip_dropdown()
|
Aux.buy.toggle_tooltip_dropdown()
|
||||||
end
|
end
|
||||||
@@ -500,5 +421,5 @@ function AuxBuyTooltipDropDown_OnClick()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Aux.buy.toggle_tooltip_dropdown()
|
function Aux.buy.toggle_tooltip_dropdown()
|
||||||
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipEdit, -12, 4)
|
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipInputBox, -12, 4)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -141,7 +141,7 @@
|
|||||||
<Size><AbsDimension x="1" y="1"/></Size>
|
<Size><AbsDimension x="1" y="1"/></Size>
|
||||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-46"/></Offset></Anchor></Anchors>
|
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-46"/></Offset></Anchor></Anchors>
|
||||||
<Frames>
|
<Frames>
|
||||||
<EditBox name="AuxBuySearchBox" autoFocus="false" inherits="InputBoxTemplate">
|
<EditBox name="AuxBuyNameInputBox" autoFocus="false" inherits="InputBoxTemplate">
|
||||||
<Size><AbsDimension x="180" y="22"/></Size>
|
<Size><AbsDimension x="180" y="22"/></Size>
|
||||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||||
<Layers>
|
<Layers>
|
||||||
@@ -230,7 +230,7 @@
|
|||||||
</Layers>
|
</Layers>
|
||||||
</CheckButton>
|
</CheckButton>
|
||||||
|
|
||||||
<EditBox name="AuxBuyTooltipEdit" autoFocus="false" inherits="InputBoxTemplate">
|
<EditBox name="AuxBuyTooltipInputBox" autoFocus="false" inherits="InputBoxTemplate">
|
||||||
<Size><AbsDimension x="145" y="22"/></Size>
|
<Size><AbsDimension x="145" y="22"/></Size>
|
||||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="557" y="0"/></Offset></Anchor></Anchors>
|
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="557" y="0"/></Offset></Anchor></Anchors>
|
||||||
<Layers>
|
<Layers>
|
||||||
@@ -248,7 +248,7 @@
|
|||||||
</Layers>
|
</Layers>
|
||||||
<Scripts>
|
<Scripts>
|
||||||
<OnEnterPressed>
|
<OnEnterPressed>
|
||||||
AuxBuyTooltipAddButton_OnClick(this)
|
AuxBuyTooltipButton_OnClick(this)
|
||||||
</OnEnterPressed>
|
</OnEnterPressed>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
</EditBox>
|
</EditBox>
|
||||||
@@ -267,12 +267,12 @@
|
|||||||
</Scripts>
|
</Scripts>
|
||||||
</Frame>
|
</Frame>
|
||||||
|
|
||||||
<Button name="AuxBuyTooltipAddButton" inherits="UIPanelButtonTemplate" text="+">
|
<Button name="AuxBuyTooltipButton" inherits="UIPanelButtonTemplate" text="+">
|
||||||
<Size><AbsDimension x="22" y="22"/></Size>
|
<Size><AbsDimension x="22" y="22"/></Size>
|
||||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="720" y="0"/></Offset></Anchor></Anchors>
|
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="720" y="0"/></Offset></Anchor></Anchors>
|
||||||
<Scripts>
|
<Scripts>
|
||||||
<OnClick>
|
<OnClick>
|
||||||
AuxBuyTooltipAddButton_OnClick(this)
|
AuxBuyTooltipButton_OnClick(this)
|
||||||
</OnClick>
|
</OnClick>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ function Aux_ContainerFrameItemButton_OnClick(button)
|
|||||||
if PanelTemplates_GetSelectedTab(AuctionFrame) == 1 then
|
if PanelTemplates_GetSelectedTab(AuctionFrame) == 1 then
|
||||||
BrowseName:SetText(container_item.name)
|
BrowseName:SetText(container_item.name)
|
||||||
elseif PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.buy.index then
|
elseif PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.buy.index then
|
||||||
AuxBuySearchBox:SetText(container_item.name)
|
AuxBuyNameInputBox:SetText(container_item.name)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
elseif AUX_SELL_SHORTCUT and IsAltKeyDown()then
|
elseif AUX_SELL_SHORTCUT and IsAltKeyDown()then
|
||||||
@@ -453,7 +453,7 @@ function Aux_ContainerFrameItemButton_OnClick(button)
|
|||||||
local container_item = Aux.info.container_item(this:GetParent():GetID(), this:GetID())
|
local container_item = Aux.info.container_item(this:GetParent():GetID(), this:GetID())
|
||||||
AuctionFrameTab_OnClick(Aux.tabs.buy.index)
|
AuctionFrameTab_OnClick(Aux.tabs.buy.index)
|
||||||
end
|
end
|
||||||
AuxBuySearchBox:SetText(container_item.name)
|
AuxBuyNameInputBox:SetText(container_item.name)
|
||||||
Aux.buy.SearchButton_onclick()
|
Aux.buy.SearchButton_onclick()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,34 +39,25 @@ end
|
|||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
function Aux.scan.on_update()
|
function Aux.scan.on_update()
|
||||||
|
|
||||||
|
if page_state and page_state.index <= page_state.count and current_job.on_read_auction then
|
||||||
|
current_job.on_read_auction(page_state.index)
|
||||||
|
end
|
||||||
|
|
||||||
|
if page_state and page_state.index == page_state.count then
|
||||||
|
current_page = current_job.next_page and current_job.next_page(current_page, page_state.count, page_state.total_count)
|
||||||
|
if current_page then
|
||||||
|
page_state = nil
|
||||||
|
else
|
||||||
|
Aux.scan.complete()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if page_state then
|
if page_state then
|
||||||
if page_state.index <= page_state.count and current_job.on_read_auction then
|
page_state.index = min(page_state.index + 1, page_state.count)
|
||||||
current_job.on_read_auction(page_state.index)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if page_state.index == page_state.count then
|
if not page_state and current_job and CanSendAuctionQuery() then
|
||||||
current_page = current_job.next_page and current_job.next_page(current_page, page_state.count, page_state.total_count)
|
|
||||||
if current_page then
|
|
||||||
page_state = nil
|
|
||||||
else
|
|
||||||
Aux.scan.complete()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if page_state.index == page_state.count then
|
|
||||||
-- if page_state.index == MAX_AUCTIONS_PER_PAGE then
|
|
||||||
-- page_state = nil
|
|
||||||
-- current_page = current_page + 1
|
|
||||||
-- else
|
|
||||||
-- Aux.scan.complete()
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
if page_state then
|
|
||||||
page_state.index = min(page_state.index + 1, page_state.count)
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif current_job and CanSendAuctionQuery() then
|
|
||||||
processing = false
|
processing = false
|
||||||
submit_query()
|
submit_query()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function same_slot(slot1, slot2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function move_item(from_slot, to_slot, amount)
|
function move_item(from_slot, to_slot, amount)
|
||||||
if stack_size(to_slot) < max_stack(from_slot) and GetTime() - last_move > 0.3 then
|
if stack_size(to_slot) < max_stack(from_slot) then
|
||||||
last_move = GetTime()
|
last_move = GetTime()
|
||||||
|
|
||||||
amount = min(max_stack(from_slot) - stack_size(to_slot), amount)
|
amount = min(max_stack(from_slot) - stack_size(to_slot), amount)
|
||||||
@@ -72,7 +72,6 @@ function move_item(from_slot, to_slot, amount)
|
|||||||
|
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
SplitContainerItem(from_slot.bag, from_slot.bag_slot, amount)
|
SplitContainerItem(from_slot.bag, from_slot.bag_slot, amount)
|
||||||
snipe.log('a'..amount..'s'..stack_size(to_slot))
|
|
||||||
PickupContainerItem(to_slot.bag, to_slot.bag_slot)
|
PickupContainerItem(to_slot.bag, to_slot.bag_slot)
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
end
|
end
|
||||||
@@ -104,8 +103,7 @@ function item_charges(slot)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Aux.stack.onupdate()
|
function Aux.stack.onupdate()
|
||||||
if state and state.processing <= 0 then
|
if state and state.processing <= 0 and GetTime() - last_move > 0.3 then
|
||||||
local next_slot = state.other_slots()
|
|
||||||
local empty_slot = find_empty_slot()
|
local empty_slot = find_empty_slot()
|
||||||
|
|
||||||
if empty_slot and stack_size(state.target_slot) > state.target_size then
|
if empty_slot and stack_size(state.target_slot) > state.target_size then
|
||||||
@@ -115,21 +113,24 @@ function Aux.stack.onupdate()
|
|||||||
stack_size(state.target_slot) - state.target_size
|
stack_size(state.target_slot) - state.target_size
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
elseif next_slot then
|
else
|
||||||
if stack_size(state.target_slot) < state.target_size then
|
local next_slot = state.other_slots()
|
||||||
move_item(
|
if next_slot then
|
||||||
next_slot,
|
if stack_size(state.target_slot) < state.target_size then
|
||||||
state.target_slot,
|
move_item(
|
||||||
state.target_size - stack_size(state.target_slot)
|
next_slot,
|
||||||
)
|
state.target_slot,
|
||||||
return
|
state.target_size - stack_size(state.target_slot)
|
||||||
elseif stack_size(state.target_slot) > state.target_size then
|
)
|
||||||
move_item(
|
return
|
||||||
state.target_slot,
|
elseif stack_size(state.target_slot) > state.target_size then
|
||||||
next_slot,
|
move_item(
|
||||||
stack_size(state.target_slot) - state.target_size
|
state.target_slot,
|
||||||
)
|
next_slot,
|
||||||
return
|
stack_size(state.target_slot) - state.target_size
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user