-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.lua
2054 lines (1835 loc) · 63.7 KB
/
GUI.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
Copyright (c) 2011, Jacob Hollenbeck (Grioja of <Eminent>)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Jacob Hollenbeck (Grioja).
4. Neither the name of Jacob Hollenbeck nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY JACOB HOLLENBECK ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL JACOB HOLLENBECK BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
]]
local L = LibStub("AceLocale-3.0"):GetLocale("EminentDKP", false)
local AceGUI = LibStub("AceGUI-3.0")
local EminentDKP = EminentDKP
local meter = EminentDKP:NewModule("MeterDisplay", "SpecializedLibBars-1.1")
local libwindow = LibStub("LibWindow-1.1")
local media = LibStub("LibSharedMedia-3.0")
-- Our display providers.
EminentDKP.displays = {}
EminentDKP.classColors = RAID_CLASS_COLORS
local color_red = { .9, .10, .10 }
local color_green = { .10, .9, .10 }
-- Add to EminentDKP's list of display providers.
meter.name = "Meter display"
EminentDKP.displays["meter"] = meter
--[[-------------------------------------------------------------------
Auction Interface Functions
---------------------------------------------------------------------]]
local auction_frame = nil
local auction_guid = ""
local last_bid_frame
local backdrop_default = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
inset = 4,
edgeSize = 8,
tile = true,
insets = {left = 2, right = 2, top = 2, bottom = 2}
}
local bidamt_backdrop_default = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 12,
tile = true,
insets = {left = 3, right = 3, top = 3, bottom = 3}
}
-- Handle the auction frame being moved
local function move(self)
if not self:GetParent().locked then
self.startX = self:GetParent():GetLeft()
self.startY = self:GetParent():GetTop()
self:GetParent():StartMoving()
end
end
-- Save position for the auction frame
local function stopMove(self)
if not self:GetParent().locked then
self:GetParent():StopMovingOrSizing()
local endX = self:GetParent():GetLeft()
local endY = self:GetParent():GetTop()
if self.startX ~= endX or self.startY ~= endY then
libwindow.SavePosition(self:GetParent())
end
end
end
-- Create the base auction frame for items
function EminentDKP:CreateAuctionFrame()
local settings = self:GetSetting('auctionframe')
auction_frame = CreateFrame("Frame", "EminentDKPAuctionFrameWindow", UIParent)
auction_frame:SetPoint("TOPLEFT", UIParent, "CENTER")
auction_frame:SetMovable(true)
auction_frame:SetClampedToScreen(true)
auction_frame:Hide()
auction_frame.title = CreateFrame("Button", nil, auction_frame)
auction_frame.title:SetScript("OnMouseDown", move)
auction_frame.title:SetScript("OnMouseUp", stopMove)
auction_frame.title:SetPoint("TOPLEFT", auction_frame, "TOPLEFT")
auction_frame.title:SetPoint("BOTTOMRIGHT", auction_frame, "BOTTOMRIGHT")
-- Register with LibWindow-1.1
libwindow.RegisterConfig(auction_frame, settings)
-- Restore auction anchor position.
libwindow.RestorePosition(auction_frame)
self:ApplyAuctionFrameSettings()
end
local auction_titlebackdrop = {}
local auction_windowbackdrop = {}
-- Apply profile settings to the auction frame (and item frames)
function EminentDKP:ApplyAuctionFrameSettings()
local p = self:GetSetting('auctionframe')
auction_frame:SetWidth(p.itemwidth)
auction_frame:SetHeight(p.itemheight * .75)
-- Auction frame title
local fo = CreateFont("TitleFontEminentDKPAuctionFrame")
fo:SetFont(media:Fetch('font', p.title.font), p.title.fontsize)
auction_frame.title:SetNormalFontObject(fo)
local inset = p.title.margin
auction_titlebackdrop.bgFile = media:Fetch("statusbar", p.title.texture)
if p.title.borderthickness > 0 then
auction_titlebackdrop.edgeFile = media:Fetch("border", p.title.bordertexture)
else
auction_titlebackdrop.edgeFile = nil
end
auction_titlebackdrop.tile = false
auction_titlebackdrop.tileSize = 0
auction_titlebackdrop.edgeSize = p.title.borderthickness
auction_titlebackdrop.insets = {left = inset, right = inset, top = inset, bottom = inset}
auction_frame.title:SetBackdrop(auction_titlebackdrop)
local color = p.title.color
auction_frame.title:SetBackdropColor(color.r, color.g, color.b, color.a or 1)
-- Auction frame background
if p.enablebackground then
if auction_frame.bgframe == nil then
auction_frame.bgframe = CreateFrame("Frame", "EminentDKPAuctionFrameBG", auction_frame)
auction_frame.bgframe:SetFrameStrata("BACKGROUND")
end
local inset = p.background.margin
auction_windowbackdrop.bgFile = media:Fetch("background", p.background.texture)
if p.background.borderthickness > 0 then
auction_windowbackdrop.edgeFile = media:Fetch("border", p.background.bordertexture)
else
auction_windowbackdrop.edgeFile = nil
end
auction_windowbackdrop.tile = false
auction_windowbackdrop.tileSize = 0
auction_windowbackdrop.edgeSize = p.background.borderthickness
auction_windowbackdrop.insets = {left = inset, right = inset, top = inset, bottom = inset}
auction_frame.bgframe:SetBackdrop(auction_windowbackdrop)
local color = p.background.color
auction_frame.bgframe:SetBackdropColor(color.r, color.g, color.b, color.a or 1)
auction_frame.bgframe:SetWidth(auction_frame:GetWidth() + (p.background.borderthickness * 2))
auction_frame.bgframe:ClearAllPoints()
auction_frame.bgframe:SetPoint("LEFT", auction_frame.title, "LEFT", -p.background.borderthickness, 0)
auction_frame.bgframe:SetPoint("RIGHT", auction_frame.title, "RIGHT", p.background.borderthickness, 0)
auction_frame.bgframe:SetPoint("TOP", auction_frame.title, "BOTTOM", 0, 0)
auction_frame.bgframe:Hide()
self:AdjustAuctionFrameBackgroundHeight()
elseif auction_frame.bgframe then
auction_frame.bgframe:Hide()
end
if auction_frame:IsShown() and p.enabletitle then
auction_frame.title:Show()
else
auction_frame.title:Hide()
end
auction_frame.locked = p.locked
self:ReApplyItemFrameSettings()
end
local item_frames = {}
local recycled_item_frames = {}
local function SetItemTip(frame)
if not frame.link then return end
GameTooltip:SetOwner(frame, "ANCHOR_TOPLEFT")
GameTooltip:SetHyperlink(frame.link)
if IsShiftKeyDown() then GameTooltip_ShowCompareItem() end
if IsModifiedClick("DRESSUP") then ShowInspectCursor() else ResetCursor() end
end
local function LootClick(frame)
if IsControlKeyDown() then DressUpItemLink(frame.link)
elseif IsShiftKeyDown() then ChatEdit_InsertLink(frame.link) end
end
local function ItemOnUpdate(self)
if IsShiftKeyDown() then GameTooltip_ShowCompareItem() end
CursorOnUpdate(self)
end
local function HideTip2() GameTooltip:Hide(); ResetCursor() end
-- This is run in the bid amount box everytime they type something
-- It ensures no incorrect bid is sent
local function VerifyBid(frame)
local value = frame:GetText()
local num_value = tonumber(value) or 0
local my_dkp = math.floor(EminentDKP:GetMyCurrentDKP())
if value == "" or my_dkp < 1 then
frame:SetText("")
SetDesaturation(frame:GetParent().bid:GetNormalTexture(), true)
frame:GetParent().bid:Disable()
return
else
SetDesaturation(frame:GetParent().bid:GetNormalTexture(), false)
frame:GetParent().bid:Enable()
end
if num_value < 1 then
frame:SetText("1")
elseif num_value > my_dkp then
frame:SetText(tostring(my_dkp))
else
frame:SetText(string.format("%d",value))
end
frame:SetBackdropBorderColor(0.5,0.5,0.5,1)
end
-- Send a bid for the auction
local function SubmitBid(frame)
PlaySound("LOOTWINDOWCOINSOUND")
last_bid_frame = frame:GetParent()
last_bid_frame.bid.bidamt:ClearFocus()
EminentDKP:ScheduleBidTimeout()
EminentDKP:SendCommand("bid",last_bid_frame.bid.bidamt:GetText())
end
-- This clears the focus of a frame (editbox)
local function ClearFocus(frame)
frame:ClearFocus()
end
-- Submit a bid and/or clear focus (depending on option)
local function DecideAction(frame)
if EminentDKP:GetSetting('auctionframe').bidonenter then
SubmitBid(frame)
else
ClearFocus(frame)
end
end
-- This updates the timer bar on an item auction
local function TimerUpdate(frame)
local left = frame:GetParent().endtime - GetTime()
if left > 0 then
local max = select(2,frame:GetMinMaxValues())
frame.spark:SetPoint("CENTER", frame, "LEFT", (left / max) * frame:GetWidth(), 0)
frame:SetValue(left)
else
frame:SetValue(0)
frame.spark:Hide()
frame:Hide()
frame:GetParent().bid.bidamt:Hide()
frame:GetParent().bid:Hide()
end
end
function EminentDKP:AdjustAuctionFrameBackgroundHeight()
if auction_frame.bgframe then
local settings = self:GetSetting('auctionframe')
local height = (#(item_frames) * (settings.itemheight + settings.itemspacing)) + settings.background.borderthickness + settings.itemspacing
auction_frame.bgframe:SetHeight(height)
if settings.enablebackground and auction_frame:IsShown() then
auction_frame.bgframe:Show()
end
end
end
-- Apply the profile settings to an item frame
local function ApplyItemFrameSettings(frame)
local p = EminentDKP:GetSetting('auctionframe')
frame:SetWidth(p.itemwidth)
frame:SetHeight(p.itemheight)
frame.button:SetWidth(frame:GetHeight())
frame.button:SetHeight(frame:GetHeight())
frame.buttonborder:SetWidth(frame.button:GetWidth())
frame.buttonborder:SetHeight(frame.button:GetHeight())
frame.buttonborder2:SetWidth(frame.button:GetWidth() + 2)
frame.buttonborder2:SetHeight(frame.button:GetHeight() + 2)
frame.status:SetWidth(frame:GetWidth() - 2 - frame.buttonborder2:GetWidth())
frame.status:SetHeight(frame:GetHeight() - 2)
frame.status:SetStatusBarTexture(media:Fetch("statusbar", p.itemtexture))
frame.status.spark:SetHeight(frame.status:GetHeight() + 10)
frame.bid:SetWidth(frame:GetHeight() - 2)
frame.bid:SetHeight(frame:GetHeight() - 2)
frame.loot:SetHeight(frame:GetHeight() - 4)
frame.loot:SetWidth(frame:GetWidth() / 2)
frame.loot:SetFont(media:Fetch('font', p.itemfont), p.itemfontsize, "OUTLINE")
frame.winner:SetHeight(frame:GetHeight() - 2)
frame.winner:SetWidth(frame:GetWidth() - frame.loot:GetWidth() - frame.button:GetWidth())
frame.winner:SetFont(media:Fetch('font', p.itemfont), p.itemfontsize - 2, "OUTLINE")
end
-- Create a new item frame absent any settings
local function CreateNewItemFrame()
local itemframe = CreateFrame("Frame", nil, auction_frame)
itemframe:SetBackdrop(backdrop_default)
itemframe:SetBackdropColor(0.1, 0.1, 0.1, 1)
itemframe:Hide()
local button = CreateFrame("Button", nil, itemframe)
button:SetPoint("LEFT", 0, 0)
button:SetScript("OnEnter", SetItemTip)
button:SetScript("OnLeave", HideTip2)
button:SetScript("OnUpdate", ItemOnUpdate)
button:SetScript("OnClick", LootClick)
itemframe.button = button
local buttonborder = CreateFrame("Frame", nil, button)
buttonborder:SetPoint("CENTER", button, "CENTER")
buttonborder:SetBackdrop(backdrop_default)
buttonborder:SetBackdropColor(1, 1, 1, 0)
itemframe.buttonborder = buttonborder
local buttonborder2 = CreateFrame("Frame", nil, button)
buttonborder2:SetFrameLevel(buttonborder:GetFrameLevel()+1)
buttonborder2:SetPoint("CENTER", button, "CENTER")
buttonborder2:SetBackdrop(backdrop_default)
buttonborder2:SetBackdropColor(0, 0, 0, 0)
buttonborder2:SetBackdropBorderColor(0,0,0,1)
itemframe.buttonborder2 = buttonborder2
local status = CreateFrame("StatusBar", nil, itemframe)
status:SetPoint("LEFT", buttonborder2, "RIGHT", 0, 0)
status:SetScript("OnUpdate", TimerUpdate)
status:SetFrameLevel(status:GetFrameLevel()-1)
status:SetStatusBarColor(.8, .8, .8, .9)
status:Hide()
itemframe.status = status
local spark = status:CreateTexture(nil, "OVERLAY")
spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
spark:SetPoint("CENTER", status, "RIGHT", 0, 0)
spark:SetBlendMode("ADD")
spark:SetWidth(14)
spark:Hide()
status.spark = spark
local bid = CreateFrame("Button", nil, itemframe)
bid:SetPoint("RIGHT", itemframe, "RIGHT", -2, -2)
bid:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Up")
bid:SetPushedTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Down")
bid:SetHighlightTexture("Interface\\Buttons\\UI-GroupLoot-Coin-Highlight")
bid:SetScript("OnClick", SubmitBid)
bid:SetMotionScriptsWhileDisabled(true)
SetDesaturation(bid:GetNormalTexture(), true)
bid:Disable()
bid:Hide()
itemframe.bid = bid
local bidamt = CreateFrame("EditBox", nil, itemframe)
bidamt:SetPoint("RIGHT", bid, "LEFT", -1, 2)
bidamt:SetWidth(55)
bidamt:SetHeight(20)
bidamt:SetTextInsets(5, 5, 5, 3)
bidamt:SetMaxLetters(6)
bidamt:SetBackdrop(bidamt_backdrop_default)
bidamt:SetBackdropColor(0.1,0.1,0.1,1)
bidamt:SetBackdropBorderColor(0.5,0.5,0.5,1)
bidamt:SetAutoFocus(false)
bidamt:SetFontObject(ChatFontNormal)
bidamt:SetScript("OnTextChanged", VerifyBid)
bidamt:SetScript("OnEnterPressed", DecideAction)
bidamt:SetScript("OnEscapePressed", ClearFocus)
bidamt:Hide()
bid.bidamt = bidamt
local loot = itemframe:CreateFontString(nil, "ARTWORK")
loot:SetPoint("LEFT", button, "RIGHT", 4, 0)
loot:SetJustifyH("LEFT")
itemframe.loot = loot
local winner = itemframe:CreateFontString(nil, "ARTWORK")
winner:SetPoint("RIGHT", itemframe, "RIGHT", -1, 0)
winner:SetJustifyH("RIGHT")
winner:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
winner:Hide()
itemframe.winner = winner
ApplyItemFrameSettings(itemframe)
return itemframe
end
-- Either get a recycled frame or create a new one
local function GetItemFrame()
local frame
if #(recycled_item_frames) > 0 then
frame = tremove(recycled_item_frames)
else
frame = CreateNewItemFrame()
end
frame:SetPoint("TOPLEFT", #(item_frames) > 0 and item_frames[#(item_frames)] or auction_frame.title, "BOTTOMLEFT", 0, -(EminentDKP:GetSetting('auctionframe').itemspacing))
table.insert(item_frames, frame)
return frame
end
-- Hide bidbox and button for an item frame
local function HideBidApparatus(frame)
frame.bid:Hide()
frame.bid.bidamt:SetBackdropBorderColor(0.5,0.5,0.5,1)
frame.bid.bidamt:Hide()
end
-- Show bidbox and button for an item frame
local function ShowBidApparatus(frame)
frame.bid:Show()
frame.bid.bidamt:Show()
end
function EminentDKP:CancelBidTimeout()
if self.bidTimeout then
self:CancelTimer(self.bidTimeout,true)
self.bidTimeout = nil
end
end
-- Incase we never get a response about a bid, just assume it was rejected
function EminentDKP:ScheduleBidTimeout()
self:CancelBidTimeout()
self.bidTimeout = self:ScheduleTimer("RejectLastItemBid",3)
end
-- Turn the bid amount box red (signify rejection of bid)
function EminentDKP:RejectLastItemBid()
self:CancelBidTimeout()
last_bid_frame.bid.bidamt:SetBackdropBorderColor(235,0,0,1)
end
-- Turn the bid amount box green (signify the acceptance of bid)
function EminentDKP:AcceptLastItemBid()
self:CancelBidTimeout()
last_bid_frame.bid.bidamt:SetBackdropBorderColor(0,235,0,1)
end
-- Reapply settings to each item frame (and adjust their positioning if necessary)
function EminentDKP:ReApplyItemFrameSettings()
for i, frame in ipairs(item_frames) do
ApplyItemFrameSettings(frame)
frame:SetPoint("TOPLEFT", i > 1 and item_frames[i-1] or auction_frame.title, "BOTTOMLEFT", 0, -(self:GetSetting('auctionframe').itemspacing))
end
-- Don't forget about recycled frames
for i, frame in ipairs(recycled_item_frames) do
ApplyItemFrameSettings(frame)
end
end
function EminentDKP:FillOutItemFrame(f)
local iName, iLink, iQuality, iLevel, iMinLevel, iType, iSubType, iStackCount, iEquipLoc, iTexture, iSellPrice = GetItemInfo(f.item)
local color
local success = true
if not iName then
f.button:SetNormalTexture("Interface\\Icons\\INV_Misc_QuestionMark")
f.button.link = nil
color = ITEM_QUALITY_COLORS[1]
f.loot:SetText("(Querying Item)")
success = false
else
f.button:SetNormalTexture(iTexture)
f.button.link = iLink
color = ITEM_QUALITY_COLORS[iQuality]
f.loot:SetText(iName)
end
f.loot:SetVertexColor(color.r, color.g, color.b)
f:SetBackdropBorderColor(color.r, color.g, color.b, 1)
f.buttonborder:SetBackdropBorderColor(color.r, color.g, color.b, 1)
f.status:SetStatusBarColor(color.r, color.g, color.b, .7)
return success
end
-- Display all the available loot for a given GUID
function EminentDKP:ShowAuctionItems(guid)
if auction_guid == guid then
-- If the lootlist has changed, re-list the items
if self.auctionItems[guid].changed then
self:RecycleAuctionItems(false)
else
return
end
else
self:RecycleAuctionItems(false)
end
auction_frame:Show()
if self:GetSetting('auctionframe').enabletitle then
auction_frame.title:Show()
end
auction_frame.title:SetText(L["EminentDKP: %s Items"]:format(self.auctionItems[guid].name))
local refill = false
for i, item in ipairs(self.auctionItems[guid].items) do
local f = GetItemFrame()
f.item = item.info
f.slot = item.slot
if not self:FillOutItemFrame(f) then refill = true end
f:Show()
end
if refill then self:ScheduleTimer("ReFillItemFrames",1) end
self.auctionItems[guid].changed = false
auction_guid = guid
self:AdjustAuctionFrameBackgroundHeight()
end
local function GetItemFrameBySlot(slot)
for i, frame in ipairs(item_frames) do
if frame.slot == slot then
return frame
end
end
error("Could not find item frame for slot: "..slot)
end
-- Cancel the auction for a specified slot
function EminentDKP:CancelAuction(slot)
local frame = GetItemFrameBySlot(slot)
HideBidApparatus(frame)
frame.status:Hide()
frame.status.spark:Hide()
frame.winner:SetText(L["Auction cancelled"])
frame.winner:Show()
PlaySound("AuctionWindowClose")
end
-- Start the timer and show bid box/button for an item
function EminentDKP:StartAuction(slot,timeleft,window)
local frame = GetItemFrameBySlot(slot)
-- If itemframe is filled out properly, and we can use the item, show the bid apparatus
if frame.button.link and self:CanIUseItem(frame.button.link) then
ShowBidApparatus(frame)
end
frame.endtime = GetTime() + timeleft
frame.status:SetMinMaxValues(0, window)
frame.status:SetValue(timeleft)
frame.status:Show()
frame.status.spark:Show()
frame.winner:Hide()
PlaySound("AuctionWindowOpen")
end
-- Label an item disenchanted
function EminentDKP:ShowAuctionDisenchant(slot)
local frame = GetItemFrameBySlot(slot)
HideBidApparatus(frame)
frame.winner:SetText(L["Disenchanted"])
frame.winner:Show()
end
-- Attempts to fill out the item frames with item data
function EminentDKP:ReFillItemFrames()
local refill = false
for i, frame in ipairs(item_frames) do
if not self:FillOutItemFrame(frame) then refill = true end
end
if refill then self:ScheduleTimer("ReFillItemFrames",1) end
end
-- Label an item with a winner
function EminentDKP:ShowAuctionWinner(slot,name,amount,tie)
local frame = GetItemFrameBySlot(slot)
HideBidApparatus(frame)
if tie then
frame.winner:SetText(L["Tie won by %s (%d)"]:format(name,amount))
else
frame.winner:SetText(L["Won by %s (%d)"]:format(name,amount))
end
frame.winner:Show()
end
-- Cleanup and recycle all the frames for re-use later (saves memory)
function EminentDKP:RecycleAuctionItems(clear_list)
if self.auctionRecycleTimer then
self:CancelTimer(self.auctionRecycleTimer,true)
self.auctionRecycleTimer = nil
end
for i, frame in ipairs(item_frames) do
frame.item = nil
frame.slot = nil
frame.endtime = nil
frame.bid.bidamt:SetText("")
frame.winner:SetText("")
HideBidApparatus(frame)
frame.winner:Hide()
table.insert(recycled_item_frames,frame)
frame:Hide()
end
wipe(item_frames)
auction_frame.title:Hide()
if auction_frame.bgframe then
auction_frame.bgframe:Hide()
end
auction_frame:Hide()
-- Clear out the loot list for this GUID, we no longer need it
if clear_list and self.auctionItems[auction_guid] then
self.auctionItems[auction_guid] = nil
end
auction_guid = ""
end
--[[-------------------------------------------------------------------
Action Panel Functions
---------------------------------------------------------------------]]
--[[
Confirmation dialogs:
StaticPopupDialogs["ResetSkadaDialog"] = {
text = L["Do you want to reset Skada?"],
button1 = ACCEPT,
button2 = CANCEL,
timeout = 30,
whileDead = 0,
hideOnEscape = 1,
OnAccept = function() Skada:Reset() end,
}
StaticPopup_Show("ResetSkadaDialog")
]]
-- Truncate a number to 2 decimals (without rounding)
local function TNum(number)
decimal = string.find(number, ".", 1, 1)
if decimal == nil then
return number
elseif string.find(number, "e-", 1, 1) ~= nil then
return 0
else
return tonumber(string.sub(number, 1, decimal+2))
end
end
function EminentDKP:ConfirmAction(name,msg,accept,cancel)
StaticPopupDialogs[name] = {
text = msg,
button1 = ACCEPT,
button2 = CANCEL,
timeout = 45,
whileDead = 1,
hideOnEscape = 0,
OnAccept = accept,
OnCancel = cancel,
OnHide = cancel,
}
StaticPopup_Show(name)
end
-- Show the tab responsible for transfers
local function CreateTransferTab(container)
local transfergrp = AceGUI:Create("InlineGroup")
transfergrp:SetTitle(L["Transfer DKP"])
transfergrp:SetLayout("Flow")
transfergrp:SetWidth(200)
local recip = AceGUI:Create("Dropdown")
recip:SetLabel(L["Recipient"])
recip:SetList(EminentDKP:GetOtherPlayersNames(true))
recip:SetWidth(150)
local amount = AceGUI:Create("Slider")
amount:SetLabel("Amount")
if EminentDKP:GetMyCurrentDKP() and EminentDKP:GetMyCurrentDKP() >= 1 then
amount:SetSliderValues(1,TNum(EminentDKP:GetMyCurrentDKP()),1)
amount:SetValue(1)
else
recip:SetDisabled(true)
end
local send = AceGUI:Create("Button")
send:SetText(L["Send"])
send:SetWidth(200)
send:SetCallback("OnClick",function(what)
EminentDKP:ConfirmAction("EminentDKPTransfer",
L["Are you sure you want to transfer %.02f DKP to %s?"]:format(amount:GetValue(),recip:GetValue()),
function() EminentDKP:SendCommand('transfer',amount:GetValue(),recip:GetValue()) end)
end)
send:SetDisabled(true)
recip:SetCallback("OnValueChanged",function(i,j,val)
if val ~= "" and EminentDKP:InQualifiedRaid() then
send:SetDisabled(false)
else
send:SetDisabled(true)
end
end)
transfergrp:AddChild(recip)
transfergrp:AddChild(amount)
transfergrp:AddChild(send)
container:AddChild(transfergrp)
end
local function CreateVanityTab(container)
local resetgrp = AceGUI:Create("InlineGroup")
resetgrp:SetTitle(L["Reset Vanity DKP"])
resetgrp:SetLayout("Flow")
resetgrp:SetWidth(200)
local who = AceGUI:Create("Dropdown")
who:SetLabel(L["Player"])
who:SetList(EminentDKP:GetPlayerNames())
who:SetWidth(150)
local reset = AceGUI:Create("Button")
reset:SetText(L["Reset"])
reset:SetWidth(150)
reset:SetCallback("OnClick",function(what)
EminentDKP:AdminVanityReset(who:GetValue())
end)
reset:SetDisabled(true)
who:SetCallback("OnValueChanged",function(i,j,val)
if val ~= "" then
reset:SetDisabled(false)
else
reset:SetDisabled(true)
end
end)
resetgrp:AddChild(who)
resetgrp:AddChild(reset)
container:AddChild(resetgrp)
local rollgrp = AceGUI:Create("InlineGroup")
rollgrp:SetTitle(L["Vanity DKP Roll"])
rollgrp:SetLayout("Flow")
rollgrp:SetWidth(200)
local roll = AceGUI:Create("Button")
roll:SetText(L["Roll"])
roll:SetWidth(150)
roll:SetCallback("OnClick",function(what)
EminentDKP:AdminVanityRoll()
end)
rollgrp:AddChild(roll)
container:AddChild(rollgrp)
end
local function CreateRenameTab(container)
local renamegrp = AceGUI:Create("InlineGroup")
renamegrp:SetTitle(L["Rename Player"])
renamegrp:SetLayout("Flow")
renamegrp:SetWidth(200)
local rename = AceGUI:Create("Button")
rename:SetText(L["Rename"])
rename:SetWidth(150)
rename:SetDisabled(true)
local newname = AceGUI:Create("Dropdown")
newname:SetLabel(L["New Player"])
newname:SetWidth(150)
newname:SetCallback("OnValueChanged",function(i,j,value)
rename:SetDisabled(false)
end)
local who = AceGUI:Create("Dropdown")
who:SetLabel(L["Old Player"])
who:SetList(EminentDKP:GetPlayerNames())
who:SetCallback("OnValueChanged",function(i,j,value)
newname:SetList(EminentDKP:GetPlayersOfClass(value,true))
rename:SetDisabled(true)
end)
who:SetWidth(150)
rename:SetCallback("OnClick",function(what)
EminentDKP:AdminRename(who:GetValue(),newname:GetValue())
end)
renamegrp:AddChild(who)
renamegrp:AddChild(newname)
renamegrp:AddChild(rename)
container:AddChild(renamegrp)
end
local function CreateBountyTab(container)
local bountygrp = AceGUI:Create("InlineGroup")
bountygrp:SetTitle(L["Award Bounty"])
bountygrp:SetLayout("Flow")
bountygrp:SetWidth(200)
local reason = AceGUI:Create("Dropdown")
reason:SetLabel(L["Reason"])
reason:SetWidth(150)
reason:SetList(EminentDKP:GetBountyReasons())
reason:SetValue("Default")
local amount = AceGUI:Create("Slider")
amount:SetLabel(L["Amount"])
amount:SetIsPercent(true)
amount:SetSliderValues(0.005,1,0.005)
amount:SetValue(0.4)
local percent = AceGUI:Create("CheckBox")
percent:SetLabel(L["Percent"])
percent:SetValue(true)
percent:SetCallback("OnValueChanged",function(i,j,checked)
if checked then
amount:SetIsPercent(true)
amount:SetSliderValues(0.005,1,0.005)
amount:SetValue(0.4)
else
amount:SetIsPercent(false)
amount:SetSliderValues(1,math.floor(EminentDKP:GetAvailableBounty()),1)
amount:SetValue(1)
end
end)
local award = AceGUI:Create("Button")
award:SetText(L["Award"])
award:SetWidth(150)
award:SetCallback("OnClick",function(what)
EminentDKP:AdminDistributeBounty(percent:GetValue(),amount:GetValue(),reason:GetValue())
end)
bountygrp:AddChild(reason)
bountygrp:AddChild(percent)
bountygrp:AddChild(amount)
bountygrp:AddChild(award)
container:AddChild(bountygrp)
end
local function CreateAdjustmentTab(container)
local adjustgrp = AceGUI:Create("InlineGroup")
adjustgrp:SetTitle(L["Issue Adjustment"])
adjustgrp:SetLayout("Flow")
adjustgrp:SetWidth(200)
local deduct = AceGUI:Create("CheckBox")
local issue = AceGUI:Create("Button")
local amount = AceGUI:Create("Slider")
amount:SetLabel(L["Amount"])
local who = AceGUI:Create("Dropdown")
who:SetLabel(L["Player"])
who:SetList(EminentDKP:GetPlayerNames(true))
who:SetWidth(150)
who:SetCallback("OnValueChanged",function(i,j,value)
issue:SetDisabled(false)
if deduct:GetValue() then
if EminentDKP:GetPlayerDKPByName(value) < 1 then
issue:SetDisabled(true)
amount:SetSliderValues(0,0,0)
else
amount:SetSliderValues(1,TNum(EminentDKP:GetPlayerDKPByName(value)),1)
end
else
amount:SetSliderValues(1,math.floor(EminentDKP:GetAvailableBounty()),1)
end
amount:SetValue(1)
end)
local reason = AceGUI:Create("EditBox")
reason:SetLabel(L["Reason"])
reason:SetWidth(150)
reason:SetMaxLetters(20)
deduct:SetLabel(L["Deduction"])
deduct:SetValue(true)
deduct:SetCallback("OnValueChanged",function(i,j,checked)
if checked and who:GetValue() ~= "" then
if EminentDKP:GetPlayerDKPByName(who:GetValue()) < 1 then
issue:SetDisabled(true)
amount:SetSliderValues(0,0,0)
else
issue:SetDisabled(false)
amount:SetSliderValues(1,TNum(EminentDKP:GetPlayerDKPByName(who:GetValue())),1)
end
else
issue:SetDisabled(false)
amount:SetSliderValues(1,math.floor(EminentDKP:GetAvailableBounty()),1)
end
amount:SetValue(1)
end)
issue:SetText(L["Issue"])
issue:SetWidth(150)
issue:SetCallback("OnClick",function(what)
EminentDKP:AdminIssueAdjustment(who:GetValue(),amount:GetValue(),deduct:GetValue(),reason:GetText())
end)
issue:SetDisabled(true)
adjustgrp:AddChild(who)
adjustgrp:AddChild(reason)
adjustgrp:AddChild(deduct)
adjustgrp:AddChild(amount)
adjustgrp:AddChild(issue)
container:AddChild(adjustgrp)
end
local function CreateVersionsTab(container)
container:SetLayout("Fill")
local scroll = AceGUI:Create("ScrollFrame")
scroll:SetLayout("Flow")
local note = AceGUI:Create("Label")
note:SetWidth(330)
note:SetFontObject(GameFontNormal)
note:SetText(L["Please note that it can take up to 5 minutes to record the versions of all other EminentDKP users."])
scroll:AddChild(note)
local versions = EminentDKP:GetAddonVersions()
local grp_names = EminentDKP:GetCurrentGroupMembersNames()
local versioned_names = { }
-- Either compile list of group members with versions, or just all known users with versions
if #(grp_names) > 0 then
for i, name in ipairs(grp_names) do
table.insert(versioned_names, { name = name, version = (versions[name] or "Unknown") })
end
else
for name, version in pairs(versions) do
table.insert(versioned_names, { name = name, version = version })
end
end
table.sort(versioned_names, function(a,b) return a.name < b.name end)
for i = 1, #(versioned_names) do
local data
-- Have to remap sorted linear list into two columns
if i % 2 == 0 then
-- Even
data = versioned_names[(i + math.ceil((#(versioned_names) - i)/2))]
else
-- Odd
data = versioned_names[(i - math.floor(i/2))]
end
local lbl_name = AceGUI:Create("Label")
local lbl_version = AceGUI:Create("Label")
if data.name == EminentDKP.myName then
data.version = EminentDKP:GetVersion()
end
lbl_name:SetText(data.name)
lbl_name:SetWidth(85)
lbl_version:SetText(data.version)
lbl_version:SetWidth(70)
if data.version ~= EminentDKP:GetNewestVersion() then
lbl_version:SetColor(unpack(color_red))
else
lbl_version:SetColor(unpack(color_green))
end
local grp = AceGUI:Create("SimpleGroup")
grp:SetLayout("Flow")
grp:SetWidth(160)
grp:AddChild(lbl_name)
grp:AddChild(lbl_version)
scroll:AddChild(grp)
end
container:AddChild(scroll)
end
-- Callback function for OnGroupSelected
local function SelectGroup(container, event, group)
container:ReleaseChildren()
container:SetLayout("Flow")
if group == "transfer" then
CreateTransferTab(container)
elseif group == "vanity" then
CreateVanityTab(container)