-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAFKS.lua
1497 lines (1308 loc) · 48.7 KB
/
AFKS.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
----------------------------------------------
-- The codes are based on ElvUI --
----------------------------------------------
local AFKS = CreateFrame("Frame")
local wowVersion
local UIscale = 1
local panelheight = GetScreenHeight() * 0.1
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then
wowVersion = "classic"
elseif WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC then
wowVersion = "wrath" -- CN only
elseif WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC then
wowVersion = "cata"
elseif WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
wowVersion = "retail"
end
local eastasian = false
if GetLocale() == "koKR" or GetLocale() == "zhCN" or GetLocale() == "zhTW" then
eastasian = true
end
--Cache global variables
--Lua functions
local _G = _G
local floor = math.floor
local type, select = type, select
local tonumber, tostring = tonumber, tostring
local pairs = pairs
local GetTime = GetTime
--WoW API / Variables
local CreateFrame = CreateFrame
local GetBattlefieldStatus = GetBattlefieldStatus
local GetGuildInfo = GetGuildInfo
local GetZonePVPInfo = _G.C_PvP.GetZonePVPInfo
local InCombatLockdown = InCombatLockdown
local IsInGuild = IsInGuild
local UnitFactionGroup = UnitFactionGroup
local UnitIsPVP = UnitIsPVP
local UnitIsAFK = UnitIsAFK
local UnitIsDeadOrGhost = UnitIsDeadOrGhost
local UnitInParty = UnitInParty
local UnitInRaid = UnitInRaid
local UnitOnTaxi = UnitOnTaxi
local WantsAlteredForm = _G.C_UnitAuras.WantsAlteredForm
local GetShapeshiftFormID = GetShapeshiftFormID
local GetExpansionDisplayInfo = GetExpansionDisplayInfo
local GetClientDisplayExpansionLevel = GetClientDisplayExpansionLevel
local MoveViewLeftStart = MoveViewLeftStart
local MoveViewLeftStop = MoveViewLeftStop
local NewTicker, NewTimer, TimerAfter = _G.C_Timer.NewTicker, _G.C_Timer.NewTimer, _G.C_Timer.After
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
--Retail only API
local GetAtlasInfo
local GetSpecializationInfo
local GetSpecialization
local PetBattles_IsInBattle
local IsRecipeRepeating
local GetStreamInfo
local GetClubInfo
local GetGlidingInfo
--Retail and Cata API
local GetNumDayEvents
local GetDayEvent
--Cata and Wrath API
local GetNumTalentTabs
local GetTalentTabInfo
--Classic only API
local CastingInfo
local GetCurrentGameModeRecordID
local GetGameModeDisplayInfo
if wowVersion == "retail" or wowVersion == "cata" then
GetNumDayEvents = _G.C_Calendar.GetNumDayEvents
GetDayEvent = _G.C_Calendar.GetDayEvent
end
if wowVersion == "cata" then
GetNumTalentTabs = _G.GetNumTalentTabs
GetTalentTabInfo = _G.GetTalentTabInfo
end
if wowVersion == "retail" then
GetAtlasInfo = _G.C_Texture.GetAtlasInfo
GetSpecializationInfo = _G.GetSpecializationInfo
GetSpecialization = _G.GetSpecialization
IsRecipeRepeating = _G.C_TradeSkillUI.IsRecipeRepeating
PetBattles_IsInBattle = _G.C_PetBattles.IsInBattle
GetStreamInfo = _G.C_Club.GetStreamInfo
GetClubInfo = _G.C_Club.GetClubInfo
GetGlidingInfo = _G.C_PlayerInfo.GetGlidingInfo
else
CastingInfo = _G.CastingInfo
GetCurrentGameModeRecordID = _G.C_GameModeManager.GetCurrentGameModeRecordID
GetGameModeDisplayInfo = _G.C_GameModeManager.GetGameModeDisplayInfo
end
--WoW Functions / Frames
--[[
local ChatHistory_GetAccessID = _G.ChatHistory_GetAccessID
local Chat_GetChatCategory = _G.Chat_GetChatCategory
local ChatFrame_GetMobileEmbeddedTexture = _G.ChatFrame_GetMobileEmbeddedTexture
local PVEFrame_ToggleFrame = PVEFrame_ToggleFrame
]]
local UIParent = _G.UIParent
local ignoreKeys = {
LALT = true,
LSHIFT = true,
RSHIFT = true,
}
local printKeys = {
PRINTSCREEN = true,
}
if IsMacClient() then
printKeys[_G.KEY_PRINTSCREEN_MAC] = true
end
local isCamp = false
SLASH_AFKSCampToggle1 = "/AFKCAMP"
function SlashCmdList.AFKSCampToggle()
if isCamp then
isCamp = false
print(AFKS_CAMPOFF)
else
isCamp = true
print(AFKS_CAMPON)
end
end
local public_channels = {
["retail"] = {26, 42},
["cata"] = {23, 25, 26},
["classic"] = {23, 24, 25},
}
local default_options = {
enabled = true,
hidechat = false,
group = false,
}
function AFKS:OnEvent(event, ...)
if event == "VARIABLES_LOADED" then
AFKS_DB = AFKS_DB or CopyTable(default_options)
self.options = AFKS_DB
self:Toggle()
self:RenderOptions()
if wowVersion == "classic" and C_GameRules.IsHardcoreActive() then
self.isHardcore = true
end
end
if event == "PLAYER_REGEN_DISABLED" or event == "LFG_PROPOSAL_SHOW" or event == "UPDATE_BATTLEFIELD_STATUS" or event == "PARTY_INVITE_REQUEST" then
if event == "UPDATE_BATTLEFIELD_STATUS" then
local status = GetBattlefieldStatus(...)
if status == "confirm" then
self:SetAFK(false)
end
else
self:SetAFK(false)
end
if event == "PLAYER_REGEN_DISABLED" then
self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEvent")
if self.isAFK then
self.isInterrupted = true
end
end
return
end
if event == "PLAY_MOVIE" then
self.isCinematic = true
end
if event == "TALKINGHEAD_REQUESTED" and self.isAFK then
self:SetAFK(false)
end
if event == "PLAYER_REGEN_ENABLED" then
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
if self.isInterrupted then
TimerAfter(0.5, function() self:SetAFK(false) end)
self.isInterrupted = false
end
end
if event == "PLAYER_CONTROL_GAINED" and UnitOnTaxi("player") and UnitIsPVP("player") then
self:SetAFK(false)
end
if not self.options.enabled then
return
end
if self.isCinematic then
if MovieFrame:IsShown() then
return
else
if not UnitIsAFK("player") then
self.isCinematic = false
end
end
end
if self.isHardcore then
return
end
--[[
if UnitInParty("player") or UnitInRaid("player") or (wowVersion == "retail" and PetBattles_IsInBattle()) then
return
end
]]
if not self.options.group and (IsInGroup() or (wowVersion == "retail" and PetBattles_IsInBattle())) then
return
end
if wowVersion == "retail" and GetGlidingInfo() then
return
end
if UnitIsPVP("player") and (GetZonePVPInfo() == "combat" or GetZonePVPInfo() == "contested" or GetZonePVPInfo() == "hostile") then
return
end
if UnitIsDeadOrGhost("player") or InCombatLockdown() then
return
end
if wowVersion == "retail" then
if IsRecipeRepeating() then
--Don't activate afk if player is crafting stuff, check back in 30 seconds
TimerAfter(30, function() self:OnEvent() end)
return
elseif ( ProfessionsFrame and ProfessionsFrame:IsShown() ) or ( ProfessionsCustomerOrdersFrame and ProfessionsCustomerOrdersFrame:IsShown() ) then
return
end
else
if CastingInfo() then
--Don't activate afk if player is crafting stuff, check back in 30 seconds
TimerAfter(30, function() self:OnEvent() end)
return
end
end
if UnitIsAFK("player") and not self.isAFK then
if wowVersion == "retail" and PVEFrame and PVEFrame:IsShown() or isCamp then return end
self:SetAFK(true)
elseif not UnitIsAFK("player") then
self:SetAFK(false)
end
end
function AFKS:Toggle()
if(self.options.enabled) then
self:RegisterEvent("PLAYER_FLAGS_CHANGED", "OnEvent")
self:RegisterEvent("PLAYER_REGEN_DISABLED", "OnEvent")
self:RegisterEvent("PLAYER_CONTROL_GAINED", "OnEvent")
self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS", "OnEvent")
self:RegisterEvent("PLAY_MOVIE", "OnEvent")
if wowVersion == "retail" then
self:RegisterEvent("LFG_PROPOSAL_SHOW", "OnEvent")
self:RegisterEvent("PARTY_INVITE_REQUEST", "OnEvent")
self:RegisterEvent("TALKINGHEAD_REQUESTED", "OnEvent")
end
SetCVar("autoClearAFK", "1")
else
self:UnregisterEvent("PLAYER_FLAGS_CHANGED")
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
self:UnregisterEvent("PLAYER_CONTROL_GAINED")
self:UnregisterEvent("UPDATE_BATTLEFIELD_STATUS")
self:UnregisterEvent("PLAY_MOVIE")
if wowVersion == "retail" then
self:UnregisterEvent("LFG_PROPOSAL_SHOW")
self:UnregisterEvent("PARTY_INVITE_REQUEST")
self:UnregisterEvent("TALKINGHEAD_REQUESTED")
end
end
end
local function OnKeyDown(self, key)
if(ignoreKeys[key]) then return end
if printKeys[key] then
Screenshot()
else
if InCombatLockdown() then return end
AFKS:SetAFK(false)
TimerAfter(60, function() AFKS:OnEvent() end)
end
end
local function Chat_MouseDown(self, button)
if button == "RightButton" then
AFKS.AFKMode.chatminbar.minimized = true
AFKS.AFKMode.chatminbar.unreadwhisper = 0
AFKS.AFKMode.chatminbar.unreadbnet = 0
AFKS.AFKMode.chatminbar.unreadchannel = 0
AFKS.AFKMode.chatminbar.unreadguild = 0
local text = format(AFKS_CHATBAR_TEXT, AFKS.AFKMode.chatminbar.unreadwhisper, AFKS.AFKMode.chatminbar.unreadbnet, AFKS.AFKMode.chatminbar.unreadchannel)
if IsInGuild() then
text = text.." "..format(AFKS_CHATBAR_GUILD, AFKS.AFKMode.chatminbar.unreadguild)
end
AFKS.AFKMode.chatminbar.title:SetText(text)
AFKS.AFKMode.chatminbar.title:Show()
AFKS.AFKMode.chatminbar:SetBackdropColor(.2, .2, .2, .8)
self:Hide()
elseif button == "LeftButton" and IsShiftKeyDown() then
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", AFKSFrame, "BOTTOMLEFT", 4, 120)
end
end
local function Chat_OnMouseWheel(self, delta)
if delta == 1 then
if IsShiftKeyDown() then
self:ScrollToTop()
else
self:ScrollUp()
end
elseif delta == -1 then
if IsShiftKeyDown() then
self:ScrollToBottom()
else
self:ScrollDown()
end
end
end
local function ChatMinBar_MouseDown(self, button)
if button == "LeftButton" or button == "RightButton" then
AFKS.AFKMode.chatminbar.minimized = false
AFKS.AFKMode.chatminbar.title:Hide()
AFKS.AFKMode.chatminbar:SetBackdropColor(.2, .2, .2, 0)
AFKS.AFKMode.chat:Show()
end
end
local function TruncateToMaxLength(text, maxLength)
local length = strlenutf8(text)
if ( length > maxLength ) then
return text:sub(1, maxLength - 2).."..."
end
return text
end
local function GetCommunityName(clubId, streamId)
local communityName = ""
local streamInfo = GetStreamInfo(clubId, streamId)
if streamInfo and streamInfo.streamType == 0 then
local clubInfo = GetClubInfo(clubId)
communityName = clubInfo and TruncateToMaxLength(clubInfo.shortName or clubInfo.name, 12) or ""
end
return communityName
end
--[[
local function GetBNFriendColor(name, id, useBTag)
local _, _, battleTag, _, _, bnetIDGameAccount = BNGetFriendInfoByID(id)
local TAG = useBTag and battleTag and strmatch(battleTag,"([^#]+)")
local Class
if not bnetIDGameAccount then --dont know how this is possible
local firstToonClass = getFirstToonClassColor(id)
if firstToonClass then
Class = firstToonClass
else
return TAG or name
end
end
if not Class then
_, _, _, _, _, _, _, Class = BNGetGameAccountInfo(bnetIDGameAccount)
end
if Class and Class ~= "" then --other non-english locales require this
for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if Class == v then Class = k;break end end
for k,v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if Class == v then Class = k;break end end
end
local CLASS = Class and Class ~= "" and gsub(strupper(Class),"%s","")
local COLOR = CLASS and classcolors[CLASS]
return (COLOR and format("|c%s%s|r", COLOR.colorStr, TAG or name)) or TAG or name
end
]]
local function Chat_OnEvent(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14)
local coloredName = GetColoredName(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
local type = strsub(event, 10)
local info = _G.ChatTypeInfo[type]
--[[
if(event == "CHAT_MSG_BN_WHISPER") then
coloredName = GetBNFriendColor(arg2, arg13)
end
]]
arg1 = RemoveExtraSpaces(arg1)
local chatGroup = _G.Chat_GetChatCategory(type)
local chatTarget, body
if ( chatGroup == "BN_CONVERSATION" ) then
chatTarget = tostring(arg8)
elseif ( chatGroup == "WHISPER" or chatGroup == "BN_WHISPER" ) then
if(not(strsub(arg2, 1, 2) == "|K")) then
chatTarget = arg2:upper()
else
chatTarget = arg2
end
end
local playerLink
local texture = ""
if type == "BN_WHISPER" then
local accountInfo = _G.C_BattleNet.GetAccountInfoByID(arg13)
if accountInfo and accountInfo.gameAccountInfo.clientProgram ~= "" then
texture = BNet_GetClientEmbeddedAtlas(accountInfo.gameAccountInfo.clientProgram, 14, 14)
end
playerLink = texture.."|HBNplayer:"..arg2..":"..arg13..":"..arg11..":"..chatGroup..(chatTarget and ":"..chatTarget or "").."|h"
if AFKS.AFKMode.chatminbar.minimized then
AFKS.AFKMode.chatminbar.unreadbnet = AFKS.AFKMode.chatminbar.unreadbnet + 1
--print("bnet:"..AFKS.AFKMode.chatminbar.unreadbnet)
end
else
playerLink = "|Hplayer:"..arg2..":"..arg11..":"..chatGroup..(chatTarget and ":"..chatTarget or "").."|h"
end
local message = arg1
if ( arg14 ) then --isMobile
message = _G.ChatFrame_GetMobileEmbeddedTexture(info.r, info.g, info.b)..message
end
--Escape any % characters, as it may otherwise cause an "invalid option in format" error in the next step
message = gsub(message, "%%", "%%%%")
local success
success, body = pcall(format, _G["CHAT_"..type.."_GET"]..message, playerLink.."["..coloredName.."]".."|h")
if not success then
print("Error:", type, message, _G["CHAT_"..type.."_GET"])
end
if type == "COMMUNITIES_CHANNEL" then
local prefix, channelCode = arg4:match("(%d+. )(.*)")
local clubId, streamId = channelCode:match("(%d+)%:(%d+)")
clubId = tonumber(clubId)
streamId = tonumber(streamId)
type = _G.Chat_GetCommunitiesChannel(clubId, streamId)
info = _G.ChatTypeInfo[type]
body = "[" .. prefix .. GetCommunityName(clubId, streamId) .. "] " .. body
if AFKS.AFKMode.chatminbar.minimized then
AFKS.AFKMode.chatminbar.unreadchannel = AFKS.AFKMode.chatminbar.unreadchannel + 1
end
elseif type == "CHANNEL" then
if arg7 == 1 or arg7 == 2 or arg7 == 22 then
return
end
for k, v in pairs(public_channels[wowVersion]) do
if arg7 == v then
return
end
end
info = _G.ChatTypeInfo[type..arg8]
body = "[" .. arg4 .. "]" .. body
if AFKS.AFKMode.chatminbar.minimized then
AFKS.AFKMode.chatminbar.unreadchannel = AFKS.AFKMode.chatminbar.unreadchannel + 1
end
end
local accessID = _G.ChatHistory_GetAccessID(chatGroup, chatTarget)
local typeID = _G.ChatHistory_GetAccessID(type, chatTarget, arg12 == "" and arg13 or arg12)
if AFKS.AFKMode.chatminbar.minimized then
if type == "WHISPER" then
AFKS.AFKMode.chatminbar.unreadwhisper = AFKS.AFKMode.chatminbar.unreadwhisper + 1
--print("whisper:"..AFKS.AFKMode.chatminbar.unreadwhisper)
elseif type == "GUILD" then
AFKS.AFKMode.chatminbar.unreadguild = AFKS.AFKMode.chatminbar.unreadguild + 1
end
local unreadwhisper, unreadbnet, unreadchannel = AFKS.AFKMode.chatminbar.unreadwhisper, AFKS.AFKMode.chatminbar.unreadbnet, AFKS.AFKMode.chatminbar.unreadchannel
if unreadwhisper > 0 then
unreadwhisper = "|cffffffff"..unreadwhisper.."|r"
end
if unreadbnet > 0 then
unreadbnet = "|cffffffff"..unreadbnet.."|r"
end
if unreadchannel > 0 then
unreadchannel = "|cffffffff"..unreadchannel.."|r"
end
local text = format(AFKS_CHATBAR_TEXT, unreadwhisper, unreadbnet, unreadchannel)
if IsInGuild() then
local unreadguild = AFKS.AFKMode.chatminbar.unreadguild
if unreadguild > 0 then
unreadguild = "|cffffffff"..unreadguild.."|r"
end
text = text.." "..format(AFKS_CHATBAR_GUILD, unreadguild)
end
AFKS.AFKMode.chatminbar.title:SetText(text)
end
self:AddMessage(body, info.r, info.g, info.b, info.id, false, accessID, typeID)
end
local function LoopAnimations()
if(AFKSPlayerModel.curAnimation == "wave") then
AFKSPlayerModel:SetAnimation(69)
AFKSPlayerModel.curAnimation = "dance"
AFKSPlayerModel.startTime = GetTime()
AFKSPlayerModel.duration = 300
AFKSPlayerModel.isIdle = false
AFKSPlayerModel.idleDuration = 120
end
end
local function FontTemplate(fs, fontSize, outline)
fontSize = fontSize or 12
if not outline then
outline = ""
end
fs:SetFont(_G.STANDARD_TEXT_FONT, fontSize, outline)
fs:SetShadowColor(0, 0, 0, 1)
fs:SetShadowOffset(1, -1)
end
local function SetTemplate(Frame)
local blank = "Interface/BUTTONS/WHITE8X8"
Frame:SetBackdrop({
bgFile = blank,
edgeFile = blank,
tile = false, tileSize = 0, edgeSize = 1,
insets = { left = -1, right = -1, top = -1, bottom = -1},
})
if not Frame.isInsetDone then
Frame.InsetTop = Frame:CreateTexture(nil, "BORDER")
Frame.InsetTop:SetPoint("TOPLEFT", Frame, "TOPLEFT", -1, 1)
Frame.InsetTop:SetPoint("TOPRIGHT", Frame, "TOPRIGHT", 1, -1)
Frame.InsetTop:SetHeight(1)
Frame.InsetTop:SetColorTexture(0,0,0)
Frame.InsetTop:SetDrawLayer("BORDER", -7)
Frame.InsetBottom = Frame:CreateTexture(nil, "BORDER")
Frame.InsetBottom:SetPoint("BOTTOMLEFT", Frame, "BOTTOMLEFT", -1, -1)
Frame.InsetBottom:SetPoint("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", 1, -1)
Frame.InsetBottom:SetHeight(1)
Frame.InsetBottom:SetColorTexture(0,0,0)
Frame.InsetBottom:SetDrawLayer("BORDER", -7)
Frame.InsetLeft = Frame:CreateTexture(nil, "BORDER")
Frame.InsetLeft:SetPoint("TOPLEFT", Frame, "TOPLEFT", -1, 1)
Frame.InsetLeft:SetPoint("BOTTOMLEFT", Frame, "BOTTOMLEFT", 1, -1)
Frame.InsetLeft:SetWidth(1)
Frame.InsetLeft:SetColorTexture(0,0,0)
Frame.InsetLeft:SetDrawLayer("BORDER", -7)
Frame.InsetRight = Frame:CreateTexture(nil, "BORDER")
Frame.InsetRight:SetPoint("TOPRIGHT", Frame, "TOPRIGHT", 1, 1)
Frame.InsetRight:SetPoint("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", -1, -1)
Frame.InsetRight:SetWidth(1)
Frame.InsetRight:SetColorTexture(0,0,0)
Frame.InsetRight:SetDrawLayer("BORDER", -7)
Frame.InsetInsideTop = Frame:CreateTexture(nil, "BORDER")
Frame.InsetInsideTop:SetPoint("TOPLEFT", Frame, "TOPLEFT", 1, -1)
Frame.InsetInsideTop:SetPoint("TOPRIGHT", Frame, "TOPRIGHT", -1, 1)
Frame.InsetInsideTop:SetHeight(1)
Frame.InsetInsideTop:SetColorTexture(0,0,0)
Frame.InsetInsideTop:SetDrawLayer("BORDER", -7)
Frame.InsetInsideBottom = Frame:CreateTexture(nil, "BORDER")
Frame.InsetInsideBottom:SetPoint("BOTTOMLEFT", Frame, "BOTTOMLEFT", 1, 1)
Frame.InsetInsideBottom:SetPoint("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", -1, 1)
Frame.InsetInsideBottom:SetHeight(1)
Frame.InsetInsideBottom:SetColorTexture(0,0,0)
Frame.InsetInsideBottom:SetDrawLayer("BORDER", -7)
Frame.InsetInsideLeft = Frame:CreateTexture(nil, "BORDER")
Frame.InsetInsideLeft:SetPoint("TOPLEFT", Frame, "TOPLEFT", 1, -1)
Frame.InsetInsideLeft:SetPoint("BOTTOMLEFT", Frame, "BOTTOMLEFT", -1, 1)
Frame.InsetInsideLeft:SetWidth(1)
Frame.InsetInsideLeft:SetColorTexture(0,0,0)
Frame.InsetInsideLeft:SetDrawLayer("BORDER", -7)
Frame.InsetInsideRight = Frame:CreateTexture(nil, "BORDER")
Frame.InsetInsideRight:SetPoint("TOPRIGHT", Frame, "TOPRIGHT", -1, -1)
Frame.InsetInsideRight:SetPoint("BOTTOMRIGHT", Frame, "BOTTOMRIGHT", 1, 1)
Frame.InsetInsideRight:SetWidth(1)
Frame.InsetInsideRight:SetColorTexture(0,0,0)
Frame.InsetInsideRight:SetDrawLayer("BORDER", -7)
Frame.isInsetDone = true
end
Frame:SetBackdropBorderColor(.31, .31, .31)
if wowVersion == "retail" then
Frame:SetBackdropColor(.06, .06, .06, 0)
else
Frame:SetBackdropColor(.06, .06, .06, .8)
end
end
local function SetSpecPanel()
local function SetLeftEndColor(specid)
local ColorBySpecID = {
-- Death Knight
[250] = {0.082, 0.078, 0.078},
[251] = {0.019, 0.11, 0.176},
[252] = {0.07, 0.082, 0.027},
-- Demon Hunter
[577] = {0.043, 0.1, 0.078},
[581] = {0.07, 0.055, 0.18},
-- Druid
[102] = {0.086, 0.1, 0.243},
[103] = {0.082, 0.129, 0.188},
[104] = {0.172, 0.086, 0.002},
[105] = {0.058, 0.086, 0.002},
-- Evoker
[1467] = {0.1, 0.063, 0.1},
[1468] = {0.062, 0.121, 0.105},
[1473] = {0.1, 0.1, 0.067},
-- Hunter
[253] = {0.082, 0.098, 0.235},
[254] = {0.066, 0.09, 0.043},
[255] = {0.176, 0.152, 0.137},
-- Mage
[62] = {0.066, 0.023, 0.141},
[63] = {0.1, 0.059, 0.035},
[64] = {0.062, 0.078, 0.145},
-- Monk
[268] = {0.082, 0.09, 0},
[269] = {0.125, 0.1, 0.16},
[270] = {0.118, 0.149, 0.255},
-- Paladin
[65] = {0.1, 0.067, 0.047},
[66] = {0.176, 0.067, 0.129},
[70] = {0.184, 0.145, 0.047},
-- Priest
[256] = {0.066, 0.086, 0.1},
[257] = {0.18, 0.145, 0.122},
[258] = {0.113, 0.07, 0.086},
-- Rogue
[259] = {0.113, 0.066, 0.003},
[260] = {0.043, 0.086, 0.082},
[261] = {0.075, 0.043, 0.075},
-- Shaman
[262] = {0.003, 0.078, 0.149},
[263] = {0.074, 0.07, 0.156},
[264] = {0.082, 0.086, 0.121},
-- Warlock
[265] = {0.07, 0.063, 0.22},
[266] = {0.078, 0.078, 0.074},
[267] = {0.1, 0.055, 0.031},
-- Warrior
[71] = {0.05, 0.078, 0.082},
[72] = {0.066, 0.07, 0.074},
[73] = {0.1, 0.078, 0.071},
}
local r, g, b = unpack(ColorBySpecID[specid])
AFKS.AFKMode.bottom.leftendtex:SetColorTexture(r, g, b)
AFKS.AFKMode.bottom.leftendtex:SetSize(GetScreenWidth() - 1567, panelheight - 3)
AFKS.AFKMode.bottom.leftendtex:Show()
end
local SpecIDToBackgroundAtlas = {
-- Death Knight
[250] = "talents-background-deathknight-blood",
[251] = "talents-background-deathknight-frost",
[252] = "talents-background-deathknight-unholy",
-- Demon Hunter
[577] = "talents-background-demonhunter-havoc",
[581] = "talents-background-demonhunter-vengeance",
-- Druid
[102] = "talents-background-druid-balance",
[103] = "talents-background-druid-feral",
[104] = "talents-background-druid-guardian",
[105] = "talents-background-druid-restoration",
-- Evoker
[1467] = "talents-background-evoker-devastation",
[1468] = "talents-background-evoker-preservation",
[1473] = "talents-background-evoker-augmentation",
-- Hunter
[253] = "talents-background-hunter-beastmastery",
[254] = "talents-background-hunter-marksmanship",
[255] = "talents-background-hunter-survival",
-- Mage
[62] = "talents-background-mage-arcane",
[63] = "talents-background-mage-fire",
[64] = "talents-background-mage-frost",
-- Monk
[268] = "talents-background-monk-brewmaster",
[269] = "talents-background-monk-windwalker",
[270] = "talents-background-monk-mistweaver",
-- Paladin
[65] = "talents-background-paladin-holy",
[66] = "talents-background-paladin-protection",
[70] = "talents-background-paladin-retribution",
-- Priest
[256] = "talents-background-priest-discipline",
[257] = "talents-background-priest-holy",
[258] = "talents-background-priest-shadow",
-- Rogue
[259] = "talents-background-rogue-assassination",
[260] = "talents-background-rogue-outlaw",
[261] = "talents-background-rogue-subtlety",
-- Shaman
[262] = "talents-background-shaman-elemental",
[263] = "talents-background-shaman-enhancement",
[264] = "talents-background-shaman-restoration",
-- Warlock
[265] = "talents-background-warlock-affliction",
[266] = "talents-background-warlock-demonology",
[267] = "talents-background-warlock-destruction",
-- Warrior
[71] = "talents-background-warrior-arms",
[72] = "talents-background-warrior-fury",
[73] = "talents-background-warrior-protection",
}
local panel_offset = { -- 0.049 + offset to toptexcoord
[63] = 0.01, -- Fire Mage
[64] = 0.05, -- Frost Mage
[65] = -0.015, -- Holy Paladin
[66] = 0.01, -- Protect Paladin
[70] = 0.075, -- Ret Paladin
[71] = 0.042, -- Arms Warrior
[72] = 0.005, -- Fury Warrior
[73] = 0.037, -- Protect Warrior
[102] = 0.006, -- Balance Druid
[103] = 0.037, -- Feral Druid
[104] = 0.025, -- Guardian Druid
[105] = 0.01, -- Resto Druid
[250] = -0.02, -- Blood DK
[251] = -0.01, -- Frost DK
[252] = 0.117, -- Unholy DK
[253] = -0.01, -- Beast Hunter
[254] = 0.005, -- Marksmanship Hunter
[255] = 0.057, -- Survival Hunter
[256] = 0.012, -- Discipline Priest
[259] = 0.02, -- Assassination Rogue
[261] = 0.064, -- Subtlety Rogue
[262] = 0.037, -- Elemental Shaman
[263] = -0.01, -- Enhancement Shaman
[264] = 0.037, -- Resto Shaman
[265] = 0.02, -- Affl Warlock
[266] = -0.035, -- Demon Warlock
[267] = 0.03, -- Dest Warlock
[268] = 0.025, -- Brew Monk
[269] = 0.015, -- Wind Monk
[577] = 0.012, -- Havoc DH
[581] = 0.022, -- Vengeance DH
[1467] = 0.014, -- Devast Evoker
[1468] = 0.023, -- Preserv Evoker
[1473] = 0.023, -- Augment Evoker
}
local model_yoffset = {
[1] = 30, -- Human
[2] = -15, -- Orc
[3] = -10, -- Dwarf
[5] = 10, -- Undead
[6] = 35, -- Tauren
[8] = 10, -- Troll
[9] = -10, -- Goblin
[11] = 8, -- Draenei
[24] = 25, -- Pandaren (Neutral)
[25] = 25, -- Pandaren (Alliance)
[26] = 25, -- Pandaren (Horde)
[28] = 25, -- Highmountain
[30] = 20, -- Lightforged
[31] = 5, -- Zandalari
[32] = 15, -- Kul Tiran
[34] = -20, -- Dark Iron Dwarf
}
local needs_to_resize = {
[3] = 1.6,
[8] = 1.8,
[9] = 1.7,
[24] = 1.7,
[25] = 1.7,
[26] = 1.7,
[28] = 1.8,
[32] = 1.8,
[34] = 1.6
}
local yoffset = GetScreenHeight() * 0.1 - 102.4
if yoffset < 0 then
yoffset = yoffset * 2.3
else
yoffset = yoffset * 3.5
end
local raceid = select(3, UnitRace("player"))
if needs_to_resize[raceid] then
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * needs_to_resize[raceid], GetScreenHeight() * needs_to_resize[raceid])
end
if raceid == 22 then -- Worgen
if WantsAlteredForm("player") then
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 1.8, GetScreenHeight() * 1.8)
yoffset = yoffset + 30
else
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 2, GetScreenHeight() * 2)
yoffset = yoffset + -7
end
elseif raceid == 52 or raceid == 70 then -- Dracthyr
if WantsAlteredForm("player") then
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 1.7, GetScreenHeight() * 1.7)
yoffset = yoffset + 30
else
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 2, GetScreenHeight() * 2)
yoffset = yoffset + -7
end
else
if model_yoffset[raceid] then
yoffset = yoffset + model_yoffset[raceid]
end
end
if select(2, UnitClass("player")) == "DRUID" then
if GetShapeshiftFormID() == 5 then -- Bear form
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 1, GetScreenHeight() * 1)
yoffset = yoffset + -120
elseif GetShapeshiftFormID() == 1 then -- Cat form
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 2, GetScreenHeight() * 2)
yoffset = yoffset - 135
elseif GetShapeshiftFormID() == 27 or GetShapeshiftFormID() == 29 then -- Flying form
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 1.4, GetScreenHeight() * 1.4)
yoffset = yoffset + -10
elseif GetShapeshiftFormID() == 31 or GetShapeshiftFormID() == 35 then -- Moonkin form
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 2, GetScreenHeight() * 2)
yoffset = yoffset + -55
elseif GetShapeshiftFormID() == 36 then -- Treant form
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 1.2, GetScreenHeight() * 1.2)
yoffset = yoffset + -30
else
if needs_to_resize[raceid] then
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * needs_to_resize[raceid], GetScreenHeight() * needs_to_resize[raceid])
else
AFKS.AFKMode.bottom.model:SetSize(GetScreenWidth() * 2, GetScreenHeight() * 2)
end
end
end
AFKS.AFKMode.bottom.modelHolder:ClearAllPoints()
AFKS.AFKMode.bottom.modelHolder:SetPoint("BOTTOMRIGHT", AFKS.AFKMode.bottom, "BOTTOMRIGHT", -220, 265 + yoffset)
local specid = select(1, GetSpecializationInfo(GetSpecialization()))
local atlasinfo = specid and SpecIDToBackgroundAtlas[specid]
local offset = panel_offset[specid] or 0
local info = atlasinfo and GetAtlasInfo(atlasinfo)
if info then
AFKS.AFKMode.bottom:SetBackdropColor(.06, .06, .06, 0)
AFKS.AFKMode.bottom.specpanel:Show()
AFKS.AFKMode.bottom.specpanel:SetTexture(info.file)
AFKS.AFKMode.bottom.specpanel:SetTexCoord(info.leftTexCoord, info.rightTexCoord, info.topTexCoord+0.049+offset, info.bottomTexCoord)
if GetScreenWidth() - 1567 > 0 then
SetLeftEndColor(specid)
else
AFKS.AFKMode.bottom.leftendtex:Hide()
end
else
AFKS.AFKMode.bottom:SetBackdropColor(.06, .06, .06, .8)
AFKS.AFKMode.bottom.specpanel:Hide()
AFKS.AFKMode.bottom.leftendtex:Hide()
end
end
local function SetSpecIcon()
if UnitLevel("player") >= 10 then
if wowVersion == "retail" then
local _, _, _, specicon = select(1, GetSpecializationInfo(GetSpecialization()))
if specicon then
AFKS.AFKMode.bottom.specicon:SetTexture(specicon)
AFKS.AFKMode.bottom.specicon:Show()
else
AFKS.AFKMode.bottom.specicon:Hide()
end
else
if wowVersion == "cata" then
local talent_points = {}
local spent = 0
local specicon
for i=1, GetNumTalentTabs() do
talent_points[i] = {}
talent_points[i]["icon"] = select(4, GetTalentTabInfo(i))
talent_points[i]["spent"] = select(5, GetTalentTabInfo(i))
end
for k, v in pairs(talent_points) do
if k == 1 then
spent = v["spent"]
specicon = v["icon"]
else
if v["spent"] > spent then
specicon = v["icon"]
spent = v["spent"]
end
end
end
if specicon then
AFKS.AFKMode.bottom.specicon:SetTexture(specicon)
AFKS.AFKMode.bottom.specicon:Show()
else
AFKS.AFKMode.bottom.specicon:Hide()
end
else
local primaryTalent
local talent_tree = {}
for i=1, GetNumTalentTabs() do
talent_tree[i] = select(3, GetTalentTabInfo(i))
end
for k, v in pairs(talent_tree) do
if k > 1 and v > talent_tree[k-1] then
primaryTalent = k
else
primaryTalent = 1
end
end
if primaryTalent == 1 and talent_tree[1] == 0 then
AFKS.AFKMode.bottom.specicon:Hide()
return
end
local specicon = select(2, GetTalentTabInfo(primaryTalent))
if specicon then
AFKS.AFKMode.bottom.specicon:SetTexture(specicon)
AFKS.AFKMode.bottom.specicon:Show()
else
AFKS.AFKMode.bottom.specicon:Hide()
end
end
end
else
AFKS.AFKMode.bottom.specicon:Hide()
end
end
local function SetDate(weekday_str, weekday_num)
local weekday
if eastasian then
local localized_weekday = {
_G.WEEKDAY_SUNDAY,
_G.WEEKDAY_MONDAY,
_G.WEEKDAY_TUESDAY,
_G.WEEKDAY_WEDNESDAY,
_G.WEEKDAY_THURSDAY,
_G.WEEKDAY_FRIDAY,
_G.WEEKDAY_SATURDAY,
}
weekday = localized_weekday[weekday_num+1]
else
weekday = weekday_str
end
if weekday_num == 6 then -- Sat
weekday = "|cFF2b59FF"..weekday.."|r"