-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBlizzard_GuildBankUI.lua
788 lines (738 loc) · 26.2 KB
/
Blizzard_GuildBankUI.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
MAX_GUILDBANK_SLOTS_PER_TAB = 98;
NUM_SLOTS_PER_GUILDBANK_GROUP = 14;
NUM_GUILDBANK_ICONS_SHOWN = 0;
NUM_GUILDBANK_ICONS_PER_ROW = 4;
NUM_GUILDBANK_ICON_ROWS = 4;
GUILDBANK_ICON_ROW_HEIGHT = 36;
NUM_GUILDBANK_COLUMNS = 7;
MAX_TRANSACTIONS_SHOWN = 21;
GUILDBANK_TRANSACTION_HEIGHT = 13;
UIPanelWindows["GuildBankFrame"] = { area = "doublewide", pushable = 0, width = 769 };
--REMOVE ME!
TABARDBACKGROUNDUPPER = "Textures\\GuildEmblems\\Background_%s_TU_U";
TABARDBACKGROUNDLOWER = "Textures\\GuildEmblems\\Background_%s_TL_U";
TABARDEMBLEMUPPER = "Textures\\GuildEmblems\\Emblem_%s_15_TU_U";
TABARDEMBLEMLOWER = "Textures\\GuildEmblems\\Emblem_%s_15_TL_U";
TABARDBORDERUPPER = "Textures\\GuildEmblems\\Border_%s_02_TU_U";
TABARDBORDERLOWER = "Textures\\GuildEmblems\\Border_%s_02_TL_U";
TABARDBACKGROUNDID = 1;
TABARDEMBLEMID = 1;
TABARDBORDERID = 1;
GUILD_BANK_LOG_TIME_PREPEND = "|cff009999 ";
function GuildBankFrame_ChangeBackground(id)
if ( id > 50 ) then
id = 1;
elseif ( id < 0 ) then
id = 50;
end
TABARDBACKGROUNDID = id;
GuildBankFrame_UpdateEmblem();
end
function GuildBankFrame_ChangeEmblem(id)
if ( id > 169 ) then
id = 1;
elseif ( id < 0 ) then
id = 169;
end
TABARDEMBLEMID = id;
GuildBankFrame_UpdateEmblem();
end
function GuildBankFrame_ChangeBorder(id)
if ( id > 9 ) then
id = 1;
elseif ( id < 0 ) then
id = 9;
end
TABARDBORDERID = id;
GuildBankFrame_UpdateEmblem();
end
function GuildBankFrame_UpdateEmblem()
local tabardBGID = TABARDBACKGROUNDID;
if ( tabardBGID < 10 ) then
tabardBGID = "0"..tabardBGID;
end
local tabardEmblemID = TABARDEMBLEMID;
if ( tabardEmblemID < 10 ) then
tabardEmblemID = "0"..tabardEmblemID;
end
local tabardBorderID = TABARDBORDERID;
if ( tabardBorderID < 10 ) then
tabardBorderID = "0"..tabardBorderID;
end
GuildBankEmblemBackgroundUL:SetTexture(format(TABARDBACKGROUNDUPPER, tabardBGID));
GuildBankEmblemBackgroundUR:SetTexture(format(TABARDBACKGROUNDUPPER, tabardBGID));
GuildBankEmblemBackgroundBL:SetTexture(format(TABARDBACKGROUNDLOWER, tabardBGID));
GuildBankEmblemBackgroundBR:SetTexture(format(TABARDBACKGROUNDLOWER, tabardBGID));
GuildBankEmblemUL:SetTexture(format(TABARDEMBLEMUPPER, tabardEmblemID));
GuildBankEmblemUR:SetTexture(format(TABARDEMBLEMUPPER, tabardEmblemID));
GuildBankEmblemBL:SetTexture(format(TABARDEMBLEMLOWER, tabardEmblemID));
GuildBankEmblemBR:SetTexture(format(TABARDEMBLEMLOWER, tabardEmblemID));
GuildBankEmblemBorderUL:SetTexture(format(TABARDBORDERUPPER, tabardBorderID));
GuildBankEmblemBorderUR:SetTexture(format(TABARDBORDERUPPER, tabardBorderID));
GuildBankEmblemBorderBL:SetTexture(format(TABARDBORDERLOWER, tabardBorderID));
GuildBankEmblemBorderBR:SetTexture(format(TABARDBORDERLOWER, tabardBorderID));
end
function GuildBankFrame_OnLoad(self)
NUM_GUILDBANK_ICONS_SHOWN = NUM_GUILDBANK_ICONS_PER_ROW * NUM_GUILDBANK_ICON_ROWS;
self:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED");
self:RegisterEvent("GUILDBANK_ITEM_LOCK_CHANGED");
self:RegisterEvent("GUILDBANK_UPDATE_TABS");
self:RegisterEvent("GUILDBANK_UPDATE_MONEY");
self:RegisterEvent("GUILDBANK_UPDATE_WITHDRAWMONEY");
self:RegisterEvent("GUILD_ROSTER_UPDATE");
self:RegisterEvent("GUILDBANKLOG_UPDATE");
self:RegisterEvent("GUILDTABARD_UPDATE");
self:RegisterEvent("GUILDBANK_UPDATE_TEXT");
self:RegisterEvent("GUILDBANK_TEXT_CHANGED");
self:RegisterEvent("PLAYER_MONEY");
-- Set the button id's
local index, column, button;
for i=1, MAX_GUILDBANK_SLOTS_PER_TAB do
index = mod(i, NUM_SLOTS_PER_GUILDBANK_GROUP);
if ( index == 0 ) then
index = NUM_SLOTS_PER_GUILDBANK_GROUP;
end
column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP);
button = _G["GuildBankColumn"..column.."Button"..index];
button:SetID(i);
end
GuildBankFrame.mode = "bank";
GuildBankFrame.numTabs = 4;
GuildBankFrame_UpdateTabs();
GuildBankFrame_UpdateTabard();
end
function GuildBankFrame_OnEvent(self, event, ...)
if ( not GuildBankFrame:IsVisible() ) then
return;
end
if ( event == "GUILDBANKBAGSLOTS_CHANGED" or event =="GUILDBANK_ITEM_LOCK_CHANGED" ) then
GuildBankFrame_UpdateTabs();
GuildBankFrame_Update();
elseif ( event == "GUILDBANK_UPDATE_TABS" or event == "GUILD_ROSTER_UPDATE" ) then
if ( event == "GUILD_ROSTER_UPDATE" and not select(1, ...) and GuildBankFrame.noViewableTabs and GuildBankFrame.mode == "bank" ) then
-- if rank changed while at the bank tab and not having any viewable tabs, query for new item data
QueryGuildBankTab(GetCurrentGuildBankTab());
end
GuildBankFrame_SelectAvailableTab();
if ( GuildBankFrameBuyInfo:IsShown() ) then
GuildBankFrame_UpdateTabBuyingInfo();
end
if ( CanEditGuildTabInfo(GetCurrentGuildBankTab()) ) then
GuildBankInfoSaveButton:Show();
else
GuildBankInfoSaveButton:Hide();
end
elseif ( event == "GUILDBANKLOG_UPDATE" ) then
if ( GuildBankFrame.mode == "log" ) then
GuildBankFrame_UpdateLog();
else
GuildBankFrame_UpdateMoneyLog();
end
GuildBankLogScroll();
elseif ( event == "GUILDTABARD_UPDATE" ) then
GuildBankFrame_UpdateTabard();
elseif ( event == "GUILDBANK_UPDATE_MONEY" or event == "GUILDBANK_UPDATE_WITHDRAWMONEY" ) then
GuildBankFrame_UpdateWithdrawMoney();
elseif ( event == "GUILDBANK_UPDATE_TEXT" ) then
GuildBankFrame_UpdateTabInfo(...);
elseif ( event == "GUILDBANK_TEXT_CHANGED" ) then
local arg1 = ...
if ( GetCurrentGuildBankTab() == tonumber(arg1) ) then
QueryGuildBankText(arg1);
end
elseif ( event == "PLAYER_MONEY" ) then
if ( GuildBankFrameBuyInfo:IsShown() ) then
GuildBankFrame_UpdateTabBuyingInfo();
end
end
end
function GuildBankFrame_SelectAvailableTab()
--If the selected tab is notViewable then select the next available one
if ( IsTabViewable(GetCurrentGuildBankTab()) ) then
GuildBankFrame_UpdateTabs();
GuildBankFrame_Update();
else
if ( GuildBankFrame.nextAvailableTab ) then
GuildBankTab_OnClick(_G["GuildBankTab" .. GuildBankFrame.nextAvailableTab], "LeftButton", GuildBankFrame.nextAvailableTab);
else
GuildBankFrame_UpdateTabs();
GuildBankFrame_Update();
end
end
end
function GuildBankFrame_OnShow()
GuildBankFrameTab_OnClick(GuildBankFrameTab1, 1);
GuildBankFrame_UpdateTabard();
GuildBankFrame_SelectAvailableTab();
PlaySound("GuildVaultOpen");
end
function GuildBankFrame_Update()
--Figure out which mode you're in and which tab is selected
if ( GuildBankFrame.mode == "bank" ) then
-- Determine whether its the buy tab or not
GuildBankFrameLog:Hide();
GuildBankInfo:Hide();
local tab = GetCurrentGuildBankTab();
if ( GuildBankFrame.noViewableTabs ) then
GuildBankFrame_HideColumns();
GuildBankFrameBuyInfo:Hide();
GuildBankErrorMessage:SetText(NO_VIEWABLE_GUILDBANK_TABS);
GuildBankErrorMessage:Show();
elseif ( tab > GetNumGuildBankTabs() ) then
if ( IsGuildLeader() ) then
--Show buy screen
GuildBankFrame_HideColumns();
GuildBankFrameBuyInfo:Show();
GuildBankErrorMessage:Hide();
else
GuildBankFrame_HideColumns();
GuildBankFrameBuyInfo:Hide();
GuildBankErrorMessage:SetText(NO_GUILDBANK_TABS);
GuildBankErrorMessage:Show();
end
else
local _, _, _, canDeposit, numWithdrawals = GetGuildBankTabInfo(tab);
if ( not canDeposit and numWithdrawals == 0 ) then
GuildBankFrame_DesaturateColumns(1);
else
GuildBankFrame_DesaturateColumns(nil);
end
GuildBankFrame_ShowColumns()
GuildBankFrameBuyInfo:Hide();
GuildBankErrorMessage:Hide();
end
-- Update the tab items
local button, index, column;
local texture, itemCount, locked;
for i=1, MAX_GUILDBANK_SLOTS_PER_TAB do
index = mod(i, NUM_SLOTS_PER_GUILDBANK_GROUP);
if ( index == 0 ) then
index = NUM_SLOTS_PER_GUILDBANK_GROUP;
end
column = ceil((i-0.5)/NUM_SLOTS_PER_GUILDBANK_GROUP);
button = _G["GuildBankColumn"..column.."Button"..index];
button:SetID(i);
texture, itemCount, locked = GetGuildBankItemInfo(tab, i);
SetItemButtonTexture(button, texture);
SetItemButtonCount(button, itemCount);
SetItemButtonDesaturated(button, locked, 0.5, 0.5, 0.5);
end
MoneyFrame_Update("GuildBankMoneyFrame", GetGuildBankMoney());
if ( CanWithdrawGuildBankMoney() ) then
GuildBankFrameWithdrawButton:Enable();
else
GuildBankFrameWithdrawButton:Disable();
end
elseif ( GuildBankFrame.mode == "log" or GuildBankFrame.mode == "moneylog" ) then
GuildBankFrame_HideColumns();
GuildBankFrameBuyInfo:Hide();
GuildBankInfo:Hide();
if ( GuildBankFrame.noViewableTabs and GuildBankFrame.mode == "log" ) then
GuildBankErrorMessage:SetText(NO_VIEWABLE_GUILDBANK_LOGS);
GuildBankErrorMessage:Show();
GuildBankFrameLog:Hide();
else
GuildBankErrorMessage:Hide();
GuildBankFrameLog:Show();
end
elseif ( GuildBankFrame.mode == "tabinfo" ) then
GuildBankFrame_HideColumns();
GuildBankErrorMessage:Hide();
GuildBankFrameBuyInfo:Hide();
GuildBankFrameLog:Hide();
GuildBankInfo:Show();
end
--Update remaining money
GuildBankFrame_UpdateWithdrawMoney();
end
function GuildBankFrameTab_OnClick(tab, id, doNotUpdate)
PanelTemplates_SetTab(GuildBankFrame, id);
if ( id == 1 ) then
--Bank
GuildBankFrame.mode = "bank";
if ( not doNotUpdate ) then
QueryGuildBankTab(GetCurrentGuildBankTab());
end
elseif ( id == 2 ) then
--Log
GuildBankMessageFrame:Clear();
GuildBankTransactionsScrollFrame:Hide();
GuildBankFrame.mode = "log";
if ( not doNotUpdate ) then
QueryGuildBankLog(GetCurrentGuildBankTab());
end
GuildBankTransactionsScrollFrameScrollBar:SetValue(0);
elseif ( id == 3 ) then
--Money log
GuildBankMessageFrame:Clear();
GuildBankTransactionsScrollFrame:Hide();
GuildBankFrame.mode = "moneylog";
if ( not doNotUpdate ) then
QueryGuildBankLog(MAX_GUILDBANK_TABS + 1);
end
GuildBankTransactionsScrollFrameScrollBar:SetValue(0);
else
--Tab Info
GuildBankFrame.mode = "tabinfo";
if ( not doNotUpdate ) then
QueryGuildBankText(GetCurrentGuildBankTab());
end
end
--Call this to gray out tabs or activate them
GuildBankFrame_UpdateTabs();
if ( not doNotUpdate ) then
GuildBankFrame_Update();
end
PlaySound("igCharacterInfoTab");
end
function GuildBankFrame_UpdateTabBuyingInfo()
local tabCost = GetGuildBankTabCost();
local numTabs = GetNumGuildBankTabs();
GuildBankFrameBuyInfoNumTabsPurchasedText:SetText(format(NUM_GUILDBANK_TABS_PURCHASED, numTabs, MAX_GUILDBANK_TABS));
if ( not tabCost ) then
--You've bought all the tabs
GuildBankTab_OnClick(GuildBankTab1, "LeftButton", 1);
else
if( GetMoney() >= tabCost or (GetMoney() + GetGuildBankMoney()) >= tabCost ) then
SetMoneyFrameColor("GuildBankFrameTabCostMoneyFrame", "white");
GuildBankFramePurchaseButton:Enable();
else
SetMoneyFrameColor("GuildBankFrameTabCostMoneyFrame", "red");
GuildBankFramePurchaseButton:Disable();
end
GuildBankTab_OnClick(_G["GuildBankTab" .. numTabs+1], "LeftButton", numTabs+1);
MoneyFrame_Update("GuildBankFrameTabCostMoneyFrame", tabCost);
end
end
function GuildBankFrame_UpdateTabs()
local tab, iconTexture, tabButton;
local name, icon, isViewable, canDeposit, numWithdrawals, remainingWithdrawals;
local numTabs = GetNumGuildBankTabs();
local currentTab = GetCurrentGuildBankTab();
local tabToBuyIndex = numTabs+1;
local unviewableCount = 0;
local disableAll = nil;
local updateAgain = nil;
local isLocked, titleText;
local withdrawalText, withdrawalStackCount;
-- Disable and gray out all tabs if in the moneyLog since the tab is irrelevant
if ( GuildBankFrame.mode == "moneylog" ) then
disableAll = 1;
end
for i=1, MAX_GUILDBANK_TABS do
tab = _G["GuildBankTab"..i];
tabButton = _G["GuildBankTab"..i.."Button"];
name, icon, isViewable, canDeposit, numWithdrawals, remainingWithdrawals = GetGuildBankTabInfo(i);
iconTexture = _G["GuildBankTab"..i.."ButtonIconTexture"];
if ( not name or name == "" ) then
name = format(GUILDBANK_TAB_NUMBER, i);
end
if ( i == tabToBuyIndex and IsGuildLeader() ) then
iconTexture:SetTexture("Interface\\GuildBankFrame\\UI-GuildBankFrame-NewTab");
tabButton.tooltip = BUY_GUILDBANK_TAB;
tab:Show();
if ( disableAll or GuildBankFrame.mode == "log" or GuildBankFrame.mode == "tabinfo" ) then
tabButton:SetChecked(nil);
SetDesaturation(iconTexture, 1);
tabButton:SetButtonState("NORMAL");
tabButton:Disable();
if ( GuildBankFrame.mode == "log" and i == currentTab and numTabs > 0 ) then
SetCurrentGuildBankTab(1);
updateAgain = 1;
end
else
if ( i == currentTab ) then
tabButton:SetChecked(1);
tabButton:Disable();
SetDesaturation(iconTexture, nil);
titleText = BUY_GUILDBANK_TAB;
else
tabButton:SetChecked(nil);
tabButton:Enable();
SetDesaturation(iconTexture, nil);
end
end
elseif ( i >= tabToBuyIndex ) then
tab:Hide();
else
iconTexture:SetTexture(icon);
tab:Show();
if ( isViewable ) then
tabButton.tooltip = name;
if ( i == currentTab ) then
if ( disableAll ) then
tabButton:SetChecked(nil);
else
tabButton:SetChecked(1);
tabButton:Enable();
end
withdrawalText = name;
titleText = name;
else
tabButton:SetChecked(nil);
tabButton:Enable();
end
if ( disableAll ) then
tabButton:Disable();
SetDesaturation(iconTexture, 1);
else
SetDesaturation(iconTexture, nil);
end
else
unviewableCount = unviewableCount+1;
tabButton:Disable();
SetDesaturation(iconTexture, 1);
tabButton:SetChecked(nil);
end
end
if ( unviewableCount == numTabs and not IsGuildLeader() ) then
--Can't view any tabs so hide everything
GuildBankFrame.noViewableTabs = 1;
else
GuildBankFrame.noViewableTabs = nil;
end
if ( updateAgain ) then
GuildBankFrame_UpdateTabs();
end
end
-- Set Title
if ( GuildBankFrame.mode == "moneylog" ) then
titleText = GUILD_BANK_MONEY_LOG;
withdrawalText = nil;
elseif ( GuildBankFrame.mode == "log" ) then
if ( titleText ) then
titleText = format(GUILDBANK_LOG_TITLE_FORMAT, titleText);
end
elseif ( GuildBankFrame.mode == "tabinfo" ) then
withdrawalText = nil;
if ( titleText ) then
titleText = format(GUILDBANK_INFO_TITLE_FORMAT, titleText);
end
end
--Get selected tab info
name, icon, isViewable, canDeposit, numWithdrawals, remainingWithdrawals = GetGuildBankTabInfo(currentTab);
if ( titleText and (GuildBankFrame.mode ~= "moneylog" and titleText ~= BUY_GUILDBANK_TAB) ) then
local access;
if ( not canDeposit and numWithdrawals == 0 ) then
access = RED_FONT_COLOR_CODE.."("..GUILDBANK_TAB_LOCKED..")"..FONT_COLOR_CODE_CLOSE;
elseif ( not canDeposit ) then
access = RED_FONT_COLOR_CODE.."("..GUILDBANK_TAB_WITHDRAW_ONLY..")"..FONT_COLOR_CODE_CLOSE;
elseif ( numWithdrawals == 0 ) then
access = RED_FONT_COLOR_CODE.."("..GUILDBANK_TAB_DEPOSIT_ONLY..")"..FONT_COLOR_CODE_CLOSE;
else
access = GREEN_FONT_COLOR_CODE.."("..GUILDBANK_TAB_FULL_ACCESS..")"..FONT_COLOR_CODE_CLOSE;
end
titleText = titleText.." "..access;
end
if ( titleText ) then
GuildBankTabTitle:SetText(titleText);
GuildBankTabTitleBackground:SetWidth(GuildBankTabTitle:GetWidth()+20);
GuildBankTabTitle:Show();
GuildBankTabTitleBackground:Show();
GuildBankTabTitleBackgroundLeft:Show();
GuildBankTabTitleBackgroundRight:Show();
else
GuildBankTabTitle:Hide();
GuildBankTabTitleBackground:Hide();
GuildBankTabTitleBackgroundLeft:Hide();
GuildBankTabTitleBackgroundRight:Hide();
end
if ( withdrawalText ) then
local stackString;
if ( remainingWithdrawals > 0 ) then
stackString = format(STACKS, remainingWithdrawals);
elseif ( remainingWithdrawals == 0 ) then
stackString = NONE;
else
stackString = UNLIMITED;
end
GuildBankLimitLabel:SetText(format(GUILDBANK_REMAINING_MONEY, withdrawalText, stackString));
GuildBankTabLimitBackground:SetWidth(GuildBankLimitLabel:GetWidth()+20);
--If the tab name is too long then reanchor the withdraw box so it's not longer centered
if ( GuildBankLimitLabel:GetWidth() > 298 ) then
GuildBankTabLimitBackground:ClearAllPoints();
GuildBankTabLimitBackground:SetPoint("RIGHT", GuildBankFrameWithdrawButton, "LEFT", -14, -1);
else
GuildBankTabLimitBackground:ClearAllPoints();
GuildBankTabLimitBackground:SetPoint("TOP", "GuildBankFrame", "TOP", 6, -388);
end
GuildBankLimitLabel:Show();
GuildBankTabLimitBackground:Show();
GuildBankTabLimitBackgroundLeft:Show();
GuildBankTabLimitBackgroundRight:Show();
else
GuildBankLimitLabel:Hide();
GuildBankTabLimitBackground:Hide();
GuildBankTabLimitBackgroundLeft:Hide();
GuildBankTabLimitBackgroundRight:Hide();
end
end
function GuildBankTab_OnClick(self, mouseButton, currentTab)
if ( GuildBankInfo:IsShown() ) then
GuildBankInfoSaveButton:Click();
end
if ( not currentTab ) then
currentTab = self:GetParent():GetID();
end
SetCurrentGuildBankTab(currentTab);
GuildBankFrame_UpdateTabs();
if ( IsGuildLeader() and mouseButton == "RightButton" and currentTab ~= (GetNumGuildBankTabs() + 1) ) then
--Show the popup if it's a right click
GuildBankPopupFrame:Show();
GuildBankPopupFrame_Update(currentTab);
end
GuildBankFrame_Update();
if ( GuildBankFrameLog:IsShown() ) then
if ( GuildBankFrame.mode == "log" ) then
QueryGuildBankTab(currentTab); --Need this to get the number of withdrawals left for this tab
QueryGuildBankLog(currentTab);
GuildBankFrame_UpdateLog();
else
QueryGuildBankLog(MAX_GUILDBANK_TABS+1);
GuildBankFrame_UpdateMoneyLog();
end
elseif ( GuildBankInfo:IsShown() ) then
QueryGuildBankText(currentTab);
else
QueryGuildBankTab(currentTab);
end
end
function GuildBankFrame_HideColumns()
if ( not GuildBankColumn1:IsShown() ) then
return;
end
for i=1, NUM_GUILDBANK_COLUMNS do
_G["GuildBankColumn"..i]:Hide();
end
end
function GuildBankFrame_ShowColumns()
if ( GuildBankColumn1:IsShown() ) then
return;
end
for i=1, NUM_GUILDBANK_COLUMNS do
_G["GuildBankColumn"..i]:Show();
end
end
function GuildBankFrame_DesaturateColumns(isDesaturated)
for i=1, NUM_GUILDBANK_COLUMNS do
SetDesaturation(_G["GuildBankColumn"..i.."Background"], isDesaturated);
end
end
function GuildBankItemButton_OnLoad(self)
self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
self:RegisterForDrag("LeftButton");
self.SplitStack = function(button, split)
SplitGuildBankItem(GetCurrentGuildBankTab(), button:GetID(), split);
end
self.UpdateTooltip = GuildBankItemButton_OnEnter;
end
function GuildBankItemButton_OnEnter(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetGuildBankItem(GetCurrentGuildBankTab(), self:GetID());
end
function GuildBankFrame_UpdateLog()
local tab = GetCurrentGuildBankTab();
local numTransactions = GetNumGuildBankTransactions(tab);
local type, name, itemLink, count, tab1, tab2, year, month, day, hour;
local msg;
GuildBankMessageFrame:Clear();
for i=1, numTransactions, 1 do
type, name, itemLink, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction(tab, i);
if ( not name ) then
name = UNKNOWN;
end
name = NORMAL_FONT_COLOR_CODE..name..FONT_COLOR_CODE_CLOSE;
if ( type == "deposit" ) then
msg = format(GUILDBANK_DEPOSIT_FORMAT, name, itemLink);
if ( count > 1 ) then
msg = msg..format(GUILDBANK_LOG_QUANTITY, count);
end
elseif ( type == "withdraw" ) then
msg = format(GUILDBANK_WITHDRAW_FORMAT, name, itemLink);
if ( count > 1 ) then
msg = msg..format(GUILDBANK_LOG_QUANTITY, count);
end
elseif ( type == "move" ) then
msg = format(GUILDBANK_MOVE_FORMAT, name, itemLink, count, GetGuildBankTabInfo(tab1), GetGuildBankTabInfo(tab2));
end
if ( msg ) then
GuildBankMessageFrame:AddMessage( msg..GUILD_BANK_LOG_TIME_PREPEND..format(GUILD_BANK_LOG_TIME, RecentTimeDate(year, month, day, hour)) );
end
end
FauxScrollFrame_Update(GuildBankTransactionsScrollFrame, numTransactions, MAX_TRANSACTIONS_SHOWN, GUILDBANK_TRANSACTION_HEIGHT );
end
function GuildBankFrame_UpdateMoneyLog()
local numTransactions = GetNumGuildBankMoneyTransactions();
local type, name, amount, year, month, day, hour;
local msg;
local money;
GuildBankMessageFrame:Clear();
for i=1, numTransactions, 1 do
type, name, amount, year, month, day, hour = GetGuildBankMoneyTransaction(i);
if ( not name ) then
name = UNKNOWN;
end
name = NORMAL_FONT_COLOR_CODE..name..FONT_COLOR_CODE_CLOSE;
money = GetDenominationsFromCopper(amount);
if ( type == "deposit" ) then
msg = format(GUILDBANK_DEPOSIT_MONEY_FORMAT, name, money);
elseif ( type == "withdraw" ) then
msg = format(GUILDBANK_WITHDRAW_MONEY_FORMAT, name, money);
elseif ( type == "repair" ) then
msg = format(GUILDBANK_REPAIR_MONEY_FORMAT, name, money);
elseif ( type == "withdrawForTab" ) then
msg = format(GUILDBANK_WITHDRAWFORTAB_MONEY_FORMAT, name, money);
elseif ( type == "buyTab" ) then
msg = format(GUILDBANK_BUYTAB_MONEY_FORMAT, name, money);
end
GuildBankMessageFrame:AddMessage(msg..GUILD_BANK_LOG_TIME_PREPEND..format(GUILD_BANK_LOG_TIME, RecentTimeDate(year, month, day, hour)));
end
FauxScrollFrame_Update(GuildBankTransactionsScrollFrame, numTransactions, MAX_TRANSACTIONS_SHOWN, GUILDBANK_TRANSACTION_HEIGHT );
end
function GuildBankLogScroll()
local offset = FauxScrollFrame_GetOffset(GuildBankTransactionsScrollFrame);
local numTransactions = 0;
if ( GuildBankFrame.mode == "log" ) then
numTransactions = GetNumGuildBankTransactions(GetCurrentGuildBankTab());
elseif ( GuildBankFrame.mode == "moneylog" ) then
numTransactions = GetNumGuildBankMoneyTransactions();
end
GuildBankMessageFrame:SetScrollOffset(offset);
FauxScrollFrame_Update(GuildBankTransactionsScrollFrame, numTransactions, MAX_TRANSACTIONS_SHOWN, GUILDBANK_TRANSACTION_HEIGHT );
end
function IsTabViewable(tab)
GuildBankFrame.nextAvailableTab = nil;
local view = false;
for i=1, MAX_GUILDBANK_TABS do
local _, _, isViewable = GetGuildBankTabInfo(i);
if ( isViewable ) then
if ( not GuildBankFrame.nextAvailableTab ) then
GuildBankFrame.nextAvailableTab = i;
end
if ( i == tab ) then
view = true;
end
end
end
return view;
end
function GuildBankFrame_UpdateWithdrawMoney()
local withdrawLimit = GetGuildBankWithdrawMoney();
if ( withdrawLimit >= 0 ) then
local amount;
if ( (not CanGuildBankRepair() and not CanWithdrawGuildBankMoney()) or (CanGuildBankRepair() and not CanWithdrawGuildBankMoney()) ) then
amount = 0;
else
amount = GetGuildBankMoney();
end
withdrawLimit = min(withdrawLimit, amount);
MoneyFrame_Update("GuildBankWithdrawMoneyFrame", withdrawLimit);
GuildBankMoneyUnlimitedLabel:Hide();
GuildBankWithdrawMoneyFrame:Show();
else
GuildBankMoneyUnlimitedLabel:Show();
GuildBankWithdrawMoneyFrame:Hide();
end
end
function GuildBankFrame_UpdateTabard()
--Set the tabard images
local tabardBackgroundUpper, tabardBackgroundLower, tabardEmblemUpper, tabardEmblemLower, tabardBorderUpper, tabardBorderLower = GetGuildTabardFileNames();
if ( not tabardEmblemUpper ) then
tabardBackgroundUpper = "Textures\\GuildEmblems\\Background_49_TU_U";
tabardBackgroundLower = "Textures\\GuildEmblems\\Background_49_TL_U";
end
GuildBankEmblemBackgroundUL:SetTexture(tabardBackgroundUpper);
GuildBankEmblemBackgroundUR:SetTexture(tabardBackgroundUpper);
GuildBankEmblemBackgroundBL:SetTexture(tabardBackgroundLower);
GuildBankEmblemBackgroundBR:SetTexture(tabardBackgroundLower);
GuildBankEmblemUL:SetTexture(tabardEmblemUpper);
GuildBankEmblemUR:SetTexture(tabardEmblemUpper);
GuildBankEmblemBL:SetTexture(tabardEmblemLower);
GuildBankEmblemBR:SetTexture(tabardEmblemLower);
GuildBankEmblemBorderUL:SetTexture(tabardBorderUpper);
GuildBankEmblemBorderUR:SetTexture(tabardBorderUpper);
GuildBankEmblemBorderBL:SetTexture(tabardBorderLower);
GuildBankEmblemBorderBR:SetTexture(tabardBorderLower);
end
function GuildBankFrame_UpdateTabInfo(tab)
local text = GetGuildBankText(tab);
if ( text ) then
GuildBankTabInfoEditBox.text = text;
GuildBankTabInfoEditBox:SetText(text);
else
GuildBankTabInfoEditBox:SetText("");
end
end
--Popup functions
function GuildBankPopupFrame_Update(tab)
local numguildBankIcons = GetNumMacroItemIcons();
local guildBankPopupIcon, guildBankPopupButton;
local guildBankPopupOffset = FauxScrollFrame_GetOffset(GuildBankPopupScrollFrame);
local index;
local _, tabTexture = GetGuildBankTabInfo(GetCurrentGuildBankTab());
-- Icon list
local texture;
for i=1, NUM_GUILDBANK_ICONS_SHOWN do
guildBankPopupIcon = _G["GuildBankPopupButton"..i.."Icon"];
guildBankPopupButton = _G["GuildBankPopupButton"..i];
index = (guildBankPopupOffset * NUM_GUILDBANK_ICONS_PER_ROW) + i;
texture = GetMacroItemIconInfo(index);
if ( index <= numguildBankIcons ) then
guildBankPopupIcon:SetTexture(texture);
guildBankPopupButton:Show();
else
guildBankPopupIcon:SetTexture("");
guildBankPopupButton:Hide();
end
if ( GuildBankPopupFrame.selectedIcon ) then
if ( index == GuildBankPopupFrame.selectedIcon ) then
guildBankPopupButton:SetChecked(1);
else
guildBankPopupButton:SetChecked(nil);
end
elseif ( tabTexture == texture ) then
guildBankPopupButton:SetChecked(1);
GuildBankPopupFrame.selectedIcon = index;
else
guildBankPopupButton:SetChecked(nil);
end
end
--Only do this if the player hasn't clicked on an icon or the icon is not visible
if ( not GuildBankPopupFrame.selectedIcon ) then
for i=1, numguildBankIcons do
texture = GetMacroItemIconInfo(i);
if ( tabTexture == texture ) then
GuildBankPopupFrame.selectedIcon = i;
break;
end
end
end
-- Scrollbar stuff
FauxScrollFrame_Update(GuildBankPopupScrollFrame, ceil(numguildBankIcons / NUM_GUILDBANK_ICONS_PER_ROW) , NUM_GUILDBANK_ICON_ROWS, GUILDBANK_ICON_ROW_HEIGHT );
end
function GuildBankPopupFrame_OnShow(self)
local name = GetGuildBankTabInfo(GetCurrentGuildBankTab());
if ( not name or name == "" ) then
name = format(GUILDBANK_TAB_NUMBER, GetCurrentGuildBankTab());
end
GuildBankPopupEditBox:SetText(name);
GuildBankPopupFrame.selectedIcon = nil;
end
function GuildBankPopupButton_OnClick(self, button)
local offset = FauxScrollFrame_GetOffset(GuildBankPopupScrollFrame);
local index = (offset * NUM_GUILDBANK_ICONS_PER_ROW)+self:GetID();
GuildBankPopupFrame.selectedIcon = index;
GuildBankPopupFrame_Update(GetCurrentGuildBankTab());
end
function GuildBankPopupOkayButton_OnClick(self)
local name = GuildBankPopupEditBox:GetText();
local tab = GetCurrentGuildBankTab();
if ( not name or name == "" ) then
name = format(GUILDBANK_TAB_NUMBER, tab);
end
SetGuildBankTabInfo(tab, name, GuildBankPopupFrame.selectedIcon);
GuildBankPopupFrame:Hide();
end
function GuildBankPopupFrame_CancelEdit()
GuildBankPopupFrame:Hide();
end