-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPVPSound_SctEngine.lua
More file actions
321 lines (297 loc) · 13.6 KB
/
PVPSound_SctEngine.lua
File metadata and controls
321 lines (297 loc) · 13.6 KB
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
local addon, ns = ...
local PVPSound = ns.PVPSound
local PS = ns.PS
local PVPSoundSctEngineFrame = CreateFrame("Frame")
local TimeSinceLastSctUpdate = 0
local PVPSound_SctQueue = { }
local PVPSound_NextSctUpdate = 0.3200
local string, table, getglobal = string, table, getglobal
-- WoW 11+/12+: prefer C_AddOns.* APIs; older globals may be nil.
local function PVPSound_IsAddOnLoaded(name)
if type(C_AddOns) == "table" and type(C_AddOns.IsAddOnLoaded) == "function" then
local ok, loadedOrLoading, loaded = pcall(C_AddOns.IsAddOnLoaded, name)
if ok then
return loadedOrLoading or loaded
end
end
if type(_G.IsAddOnLoaded) == "function" then
local ok, loaded = pcall(_G.IsAddOnLoaded, name)
if ok then
return loaded
end
end
return false
end
local IsAddOnLoaded = PVPSound_IsAddOnLoaded
local ChatTypeInfo = ChatTypeInfo
-- Internal fallback message frame used when Blizzard combat text APIs are unavailable (12.0+).
function PVPSound:EnsureInternalSctFrame()
if self._InternalSctFrame then return end
local f = CreateFrame("ScrollingMessageFrame", "PVPSound_InternalSctFrame", UIParent)
f:SetSize(800, 250)
f:SetPoint("CENTER", UIParent, "CENTER", 0, 200)
local font = STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF"
f:SetFont(font, 32, "OUTLINE")
f:SetJustifyH("CENTER")
f:SetJustifyV("MIDDLE")
f:SetFading(true)
f:SetFadeDuration(1.0)
f:SetTimeVisible(1.5)
f:SetMaxLines(20)
f:SetInsertMode("TOP")
f:SetFrameStrata("HIGH")
f:Show()
self._InternalSctFrame = f
end
-- Sct Queue
function PVPSound:AddSctToQueue(killtype, file, message, frame)
-- This function will add file to the Sct Queue to be shown
-- If the file could not be found in the sound lengths table then just show it
-- This is a table of SoundLengths according to the selected SoundPack
if frame == nil then frame = "RaidWarning" end
if (PS_KillSoundPackName == "DevilMayCry" or PS_KillSoundPackName == "Dota2" or PS_KillSoundPackName == "Halo4" or PS_KillSoundPackName == "UnrealTournament3" or PS_KillSoundPackName == "Custom") and PS_SctEngine == true then
if killtype ~= nil and file ~= nil and message ~= nil then
local SctSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack..killtype.."Durations")
if SctSoundLengthTable ~= nil then
local SctFileFoundLength
for i = 1, table.getn(SctSoundLengthTable), 1 do
if string.upper(SctSoundLengthTable[i].dir) == string.upper(file) then
SctFileFoundLength = SctSoundLengthTable[i].duration
end
end
if SctFileFoundLength then
local SctTable = {message = message, frame = frame, length = SctFileFoundLength}
-- Insert the Sct into the Sct Queue
table.insert(PVPSound_SctQueue, SctTable)
else
-- Not in the sound table so just show it
PVPSound:AddToSct(message, frame)
end
else
PVPSound:AddToSct(message, frame)
end
end
else
-- We've got lengths for UnrealTournament3 and Custom SoundPacks only, if that's not selected or SoundEngine is disabled then just show it
if message ~= nil then
PVPSound:AddToSct(message, frame)
end
end
if #PVPSound_SctQueue > 0 and not PVPSoundSctEngineFrame:GetScript("OnUpdate") then
PVPSound_NextSctUpdate = 0
PVPSoundSctEngineFrame:SetScript("OnUpdate", PVPSound.UpdateSctEngine)
end
end
function PVPSound:AddToSct(message, frame)
if message == "nil" and frame ~= nil then
return false
elseif message ~= nil and PS_SctEngine == true then
if frame == nil then frame = "RaidWarning" end
if PS_KillSct == true and PS_MultiKillSct == true and PS_PaybackSct == true then
PVPSound:TriggerSct(message.."!", frame)
elseif PS_KillSct == true and PS_MultiKillSct == true and PS_PaybackSct == false then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."PaybackKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
elseif PS_KillSct == true and PS_MultiKillSct == false and PS_PaybackSct == true then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."MultiKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
elseif PS_KillSct == false and PS_MultiKillSct == true and PS_PaybackSct == true then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."KillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
elseif PS_KillSct == true and PS_MultiKillSct == false and PS_PaybackSct == false then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."MultiKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."PaybackKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
elseif PS_KillSct == false and PS_MultiKillSct == true and PS_PaybackSct == false then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."KillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."PaybackKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
elseif PS_KillSct == false and PS_MultiKillSct == false and PS_PaybackSct == true then
local FoundIt = false
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."KillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
local KillSoundLengthTable = getglobal("PVPSound_"..PS.KillSoundPack.."MultiKillDurations")
for i = 1, table.getn(KillSoundLengthTable), 1 do
if message == KillSoundLengthTable[i].name then
FoundIt = true
end
end
if FoundIt == false then
PVPSound:TriggerSct(message.."!", frame)
end
end
end
end
function PVPSound:TriggerSct(message, frame)
-- MSBT
-- MikSBT.DisplayMessage(message, scrollArea, isSticky, colorR(0-255), colorG(0-255), colorB(0-255), fontSize, fontName, outlineIndex, texturePath)
if MikSBT then
MikSBT.DisplayMessage(message, frame, true, 255, 0, 0, nil, nil, nil, nil)
-- SCT and SCTD
-- Message Frame -- SCT:DisplayMessage(message, color{r = (0.00-10.00), g = (0.00-10.00), b = (0.00-10.00)})
-- Frame 1, Frame 2, Frame 3 -- SCT:DisplayText(message, color{r = (0.00-10.00), g = (0.00-10.00), b = (0.00-10.00)}, isCrit, eventtype, frame[(1-3)], anitype, parent, icon)
elseif SCT then
if frame == "Message" or frame == "message" or frame == "MESSAGE" or frame == "Frame0" or frame == "Frame 0" or frame == "frame0" or frame == "frame 0" or frame == "FRAME0" or frame == "FRAME 0" or frame == "0" then
SCT:DisplayMessage(message, {r = 10, g = 0, b = 0})
elseif frame == "Frame1" or frame == "Frame 1" or frame == "frame1" or frame == "frame 1" or frame == "FRAME1" or frame == "FRAME 1" or frame == "1" then
SCT:DisplayText(message, {r = 10, g = 0, b = 0}, true, nil, 1, nil, nil, nil)
elseif frame == "Frame2" or frame == "Frame 2" or frame == "frame2" or frame == "frame 2" or frame == "FRAME2" or frame == "FRAME 2" or frame == "2" then
SCT:DisplayText(message, {r = 10, g = 0, b = 0}, true, nil, 2, nil, nil, nil)
elseif frame == "Damage" or frame == "damage" or frame == "DAMAGE" or frame == "Frame3" or frame == "Frame 3" or frame == "frame3" or frame == "frame 3" or frame == "FRAME3" or frame == "FRAME 3" or frame == "3" then
SCT:DisplayText(message, {r = 10, g = 0, b = 0}, true, nil, 3, nil, nil, nil)
end
-- Parrot
-- Parrot:ShowMessage(message, frame, sticky, colorR(0-255), colorG(0-255), colorB(0-255), font, fontsize, outline, icon)
elseif Parrot then
Parrot:ShowMessage(message, frame, true, 255, 0, 0, nil, nil, nil, nil)
-- xCT
-- ct.frames[(1-4)]:AddMessage(message, colorR(0-255), colorG(0-255), colorB(0-255))
elseif xCT then
if frame == "Damage" or frame == "damage" or frame == "DAMAGE" or frame == "Frame1" or frame == "Frame 1" or frame == "frame1" or frame == "frame 1" or frame == "FRAME1" or frame == "FRAME 1" or frame == "1" then
ct.frames[1]:AddMessage(message, 255, 0, 0)
elseif frame == "Healing" or frame == "healing" or frame == "HEALING" or frame == "Frame2" or frame == "Frame 2" or frame == "frame2" or frame == "frame 2" or frame == "FRAME2" or frame == "FRAME 2" or frame == "2" then
ct.frames[2]:AddMessage(message, 255, 0, 0)
elseif frame == "Damage Done" or frame == "damage done" or frame == "DAMAGE DONE" or frame == "Healing Done" or frame == "healing done" or frame == "HEALING DONE" or frame == "Floating Combat Text" or frame == "floating combat text" or frame == "FLOATING COMBAT TEXT" or frame == "Frame3" or frame == "Frame 3" or frame == "frame3" or frame == "frame 3" or frame == "FRAME3" or frame == "FRAME 3" or frame == "3" then
ct.frames[3]:AddMessage(message, 255, 0, 0)
elseif frame == "Frame4" or frame == "Frame 4" or frame == "frame4" or frame == "frame 4" or frame == "FRAME4" or frame == "FRAME 4" or frame == "4" then
ct.frames[4]:AddMessage(message, 255, 0, 0)
end
-- xCT+
-- xCT_Plus:AddMessage(frame, message, color{r = (0.00-1.00), g = (0.00-1.00), b = (0.00-1.00)})
elseif xCT_Plus then
if frame == "General" or frame == "general" or frame == "GENERAL" then
xCT_Plus:AddMessage("general", message, {1, 0, 0})
elseif frame == "Outgoing" or frame == "outgoing" or frame == "OUTGOING" then
xCT_Plus:AddMessage("outgoing", message, {1, 0, 0})
elseif frame == "Critical" or frame == "critical" or frame == "CRITICAL" then
xCT_Plus:AddMessage("critical", message, {1, 0, 0})
elseif frame == "Damage" or frame == "damage" or frame == "DAMAGE" then
xCT_Plus:AddMessage("damage", message, {1, 0, 0})
elseif frame == "Healing" or frame == "healing" or frame == "HEALING" then
xCT_Plus:AddMessage("healing", message, {1, 0, 0})
elseif frame == "Power" or frame == "power" or frame == "POWER" then
xCT_Plus:AddMessage("power", message, {1, 0, 0})
elseif frame == "Procs" or frame == "procs" or frame == "PROCS" then
xCT_Plus:AddMessage("procs", message, {1, 0, 0})
elseif frame == "Loot" or frame == "loot" or frame == "LOOT" then
xCT_Plus:AddMessage("loot", message, {1, 0, 0})
end
-- Default Blizzard SCT
-- CombatText_AddMessage(message, frame, colorR(0.00-1.00), colorG(0.00-1.00), colorB(0.00-1.00))
elseif IsAddOnLoaded("Blizzard_CombatText") then
-- 12.0+: Blizzard_CombatText may not expose CombatText_UpdateDisplayedMessages/COMBAT_TEXT_SCROLL_FUNCTION.
if type(_G.CombatText_AddMessage) == "function" and _G.COMBAT_TEXT_SCROLL_FUNCTION then
_G.CombatText_AddMessage(message, _G.COMBAT_TEXT_SCROLL_FUNCTION, 1, 0, 0)
else
PVPSound:EnsureInternalSctFrame()
if PVPSound._InternalSctFrame then
PVPSound._InternalSctFrame:AddMessage(message, 1, 0, 0)
return
end
end
-- Raid Notice
-- RaidNotice_AddMessage(frame, message, color)
else
PVPSound:EnsureInternalSctFrame()
if PVPSound._InternalSctFrame then
PVPSound._InternalSctFrame:AddMessage(message, 1, 0, 0)
return
end
RaidNotice_AddMessage(RaidBossEmoteFrame, message, ChatTypeInfo["RAID_WARNING"])
end
end
function PVPSound:ClearSctQueue()
-- This function will clear all the Scts from the Sct Queue
for i = table.getn(PVPSound_SctQueue), 1, - 1 do
table.remove(PVPSound_SctQueue, i)
end
PVPSoundSctEngineFrame:SetScript("OnUpdate", nil)
end
function PVPSound:PlayNextSct()
-- This function will play the next Sct in the Sct Queue and return how long that Sct will be played
-- If there is no Sct in the Sct Queue it will just return 0.3200
if PVPSound:SctInQueue() then
local x
PVPSound:AddToSct(PVPSound_SctQueue[1].message, PVPSound_SctQueue[1].frame)
x = PVPSound_SctQueue[1].length
table.remove(PVPSound_SctQueue, 1)
return x
else
return 0.3200
end
end
function PVPSound:SctInQueue()
-- This function will return 1 if there is a Sct in the Sct Queue, nil otherwise
if table.getn(PVPSound_SctQueue) > 0 then
return 1
else
return nil
end
end
function PVPSound:UpdateSctEngine(elapsed)
if PS_SctEngine == true then
TimeSinceLastSctUpdate = TimeSinceLastSctUpdate + elapsed
while TimeSinceLastSctUpdate > PVPSound_NextSctUpdate do
TimeSinceLastSctUpdate = TimeSinceLastSctUpdate - PVPSound_NextSctUpdate
if #PVPSound_SctQueue == 0 then
PVPSoundSctEngineFrame:SetScript("OnUpdate", nil)
end
PVPSound_NextSctUpdate = PVPSound:PlayNextSct()
end
end
end
--PVPSoundSctEngineFrame:SetScript("OnUpdate", PVPSound.UpdateSctEngine)