-
Notifications
You must be signed in to change notification settings - Fork 9
/
RepHelper.lua
3972 lines (3591 loc) · 135 KB
/
RepHelper.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
----------------------------------------------------------
-- RepHelper | A World of Warcraft addon to help you manage your reputation and Factions. --
-------------------------------------------------------
---------------------------
-- _00_ Variables Set up --
---------------------------
RPH_ToExalted = {}
RPH_ToExalted[0] = 84000;
RPH_ToExalted[1] = 48000; -- working on Hated -> Hostile, base offset 21k+12k+6k+3k+3k+3k
RPH_ToExalted[2] = 45000; -- working on Hostile -> Unfriendly, base offset 21k+12k+6k+3k+3k
RPH_ToExalted[3] = 42000; -- working on Unfriendly -> Neutral, base offset 21k+12k+6k+3k
RPH_ToExalted[4] = 39000; -- working on Neutral -> Friendly, base offset 21k+12k+6k
RPH_ToExalted[5] = 33000; -- working on Friendly -> Honored, base offset 21k+12k
RPH_ToExalted[6] = 21000; -- working on Honored -> Revered, base offset 21k
RPH_ToExalted[7] = 0; -- working on Revered -> Exalted, so no base offset
RPH_ToExalted[8] = 0; -- already at Exalted -> no offset
-- Addon constants
RPH_NAME = "RepHelper"
RPH_VNMBR = 6020012 -- Number code for this version
local addonName, vars = ...
local L = vars.L
RPH = vars
-- Colours
RPH_Help_COLOUR = "|cFFFFFF7F"
RPH_NEW_REP_COLOUR = "|cFF7F7FFF"
RPH_NEW_STANDING_COLOUR = "|cFF6060C0"
RPH_BAG_COLOUR = "|cFFC0FFC0"
RPH_BAG_BANK_COLOUR = "|cFFFFFF7F"
RPH_QUEST_COLOUR = "|cFFC0FFC0"
RPH_HIGHLIGHT_COLOUR = "|cFF00FF00"
RPH_QUEST_ACTIVE_COLOUR = "|cFFFF7F7F"
RPH_LOWLIGHT_COLOUR = "|cFFFF3F3F"
RPH_SUPPRESS_COLOUR = "|cFF7F7F7F"
--Profestions ggg
RPH_LIMIT_TYPE_Herb = 1
RPH_LIMIT_TYPE_Skin = 2
RPH_LIMIT_TYPE_Mine = 3
RPH_LIMIT_TYPE_Gather = 4
RPH_LIMIT_TYPE_Engi = 5
RPH_LIMIT_TYPE_Alch = 6
RPH_LIMIT_TYPE_Blac = 7
RPH_LIMIT_TYPE_Tail = 8
RPH_LIMIT_TYPE_Leat = 9
RPH_LIMIT_TYPE_Ench = 10
RPH_LIMIT_TYPE_Jewe = 11
RPH_LIMIT_TYPE_Incr = 12
RPH_LIMIT_TYPE_Aid = 13
RPH_LIMIT_TYPE_Arch = 14
RPH_LIMIT_TYPE_Cook = 15
RPH_LIMIT_TYPE_Fish = 16
--------------------------
-- _01_ Addon Variables --
--------------------------
-- Stored data
RPH_Data = {} -- Data saved between sessions
-- Initialization
RPH_Main = nil -- Main program window
RPH_InitComplete = nil
RPH_VarsLoaded = nil
RPH_InitStages = 0
RPH_InitCount = 0
RPH_difficultyID = 0
RPH_UpdateRequest = nil
RPH_UPDATE_INTERVAL = 5
-- Faction information
RPH_FactionMapping = {}
RPH_FactionGain = {}
-- Tracking data
RPH_Entries = {}
-- Skill Tracking ggg
RPH_Herb = false
RPH_Skin = false
RPH_Mine = false
RPH_Jewel = false
RPH_Cook = false
RPH_Arch = false
RPH_Fish = false
RPH_Aid = false
RPH_Black = false
RPH_Tailor = false
RPH_Leath = false
RPH_Enchan = false
RPH_Engin = false
RPH_Incrip = false
RPH_Alche = false
--- Race/Side/Difficulty
RPH_IsHuman = false
RPH_IsDeathKnight = false
RPH_IsAlliance = false
RPH_IsHorde = false
RPH_IsHeroic=false
-- Guild Tracking
RPH_GuildName = nil
-- Garrison Trading post level 3
RPH_HasTradingPost = false
RPH_OnLoadingScreen = false
------------------------
-- _02_ Addon Startup --
------------------------
------------------------------------------------------------
function RPH_OnLoad(self)
-- Events monitored by Event Handler
RPH_Main = self
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("VARIABLES_LOADED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("LOADING_SCREEN_ENABLED")
self:RegisterEvent("LOADING_SCREEN_DISABLED")
-- Slash commands for CLI
SLASH_RPH1 = "/rephelper"
SLASH_RPH2 = "/rph"
SlashCmdList.RPH = RPH_SlashHandler
RPH_Orig_GetFactionInfo = GetFactionInfo; -- api function
--GetFactionInfo = RPH_GetFactionInfo; -- api function
RPH_Orig_ReputationFrame_Update = ReputationFrame_Update -- rfl function
ReputationFrame_Update = RPH_ReputationFrame_Update -- rfl function
RPH_Orig_ReputationBar_OnClick = ReputationBar_OnClick -- rfl function
ReputationBar_OnClick = RPH_ReputationBar_OnClick -- rfl function
RPH_Orig_ExpandFactionHeader = ExpandFactionHeader
ExpandFactionHeader = RPH_ExpandFactionHeader
RPH_Orig_CollapseFactionHeader = CollapseFactionHeader
CollapseFactionHeader = RPH_CollapseFactionHeader
--RPH_Orig_ChatFrame_OnEvent = ChatFrame_OnEvent
--ChatFrame_OnEvent = RPH_ChatFrame_OnEvent
RPH_Orig_StandingText = ReputationFrameStandingLabel:GetText()
end
------------------------
-- _03_ Event Handler --
------------------------
function RPH_OnEvent(self, event, ...)
if (event== "LOADING_SCREEN_ENABLED") then
RPH_OnLoadingScreen = true
end
if (event == "LOADING_SCREEN_DISABLED") then
RPH_OnLoadingScreen = false
RPH:DumpReputationChangesToChat() -- Just to make sure we don't miss printing out any rep gain that occured during the loading screen
end
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 = ...
if (event == "ADDON_LOADED") and (arg1 == RPH_NAME) then
RPH_Main:UnregisterEvent("ADDON_LOADED")
RPH_InitStages = RPH_InitStages + 1
RPH:Init()
elseif (event == "VARIABLES_LOADED") then
RPH_OnShowOptionFrame()
RPH_VarsLoaded = true
RPH_InitStages = RPH_InitStages + 2
RPH:Init()
elseif (event == "PLAYER_LOGIN") then
RPH_Main:UnregisterEvent("PLAYER_LOGIN")
--RPH_DoInitialCollapse()
RPH_InitStages = RPH_InitStages + 4
RPH:Init()
elseif (event == "PLAYER_ENTERING_WORLD") then
RPH_InitStages = RPH_InitStages + 8
RPH:Init()
RPH_Main:UnregisterEvent("PLAYER_ENTERING_WORLD")
RPH_Main:RegisterEvent("UPDATE_FACTION") --rfl
-- to keep item list up to date
RPH_Main:RegisterEvent("BAG_UPDATE")
RPH_Main:RegisterEvent("BANKFRAME_OPENED")
RPH_Main:RegisterEvent("BANKFRAME_CLOSED")
-- to keep dungeon Difficulty up to date
RPH_Main:RegisterEvent("PLAYER_DIFFICULTY_CHANGED")
-- to keep list of known skills up to date
RPH_Main:RegisterEvent("CHAT_MSG_SKILL")
RPH_Main:RegisterEvent("SKILL_LINES_CHANGED")
RPH_Main:RegisterEvent("UPDATE_TRADESKILL_RECAST")
RPH_Main:RegisterEvent("QUEST_COMPLETE")
RPH_Main:RegisterEvent("QUEST_WATCH_UPDATE")
RPH_Main:RegisterEvent("GARRISON_UPDATE")
-- new chat hook system
ChatFrame_AddMessageEventFilter("CHAT_MSG_COMBAT_FACTION_CHANGE", RPH_ChatFilter)
ChatFrame_AddMessageEventFilter("COMBAT_TEXT_UPDATE", RPH_ChatFilter)
elseif (event == "UPDATE_FACTION" or
event == "QUEST_COMPLETE" or
event == "QUEST_WATCH_UPDATE") then
-- rfl Event v
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
-- rfl event ^
if ( RPH_ReputationDetailFrame:IsVisible()) then
RPH:BuildUpdateList()
RPH_UpdateList_Update()
end
RPH:DumpReputationChangesToChat()
elseif ( event == "BAG_UPDATE") then
if (RPH_ReputationDetailFrame:IsVisible()) then
-- Update rep frame (implicitely updates detail frame which In turn implicitely reparses bag contents)
ReputationFrame_Update()
end
elseif ( event == "BANKFRAME_OPENED") then
RPH_BankOpen = true
elseif ( event == "BANKFRAME_CLOSED") then
-- this is fired twice when closing the bank window, bank contents only available at the first Event
if (RPH_BankOpen) then
-- this is the first call
RPH_BankOpen = nil
if (RPH_ReputationDetailFrame:IsVisible()) then
-- Update rep frame (implicitely updates detail frame which In turn implicitely reparses bag contents)
ReputationFrame_Update()
end
end
elseif ( event == "PLAYER_DIFFICULTY_CHANGED") then -- ccc
--RPH:Print("PLAYER_DIFFICULTY_CHANGED", nil)
elseif ( event == "CHAT_MSG_SKILL") or
( event == "SKILL_LINES_CHANGED") or
( event == "UPDATE_TRADESKILL_RECAST") then
RPH:ExtractSkills()
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( RPH_ReputationDetailFrame:IsVisible()) then
RPH:BuildUpdateList()
RPH_UpdateList_Update()
end
elseif (event == "GARRISON_UPDATE") then
-- Get garrison buildings to check for trading post
local garrisonBuildings = C_Garrison.GetBuildings(Enum.GarrisonType.Type_6_0)
for i, building in pairs(garrisonBuildings) do
if building["buildingID"] == 145 then
RPH_HasTradingPost = true
end
end
RPH_InitStages = RPH_InitStages + 5
RPH:Init()
RPH_Main:UnregisterEvent("GARRISON_UPDATE")
end
end
-------------------------------
function RPH_OnUpdate(self)
if not RPH_UpdateRequest then return end
if RPH_InitComplete and RPH_InitCount > 5 then return end
if (GetTime() < RPH_UpdateRequest) then return end
if (RPH_InitCount <= 5) then
-- Guild level seems to only return a proper value a little later
--RPH:Print("update number "..tostring(RPH_InitCount))
RPH_InitCount = RPH_InitCount + 1
RPH_UpdateRequest = GetTime() + RPH_UPDATE_INTERVAL
if (RPH_InitCount > 5) then
RPH_UpdateRequest = nil
--RPH:Print("Stopping updates")
end
end
end
function RPH:DumpTable(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. RPH:DumpTable(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
-------------------------------
-- _04_ Addon Initialization --
-------------------------------
function RPH:InitVariable(var, value)
local result = 0
if var == nil then return result end
if (not RPH_Data[var]) and (not RPH_Data[var.."_inited"]) then
-- this option is not Set, and has never been Set by default, do so and let the user know
RPH_Data[var] = value
RPH_Data[var.."_inited"] = true
result = 1
elseif (not RPH_Data[var.."_inited"]) then
-- the option is enabled, but not marked as inited, do so silently
RPH_Data[var.."_inited"] = true
end
return result
end
-------------------------------
function RPH:Init()
if RPH_InitComplete then return end
--RPH:Print("RPH_InitStages ["..tostring(RPH_InitStages).."]")
if (RPH_InitStages ~= 20) then return end
local version = GetAddOnMetadata("RepHelper", "Version");
if (version == nil) then
version = "unknown";
end
-- create data structures
if not RPH_Data then RPH_Data = {} end
if not RPH_Data.OriginalCollapsed then RPH_Data.OriginalCollapsed = {} end
if RPH_Data.ChatFrame == nil then RPH_Data.ChatFrame = 0 end
local changed = 0
changed = changed + RPH:InitVariable("ShowMobs", true)
changed = changed + RPH:InitVariable("ShowQuests", true)
changed = changed + RPH:InitVariable("ShowInstances", true)
changed = changed + RPH:InitVariable("ShowItems", true)
changed = changed + RPH:InitVariable("ShowGeneral", true)
changed = changed + RPH:InitVariable("ShowMissing", true)
changed = changed + RPH:InitVariable("ExtendDetails", true)
changed = changed + RPH:InitVariable("WriteChatMessage", true)
changed = changed + RPH:InitVariable("NoGuildGain", true)
changed = changed + RPH:InitVariable("ShowPreviewRep", true)
changed = changed + RPH:InitVariable("SwitchFactionBar", true)
changed = changed + RPH:InitVariable("SilentSwitch", true)
changed = changed + RPH:InitVariable("NoGuildSwitch", true)
changed = changed + RPH:InitVariable("ShowParagonBar", true)
if (changed > 0) then
StaticPopupDialogs["RPH_CONFIG_CHANGED"] = {
text = RPH_TXT.configQuestion,
button1 = RPH_TXT.showConfig,
button2 = RPH_TXT.later,
OnAccept = function()
RPH:ToggleConfigWindow(); --- f_tcw
end,
--OnCancel = function()
-- RPH:Print(GLDG_Data.colours.help..GLDG_NAME..":|cFFFF0000 "..GLDG_TXT.reload)
-- end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
sound = SOUNDKIT.IG_QUEST_LOG_ABANDON_QUEST,
};
StaticPopup_Show("RPH_CONFIG_CHANGED");
end
-- keep version In configuration file
RPH_Data.Version = RPH_VNMBR
-- Set up UI
RPH_OptionsFrameTitle:SetText(RPH_NAME.." "..RPH_TXT.options)
RPH_EnableMissingBoxText:SetText(RPH_TXT.showMissing)
RPH_ExtendDetailsBoxText:SetText(RPH_TXT.extendDetails)
RPH_GainToChatBoxText:SetText(RPH_TXT.gainToChat)
RPH_NoGuildGainBoxText:SetText(RPH_TXT.noGuildGain)
RPH_ShowPreviewRepBoxText:SetText(RPH_TXT.showPreviewRep)
RPH_SwitchFactionBarBoxText:SetText(RPH_TXT.switchFactionBar)
RPH_NoGuildSwitchBoxText:SetText(RPH_TXT.noGuildSwitch)
RPH_SilentSwitchBoxText:SetText(RPH_TXT.silentSwitch)
RPH_OrderByStandingCheckBoxText:SetText(RPH_TXT.orderByStanding)
RPH_EnableParagonBarBoxText:SetText(RPH_TXT.EnableParagonBar)
--- RPH_OnShowOptionFrame()
RPH:ExtractSkills()
local _, race = UnitRace("player")
local faction, locFaction = UnitFactionGroup("player")
local class, enClass = UnitClass("player")
RPH_Player = UnitName("player")
RPH_Realm = GetRealmName()
if (IsInGuild()) then
if (RPH_GuildName == nil or RPH_GuildName == "") then RPH_GuildName = GetGuildInfo("player") end
end
if (race and faction and locFaction and RPH_Player and RPH_Realm) then
if (race == "Human") then
RPH_IsHuman = true
end
if enClass and enClass == "DEATHKNIGHT" then
RPH_IsDeathKnight = true
end
if (faction == FACTION_ALLIANCE) or (locFaction == FACTION_ALLIANCE) then
RPH_IsAlliance = true
end
if (faction == FACTION_HORDE) or (locFaction == FACTION_HORDE) then
RPH_IsHorde = true
end
RPH:InitFactor(RPH_IsHuman)
-- Initialize Faction information
local locale = GetLocale()
RPH:InitFactionMap(locale, RPH_GuildName)
-- Changed by Bagdad for easy reputation content moderation
RPH_FactionGain = {}
RPH_InitEnFactionGains(RPH_GuildName)
RPH:DumpReputationChangesToChat(true)
RPH_InitComplete = true
if (RPH_InitCount <= 5) then
RPH_UpdateRequest = GetTime() + RPH_UPDATE_INTERVAL
--RPH:Print("Init complete, setting up updates ("..tostring(RPH_InitCount).." already done)")
--else
--RPH:Print("Init complete, not starting updates")
end
end
end
function RPH:ToggleDarkmoonFaireBuff()
RPH_FactionGain = {}
RPH_InitEnFactionGains(RPH_GuildName)
RPH_ReputationFrame_Update()
end
------------------------
-- _05_ Slash Handler --
------------------------
function RPH_SlashHandler(msg)
if not msg then
return
else
local msgLower = string.lower(msg)
local words = RPH:GetWords(msg)
local wordsLower = RPH:GetWords(msgLower)
local size = RPH:TableSize(wordsLower)
local FD_SH = RPH_Data
if (size>0) then
if (wordsLower[0]=="enable") then
if (size>1) then
if (wordsLower[1]=="mobs") then
FD_SH.ShowMobs = true
elseif (wordsLower[1]=="quests") then
FD_SH.ShowQuests = true
elseif (wordsLower[1]=="dungeons" or wordsLower[1]=="instances") then
FD_SH.ShowInstances = true
elseif (wordsLower[1]=="items") then
FD_SH.ShowItems = true
elseif (wordsLower[1]=="general") then
FD_SH.ShowGeneral = true
elseif (wordsLower[1]=="missing") then
FD_SH.ShowMissing = true
elseif (wordsLower[1]=="details") then
FD_SH.ExtendDetails = true
elseif (wordsLower[1]=="chat") then
FD_SH.WriteChatMessage = true
FD_SH.NoGuildGain = false
elseif (wordsLower[1]=="preview") then
FD_SH.ShowPreviewRep = true
elseif (wordsLower[1]=="bar") then
FD_SH.SwitchFactionBar = true
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
elseif (wordsLower[1]=="paragon") then
FD_SH.ShowParagonBar = true
elseif (wordsLower[1]=="all") then
FD_SH.ShowMobs = true
FD_SH.ShowQuests = true
FD_SH.ShowInstances = true
FD_SH.ShowItems = true
FD_SH.ShowGeneral = true
FD_SH.ShowMissing = true
FD_SH.ExtendDetails = true
FD_SH.WriteChatMessage = true
FD_SH.NoGuildGain = false
FD_SH.ShowPreviewRep = true
FD_SH.SwitchFactionBar = true
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( RPH_ReputationDetailFrame:IsVisible()) then
RPH:BuildUpdateList()
RPH_UpdateList_Update()
end
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
elseif (wordsLower[0]=="disable") then
if (size>1) then
if (wordsLower[1]=="mobs") then
FD_SH.ShowMobs = false
elseif (wordsLower[1]=="quests") then
FD_SH.ShowQuests = false
elseif (wordsLower[1]=="dungeons" or wordsLower[1]=="instances") then
FD_SH.ShowInstances = false
elseif (wordsLower[1]=="items") then
FD_SH.ShowItems = false
elseif (wordsLower[1]=="general") then
FD_SH.ShowGeneral = false
elseif (wordsLower[1]=="missing") then
FD_SH.ShowMissing = false
elseif (wordsLower[1]=="details") then
FD_SH.ExtendDetails = false
elseif (wordsLower[1]=="chat") then
FD_SH.WriteChatMessage = false
FD_SH.NoGuildGain = false
elseif (wordsLower[1]=="preview") then
FD_SH.ShowPreviewRep = false
elseif (wordsLower[1]=="bar") then
FD_SH.SwitchFactionBar = false
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
elseif (wordsLower[1]=="paragon") then
FD_SH.ShowParagonBar = false
elseif (wordsLower[1]=="all") then
FD_SH.ShowMobs = false
FD_SH.ShowQuests = false
FD_SH.ShowInstances = false
FD_SH.ShowItems = false
FD_SH.ShowGeneral = false
FD_SH.ShowMissing = false
FD_SH.ExtendDetails = false
FD_SH.WriteChatMessage = false
FD_SH.NoGuildGain = false
FD_SH.ShowPreviewRep = false
FD_SH.SwitchFactionBar = false
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( RPH_ReputationDetailFrame:IsVisible()) then
RPH:BuildUpdateList()
RPH_UpdateList_Update()
end
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
elseif (wordsLower[0]=="toggle") then
if (size>1) then
if (wordsLower[1]=="mobs") then
FD_SH.ShowMobs = not FD_SH.ShowMobs
elseif (wordsLower[1]=="quests") then
FD_SH.ShowQuests = not FD_SH.ShowQuests
elseif (wordsLower[1]=="dungeons" or wordsLower[1]=="instances") then
FD_SH.ShowInstances = not FD_SH.ShowInstances
elseif (wordsLower[1]=="items") then
FD_SH.ShowItems = not FD_SH.ShowItems
elseif (wordsLower[1]=="general") then
FD_SH.ShowGeneral = not FD_SH.ShowGeneral
elseif (wordsLower[1]=="missing") then
FD_SH.ShowMissing = not FD_SH.ShowMissing
elseif (wordsLower[1]=="details") then
FD_SH.ExtendDetails = not FD_SH.ExtendDetails
elseif (wordsLower[1]=="chat") then
FD_SH.WriteChatMessage = not FD_SH.WriteChatMessage
FD_SH.NoGuildGain = false
elseif (wordsLower[1]=="preview") then
FD_SH.ShowPreviewRep = not FD_SH.ShowPreviewRep
elseif (wordsLower[1]=="preview") then
FD_SH.SwitchFactionBar = not FD_SH.SwitchFactionBar
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
elseif (wordsLower[1]=="paragon") then
FD_SH.ShowParagonBar = not FD_SH.ShowParagonBar;
elseif (wordsLower[1]=="all") then
FD_SH.ShowMobs = not FD_SH.ShowMobs
FD_SH.ShowQuests = not FD_SH.ShowQuests
FD_SH.ShowInstances = not FD_SH.ShowInstances
FD_SH.ShowItems = not FD_SH.ShowItems
FD_SH.ShowGeneral = not FD_SH.ShowGeneral
FD_SH.ShowMissing = not FD_SH.ShowMissing
FD_SH.ExtendDetails = not FD_SH.ExtendDetails
FD_SH.WriteChatMessage = not FD_SH.WriteChatMessage
FD_SH.NoGuildGain = false
FD_SH.ShowPreviewRep = not FD_SH.ShowPreviewRep
FD_SH.SwitchFactionBar = not FD_SH.SwitchFactionBar
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( RPH_ReputationDetailFrame:IsVisible()) then
RPH:BuildUpdateList()
RPH_UpdateList_Update()
end
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
elseif (wordsLower[0]=="list") then
if (size>1) then
if (wordsLower[1]=="1" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL1"])) then
RPH:ListByStanding(1)
elseif (wordsLower[1]=="2" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL2"])) then
RPH:ListByStanding(2)
elseif (wordsLower[1]=="3" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL3"])) then
RPH:ListByStanding(3)
elseif (wordsLower[1]=="4" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL4"])) then
RPH:ListByStanding(4)
elseif (wordsLower[1]=="5" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL5"])) then
RPH:ListByStanding(5)
elseif (wordsLower[1]=="6" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL6"])) then
RPH:ListByStanding(6)
elseif (wordsLower[1]=="7" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL7"])) then
RPH:ListByStanding(7)
elseif (wordsLower[1]=="8" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL8"])) then
RPH:ListByStanding(8)
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
else
RPH:ListByStanding()
end
elseif (wordsLower[0]=="loc") then
if (size>1) then
if (wordsLower[1]=="1" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL1"])) then
RPH:ListByStanding(1)
elseif (wordsLower[1]=="2" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL2"])) then
RPH:ListByStanding(2)
elseif (wordsLower[1]=="3" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL3"])) then
RPH:ListByStanding(3)
elseif (wordsLower[1]=="4" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL4"])) then
RPH:ListByStanding(4)
elseif (wordsLower[1]=="5" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL5"])) then
RPH:ListByStanding(5)
elseif (wordsLower[1]=="6" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL6"])) then
RPH:ListByStanding(6)
elseif (wordsLower[1]=="7" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL7"])) then
RPH:ListByStanding(7)
elseif (wordsLower[1]=="8" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL8"])) then
RPH:ListByStanding(8)
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
else
RPH_ShowGerman()
end
elseif (wordsLower[0]=="test") then
RPH_Test()
elseif (wordsLower[0]=="status") then
RPH:Status()
elseif (wordsLower[0]=="help") then
RPH:Help()
elseif (wordsLower[0]=="about") then
RPH:About()
else
RPH:PrintSlash(RPH_TXT.command,msgLower)
end
else
-- do nothing
end
end
end
-----------------------------------
-- _06_ General Helper Functions --
-----------------------------------
function RPH:Print(msg, forceDefault) --zzz
if not (msg) then return end
if ((RPH_Data==nil) or forceDefault) then
DEFAULT_CHAT_FRAME:AddMessage(msg)
else
for i = 1, NUM_CHAT_WINDOWS do
local chatTab = _G["ChatFrame"..i.."Tab"]
if chatTab:IsShown() then
local chatFrame = _G["ChatFrame"..i]
local messageTypes = chatFrame.messageTypeList
for j = 1, #messageTypes do
if messageTypes[j] == "COMBAT_FACTION_CHANGE" then
_G["ChatFrame"..i]:AddMessage(msg)
end
end
end
end
end
end
------------------------------------------------------------
function RPH:Printtest(msg,msg1,msg2) --fpt
RPH:Print(""..tostring(msg).." "..tostring(msg1).." "..tostring(msg2), nil)
end
------------------------------------------------------------
function RPH:PrintSlash(msg,msg1) --zzz
RPH:Print(RPH_Help_COLOUR..RPH_NAME..":|r "..msg.." ["..RPH_Help_COLOUR..msg1.."|r]", true)
RPH:Help()
end
------------------------------------------------------------
function RPH:Debug(msg)
if not (msg) then return end
--RPH:Print(msg)
end
------------------------------------------------------------
function RPH:TableSize(info)
local result = 0
if info then
for item in pairs(info) do result = result + 1 end
end
return result
end
------------------------------------------------------------
function RPH:GetWords(str)
local ret = {};
local pos=0;
local index=0
while(true) do
local word;
_,pos,word=string.find(str, "^ *([^%s]+) *", pos+1);
if(not word) then
return ret;
end
ret[index]=word
index = index+1
end
end
------------------------------------------------------------
function RPH:Concat(list, start, stop)
local ret = "";
if (start == nil) then start = 0 end
if (stop == nil) then stop = RPH:TableSize(list) end
for i = start,stop do
if list[i] then
if (ret ~= "") then ret = ret.." " end
ret = ret..list[i]
end
end
return ret
end
------------------------------------------------------------
function RPH:BoolToEnabled(b)
local result = RPH_TXT.disabled
if b then result = RPH_TXT.enabled end
return result
end
------------------------------------------------------------
function RPH:RGBToColour_perc(a, r, g, b)
return string.format("|c%02X%02X%02X%02X", a*255, r*255, g*255, b*255)
end
function RPH:has_value (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
------------------------
-- _07_ information
------------------------
function RPH:Help() --xxx
RPH:Print(" ", true)
RPH:Print(RPH_Help_COLOUR..RPH_NAME..":|r "..RPH_TXT.help, true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph help "..RPH_Help_COLOUR..RPH_TXT.helphelp, true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph about "..RPH_Help_COLOUR..RPH_TXT.helpabout, true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph status "..RPH_Help_COLOUR..RPH_TXT.helpstatus, true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph enable { mobs | quests | instances | items | all }", true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph disable { mobs | quests | instances | items | all }", true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph toggle { mobs | quests | instances | items | all }", true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph enable { missing | details | chat | paragon }", true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph disable { missing | details | chat | paragon}", true)
RPH:Print(RPH_Help_COLOUR..RPH_TXT.usage..":|r /rph toggle { missing | details | chat | paragon}" , true)
end
------------------------------------------------------------
function RPH:About()
local ver = GetAddOnMetadata("RepHelper", "Version");
local date = GetAddOnMetadata("RepHelper", "X-Date");
local author = GetAddOnMetadata("RepHelper", "Author");
local web = GetAddOnMetadata("RepHelper", "X-Website");
if (author ~= nil) then
RPH:Print(RPH_NAME.." "..RPH_TXT.by.." "..RPH_Help_COLOUR..author.."|r", true);
end
if (ver ~= nil) then
RPH:Print(" "..RPH_TXT.version..": "..RPH_Help_COLOUR..ver.."|r", true);
end
if (date ~= nil) then
RPH:Print(" "..RPH_TXT.date..": "..RPH_Help_COLOUR..date.."|r", true);
end
if (web ~= nil) then
RPH:Print(" "..RPH_TXT.web..": "..RPH_Help_COLOUR..web.."|r", true);
end
end
------------------------------------------------------------
function RPH:Status()
RPH:Print(" ", true)
RPH:Print(RPH_Help_COLOUR..RPH_NAME..":|r "..RPH_TXT.status, true)
RPH:Print(" "..RPH_TXT.statMobs..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowMobs).."|r", true)
RPH:Print(" "..RPH_TXT.statQuests..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowQuests).."|r", true)
RPH:Print(" "..RPH_TXT.statInstances..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowInstances).."|r", true)
RPH:Print(" "..RPH_TXT.statItems..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowItems).."|r", true)
RPH:Print(" "..RPH_TXT.statGeneral..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowGeneral).."|r", true)
RPH:Print(" "..RPH_TXT.statMissing..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowMissing).."|r", true)
RPH:Print(" "..RPH_TXT.statDetails..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ExtendDetails).."|r", true)
RPH:Print(" "..RPH_TXT.statChat..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.WriteChatMessage).."|r", true)
RPH:Print(" "..RPH_TXT.statNoGuildChat..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.NoGuildGain).."|r", true)
RPH:Print(" "..RPH_TXT.statPreview..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowPreviewRep).."|r", true)
RPH:Print(" "..RPH_TXT.statSwitch..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.SwitchFactionBar).."|r", true)
RPH:Print(" "..RPH_TXT.statNoGuildSwitch..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.NoGuildSwitch).."|r", true)
RPH:Print(" "..RPH_TXT.statSilentSwitch..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.SilentSwitch).."|r", true)
RPH:Print(" "..RPH_TXT.EnableParagonBar..": "..RPH_Help_COLOUR..RPH:BoolToEnabled(RPH_Data.ShowParagonBar).."|r", true)
end
-----------------------------------
-- _08_ Faction map --
-----------------------------------
function RPH:InitMapName(fimap)
--- fpt f_imn RPH:Printtest(fimap,"","map 1")
local map
if fimap == 1 then
map = RPH_TXT.srfd
elseif fimap== 2 then
map = RPH_TXT.tbd
elseif fimap== 3 then
map = RPH_TXT.mnd
elseif fimap== 5 then
map = RPH_TXT.nci
elseif fimap == 6 then
map = RPH_TXT.hci
elseif not fimap then
map = " "
else
local mapName = C_Map.GetMapInfo(fimap).name
map = mapName
end
--- fpt f_imn RPH:Printtest(fimap,"","map 2")
if not map then
map = fimap
end
return map
end
function RPH:InitMobName(fimob)
--- fpt f_ion RPH:Printtest(fimob,"","mob 1")
local mob
if fimob == 1 then
mob = RPH_TXT.tmob
elseif fimob== 2 then
mob = RPH_TXT.oboss
elseif fimob== 3 then
mob = RPH_TXT.aboss
elseif fimob == 4 then
mob = RPH_TXT.pboss
elseif fimob == 5 then
mob = RPH_TXT.fclear
elseif fimob == 11 then
mob = (RPH_TXT.AU.." "..RPH_TXT.BB)
elseif fimob== 12 then
mob = (RPH_TXT.AU.." "..RPH_TXT.SSP)
elseif fimob== 13 then
mob = (RPH_TXT.AU.." "..RPH_TXT.Wa)
elseif fimob == 14 then
mob = RPH_TXT.VCm
elseif fimob == 15 then
mob = (RPH_TXT.AN.." "..RPH_TXT.BB)
elseif fimob== 16 then
mob = (RPH_TXT.AN.." "..RPH_TXT.SSP)
elseif fimob== 17 then
mob = (RPH_TXT.AN.." "..RPH_TXT.Wa)
else
--[[-- local mobName = GetmobNameByID(fimob);
mob = mobName --]]--
end
--- fpt f_ion RPH:Printtest(fimob,mob,"mob 2")
if not mob then
mob = fimob
end
return mob
end
function RPH:InitItemName(fiitem,amt)
--- fpt f_iin RPH:Printtest(fiitem,amt,"item 1")
if fiitem==1 then
item_name = RPH_TXT.cdq
elseif fiitem==2 then
item_name = RPH_TXT.fdq
elseif fiitem==3 then
item_name = RPH_TXT.ndq
elseif fiitem == 4 then
item_name = RPH_TXT.cbadge
elseif fiitem == 5 then
item_name = RPH_TXT.deleted
else
item_name = GetItemInfo(fiitem)
end
if not item_name then
item = C_CurrencyInfo.GetCurrencyInfo(fiitem)
if item then
item_name = item.name
end
end
if not item_name then
item_name = fiitem
end
return item_name
end
function RPH:Quest_Names(questIndex)
RPH_HiddenQuestTooltip:SetOwner(WorldFrame, ANCHOR_NONE)
RPH_HiddenQuestTooltip:SetHyperlink(format("quest:%d", questIndex))
local quest = RPH_HiddenQuestTooltipTextLeft1:GetText()
RPH_HiddenQuestTooltip:Hide()
if questIndex == 1 then
quest = RPH_TXT.cdq
elseif questIndex == 2 then
quest = RPH_TXT.coq
elseif questIndex == 3 then
quest = RPH_TXT.fdq
elseif questIndex == 4 then
quest = RPH_TXT.foq
elseif questIndex == 5 then
quest = RPH_TXT.ndq
elseif questIndex == 6 then
quest = RPH_TXT.deleted
elseif questIndex == 7 then
quest = RPH_TXT.Championing
elseif questIndex == 8 then
quest = RPH_TXT.bpqfg
elseif questIndex == 9 then
quest = RPH_TXT.djdq
elseif questIndex == 99 then
quest = RPH_TXT.tbd
else
if not quest then
quest = questIndex
end
end
return quest
end
function RPH:GetTabardFaction()
for i = 1, 40 do
local _, _, _, _, _, _, _, _, _, _, id = UnitBuff("player", i)
if not id then
break
end
local data = championFactions[id]
if data then
local faction, level = data[2], data[1]
if DEBUG then self:Debug("GetChampionedFaction:", tostring(faction), tostring(level)) end
return faction, level
end
end
if DEBUG then self:Debug("GetChampionedFaction:", "none") end
end
function RPH:InitFactor(RPH_IsHuman,faction)
--- Thanks Gwalkmaur for the heads up
--RPH:Print("Faction: "..faction);
local draenorFactions = {"Council of Exarchs",
"Frostwolf Orcs",