-
Notifications
You must be signed in to change notification settings - Fork 0
/
Banana.lua
1531 lines (1352 loc) · 46.8 KB
/
Banana.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
BANANA_SYMBOL_COLOR1 = "00f7f26c";
BANANA_SYMBOL_COLOR2 = "00f69218";
BANANA_SYMBOL_COLOR3 = "00cb32dd";
BANANA_SYMBOL_COLOR4 = "000fb20a";
BANANA_SYMBOL_COLOR5 = "008cb0c5";
BANANA_SYMBOL_COLOR6 = "00007aff";
BANANA_SYMBOL_COLOR7 = "00d7422e";
BANANA_SYMBOL_COLOR8 = "00e7e4d9";
BANANA_PRINT_COLOR = "00c0ffc0";
BANANA_PRINT_FORMAT = "|c"..BANANA_PRINT_COLOR.."[|c"..BANANA_SYMBOL_COLOR4.."Banana|c"..BANANA_SYMBOL_COLOR4.."Bar|r|c"..BANANA_PRINT_COLOR.."] %s|r";
BINDING_HEADER_BANANA_PLUGINNAME = "BananaBar Raid Target Symbols";
BINDING_NAME_BANANA_TARGET_SYMBOL1 = "Target Symbol 1 ("..RAID_TARGET_1..")";
BINDING_NAME_BANANA_TARGET_SYMBOL2 = "Target Symbol 2 ("..RAID_TARGET_2..")";
BINDING_NAME_BANANA_TARGET_SYMBOL3 = "Target Symbol 3 ("..RAID_TARGET_3..")";
BINDING_NAME_BANANA_TARGET_SYMBOL4 = "Target Symbol 4 ("..RAID_TARGET_4..")";
BINDING_NAME_BANANA_TARGET_SYMBOL5 = "Target Symbol 5 ("..RAID_TARGET_5..")";
BINDING_NAME_BANANA_TARGET_SYMBOL6 = "Target Symbol 6 ("..RAID_TARGET_6..")";
BINDING_NAME_BANANA_TARGET_SYMBOL7 = "Target Symbol 7 ("..RAID_TARGET_7..")";
BINDING_NAME_BANANA_TARGET_SYMBOL8 = "Target Symbol 8 ("..RAID_TARGET_8..")";
BINDING_NAME_BANANA_TARGET_SYMBOL9 = "Target Symbol 9 (Huntersmark)";
BINDING_NAME_BANANA_SETTARGET_SYMBOL1 = "Set Symbol "..RAID_TARGET_1.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL2 = "Set Symbol "..RAID_TARGET_2.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL3 = "Set Symbol "..RAID_TARGET_3.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL4 = "Set Symbol "..RAID_TARGET_4.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL5 = "Set Symbol "..RAID_TARGET_5.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL6 = "Set Symbol "..RAID_TARGET_6.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL7 = "Set Symbol "..RAID_TARGET_7.." (w/ mouseover)"
BINDING_NAME_BANANA_SETTARGET_SYMBOL8 = "Set Symbol "..RAID_TARGET_8.." (w/ mouseover)"
--"Interface\TargetingFrame\UI-RaidTargetingIcons"
local snipershot = "Interface\\Icons\\Ability_Hunter_SniperShot";
BANANA_HIDE_UNUSED_BUTTONS = nil;
BANANA_BUTTON_LAYOUT = nil;
BANANA_BUTTON_SCALE = nil;
BANANA_HIDE_BUTTON_FRAMES = nil;
BANANA_GREY_OUT_DEATH = nil;
BANANA_POS = nil;
BANANA_SHOW_IN_RAID = nil;
BANANA_SHOW_IN_PARTY = nil;
BANANA_SHOW_OUT_OF_GROUP = nil;
BANANA_SHOW_EXTRA_INFO = nil;
BANANA_SHOW_PRINT_MESSAGES = nil;
BANANA_SHOW_DEBUG_MESSAGES = nil;
SLASH_BANANA1 = "/bananabar";
SLASH_BANANA2 = "/bb";
SLASH_BANANABAR1 = "/banana";
SLASH_BANANABAR2 = "/bbr";
local BANANA_READY = nil;
local raidTargetStatus =
{
[1] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[2] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[3] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[4] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[5] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[6] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[7] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[8] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
[9] = {["Count"] = 0,["Target"] = nil,["Players"] = {},},
}
BANANA_ICON = nil;
function Banana_InitArrays()
if not BANANA_ICON then
BANANA_ICON = {};
local i;
for i = 1, 9, 1 do
BANANA_ICON[i] = {};
BANANA_ICON[i].FrameIcon = getglobal("RaidTargetFrame"..i.."ButtonIcon");
BANANA_ICON[i].FrameButton = getglobal("RaidTargetFrame"..i.."Button");
BANANA_ICON[i].FrameFlash = getglobal("RaidTargetFrame"..i.."ButtonFlash");
BANANA_ICON[i].FrameHotKey = getglobal("RaidTargetFrame"..i.."ButtonHotKey");
BANANA_ICON[i].FrameName = getglobal("RaidTargetFrame"..i.."ButtonName");
BANANA_ICON[i].FrameCount = getglobal("RaidTargetFrame"..i.."ButtonCount");
BANANA_ICON[i].FrameNormalTexture = getglobal("RaidTargetFrame"..i.."ButtonNormalTexture");
BANANA_ICON[i].FrameMobName = getglobal("RaidTargetFrame"..i.."ButtonMobName");
BANANA_ICON[i].FrameTargetSymbol = getglobal("RaidTargetFrame"..i.."ButtonTargetSymbol");
BANANA_ICON[i].Count = 0;
BANANA_ICON[i].Target = nil;
BANANA_ICON[i].Players = {};
BANANA_ICON[i].Info = nil;
BANANA_ICON[i].Debuff = nil;
BANANA_ICON[i].MovingButton = 1;
BANANA_ICON[i].IsDeath = nil;
BANANA_ICON[i].MyTarget = nil;
end
end
end
function Banana_UpdateButton(index)
if BANANA_ICON[index].MyTarget == 1 then
BANANA_ICON[index].FrameButton:SetChecked(1);
else
BANANA_ICON[index].FrameButton:SetChecked(0);
end
if BANANA_ICON[index].IsDeath == 1 and BANANA_GREY_OUT_DEATH == 1 then
BANANA_ICON[index].FrameButton:SetAlpha(0.33);
else
if BANANA_HIDE_UNUSED_BUTTONS == 1 and (not raidTargetStatus[index].Target) then
Banana_HideButton(BANANA_ICON[index].FrameButton);
else
BANANA_ICON[index].FrameButton:SetAlpha(1);
BANANA_ICON[index].FrameButton:Show();
end
end
if BANANA_HIDE_BUTTON_FRAMES == 1 then
BANANA_ICON[index].FrameNormalTexture:Hide();
else
BANANA_ICON[index].FrameNormalTexture:Show();
end
if raidTargetStatus[index].Target and BANANA_SHOW_EXTRA_INFO == 1 then
BANANA_ICON[index].FrameMobName:SetText(raidTargetStatus[index].Target);
BANANA_ICON[index].FrameMobName:Show();
if raidTargetStatus[index].TargetSymbol and raidTargetStatus[index].TargetSymbol ~= 0 then
Banana_TexCoord(BANANA_ICON[index].FrameTargetSymbol,raidTargetStatus[index].TargetSymbol)
BANANA_ICON[index].FrameTargetSymbol:Show();
else
BANANA_ICON[index].FrameTargetSymbol:Hide();
end
else
BANANA_ICON[index].FrameMobName:SetText();
BANANA_ICON[index].FrameMobName:Hide();
BANANA_ICON[index].FrameTargetSymbol:Hide();
end
end
function Banana_Print(msg)
if not DEFAULT_CHAT_FRAME then
return
end
local strx = string.format(BANANA_PRINT_FORMAT,tostring(msg));
if BANANA_SHOW_PRINT_MESSAGES == 1 then
DEFAULT_CHAT_FRAME:AddMessage(strx);
end
end
function Banana_Debug(msg)
if not DEFAULT_CHAT_FRAME then
return
end
local strx = string.format(BANANA_PRINT_FORMAT,tostring(msg));
if BANANA_SHOW_DEBUG_MESSAGES == 1 then
DEFAULT_CHAT_FRAME:AddMessage(strx);
end
end
function Banana_OnLoad()
this:RegisterEvent("PLAYER_ENTERING_WORLD");
SlashCmdList["BANANA"] = Banana_Command;
SlashCmdList["BANANABAR"] = Banana_Command;
end
function Banana_OnEvent()
if ( event == "PLAYER_ENTERING_WORLD" ) then
if not BANANA_READY then
Banana_InitArrays();
end
Banana_Print("Banana Raid Symbols loaded. Type /bb, /bbr, /banana or /bananabar to open config panel.");
if not BANANA_SHOW_EXTRA_INFO then
Banana_Print("First start of BananaBar detected, showing config window.");
UIDropDownMenu_Initialize(BananaConfigFrameComboBoxLayout, Banana_ComboBoxLayout_Initialize);
Banana_ResetAll()
BananaConfigFrame:Show();
else
if not BANANA_READY then
Banana_UpdateScale();
Banana_Layout();
Banana_ReloadFramePositions();
UIDropDownMenu_Initialize(BananaConfigFrameComboBoxLayout, Banana_ComboBoxLayout_Initialize);
Banana_UpdateDialogFromVariables();
end
end
BANANA_READY = true;
end
end
local ticker = 0;
local debugticker = 0;
function Banana_OnUpdate(elapsed)
ticker = ticker + elapsed;
if ticker > 0.1 then
ticker = ticker -0.1;
Banana_OnUpdateTick();
end
if ticker > 0.1 then
ticker = 0;
end
debugticker = debugticker + elapsed;
if debugticker > 1 then
debugticker = debugticker -1;
--Banana_OnUpdateDebug();
end
if debugticker > 1 then
debugticker = 0;
end
end
BANANA_CLEAR_PLAYER_SYMBOL_TRY = 1;
function Banana_OnUpdateTick()
if BANANA_READY then
Banana_UpdateStatus();
Banana_CtRaMainTankUpdate();
end
if BANANA_CLEAR_PLAYER_SYMBOL then
if BANANA_CLEAR_PLAYER_SYMBOL > 0 then
BANANA_CLEAR_PLAYER_SYMBOL = BANANA_CLEAR_PLAYER_SYMBOL - 1;
if Banana_GetSymbol("PLAYER") then
Banana_Print("Clearing own symbol again try "..BANANA_CLEAR_PLAYER_SYMBOL_TRY.." (fix for a wow bug)");
BANANA_CLEAR_PLAYER_SYMBOL_TRY = BANANA_CLEAR_PLAYER_SYMBOL_TRY+1;
Banana_SetSymbol("PLAYER",0);
else
BANANA_CLEAR_PLAYER_SYMBOL_TRY = 1;
end
if BANANA_CLEAR_PLAYER_SYMBOL == 0 and Banana_GetSymbol("PLAYER") then
Banana_Print("Clearing own symbol failed");
BANANA_CLEAR_PLAYER_SYMBOL_TRY = 1;
end
end
end
end
--/script Banana_TexCoord(RaidTargetFrame2ButtonTargetSymbol,5)
function Banana_TexCoord(icon,index)
if index == 9 then
icon:SetTexture("Interface\\AddOns\\Banana\\Images\\HuntermarkArrow");
icon:SetTexCoord(0, 1, 0, 1);
return;
end
local button = UnitPopupButtons["RAID_TARGET_"..index];
local x1 = button.tCoordLeft;
local y1 = button.tCoordTop;
local x2 = button.tCoordRight;
local y2 = button.tCoordBottom;
icon:SetTexture("Interface/TargetingFrame/UI-RaidTargetingIcons");
icon:SetTexCoord(x1, x2, y1, y2);
end
function Banana_IndexFromButtonName(name)
return tonumber(string.sub(name,16,-7));
end
function Banana_RaidTargetButtonOnLoad()
local index = Banana_IndexFromButtonName(this:GetName());
local icon = getglobal(this:GetName().."Icon");
Banana_TexCoord(icon,index)
end
function Banana_CanSetSymbols()
if GetNumRaidMembers() > 0 then
if IsRaidOfficer() or IsRaidLeader() then
return 1;
end
end
if GetNumPartyMembers() > 0 then
if IsPartyLeader() then
return 1;
end
end
return nil;
end
function Banana_CanUseSymbols()
if GetNumRaidMembers() > 0 then
return 1;
end
if GetNumPartyMembers() > 0 then
return 1;
end
return nil;
end
function Banana_ButtonOnClick(mousebutton)
local index = tonumber(string.sub(this:GetName(),16,-7));
if (IsControlKeyDown()) and mousebutton == "LeftButton" then
Banana_SetRaidSymbol(index);
return;
end
if (not IsControlKeyDown()) and mousebutton == "LeftButton" then
if Banana_CanUseSymbols() then
Banana_TargetRaidSymbol(index);
else
Banana_PlayError();
Banana_Print("Raid targets can only be used if you are in raid or party.");
Banana_Print("Type /bb, /bbr or /bananabar to open config window and hide unused buttons.");
end
return;
end
if (IsControlKeyDown()) and mousebutton == "RightButton" then
--moving
return;
end
Banana_Print("Use Ctrl+RightMouseButtonc to move buttons");
end
local movingbutton = nil;
function Banana_ButtonOnMouseDown(mousebutton)
if IsControlKeyDown() and mousebutton == "RightButton" then
local index = Banana_IndexFromButtonName(this:GetName());
if not movingbutton then
if getglobal("RaidTargetFrame"..BANANA_ICON[index].MovingButton.."Button"):IsMovable() then
Banana_Debug("Start Moving Button "..index);
movingbutton = index;
getglobal("RaidTargetFrame"..BANANA_ICON[index].MovingButton.."Button"):StartMoving();
end
end
end
if (not IsControlKeyDown()) and mousebutton == "RightButton" then
Banana_RemoveRaidSymbol(index);
end
end
function Banana_ButtonOnMouseUp(mousebutton)
local index = tonumber(string.sub(this:GetName(),16,-7));
if movingbutton then
Banana_Debug("Stop Moving Button "..movingbutton);
getglobal("RaidTargetFrame"..BANANA_ICON[movingbutton].MovingButton.."Button"):StopMovingOrSizing();
getglobal("RaidTargetFrame"..BANANA_ICON[movingbutton].MovingButton.."Button"):SetUserPlaced(false);
Banana_SaveFramePos(getglobal("RaidTargetFrame"..BANANA_ICON[movingbutton].MovingButton.."Button"));
movingbutton = nil;
end
end
function Banana_ButtonOnEnter()
if ( GetCVar("UberTooltips") == "1" ) then
GameTooltip_SetDefaultAnchor(GameTooltip, this);
else
GameTooltip:SetOwner(button, "ANCHOR_RIGHT");
end
local index = tonumber(string.sub(this:GetName(),16,-7));
if (raidTargetStatus[index].Target) then
GameTooltip:AddLine(raidTargetStatus[index].Target);
if raidTargetStatus[index].Count > 0 then
GameTooltip:AddLine(raidTargetStatus[index].Count.." Players",0.5,0.5,0.5);
local loop;
for loop = 1,raidTargetStatus[index].Count,1 do
GameTooltip:AddLine(raidTargetStatus[index].Players[loop].Name,raidTargetStatus[index].Players[loop].Color.r,raidTargetStatus[index].Players[loop].Color.g,raidTargetStatus[index].Players[loop].Color.b);
end
end
GameTooltip:Show();
else
GameTooltip:SetText("Not used\n/bananabar to open config window\nCtrl+RightMouseButton to move buttons");
end
end
function Banana_ButtonOnLeave()
GameTooltip:Hide();
end
function Banana_SetRaidSymbol(index)
local unit = nil
if UnitExists("mouseover") or UnitExists("target") then
if UnitExists("mouseover") then
unit = "mouseover"
elseif UnitExists("target") then
unit = "target"
end
local oldindex = (Banana_GetSymbol(unit) or 0)
if oldindex == index then
Banana_SetSymbol(unit, 0)
Banana_PlayRemove1()
else
Banana_SetSymbol(unit, index)
end
Banana_UpdateStatus()
end
end
function Banana_TargetRaidSymbol(index)
for i = 1, 40, 1 do
if Banana_TargetRaidSymbolUnit("raid"..i,index) then
return;
end
end;
for i = 1, 4, 1 do
if Banana_TargetRaidSymbolUnit("party"..i,index) then
return;
end
end;
if Banana_TargetRaidSymbolUnit("player",index) then
return;
end
Banana_PlayError();
Banana_Print("Nothing to target");
Banana_UpdateStatus();
end
function Banana_TargetRaidSymbolUnit(unit,index)
if UnitExists(unit) then
if ( Banana_GetSymbol(unit) == index ) then
TargetUnit(unit);
Banana_UpdateStatus();
return 1;
end;
if UnitExists(unit.."target") then
if ( Banana_GetSymbol(unit.."target") == index ) then
TargetUnit(unit.."target");
Banana_Print("Target: "..(UnitName(unit.."target") or "<Unknown>"));
return 1;
end;
end
end
return nil;
end
function Banana_RemoveRaidSymbol(index)
Banana_UpdateStatus();
end
function Banana_UpdateStatusInit()
local index;
for index = 1, 9, 1 do
raidTargetStatus[index].Count = 0;
raidTargetStatus[index].Target = nil;
raidTargetStatus[index].TargetSymbol = nil;
raidTargetStatus[index].Players = {};
BANANA_ICON[index].Debuff = nil;
BANANA_ICON[index].IsDeath = nil;
BANANA_ICON[index].MyTarget = nil;
end
end
function Banana_DebuffCheckAll(target)
local result;
result = Banana_DebuffCheck(target, "Interface\\Icons\\Spell_Shadow_GatherShadows");
if result ~= "" then
return result;
end
return "";
end
function Banana_DebuffCheck(sUnitname, sBuffname)
local iIterator = 1
while (true) do
local debuffTexture, debuffApplications, debuffDispelType = UnitDebuff(sUnitname, iIterator);
if not debuffTexture then
return "";
end
--Banana_Print("t;"..debuffTexture);
--Banana_Print("u;"..sBuffname);
if debuffTexture == sBuffname then
return sBuffname;
end
iIterator = iIterator + 1
end
end
function Banana_HideButton(frame)
if BananaConfigFrame:IsVisible() then
frame:Show();
frame:SetAlpha(0.16);
else
frame:Hide();
frame:SetAlpha(1);
end
end
function Banana_UpdateStatus()
local index;
if GetNumRaidMembers() > 0 then
if BANANA_SHOW_IN_RAID == 1 then
Banana_UpdateStatusInit();
Banana_UpdateStatusPlayerLoop("RAID",40);
Banana_UpdateStatusUpdate();
else
for index = 1, 9, 1 do
local button = getglobal("RaidTargetFrame"..index.."Button");
Banana_HideButton(button)
end
end
elseif GetNumPartyMembers() > 0 then
if BANANA_SHOW_IN_PARTY == 1 then
Banana_UpdateStatusInit();
Banana_UpdateStatusPlayerLoop("PARTY",5);
Banana_UpdateStatusUpdate();
else
for index = 1, 9, 1 do
local button = getglobal("RaidTargetFrame"..index.."Button");
Banana_HideButton(button)
end
end
else
if BANANA_SHOW_OUT_OF_GROUP == 1 then
Banana_UpdateStatusInit();
Banana_UpdateStatusPlayerLoop("PARTY",5);
Banana_UpdateStatusUpdate();
else
for index = 1, 9, 1 do
local button = getglobal("RaidTargetFrame"..index.."Button");
Banana_HideButton(button)
end
end
-- Banana_UpdateStatusInit();
-- Banana_UpdateStatusPlayerLoop("PARTY",5);
-- Banana_UpdateStatusUpdate();
-- for index = 1, 9, 1 do
-- local button = getglobal("RaidTargetFrame"..index.."Button");
-- Banana_UpdateButton(index);
-- if BANANA_SHOW_OUT_OF_GROUP == 1 then
-- button:Show();
-- else
-- Banana_HideButton(button);
-- end
-- end
end
end
function Banana_UpdateStatusPlayerLoop(prefix,count)
for i = 1, count, 1 do
local loopmember = prefix..i;
if loopmember == "PARTY5" or loopmember == "party5" then
loopmember = "PLAYER";
end
if UnitExists(loopmember) then
local loopmembersymbol = (Banana_GetSymbol(loopmember) or 0);
if loopmembersymbol ~= 0 then
Banana_UpdateTargetSymbol(loopmember,loopmembersymbol);
raidTargetStatus[loopmembersymbol].Target = UnitName(loopmember);
-- loopmember has aggro?
if UnitIsUnit(loopmember,loopmember.."TARGETTARGET") then
raidTargetStatus[loopmembersymbol].Aggro = true;
end
Banana_UpdateStatusScanTarget(loopmember,i,loopmembersymbol);
end
local loopmembertarget = loopmember.."TARGET";
if UnitExists(loopmembertarget) then
local symbol = (Banana_GetSymbol(loopmembertarget) or 0);
if symbol ~= 0 then
Banana_UpdateTargetSymbol(loopmembertarget,symbol);
raidTargetStatus[symbol].Target = UnitName(loopmembertarget);
raidTargetStatus[symbol].Count = raidTargetStatus[symbol].Count + 1;
raidTargetStatus[symbol].Players[raidTargetStatus[symbol].Count] = {};
raidTargetStatus[symbol].Players[raidTargetStatus[symbol].Count].Name = UnitName(loopmember);
local _, englishClass = UnitClass(loopmember);
raidTargetStatus[symbol].Players[raidTargetStatus[symbol].Count].Color = RAID_CLASS_COLORS[englishClass];
Banana_UpdateStatusScanTarget(loopmembertarget,i,symbol)
end
end
end
end
end
function Banana_UpdateTargetSymbol(unit,symbol)
local target = unit.."TARGET";
if not raidTargetStatus[symbol].TargetSymbol then
if not UnitExists(target) then
raidTargetStatus[symbol].TargetSymbol = 0;
else
local tts = Banana_GetSymbol(target) or 0;
raidTargetStatus[symbol].TargetSymbol = tts;
end
end
end
function Banana_UpdateStatusScanTarget(targettype,i,index)
if not BANANA_ICON[index].Debuff then
BANANA_ICON[index].Debuff = Banana_DebuffCheckAll(targettype);
end
if not BANANA_ICON[index].IsDeath then
if UnitIsDead(targettype) then
BANANA_ICON[index].IsDeath = 1;
else
BANANA_ICON[index].IsDeath = 0;
end
end
if not BANANA_ICON[index].MyTarget then
if UnitIsUnit(targettype,"TARGET") then
BANANA_ICON[index].MyTarget = 1;
else
BANANA_ICON[index].MyTarget = 0;
end
end
end
function Banana_UpdateStatusUpdate()
for index = 1, 9, 1 do
local button = getglobal("RaidTargetFrame"..index.."Button");
local flash = getglobal("RaidTargetFrame"..index.."ButtonFlash");
local count = getglobal("RaidTargetFrame"..index.."ButtonCount");
if ( raidTargetStatus[index].Target) then
count:SetText(tostring(raidTargetStatus[index].Count));
count:Show();
button:Show();
if BANANA_ICON[index].Debuff ~= "" then
flash:ClearAllPoints();
flash:SetPoint("TOPLEFT",button,"TOPLEFT")
flash:SetWidth(18);
flash:SetHeight(18);
flash:SetTexture(BANANA_ICON[index].Debuff);
flash:Show();
else
flash:Hide();
end
else
flash:Hide();
count:Hide();
end
Banana_UpdateButton(index);
end
end
function Banana_ComboBoxLayout_Initialize()
local info;
info = {};
info.text = BANANA_LAYOUT1;
info.func = Banana_ComboBoxLayout_OnClick;
info.value = 1;
UIDropDownMenu_AddButton(info);
info = {};
info.text = BANANA_LAYOUT2;
info.func = Banana_ComboBoxLayout_OnClick;
info.value = 2;
UIDropDownMenu_AddButton(info);
info = {};
info.text = BANANA_LAYOUT3;
info.func = Banana_ComboBoxLayout_OnClick;
info.value = 3;
UIDropDownMenu_AddButton(info);
info = {};
info.text = BANANA_LAYOUT4;
info.func = Banana_ComboBoxLayout_OnClick;
info.value = 4;
UIDropDownMenu_AddButton(info);
info = {};
info.text = BANANA_LAYOUT5;
info.func = Banana_ComboBoxLayout_OnClick;
info.value = 5;
UIDropDownMenu_AddButton(info);
end
function Banana_ComboBoxLayout_OnClick()
if not BANANA_READY then
return;
end
UIDropDownMenu_SetSelectedID(BananaConfigFrameComboBoxLayout, this:GetID());
if BANANA_BUTTON_LAYOUT ~= this:GetID() then
BANANA_BUTTON_LAYOUT = this:GetID()
Banana_Layout();
end
end
function BananaConfig_ValueChangedResize()
if BANANA_READY then
BANANA_BUTTON_SCALE = this:GetValue();
Banana_UpdateScale();
end
end
function Banana_UpdateScale()
Banana_Print("scale:"..(BANANA_BUTTON_SCALE or "?"));
Banana_UpdateFrameScale(RaidTargetFrame1Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame2Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame3Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame4Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame5Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame6Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame7Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame8Button,BANANA_BUTTON_SCALE / 100)
Banana_UpdateFrameScale(RaidTargetFrame9Button,BANANA_BUTTON_SCALE / 100)
end
function Banana_UpdateFrameScale(frame,scale)
if frame:IsMovable() then
frame:ClearAllPoints();
Banana_SaveFramePos(frame);
frame:SetScale(scale);
Banana_LoadFramePos(frame);
else
frame:SetScale(scale);
end
end
function BananaConfig_ValueChangedShowInRaid()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_IN_RAID = 1;
else
BANANA_SHOW_IN_RAID = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedShowInParty()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_IN_PARTY = 1;
else
BANANA_SHOW_IN_PARTY = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedShowOutOfGroup()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_OUT_OF_GROUP = 1;
else
BANANA_SHOW_OUT_OF_GROUP = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedHideButtonFrames()
if BANANA_READY then
if this:GetChecked() then
BANANA_HIDE_BUTTON_FRAMES = 1;
else
BANANA_HIDE_BUTTON_FRAMES = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedGreyOutDeath()
if BANANA_READY then
if this:GetChecked() then
BANANA_GREY_OUT_DEATH = 1;
else
BANANA_GREY_OUT_DEATH = 0;
end
Banana_Print("BANANA_GREY_OUT_DEATH="..BANANA_GREY_OUT_DEATH);
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedShowExtraInfo()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_EXTRA_INFO = 1;
else
BANANA_SHOW_EXTRA_INFO = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedShowPrintMessages()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_PRINT_MESSAGES = 1;
else
BANANA_SHOW_PRINT_MESSAGES = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedShowDebugMessages()
if BANANA_READY then
if this:GetChecked() then
BANANA_SHOW_DEBUG_MESSAGES = 1;
else
BANANA_SHOW_DEBUG_MESSAGES = 0;
end
Banana_UpdateStatus();
end
end
function BananaConfig_ValueChangedHideUnused()
if BANANA_READY then
if this:GetChecked() then
BANANA_HIDE_UNUSED_BUTTONS = 1;
else
BANANA_HIDE_UNUSED_BUTTONS = 0;
end
Banana_UpdateStatus();
end
end
function Banana_Command(command)
if BananaConfigFrame:IsVisible() then
BananaConfigFrame:Hide();
else
BananaConfigFrame:Show();
end
end
function BananaConfig_Close(command)
BananaConfigFrame:Hide();
end
function Banana_ResetAll()
Banana_Print("Loading defaults.");
BANANA_SHOW_IN_RAID = 1;
BANANA_SHOW_IN_PARTY = 1;
BANANA_SHOW_OUT_OF_GROUP = 0;
BANANA_HIDE_UNUSED_BUTTONS = 0;
BANANA_BUTTON_LAYOUT = 3;
BANANA_BUTTON_SCALE = 100;
BANANA_HIDE_BUTTON_FRAMES = 1;
BANANA_GREY_OUT_DEATH = 0;
BANANA_SHOW_EXTRA_INFO = 1;
BANANA_SHOW_PRINT_MESSAGES = 0;
BANANA_SHOW_DEBUG_MESSAGES = 0;
Banana_UpdateDialogFromVariables();
Banana_UpdateScale();
RaidTargetFrame1Button:ClearAllPoints();
RaidTargetFrame2Button:ClearAllPoints();
RaidTargetFrame3Button:ClearAllPoints();
RaidTargetFrame4Button:ClearAllPoints();
RaidTargetFrame5Button:ClearAllPoints();
RaidTargetFrame6Button:ClearAllPoints();
RaidTargetFrame7Button:ClearAllPoints();
RaidTargetFrame8Button:ClearAllPoints();
RaidTargetFrame9Button:ClearAllPoints();
Banana_Layout();
local starty = -GetScreenHeight()/5;
local startx = GetScreenWidth()/5;
local ofsx = -70;
local ofsy = 70;
BANANA_POS = {
["RaidTargetFrame1Button"] = {
["x"] = startx-(0*ofsx),
["y"] = starty-(0*ofsy),
},
["RaidTargetFrame2Button"] = {
["x"] = startx-(0*ofsx),
["y"] = starty-(1*ofsy),
},
["RaidTargetFrame3Button"] = {
["x"] = startx-(0*ofsx),
["y"] = starty-(2*ofsy),
},
["RaidTargetFrame4Button"] = {
["x"] = startx-(0*ofsx),
["y"] = starty-(3*ofsy),
},
["RaidTargetFrame5Button"] = {
["x"] = startx-(1*ofsx),
["y"] = starty-(0*ofsy),
},
["RaidTargetFrame6Button"] = {
["x"] = startx-(1*ofsx),
["y"] = starty-(1*ofsy),
},
["RaidTargetFrame7Button"] = {
["x"] = startx-(1*ofsx),
["y"] = starty-(2*ofsy),
},
["RaidTargetFrame8Button"] = {
["x"] = startx-(1*ofsx),
["y"] = starty-(3*ofsy),
},
["RaidTargetFrame9Button"] = {
["x"] = startx-(0.5*ofsx),
["y"] = starty-(4*ofsy),
},
};
Banana_ReloadFramePositions();
end
function Banana_TargetSymbol1()
Banana_TargetRaidSymbol(1);
end
function Banana_TargetSymbol2()
Banana_TargetRaidSymbol(2);
end
function Banana_TargetSymbol3()
Banana_TargetRaidSymbol(3);
end
function Banana_TargetSymbol4()
Banana_TargetRaidSymbol(4);
end
function Banana_TargetSymbol5()
Banana_TargetRaidSymbol(5);
end
function Banana_TargetSymbol6()
Banana_TargetRaidSymbol(6);
end
function Banana_TargetSymbol7()
Banana_TargetRaidSymbol(7);
end
function Banana_TargetSymbol8()
Banana_TargetRaidSymbol(8);
end
function Banana_TargetSymbol9()
Banana_TargetRaidSymbol(9);
end
function Banana_SetTargetSymbol8()
end
function Banana_ShowDebugInfo()
Banana_Print("BANANA_HIDE_UNUSED_BUTTONS "..(BANANA_HIDE_UNUSED_BUTTONS or "<nil>"));
Banana_Print("BANANA_BUTTON_LAYOUT "..(BANANA_BUTTON_LAYOUT or "<nil>"));
Banana_Print("BANANA_BUTTON_SCALE "..(BANANA_BUTTON_SCALE or "<nil>"));
Banana_Print("BANANA_HIDE_BUTTON_FRAMES "..(BANANA_HIDE_BUTTON_FRAMES or "<nil>"));
Banana_Print("BANANA_GREY_OUT_DEATH "..(BANANA_GREY_OUT_DEATH or "<nil>"));
Banana_Print("BANANA_SHOW_IN_RAID "..(BANANA_SHOW_IN_RAID or "<nil>"));
Banana_Print("BANANA_SHOW_IN_PARTY "..(BANANA_SHOW_IN_PARTY or "<nil>"));
Banana_Print("BANANA_SHOW_OUT_OF_GROUP "..(BANANA_SHOW_OUT_OF_GROUP or "<nil>"));
Banana_Print("BANANA_SHOW_EXTRA_INFO "..(BANANA_SHOW_EXTRA_INFO or "<nil>"));
-- BananaMtSymbolTemplate
-- CreateFrame("frameType"[ ,"name"][, parent][, "inheritFrame"]) -
Banana_Print((UnitDebuff("TARGET", 0,0) or "nix"));
Banana_Print((UnitDebuff("TARGET", 1,0) or "nix"));
Banana_Print((UnitDebuff("TARGET", 2,0) or "nix"));
Banana_Print((UnitDebuff("TARGET", 3,0) or "nix"));
Banana_Print((UnitDebuff("TARGET", 4,0) or "nix"));
local spell = nil;
local searchid = 1;
local tex;
repeat
tex = GetSpellTexture(searchid, BOOKTYPE_SPELL);
Banana_Print(searchid.." "..(tex or "niiil"));
if tex == snipershot then
Banana_Print("ss");
spell,_ = GetSpellName( searchid, BOOKTYPE_SPELL );
end
searchid = searchid +1;
until spell ~= nil or tex == nil;
Banana_Print(tex or "texnil");