-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blizzard_FeedbackUI.lua
1993 lines (1729 loc) · 73.5 KB
/
Blizzard_FeedbackUI.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
--Constants
C_FEEDBACKUI_MAXALERTS = 10;
C_FEEDBACKUI_UPDATEINTERVAL = .75;
FEEDBACKUI_OFFSETPIXELS = 20;
FEEDBACKUI_DELIMITER = "|";
FEEDBACKUI_FIELDS = {
[0] = "feedbacktype", -- number returns the type, ex: bug feedback or advice
[1] = "version", -- version = 2.2.2 etc
[2] = "build", -- build numbers ex: 12340
[3] = "date", -- Possibly build date or time/date submitted
[4] = "realm", -- Realm name
[5] = "locale", -- language :P
[6] = "name", -- character name
[7] = "level", -- character level
[8] = "race", -- race
[9] = "sex", -- gender
[10] = "class", -- herp
[11] = "map", -- map NAME
[12] = "zone", -- zone NAME
[13] = "area", -- area NAME
[14] = "position", -- positon in coordinates
[15] = "facing", -- direction coordinates
[16] = "speed", -- speed (probably walking speed)
[17] = "chunk", -- chunk? something to do with map tiles?
[18] = "coords", -- coordinates XYZ
[19] = "addonsloaded", -- herp
[20] = "addonsdisabled", -- herp
[21] = "talents", -- uh I expect this to be the same output as in the database
[22] = "equipment", -- equipment item IDs
[23] = "who", -- bugreport npc name
[24] = "where", -- bugreport where was it stuff
[25] = "when", -- bugreport time that it went on
[26] = "type", -- type of bugreport
[27] = "surveyname", -- survey name (probably easy to make them) :: For instances this returns Deadwind Pass, Karazhan (portfromzone, porttoinstancezone)
[28] = "surveyid", -- survey ID (possibly for quests) :: For instances this returns something like Magisters' Terrace1
[29] = "surveyobjective", -- same as above
[30] = "surveytype", -- see above too
[31] = "surveyobtained", -- here
[32] = "surveysubmitted", -- and here
[33] = "category1", -- probably graphical / game world / etc types of bug categories
[34] = "category2",
[35] = "category3",
[36] = "category4",
[37] = "combats", -- amount of recorded combats
[38] = "deaths", -- amount of deaths
[39] = "averagelength", -- average length of combat
[40] = "videooptions", -- CVARs for video options
[41] = "text", -- text the user types in
[42] = "soundoptions", -- CVARs for sound options
[43] = "objectname", -- objectname for the bug report
};
FEEDBACKUI_CVARS = {
["Video"] = {
-- Display
[1] = { name = "gxResolution", bits = 32, varType = "Value", splitDelimiter = "x" },
[2] = { name = "gxRefresh", bits = 8, varType = "Value" },
[3] = { name = "gxColorBits", bits = 2, varType = "Index", values = {16, 24, 32} },
[4] = { name = "gxDepthBits", bits = 2, varType = "Index", values = {16, 24, 32} },
[5] = { name = "gxMultisample", bits = 2, varType = "Index", values = {1, 2, 4, 8} },
[6] = { name = "gxWindow", bits = 1, varType = "Bit" },
[7] = { name = "gxMaximize", bits = 1, varType = "Bit" },
[8] = { name = "useUiScale", bits = 1, varType = "Bit" },
[9] = { name = "uiScale", bits = 6, varType = "Index", rate = 0.01, minVal = 0.64, maxVal = 1.00 },
[10] = { name = "Dummy", bits = 1, varType = "Bit" },
-- World Appearance
[11] = { name = "farclip", bits = 4, varType = "Index", rate = 60, minVal = 177, maxVal = 777 },
[12] = { name = "SmallCull", bits = 2, varType = "Index", values = {0.07, 0.04, 0.01} },
[13] = { name = "shadowLevel", bits = 1, varType = "Bit" },
[14] = { name = "baseMip", bits = 1, varType = "Bit" },
[15] = { name = "anisotropic", bits = 4, varType = "Index", values = {1, 2, 4, 8, 16} },
[16] = { name = "spellEffectLevel", bits = 2, varType = "Bit" },
[17] = { name = "weatherDensity", bits = 2, varType = "Bit" },
[18] = { name = "shadowlod", bits = 1, varType = "Bit" },
[19] = { name = "lod", bits = 1, varType = "Bit" },
-- Brightness
[20] = { name = "DesktopGamma", bits = 1, varType = "Bit" },
[21] = { name = "gamma", bits = 4, varType = "Index", rate = 0.1, minVal = 0.5, maxVal = 1.5 },
[22] = { name = "Dummy", bits = 1, varType = "Bit" },
-- Shaders
[23] = { name = "pixelShaders", bits = 1, varType = "Bit" },
[24] = { name = "specular", bits = 1, varType = "Bit" },
[25] = { name = "ffxGlow", bits = 1, varType = "Bit" },
[26] = { name = "ffxDeath", bits = 1, varType = "Bit" },
[27] = { name = "M2UseShaders", bits = 1, varType = "Bit" },
[28] = { name = "Dummy", bits = 1, varType = "Bit" },
[29] = { name = "useWeatherShaders", bits = 1, varType = "Bit" },
[30] = { name = "Dummy", bits = 1, varType = "Bit" },
-- Misc.
[31] = { name = "Dummy", bits = 1, varType = "Bit" },
[32] = { name = "gxVSync", bits = 1, varType = "Bit" },
[33] = { name = "gxTripleBuffer", bits = 1, varType = "Bit" },
[34] = { name = "movieSubtitle", bits = 1, varType = "Bit" },
[35] = { name = "gxCursor", bits = 1, varType = "Bit" },
[36] = { name = "gxFixLag", bits = 1, varType = "Bit" },
},
["Sound"] = {
-- Sound Playback
[1] = { name = "Sound_EnableAllSound", bits = 1, varType = "Bit" },
[2] = { name = "Sound_EnableSFX", bits = 1, varType = "Bit" },
[3] = { name = "Sound_EnableErrorSpeech", bits = 1, varType = "Bit" },
[4] = { name = "Sound_EnableEmoteSounds", bits = 1, varType = "Bit" },
[5] = { name = "Sound_EnableMusic", bits = 1, varType = "Bit" },
[6] = { name = "Sound_ZoneMusicNoDelay", bits = 1, varType = "Bit" },
[7] = { name = "Sound_EnableAmbience", bits = 1, varType = "Bit" },
[8] = { name = "Sound_ListenerAtCharacter", bits = 1, varType = "Bit" },
[9] = { name = "Sound_EnableSoundWhenGameIsInBG", bits = 1, varType = "Bit" },
[10] = { name = "Sound_NumChannels", bits = 3, varType = "Index", values = {16, 32, 64, 128} },
[11] = { name = "Sound_EnableReverb", bits = 1, varType = "Bit" },
[12] = { name = "Dummy", bits = 3, varType = "Bit" },
[13] = { name = "Sound_MasterVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[14] = { name = "Sound_SFXVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[15] = { name = "Sound_MusicVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[16] = { name = "Sound_AmbienceVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
-- Voice
[17] = { name = "EnableVoiceChat", bits = 1, varType = "Bit" },
[18] = { name = "EnableMicrophone", bits = 1, varType = "Bit" },
[19] = { name = "VoiceChatMode", bits = 1, varType = "Bit" },
[20] = { name = "PUSHTOTALK_SOUND", var = true, bits = 1, varType = "Bit" },
[21] = { name = "Dummy", bits = 4, varType = "Bit" },
[22] = { name = "VoiceActivationSensitivity", bits = 6, varType = "Index", rate = 0.02, minVal = 0, maxVal = 1 },
[23] = { name = "Dummy", bits = 2, varType = "Bit" },
[24] = { name = "InboundChatVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[25] = { name = "Dummy", bits = 4, varType = "Bit" },
[26] = { name = "OutboundChatVolume", bits = 4, varType = "Index", rate = 0.5, minVal = 0.25, maxVal = 2.5 },
[27] = { name = "ChatSoundVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[28] = { name = "ChatMusicVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[29] = { name = "ChatAmbienceVolume", bits = 4, varType = "Index", rate = 0.1, minVal = 0, maxVal = 1 },
[30] = { name = "PushToTalkButton", varType = "String" },
[31] = { name = "Sound_OutputDriverName", varType = "String" },
[32] = { name = "Sound_VoiceChatInputDriverName", varType = "String" },
[33] = { name = "Sound_VoiceChatOutputDriverName", varType = "String" },
},
}
FEEDBACKUI_SURVEYFIELDS = { }
FEEDBACKUI_PVPFIELDS = { }
--Global Variables
feedbackFrames = {};
g_FeedbackUI_feedbackVars = {};
g_FeedbackUI_feedbackVars.PVPStats = {};
g_FeedbackUI_feedbackVars.PVPStats["combats"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["deaths"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["averagelength"] = 0;
g_FeedbackUI_dropdownMenus = {};
--Local Variables
local feedbackUpdateInterval = 0;
local waitTable = {};
local oldSetItemRef;
--Tables for hijacking Item tooltips
local tooltips = {
ItemRefTooltip,
GameTooltip,
ShoppingTooltip1,
ShoppingTooltip2 }
local methods = {
"SetHyperlink",
"SetBagItem",
"SetInventoryItem",
"SetLootItem",
"SetLootRollItem",
"SetQuestItem",
"SetQuestLogItem",
"SetQuestLogSpecialItem",
"SetMerchantItem",
"SetBuybackItem",
"SetAuctionSellItem",
"SetCraftItem",
"SetMerchantCostItem",
"SetAuctionItem",
"SetInboxItem",
"SetSendMailItem",
"SetTradeTargetItem",
"SetTradePlayerItem",
"SetTradeSkillItem",
"SetTrainerService",
"SetSpell",
"SetTalent",
}
function FeedbackUI_OnLoad (self)
--Take over WoW's original slash commands for Bug and Suggest.
if ( not ( SLASH_BUG1 ) or not ( SLASH_SUGGEST1 ) ) then
SLASH_BUG1 = "/bug"
SLASH_SUGGEST1 = "/suggest"
end
SLASH_SURVEY1 = "/survey"
SlashCmdList["BUG"] = FeedbackUI_SlashBug;
SlashCmdList["SUGGEST"] = FeedbackUI_SlashSuggest;
SlashCmdList["SURVEY"] = FeedbackUI_SlashSurvey;
-- Localize settings!
FeedbackUI_Localize()
FeedbackUI:RegisterEvent("VARIABLES_LOADED");
--Set up the tabs using the CharacterFrame template.
PanelTemplates_SetNumTabs(self, 4);
FeedbackUI.selectedTab = 4;
PanelTemplates_UpdateTabs(self);
--Setup Frames for mouse clicks
FeedbackUI_RegisterFramesForClicks();
end
function FeedbackUI_MouseOptions_OnClick ()
local modifierValue, buttonValue;
modifierValue = g_FeedbackUI_dropdownMenus.modifierKey:GetSelectedValue();
buttonValue = g_FeedbackUI_dropdownMenus.mouseButton:GetSelectedValue();
SetModifiedClick("GENERATEFEEDBACK", modifierValue .. "-" .. buttonValue);
SaveBindings(GetCurrentBindingSet());
end
function FeedbackUI_BuildTooltipLine(tooltip)
_, _, modifier, button = string.find(GetModifiedClick("GENERATEFEEDBACK"), "(.+)%-(.+)");
for i, value in next, FEEDBACKUI_MODIFIERKEYS do
if (value.value == modifier) then
modifier = value.text;
end
end
for i, value in next, FEEDBACKUI_MOUSEBUTTONS do
if (value.value == button) then
button = value.text;
end
end
return string.format(tooltip, modifier, button);
end
function FeedbackUI_OnEvent (self, event, ...)
local args = {...};
if ( event == "ADDON_LOADED" and type(args[1]) == "string" and string.match(args[1], "FeedbackUI") ) then
--g_FeedbackUI_surveysTable = {}
for _, frame in pairs(feedbackFrames) do
if frame.panels then
for _, panel in pairs(frame.panels) do
if panel.Localize then
panel.Localize(panel);
end
if panel.Load then
panel.Load(panel);
end
end
end
end
for _, tooltip in pairs(tooltips) do
for _, method in ipairs(methods) do
pcall(hooksecurefunc, tooltip, method, FeedbackUI_ItemTooltip);
end
end
--I don't mind saying I hate doing this immensely.
FeedbackUI:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
FeedbackUI_FixContainerPortrait();
--Hook all click events, everywhere~!
WorldFrame:SetScript("OnMouseUp", FeedbackUI_WorldFrame_OnClick);
FeedbackUI:RegisterEvent("PLAYER_ENTERING_WORLD");
--For learning new companion pets
FeedbackUI:RegisterEvent("COMPANION_LEARNED");
--Yay for PVP
FeedbackUI:RegisterEvent("PLAYER_LEAVE_COMBAT");
FeedbackUI:RegisterEvent("PLAYER_REGEN_ENABLED");
FeedbackUI:RegisterEvent("CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS");
FeedbackUI:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE");
FeedbackUI:RegisterEvent("PLAYER_DEAD");
FeedbackUI:RegisterEvent("UNIT_COMBAT");
-- Init drop downs
if ( not g_FeedbackUI_dropdownMenus.mouseButton ) then
g_FeedbackUI_dropdownMenus.mouseButton = BQAE_DropDown:Init("FeedbackUI_MouseButtonDropDown", FeedbackUIWelcomeFrameClickOptions, "+");
g_FeedbackUI_dropdownMenus.mouseButton:SetPoint("TOPRIGHT", FeedbackUIWelcomeFrameClickOptions, "TOPRIGHT", -12, -2);
for i, value in next, FEEDBACKUI_MOUSEBUTTONS do
g_FeedbackUI_dropdownMenus.mouseButton:AddButton(value.text, value.value, FeedbackUI_MouseOptions_OnClick);
end
g_FeedbackUI_dropdownMenus.mouseButton:SetWidth(105);
g_FeedbackUI_dropdownMenus.mouseButton:SetSelectedIndex(1);
end
if ( not g_FeedbackUI_dropdownMenus.modifierKey ) then
g_FeedbackUI_dropdownMenus.modifierKey = BQAE_DropDown:Init("FeedbackUI_ModifierKeyDropDown", FeedbackUIWelcomeFrameClickOptions, FEEDBACKUI_MODIFIERKEY);
g_FeedbackUI_dropdownMenus.modifierKey:SetPoint("RIGHT", g_FeedbackUI_dropdownMenus.mouseButton, "LEFT", -24, 0);
for i, value in next, FEEDBACKUI_MODIFIERKEYS do
g_FeedbackUI_dropdownMenus.modifierKey:AddButton(value.text, value.value, FeedbackUI_MouseOptions_OnClick);
end
g_FeedbackUI_dropdownMenus.modifierKey:SetWidth(105);
g_FeedbackUI_dropdownMenus.modifierKey:SetSelectedIndex(1);
end
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_AuctionUI" ) then
FeedbackUI_AuctionFrameSetup();
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_InspectUI" ) then
FeedbackUI_InspectFrameSetup();
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_TradeSkillUI" ) then
FeedbackUI_TradeSkillFrameSetup();
-- This may need to be changed or removed once the SetItemRef code in the Blizzard CombatLog is merged into FrameXML's itemRef.lua
-- This event handler pre-hooks the combat log's version of SetItemRef so that the new R-click menu does not prevent FUI from opening.
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_CombatLog" ) then
oldSetItemRef = SetItemRef;
SetItemRef = FeedbackUI_SetItemRef;
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_TrainerUI" ) then
ClassTrainerSkillIcon:RegisterForClicks("LeftButtonUp", "RightButtonUp");
elseif ( event == "ADDON_LOADED" and args[1] == "Blizzard_TalentUI" ) then
--oldPlayerTalentFrameTalent_OnClick = PlayerTalentFrameTalent_OnClick;
--PlayerTalentFrameTalent_OnClick = FeedbackUI_PlayerTalentFrameTalent_OnClick;
local button, func;
for i = 1, MAX_NUM_TALENTS do
button = getglobal("PlayerTalentFrameTalent" .. i);
if ( button ) then
func = button:GetScript("OnClick");
button:RegisterForClicks("RightButtonUp", "LeftButtonUp")
button:SetScript("OnClick", function(...) FeedbackUI_PlayerTalentFrameTalent_OnClick(..., func, ...) end);
--hooksecurefunc( "PlayerTalentFrameTalent_OnClick", FeedbackUI_PlayerTalentFrameTalent_OnClick);
--button:HookScript("OnClick", function(...) FeedbackUI_PlayerTalentFrameTalent_OnClick(button, func, ... ) end);
end
end
elseif ( event == "VARIABLES_LOADED" ) then
if ( not g_FeedbackUI_feedbackVars.PVPStats ) then
g_FeedbackUI_feedbackVars.PVPStats = {}
g_FeedbackUI_feedbackVars.PVPStats["combats"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["deaths"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["averagelength"] = 0;
end
if g_FeedbackUI_feedbackVars["verbose"] == nil then
g_FeedbackUI_feedbackVars["verbose"] = true;
end
g_FeedbackUI_feedbackVars.PVP = false;
FeedbackUI_SetupTargets();
if not waitTable then
waitTable = {}
end
tinsert(waitTable, { func=function() FeedbackUI_SendPVPData() end, exTime = GetTime() + 2 });
-- Hook the OnClick Handler for QuestLogTitle 1-6 buttons.
local QLTButton
for i = 1, 6 do
if ( getglobal( "QuestLogScrollFrameButton" .. i) ) then
QLTButton = getglobal("QuestLogScrollFrameButton" .. i);
end
if ( QLTButton ) then
QLTButton:HookScript("OnClick", function(...) FeedbackUI_QuestLogTitleButton_OnClick(self, ...) end );
end
end
-- Hook the OnMouseUp Handler for WorldMapButton
if ( "WorldMapButton" ) then
WorldMapButton:HookScript("OnMouseUp", function(...) FeedbackUI_WorldMapButton_OnClick(..., button) end );
end
elseif ( event == "UPDATE_MOUSEOVER_UNIT" ) then
if ( UnitIsPlayer("mouseover") ) then
FeedbackUI.currentMouseover = nil;
else
FeedbackUI.currentMouseover = UnitName("mouseover");
FeedbackUI_SpawnTooltip();
end
elseif (
( ( event == "UNIT_COMBAT"
and args[1] == "target"
and args[2] == "WOUND"
and UnitIsPlayer("target")
and not ( UnitFactionGroup("player") == UnitFactionGroup("target") )
)
or
( ( event == "CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS"
or event == "CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE"
)
and string.find(string.lower(args[1]), string.lower(YOU) )
) )
and UnitAffectingCombat("player")
and not g_FeedbackUI_feedbackVars.PVP
) then
g_FeedbackUI_feedbackVars.PVP = true;
g_FeedbackUI_feedbackVars.PVPStats["combats"] = g_FeedbackUI_feedbackVars.PVPStats["combats"] + 1;
g_FeedbackUI_feedbackVars.PVPStart = GetTime();
elseif ( ( event == "PLAYER_LEAVE_COMBAT" or event == "PLAYER_REGEN_ENABLED" ) and g_FeedbackUI_feedbackVars.PVP ) then
local combats = g_FeedbackUI_feedbackVars.PVPStats["combats"] - 1;
local average = g_FeedbackUI_feedbackVars.PVPStats["averagelength"] * combats;
average = tonumber(average + math.ceil(GetTime() - ( g_FeedbackUI_feedbackVars.PVPStart or GetTime() ))) or 0;
g_FeedbackUI_feedbackVars.PVPStats["averagelength"] = math.floor(average / ( combats + 1 ));
tinsert(waitTable, { func = function () g_FeedbackUI_feedbackVars.PVP = false end, exTime = GetTime() + 2 } );
elseif ( event == "PLAYER_DEAD" and g_FeedbackUI_feedbackVars.PVP ) then
g_FeedbackUI_feedbackVars.PVP = false;
g_FeedbackUI_feedbackVars.PVPStats["deaths"] = g_FeedbackUI_feedbackVars.PVPStats["deaths"] + 1
elseif ( event == "PLAYER_ENTERING_WORLD" ) then
FeedbackUI_CompanionHook()
elseif ( event == "COMPANION_LEARNED" ) then
FeedbackUI_CompanionHook()
end
end
function FeedbackUI_RegisterFramesForClicks ()
for i = 1, 10 do getglobal("QuestInfoItem" .. i):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
for i = 1, 12 do getglobal("CompanionButton" .. i):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
--CharacterAmmoSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
for i = 1, 7 do getglobal("TradePlayerItem" .. i .. "ItemButton"):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
for i = 1, 7 do getglobal("TradeRecipientItem" .. i .. "ItemButton"):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
for i = 1, 7 do getglobal("BankFrameBag" .. i):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
for i = 1, 13 do getglobal("ContainerFrame" .. i .. "PortraitButton"):RegisterForClicks("LeftButtonUp", "RightButtonUp"); end
MinimapZoneTextButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
AzerothButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
OutlandButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
end
function FeedbackUI_InspectFrameSetup ()
InspectHeadSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectNeckSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectShoulderSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectBackSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectChestSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectShirtSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectTabardSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectWristSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectHandsSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectWaistSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectLegsSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectFeetSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectFinger0Slot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectFinger1Slot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectTrinket0Slot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectTrinket1Slot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectMainHandSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectSecondaryHandSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
InspectRangedSlot:RegisterForClicks("LeftButtonUp", "RightButtonUp");
end
function FeedbackUI_AuctionFrameSetup ()
for i = 1, 8 do
getglobal("BrowseButton" .. i .. "Item"):RegisterForClicks("LeftButtonUp", "RightButtonUp");
getglobal("BidButton" .. i .. "Item"):RegisterForClicks("LeftButtonUp", "RightButtonUp");
getglobal("AuctionsButton" .. i .. "Item"):RegisterForClicks("LeftButtonUp", "RightButtonUp");
end
end
function FeedbackUI_TradeSkillFrameSetup ()
local skillFrame, reagentFrame, script;
TradeSkillListScrollFrame:HookScript("OnVerticalScroll",
function(self, offset)
if ( GameTooltip:IsVisible() ) then
if ( string.match(GameTooltip:GetOwner():GetName(), "^TradeSkillSkill") ) then
FeedbackUI_TradeSkillFrame_Update(GameTooltip:GetOwner());
end
end
end);
for i = 1, 8 do
skillFrame = getglobal("TradeSkillSkill" .. i);
reagentFrame = getglobal("TradeSkillReagent" ..i);
--[[ Grab OnClick events ]]
skillFrame:HookScript("OnEnter",
function(self)
FeedbackUI_TradeSkillFrame_Update(self);
end);
skillFrame:HookScript("OnLeave",
function(self)
GameTooltip:Hide();
end);
skillFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp");
reagentFrame:RegisterForClicks("LeftButtonUp", "RightButtonUp");
skillFrame:HookScript("OnClick",
function(...)
FeedbackUI_TradeSkillListClick(self, ...);
end);
reagentFrame:HookScript("OnClick",
function(...)
FeedbackUI_TradeSkillListClick(self, ...);
end);
end
TradeSkillSkillIcon:RegisterForClicks("LeftButtonUp", "RightButtonUp");
end
function FeedbackUI_TradeSkillFrame_Update(self)
if ( GetTradeSkillItemLink(self:GetID()) or GetTradeSkillRecipeLink(self:GetID()) ) then
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT", 0, self:GetHeight());
GameTooltip:SetTradeSkillItem(self:GetID());
end
end
function FeedbackUI_ParseModifiedClick()
local keyString = GetModifiedClick("GENERATEFEEDBACK");
local modifierKey, mouseButton = strsplit("-", keyString);
g_FeedbackUI_dropdownMenus.modifierKey:SetSelectedValue(modifierKey);
g_FeedbackUI_dropdownMenus.mouseButton:SetSelectedValue(mouseButton);
end
function FeedbackUI_SendPVPData ()
if g_FeedbackUI_feedbackVars.PVPStats["combats"] == 0 then return; end
FeedbackUIBugFrameInfoPanel.OnShow(FeedbackUIBugFrameInfoPanel);
local infoString = "";
FeedbackUIBugFrameInfoPanel.infoTable["feedbacktype"] = 3;
for index, field in next, FEEDBACKUI_FIELDS do
if g_FeedbackUI_feedbackVars.PVPStats[field] then
FeedbackUIBugFrameInfoPanel.infoTable[field] = g_FeedbackUI_feedbackVars.PVPStats[field];
infoString = infoString .. "<" .. index .. ">" .. string.gsub(FeedbackUIBugFrameInfoPanel.infoTable[field], "\n", " ") .. "</" .. index ..">";
--infoString = infoString .. string.gsub(FeedbackUIBugFrameInfoPanel.infoTable[field], "\n", " ") .. FEEDBACKUI_DELIMITER;
elseif not ( FeedbackUIBugFrameInfoPanel.infoTable[field] ) then
FeedbackUIBugFrameInfoPanel.infoTable[field] = "";
--infoString = infoString .. FEEDBACKUI_DELIMITER;
else
infoString = infoString .. "<" .. index .. ">" .. string.gsub(FeedbackUIBugFrameInfoPanel.infoTable[field], "\n", " "):gsub(FEEDBACKUI_DELIMITER, " ") .. "</" .. index .. ">";
-- infoString = infoString .. string.gsub(FeedbackUIBugFrameInfoPanel.infoTable[field], "\n", " "):gsub(FEEDBACKUI_DELIMITER, " ") .. FEEDBACKUI_DELIMITER;
end
end
ReportSuggestion(infoString);
UIErrorsFrame:Clear();
g_FeedbackUI_feedbackVars.PVPStats = {}
g_FeedbackUI_feedbackVars.PVPStats["combats"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["deaths"] = 0;
g_FeedbackUI_feedbackVars.PVPStats["averagelength"] = 0;
end
function FeedbackUI_OnUpdate (interval)
feedbackUpdateInterval = feedbackUpdateInterval + interval;
if ( feedbackUpdateInterval > C_FEEDBACKUI_UPDATEINTERVAL ) then
for _, frame in pairs(feedbackFrames) do
if frame.panels then
for _, panel in pairs(frame.panels) do
if panel.OnUpdate then
panel.OnUpdate(panel, C_FEEDBACKUI_UPDATEINTERVAL)
end
end
end
end
feedbackUpdateInterval = 0;
elseif ( #waitTable > 0 ) then
for index, entry in next, waitTable do
if ( entry.exTime < GetTime() ) then
entry.func();
waitTable[index] = nil;
end
end
end
end
function math.round (num, idp)
return math.floor(num * 10^(idp or 0) + 0.5) / 10^(idp or 0)
end
function ConvertToHex(decimal)
if (not decimal) then return; end
local out = "";
local hex = "0123456789ABCDEF";
local index = 0;
local d;
while decimal > 0 do
index = index + 1;
decimal, d = floor(decimal / 16), mod(decimal, 16) + 1;
out = string.sub(hex, d, d) .. out;
end
for i = 1, strlen(out) do
if (mod(strlen(out), 2) ~= 0) then
out = "0" .. out;
end
end
if (strlen(out) == 0) then
out = "00";
end
return out;
end
function FeedbackUI_BuildSettingsString(category)
if (not category) then return; end
if (not FEEDBACKUI_CVARS[category]) then return; end
local dataString = "";
local bitOffset = 8;
local byte = 0;
local hexLength;
local value = nil;
local varFunc, varError;
for _, variable in ipairs(FEEDBACKUI_CVARS[category]) do
if ( pcall(GetCVar, variable.name) ) then
value = GetCVar(variable.name);
else
if ( variable.varType == "String" ) then
value = "";
else
value = 0;
end
end
if ( variable.var ) then
varFunc = assert(loadstring("return " .. variable.name));
value, varError = varFunc();
if ( not varError ) then
if ( not value ) then
value = 0;
end
bitOffset = bitOffset - variable.bits;
byte = byte + bit.lshift(value, bitOffset);
end
elseif ( variable.varType == "String" ) then
dataString = dataString .. "," .. gsub(value, ",", " ");
elseif ( variable.varType == "Value" ) then
if ( variable.splitDelimiter ) then
local _, _, a, b = string.find(value, "(.*)" .. variable.splitDelimiter .. "(.*)");
-- if ( a and b ) then
hexLength = variable.bits / 8;
dataString = dataString .. string.format("%0" .. hexLength .. "X", (a or 0)) .. string.format("%0" .. hexLength .. "X", (b or 0));
-- end
else
hexLength = variable.bits / 4;
dataString = dataString .. string.format("%0" .. hexLength .. "X", value);
end
elseif ( variable.varType == "Index" ) then
bitOffset = bitOffset - variable.bits;
if ( not variable.values ) then
local cVar = string.format("%.2f", value);
if ( tonumber(cVar) > variable.maxVal ) then cVar = variable.maxVal; end
local index = (cVar - variable.minVal) / variable.rate;
byte = byte + bit.lshift(index, bitOffset);
else
local index = nil;
for i, val in ipairs(variable.values) do
if ( tonumber(value) == val ) then
byte = byte + bit.lshift(i - 1, bitOffset);
end
end
end
elseif ( variable.varType == "Bit" ) then
bitOffset = bitOffset - variable.bits;
if ( variable.name == "Dummy" ) then
byte = byte + bit.lshift(0, bitOffset);
else
byte = byte + bit.lshift((value or 0), bitOffset);
end
end
if (bitOffset <= 0) then
dataString = dataString .. string.format("%02X", byte);
bitOffset = 8;
byte = 0;
end
end
return dataString;
end
function FeedbackUI_Hide ()
for index, frame in pairs(feedbackFrames) do
if frame.panels then
for num, panel in pairs(frame.panels) do
if ( panel.OnHide ) then
panel.OnHide(panel);
end
end
end
end
collectgarbage("collect");
end
function FeedbackUI_Show ()
if FeedbackUI:IsVisible() then
FeedbackUI:Hide()
else
FeedbackUI:Show()
FeedbackUI:Raise()
end
end
function FeedbackUI_RefreshPanels ()
end
function msg (arg)
if type(arg) == "string" then
DEFAULT_CHAT_FRAME:AddMessage(arg)
else
DEFAULT_CHAT_FRAME:AddMessage(tostring(arg))
end
end
--Display the bug form when /bug is typed.
function FeedbackUI_SlashBug (buttonPress)
for index, frame in pairs(feedbackFrames) do
if frame.panels then
for num, panel in pairs(frame.panels) do
if ( panel.OnHide ) then
panel.OnHide(panel);
end
end
end
end
for _, panel in pairs(FeedbackUIBugFrame.panels) do
if ( panel.OnShow ) then
panel.OnShow(panel);
end
end
FeedbackUI_SetupEntryForms(FeedbackUIBugFrame, buttonPress);
if ( not buttonPress ) then
FEEDBACKUI_TYPETABLE = FEEDBACKUI_GENERICTYPETABLE;
FeedbackUIBugFrame.stepThroughPanel.table = FEEDBACKUI_WHERETABLE;
FeedbackUIBugFrame.stepThroughPanel.startlink = FEEDBACKUI_WHERETABLE;
FeedbackUIBugFrame.stepThroughPanel.Render(FeedbackUIBugFrame.stepThroughPanel);
end
if not ( FeedbackUI.selectedTab == 1 ) then
FeedbackUITab1:Click();
if not ( FeedbackUI:IsVisible() ) then
FeedbackUI_Show();
end
else
FeedbackUI_Show();
end
end
--Display the suggestion form when /suggest is typed.
function FeedbackUI_SlashSuggest (buttonPress)
for index, frame in pairs(feedbackFrames) do
if frame.panels then
for num, panel in pairs(frame.panels) do
if ( panel.OnHide ) then
panel.OnHide(panel);
end
end
end
end
for _, panel in pairs(FeedbackUISuggestFrame.panels) do
if ( panel.OnShow ) then
panel.OnShow(panel);
end
end
FeedbackUI_SetupEntryForms(FeedbackUISuggestFrame, buttonPress);
if ( not buttonPress ) then
FEEDBACKUI_TYPETABLE = FEEDBACKUI_GENERICTYPETABLE;
FeedbackUISuggestFrame.stepThroughPanel.table = FEEDBACKUI_WHERETABLE;
FeedbackUISuggestFrame.stepThroughPanel.startlink = FEEDBACKUI_WHERETABLE;
FeedbackUISuggestFrame.stepThroughPanel.Render(FeedbackUISuggestFrame.stepThroughPanel);
end
if not ( FeedbackUI.selectedTab == 2 ) then
FeedbackUITab2:Click();
if not ( FeedbackUI:IsVisible() ) then
FeedbackUI_Show();
end
else
FeedbackUI_Show();
end
end
--Display the survey form when /survey is typed.
function FeedbackUI_SlashSurvey (buttonPress)
local panel = FeedbackUISurveyFrameSurveysPanel;
for index, frame in pairs(feedbackFrames) do
if frame.panels then
for num, panel in pairs(frame.panels) do
if ( panel.OnHide ) then
panel.OnHide(panel);
end
end
end
end
for _, panel in pairs(FeedbackUISurveyFrame.panels) do
if ( panel.OnShow ) then
panel.OnShow(panel);
end
end
if ( ( buttonPress == true ) and FeedbackUI.focus ) then
local survey, index, found = panel.AddSurvey(panel, FeedbackUI.focus);
--msg(survey.status);
if type(survey) == "table" then
if ( survey.status and ( survey.status == "Hidden" ) ) then
g_FeedbackUI_surveysTable[survey.type][index].status = "Available";
elseif ( survey.status ) then
FeedbackUISurveyFrameSurveysPanel.ddlStatus:SetSelectedValue(survey.status);
end
end
panel.Expand(panel, FeedbackUI.focus.type)
FeedbackUISurveyFrameSurveysPanel.ddlCategory:SetSelectedValue("All");
panel.table = {};
panel.PopulateTable(panel)
panel.ScrollToSurvey(panel, FeedbackUI.focus);
return;
end
FeedbackUISurveyFrameSurveysPanel.ddlStatus:SetSelectedValue("Available");
FeedbackUISurveyFrameSurveysPanel.ddlCategory:SetSelectedValue("All");
for _, entry in pairs(panel.categories) do
panel.Expand(panel, entry);
end
panel.table = {};
panel.PopulateTable(panel)
if not ( FeedbackUI.selectedTab == 3 ) then
FeedbackUITab3:Click();
if not ( FeedbackUI:IsVisible() ) then
FeedbackUI_Show();
end
else
FeedbackUI_Show();
end
end
--Creates all the panels that go inside the frames.
function FeedbackUI_SetupPanel (panel)
local panelFrame = CreateFrame("Frame", panel.parent .. panel.name, getglobal(panel.parent), panel.inherits);
panelFrame.name = panel.name;
panelFrame.parent = getglobal(panel.parent);
if panel.labelText then
panelFrame.label = getglobal(panelFrame:GetName() .. "Label");
panelFrame.label:SetText(panel.labelText);
end
if panel.anchors then
for _, anchor in next, panel.anchors do
panelFrame:SetPoint(anchor.point, anchor.relativeto, anchor.relativepoint, anchor.x, anchor.y)
end
end
if panel.size then
if panel.size.x then
panelFrame:SetWidth(panel.size.x)
end
if panel.size.y then
panelFrame:SetHeight(panel.size.y)
end
end
panelFrame.Load = panel.Load;
panelFrame.OnShow = panel.OnShow;
panelFrame.OnHide = panel.OnHide;
panelFrame.OnUpdate = panel.OnUpdate;
if panel.Setup then
panel.Setup(panelFrame)
end
if panel.event then
for _, event in pairs(panel.event) do
panelFrame:RegisterEvent(event)
end
panelFrame.Handler = panel.Handler
panelFrame:SetScript("OnEvent", panelFrame.Handler)
end
if ( not panelFrame.parent.panels ) then
panelFrame.parent.panels = {}
tinsert(panelFrame.parent.panels, panelFrame)
else
tinsert(panelFrame.parent.panels, panelFrame)
end
end
--Creates InfoLines that go inside some of the panels.
function FeedbackUI_AddInfoLine (line)
local lineFrame = CreateFrame("Frame", line.parent .. line.name, getglobal(line.parent), line.inherits);
lineFrame.parent = getglobal(line.parent);
lineFrame.value = getglobal(lineFrame:GetName() .. "Value");
if line.labelText then
lineFrame.label = getglobal(lineFrame:GetName() .. "Label")
lineFrame.label:SetText(line.labelText)
end
if line.Update then
lineFrame.Update = line.Update
end
if ( not lineFrame.parent.infoLines ) then
lineFrame.parent.infoLines = {}
end
table.insert(lineFrame.parent.infoLines, lineFrame)
if line.Setup then
line.Setup(lineFrame);
end
if ( #lineFrame.parent.infoLines == 1 ) then
lineFrame:SetPoint("TOPLEFT", lineFrame.parent:GetName(), "TOPLEFT", 3, -8)
else
lineFrame:SetPoint("TOPLEFT", lineFrame.parent.infoLines[table.maxn(lineFrame.parent.infoLines)-1]:GetName(), "BOTTOMLEFT", 0, -2)
end
lineFrame:SetWidth(lineFrame.parent:GetWidth() - 8)
end
---------------------------------------------------------------------------------------------------
-- Create a unique hash from a string.
---------------------------------------------------------------------------------------------------
-- similar to lua's hashing algorithm
--[[
--function FeedbackUI_HexHashXXX (str)
local hash = 5381;
local c;
for i = 1, #str do
c = string.byte(str, i);
hash = bit.bxor(hash, bit.lshift(hash, 5) + bit.rshift(hash, 2) + c);
end
return format("%08x", hash);
end
]]--
--Make sure the right-click config menu accurately represents current settings
function FeedbackUI_OptionsInit()
for _, button in ipairs(FEEDBACKUI_OPTIONSBUTTONS) do
if ( button.text == FEEDBACKUILBLSURVEYALERTSCHECK_TEXT ) then
button.checked = g_FeedbackUI_feedbackVars["alerts"];
else
button.checked = g_FeedbackUI_feedbackVars["verbose"];
end
button.func = FeedbackUI_OptionsClick;
UIDropDownMenu_AddButton(button);
end
end
--Handle clicking on an option in the configuration menu
function FeedbackUI_OptionsClick(self, button)
this = (this or self);
if ( this.value == FEEDBACKUILBLSURVEYALERTSCHECK_TEXT ) then
g_FeedbackUI_feedbackVars["alerts"] = not g_FeedbackUI_feedbackVars["alerts"];
FeedbackUISurveyFrameSurveysPanel.UpdateAlertButtons(FeedbackUISurveyFrameSurveysPanel);
elseif ( this.value == FEEDBACKUISHOWCUES_TEXT ) then
g_FeedbackUI_feedbackVars["verbose"] = not g_FeedbackUI_feedbackVars["verbose"];
end
end
--Make a nice long string that represents items in the player's inventory.
function FeedbackUI_GetInventoryInfo ()
local inventoryTable = {};
local partLink;
for i = 1, 23 do
if ( not GetInventoryItemLink("player", i) ) then
inventoryTable[i] = "0:0:0:0:0";
else
partLink = string.match(GetInventoryItemLink("player", i), ":([%d]+:[%d]+:[%d]+:[%d]+:[%d]+):");
inventoryTable[i] = partLink;
end
end
return table.concat(inventoryTable, "/");
end
---------------------------------------------------------------------------------------------------
-- Functions for managing the display of the Welcome portal.
---------------------------------------------------------------------------------------------------
--Setup the welcome portal to display the object or a generic welcome message.