1- local _ , private = ...
2-
3- local GetItemInfo = (GetItemInfo or C_Item .GetItemInfo )
1+ EventUtil .ContinueOnAddOnLoaded (' Blizzard_AuctionHouseUI' , function ()
2+ local function buyNow (itemID , quantity )
3+ C_AuctionHouse .ConfirmCommoditiesPurchase (itemID , quantity )
4+ end
45
5- private .BuyNow = function (itemID , quantity )
6- C_AuctionHouse .ConfirmCommoditiesPurchase (itemID , quantity )
7- end
6+ local originalStartCommoditiesPurchase = AuctionHouseFrame .StartCommoditiesPurchase
7+ AuctionHouseFrame .StartCommoditiesPurchase = function (self , itemID , quantity , unitPrice , totalPrice )
8+ if quantity == 1 then
9+ originalStartCommoditiesPurchase (self , itemID , quantity , unitPrice , totalPrice )
10+ return
11+ end
812
9- private .CustomStartCommoditiesPurchase = function (self , itemID , quantity , unitPrice , totalPrice )
10- if (quantity > 1 ) then
11- local _ , link , _ = GetItemInfo (itemID )
13+ local _ , link , _ = C_Item .GetItemInfo (itemID )
1214 local data = {
1315 itemID = itemID ,
1416 count = quantity ,
@@ -18,73 +20,60 @@ private.CustomStartCommoditiesPurchase = function(self, itemID, quantity, unitPr
1820 useLinkForItemInfo = true ,
1921 };
2022 StaticPopup_Show (' AUCTION_HOUSE_CONFIRM_PURCHASE_AMOUNT' , quantity , link , data )
21-
22- return
2323 end
2424
25- self .BuyDialog :SetItemID (itemID , quantity , unitPrice , totalPrice );
26- self .BuyDialog :Show ();
27- C_AuctionHouse .StartCommoditiesPurchase (itemID , quantity , unitPrice );
28- end
29-
30- if (C_AddOns .IsAddOnLoaded (' Blizzard_AuctionHouseUI' )) then
31- AuctionHouseFrame .StartCommoditiesPurchase = private .CustomStartCommoditiesPurchase
32- else
33- private .frame = CreateFrame (' Frame' )
34- private .frame :HookScript (' OnEvent' , function (self , event , addon , ...)
35- if addon == ' Blizzard_AuctionHouseUI' then
36- AuctionHouseFrame .StartCommoditiesPurchase = private .CustomStartCommoditiesPurchase
37- end
38- end )
39- private .frame :RegisterEvent (' ADDON_LOADED' )
40- end
25+ StaticPopupDialogs [' AUCTION_HOUSE_CONFIRM_PURCHASE_AMOUNT' ] = {
26+ text = ' You selected to buy %d %s, please confirm this.' ,
27+ button1 = ' Confirm' ,
28+ button2 = ' Cancel' ,
29+ --- @param popup StaticPopupTemplate
30+ OnShow = function (popup , data )
31+ --- @type StaticPopupButtonTemplate
32+ local button1 = popup .GetButton1 and popup :GetButton1 () or popup .button1
33+ --- @type StaticPopupTemplate_ItemFrame
34+ local itemFrame = popup .GetItemFrame and popup :GetItemFrame () or popup .itemFrame
35+ --- @type StaticPopupTemplate_MoneyFrame
36+ local moneyFrame = popup .MoneyFrame or popup .moneyFrame
4137
42- StaticPopupDialogs [' AUCTION_HOUSE_CONFIRM_PURCHASE_AMOUNT' ] = {
43- text = ' You selected to buy %s %s, please confirm this.' ,
44- button1 = ' Confirm' ,
45- button2 = ' Cancel' ,
46- --- @param popup StaticPopupTemplate
47- OnShow = function (popup , data )
48- local button1 = popup .GetButtons and popup :GetButtons ()[1 ] or popup .button1
49- local itemFrame = popup .GetItemFrame and popup :GetItemFrame () or popup .itemFrame
50- local moneyFrame = popup .MoneyFrame or popup .moneyFrame
51-
52- button1 :Disable ()
53- MoneyFrame_Update (moneyFrame , data .totalPrice )
54- C_AuctionHouse .StartCommoditiesPurchase (data .itemID , data .count , data .unitPrice );
55-
56- itemFrame :ClearAllPoints ();
57- itemFrame :SetPoint (' BOTTOM' , popup , ' BOTTOM' , - 60 , 80 )
58- end ,
59- OnAccept = function (popup , data )
60- private .BuyNow (data .itemID , data .count )
61- end ,
62- EditBoxOnEscapePressed = function (editBox )
63- editBox :GetParent ():Hide ()
64- end ,
65- EditBoxOnEnterPressed = function (editBox )
66- --- @type StaticPopupTemplate
67- local popup = editBox :GetParent ()
68- local button1 = popup .GetButtons and popup :GetButtons ()[1 ] or popup .button1
69- if button1 :IsEnabled () then
70- StaticPopup_OnClick (popup , 1 )
71- end
72- end ,
73- EditBoxOnTextChanged = function (editBox , data )
74- --- @type StaticPopupTemplate
75- local popup = editBox :GetParent ()
76- local button1 = popup .GetButtons and popup :GetButtons ()[1 ] or popup .button1
77- if (editBox :GetText () == data .count .. ' ' ) then
78- button1 :Enable ()
79- else
8038 button1 :Disable ()
81- end
82- end ,
83- hasItemFrame = true ,
84- hasMoneyFrame = true ,
85- hasEditBox = true ,
86- timeout = 0 ,
87- whileDead = true ,
88- hideOnEscape = true ,
89- preferredIndex = 3 ,
90- }
39+ MoneyFrame_Update (moneyFrame , data .totalPrice )
40+ C_AuctionHouse .StartCommoditiesPurchase (data .itemID , data .count , data .unitPrice );
41+
42+ itemFrame :ClearAllPoints ();
43+ itemFrame :SetPoint (' BOTTOM' , popup , ' BOTTOM' , - 60 , 80 )
44+ end ,
45+ OnAccept = function (popup , data )
46+ buyNow (data .itemID , data .count )
47+ end ,
48+ EditBoxOnEscapePressed = function (editBox )
49+ editBox :GetParent ():Hide ()
50+ end ,
51+ EditBoxOnEnterPressed = function (editBox )
52+ --- @type StaticPopupTemplate
53+ local popup = editBox :GetParent ()
54+ --- @type StaticPopupButtonTemplate
55+ local button1 = popup .GetButton1 and popup :GetButton1 () or popup .button1
56+ if button1 :IsEnabled () then
57+ StaticPopup_OnClick (popup , 1 )
58+ end
59+ end ,
60+ EditBoxOnTextChanged = function (editBox , data )
61+ --- @type StaticPopupTemplate
62+ local popup = editBox :GetParent ()
63+ --- @type StaticPopupButtonTemplate
64+ local button1 = popup .GetButton1 and popup :GetButton1 () or popup .button1
65+ if (editBox :GetText () == data .count .. ' ' ) then
66+ button1 :Enable ()
67+ else
68+ button1 :Disable ()
69+ end
70+ end ,
71+ hasItemFrame = true ,
72+ hasMoneyFrame = true ,
73+ hasEditBox = true ,
74+ timeout = 0 ,
75+ whileDead = true ,
76+ hideOnEscape = true ,
77+ preferredIndex = 3 ,
78+ }
79+ end )
0 commit comments