vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | IMA_Settings = {}; |
2 | |||
3 | local IMA_NUMITEMBUTTONS = 18; |
||
4 | local IMA_Playername = nil; |
||
5 | local IMA_AuctionFrameTab_OnClickOrig = nil; |
||
6 | local IMA_PickupContainerItemOrig = nil; |
||
7 | local IMA_ContainerFrame_UpdateOrig = nil; |
||
8 | |||
9 | function IMA_PickupContainerItem(bag, item) |
||
10 | -- pass through if auction window not open or item already in |
||
11 | if ( not AuctionFrame:IsVisible() ) then |
||
12 | IMA_PickupContainerItemOrig(bag, item); |
||
13 | return; |
||
14 | end |
||
15 | |||
16 | if ( IMA_GetItemFrame(bag, item) ) then |
||
17 | return; |
||
18 | end |
||
19 | |||
20 | if ( not CursorHasItem() ) then |
||
21 | IMA_ClearAuctionSellItem(); |
||
22 | IMA_AuctionFrameMassAuction.bag = bag; |
||
23 | IMA_AuctionFrameMassAuction.item = item; |
||
24 | end |
||
25 | if ( IsAltKeyDown() and IMA_AuctionFrameMassAuction:IsVisible() and not CursorHasItem() ) then |
||
26 | IMA_ClearAuctionSellItem(); |
||
27 | local i; |
||
28 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
29 | if ( not getglobal("IMA_Item"..i.."ItemButton").item ) then |
||
30 | IMA_PickupContainerItemOrig(bag, item); |
||
31 | IMA_ItemButton_OnClick(getglobal("IMA_Item"..i.."ItemButton")); |
||
32 | IMA_UpdateItemButtons(); |
||
33 | return; |
||
34 | end |
||
35 | end |
||
36 | elseif ( IsAltKeyDown() and not CursorHasItem() ) then |
||
37 | IMA_ClearAuctionSellItem(); |
||
38 | IMA_PickupContainerItemOrig(bag, item); |
||
39 | ClickAuctionSellItemButton(); |
||
40 | return; |
||
41 | end |
||
42 | IMA_PickupContainerItemOrig(bag, item); |
||
43 | IMA_UpdateItemButtons(); |
||
44 | end |
||
45 | |||
46 | -- Controls the 4th tab in AuctionFrame |
||
47 | function IMA_AuctionFrameTab_OnClick(index) |
||
48 | -- no Sea req |
||
49 | if ( IMA_AuctionFrameTab_OnClickOrig ~= nil ) then |
||
50 | IMA_AuctionFrameTab_OnClickOrig(index); |
||
51 | end |
||
52 | |||
53 | if ( not index ) then |
||
54 | index = this:GetID(); |
||
55 | end |
||
56 | |||
57 | if ( index == 4 ) then |
||
58 | -- MassAuction tab |
||
59 | AuctionFrameTopLeft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopLeft"); |
||
60 | AuctionFrameTop:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Top"); |
||
61 | AuctionFrameTopRight:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-TopRight"); |
||
62 | AuctionFrameBotLeft:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotLeft"); |
||
63 | AuctionFrameBot:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-Bot"); |
||
64 | AuctionFrameBotRight:SetTexture("Interface\\AuctionFrame\\UI-AuctionFrame-Bid-BotRight"); |
||
65 | |||
66 | -- this is to fix a bug where the AuctionsFrame can't handle having auctions added without it showing first |
||
67 | if (AuctionFrameAuctions.page == nil) then |
||
68 | AuctionFrameAuctions.page = 0; |
||
69 | end |
||
70 | |||
71 | IMA_AuctionFrameMassAuction:Show(); |
||
72 | else |
||
73 | IMA_AuctionFrameMassAuction:Hide(); |
||
74 | end |
||
75 | end |
||
76 | |||
77 | function IMA_ContainerFrame_Update(frame) |
||
78 | if ( IMA_ContainerFrame_UpdateOrig ~= nil ) then |
||
79 | IMA_ContainerFrame_UpdateOrig(frame) |
||
80 | end |
||
81 | |||
82 | if ( not IMA_AuctionFrameMassAuction:IsVisible() ) then |
||
83 | return; |
||
84 | end |
||
85 | |||
86 | local id = frame:GetID(); |
||
87 | local i; |
||
88 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
89 | local btn = getglobal("IMA_Item"..i.."ItemButton"); |
||
90 | if ( btn.item and btn.bag ) then |
||
91 | if ( btn.bag == frame:GetID() ) then |
||
92 | SetItemButtonDesaturated(getglobal(frame:GetName() .. "Item" .. (frame.size-btn.item)+1), 1, 0.5, 0.5, 0.5); |
||
93 | end |
||
94 | end |
||
95 | end |
||
96 | end |
||
97 | |||
98 | function IMA_AuctionFrameMassAuction_OnLoad() |
||
99 | -- Igors Mass Auction makes some hooks |
||
100 | -- AuctionFrameTab_OnClick - lets us access our 4th tab |
||
101 | -- PickupContainerItem - grabs something from a bag with the mouse |
||
102 | IMA_PickupContainerItemOrig = PickupContainerItem |
||
103 | if ( Sea ~= nil and Sea.util ~= nil and Sea.util.hook ~= nil ) then |
||
104 | Sea.util.hook("AuctionFrameTab_OnClick","IMA_AuctionFrameTab_OnClick","after"); |
||
105 | Sea.util.hook("PickupContainerItem","IMA_PickupContainerItem","replace"); |
||
106 | Sea.util.hook("ContainerFrame_Update","IMA_ContainerFrame_Update","after"); |
||
107 | else |
||
108 | -- no Sea req code |
||
109 | IMA_AuctionFrameTab_OnClickOrig = AuctionFrameTab_OnClick; |
||
110 | AuctionFrameTab_OnClick = IMA_AuctionFrameTab_OnClick; |
||
111 | PickupContainerItem = IMA_PickupContainerItem; |
||
112 | IMA_ContainerFrame_UpdateOrig = ContainerFrame_Update; |
||
113 | ContainerFrame_Update = IMA_ContainerFrame_Update; |
||
114 | end |
||
115 | |||
116 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
117 | IMA_AuctionsRadioButton_OnClick(i,3); |
||
118 | end |
||
119 | |||
120 | this:RegisterEvent("UNIT_NAME_UPDATE"); |
||
121 | this:RegisterEvent("AUCTION_HOUSE_CLOSED"); |
||
122 | end |
||
123 | |||
124 | function IMA_AuctionFrameMassAuction_OnShow() |
||
125 | IMA_UpdateItemButtons(); |
||
126 | |||
127 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
128 | IMA_AuctionsRadioButton_OnClick(i,IMA_Settings["duration"..i]) |
||
129 | end |
||
130 | end |
||
131 | |||
132 | function IMA_SetItemAsAuction(itemindex) |
||
133 | IMA_ClearAuctionSellItem(); |
||
134 | |||
135 | -- first see if something is in that slot |
||
136 | but = getglobal("IMA_Item"..itemindex.."ItemButton"); |
||
137 | if ( but.bag == nil or but.item == nil) then return end |
||
138 | |||
139 | -- if we have something on cursor already, remember it |
||
140 | oldbag = IMA_AuctionFrameMassAuction.bag; |
||
141 | olditem = IMA_AuctionFrameMassAuction.item; |
||
142 | |||
143 | -- if we are already holding what we want |
||
144 | if (but.bag == oldbag and but.item == olditem) then |
||
145 | ClickAuctionSellItemButton(); |
||
146 | return; |
||
147 | end |
||
148 | |||
149 | -- put down what we had |
||
150 | if ( oldbag ~= nil and olditem ~= nil) then |
||
151 | IMA_PickupContainerItemOrig(oldbag,olditem); |
||
152 | end |
||
153 | |||
154 | -- pick up the new thing and put it in |
||
155 | IMA_PickupContainerItemOrig(but.bag,but.item); |
||
156 | ClickAuctionSellItemButton(); |
||
157 | IMA_PickupContainerItemOrig(but.bag,but.item); |
||
158 | |||
159 | -- pick up what we had |
||
160 | if ( oldbag ~= nil and olditem ~= nil) then |
||
161 | IMA_PickupContainerItemOrig(oldbag,olditem); |
||
162 | end |
||
163 | end |
||
164 | |||
165 | function IMA_FindAuctionItem() |
||
166 | for bag = 0,4,1 do |
||
167 | slots = GetContainerNumSlots(bag) |
||
168 | if (slots ~= nil and slots > 0) then |
||
169 | for item = 1, slots, 1 do |
||
170 | local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bag,item); |
||
171 | local lockedstr = locked; |
||
172 | if ( locked == nil ) then |
||
173 | lockedstr = "nil"; |
||
174 | end |
||
175 | if ( itemCount ~= nil and itemCount > 0 and locked ~= nil ) then |
||
176 | return bag,item; |
||
177 | end |
||
178 | end |
||
179 | end |
||
180 | end |
||
181 | return nil; |
||
182 | end |
||
183 | |||
184 | -- this function assumes that itemindex is the current active auction item |
||
185 | function IMA_SetInitialPrices(btn) |
||
186 | local scheme = UIDropDownMenu_GetSelectedValue(IMA_PriceSchemeDropDown); |
||
187 | scheme = string.gsub(scheme," ","_"); |
||
188 | |||
189 | local name, texture, count, quality, canUse, price = GetAuctionSellItemInfo(); |
||
190 | local start = max(100, floor(price * 1.5)); |
||
191 | local buyout = 0; |
||
192 | |||
193 | pricefunc = getglobal("IMA_"..scheme.."_GetPriceAndBuyout"); |
||
194 | if (pricefunc ~= nil) then |
||
195 | local start2 = nil; |
||
196 | local buyout2 = nil; |
||
197 | start2, buyout2 = pricefunc(btn.bag,btn.item,btn.count,btn.texture,btn.name,btn.price,start) |
||
198 | if (start2 ~= nil) then |
||
199 | start = start2; |
||
200 | end |
||
201 | if (buyout2 ~= nil) then |
||
202 | buyout = buyout2; |
||
203 | end |
||
204 | end |
||
205 | |||
206 | MoneyInputFrame_SetCopper(getglobal(btn:GetParent():GetName().."StartPrice"), start); |
||
207 | MoneyInputFrame_SetCopper(getglobal(btn:GetParent():GetName().."BuyoutPrice"), buyout); |
||
208 | end |
||
209 | |||
210 | -- TODO: Make this work |
||
211 | function IMA_AuctionsFrameAuctions_ValidateAuction(itemindex) |
||
212 | --IMA_AuctionsCreateAuctionButton:Disable(); |
||
213 | --IMA_AuctionsBuyoutErrorText:Hide(); |
||
214 | -- No item |
||
215 | if ( not GetAuctionSellItemInfo() ) then |
||
216 | return; |
||
217 | end |
||
218 | -- Buyout price is less than the start price |
||
219 | --if ( MoneyInputFrame_GetCopper(IMA_BuyoutPrice) > 0 and MoneyInputFrame_GetCopper(IMA_StartPrice) > MoneyInputFrame_GetCopper(IMA_BuyoutPrice) ) then |
||
220 | --IMA_AuctionsBuyoutErrorText:Show(); |
||
221 | --return; |
||
222 | --end |
||
223 | -- Start price is 0 |
||
224 | --if ( MoneyInputFrame_GetCopper(IMA_StartPrice) < 1 ) then |
||
225 | --return; |
||
226 | --end |
||
227 | --IMA_AuctionsCreateAuctionButton:Enable(); |
||
228 | end |
||
229 | |||
230 | function IMA_AuctionsRadioButton_OnClick(itemindex,index) |
||
231 | if index == nil then |
||
232 | index = 3; |
||
233 | end |
||
234 | |||
235 | getglobal("IMA_Item"..itemindex.."ShortAuction"):SetChecked(nil) |
||
236 | getglobal("IMA_Item"..itemindex.."MediumAuction"):SetChecked(nil) |
||
237 | getglobal("IMA_Item"..itemindex.."LongAuction"):SetChecked(nil) |
||
238 | if ( index == 1 ) then |
||
239 | getglobal("IMA_Item"..itemindex.."ShortAuction"):SetChecked(1) |
||
240 | getglobal("IMA_Item"..itemindex).duration = 120; |
||
241 | elseif ( index ==2 ) then |
||
242 | getglobal("IMA_Item"..itemindex.."MediumAuction"):SetChecked(1) |
||
243 | getglobal("IMA_Item"..itemindex).duration = 480; |
||
244 | else |
||
245 | getglobal("IMA_Item"..itemindex.."LongAuction"):SetChecked(1) |
||
246 | getglobal("IMA_Item"..itemindex).duration = 1440; |
||
247 | end |
||
248 | |||
249 | IMA_Settings["duration"..itemindex] = index; |
||
250 | |||
251 | -- maybe sure this is the current item before we update |
||
252 | IMA_SetItemAsAuction(itemindex); |
||
253 | IMA_UpdateDeposit(itemindex); |
||
254 | end |
||
255 | |||
256 | function IMA_UpdateDeposit(itemindex, amount) |
||
257 | if ( amount == nil ) then |
||
258 | amount = CalculateAuctionDeposit(getglobal("IMA_Item"..itemindex).duration); |
||
259 | end |
||
260 | if ( amount == nil ) then |
||
261 | amount = 0; |
||
262 | end |
||
263 | |||
264 | MoneyFrame_Update("IMA_Item"..itemindex.."DepositCharge",amount) |
||
265 | end |
||
266 | |||
267 | -- this function assumes you don't have something on the cursor already |
||
268 | function IMA_ClearAuctionSellItem() |
||
269 | if ( GetAuctionSellItemInfo() ~= nil ) then |
||
270 | ClickAuctionSellItemButton(); |
||
271 | local bag, item = IMA_FindAuctionItem(); |
||
272 | IMA_PickupContainerItemOrig(bag, item); |
||
273 | end |
||
274 | end |
||
275 | |||
276 | -- Handles the draggin of items |
||
277 | function IMA_ItemButton_OnClick(button) |
||
278 | if ( not button ) then |
||
279 | button = this; |
||
280 | end |
||
281 | |||
282 | if ( CursorHasItem() ) then |
||
283 | local bag = IMA_AuctionFrameMassAuction.bag; |
||
284 | local item = IMA_AuctionFrameMassAuction.item; |
||
285 | |||
286 | if ( not bag or not item ) then return; end |
||
287 | |||
288 | -- put it in auction slot while we're holding it |
||
289 | ClickAuctionSellItemButton(); |
||
290 | |||
291 | -- We'll still be holding the item if it fails |
||
292 | if (CursorHasItem()) then |
||
293 | IMA_PickupContainerItemOrig(bag, item); |
||
294 | return; |
||
295 | end |
||
296 | |||
297 | -- put the item back |
||
298 | IMA_PickupContainerItemOrig(bag, item); |
||
299 | |||
300 | if ( this.bag and this.item ) then |
||
301 | -- There's already an item there |
||
302 | IMA_PickupContainerItemOrig(button.bag, button.item); |
||
303 | IMA_AuctionFrameMassAuction.bag = button.bag; |
||
304 | IMA_AuctionFrameMassAuction.item = button.item; |
||
305 | else |
||
306 | IMA_AuctionFrameMassAuction.bag = nil; |
||
307 | IMA_AuctionFrameMassAuction.item = nil; |
||
308 | end |
||
309 | |||
310 | local texture, count = GetContainerItemInfo(bag, item); |
||
311 | |||
312 | getglobal(button:GetName() .. "IconTexture"):Show(); |
||
313 | getglobal(button:GetName() .. "IconTexture"):SetTexture(texture); |
||
314 | |||
315 | if ( count > 1 ) then |
||
316 | getglobal(button:GetName() .. "Count"):SetText(count); |
||
317 | getglobal(button:GetName() .. "Count"):Show(); |
||
318 | else |
||
319 | getglobal(button:GetName() .. "Count"):Hide(); |
||
320 | end |
||
321 | |||
322 | local name, texture, count, quality, canUse, price = GetAuctionSellItemInfo(); |
||
323 | button.bag = bag; |
||
324 | button.item = item; |
||
325 | button.texture = texture; |
||
326 | button.count = count; |
||
327 | button.name = name; |
||
328 | button.price = price; |
||
329 | |||
330 | -- set our item count based on the first item |
||
331 | if (button:GetParent():GetID() == 1) then |
||
332 | IMA_AllSamePriceFrameStackSize:SetText(count); |
||
333 | end |
||
334 | |||
335 | IMA_UpdateDeposit(button:GetParent():GetID()); |
||
336 | IMA_SetInitialPrices(button); |
||
337 | |||
338 | elseif ( button.item and button.bag ) then |
||
339 | IMA_ClearAuctionSellItem(); |
||
340 | |||
341 | IMA_PickupContainerItemOrig(button.bag, button.item); |
||
342 | |||
343 | getglobal(button:GetName() .. "IconTexture"):Hide(); |
||
344 | getglobal(button:GetName() .. "Count"):Hide(); |
||
345 | |||
346 | IMA_AuctionFrameMassAuction.bag = button.bag; |
||
347 | IMA_AuctionFrameMassAuction.item = button.item; |
||
348 | |||
349 | button.item = nil; |
||
350 | button.bag = nil; |
||
351 | button.count = nil; |
||
352 | button.texture = nil; |
||
353 | button.name = nil; |
||
354 | button.price = nil; |
||
355 | end |
||
356 | IMA_UpdateItemButtons(); |
||
357 | |||
358 | -- TODO: Display the total deposit |
||
359 | |||
360 | for i = 1, NUM_CONTAINER_FRAMES, 1 do |
||
361 | if ( getglobal("ContainerFrame" .. i):IsVisible() ) then |
||
362 | ContainerFrame_Update(getglobal("ContainerFrame" .. i)); |
||
363 | end |
||
364 | end |
||
365 | end |
||
366 | |||
367 | function IMA_UpdateItemButtons(frame) |
||
368 | local i; |
||
369 | local num = 0; |
||
370 | local totalDeposit = 0; |
||
371 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
372 | local btn = getglobal("IMA_Item"..i.."ItemButton"); |
||
373 | if ( not frame or btn ~= frame ) then |
||
374 | local texture, count; |
||
375 | if ( btn.item and btn.bag ) then |
||
376 | texture, count = GetContainerItemInfo(btn.bag, btn.item); |
||
377 | end |
||
378 | if ( not texture ) then |
||
379 | getglobal(btn:GetName() .. "IconTexture"):Hide(); |
||
380 | getglobal(btn:GetName() .. "Count"):Hide(); |
||
381 | btn.item = nil; |
||
382 | btn.bag = nil; |
||
383 | btn.count = nil; |
||
384 | btn.texture = nil; |
||
385 | btn.name = nil; |
||
386 | btn.price = nil; |
||
387 | IMA_UpdateDeposit(btn:GetParent():GetID(),0); |
||
388 | MoneyInputFrame_SetCopper(getglobal(btn:GetParent():GetName().."StartPrice"), 0); |
||
389 | MoneyInputFrame_SetCopper(getglobal(btn:GetParent():GetName().."BuyoutPrice"), 0); |
||
390 | else |
||
391 | num = num + 1 |
||
392 | local deposit = getglobal(btn:GetParent():GetName().."DepositCharge").staticMoney; |
||
393 | if ( deposit ~= nil ) then |
||
394 | totalDeposit = totalDeposit + deposit; |
||
395 | end |
||
396 | btn.count = count; |
||
397 | btn.texture = texture; |
||
398 | getglobal(btn:GetName() .. "IconTexture"):Show(); |
||
399 | getglobal(btn:GetName() .. "IconTexture"):SetTexture(texture); |
||
400 | if ( count > 1 ) then |
||
401 | getglobal(btn:GetName() .. "Count"):Show(); |
||
402 | getglobal(btn:GetName() .. "Count"):SetText(count); |
||
403 | else |
||
404 | getglobal(btn:GetName() .. "Count"):Hide(); |
||
405 | end |
||
406 | end |
||
407 | end |
||
408 | end |
||
409 | IMA_AuctionFrameMassAuction.num = num; |
||
410 | IMA_AuctionFrameMassAuction.totalDeposit = totalDeposit; |
||
411 | if ( num > 0 ) then |
||
412 | IMA_AuctionsClearButton:Enable(); |
||
413 | IMA_AuctionsSubmitButton:Enable(); |
||
414 | else |
||
415 | IMA_AuctionsClearButton:Disable(); |
||
416 | IMA_AuctionsSubmitButton:Disable(); |
||
417 | end |
||
418 | end |
||
419 | |||
420 | function IMA_GetItemFrame(bag, item) |
||
421 | local i; |
||
422 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
423 | local btn = getglobal("IMA_Item"..i.."ItemButton"); |
||
424 | if ( btn.item == item and btn.bag == bag ) then |
||
425 | return btn; |
||
426 | end |
||
427 | end |
||
428 | return nil; |
||
429 | end |
||
430 | |||
431 | function IMA_ClearItems() |
||
432 | local i; |
||
433 | local num = 0; |
||
434 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
435 | local item = getglobal("IMA_Item"..i); |
||
436 | local btn = getglobal(item:GetName().."ItemButton"); |
||
437 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."StartPrice"), 0); |
||
438 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."BuyoutPrice"), 0); |
||
439 | IMA_UpdateDeposit(i,0); |
||
440 | btn.item = nil; |
||
441 | btn.count = nil; |
||
442 | btn.bag = nil; |
||
443 | btn.texture = nil; |
||
444 | btn.name = nil; |
||
445 | btn.price = nil; |
||
446 | end |
||
447 | IMA_UpdateItemButtons(); |
||
448 | IMA_ClearAuctionSellItem(); |
||
449 | end |
||
450 | |||
451 | function IMA_ClearItem(bag,item) |
||
452 | local i; |
||
453 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
454 | local item = getglobal("IMA_Item"..i); |
||
455 | local btn = getglobal(item:GetName().."ItemButton"); |
||
456 | if (btn.bag == bag and btn.item == item) then |
||
457 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."StartPrice"), 0); |
||
458 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."BuyoutPrice"), 0); |
||
459 | IMA_UpdateDeposit(i,0); |
||
460 | btn.item = nil; |
||
461 | btn.count = nil; |
||
462 | btn.bag = nil; |
||
463 | btn.texture = nil; |
||
464 | btn.name = nil; |
||
465 | btn.price = nil; |
||
466 | return; |
||
467 | end |
||
468 | end |
||
469 | IMA_UpdateItemButtons(); |
||
470 | end |
||
471 | |||
472 | function IMA_OnEvent() |
||
473 | if (( event == "UNIT_NAME_UPDATE" ) and (arg1 == "player")) then |
||
474 | local playername = UnitName("player"); |
||
475 | IMA_Playername = playername; |
||
476 | elseif ( event == "AUCTION_HOUSE_CLOSED" ) then |
||
477 | IMA_ClearItems(); |
||
478 | IMA_GlobalFrame.total = 0; |
||
479 | IMA_GlobalFrame.queue = { }; |
||
480 | end |
||
481 | end |
||
482 | |||
483 | function IMA_AcceptSendFrame_OnShow() |
||
484 | getglobal(this:GetName().."Info"):Show(); |
||
485 | getglobal(this:GetName().."InfoString"):Show(); |
||
486 | getglobal(this:GetName().."MoneyFrame"):Show(); |
||
487 | getglobal(this:GetName().."InfoItems"):SetText(IMA_AuctionFrameMassAuction.num .. " " .. IMA_ITEMS); |
||
488 | getglobal(this:GetName().."SubmitButton"):Enable(); |
||
489 | IMA_UpdateItemButtons(); |
||
490 | MoneyFrame_Update(this:GetName() .. "MoneyFrame", IMA_AuctionFrameMassAuction.totalDeposit); |
||
491 | end |
||
492 | |||
493 | function IMA_AcceptSendFrameSubmitButton_OnClick() |
||
494 | IMA_GlobalFrame.queue = IMA_FillItemTable(); |
||
495 | IMA_GlobalFrame.total = getn(IMA_GlobalFrame.queue); |
||
496 | IMA_GlobalFrame.sent = 0; |
||
497 | getglobal(this:GetParent():GetName().."Info"):Hide(); |
||
498 | getglobal(this:GetParent():GetName().."InfoString"):Hide(); |
||
499 | getglobal(this:GetParent():GetName().."MoneyFrame"):Hide(); |
||
500 | this:Disable(); |
||
501 | end |
||
502 | |||
503 | function IMA_AcceptSendFrameCancelButton_OnClick() |
||
504 | this:GetParent():Hide(); |
||
505 | IMA_GlobalFrame.queue = {}; |
||
506 | IMA_GlobalFrame.total = 0; |
||
507 | IMA_GlobalFrame.sent = 0; |
||
508 | end |
||
509 | |||
510 | function IMA_FillItemTable() |
||
511 | local arr = { }; |
||
512 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
513 | local item = getglobal("IMA_Item"..i); |
||
514 | local btn = getglobal(item:GetName().."ItemButton"); |
||
515 | local price = MoneyInputFrame_GetCopper(getglobal(item:GetName().."StartPrice")); |
||
516 | local buyout = MoneyInputFrame_GetCopper(getglobal(item:GetName().."BuyoutPrice")); |
||
517 | if ( btn.item and btn.bag ) then |
||
518 | tinsert(arr, { ["item"] = btn.item, ["bag"] = btn.bag, ["price"] = price, |
||
519 | ["buyout"] = buyout, ["duration"] = item.duration }); |
||
520 | end |
||
521 | end |
||
522 | return arr; |
||
523 | end |
||
524 | |||
525 | function IMA_ProcessQueue(elapsed) |
||
526 | if ( this.bag ~= nil and this.item ~= nil ) then |
||
527 | if ( GetContainerItemInfo(this.bag, this.item) == nil ) then |
||
528 | this.sent = this.sent + 1; |
||
529 | IMA_ClearItem(this.bag,this.item); |
||
530 | this.bag = nil; |
||
531 | this.item = nil; |
||
532 | if (this.sent == this.total) then |
||
533 | IMA_AcceptSendFrame:Hide(); |
||
534 | end |
||
535 | end |
||
536 | end |
||
537 | |||
538 | if ( this.total == 0 ) then |
||
539 | return; |
||
540 | end |
||
541 | |||
542 | if ( this.bag == nil and this.item == nil ) then |
||
543 | IMA_StartAuction(); |
||
544 | IMA_AcceptSendFrameInfoItems:SetText( |
||
545 | IMA_POSTING_ITEM..(this.sent+1)..IMA_OF..this.total.."...") |
||
546 | end |
||
547 | end |
||
548 | |||
549 | function IMA_StartAuction() |
||
550 | IMA_ClearAuctionSellItem(); |
||
551 | |||
552 | key, val = next(this.queue); |
||
553 | if (key == nil) then |
||
554 | this.total = 0; |
||
555 | this.bag = nil; |
||
556 | this.item = nil; |
||
557 | this.queue = { }; |
||
558 | return; |
||
559 | end |
||
560 | |||
561 | this.bag = val.bag; |
||
562 | this.item = val.item; |
||
563 | |||
564 | -- put down what we picked up so things don't mess up |
||
565 | if ( CursorHasItem() and IMA_AuctionFrameMassAuction.bag and IMA_AuctionFrameMassAuction.item ) then |
||
566 | PickupContainerItem(IMA_AuctionFrameMassAuction.bag, IMA_AuctionFrameMassAuction.item); |
||
567 | IMA_AuctionFrameMassAuction.bag = nil; |
||
568 | IMA_AuctionFrameMassAuction.item = nil; |
||
569 | end |
||
570 | |||
571 | IMA_PickupContainerItemOrig(val.bag, val.item); |
||
572 | |||
573 | ClickAuctionSellItemButton(); |
||
574 | |||
575 | local name, texture, count, quality, canUse, price = GetAuctionSellItemInfo(); |
||
576 | |||
577 | if ( not name ) then |
||
578 | DEFAULT_CHAT_FRAME:AddMessage("<MassAuction> " .. IMA_ERROR, 1, 0, 0); |
||
579 | else |
||
580 | -- these 3 lines help with compatability |
||
581 | MoneyInputFrame_SetCopper(StartPrice, val.price); |
||
582 | MoneyInputFrame_SetCopper(BuyoutPrice, val.buyout); |
||
583 | AuctionFrameAuctions.duration = val.duration; |
||
584 | |||
585 | StartAuction(val.price, val.buyout, val.duration); |
||
586 | end |
||
587 | |||
588 | this.queue[key] = nil; |
||
589 | return; |
||
590 | end |
||
591 | |||
592 | -- SET PRICES DROPDOWN CODE |
||
593 | |||
594 | function IMA_PriceSchemeDropDown_OnShow() |
||
595 | IMA_PriceSchemeDropDown_OnLoad(); |
||
596 | |||
597 | -- set default if none |
||
598 | if IMA_Settings.DropDown == nil then |
||
599 | IMA_Settings.DropDown = "Default"; |
||
600 | end |
||
601 | |||
602 | getglobal("IMA_" .. IMA_Settings.DropDown .. "_function")(); |
||
603 | end |
||
604 | |||
605 | function IMA_PriceSchemeDropDown_OnLoad() |
||
606 | UIDropDownMenu_Initialize(this, IMA_PriceSchemeDropDown_Initialize); |
||
607 | end |
||
608 | |||
609 | function IMA_ClearTopFrame() |
||
610 | if IMA_MultiplierFrame then |
||
611 | IMA_MultiplierFrame:Hide(); |
||
612 | IMA_AllSamePriceFrame:Hide(); |
||
613 | IMA_EasyAuctionFrame:Hide(); |
||
614 | end |
||
615 | end |
||
616 | |||
617 | function IMA_Default_function() |
||
618 | UIDropDownMenu_SetSelectedValue(IMA_PriceSchemeDropDown, "Default"); |
||
619 | IMA_ClearTopFrame(); |
||
620 | IMA_Settings.DropDown = "Default"; |
||
621 | end |
||
622 | |||
623 | function IMA_Multiplier_function() |
||
624 | UIDropDownMenu_SetSelectedValue(IMA_PriceSchemeDropDown, "Multiplier"); |
||
625 | IMA_ClearTopFrame(); |
||
626 | IMA_MultiplierFrame:Show(); |
||
627 | IMA_Settings.DropDown = "Multiplier"; |
||
628 | end |
||
629 | |||
630 | function IMA_AllSamePrice_function() |
||
631 | UIDropDownMenu_SetSelectedValue(IMA_PriceSchemeDropDown, "AllSamePrice"); |
||
632 | IMA_ClearTopFrame(); |
||
633 | IMA_AllSamePriceFrame:Show(); |
||
634 | IMA_Settings.DropDown = "AllSamePrice"; |
||
635 | end |
||
636 | |||
637 | function IMA_EasyAuction_function() |
||
638 | UIDropDownMenu_SetSelectedValue(IMA_PriceSchemeDropDown, "EasyAuction"); |
||
639 | IMA_ClearTopFrame(); |
||
640 | IMA_EasyAuctionFrame:Show(); |
||
641 | IMA_Settings.DropDown = "EasyAuction"; |
||
642 | end |
||
643 | |||
644 | function IMA_PriceSchemeDropDown_Initialize() |
||
645 | local info = {}; |
||
646 | info.text = IMA_DEFAULT; |
||
647 | info.value = "Default"; |
||
648 | info.func = IMA_Default_function; |
||
649 | UIDropDownMenu_AddButton(info); |
||
650 | |||
651 | info = {}; |
||
652 | info.text = IMA_VALUE_MULTIPLIER; |
||
653 | info.value = "Multiplier"; |
||
654 | info.func = IMA_Multiplier_function; |
||
655 | UIDropDownMenu_AddButton(info); |
||
656 | |||
657 | info = {}; |
||
658 | info.text = IMA_ALL_SAME_PRICE; |
||
659 | info.value = "AllSamePrice"; |
||
660 | info.func = IMA_AllSamePrice_function; |
||
661 | UIDropDownMenu_AddButton(info); |
||
662 | |||
663 | info = {}; |
||
664 | info.text = IMA_EASY_AUCTION; |
||
665 | info.value = "EasyAuction"; |
||
666 | info.func = IMA_EasyAuction_function; |
||
667 | UIDropDownMenu_AddButton(info); |
||
668 | end |
||
669 | |||
670 | function IMA_SetAllPricesButton_OnClick() |
||
671 | local scheme = UIDropDownMenu_GetSelectedValue(IMA_PriceSchemeDropDown); |
||
672 | scheme = string.gsub(scheme," ","_"); |
||
673 | |||
674 | pricefunc = getglobal("IMA_"..scheme.."_GetPriceAndBuyout"); |
||
675 | if (pricefunc == nil) then |
||
676 | return; |
||
677 | end |
||
678 | |||
679 | IMA_ClearAuctionSellItem(); |
||
680 | for i = 1, IMA_NUMITEMBUTTONS, 1 do |
||
681 | local item = getglobal("IMA_Item"..i); |
||
682 | local btn = getglobal(item:GetName().."ItemButton"); |
||
683 | |||
684 | if (btn.bag ~= nil and btn.item ~= nil) then |
||
685 | if (true and true) then -- put checkbox code here |
||
686 | price, buyout = pricefunc(btn.bag,btn.item,btn.count,btn.texture,btn.name,btn.price, |
||
687 | MoneyInputFrame_GetCopper(getglobal(item:GetName().."StartPrice"))) |
||
688 | if (price ~= nil) then |
||
689 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."StartPrice"),price); |
||
690 | end |
||
691 | if (buyout ~= nil) then |
||
692 | MoneyInputFrame_SetCopper(getglobal(item:GetName().."BuyoutPrice"),buyout); |
||
693 | end |
||
694 | end |
||
695 | end |
||
696 | end |
||
697 | end |
||
698 | |||
699 | function IMA_Default_GetPriceAndBuyout(bag, item, count, texture, name, price, currentstart) |
||
700 | start = MoneyInputFrame_GetCopper(StartPrice); |
||
701 | buyout = MoneyInputFrame_GetCopper(BuyoutPrice); |
||
702 | |||
703 | return start, buyout; |
||
704 | end |
||
705 | |||
706 | function IMA_Multiplier_GetPriceAndBuyout(bag, item, count, texture, name, price, currentstart) |
||
707 | local retprice = nil; |
||
708 | local retbuyout = nil; |
||
709 | |||
710 | if (IMA_MultiplierFramePriceCheckButton:GetChecked()) then |
||
711 | pricepercent = IMA_MultiplierFramePriceMultiplier:GetText() + 0; |
||
712 | if (pricepercent >= 1 and pricepercent <= 9999) then |
||
713 | retprice = max(100,floor(price * pricepercent / 100.0)); |
||
714 | currentstart = retprice + 0; |
||
715 | end |
||
716 | end |
||
717 | |||
718 | if (IMA_MultiplierFrameBuyoutCheckButton:GetChecked()) then |
||
719 | buyoutpercent = IMA_MultiplierFrameBuyoutMultiplier:GetText() + 0; |
||
720 | if (buyoutpercent >= 1 and buyoutpercent <= 9999) then |
||
721 | retbuyout = floor(currentstart * buyoutpercent / 100.0); |
||
722 | end |
||
723 | end |
||
724 | |||
725 | return retprice,retbuyout |
||
726 | end |
||
727 | |||
728 | function IMA_AllSamePrice_GetPriceAndBuyout(bag, item, count, texture, name, price, currentstart) |
||
729 | local price = MoneyInputFrame_GetCopper(IMA_AllSamePriceFrameStartPrice); |
||
730 | local buyout = MoneyInputFrame_GetCopper(IMA_AllSamePriceFrameBuyoutPrice); |
||
731 | local basecount = IMA_AllSamePriceFrameStackSize:GetText() + 0; |
||
732 | |||
733 | if (basecount > 0 and count ~= basecount) then |
||
734 | price = floor(price / basecount * count); |
||
735 | buyout = floor(buyout / basecount * count); |
||
736 | end |
||
737 | |||
738 | return price,buyout; |
||
739 | end |
||
740 | |||
741 | function IMA_EasyAuction_GetPriceAndBuyout(bag, item, count, texture, name, price, currentstart) |
||
742 | local start = nil; |
||
743 | local buyout = nil; |
||
744 | |||
745 | if (EasyAuction_Prices ~= nil and EasyAuction_PersonalPrices ~= nil) then |
||
746 | local lastauction = nil; |
||
747 | if (IMA_Playername ~= nil and EasyAuction_PersonalPrices[IMA_Playername] ~= nil |
||
748 | and EasyAuction_PersonalPrices[IMA_Playername][name] ~= nil) then |
||
749 | lastauction = EasyAuction_PersonalPrices[IMA_Playername][name]; |
||
750 | else |
||
751 | if (EasyAuction_Prices[name] ~= nil) then |
||
752 | lastauction = EasyAuction_Prices[name]; |
||
753 | end |
||
754 | end |
||
755 | if (lastauction ~= nil) then |
||
756 | start = lastauction.bid * count; |
||
757 | buyout = lastauction.buyout * count; |
||
758 | end |
||
759 | end |
||
760 | |||
761 | return start,buyout; |
||
762 | end |
||
763 |