@@ -26,6 +26,7 @@ local QB_STATUS = {
26
26
27
27
--- @class CraftSim.CRAFTQ : Frame
28
28
CraftSim .CRAFTQ = GUTIL :CreateRegistreeForEvents ({ " TRADE_SKILL_ITEM_CRAFTED_RESULT" , " COMMODITY_PURCHASE_SUCCEEDED" ,
29
+ " COMMODITY_PURCHASE_FAILED" ,
29
30
" AUCTION_HOUSE_THROTTLED_SYSTEM_READY" ,
30
31
" NEW_RECIPE_LEARNED" , " CRAFTINGORDERS_CLAIMED_ORDER_UPDATED" , " CRAFTINGORDERS_CLAIMED_ORDER_REMOVED" })
31
32
@@ -53,7 +54,10 @@ CraftSim.CRAFTQ.quickBuyCache = {
53
54
--- @type string Auctionator SearchString
54
55
currentSearchString = nil ,
55
56
purchasePending = false , -- listen for commoditybought event / item bought event
56
- purchaseConfirmed = false ,
57
+ --- @type ItemID ?
58
+ pendingItemID = nil ,
59
+ --- @type number ?
60
+ pendingItemCount = nil ,
57
61
}
58
62
59
63
local printQB = CraftSim .DEBUG :RegisterDebugID (" Modules.CraftQueue.AuctionatorQuickBuy" )
@@ -76,20 +80,21 @@ function CraftSim.CRAFTQ:OnConfirmCommoditiesPurchase(itemID, boughtQuantity)
76
80
item = Item :CreateFromItemID (itemID ),
77
81
quantity = boughtQuantity
78
82
}
79
-
80
-
81
- -- -- continue with
82
- -- local qbCache = self.quickBuyCache
83
- -- if qbCache.status
84
- -- qbCache.status = QB_STATUS.CONFIRM_READY
85
- self .quickBuyCache .purchaseConfirmed = true
86
- -- self:AuctionatorQuickBuy() -- wil trigger confirm await
87
83
end
88
84
89
85
function CraftSim .CRAFTQ :COMMODITY_PURCHASE_SUCCEEDED ()
90
86
-- reset purchase pending in qbCache
91
87
printQB (" - " .. f .l (" COMMODITY_PURCHASE_SUCCEEDED" ))
92
- CraftSim .CRAFTQ .quickBuyCache .purchasePending = false
88
+ if self .quickBuyCache .purchasePending then
89
+ self .purchasedItem .item :ContinueOnItemLoad (function ()
90
+ CraftSim .DEBUG :SystemPrint (f .l (" CraftSim " ) ..
91
+ f .g (" Quick Buy: " ) ..
92
+ " Purchased " .. self .quickBuyCache .pendingItemCount .. " x " .. self .purchasedItem .item :GetItemLink ())
93
+ end )
94
+ end
95
+ self .quickBuyCache .purchasePending = false
96
+ self .quickBuyCache .pendingItemCount = nil
97
+ self .quickBuyCache .pendingItemID = nil
93
98
94
99
if not select (2 , C_AddOns .IsAddOnLoaded (CraftSim .CONST .SUPPORTED_PRICE_API_ADDONS [2 ])) then
95
100
return -- do not need if Auctionator not loaded
@@ -1048,10 +1053,6 @@ function CraftSim.CRAFTQ:AuctionatorQuickBuy()
1048
1053
1049
1054
local listsContainer = AuctionatorShoppingFrame .ListsContainer
1050
1055
local resultsList = AuctionatorShoppingFrame .ResultsListing
1051
- local buyButton = AuctionatorBuyCommodityFrame .DetailsContainer .BuyButton
1052
-
1053
- local commodityFrame = AuctionatorBuyCommodityFrame
1054
- local confirmationDialog = commodityFrame .FinalConfirmationDialog
1055
1056
1056
1057
--- @param value CraftSim.CRAFTQ.QB_STATUS
1057
1058
--- @return boolean
@@ -1117,21 +1118,13 @@ function CraftSim.CRAFTQ:AuctionatorQuickBuy()
1117
1118
end
1118
1119
1119
1120
-- get item that was not bought yet
1120
- local firstShoppingListSearchString = GUTIL :Find (list .data .items , function (searchString )
1121
+ local buyShoppingListSearchString = GUTIL :Find (list .data .items , function (searchString )
1121
1122
return not qbCache .boughtSearchStrings [searchString ]
1122
1123
end )
1123
1124
1124
1125
print (" - STATUS: " .. tostring (qbCache .status ))
1125
- -- print("- firstShoppingListSearchString: " .. tostring(firstShoppingListSearchString))
1126
-
1127
-
1128
- -- if qbCache.purchasePending then
1129
- -- print(f.r("- Purchase Pending"))
1130
- -- return
1131
- -- end
1132
1126
1133
-
1134
- if not firstShoppingListSearchString then
1127
+ if not buyShoppingListSearchString then
1135
1128
print (" - All bought" )
1136
1129
self :ResetQuickBuyCache ()
1137
1130
return
@@ -1162,61 +1155,52 @@ function CraftSim.CRAFTQ:AuctionatorQuickBuy()
1162
1155
end
1163
1156
end
1164
1157
1165
- if firstShoppingListSearchString and status (QB_STATUS .RESULT_LIST_READY ) then
1166
- local resultRow = qbCache .resultRows [firstShoppingListSearchString ]
1158
+ if buyShoppingListSearchString and status (QB_STATUS .RESULT_LIST_READY ) then
1159
+ local resultRow = qbCache .resultRows [buyShoppingListSearchString ]
1167
1160
1168
1161
if not resultRow then
1169
- print (" Result Row not found in result list: " .. tostring (firstShoppingListSearchString ))
1162
+ print (" Result Row not found in result list: " .. tostring (buyShoppingListSearchString ))
1170
1163
return
1171
1164
end
1172
1165
1173
- resultRow :OnClick ()
1174
- qbCache .currentSearchString = firstShoppingListSearchString
1175
- set (QB_STATUS .BUY_READY )
1176
- return
1177
- end
1178
-
1179
- if status (QB_STATUS .BUY_READY ) then
1180
- if buyButton :IsVisible () and buyButton :IsEnabled () then
1181
- buyButton :Click ()
1182
- set (QB_STATUS .CONFIRM_START )
1183
- return
1184
- else
1185
- return
1186
- end
1187
- end
1166
+ qbCache .pendingItemID = resultRow .rowData .itemKey .itemID
1167
+ qbCache .pendingItemCount = resultRow .rowData .purchaseQuantity
1188
1168
1189
- if status (QB_STATUS .CONFIRM_START ) and confirmationDialog :IsVisible () and not confirmationDialog .purchasePending then
1190
- print (" - " .. f .g (" Confirm Purchase" ))
1169
+ qbCache .currentSearchString = buyShoppingListSearchString
1191
1170
qbCache .purchasePending = true
1192
- qbCache .purchaseConfirmed = false
1193
-
1194
- confirmationDialog :ConfirmPurchase () -- will trigger event
1195
- set (QB_STATUS .CONFIRM_AWAIT )
1196
- end
1197
-
1198
- if status (QB_STATUS .CONFIRM_AWAIT ) and qbCache .purchaseConfirmed then
1199
- qbCache .boughtSearchStrings [qbCache .currentSearchString ] = true
1200
1171
set (QB_STATUS .PURCHASE_AWAIT )
1172
+
1173
+ -- Triggers AUCTION_HOUSE_THROTTLED_SYSTEM_READY and needs confirmation there
1174
+ C_AuctionHouse .StartCommoditiesPurchase (qbCache .pendingItemID , qbCache .pendingItemCount )
1201
1175
return
1202
1176
end
1203
1177
1204
1178
if status (QB_STATUS .PURCHASE_AWAIT ) and not qbCache .purchasePending then
1179
+ qbCache .boughtSearchStrings [qbCache .currentSearchString ] = true
1205
1180
set (QB_STATUS .RESULT_LIST_READY )
1206
- self :AuctionatorQuickBuy () -- to instantly click next item
1181
+ self :AuctionatorQuickBuy ()
1207
1182
end
1208
1183
end
1209
1184
1210
1185
function CraftSim .CRAFTQ :AUCTION_HOUSE_THROTTLED_SYSTEM_READY ()
1186
+ local qbCache = self .quickBuyCache
1187
+ if qbCache .pendingItemCount and qbCache .pendingItemID then
1188
+ C_AuctionHouse .ConfirmCommoditiesPurchase (qbCache .pendingItemID , qbCache .pendingItemCount )
1189
+ -- triggers COMMODITY_PURCHASE_SUCCEEDED
1190
+ -- TODO: Consider COMMODITY_PURCHASE_FAILED
1191
+ end
1192
+ end
1211
1193
1194
+ function CraftSim .CRAFTQ :COMMODITY_PURCHASE_FAILED ()
1195
+ -- reset quick buy
1196
+ self :ResetQuickBuyCache ()
1212
1197
end
1213
1198
1214
1199
function CraftSim .CRAFTQ :ResetQuickBuyCache ()
1215
1200
local qbCache = self .quickBuyCache
1216
1201
qbCache .status = QB_STATUS .INIT
1217
1202
qbCache .currentSearchString = nil
1218
1203
qbCache .purchasePending = false
1219
- qbCache .purchaseConfirmed = false
1220
1204
wipe (qbCache .boughtSearchStrings )
1221
1205
wipe (qbCache .resultRows )
1222
1206
end
0 commit comments