-
Notifications
You must be signed in to change notification settings - Fork 6
/
Tongues.lua
1844 lines (1597 loc) · 73.7 KB
/
Tongues.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
----------------------------------------------------------------------------------------------------------
Tongues.Version = GetAddOnMetadata("Tongues", "Version");
-- Note: This is completely inspired by the Lore 7.5.7 AddOn --
-- I decided to take a different approach, and as I got more into it I started having --
-- problems doing further modification (mostly with the XML,) it just seemed better to --
-- start over! --
----------------------------------------------------------------------------------------------------------
-- I prefer to use the table structure form for the functions so that we can instantiate the whole --
-- thing --
----------------------------------------------------------------------------------------------------------
TONGUES_MAX_MSG_LEN = 247;
local ldbt = LibStub:GetLibrary("LibDataBroker-1.1");
local BRAC = LibStub("LibBabble-Race-3.0"):GetLookupTable()
local BFAC = LibStub("LibBabble-Faction-3.0"):GetLookupTable()
local BCT = LibStub("LibBabble-CreatureType-3.0"):GetLookupTable()
local _,Tclass,_ = UnitClass("player")
local TONGUES_NONE = "<None>";
local VERSIONSUPPORTSFACTIONPICK = LE_EXPANSION_MISTS_OF_PANDARIA or 4;
local EDDM = LibStub("ElioteDropDownMenu-1.0")
local Tclasses = {}
FillLocalizedClassList(Tclasses, true)
local BlizzLangs = {"Darnassian", "Pandaren","Zandali","Thalassian","Goblin","Gnomish","Taurahe","Forsaken","Dwarvish","Draenei","Demonic", "Shalassian","Draconic"}
--===============================================MAIN===================================================--
---counte number of languages in tongues
function countLangauge()
local count = 0;
for k,v in pairs(Tongues.Settings.Character.Fluency) do
count = count+1;
end;
return count
end
--get languages currently spokein in UI
TonguesmageKnownLang = false;
function GetSpeaking()
local language = Tongues.Settings.Character.Language
local numLanguages = GetNumLanguages();
local i;
local langfound = false;
TonguesmageKnownLang = false;
for i = 1, numLanguages, 1 do
local getlanguage, getlanguageID = GetLanguageByIndex(i);
if (language == getlanguage) then
languageID = getlanguageID;
langfound = true;
TonguesmageKnownLang = true;
if Tongues.Settings.Character.ShapeshiftLanguage == true and GetShapeshiftForm(true) ~= 0 and Tclass == "DRUID" then
langfound = false
end
end
end
--print(GetLanguageByIndex(2))
local locRace, raceName = UnitRace("player")
if langfound == false then
local getlanguage2, getlanguageID2
getlanguage2, getlanguageID2 = GetLanguageByIndex(1)
if UnitClass("player") == "Mage" and IsSpellKnown(210086) then
for i = 1, numLanguages, 1 do
getlanguage2, getlanguageID2 = GetLanguageByIndex(i)
if ( getlanguage2 == "Orcish" or getlanguage2 == "Common" ) then
languageID = getlanguageID2
TonguesmageKnownLang = false;
end
end
elseif ( getlanguage2 == "Orcish" or getlanguage2 == "Common" ) then
languageID = getlanguageID2
else
getlanguage2, getlanguageID2 = GetLanguageByIndex(2)
languageID = getlanguageID2
--print(getlanguage2)
end
--print(getlanguage2)
end
return languageID,language
end
---tongues class setup
Tongues = Class:inherits(Tongues,{
Hooks = {
Send = SendChatMessage;
Receive = ChatFrame_MessageEventHandler;
--FCF = FCF_Tab_OnClick;
};
PreviousSentMsg = "";
Colors = {};
Settings = {
Character = { -- Player settings get applied only the the current player
Language = nil;
Fluency = {};
--LD = {};
Dialect = TONGUES_NONE;
Affect = TONGUES_NONE;
AffectFrequency = 100;
Filter = TONGUES_NONE;
Faction = "";
Race = "";
Class = "";
Debugging = false;
DialectDrift = false;
LanguageLearning = true;
ShapeshiftLanguage = true;
LoreCompatibility = true;
MMH=false;
Translations = {
Self = false;
Targetted = false;
Party = false;
Guild = false;
Officer = false;
Raid = false;
RaidAlert = false;
Battleground = false;
};
Translators = {};
Screen = {
Self = false;
Targetted = false;
Party = true;
Guild = true;
Officer = true;
Raid = true;
RaidAlert = true;
Battleground = true;
};
UI = {
MainMenu = {
point = "CENTER",
relativePoint = "CENTER",
xOfs = 0;
yOfs = 0;
};
MiniMenu = {
point = "CENTER",
relativePoint = "CENTER",
xOfs = 0;
yOfs = 0;
};
}
};
};
----------------------------------------------------------------------------------------
dialectcmd = function(msg)---dialect selection slash command
local param = {};
msg = string.gsub(msg,"([%a0-9]+)", function(a)
table.insert(param,#param + 1,a);
end);
if param ~= nil then
Tongues:SetDialect(param[1]);
else
Tongues:SetDialect(TONGUES_NONE);
end;
end;
Command = function(msg)--/tongues command function
local param = {};
msg = string.gsub(msg,"([%a0-9]+)", function(a)
table.insert(param,#param + 1,a);
end);
local i,k,v
if param ~= nil then
if param[1] ~= nil and string.lower(param[1]) == "help" then
for i=1,NUM_CHAT_WINDOWS do
_G["ChatFrame" .. i ]:AddMessage("Tongues Commands: " ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" <language>(just /tongues and language to speak a language)" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Shapeshift <true|false>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Cycle <cycle through languages" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Dialect <Chosen Dialect CASE SENSATIVE>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Affect <Chosen Effect(stutter,etc) CASE SENSATIVE, blank to remove><FREQUENCY(0-100)>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Remove <Language to remove CASE SENSATIVE>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Add <Language to add CASE SENSATIVE> <FLUANCY>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Roleplay <No option toggles the roleplay filter on and off>" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" List List all Lanugages" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Translate <Name> - Add or remove a translater(if they aren't on ther list it adds, if they are it removes)" ,1,1,0)
_G["ChatFrame" .. i ]:AddMessage(" Help - this message" ,1,1,0)
end;
elseif param[1] ~= nil and string.lower(param[1]) == "language" then
if param[2] ~= nil then
Tongues:SetLanguage(param[2]);
end;
elseif param[1] ~= nil and string.lower(param[1]) == "dialect" then
Tongues:SetDialect(param[2]);
elseif param[1] ~= nil and string.lower(param[1]) == "roleplay" then
if Tongues.Settings.Character.Filter == TONGUES_NONE then
Tongues.Settings.Character.Filter = "Roleplay";
else
Tongues.Settings.Character.Filter = TONGUES_NONE;
end;
elseif param[1] ~= nil and string.lower(param[1]) == "shapeshift" then
if Tongues.Settings.Character.ShapeshiftLanguage == true then
Tongues.Settings.Character.ShapeshiftLanguage = false;
else
Tongues.Settings.Character.ShapeshiftLanguage = true;
end
elseif param[1] ~= nil and string.lower(param[1]) == "reset" then
--Tongues.UI.MiniMenu:SetPoint("CENTER")
TonguesMiniMenu:ClearAllPoints()
TonguesMiniMenu:SetPoint("CENTER")
elseif param[1] ~= nil and string.lower(param[1]) == "opt" then
Tongues.UI.MainMenu.Frame:Show();
elseif param[1] ~= nil and string.lower(param[1]) == "cycle" then
--if countLangauge() ~= 1 then
Tongues:CycleLanguage();
--end
elseif param[1] ~= nil and string.lower(param[1]) == "affect" then
if param[2] ~= nil then
Tongues.Settings.Character.Affect = param[2];
else
Tongues.Settings.Character.Affect = TONGUES_NONE;
end;
elseif param[1] ~= nil and string.lower(param[1]) == "list" then
DEFAULT_CHAT_FRAME:AddMessage("Known Languages:");
for k,v in pairs(Tongues.Settings.Character.Fluency) do
DEFAULT_CHAT_FRAME:AddMessage(k .. " = " .. v .. "%")
end;
elseif param[1] ~= nil and string.lower(param[1]) == "remove" then
if param[2] ~= nil then
if param[3] ~= nil then
lang=param[2].." "..param[3]
Tongues.Settings.Character.Fluency[Tongues:GetRealLanguage(lang)] = nil;
else
Tongues.Settings.Character.Fluency[Tongues:GetRealLanguage(param[2])] = nil;
end
end
elseif param[1] ~= nil and string.lower(param[1]) == "add" then
if param[2] ~= nil then
if param[3] ~= nil then
lang=param[2]
Tongues.Settings.Character.Fluency[Tongues:GetRealLanguage(lang)] = param[3];
else
Tongues.Settings.Character.Fluency[Tongues:GetRealLanguage(param[2])] = param[3];
end
end
elseif param[1] ~= nil and string.lower(param[1]) == "translate" then
if param[2] ~= nil then
if Tongues:FindTranslator(param[2])==false then
Tongues:AddTranslator(param[2]);
DEFAULT_CHAT_FRAME:AddMessage("Added " .. param[2] .. " to the Translator list")
else
Tongues:RemoveTranslator(Tongues.UI.MainMenu.Translators.TranslatorEditbox.Frame:GetText());
DEFAULT_CHAT_FRAME:AddMessage("Removed " .. param[2] .. " from the Translator list")
end
end
elseif param[1] ~= nil then
Tongues:SetLanguage(param[1]);
end;
end;
end;
---------------------------------------------------------------------------------------
---===Helper====----
GetMountPetName = function()--get mount name or pet name/type
for i=1,GetNumCompanions("MOUNT") do
local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("MOUNT", i);
if issummoned then
return creatureName;
end
end
end;
-----=================================
Mountspeak = function(msg)--/ms mountspeak command
local mountname = Tongues:GetMountPetName();
local mountlanguage = nil;
local mountspeaktype = nil;
local mountType = nil;
for k,v in Tongues.PairsByKeys(Tongues.MountTable) do
----print(mountname)
if mountname == ("Dreadsteed") or mountname == "Felsteed"then
mountType = mountname;
elseif mountname == "Headless Horseman's Mount" then
mountType = "Dreadsteed";
elseif string.find(strlower(mountname),strlower(k)) then
----print("hit")
mountType = k;
end
end
if Tongues.MountTable[mountType] ~= nil then
local realLanguage = "";
if Tongues.Language[Tongues.MountTable[mountType]["Language"]] ~= nil then
if Tongues.Language[Tongues.MountTable[mountType]["Language"]]["alias"] ~= nil then
mountlanguage = Tongues.Language[Tongues.MountTable[mountType]["Language"]]["alias"];
else
mountlanguage = Tongues.MountTable[mountType]["Language"];
end;
mountspeaktype = Tongues.MountTable[mountType]["Speaktype"];
end;
if mountspeaktype ~= nil and mountlanguage ~= nil then
Tongues.PreviousMountSentMsg = msg
---- DO STUFF BEFORE LINKS (WHEN THEY ARE NOT LINKS)
if string.find(msg,"(.-)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)") ~= nil then
msg = string.gsub(msg,"(.-)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)",
function(a,link)
a = Tongues:TranslateWord(a,mountlanguage)
return a .. link
end
);
end;
---- DO THE LAST PART OF THE MESSAGE IF NOT A LINK
if string.find(msg,"(.*)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)(.-)$") ~= nil then
msg = string.gsub(msg,"(.*)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)(.-)$",
function(a,link,c)
c = Tongues:TranslateWord(c,mountlanguage)
return a .. link .. c
end
);
else
---- IF NO LINK THEN DO ANYWAY
msg = Tongues:TranslateWord(msg,mountlanguage)
end;
end;
Tongues.Hooks.Send( "'s mount " .. mountname .. " " .. mountspeaktype .. ", \"[".. mountlanguage .. "] " .. msg .. "\"", "EMOTE", nil, nil)
end;
end;
-------------------------------------------------------------
Petspeak = function(msg)--/ps or petspeak command
local petname = UnitName("pet") ;
local petlanguage = nil;
local petspeaktype = nil;
if Tongues.PetTable[UnitCreatureFamily("pet")] ~= nil then
local realLanguage = "";
if Tongues.Language[Tongues.PetTable[UnitCreatureFamily("pet")]["Language"]] ~= nil then
if Tongues.Language[Tongues.PetTable[UnitCreatureFamily("pet")]["Language"]]["alias"] ~= nil then
petlanguage = Tongues.Language[Tongues.PetTable[UnitCreatureFamily("pet")]["Language"]]["alias"];
else
petlanguage = Tongues.PetTable[UnitCreatureFamily("pet")]["Language"];
end;
petspeaktype = Tongues.PetTable[UnitCreatureFamily("pet")]["Speaktype"];
end;
if petspeaktype ~= nil and petlanguage ~= nil then
Tongues.PreviousPetSentMsg = msg
---- DO STUFF BEFORE LINKS (WHEN THEY ARE NOT LINKS)
if string.find(msg,"(.-)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)") ~= nil then
msg = string.gsub(msg,"(.-)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)",
function(a,link)
a = Tongues:TranslateWord(a,petlanguage)
return a .. link
end
);
end;
---- DO THE LAST PART OF THE MESSAGE IF NOT A LINK
if string.find(msg,"(.*)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)(.-)$") ~= nil then
msg = string.gsub(msg,"(.*)(|[cC][0-9a-fA-F]+|H[%a%A]-|h|r)(.-)$",
function(a,link,c)
c = Tongues:TranslateWord(c,petlanguage)
return a .. link .. c
end
);
else
---- IF NO LINK THEN DO ANYWAY
msg = Tongues:TranslateWord(msg,petlanguage)
end;
end;
Tongues.Hooks.Send( "'s pet " .. petname .. " " .. petspeaktype .. ", \"[".. petlanguage .. "] " .. msg .. "\"", "EMOTE", nil, nil)
end;
end;
---------------------------------------------------------------------------------------
OnLoad = function()
end;
---------------------------------------------------------------------------------------
OnEvent = function(self, event,...)--onevent functions and set up
self = Tongues;
if (event=="ADDON_LOADED") then
self.Settings.Character.Faction = UnitFactionGroup("player");
self.Settings.Character.Class = UnitClass("player");
self.Settings.Character.Race = UnitRace("player");
elseif (event=="VARIABLES_LOADED") then
---BETTER TO HEAL TOTALLY PROGRAMMATICALLY
local tempUI = self.Settings.Character.UI;
local tempTranslations = self.Settings.Character.Translations;
local tempLanguage = self.Settings.Character.Language;
local tempLanguageLearning = self.Settings.Character.LanguageLearning
local tempScreen = self.Settings.Character.Screen;
local tempFluency = self.Settings.Character.Fluency;
local tempAffectFrequency = self.Settings.Character.AffectFrequency;
local tempTranslators = self.Settings.Character.Translators;
self.Settings.Character = Tongues_Character
--- HEAL VARIABLES FROM OLD VERSIONS OR MALFORMED VARIABLES
if self.Settings.Character.UI == nil then
self.Settings.Character.UI = tempUI;
end;
if self.Settings.Character.Translations == nil then
self.Settings.Character.Translations = tempTranslations;
end;
if self.Settings.Character.Screen == nil then
self.Settings.Character.Screen = tempScreen;
end;
if self.Settings.Character.Fluency == nil then
self.Settings.Character.Fluency = tempFluency;
end;
if self.Settings.Character.AffectFrequency == nil then
self.Settings.Character.AffectFrequency = tempAffectFrequency;
end;
if self.Settings.Character.Translators == nil then
self.Settings.Character.Translators = tempTranslators;
end;
if self.Settings.Character.Language == nil or self.Language[self.Settings.Character.Language] == nil then
self.Settings.Character.Language = tempLanguage;
end;
if self.Settings.Character.LanguageLearning == nil then
self.Settings.Character.LanguageLearning = tempLanguageLearning;
end;
if self.Dialect[self.Settings.Character.Dialect] == nil then
self.Settings.Character.Dialect = TONGUES_NONE;
end;
if self.Affect[self.Settings.Character.Affect] == nil then
self.Settings.Character.Affect = TONGUES_NONE;
end;
if self.Filter[self.Settings.Character.Filter] == nil then
self.Settings.Character.Filter = TONGUES_NONE;
end;
if self.Settings.Character.Language == nil then
if UnitRace("player") == BRAC["Human"] or UnitRace("player") == BRAC["Kul Tiran"] then
self.Settings.Character.Language = T_Common--T_Common
elseif UnitRace("player") == BRAC["Orc"] or UnitRace("player") == BRAC["Mag'har Orc"] then
self.Settings.Character.Language = T_Orcish--T_Orcish
elseif (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == BRAC["Void Elf"]) then
self.Settings.Character.Language = T_Thalassian
elseif UnitRace("player") == BRAC["Night Elf"] then
self.Settings.Character.Language = T_Darnassian
elseif (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == BRAC["Lightforged Draenei"]) then
self.Settings.Character.Language = T_Draenei
elseif (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == BRAC["Highmountain Tauren"]) then
self.Settings.Character.Language = T_Taurahe
elseif (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == BRAC["Dark Iron Dwarf"]) then
self.Settings.Character.Language = T_Dwarvish
elseif UnitRace("player") == BRAC["Undead"] then
self.Settings.Character.Language = T_Forsaken
elseif (UnitRace("player") == BRAC["Gnome"] or UnitRace("player") == "Mechagnome") then
self.Settings.Character.Language = T_Gnomish
elseif UnitRace("player") == BRAC["Troll"] or UnitRace("player") == BRAC["Zandalari Troll"] then
self.Settings.Character.Language = "Zandali"
self.Settings.Character.Language = T_Troll
elseif UnitRace("player") == BRAC["Worgen"] then
self.Settings.Character.Language = "Gilnean-CodeSpeak"
self.Settings.Character.Fluency[BCT["Wolf"]] = Tongues_Character.Fluency[BCT["Wolf"]] or 100
elseif UnitRace("player") == BRAC["Goblin"] then
self.Settings.Character.Language = BRAC["Goblin"]
elseif UnitRace("player") == BRAC["Nightborne"] then
self.Settings.Character.Language = "Shalassian"
elseif UnitRace("player") == "Pandaren" then
self.Settings.Character.Language = "Pandaren"
elseif UnitRace("player") == "Vulpera" then
self.Settings.Character.Language = "Vulpera"
elseif UnitRace("player") == "Dracthyr" then
self.Settings.Character.Language = "Draconic"
end;
self.Settings.Character.Fluency[self.Settings.Character.Language] = Tongues_Character.Fluency[self.Settings.Character.Language] or 100
if UnitFactionGroup("player") == BFAC["Alliance"] then
--print("hit")
self.Settings.Character.Fluency[T_Common] = Tongues_Character.Fluency[T_Common] or 100
elseif UnitFactionGroup("player") == BFAC["Horde"] then
self.Settings.Character.Fluency[T_Orcish] = Tongues_Character.Fluency[T_Orcish] or 100
end;
if Tclass == "DRUID" then
self.Settings.Character.Fluency[BCT["Bear"]] = self.Settings.Character.Fluency[BCT["Bear"]] or 100;
self.Settings.Character.Fluency[BCT["Cat"]] = self.Settings.Character.Fluency[BCT["Cat"]] or 100;
if UnitRace("player")== BRAC["Troll"] then
self.Settings.Character.Fluency[BCT["Bat"]] = self.Settings.Character.Fluency[BCT["Bat"]] or 100;
elseif UnitRace("player") == "Zandalari Troll" then
self.Settings.Character.Fluency["Pterrordaxe"] = self.Settings.Character.Fluency["Pterrordaxe"] or 100;
self.Settings.Character.Fluency[BCT["Raptor"]] = self.Settings.Character.Fluency[BCT["Raptor"]] or 100;
else
self.Settings.Character.Fluency[T_Bird] = self.Settings.Character.Fluency[T_Bird] or 100;
end
self.Settings.Character.Fluency[T_Moonkin] = self.Settings.Character.Fluency[T_Moonkin] or 100;
self.Settings.Character.Fluency[T_Trentish] = self.Settings.Character.Fluency[T_Trentish] or 100;
self.Settings.Character.Fluency[T_Seal] = self.Settings.Character.Fluency[T_Seal] or 100;
self.Settings.Character.Fluency["Orca"] = self.Settings.Character.Fluency["Orca"] or 100;
self.Settings.Character.Fluency["Stag"] = self.Settings.Character.Fluency["Stag"] or 100;
elseif Tclass == "SHAMAN" then
--print("hit")
self.Settings.Character.Fluency[T_Wolf] = self.Settings.Character.Fluency[T_Wolf] or 100;
self.Settings.Character.Fluency[T_Kalimag] = self.Settings.Character.Fluency[T_Kalimag] or 100;
elseif Tclass == "WARLOCK" or Tclass == "DEMONHUNTER" then
self.Settings.Character.Fluency[T_Eredun] = self.Settings.Character.Fluency[T_Eredun] or 100;
self.Settings.Character.Fluency[T_Demonic] = self.Settings.Character.Fluency[T_Demonic] or 100;
end;
end;
--Lib_UIDropDownMenu_Initialize(Tongues.UI.MainMenu.Speak.LanguageDropDown.Frame, Tongues.UpdateLanguageDropDown);
self:SetLanguage(self.Settings.Character.Language);
-- Removing UIParent from settings
if self.Settings.Character.UI.MiniMenu.relativeTo then
self.Settings.Character.UI.MiniMenu.relativeTo = nil;
end
if self.Settings.Character.UI.MainMenu.relativeTo then
self.Settings.Character.UI.MainMenu.relativeTo = nil;
end
----------------------
self.Settings.Global = Tongues_Global;
self.UI:LoadDefaults();
elseif LE_EXPANSION_LEVEL_CURRENT >= VERSIONSUPPORTSFACTIONPICK and event == "NEUTRAL_FACTION_SELECT_RESULT" then
if UnitFactionGroup("player") == BFAC["Alliance"] then
--print("hit")
self.Settings.Character.Fluency[T_Common] = Tongues_Character.Fluency[T_Common] or 100
elseif UnitFactionGroup("player") == BFAC["Horde"] then
self.Settings.Character.Fluency[T_Orcish] = Tongues_Character.Fluency[T_Orcish] or 100
end;
elseif event == "UPDATE_CHAT_COLOR" then
local typec, red,green,blue = ...;
if (
typec == "SAY" or
typec == "WHISPER" or
typec == "YELL" or
typec == "PARTY" or
typec == "GUILD" or
typec == "OFFICER" or
typec == "RAID" or
typec == "RAID_WARNING" or
typec == "RAID_LEADER" or
typec == "PARTY_LEADER" or
typec == "BATTLEGROUND" or
typec == "BATTLEGROUND_LEADER" or
typec == "CHANNEL" or
typec == "INSTANCE_CHAT" or
typec == "INSTANCE_CHAT_LEADER"
) then
if typec == "SAY" then
local saycolor = ChatTypeInfo["SAY"];
Tongues.Colors[typec] = {saycolor.r, saycolor.g, saycolor.b}
else
Tongues.Colors[typec] = {red, green, blue}
end
end
end;
end;
---------------------------------------------------------------------------------------
Initialize = function(self)
---INITIALIZE SLASHCOMMANDS AND SAVED VARS
table.insert(self,self.UI);
SLASH_DIALECT1 = "/dialect";
SlashCmdList["DIALECT"] = self.dialectcmd;
SLASH_TONGUES1 = "/tongues";
SlashCmdList["TONGUES"] = self.Command;
SLASH_PETSPEAK1 = "/petspeak";
SlashCmdList["PETSPEAK"] = self.Petspeak;
SLASH_PS1 = "/ps";
SlashCmdList["PS"] = self.Petspeak;
SLASH_MOUNTSPEAK1 = "/mountspeak";
SlashCmdList["MOUNTSPEAK"] = self.Mountspeak;
SLASH_MS1 = "/ms";
SlashCmdList["MS"] = self.Mountspeak;
Tongues_Global = self.Settings.Global;
Tongues_Character = self.Settings.Character;
self.Filter = merge({
self.Filter,
self.Custom.Filter
});
self.Dialect = merge({
self.Dialect,
self.Custom.Dialect
});
self.Language = merge({
self.Language,
self.Custom.Language
});
self.Affect = merge({
self.Affect,
self.Custom.Affect
});
self.Frame = CreateFrame("Frame",nil,UIParent);
self.Frame:RegisterEvent("ADDON_LOADED");
if LE_EXPANSION_LEVEL_CURRENT >= VERSIONSUPPORTSFACTIONPICK then
self.Frame:RegisterEvent("NEUTRAL_FACTION_SELECT_RESULT")
end
self.Frame:RegisterEvent("VARIABLES_LOADED");
self.Frame:RegisterEvent("CHAT_MSG_ADDON");
self.Frame:RegisterEvent("UPDATE_CHAT_COLOR");
self.Frame:SetScript("OnEvent", Tongues.OnEvent);
TTimerFrame = CreateFrame("frame")
TTimerFrame:SetScript("OnUpdate", Tongues.Timer)
TTimerFrame:Hide()
self.UI:Configure()
local diactxt = false;
--============================LIBDATA BROKER SETUP==============================================================
---LDB Setup Merg to tongues 2
Tongues.LDBT={};
Tongues.LDBT.OnClick = function(self)
--print(self.value)
if diactxt == false then
Tongues:SetLanguage(self.value);
else
--Tongues.Settings.Character.Dialect = self.value;
--Lib_UIDropDownMenu_SetSelectedValue(Tongues.UI.MainMenu.Speak.DialectDropDown.Frame, self.value)
Tongues:SetDialect(self.value);
end
end
tBroker = ldbt:NewDataObject("TonguesBroker", {
type ="data source",
icon = "Interface\\Icons\\Spell_Shadow_SoulLeech",
text = "Tongues",
value = Tongues_Character.Language,
label = "Tongues",
OnClick = function(clickedframe, button)
if button == "RightButton" then
Tongues.UI.MainMenu.Frame:Show();
else
if IsAltKeyDown() then
--Tongues.MenuClass:new();
diactxt = false;
Tongues:UpdateLanguageContext();
Tongues.MenuClass:Show();
elseif IsShiftKeyDown() then
diactxt = true;
Tongues:UpdateDialectContext();
Tongues.MenuClass:Show();
else
--if countLangauge() ~= 1 then
Tongues:CycleLanguage();
--end
end
end
end,
}
)
end;
---=====================================================================LDB Setup END
--==========================================================================================================
HandleSend = function(self, msg, chatType, langID, language, channel)--HANDLE TEXT SENDING
--- NEVER PARSE CHANNEL AFK DND etc,
if (chatType=="CHANNEL" or chatType=="AFK" or chatType=="DND" or chatType=="INSTANCE_CHAT_LEADER" or chatType == "RAID_LEADER") then
self.Hooks.Send( msg, chatType, langID, channel );
return
end
local languagename = "";
local translatelanguage = "";
local starform = self:hasStarForm()
--- GET THE RIGHT LANGUAGE AND TAG
if starform ~= true and self.Settings.Character.ShapeshiftLanguage == true and GetShapeshiftForm(true) ~= 0 and Tclass == "DRUID" then
languagename = "[" .. self:ReturnForm() .."] ";
translatelanguage = self:ReturnForm()
elseif UnitFactionGroup("player") == BFAC["Alliance"] and self.Settings.Character.Language == T_Common then
elseif UnitFactionGroup("player") == BFAC["Horde"] and self.Settings.Character.Language == T_Orcish then
elseif self.Settings.Character.Language == self:ReturnSpecialLanguage() then
language = self.Settings.Character.Language;
translatelanguage = language;
else
languagename = "[" .. self.Settings.Character.Language .."] ";
translatelanguage = self.Settings.Character.Language
end;
-----PROCESS EMOTES
if (chatType=="EMOTE") or (chatType=="emote") then
self.Hooks.Send( msg,chatType, langID, channel);
else
--- APPLY BASIC ROLEPLAYING FULL SENTANCE FILTERS (SHOULDNT EFFECT LINKS)
---I don't like how i am doing this check but i am doing it...
if (self.Settings.Character.Screen.Guild == true and (chatType == "GUILD" or chatType=="guild")) then
--nothing
v = self:ParseLink(msg, language);
elseif (self.Settings.Character.Screen.Raid == true and (chatType == "RAID" or chatType == "raid")) then
v = self:ParseLink(msg, language);
elseif (self.Settings.Character.Screen.RaidAlert == true and (chatType == "RAID_WARNING" or chatType == "raid_warning")) then
v = self:ParseLink(msg, language);
elseif (self.Settings.Character.Screen.Party == true and (chatType == "PARTY" or chatType == "Party" or chatType == "PARTY_LEADER" or chatType == "party_leader")) then
v = self:ParseLink(msg, language);
elseif (self.Settings.Character.Screen.Officer == true and (chatType == "OFFICER" or chatType == "OFFICER")) then
v = self:ParseLink(msg, language);
else
msg = self:Substitute(msg, self.Filter[self.Settings.Character.Filter]["filters"]);
msg = self:ApplyEffect(msg, self.Filter[self.Settings.Character.Filter]["affects"]);
-- PROCESSES PARTS OF MESSAGE THAT ARE NOT LINKS
v = self:ParseLink(msg, language);
end;
end;
self.PreviousSentMsg = self:ApplySpeech(msg, false);
--- Lots of settings have to be handled here
-----TRANSLATIONS to SELF
if (self.Settings.Character.Translations.Self == true and chatType~="WHISPER" and chattype~="whisper" and chatType~="CHANNEL" and chatType~="channel") then
if self.Settings.Character.Translations.Self == false then
self.Hooks.Send(msg , chatType, langID, channel);
SELECTED_CHAT_FRAME:AddMessage("(" .. UnitName("player") .. ": " ..msg .. ")",1,1,0);
else
SELECTED_CHAT_FRAME:AddMessage("(" .. UnitName("player") .. ": " ..msg .. ")",1,1,0);
end
end
-----PROCESS for SAY or YELL
if (chatType == "SAY" or chatType == "say" or chatType == "YELL" or chatType=="yell") then
---taken from http://www.wowinterface.com/forums/showthread.php?p=234858#post234858
if (UnitClass("player") == "Mage" and IsSpellKnown(210086)) and TonguesmageKnownLang == true then
self.Hooks.Send(msg , chatType, langID, channel);
elseif Tclass == "DEMONHUNTER" and TonguesmageKnownLang == true then
self.Hooks.Send(msg , chatType, langID, channel);
else
self.Hooks.Send( languagename .. v , chatType, langID, channel);
end
end;
----TRANSLATE TO TARGETTED
if (self.Settings.Character.Translations.Targetted == true) and (UnitIsPlayer("target") ~= nil) and (chatType == "SAY" or chatType=="say" or chatType == "YELL" or chatType=="yell") and UnitFactionGroup("target") == UnitFactionGroup("player") and languagename ~= "" then
self.Hooks.Send("[Translation - " .. translatelanguage .. "] " .. self:ApplySpeech(msg, false), "WHISPER", nil, UnitName("target"));
end
----TRANSLATE TO TRANSLATORS IF THEY ARE VISIBLE
for kname,vname in pairs(self.Settings.Character.Translators) do
local id,langNam = GetSpeaking()
if (chatType== "WHISPER" or chatType== "whisper" or chatType== "EMOTE" or chatType== "emote") or (langNam == "Common" or langNam == "Orcish")then
else
--print(chatType)
self.Hooks.Send("[Translation - " .. translatelanguage .. "] " .. self:ApplySpeech(msg, false), "WHISPER", nil, vname);
end
end;
-----DONT DO TRANSLATION IF WHISPER IS SENT
if (chatType=="WHISPER" or chatType=="whisper") then
self.Hooks.Send(msg , chatType, langID, channel);
else
-----TRANSLATIONS and PROCESS for PARTY
if (self.Settings.Character.Screen.Party == true and (chatType == "PARTY" or chatType == "party" or chatType == "PARTY_LEADER")) then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg , chatType, language, channel);
elseif (self.Settings.Character.Translations.Party == true and (chatType == "PARTY" or chatType == "party"or chatType == "PARTY_LEADER" )) then
self.Hooks.Send(self:ApplySpeech(msg, false), "PARTY", nil, channel);
elseif (self.Settings.Character.Translations.Party == true and (chatType ~= "PARTY" and chatType ~= "party" or chatType ~= "PARTY_LEADER") and GetNumSubgroupMembers() ~= 0) then
self.Hooks.Send(self:ApplySpeech(msg, false), "PARTY", nil, channel);
elseif (self.Settings.Character.Translations.Party == false and (chatType == "PARTY" or chatType == "party"or chatType == "PARTY_LEADER" )) then
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
-----TRANSLATIONS and PROCESS for GUILD
if (self.Settings.Character.Screen.Guild == true and (chatType == "GUILD" or chatType=="guild")) then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg , "GUILD", language, channel);
elseif (self.Settings.Character.Translations.Guild == true and (chatType == "GUILD" or chatType=="guild")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "GUILD", nil, channel);
elseif (self.Settings.Character.Translations.Guild == true and (chatType ~= "GUILD" and chatType~="guild") and IsInGuild()) then
self.Hooks.Send(self:ApplySpeech(msg, false), "GUILD", nil, channel);
elseif (self.Settings.Character.Translations.Guild == false and (chatType == "GUILD" or chatType=="guild")) then
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
-----TRANSLATIONS and PROCESS for OFFICER
if (self.Settings.Character.Screen.Officer == true and chatType == "OFFICER") then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg , "OFFICER", language, channel);
elseif (self.Settings.Character.Translations.Officer == true and (chatType == "OFFICER" or chatType == "officer")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "OFFICER", nil, channel);
elseif (self.Settings.Character.Translations.Officer == true and (chatType ~= "OFFICER" and chatType ~= "officer") and IsInGuild()) then
self.Hooks.Send(self:ApplySpeech(msg, false), "OFFICER", nil, channel);
elseif (self.Settings.Character.Translations.Officer == false and (chatType == "OFFICER" or chatType == "officer")) then
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
-----TRANSLATIONS and PROCESS for RAID
if (self.Settings.Character.Screen.Raid == true and (chatType == "RAID" or chatType == "raid")) then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg ,"RAID", language, channel);
elseif (self.Settings.Character.Translations.Raid == true and (chatType == "RAID" or chatType == "raid")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "RAID", nil, channel);
elseif (self.Settings.Character.Translations.Raid == true and (chatType ~= "RAID" and chatType ~= "raid") and UnitInRaid("player")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "RAID", nil, channel);
elseif (self.Settings.Character.Translations.Raid == false and (chatType == "RAID" or chatType == "raid")) then
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
-----TRANSLATIONS and PROCESS for RAIDALERT
if (self.Settings.Character.Screen.RaidAlert == true and (chatType == "RAID_WARNING" or chatType == "raid_warning")) then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg ,"RAID_WARNING", language, channel);
elseif (self.Settings.Character.Translations.RaidAlert == true and (chatType == "RAID_WARNING" or chatType == "raid_warning")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "RAID_WARNING", nil, channel);
elseif (self.Settings.Character.Translations.RaidAlert == true and (chatType ~= "RAID_WARNING" and chatType ~= "raid_warning") and UnitInRaid("player")) then
self.Hooks.Send(self:ApplySpeech(msg, false), "RAID_WARNING", nil, channel);
elseif (self.Settings.Character.Translations.RaidAlert == false and (chatType == "RAID_WARNING" or chatType == "raid_warning")) then
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
-----TRANSLATIONS and PROCESS for BATTLEGROUND
if(self.Settings.Character.Screen.Battleground == true and (chatType == "INSTANCE_CHAT" or chatType == "instance_chat")) then
if UnitRace("player") == BRAC["Human"] and self.Settings.Character.Language == T_Common
or UnitRace("player") == BRAC["Orc"] and self.Settings.Character.Language == T_Orcish
or (UnitRace("player") == BRAC["Blood Elf"] or UnitRace("player") == "Void Elf") and self.Settings.Character.Language == T_Thalassian
or UnitRace("player") == BRAC["Night Elf"] and self.Settings.Character.Language == T_Darnassian
or (UnitRace("player") == BRAC["Draenei"] or UnitRace("player") == "Lightforged Draenei") and self.Settings.Character.Language == T_Draenei
or (UnitRace("player") == BRAC["Tauren"] or UnitRace("player") == "High Mountain Tauren")and self.Settings.Character.Language == T_Taurahe
or (UnitRace("player") == BRAC["Dwarf"] or UnitRace("player") == "Dark Iron Dwarf") and self.Settings.Character.Language == T_Dwarvish
or UnitRace("player") == BRAC["Undead"] and self.Settings.Character.Language == T_Forsaken
or UnitRace("player") == BRAC["Gnome"] and self.Settings.Character.Language == T_Gnomish
or UnitRace("player") == BRAC["Troll"] and self.Settings.Character.Language == T_Troll
or UnitRace("player") == BRAC["Worgen"] and self.Settings.Character.Language == "Gilnean-CodeSpeak"
or UnitRace("player") == BRAC["Goblin"] and self.Settings.Character.Language == BRAC["Goblin"]
or UnitRace("player") == "Nightborne" and self.Settings.Character.Language == "Shalassian"
or UnitRace("player") == "Pandaren" and self.Settings.Character.Language == "Pandaren" then
language = nil
end;
self.Hooks.Send(msg , "INSTANCE_CHAT", language, channel);
elseif (self.Settings.Character.Translations.Battleground == true and (chatType == "INSTANCE_CHAT" or chatType == "instance_chat" )) then
self.Hooks.Send(self:ApplySpeech(msg, false), "INSTANCE_CHAT", nil, channel);
elseif (self.Settings.Character.Translations.Battleground == true and (chatType ~= "INSTANCE_CHAT" and chatType ~= "instance_chat" )) then
self.Hooks.Send(self:ApplySpeech(msg, false), "INSTANCE_CHAT", nil, channel);
elseif (self.Settings.Character.Translations.Battleground == false and (chatType == "INSTANCE_CHAT" or chatType == "instance_chat")) then--chatType == "INSTANCE_CHAT_LEADER")
self.Hooks.Send(languagename .. v , chatType, langID, channel);
end
end;
end;
---------------------------------------------------------------------------------------
--local cID = nil;
HandleReceive = function(self,CHAT_FRAME,event, ...)--HANDLE RECIVING OF TEXT
local message, snder, lang, channelString, target, flags, unknown, channelNumber, channelName, unknown, counter = ...;
--CHAT_FRAME = CHAT_FRAME;
--FOR NOW DOING DIRECT REQUESTS FROM THE USER WHO SENDS THE 'LANGUAGE' --
local TP = "<Tongues>"
local TPLen = string.len(TP)
dontprint = 1;
local cID = CHAT_FRAME:GetID()
----print(cID:GetID())
local cIDN = _G["ChatFrame"..cID];--CHAT_FRAME:GetID();
if (event=="CHAT_MSG_SAY") or
(event=="CHAT_MSG_YELL") or
(event=="CHAT_MSG_GUILD") or
(event=="CHAT_MSG_PARTY") or
(event=="CHAT_MSG_PARTY_LEADER") or
(event=="CHAT_MSG_RAID") or
(event=="CHAT_MSG_RAID_WARNING")or
(event=="CHAT_MSG_OFFICER") or
(event=="CHAT_MSG_BATTLEGROUND") or
(event == "CHAT_MSG_INSTANCE_CHAT_LEADER") or
(event == "CHAT_MSG_INSTANCE_CHAT") then
--CODE TO EXTRACT LANGUAGE TAG IF ONE EXISTS
local languagetag = ""
if string.match(message, "%[([%a%s'%-]+)%][%a%A]+") then
languagetag = string.gsub(message, "%[([%a%s'%-]+)%]([%a%A]+)", "%1")
message = string.gsub(message, "%[([%a%s'%-]+)%]([%a%A]+)", "%2")
languagetag = "[" .. languagetag .. "] "
end
---------------------------------------------
message = self:Substitute(message, self.Filter[self.Settings.Character.Filter]["filters"]);
message = self:ApplyEffect(message, self.Filter[self.Settings.Character.Filter]["affects"]);
--CODE TO READ LANGUAGE TAG IF ONE EXISTS
if (languagetag) then
message = languagetag .. message
end