diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c16ea50..ee1b1e4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,11 @@ - - - - + + @@ -64,8 +62,8 @@ @@ -76,68 +74,58 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - + + @@ -147,17 +135,7 @@ - - - - - - - - - - - + @@ -166,13 +144,33 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -186,16 +184,17 @@ @@ -300,19 +299,6 @@ @@ -470,26 +469,10 @@ - + - - - - - - - - - - - - - - - - - - + + @@ -502,22 +485,38 @@ - + - - + + + + + + + + + + - + + + + + + + + + @@ -536,7 +535,7 @@ - + @@ -550,26 +549,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + + diff --git a/core.lua b/core.lua index 2df6307..36767b2 100644 --- a/core.lua +++ b/core.lua @@ -121,6 +121,15 @@ function Aux_SetupHookFunctions() Aux.orig.ContainerFrameItemButton_OnClick = ContainerFrameItemButton_OnClick ContainerFrameItemButton_OnClick = Aux_ContainerFrameItemButton_OnClick + Aux.orig.AuctionFrameAuctions_OnEvent = AuctionFrameAuctions_OnEvent + AuctionFrameAuctions_OnEvent = Aux.AuctionFrameAuctions_OnEvent + +end + +function Aux.AuctionFrameAuctions_OnEvent() + if AuctionFrameAuctions:IsVisible() then + Aux.orig.AuctionFrameAuctions_OnEvent() + end end function Aux_OnAuctionHouseShow() diff --git a/info.lua b/info.lua index 33ac224..ef6087e 100644 --- a/info.lua +++ b/info.lua @@ -33,8 +33,7 @@ function Aux.info.auction_sell_item() if name then - local deposit_factor = CalculateAuctionDeposit(120) / vendor_price - local vendor_price_per_unit = vendor_price / stack_size + local unit_vendor_price = vendor_price / stack_size auction_sell_item = { name = name, @@ -42,8 +41,7 @@ function Aux.info.auction_sell_item() stack_size = stack_size, quality = quality, usable = usable, - vendor_price_per_unit = vendor_price_per_unit, - vendor_price = vendor_price, + unit_vendor_price = unit_vendor_price, deposit_factor = deposit_factor, } diff --git a/sell.lua b/sell.lua index c793b91..a714b5f 100644 --- a/sell.lua +++ b/sell.lua @@ -212,7 +212,7 @@ function Aux.sell.on_open() Aux.sell.validate_parameters() - inventory_data = auction_candidates() + update_inventory_data() update_inventory_listing() update_auction_listing() @@ -283,7 +283,7 @@ function Aux.sell.post_auctions() end end Aux.sell.clear_auction() - inventory_data = auction_candidates() + update_inventory_data() update_inventory_listing() report(hyperlink, stack_size, buyout_price, posted) end @@ -363,7 +363,7 @@ function update_recommendation() AuxSellStackCountSlider:SetMinMaxValues(0,0) AuxSellStackCount:SetNumber(0) else - AuxSellStackSize:SetNumber(AuxSellStackSizeSlider:GetValue()) + AuxSellStackSize:SetNumber(current_auction.charges and AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider:GetValue()] or AuxSellStackSizeSlider:GetValue()) AuxSellStackCount:SetNumber(AuxSellStackCountSlider:GetValue()) AuxSellParametersItemIconTexture:SetTexture(current_auction.texture) @@ -377,12 +377,13 @@ function update_recommendation() end AuxSellRefreshButton:Enable() - - MoneyFrame_Update("AuxSellParametersDepositMoneyFrame", floor(current_auction.vendor_price_per_unit * current_auction.deposit_factor * (current_auction.charges and 1 or get_stack_size_slider_value())) * AuxSellStackCountSlider:GetValue() * AuctionFrameAuctions.duration / 120) + + -- TODO neutral AH deposit formula + MoneyFrame_Update('AuxSellParametersDepositMoneyFrame', floor(current_auction.unit_vendor_price * 0.05 * (current_auction.charges and 1 or get_stack_size_slider_value())) * AuxSellStackCountSlider:GetValue() * AuctionFrameAuctions.duration / 120) if auxSellEntries[current_auction.name] and auxSellEntries[current_auction.name].selected then if not auxSellEntries[current_auction.name].created or GetTime() - auxSellEntries[current_auction.name].created > 1800 then - AuxSellParametersStrategyDropDownStaleWarning:SetText("Stale data!") -- data older than half an hour marked as stale + AuxSellParametersStrategyDropDownStaleWarning:SetText('Stale data!') -- data older than half an hour marked as stale end local newBuyoutPrice = auxSellEntries[current_auction.name].selected.unit_buyout_price * get_stack_size_slider_value() @@ -429,7 +430,7 @@ end function Aux.sell.quantity_update() if current_auction then - AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider.GetValue()]] or floor(current_auction.availability[0] / get_stack_size_slider_value())) + AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider:GetValue()]] or floor(current_auction.availability[0] / get_stack_size_slider_value())) end select_entry() update_recommendation() @@ -455,7 +456,7 @@ function set_auction(auction_candidate) update_inventory_listing() local charge_classes = charge_classes(current_auction.availability) - AuxSellStackSizeSlider.charge_classes = charge_classes + AuxSellStackSizeSlider.charge_classes = current_auction.charges and charge_classes local stack_size_slider_max = current_auction.charges and getn(charge_classes) or min(current_auction.max_stack, current_auction.availability[0]) AuxSellStackSizeSlider:SetMinMaxValues(1, stack_size_slider_max) @@ -484,66 +485,81 @@ function charge_classes(availability) return charge_classes end -function auction_candidates() +function update_inventory_data() + inventory_data = {} + update_inventory_listing() local auction_candidate_map = {} - Aux.util.without_sound(function() - Aux.util.without_errors(function() + local function process_inventory(inventory_iterator, k) + local slot = inventory_iterator() - for bag = 0, 4 do - if GetBagName(bag) then - for slot = 1, GetContainerNumSlots(bag) do - local item_info = Aux.info.container_item(bag, slot) + if not slot then + return k() + end - if item_info then + local item_info = Aux.info.container_item(slot.bag, slot.bag_slot) - local charge_class = item_info.charges or 0 + if item_info then - ClearCursor() - PickupContainerItem(bag,slot) - ClickAuctionSellItemButton() - local auction_sell_item = Aux.info.auction_sell_item() - ClearCursor() - ClickAuctionSellItemButton() - ClearCursor() + return Aux.control.on_next_update(function() - if auction_sell_item then - if not auction_candidate_map[item_info.item_signature] then + local charge_class = item_info.charges or 0 - auction_candidate_map[item_info.item_signature] = { - hyperlink = item_info.hyperlink, - name = item_info.name, - texture = item_info.texture, - quality = item_info.quality, - class = item_info.type, - subclass = item_info.subtype, - deposit_factor = auction_sell_item.deposit_factor, - vendor_price_per_unit = auction_sell_item.vendor_price_per_unit, - charges = item_info.charges, - aux_quantity = item_info.charges or item_info.count, - max_stack = item_info.max_stack, - availability = { [charge_class]=item_info.count }, - } - else - local candidate = auction_candidate_map[item_info.item_signature] - candidate.availability[charge_class] = (candidate.availability[charge_class] or 0) + item_info.count - candidate.aux_quantity = candidate.aux_quantity + (item_info.charges or item_info.count) - end - end - end + local auction_sell_item + + Aux.util.without_sound(function() + Aux.util.without_errors(function() + + ClearCursor() + PickupContainerItem(slot.bag, slot.bag_slot) + ClickAuctionSellItemButton() + auction_sell_item = Aux.info.auction_sell_item() + ClearCursor() + ClickAuctionSellItemButton() + ClearCursor() + + end) + end) + + if auction_sell_item then + if not auction_candidate_map[item_info.item_signature] then + + auction_candidate_map[item_info.item_signature] = { + hyperlink = item_info.hyperlink, + name = item_info.name, + texture = item_info.texture, + quality = item_info.quality, + class = item_info.type, + subclass = item_info.subtype, + unit_vendor_price = auction_sell_item.unit_vendor_price, + charges = item_info.charges, + aux_quantity = item_info.charges or item_info.count, + max_stack = item_info.max_stack, + availability = { [charge_class]=item_info.count }, + } + else + local candidate = auction_candidate_map[item_info.item_signature] + candidate.availability[charge_class] = (candidate.availability[charge_class] or 0) + item_info.count + candidate.aux_quantity = candidate.aux_quantity + (item_info.charges or item_info.count) end end - end - end) - end) + return process_inventory(inventory_iterator, k) + end) + end - local auction_candidates = {} - for _, auction_candidate in pairs(auction_candidate_map) do - tinsert(auction_candidates, auction_candidate) + return process_inventory(inventory_iterator, k) end - return auction_candidates + + process_inventory(Aux.util.inventory_iterator(), function() + local auction_candidates = {} + for _, auction_candidate in pairs(auction_candidate_map) do + tinsert(auction_candidates, auction_candidate) + end + inventory_data = auction_candidates + update_inventory_listing() + end) end function refresh_entries() diff --git a/sell.xml b/sell.xml index c69c05a..0363303 100644 --- a/sell.xml +++ b/sell.xml @@ -115,7 +115,14 @@ - AuxSellStackSizeSlider:SetValue(this.charge_classes and this.charge_classes[this:GetNumber()] or this:GetNumber()) + if AuxSellStackSizeSlider.charge_classes then + local charge_slider_value = Aux.util.index_of(this:GetNumber(), AuxSellStackSizeSlider.charge_classes) + if charge_slider_value then + AuxSellStackSizeSlider:SetValue(charge_slider_value) + end + else + AuxSellStackSizeSlider:SetValue(this:GetNumber()) + end Aux.sell.quantity_update() diff --git a/stack.lua b/stack.lua index 3ece536..39420bf 100644 --- a/stack.lua +++ b/stack.lua @@ -10,30 +10,10 @@ end)() local state -local inventory, item_slots, find_empty_slot, locked, same_slot, move_item, item_name, stack_size, stop, process - -function inventory() - local inventory = {} - for bag = 0, 4 do - if GetBagName(bag) then - for bag_slot = 1, GetContainerNumSlots(bag) do - tinsert(inventory, { bag = bag, bag_slot = bag_slot }) - end - end - end - - local i = 0 - local n = getn(inventory) - return function() - i = i + 1 - if i <= n then - return inventory[i] - end - end -end +local item_slots, find_empty_slot, locked, same_slot, move_item, item_name, stack_size, stop, process function item_slots(name) - local slots = inventory() + local slots = Aux.util.inventory_iterator() return function() repeat slot = slots() @@ -43,7 +23,7 @@ function item_slots(name) end function find_empty_slot() - for slot in inventory() do + for slot in Aux.util.inventory_iterator() do if not GetContainerItemInfo(slot.bag, slot.bag_slot) then return slot end diff --git a/util.lua b/util.lua index 83badd1..efb8fca 100644 --- a/util.lua +++ b/util.lua @@ -9,6 +9,26 @@ local merge, copy_array function Aux.util.pass() end +function Aux.util.inventory_iterator() + local inventory = {} + for bag = 0, 4 do + if GetBagName(bag) then + for bag_slot = 1, GetContainerNumSlots(bag) do + tinsert(inventory, { bag = bag, bag_slot = bag_slot }) + end + end + end + + local i = 0 + local n = getn(inventory) + return function() + i = i + 1 + if i <= n then + return inventory[i] + end + end +end + function Aux.util.safe_index(chain) local target = chain[1]