forked from Daklerid/Factionizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Factionizer.lua
executable file
·4069 lines (3738 loc) · 135 KB
/
Factionizer.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
----------------------------------------------------------
-- Factionizer, a reputation management tool 5.04.00.7.2 14.4.27 41756.9846395833 --
-------------------------------------------------------
---------------------------
-- _00_ Variables Set up --
---------------------------
FIZ_ToExalted = {}
FIZ_ToExalted[0] = 84000;
FIZ_ToExalted[1] = 48000; -- working on Hated -> Hostile, base offset 21k+12k+6k+3k+3k+3k
FIZ_ToExalted[2] = 45000; -- working on Hostile -> Unfriendly, base offset 21k+12k+6k+3k+3k
FIZ_ToExalted[3] = 42000; -- working on Unfriendly -> Neutral, base offset 21k+12k+6k+3k
FIZ_ToExalted[4] = 39000; -- working on Neutral -> Friendly, base offset 21k+12k+6k
FIZ_ToExalted[5] = 33000; -- working on Friendly -> Honored, base offset 21k+12k
FIZ_ToExalted[6] = 21000; -- working on Honored -> Revered, base offset 21k
FIZ_ToExalted[7] = 0; -- working on Revered -> Exalted, so no base offset
FIZ_ToExalted[8] = 0; -- already at Exalted -> no offset
FIZ_ToBFF = {} --> Friendship levels:
FIZ_ToBFF[0] = 42999; --> 1 - Stranger: 0-8400
FIZ_ToBFF[1] = 42000; --> 2 - Acquaintance: 8400-16800
FIZ_ToBFF[2] = 33600; --> 3 - Buddy: 16800-25200
FIZ_ToBFF[3] = 25200; --> 4 - Friend: 25200-33600
FIZ_ToBFF[4] = 16800; --> 5 - Good Friend: 33600-42000
FIZ_ToBFF[5] = 8400; --> 6 - Best Friend: 42000-42999
-- Addon constants
FIZ_NAME = "Factionizer"
FIZ_VNMBR = 504007.2 -- Number code for this version
-- Colours
FIZ_HELP_COLOUR = "|cFFFFFF7F"
FIZ_NEW_REP_COLOUR = "|cFF7F7FFF"
FIZ_NEW_STANDING_COLOUR = "|cFF6060C0"
FIZ_BAG_COLOUR = "|cFFC0FFC0"
FIZ_BAG_BANK_COLOUR = "|cFFFFFF7F"
FIZ_QUEST_COLOUR = "|cFFC0FFC0"
FIZ_HIGHLIGHT_COLOUR = "|cFF00FF00"
FIZ_QUEST_ACTIVE_COLOUR = "|cFFFF7F7F"
FIZ_LOWLIGHT_COLOUR = "|cFFFF3F3F"
FIZ_SUPPRESS_COLOUR = "|cFF7F7F7F"
--Profestions ggg
FIZ_LIMIT_TYPE_Herb = 1
FIZ_LIMIT_TYPE_Skin = 2
FIZ_LIMIT_TYPE_Mine = 3
FIZ_LIMIT_TYPE_Gather = 4
FIZ_LIMIT_TYPE_Engi = 5
FIZ_LIMIT_TYPE_Alch = 6
FIZ_LIMIT_TYPE_Blac = 7
FIZ_LIMIT_TYPE_Tail = 8
FIZ_LIMIT_TYPE_Leat = 9
FIZ_LIMIT_TYPE_Ench = 10
FIZ_LIMIT_TYPE_Jewe = 11
FIZ_LIMIT_TYPE_Incr = 12
FIZ_LIMIT_TYPE_Aid = 13
FIZ_LIMIT_TYPE_Arch = 14
FIZ_LIMIT_TYPE_Cook = 15
FIZ_LIMIT_TYPE_Fish = 16
FIZ_GUILD_CAP_BASE = 4375
FIZ_FLAG_GUILD_CAP = 1000
--------------------------
-- _01_ Addon Variables --
--------------------------
-- Stored data
FIZ_Data = {} -- Data saved between sessions
-- Initialization
FIZ_Main = nil -- Main program window
FIZ_InitComplete = nil
FIZ_VarsLoaded = nil
FIZ_InitStages = 0
FIZ_InitCount = 0
FIZ_difficultyID = 0
FIZ_UpdateRequest = nil
FIZ_UPDATE_INTERVAL = 5
-- Faction information
FIZ_FactionMapping = {}
FIZ_FactionGain = {}
-- Tracking data
FIZ_Entries = {}
-- Skill Tracking ggg
FIZ_Herb = false
FIZ_Skin = false
FIZ_Mine = false
FIZ_Jewel = false
FIZ_Cook = false
FIZ_Arch = false
FIZ_Fish = false
FIZ_Aid = false
FIZ_Black = false
FIZ_Tailor = false
FIZ_Leath = false
FIZ_Enchan = false
FIZ_Engin = false
FIZ_Incrip = false
FIZ_Alche = false
--- Race/Side/Difficulty
FIZ_IsHuman = false
FIZ_IsDeathKnight = false
FIZ_IsAlliance = false
FIZ_IsHorde = false
FIZ_IsHeroic=false
-- Guild Tracking
FIZ_GuildName = nil
-- Guild rep cap
-- FIZ_CapIndex = nil
-- FIZ_Tuesday = nil
------------------------
-- _02_ Addon Startup --
------------------------
------------------------------------------------------------
function FIZ_OnLoad(self)
-- Events monitored by Event Handler
FIZ_Main = self
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("VARIABLES_LOADED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_LOGIN")
-- Slash commands for CLI
SLASH_FIZ1 = "/factionizer"
SLASH_FIZ2 = "/fz"
SlashCmdList.FIZ = FIZ_SlashHandler
FIZ_Orig_GetFactionInfo = GetFactionInfo; -- api function
GetFactionInfo = FIZ_GetFactionInfo; -- api function
FIZ_Orig_ReputationFrame_Update = ReputationFrame_Update -- rfl function
ReputationFrame_Update = FIZ_ReputationFrame_Update -- rfl function
FIZ_Orig_ReputationBar_OnClick = ReputationBar_OnClick -- rfl function
ReputationBar_OnClick = FIZ_ReputationBar_OnClick -- rfl function
FIZ_Orig_ExpandFactionHeader = ExpandFactionHeader
ExpandFactionHeader = FIZ_ExpandFactionHeader
FIZ_Orig_CollapseFactionHeader = CollapseFactionHeader
CollapseFactionHeader = FIZ_CollapseFactionHeader
--FIZ_Orig_ChatFrame_OnEvent = ChatFrame_OnEvent
--ChatFrame_OnEvent = FIZ_ChatFrame_OnEvent
FIZ_Orig_StandingText = ReputationFrameStandingLabel:GetText()
end
------------------------
-- _03_ Event Handler --
------------------------
function FIZ_OnEvent(self, event, ...)
--- fpt FIZ_Printtest("Event Handler ",tostring(Event),"")
local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 = ...
if (event == "ADDON_LOADED") and (arg1 == FIZ_NAME) then
FIZ_Main:UnregisterEvent("ADDON_LOADED")
FIZ_InitStages = FIZ_InitStages + 1
FIZ_Init()
elseif (event == "VARIABLES_LOADED") then
FIZ_OnShowOptionFrame()
FIZ_VarsLoaded = true
FIZ_InitStages = FIZ_InitStages + 2
FIZ_Init()
elseif (event == "PLAYER_LOGIN") then
FIZ_Main:UnregisterEvent("PLAYER_LOGIN")
--FIZ_DoInitialCollapse()
FIZ_InitStages = FIZ_InitStages + 4
FIZ_Init()
elseif (event == "PLAYER_ENTERING_WORLD") then
FIZ_InitStages = FIZ_InitStages + 8
FIZ_Init()
FIZ_Main:UnregisterEvent("PLAYER_ENTERING_WORLD")
FIZ_Main:RegisterEvent("UPDATE_FACTION") --rfl
FIZ_Main:RegisterEvent("LFG_BONUS_FACTION_ID_UPDATED") --rfl
-- to keep item list up to date
FIZ_Main:RegisterEvent("BAG_UPDATE")
FIZ_Main:RegisterEvent("BANKFRAME_OPENED")
FIZ_Main:RegisterEvent("BANKFRAME_CLOSED")
-- to keep dungeon difficulty up to date
FIZ_Main:RegisterEvent("PLAYER_DIFFICULTY_CHANGED")
-- to keep list of known skills up to date
FIZ_Main:RegisterEvent("CHAT_MSG_SKILL")
FIZ_Main:RegisterEvent("CHAT_MSG_SPELL_TRADESKILLS")
FIZ_Main:RegisterEvent("SKILL_LINES_CHANGED")
FIZ_Main:RegisterEvent("UPDATE_TRADESKILL_RECAST")
FIZ_Main:RegisterEvent("QUEST_COMPLETE")
FIZ_Main:RegisterEvent("QUEST_WATCH_UPDATE")
-- new chat hook system
ChatFrame_AddMessageEventFilter("CHAT_MSG_COMBAT_FACTION_CHANGE", FIZ_ChatFilter)
ChatFrame_AddMessageEventFilter("COMBAT_TEXT_UPDATE", FIZ_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 ( FIZ_ReputationDetailFrame:IsVisible()) then
FIZ_BuildUpdateList()
FIZ_UpdateList_Update()
end
FIZ_DumpReputationChangesToChat()
elseif ( event == "BAG_UPDATE") then
if (FIZ_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
FIZ_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 (FIZ_BankOpen) then
-- this is the first call
FIZ_ParseBankContent()
FIZ_BankOpen = nil
if (FIZ_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
FIZ_Print("PLAYER_DIFFICULTY_CHANGED", nil)
elseif ( event == "CHAT_MSG_SKILL") or
( event == "CHAT_MSG_SPELL_TRADESKILLS") or
( event == "SKILL_LINES_CHANGED") or
( event == "UPDATE_TRADESKILL_RECAST") then
FIZ_ExtractSkills()
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( FIZ_ReputationDetailFrame:IsVisible()) then
FIZ_BuildUpdateList()
FIZ_UpdateList_Update()
end
end
end
-------------------------------
function FIZ_OnUpdate(self)
if not FIZ_UpdateRequest then return end
if FIZ_InitComplete and FIZ_InitCount > 5 then return end
if (GetTime() < FIZ_UpdateRequest) then return end
if (FIZ_InitCount <= 5) then
-- Guild level seems to only return a proper value a little later
--FIZ_Print("update number "..tostring(FIZ_InitCount))
FIZ_InitCount = FIZ_InitCount + 1
FIZ_UpdateRequest = GetTime() + FIZ_UPDATE_INTERVAL
if (FIZ_InitCount > 5) then
FIZ_UpdateRequest = nil
--FIZ_Print("Stopping updates")
end
end
end
-------------------------------
-- _04_ Addon Initialization --
-------------------------------
function FIZ_InitVariable(var, value)
local result = 0
if var == nil then return result end
if (not FIZ_Data[var]) and (not FIZ_Data[var.."_inited"]) then
-- this option is not Set, and has never been Set by default, do so and let the user know
FIZ_Data[var] = value
FIZ_Data[var.."_inited"] = true
result = 1
elseif (not FIZ_Data[var.."_inited"]) then
-- the option is enabled, but not marked as inited, do so silently
FIZ_Data[var.."_inited"] = true
end
return result
end
-------------------------------
function FIZ_Init()
if FIZ_InitComplete then return end
--FIZ_Print("FIZ_InitStages ["..tostring(FIZ_InitStages).."]")
if (FIZ_InitStages ~= 15) then return end
local version = GetAddOnMetadata("Factionizer", "Version");
if (version == nil) then
version = "unknown";
end
-- create data structures
if not FIZ_Data then FIZ_Data = {} end
if not FIZ_Data.OriginalCollapsed then FIZ_Data.OriginalCollapsed = {} end
if FIZ_Data.ChatFrame == nil then FIZ_Data.ChatFrame = 0 end
local changed = 0
changed = changed + FIZ_InitVariable("ShowMobs", true)
changed = changed + FIZ_InitVariable("ShowQuests", true)
changed = changed + FIZ_InitVariable("ShowInstances", true)
changed = changed + FIZ_InitVariable("ShowItems", true)
changed = changed + FIZ_InitVariable("ShowGeneral", true)
changed = changed + FIZ_InitVariable("ShowMissing", true)
changed = changed + FIZ_InitVariable("ExtendDetails", true)
changed = changed + FIZ_InitVariable("WriteChatMessage", true)
changed = changed + FIZ_InitVariable("NoGuildGain", true)
changed = changed + FIZ_InitVariable("SuppressOriginalChat", true)
changed = changed + FIZ_InitVariable("ShowPreviewRep", true)
changed = changed + FIZ_InitVariable("SwitchFactionBar", true)
changed = changed + FIZ_InitVariable("SilentSwitch", true)
changed = changed + FIZ_InitVariable("NoGuildSwitch", true)
if (changed > 0) then
StaticPopupDialogs["FIZ_CONFIG_CHANGED"] = {
text = FIZ_TXT.configQuestion,
button1 = FIZ_TXT.showConfig,
button2 = FIZ_TXT.later,
OnAccept = function()
FIZ_ToggleConfigWindow(); --- f_tcw
end,
--OnCancel = function()
-- FIZ_Print(GLDG_Data.colours.help..GLDG_NAME..":|cFFFF0000 "..GLDG_TXT.reload)
-- end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
sound = "igQuestFailed",
};
StaticPopup_Show("FIZ_CONFIG_CHANGED");
end
-- keep version In configuration file
FIZ_Data.Version = FIZ_VNMBR
-- Set up UI
FIZ_OptionsButtonText:SetText(FIZ_TXT.options)
FIZ_OptionsFrameTitle:SetText(FIZ_NAME.." "..FIZ_TXT.options)
FIZ_EnableMissingBoxText:SetText(FIZ_TXT.showMissing)
FIZ_ExtendDetailsBoxText:SetText(FIZ_TXT.extendDetails)
FIZ_GainToChatBoxText:SetText(FIZ_TXT.gainToChat)
FIZ_NoGuildGainBoxText:SetText(FIZ_TXT.noGuildGain)
FIZ_SupressOriginalGainBoxText:SetText(FIZ_TXT.suppressOriginalGain)
FIZ_ShowPreviewRepBoxText:SetText(FIZ_TXT.showPreviewRep)
FIZ_SwitchFactionBarBoxText:SetText(FIZ_TXT.switchFactionBar)
FIZ_NoGuildSwitchBoxText:SetText(FIZ_TXT.noGuildSwitch)
FIZ_SilentSwitchBoxText:SetText(FIZ_TXT.silentSwitch)
FIZ_OrderByStandingCheckBoxText:SetText(FIZ_TXT.orderByStanding)
--- FIZ_OnShowOptionFrame()
FIZ_ExtractSkills()
local _, race = UnitRace("player")
local faction, locFaction = UnitFactionGroup("player")
local class, enClass = UnitClass("player")
FIZ_Player = UnitName("player")
FIZ_Realm = GetRealmName() -- FIZ_Realm = GetCVar("realmName")
-- gci FIZ_CapIndex = FIZ_Realm.." - "..FIZ_Player
if (IsInGuild()) then
if (FIZ_GuildName == nil or FIZ_GuildName == "") then FIZ_GuildName = GetGuildInfo("player") end
end
if (race and faction and locFaction and FIZ_Player and FIZ_Realm) then
if (race == "Human") then
FIZ_IsHuman = true
end
if enClass and enClass == "DEATHKNIGHT" then
FIZ_IsDeathKnight = true
end
if (faction == FACTION_ALLIANCE) or (locFaction == FACTION_ALLIANCE) then
FIZ_IsAlliance = true
end
if (faction == FACTION_HORDE) or (locFaction == FACTION_HORDE) then
FIZ_IsHorde = true
end
FIZ_InitFactor(FIZ_IsHuman)
-- Initialize Faction information
local locale = GetLocale()
FIZ_InitFactionMap(locale, FIZ_GuildName)
-- Changed by Bagdad for easy reputation content moderation
FIZ_FactionGain = {}
FIZ_InitEnFactionGains(FIZ_GuildName, FIZ_GUILD_CAP_BASE)
FIZ_DumpReputationChangesToChat(true)
FIZ_InitComplete = true
if (FIZ_InitCount <= 5) then
FIZ_UpdateRequest = GetTime() + FIZ_UPDATE_INTERVAL
--FIZ_Print("Init complete, setting up updates ("..tostring(FIZ_InitCount).." already done)")
--else
--FIZ_Print("Init complete, not starting updates")
end
end
end
------------------------
-- _05_ Slash Handler --
------------------------
function FIZ_SlashHandler(msg)
if not msg then
return
else
local msgLower = string.lower(msg)
local words = FIZ_GetWords(msg)
local wordsLower = FIZ_GetWords(msgLower)
local size = FIZ_TableSize(wordsLower)
local FD_SH = FIZ_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]=="suppress") then
FD_SH.SuppressOriginalChat = true
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]=="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.SuppressOriginalChat = true
FD_SH.ShowPreviewRep = true
FD_SH.SwitchFactionBar = true
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( FIZ_ReputationDetailFrame:IsVisible()) then
FIZ_BuildUpdateList()
FIZ_UpdateList_Update()
end
else
FIZ_PrintSlash(FIZ_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]=="suppress") then
FD_SH.SuppressOriginalChat = 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]=="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.SuppressOriginalChat = false
FD_SH.ShowPreviewRep = false
FD_SH.SwitchFactionBar = false
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( FIZ_ReputationDetailFrame:IsVisible()) then
FIZ_BuildUpdateList()
FIZ_UpdateList_Update()
end
else
FIZ_PrintSlash(FIZ_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]=="suppress") then
FD_SH.SuppressOriginalChat = not FD_SH.SuppressOriginalChat
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]=="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.SuppressOriginalChat = not FD_SH.SuppressOriginalChat
FD_SH.ShowPreviewRep = not FD_SH.ShowPreviewRep
FD_SH.SwitchFactionBar = not FD_SH.SwitchFactionBar
FD_SH.NoGuildSwitch = false
FD_SH.SilentSwitch = false
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
if ( ReputationFrame:IsVisible() ) then
ReputationFrame_Update(); -- rfl Event
end
if ( FIZ_ReputationDetailFrame:IsVisible()) then
FIZ_BuildUpdateList()
FIZ_UpdateList_Update()
end
else
FIZ_PrintSlash(FIZ_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
FIZ_ListByStanding(1)
elseif (wordsLower[1]=="2" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL2"])) then
FIZ_ListByStanding(2)
elseif (wordsLower[1]=="3" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL3"])) then
FIZ_ListByStanding(3)
elseif (wordsLower[1]=="4" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL4"])) then
FIZ_ListByStanding(4)
elseif (wordsLower[1]=="5" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL5"])) then
FIZ_ListByStanding(5)
elseif (wordsLower[1]=="6" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL6"])) then
FIZ_ListByStanding(6)
elseif (wordsLower[1]=="7" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL7"])) then
FIZ_ListByStanding(7)
elseif (wordsLower[1]=="8" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL8"])) then
FIZ_ListByStanding(8)
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
else
FIZ_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
FIZ_ShowGerman(1)
elseif (wordsLower[1]=="2" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL2"])) then
FIZ_ShowGerman(2)
elseif (wordsLower[1]=="3" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL3"])) then
FIZ_ShowGerman(3)
elseif (wordsLower[1]=="4" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL4"])) then
FIZ_ShowGerman(4)
elseif (wordsLower[1]=="5" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL5"])) then
FIZ_ShowGerman(5)
elseif (wordsLower[1]=="6" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL6"])) then
FIZ_ShowGerman(6)
elseif (wordsLower[1]=="7" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL7"])) then
FIZ_ShowGerman(7)
elseif (wordsLower[1]=="8" or wordsLower[1]==string.lower(_G["FACTION_STANDING_LABEL8"])) then
FIZ_ShowGerman(8)
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
else
FIZ_ShowGerman()
end
elseif (wordsLower[0]=="test") then
FIZ_Test()
elseif (wordsLower[0]=="status") then
FIZ_Status()
elseif (wordsLower[0]=="help") then
FIZ_Help()
elseif (wordsLower[0]=="about") then
FIZ_About()
else
FIZ_PrintSlash(FIZ_TXT.command,msgLower)
end
else
-- do nothing
end
end
end
-----------------------------------
-- _06_ General Helper Functions --
-----------------------------------
function FIZ_Print(msg, forceDefault) --zzz
if not (msg) then return end
if ((FIZ_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 FIZ_Printtest(msg,msg1,msg2) --fpt
FIZ_Print(""..tostring(msg).." "..tostring(msg1).." "..tostring(msg2), nil)
end
------------------------------------------------------------
function FIZ_PrintSlash(msg,msg1) --zzz
FIZ_Print(FIZ_HELP_COLOUR..FIZ_NAME..":|r "..msg.." ["..FIZ_HELP_COLOUR..msg1.."|r]", true)
FIZ_Help()
end
------------------------------------------------------------
function FIZ_Debug(msg)
if not (msg) then return end
--FIZ_Print(msg)
end
------------------------------------------------------------
function FIZ_TableSize(info)
local result = 0
if info then
for item in pairs(info) do result = result + 1 end
end
return result
end
------------------------------------------------------------
function FIZ_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 FIZ_Concat(list, start, stop)
local ret = "";
if (start == nil) then start = 0 end
if (stop == nil) then stop = FIZ_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 FIZ_BoolToEnabled(b)
local result = FIZ_TXT.disabled
if b then result = FIZ_TXT.enabled end
return result
end
------------------------------------------------------------
function FIZ_RGBToColour_perc(a, r, g, b)
return string.format("|c%02X%02X%02X%02X", a*255, r*255, g*255, b*255)
end
------------------------
-- _07_ information
------------------------
function FIZ_Help() --xxx
FIZ_Print(" ", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_NAME..":|r "..FIZ_TXT.help, true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz help "..FIZ_HELP_COLOUR..FIZ_TXT.helphelp, true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz about "..FIZ_HELP_COLOUR..FIZ_TXT.helpabout, true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz status "..FIZ_HELP_COLOUR..FIZ_TXT.helpstatus, true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz enable { mobs | quests | instances | items | all }", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz disable { mobs | quests | instances | items | all }", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz toggle { mobs | quests | instances | items | all }", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz enable { missing | details | chat | suppress }", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz disable { missing | details | chat | suppress }", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_TXT.usage..":|r /fz toggle { missing | details | chat | suppress }" , true)
end
------------------------------------------------------------
function FIZ_About()
local ver = GetAddOnMetadata("Factionizer", "Version");
local date = GetAddOnMetadata("Factionizer", "X-Date");
local author = GetAddOnMetadata("Factionizer", "Author");
local web = GetAddOnMetadata("Factionizer", "X-Website");
if (author ~= nil) then
FIZ_Print(FIZ_NAME.." "..FIZ_TXT.by.." "..FIZ_HELP_COLOUR..author.."|r", true);
end
if (ver ~= nil) then
FIZ_Print(" "..FIZ_TXT.version..": "..FIZ_HELP_COLOUR..ver.."|r", true);
end
if (date ~= nil) then
FIZ_Print(" "..FIZ_TXT.date..": "..FIZ_HELP_COLOUR..date.."|r", true);
end
if (web ~= nil) then
FIZ_Print(" "..FIZ_TXT.web..": "..FIZ_HELP_COLOUR..web.."|r", true);
end
end
------------------------------------------------------------
function FIZ_Status()
FIZ_Print(" ", true)
FIZ_Print(FIZ_HELP_COLOUR..FIZ_NAME..":|r "..FIZ_TXT.status, true)
FIZ_Print(" "..FIZ_TXT.statMobs..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowMobs).."|r", true)
FIZ_Print(" "..FIZ_TXT.statQuests..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowQuests).."|r", true)
FIZ_Print(" "..FIZ_TXT.statInstances..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowInstances).."|r", true)
FIZ_Print(" "..FIZ_TXT.statItems..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowItems).."|r", true)
FIZ_Print(" "..FIZ_TXT.statGeneral..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowGeneral).."|r", true)
FIZ_Print(" "..FIZ_TXT.statMissing..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowMissing).."|r", true)
FIZ_Print(" "..FIZ_TXT.statDetails..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ExtendDetails).."|r", true)
FIZ_Print(" "..FIZ_TXT.statChat..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.WriteChatMessage).."|r", true)
FIZ_Print(" "..FIZ_TXT.statNoGuildChat..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.NoGuildGain).."|r", true)
FIZ_Print(" "..FIZ_TXT.statSuppress..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.SuppressOriginalChat).."|r", true)
FIZ_Print(" "..FIZ_TXT.statPreview..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.ShowPreviewRep).."|r", true)
FIZ_Print(" "..FIZ_TXT.statSwitch..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.SwitchFactionBar).."|r", true)
FIZ_Print(" "..FIZ_TXT.statNoGuildSwitch..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.NoGuildSwitch).."|r", true)
FIZ_Print(" "..FIZ_TXT.statSilentSwitch..": "..FIZ_HELP_COLOUR..FIZ_BoolToEnabled(FIZ_Data.SilentSwitch).."|r", true)
end
-----------------------------------
-- _08_ Faction map --
-----------------------------------
function FIZ_Initmapname(fimap)
--- fpt f_imn FIZ_Printtest(fimap,"","map 1")
local map
if fimap == 1 then
map = FIZ_TXT.srfd
elseif fimap== 2 then
map = FIZ_TXT.tbd
elseif fimap== 3 then
map = FIZ_TXT.mnd
elseif fimap== 5 then
map = FIZ_TXT.nci
elseif fimap == 6 then
map = FIZ_TXT.hci
elseif not fimap then
map = " "
else
local mapName = GetMapNameByID(fimap);
map = mapName
end
--- fpt f_imn FIZ_Printtest(fimap,"","map 2")
if not map then
map = fimap
end
mark_map = map
end
function FIZ_Initmobname(fimob)
--- fpt f_ion FIZ_Printtest(fimob,"","mob 1")
local mob
if fimob == 1 then
mob = FIZ_TXT.tmob
elseif fimob== 2 then
mob = FIZ_TXT.oboss
elseif fimob== 3 then
mob = FIZ_TXT.aboss
elseif fimob == 4 then
mob = FIZ_TXT.pboss
elseif fimob == 5 then
mob = FIZ_TXT.fclear
elseif fimob == 11 then
mob = (FIZ_TXT.AU.." "..FIZ_TXT.BB)
elseif fimob== 12 then
mob = (FIZ_TXT.AU.." "..FIZ_TXT.SSP)
elseif fimob== 13 then
mob = (FIZ_TXT.AU.." "..FIZ_TXT.Wa)
elseif fimob == 14 then
mob = FIZ_TXT.VCm
elseif fimob == 15 then
mob = (FIZ_TXT.AN.." "..FIZ_TXT.BB)
elseif fimob== 16 then
mob = (FIZ_TXT.AN.." "..FIZ_TXT.SSP)
elseif fimob== 17 then
mob = (FIZ_TXT.AN.." "..FIZ_TXT.Wa)
else
--[[-- local mobName = GetmobNameByID(fimob);
mob = mobName --]]--
end
--- fpt f_ion FIZ_Printtest(fimob,mob,"mob 2")
if not mob then
mob = fimob
end
mark_mob = mob
end
function FIZ_Inititemname(fiitem,amt)
--- fpt f_iin FIZ_Printtest(fiitem,amt,"item 1")
if fiitem==1 then
item_name = FIZ_TXT.cdq
elseif fiitem==2 then
item_name = FIZ_TXT.fdq
elseif fiitem==3 then
item_name = FIZ_TXT.ndq
elseif fiitem == 4 then
item_name = FIZ_TXT.cbadge
elseif fiitem == 5 then
item_name = FIZ_TXT.deleted
else
item_name = GetItemInfo(fiitem)
end
mark_I={}
if not item_name then
item_name=fiitem
end
mark_I[item_name]=amt
--- fpt f_iin FIZ_Printtest(item_name,mark_I[item_name],"item 2")
end
local quest_names = setmetatable({}, {
__index = function(t, id_num)
GameTooltip:SetOwner(UIParent, ANCHOR_NONE)
GameTooltip:SetHyperlink(format("quest:%d", id_num))
local quest_name = GameTooltipTextLeft1:GetText()
GameTooltip:Hide()
if id_num == 1 then
quest_name = FIZ_TXT.cdq
elseif id_num == 2 then
quest_name = FIZ_TXT.coq
elseif id_num == 3 then
quest_name = FIZ_TXT.fdq
elseif id_num == 4 then
quest_name = FIZ_TXT.foq
elseif id_num == 5 then
quest_name = FIZ_TXT.ndq
elseif id_num == 6 then
quest_name = FIZ_TXT.deleted
elseif id_num == 7 then
quest_name = FIZ_TXT.Championing
elseif id_num == 8 then
quest_name = FIZ_TXT.bpqfg
elseif id_num== 99 then
quest_name = FIZ_TXT.tbd
else
if not quest_name then
return id_num
end
t[id_num] = quest_name
end
return quest_name
end
})
function FIZ_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 FIZ_InitFactor(FIZ_IsHuman,faction)
--- Thanks Gwalkmaur for the heads up
local factor=1.0
-- race check
if FIZ_IsHuman then factor = factor + 0.1 end
-- bonus repgain check
local numFactions = GetNumFactions();
local factionOffset=0;
local factionIndex;
local factor_h=0
--- FIZ_Printtest(numFactions,factionOffset,factionIndex)
--- f_if FIZ_Printtest(faction,name)
for i=1,numFactions do
local factionIndex = factionOffset + i;
if (factionIndex <= numFactions) then
local name, hasBonusRepGain;
local name, _, _, _, _, _, _, _, _, _, _, _, _, _, hasBonusRepGain, _ = GetFactionInfo(factionIndex);
if (faction==name) then
--- f_if FIZ_Printtest(faction,name,"test")
if (hasBonusRepGain) then
--- f_if FIZ_Printtest(faction,name,"Gain")
factor=factor+1
end
end
end
end
--- f_if FIZ_Printtest(faction,factor,"fact")
FIZ_factor = factor
end
function FIZ_InitFaction(guildName,faction)
if faction=="guildName" or faction==FIZ_GuildName then
--- f_ifa FIZ_Printtest(faction,guildName,"1")
FIZ_faction = faction
else
--- f_ifa FIZ_Printtest(faction,FIZ_faction,"2")
FIZ_faction = GetFactionInfoByID(faction)
end
end
function FIZ_InitFactionMap(locale, guildName)
FIZ_FactionMapping = {}
FIZ_InitEnFactions()
if (guildName) then
FIZ_AddMapping(guildName, guildName)
end
end