-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirectedByRobertBWeide.lua
executable file
·244 lines (206 loc) · 5.16 KB
/
DirectedByRobertBWeide.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
--- Main module
-- @module DBRBW
DBRBW = {}
local creditsFrame
local creditsBackground
local creditsText
local creditsFadeAnimation
local creditsTextAnimation
local isPlaying = false
local timers = {}
local musicHandle
--- Main initialization
--
function DBRBW.Initialize()
-- Create UI elements
creditsFrame = CreateFrame("Frame", "DBRBW_Credits", UIParent)
creditsFrame:EnableMouse(true)
creditsFrame:SetAllPoints()
creditsFrame:Hide()
creditsBackground = creditsFrame:CreateTexture("DBRBW_CreditsBackground", "OVERLAY", nil, 7)
creditsBackground:SetColorTexture(0, 0, 0, 1)
creditsBackground:SetAllPoints()
creditsText = creditsFrame:CreateFontString(nil, "OVERLAY")
creditsText:SetAllPoints()
creditsText:SetFont("Interface\\AddOns\\DirectedByRobertBWeide\\Clarendon-Medium.ttf", 50)
creditsText:SetSpacing(20)
creditsText:SetTextColor(1, 1, 1, 1)
-- Create animations
creditsFadeAnimation = creditsFrame:CreateAnimationGroup()
creditsFadeAnimation:SetToFinalAlpha(true)
local fadeIn = creditsFadeAnimation:CreateAnimation("Alpha")
fadeIn:SetFromAlpha(0)
fadeIn:SetToAlpha(1)
fadeIn:SetDuration(.5)
fadeIn:SetSmoothing("OUT")
creditsTextAnimation = creditsText:CreateAnimationGroup()
creditsTextAnimation:SetToFinalAlpha(true)
local textFade = creditsTextAnimation:CreateAnimation("Alpha")
textFade:SetFromAlpha(0)
textFade:SetToAlpha(1)
textFade:SetDuration(.5)
textFade:SetSmoothing("OUT")
-- Stop credits animation when escape is pressed
creditsFrame:SetScript(
"OnKeyDown",
function(self, keyValue)
if keyValue == "ESCAPE" then
DBRBW.HideCredits()
if not InCombatLockdown() then
self:SetPropagateKeyboardInput(false)
end
return
end
if not InCombatLockdown() then
self:SetPropagateKeyboardInput(true)
end
end
)
-- Play credits animation when dead
creditsFrame:RegisterEvent("PLAYER_DEAD")
creditsFrame:SetScript(
"OnEvent",
function()
C_Timer.After(2.5, DBRBW.ShowCredits)
end
)
-- /dbrbw command
SlashCmdList["DBRBW"] = DBRBW.ShowCredits
SLASH_DBRBW1 = "/dbrbw"
SLASH_DBRBW2 = "/curb"
end
--- Get customized credits
-- @return credits (table)
function DBRBW.GetCredits()
local himself = UnitSex("player") == 3 and "Herself" or "Himself"
local player = string.upper(UnitName("player"))
return {
{ "Directed by", "ROBERT B. WEIDE", 1 },
{ "Executive Producer", "LARRY DAVID", 3.3 },
{ "Executive Producer", "JEFF GARLIN", 3.3 },
{ "Executive Producer", "GAVIN POLONE", 3.3 },
{ "Co-Executive Producer", "ROBERT B. WEIDE", 3.3 },
{ "Produced by", "TIM GIBBONS", 3.3 },
{ "Co-Producer", "ERIN O'MALLEY", 3.3 },
{ "Consulting Producer", "ALAN ZWEIBEL", 3.3 },
{ "Starring", player .. " as " .. himself, 3.3 }
}
end
--- Start credits animation
--
function DBRBW.ShowCredits()
-- Stop previously playing credits
DBRBW.HideCredits()
-- Mute game music
PlayMusic("Interface\\AddOns\\DirectedByRobertBWeide\\silent.mp3")
-- Preload audio
local _, preloadHandle = PlaySoundFile("Interface\\AddOns\\DirectedByRobertBWeide\\frolic.mp3", "Master")
StopSound(preloadHandle, 0)
-- UI needs to be shown
UIParent:Show()
-- Enable keyboard control
creditsFrame:EnableKeyboard(true)
-- Prepare credits
creditsText:SetText("")
-- Enqueue credits
local time = 0
local credit
for _, credit in pairs(DBRBW.GetCredits()) do
local row1, row2, delay = unpack(credit)
time = time + delay
table.insert(
timers,
C_Timer.NewTimer(
time,
function()
creditsText:SetText(row1 .. "\n" .. row2)
end
)
)
end
-- Enqueue music
table.insert(
timers,
C_Timer.NewTimer(
1 + 3.3 - 2.2,
function()
_, musicHandle = PlaySoundFile("Interface\\AddOns\\DirectedByRobertBWeide\\frolic.mp3", "Master")
end
)
)
-- Enqueue animation end sequence
table.insert(
timers,
C_Timer.NewTimer(
30,
function()
StopSound(musicHandle, 5000)
musicHandle = nil
end
)
)
table.insert(
timers,
C_Timer.NewTimer(
34,
function()
creditsTextAnimation:Play(true)
end
)
)
table.insert(
timers,
C_Timer.NewTimer(
35,
function()
creditsFadeAnimation:Play(true)
end
)
)
table.insert(
timers,
C_Timer.NewTimer(
36,
function()
DBRBW.HideCredits()
end
)
)
-- Init frame
creditsFrame:SetFrameStrata("TOOLTIP")
creditsFrame:SetFrameLevel(UIParent:GetFrameLevel() + 1000)
creditsFrame:SetAlpha(0)
creditsText:SetAlpha(1)
creditsFrame:Show()
creditsFrame:SetScale(1 / UIParent:GetScale())
-- Play animation
creditsFadeAnimation:Play()
isPlaying = true
end
--- Stop credits animation
--
function DBRBW.HideCredits()
if not (isPlaying) then
return
end
-- Disable keyboard control
creditsFrame:EnableKeyboard(false)
-- Stop all timers
local timer
for _, timer in pairs(timers) do
timer:Cancel()
end
timers = {}
-- Stop animations, hide frame
creditsFadeAnimation:Stop()
creditsTextAnimation:Stop()
creditsFrame:Hide()
-- Stop music
if musicHandle then
StopSound(musicHandle, 100)
end
musicHandle = nil
StopMusic()
isPlaying = false
end
DBRBW.Initialize()