-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeathScreen.lua
More file actions
714 lines (632 loc) · 21.1 KB
/
DeathScreen.lua
File metadata and controls
714 lines (632 loc) · 21.1 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
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
---@class FunFact
local FunFact = FunFact
-- Default funny death messages
local DefaultDeathMessages = {
-- HUMOR (50)
'Here is a fun fact. You Died.',
'WELCOME TO FLOOR POV',
'YOU DIED. AGAIN.',
'GRAVITY WINS AGAIN',
'FLOOR INSPECTOR REPORTING',
'TAKING A DIRT NAP',
'RESPAWN LOADING...',
'HORIZONTAL HERO MODE',
'GROUND LEVEL ACHIEVED',
'FLOOR IS LAVA? NOT ANYMORE.',
'TACTICAL REPOSITIONING',
'UNSCHEDULED NAP TIME',
'THE FLOOR NEEDED A HUG',
"THAT WASN'T THE PLAN",
'CTRL+ALT+DELETED',
'TASK FAILED SUCCESSFULLY',
'SKILL ISSUE DETECTED',
'PRESS F TO PAY RESPECTS',
'404: LIFE NOT FOUND',
'CRITICAL EXISTENCE FAILURE',
'HARDCORE MODE: OFF',
'HAVE YOU TRIED NOT DYING?',
'YOUR REPAIR BILL SAYS HELLO',
'DEATH SPEEDRUN: PERSONAL BEST!',
'INSTRUCTIONS UNCLEAR. DIED ANYWAY.',
'WORKING AS INTENDED',
'CALCULATED. POORLY.',
'PROTIP: HEALTH SHOULD STAY ABOVE ZERO',
'YOU ZIGGED WHEN YOU SHOULD HAVE ZAGGED',
"THAT'LL BUFF OUT... RIGHT?",
'ACHIEVEMENT UNLOCKED: FLOOR TASTER',
'YOUR ANCESTORS ARE DISAPPOINTED',
'INSERT COIN TO CONTINUE',
'KILLED BY: BAD DECISIONS',
'YOU FORGOT TO DODGE',
'TURNS OUT THAT WAS AVOIDABLE',
'DEATH: 1, YOU: 0',
'MAYBE TRY EASIER CONTENT?',
'RIP BOZO',
'L + RATIO + YOU DIED',
'CERTIFIED BRUH MOMENT',
'NOT YOUR FINEST HOUR',
'WELL THAT ESCALATED QUICKLY',
'SHOULDA STAYED IN BED TODAY',
'YOUR LIFE FLASHED. IT WAS BORING.',
'PLOT TWIST: YOU WERE THE LOOT',
'FREE TRIP BACK TO THE GRAVEYARD',
'SPEEDRUNNING THE RESPAWN TIMER',
'THAT WENT WELL. FOR THEM.',
'YOU TRIED. THAT COUNTS FOR NOTHING.',
-- GAMING (25)
'WASTED',
'FATALITY',
'YOU DIED - DARK SOULS STYLE',
'SNAKE? SNAKE?! SNAAAAKE!!!',
'FINISH HIM! ...OH WAIT, THEY DID',
"IT'S DANGEROUS TO GO ALONE. YOU WENT ANYWAY.",
'YOU HAVE DIED OF DYSENTERY',
"MISSION FAILED. WE'LL GET 'EM NEXT TIME.",
'YOUR PRINCESS IS IN ANOTHER GRAVEYARD',
'DO A BARREL ROLL! ...INTO YOUR GRAVE',
'ALL YOUR BASE ARE BELONG TO DEATH',
'THE CAKE WAS A LIE. SO WAS YOUR SURVIVAL.',
'LEEEEROOOOY JENKINS!!! ...AND THEN YOU DIED',
'50 DKP MINUS!',
'MANY WHELPS! HANDLE IT! ...YOU DID NOT.',
'AT LEAST YOU HAVE CHICKEN',
'FROSTMOURNE HUNGERS... FOR YOUR SOUL',
'YOU ARE NOT PREPARED... TO LIVE',
'RUN AWAY LITTLE GIRL! ...YOU DID NOT.',
'MORE DOTS! ...NOT ENOUGH DOTS.',
'THAT WAS NOT VERY CASH MONEY OF THAT BOSS',
'GG EZ... WAIT, YOU LOST',
'SKILL TREE NEEDS MORE SURVIVAL POINTS',
'RESPAWN IN 3... 2... 1...',
'YOUR GEAR SCORE WAS NOT HIGH ENOUGH',
-- POP CULTURE (40)
'HARAMBE SENDS HIS REGARDS',
'THE UPSIDE DOWN CALLED. YOU ANSWERED.',
'YOU JUST GOT RICKROLLED BY DEATH',
'GAME OVER, MAN. GAME OVER!',
'I USED TO BE AN ADVENTURER LIKE YOU...',
"THIS ISN'T EVEN MY FINAL FORM",
'THANKS OBAMA',
'EMOTIONAL DAMAGE!',
'TO BE CONTINUED...',
'DIRECTED BY ROBERT B. WEIDE',
"I'VE MADE A HUGE MISTAKE",
'SURPRISE MECHANICS',
'AND I OOP-',
"SIR, THIS IS A WENDY'S... GRAVEYARD",
'THEY DID SURGERY ON A GRAPE. THEY DID MURDER ON YOU.',
'OK BOOMER. OK DEAD.',
'IT BE LIKE THAT SOMETIMES',
'I GUESS YOU COULD SAY... YOU DIED',
'VIBE CHECK: FAILED',
'NO CAP, YOU JUST DIED FR FR',
'SHEESH... THAT WAS BAD',
'CAUGHT IN 4K... DYING',
'RENT FREE IN THE GRAVEYARD',
'POV: YOU MADE A MISTAKE',
'MAIN CHARACTER SYNDROME: CURED',
'THE SIMULATION HAS ENDED YOUR TRIAL',
'WINTER CAME FOR YOU',
'YOU KNOW NOTHING, DEAD PLAYER',
'I AM INEVITABLE. YOU ARE DEAD.',
'PERFECTLY BALANCED. YOU ARE NOT.',
'REALITY IS OFTEN DISAPPOINTING',
'YOU SHOULD HAVE GONE FOR THE HEAD',
'I DONT FEEL SO GOOD...',
'WHAT IS GRIEF IF NOT LOVE PERSEVERING?',
'THIS IS THE WAY... TO THE GRAVEYARD',
'I HAVE SPOKEN. YOU HAVE DIED.',
'SOMEHOW, YOU DIED AGAIN',
'NEVER GONNA GIVE YOU UP. DEATH WILL.',
'THEY TOOK THE HOBBITS TO ISENGARD. THEY TOOK YOU TO THE GRAVE.',
'ONE DOES NOT SIMPLY WALK INTO MORDOR. OR SURVIVE.',
}
---@class FunFact.DeathScreen
---@field frame Frame The main death screen frame
---@field ticker any C_Timer ticker for fact rotation
---@field currentFact string The currently displayed fact
---@field timeRemaining number Seconds until next fact
---@field isTestMode boolean Whether we're in test mode (not actually dead)
local DeathScreen = {}
FunFact.DeathScreen = DeathScreen
-- Default position settings (change these to adjust default position)
local DEFAULT_Y_OFFSET = -250
-- Role-specific death messages (25 each)
local HealerDeathMessages = {
'HEALER DOWN! ...WAIT, YOU ARE THE HEALER',
'YOU HAD ONE JOB... HEAL YOURSELF',
'PHYSICIAN, HEAL THYSELF',
'WHO HEALS THE HEALER? NOBODY, APPARENTLY.',
'HEALING OTHERS: YES. HEALING SELF: NO.',
'THE RAID IS FINE. YOU ARE NOT.',
'MANA WAS FULL. HEALTH WAS NOT.',
'SHOULD HAVE USED A DEFENSIVE',
'FORGOT TO HEAL THE MOST IMPORTANT PERSON',
'YOUR HOTS COULD NOT SAVE YOU',
'DISPEL THAT DEATH DEBUFF... OH WAIT',
'THE GREEN BARS BETRAYED YOU',
'HEAL PRIORITY: TANK > DPS > YOU, APPARENTLY',
'EVEN YOUR OWN HEALS GAVE UP',
'STOOD IN FIRE WHILE HEALING EVERYONE ELSE',
'FOCUSED TOO HARD ON RAID FRAMES',
'YOUR HEALING METERS DIED WITH YOU',
'CARRIED THE RAID. DROPPED YOURSELF.',
'AT LEAST THE TANK IS ALIVE... RIGHT?',
'OVERHEALING YOURSELF: 0%',
'WHO NEEDS SELF-PRESERVATION ANYWAY?',
'HEALING EFFICIENCY: FATAL',
'YOU WERE TOO BUSY WATCHING HEALTH BARS',
'COOLDOWNS READY. YOU ARE NOT.',
'THE SPIRIT HEALER IS NOW YOUR CO-HEALER',
}
local TankDeathMessages = {
'PULLED TOO MUCH, EH?',
'FACE TANKING HAS ITS LIMITS',
'EVEN YOUR ARMOR GAVE UP',
'THE BOSS FOUND YOUR COOLDOWN GAP',
'THREAT ESTABLISHED. SURVIVAL NOT.',
'MAIN TANK DOWN! ...WHO PULLS NOW?',
'MITIGATION: 100%. SURVIVAL: 0%.',
'SHOULD HAVE KITED THAT ONE',
'YOUR SHIELD SENDS ITS CONDOLENCES',
'HEALER BLAMED. YOU KNOW IT WAS YOU.',
'DEFENSIVE COOLDOWNS ARE FOR USING',
'THE FLOOR TANK TAKES OVER',
'PULLED WALL-TO-WALL. DIED WALL-TO-FLOOR.',
"THAT'S ONE WAY TO DROP AGGRO",
'ACTIVE MITIGATION? MORE LIKE INACTIVE.',
'THOUGHT YOU WERE INVINCIBLE, HUH?',
'THE BOSS CRITTED YOUR EGO',
'TANKED EVERYTHING EXCEPT STAYING ALIVE',
'INCOMING DAMAGE EXCEEDED HEALER PATIENCE',
'PERHAPS LESS TRASH NEXT PULL?',
'YOU HELD AGGRO. BRIEFLY.',
'CONGRATULATIONS, YOU WIPED THE GROUP',
'RAID LEADER IS TYPING...',
'YOUR HEALTH BAR SAID GOODBYE',
'REPAIR BILL: YOUR DIGNITY',
}
local DPSDeathMessages = {
'IF YOU DID MORE DPS, YOU WOULD NOT BE DEAD',
'DEAD DPS IS ZERO DPS',
'SHOULD HAVE KILLED IT FASTER',
'MECHANICS ARE NOT A DPS LOSS IF YOU LIVE',
'YOUR PARSE DIED WITH YOU',
'PADDING METERS FROM THE GRAVEYARD?',
'TUNNELED THE BOSS. IGNORED THE MECHANIC.',
'THREAT ISSUES? IN THIS ECONOMY?',
'THE FLOOR IS NOT PART OF YOUR ROTATION',
"DPS'D SO HARD YOU FORGOT TO LIVE",
'STOOD IN BAD FOR THAT EXTRA CAST',
'GREED CAST: FATAL',
'YOUR DAMAGE METER STOPPED UPDATING',
'MAYBE INTERRUPT NEXT TIME?',
'PHASE TWO CLAIMED ANOTHER ONE',
'HEALERS HAVE PRIORITIES. YOU WERE NOT ONE.',
'AT LEAST YOU WERE TOP DPS... FOR A SECOND',
'EXECUTED THE ROTATION. GOT EXECUTED.',
"CAN'T PARSE FROM THE FLOOR",
'SOAK MECHANICS EXIST FOR A REASON',
'BLOODLUST COULD NOT SAVE YOU',
'SHOULD HAVE SAVED THAT DEFENSIVE',
'YOUR COOLDOWNS WILL MISS YOU',
'ENRAGE TIMER: YOU LOST',
'LOG THIS, WARCRAFTLOGS',
}
-- Easter egg messages for names ending in 'gale' (druid healer friend)
local GaleDruidMessages = {
'REJUVENATION? REGROWTH? HELLO?!',
"LIFEBLOOM COULDN'T SAVE YOU THIS TIME, GALE",
'INNERVATE THIS, GALE',
'TRANQUILITY WOULD HAVE BEEN NICE, GALE',
'WILD GROWTH? MORE LIKE WILD DEATH, GALE',
"BEAR FORM WASN'T ENOUGH, HUH GALE?",
'SHOULD HAVE STAYED IN TREE FORM, GALE',
'EVEN NATURE ABANDONED YOU, GALE',
'IRONBARK YOURSELF NEXT TIME, GALE... OH WAIT',
'THE DREAM CALLED. IT SAID GIT GUD, GALE.',
'SWIFTMEND WAS OFF COOLDOWN, GALE',
'CENARION WARD SENDS REGRETS, GALE',
}
local GaleNonDruidMessages = {
'A DRUID WOULD NOT HAVE DIED FROM THAT... GALE.',
'SHOULD HAVE ROLLED DRUID, GALE.',
'YOUR DRUID WOULD HAVE LIVED, JUST SAYING.',
'IMAGINE DYING AS A NON-DRUID... GALE.',
'MISS YOUR HEALS YET, GALE?',
'THIS IS WHAT HAPPENS WHEN YOU BETRAY THE DREAM, GALE',
"NATURE'S CURE CAN'T SAVE YOU NOW, GALE",
'ELUNE IS DISAPPOINTED, GALE.',
}
---Gets the player's role (HEALER, TANK, DAMAGER, or nil)
---@return string|nil
local function GetPlayerRole()
local spec = GetSpecialization()
if spec then
local role = GetSpecializationRole(spec)
return role
end
return nil
end
---Gets a random death message from defaults + user custom messages
---@return string
function DeathScreen:GetDeathMessage()
local playerName = UnitName('player') or ''
local nameLower = playerName:lower()
local _, playerClass = UnitClass('player')
local playerRole = GetPlayerRole()
-- Easter egg: 20% chance for special message if name ends in 'gale'
if nameLower:sub(-4) == 'gale' and math.random(1, 100) <= 20 then
if playerClass == 'DRUID' then
return GaleDruidMessages[math.random(1, #GaleDruidMessages)]
else
return GaleNonDruidMessages[math.random(1, #GaleNonDruidMessages)]
end
end
-- 20% chance for role-specific message
if playerRole and math.random(1, 100) <= 20 then
if playerRole == 'HEALER' then
return HealerDeathMessages[math.random(1, #HealerDeathMessages)]
elseif playerRole == 'TANK' then
return TankDeathMessages[math.random(1, #TankDeathMessages)]
elseif playerRole == 'DAMAGER' then
return DPSDeathMessages[math.random(1, #DPSDeathMessages)]
end
end
local messages = {}
-- Add default messages
for _, msg in ipairs(DefaultDeathMessages) do
table.insert(messages, msg)
end
-- Add user custom messages
if FunFact.DB and FunFact.DB.DeathScreen and FunFact.DB.DeathScreen.customMessages then
for _, msg in ipairs(FunFact.DB.DeathScreen.customMessages) do
if msg and msg ~= '' then
table.insert(messages, msg)
end
end
end
return messages[math.random(1, #messages)]
end
---Gets a random fact from enabled categories (death screen specific)
---@return string fact The fact text
---@return string category The category display name
function DeathScreen:GetFact()
local enabledCategories = FunFact.DB.DeathScreen.enabledCategories
local facts = {}
-- Collect facts from enabled categories with their category info
for name, submodule in FunFact:IterateModules() do
if string.match(name, 'FactList_') then
local categoryName = string.sub(name, 10)
-- Check if category is enabled (default to true if not set)
local isEnabled = enabledCategories[categoryName]
if isEnabled == nil then
isEnabled = enabledCategories['**'] or true
end
if isEnabled and submodule.Facts then
local displayName = submodule.displayname or categoryName
for _, fact in ipairs(submodule.Facts) do
table.insert(facts, { text = fact, category = displayName })
end
end
end
end
if #facts == 0 then
return 'No facts available. Enable some fact categories in the options.', 'Error'
end
local selected = facts[math.random(1, #facts)]
return selected.text, selected.category
end
---Creates the death screen frame
function DeathScreen:CreateFrame()
if self.frame then
return
end
local frame = CreateFrame('Frame', 'FunFactDeathScreen', UIParent, 'BackdropTemplate')
frame:SetSize(780, 195)
frame:SetPoint('TOP', 0, DEFAULT_Y_OFFSET)
frame:SetFrameStrata('FULLSCREEN_DIALOG')
frame:SetMovable(true)
frame:EnableMouse(true)
frame:Hide()
-- Background with atlas
frame.bg = frame:CreateTexture(nil, 'BACKGROUND')
frame.bg:SetAllPoints()
frame.bg:SetAtlas('house-upgrade-reward-section-bg')
frame.bg:SetAtlas('runecarving-background-smoke')
frame.bg:SetAlpha(0.9)
-- Shift+drag to move, Ctrl+Shift+Click to reset
frame:SetScript('OnMouseDown', function(f, button)
if button == 'LeftButton' then
if IsControlKeyDown() and IsShiftKeyDown() then
-- Reset position
DeathScreen:ResetPosition()
elseif IsShiftKeyDown() then
f:StartMoving()
end
end
end)
frame:SetScript('OnMouseUp', function(f, button)
f:StopMovingOrSizing()
-- Save position only if moved from default
local point, _, _, x, y = f:GetPoint()
if FunFact.DB and FunFact.DB.DeathScreen then
-- Check if position differs from default
local isDefault = (point == 'TOP' and math.abs(x) < 1 and math.abs(y - DEFAULT_Y_OFFSET) < 1)
if isDefault then
-- Clear position from DB if at default
FunFact.DB.DeathScreen.position = nil
else
-- Only store position if user has moved it
FunFact.DB.DeathScreen.position = {
point = point,
x = x,
y = y,
}
end
-- Update hint text visibility
DeathScreen:UpdateHintText()
end
end)
-- Death message header
frame.deathMessage = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormalHuge')
frame.deathMessage:SetPoint('TOP', frame, 'TOP', 0, -15)
frame.deathMessage:SetTextColor(1, 0.2, 0.2, 1)
frame.deathMessage:SetText('WELCOME TO FLOOR POV')
-- Category label
frame.categoryText = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
frame.categoryText:SetPoint('TOP', frame.deathMessage, 'BOTTOM', 0, -8)
frame.categoryText:SetTextColor(0.8, 0.8, 0.2, 1)
frame.categoryText:SetText('FunFact from DadJokes')
-- Fact text
frame.factText = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
frame.factText:SetPoint('TOP', frame.categoryText, 'BOTTOM', 0, -10)
frame.factText:SetPoint('LEFT', frame, 'LEFT', 30, 0)
frame.factText:SetPoint('RIGHT', frame, 'RIGHT', -30, 0)
frame.factText:SetJustifyH('CENTER')
frame.factText:SetJustifyV('TOP')
frame.factText:SetWordWrap(true)
frame.factText:SetTextColor(1, 1, 1, 1)
frame.factText:SetText('')
-- Close button in top right
frame.closeButton = CreateFrame('Button', nil, frame)
frame.closeButton:SetSize(20, 20)
frame.closeButton:SetPoint('TOPRIGHT', frame, 'TOPRIGHT', -8, -8)
frame.closeButton:SetNormalAtlas('runecarving-icon-reagent-empty-error')
frame.closeButton:SetHighlightTexture('Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight')
frame.closeButton:SetScript('OnClick', function()
DeathScreen:Hide()
end)
-- Clickable timer/spinner button to skip to next fact
frame.timerButton = CreateFrame('Button', nil, frame)
frame.timerButton:SetPoint('BOTTOM', frame, 'BOTTOM', 0, 50)
frame.timerButton:SetSize(150, 24)
-- Timer text with spinner
frame.timerText = frame.timerButton:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
frame.timerText:SetPoint('CENTER', frame.timerButton, 'CENTER', 8, 0)
frame.timerText:SetTextColor(0.7, 0.7, 0.7, 1)
frame.timerText:SetText('Next fact in 30s')
-- Spinner animation texture
frame.spinner = frame.timerButton:CreateTexture(nil, 'OVERLAY')
frame.spinner:SetSize(16, 16)
frame.spinner:SetPoint('RIGHT', frame.timerText, 'LEFT', -5, 0)
frame.spinner:SetAtlas('UI-RefreshButton')
-- Create rotation animation for spinner
frame.spinnerAnim = frame.spinner:CreateAnimationGroup()
local rotation = frame.spinnerAnim:CreateAnimation('Rotation')
rotation:SetDegrees(-360)
rotation:SetDuration(2)
rotation:SetSmoothing('NONE')
frame.spinnerAnim:SetLooping('REPEAT')
-- Click to load next fact
frame.timerButton:SetScript('OnClick', function()
DeathScreen:UpdateFact()
DeathScreen.timeRemaining = FunFact.DB.DeathScreen.rotationInterval
DeathScreen:UpdateTimer()
end)
-- Highlight on hover
frame.timerButton:SetScript('OnEnter', function()
frame.timerText:SetTextColor(1, 1, 1, 1)
end)
frame.timerButton:SetScript('OnLeave', function()
frame.timerText:SetTextColor(0.7, 0.7, 0.7, 1)
end)
-- Copy to Chat button
frame.copyButton = CreateFrame('Button', nil, frame)
frame.copyButton:SetSize(120, 28)
frame.copyButton:SetPoint('BOTTOM', frame, 'BOTTOM', 0, 20)
frame.copyButton:SetNormalAtlas('auctionhouse-nav-button')
frame.copyButton:SetHighlightAtlas('auctionhouse-nav-button-highlight')
frame.copyButton:SetPushedAtlas('auctionhouse-nav-button-select')
local normalTexture = frame.copyButton:GetNormalTexture()
if normalTexture then
normalTexture:SetTexCoord(0, 1, 0, 0.7)
end
frame.copyButton.text = frame.copyButton:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
frame.copyButton.text:SetPoint('CENTER')
frame.copyButton.text:SetText('Copy to Chat')
frame.copyButton.text:SetTextColor(1, 1, 1, 1)
frame.copyButton:SetScript('OnClick', function()
DeathScreen:CopyToChat()
end)
-- Hint text for moving/resetting
frame.hintText = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormalSmall')
frame.hintText:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', -10, 5)
frame.hintText:SetTextColor(0.5, 0.5, 0.5, 0.7)
frame.hintText:SetText('Shift+Drag to move')
self.frame = frame
end
---Updates the hint text based on whether the frame has been moved
function DeathScreen:UpdateHintText()
if not self.frame or not self.frame.hintText then
return
end
-- If position exists in DB, user has moved it from default
local pos = FunFact.DB.DeathScreen.position
if pos then
self.frame.hintText:SetText('Ctrl+Shift+Click to reset')
else
self.frame.hintText:SetText('Shift+Drag to move')
end
end
---Copies the current fact to the chat edit box
function DeathScreen:CopyToChat()
if not self.currentFact then
return
end
local editBox = ChatFrame1EditBox
if editBox then
editBox:SetText(self.currentFact)
editBox:Show()
editBox:SetFocus()
editBox:HighlightText()
end
end
---Updates the displayed fact
function DeathScreen:UpdateFact()
if not self.frame then
return
end
local fact, category = self:GetFact()
self.currentFact = fact
self.currentCategory = category
self.frame.factText:SetText(fact)
self.frame.categoryText:SetText('FunFact from ' .. category)
self.timeRemaining = FunFact.DB.DeathScreen.rotationInterval
end
---Updates the timer display
function DeathScreen:UpdateTimer()
if not self.frame or not self.frame:IsShown() then
return
end
if FunFact.DB.DeathScreen.showTimer then
self.frame.timerText:Show()
self.frame.spinner:Show()
self.frame.timerText:SetText(string.format('Next fact in %ds', self.timeRemaining))
else
self.frame.timerText:Hide()
self.frame.spinner:Hide()
end
end
---Starts the fact rotation timer
function DeathScreen:StartTimer()
self:StopTimer()
self.timeRemaining = FunFact.DB.DeathScreen.rotationInterval
-- Update timer every second
self.ticker = C_Timer.NewTicker(1, function()
self.timeRemaining = self.timeRemaining - 1
self:UpdateTimer()
if self.timeRemaining <= 0 then
self:UpdateFact()
self.timeRemaining = FunFact.DB.DeathScreen.rotationInterval
end
end)
-- Start spinner animation
if self.frame and self.frame.spinnerAnim then
self.frame.spinnerAnim:Play()
end
end
---Stops the fact rotation timer
function DeathScreen:StopTimer()
if self.ticker then
self.ticker:Cancel()
self.ticker = nil
end
if self.frame and self.frame.spinnerAnim then
self.frame.spinnerAnim:Stop()
end
end
---Resets the frame position to default
function DeathScreen:ResetPosition()
-- Clear position from DB to use default
FunFact.DB.DeathScreen.position = nil
if self.frame then
self.frame:ClearAllPoints()
self.frame:SetPoint('TOP', UIParent, 'TOP', 0, DEFAULT_Y_OFFSET)
end
self:UpdateHintText()
if FunFact.logger then
FunFact.logger.info('DeathScreen position reset to default')
end
end
---Shows the death screen
---@param isTest boolean|nil Whether this is a test invocation
function DeathScreen:Show(isTest)
if not FunFact.DB.DeathScreen.enabled then
return
end
self.isTestMode = isTest or false
if not self.frame then
self:CreateFrame()
end
-- Restore saved position only if user has moved it, otherwise use default
local pos = FunFact.DB.DeathScreen.position
if pos and pos.point then
self.frame:ClearAllPoints()
self.frame:SetPoint(pos.point, UIParent, pos.point, pos.x or 0, pos.y or DEFAULT_Y_OFFSET)
else
-- Use default position
self.frame:ClearAllPoints()
self.frame:SetPoint('TOP', UIParent, 'TOP', 0, DEFAULT_Y_OFFSET)
end
-- Update hint text based on moved state
self:UpdateHintText()
-- Set death message
self.frame.deathMessage:SetText(self:GetDeathMessage())
-- Get initial fact
self:UpdateFact()
self:UpdateTimer()
-- Start rotation
self:StartTimer()
self.frame:Show()
end
---Hides the death screen
function DeathScreen:Hide()
self:StopTimer()
if self.frame then
self.frame:Hide()
end
self.isTestMode = false
end
---Toggles the death screen (for test command)
function DeathScreen:Toggle()
if self.frame and self.frame:IsShown() then
self:Hide()
else
self:Show(true)
end
end
---Initializes the death screen module
function DeathScreen:Initialize()
-- Create the frame
self:CreateFrame()
-- Register for death events
local eventFrame = CreateFrame('Frame')
eventFrame:RegisterEvent('PLAYER_DEAD')
eventFrame:RegisterEvent('PLAYER_ALIVE')
eventFrame:RegisterEvent('PLAYER_UNGHOST')
eventFrame:RegisterEvent('PLAYER_ENTERING_WORLD')
eventFrame:SetScript('OnEvent', function(_, event)
if event == 'PLAYER_DEAD' then
-- Small delay to let the death UI appear first
C_Timer.After(0.5, function()
DeathScreen:Show(false)
end)
elseif event == 'PLAYER_ALIVE' or event == 'PLAYER_UNGHOST' then
-- Don't hide if in test mode
if not DeathScreen.isTestMode then
DeathScreen:Hide()
end
elseif event == 'PLAYER_ENTERING_WORLD' then
-- Check if player is dead on login/reload
if UnitIsDeadOrGhost('player') then
C_Timer.After(0.5, function()
DeathScreen:Show(false)
end)
end
end
end)
if FunFact.logger then
FunFact.logger.info('DeathScreen module initialized')
end
end