fixed bug with stacking

This commit is contained in:
Manuel Simon Hirsig
2015-10-01 00:44:26 +02:00
parent b955184c51
commit 6d0ccf3eb4
5 changed files with 62 additions and 149 deletions
+18 -97
View File
@@ -35,12 +35,14 @@ function Aux.buy.SearchButton_onclick()
Aux_Buy_ScrollbarUpdate()
local category = UIDropDownMenu_GetSelectedValue(AuxBuyCategoryDropDown)
local tooltip_patterns = Aux.util.set_to_array(tooltip_patterns)
search_query = {
name = AuxBuySearchBox:GetText(),
name = AuxBuyNameInputBox:GetText(),
slot = category and category.slot,
class = category and category.class,
subclass = category and category.subclass,
usable = AuxBuyUsableCheckButton:GetChecked()
}
set_message('Scanning auctions ...')
@@ -57,7 +59,7 @@ function Aux.buy.SearchButton_onclick()
return
end
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(
auction_item.name,
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()
AuxBuySearchButton:Disable()
local i = this:GetID()
local entry = entries[i]
-- if Aux.util.set_contains(selectedEntries, entry) then
-- Aux.util.set_remove(selectedEntries, entry)
-- else
-- Aux.util.set_add(selectedEntries, entry)
-- end
-- Aux_Buy_ScrollbarUpdate()
-- PlaySound("igMainMenuOptionCheckBoxOn")
PlaySound("igMainMenuOptionCheckBoxOn")
local found
local order_key = Aux.auction_key(entry.tooltip, entry.stack_size, entry.buyout_price)
Aux.log('starting' .. entry.page .. ' - ' .. current_page)
Aux.scan.start{
query = search_query,
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)
if key == order_key then
found = true
Aux.log('found')
if GetMoney() >= auction_item.buyout_price then
PlaceAuctionBid("list", i, auction_item.buyout_price)
tremove(entries,i)
-- TODO remove
Aux.scan.abort()
end
end
end,
on_complete = function()
if not found then
-- TODO remove
tremove(entries,i)
end
AuxBuySearchButton:Enable()
Aux_Buy_ScrollbarUpdate()
end,
on_abort = function()
AuxBuySearchButton:Enable()
Aux_Buy_ScrollbarUpdate()
end,
}
@@ -464,12 +385,12 @@ function AuxBuySlotDropDown_OnClick()
end
function AuxBuyTooltipAddButton_OnClick()
local pattern = AuxBuyTooltipEdit:GetText()
function AuxBuyTooltipButton_OnClick()
local pattern = AuxBuyTooltipInputBox:GetText()
if pattern ~= '' then
Aux.util.set_add(tooltip_patterns, pattern)
end
AuxBuyTooltipEdit:SetText('')
AuxBuyTooltipInputBox:SetText('')
if DropDownList1:IsVisible() then
Aux.buy.toggle_tooltip_dropdown()
end
@@ -477,8 +398,8 @@ function AuxBuyTooltipAddButton_OnClick()
end
function AuxBuyTooltipRemoveButton_OnClick()
Aux.util.set_remove(tooltip_patterns, AuxBuyTooltipEdit:GetText())
AuxBuyTooltipEdit:SetText('')
Aux.util.set_remove(tooltip_patterns, AuxBuyTooltipInputBox:GetText())
AuxBuyTooltipInputBox:SetText('')
if DropDownList1:IsVisible() then
Aux.buy.toggle_tooltip_dropdown()
end
@@ -500,5 +421,5 @@ function AuxBuyTooltipDropDown_OnClick()
end
function Aux.buy.toggle_tooltip_dropdown()
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipEdit, -12, 4)
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipInputBox, -12, 4)
end
+5 -5
View File
@@ -141,7 +141,7 @@
<Size><AbsDimension x="1" y="1"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-46"/></Offset></Anchor></Anchors>
<Frames>
<EditBox name="AuxBuySearchBox" autoFocus="false" inherits="InputBoxTemplate">
<EditBox name="AuxBuyNameInputBox" autoFocus="false" inherits="InputBoxTemplate">
<Size><AbsDimension x="180" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Layers>
@@ -230,7 +230,7 @@
</Layers>
</CheckButton>
<EditBox name="AuxBuyTooltipEdit" autoFocus="false" inherits="InputBoxTemplate">
<EditBox name="AuxBuyTooltipInputBox" autoFocus="false" inherits="InputBoxTemplate">
<Size><AbsDimension x="145" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="557" y="0"/></Offset></Anchor></Anchors>
<Layers>
@@ -248,7 +248,7 @@
</Layers>
<Scripts>
<OnEnterPressed>
AuxBuyTooltipAddButton_OnClick(this)
AuxBuyTooltipButton_OnClick(this)
</OnEnterPressed>
</Scripts>
</EditBox>
@@ -267,12 +267,12 @@
</Scripts>
</Frame>
<Button name="AuxBuyTooltipAddButton" inherits="UIPanelButtonTemplate" text="+">
<Button name="AuxBuyTooltipButton" inherits="UIPanelButtonTemplate" text="+">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="720" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxBuyTooltipAddButton_OnClick(this)
AuxBuyTooltipButton_OnClick(this)
</OnClick>
</Scripts>
</Button>
+2 -2
View File
@@ -435,7 +435,7 @@ function Aux_ContainerFrameItemButton_OnClick(button)
if PanelTemplates_GetSelectedTab(AuctionFrame) == 1 then
BrowseName:SetText(container_item.name)
elseif PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.buy.index then
AuxBuySearchBox:SetText(container_item.name)
AuxBuyNameInputBox:SetText(container_item.name)
end
return
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())
AuctionFrameTab_OnClick(Aux.tabs.buy.index)
end
AuxBuySearchBox:SetText(container_item.name)
AuxBuyNameInputBox:SetText(container_item.name)
Aux.buy.SearchButton_onclick()
return
end
+17 -26
View File
@@ -39,34 +39,25 @@ end
-----------------------------------------
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.index <= page_state.count and current_job.on_read_auction then
current_job.on_read_auction(page_state.index)
end
page_state.index = min(page_state.index + 1, page_state.count)
end
if 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.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
if not page_state and current_job and CanSendAuctionQuery() then
processing = false
submit_query()
end
+20 -19
View File
@@ -63,7 +63,7 @@ function same_slot(slot1, slot2)
end
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()
amount = min(max_stack(from_slot) - stack_size(to_slot), amount)
@@ -72,7 +72,6 @@ function move_item(from_slot, to_slot, amount)
ClearCursor()
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)
ClearCursor()
end
@@ -104,8 +103,7 @@ function item_charges(slot)
end
function Aux.stack.onupdate()
if state and state.processing <= 0 then
local next_slot = state.other_slots()
if state and state.processing <= 0 and GetTime() - last_move > 0.3 then
local empty_slot = find_empty_slot()
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
)
return
elseif next_slot then
if stack_size(state.target_slot) < state.target_size then
move_item(
next_slot,
state.target_slot,
state.target_size - stack_size(state.target_slot)
)
return
elseif stack_size(state.target_slot) > state.target_size then
move_item(
state.target_slot,
next_slot,
stack_size(state.target_slot) - state.target_size
)
return
else
local next_slot = state.other_slots()
if next_slot then
if stack_size(state.target_slot) < state.target_size then
move_item(
next_slot,
state.target_slot,
state.target_size - stack_size(state.target_slot)
)
return
elseif stack_size(state.target_slot) > state.target_size then
move_item(
state.target_slot,
next_slot,
stack_size(state.target_slot) - state.target_size
)
return
end
end
end