RaidWarning.lua

RaidWarning.lua (8.3.0.34963; unchanged since 8.1.5.29701)
  1. RAID_NOTICE_DEFAULT_HOLD_TIME = 10.0;
  2. RAID_NOTICE_FADE_IN_TIME = 0.2;
  3. RAID_NOTICE_FADE_OUT_TIME = 3.0;
  4. function RaidNotice_FadeInit( slotFrame )
  5. FadingFrame_OnLoad(slotFrame);
  6. FadingFrame_SetFadeInTime(slotFrame, RAID_NOTICE_FADE_IN_TIME);
  7. FadingFrame_SetHoldTime(slotFrame, RAID_NOTICE_FADE_IN_TIME);
  8. FadingFrame_SetFadeOutTime(slotFrame, RAID_NOTICE_FADE_OUT_TIME);
  9. end
  10. function RaidNotice_AddMessage( noticeFrame, textString, colorInfo, displayTime )
  11. if ( not textString ) then
  12. return;
  13. end
  14. if (not displayTime or displayTime == 0) then
  15. displayTime = RAID_NOTICE_DEFAULT_HOLD_TIME;
  16. else
  17. displayTime = displayTime - RAID_NOTICE_FADE_OUT_TIME;
  18. displayTime = max(displayTime, 1.0);
  19. end
  20. noticeFrame:Show();
  21. if ( not noticeFrame.slot1:IsShown() ) then
  22. noticeFrame.slot1_text = textString;
  23. RaidNotice_SetSlot( noticeFrame.slot1, noticeFrame.slot1_text, colorInfo, noticeFrame.timings["RAID_NOTICE_MIN_HEIGHT"], displayTime );
  24. noticeFrame.slot1.scrollTime = 0;
  25. else
  26. if ( noticeFrame.slot2:IsShown() and FadingFrame_GetRemainingTime(noticeFrame.slot2) > FadingFrame_GetRemainingTime(noticeFrame.slot1)) then
  27. noticeFrame.slot1_text = noticeFrame.slot2_text;
  28. RaidNotice_SetSlot( noticeFrame.slot1, noticeFrame.slot1_text, colorInfo, noticeFrame.timings["RAID_NOTICE_MIN_HEIGHT"] );
  29. noticeFrame.slot1.scrollTime = noticeFrame.slot2.scrollTime;
  30. FadingFrame_CopyTimes(noticeFrame.slot2, noticeFrame.slot1);
  31. end
  32. noticeFrame.slot2_text = textString;
  33. RaidNotice_SetSlot( noticeFrame.slot2, noticeFrame.slot2_text, colorInfo, noticeFrame.timings["RAID_NOTICE_MIN_HEIGHT"], displayTime );
  34. noticeFrame.slot2.scrollTime = 0;
  35. end
  36. end
  37. function RaidNotice_SetSlot( slotFrame, textString, colorInfo, minHeight, displayTime )
  38. slotFrame:SetText( textString );
  39. slotFrame:SetTextColor( colorInfo.r, colorInfo.g, colorInfo.b, 1.0 )
  40. slotFrame:SetTextHeight(minHeight);
  41. FadingFrame_SetHoldTime(slotFrame, displayTime or RAID_NOTICE_DEFAULT_HOLD_TIME );
  42. FadingFrame_Show( slotFrame );
  43. end
  44. function RaidNotice_OnUpdate( noticeFrame, elapsedTime )
  45. local inUse = false;
  46. if ( noticeFrame.slot1:IsShown() ) then
  47. RaidNotice_UpdateSlot( noticeFrame.slot1, noticeFrame.timings, elapsedTime, true );
  48. inUse = true;
  49. end
  50. if ( noticeFrame.slot2:IsShown() ) then
  51. RaidNotice_UpdateSlot( noticeFrame.slot2, noticeFrame.timings, elapsedTime, true );
  52. inUse = true;
  53. end
  54. if ( not inUse ) then
  55. noticeFrame:Hide();
  56. end
  57. end
  58. function RaidNotice_Clear( noticeFrame )
  59. RaidNotice_ClearSlot(noticeFrame.slot1);
  60. RaidNotice_ClearSlot(noticeFrame.slot2);
  61. end
  62. function RaidNotice_ClearSlot( slotFrame )
  63. slotFrame.scrollTime = nil;
  64. slotFrame:Hide();
  65. end
  66. function RaidNotice_UpdateSlot( slotFrame, timings, elapsedTime, hasFading )
  67. if ( slotFrame.scrollTime ) then
  68. slotFrame.scrollTime = slotFrame.scrollTime + elapsedTime;
  69. if ( slotFrame.scrollTime <= timings["RAID_NOTICE_SCALE_UP_TIME"] ) then
  70. slotFrame:SetTextHeight(floor(timings["RAID_NOTICE_MIN_HEIGHT"]+((timings["RAID_NOTICE_MAX_HEIGHT"]-timings["RAID_NOTICE_MIN_HEIGHT"])*slotFrame.scrollTime/timings["RAID_NOTICE_SCALE_UP_TIME"])));
  71. elseif ( slotFrame.scrollTime <= timings["RAID_NOTICE_SCALE_DOWN_TIME"] ) then
  72. slotFrame:SetTextHeight(floor(timings["RAID_NOTICE_MAX_HEIGHT"] - ((timings["RAID_NOTICE_MAX_HEIGHT"]-timings["RAID_NOTICE_MIN_HEIGHT"])*(slotFrame.scrollTime - timings["RAID_NOTICE_SCALE_UP_TIME"])/(timings["RAID_NOTICE_SCALE_DOWN_TIME"] - timings["RAID_NOTICE_SCALE_UP_TIME"]))));
  73. else
  74. slotFrame:SetTextHeight(timings["RAID_NOTICE_MIN_HEIGHT"]);
  75. slotFrame.scrollTime = nil;
  76. end
  77. end
  78. if ( hasFading ) then
  79. FadingFrame_OnUpdate(slotFrame);
  80. end
  81. end
  82. ----------- RAID WARNING
  83. function RaidWarningFrame_OnLoad(self)
  84. self:RegisterEvent("CHAT_MSG_RAID_WARNING");
  85. self.slot1 = RaidWarningFrameSlot1;
  86. self.slot2 = RaidWarningFrameSlot2;
  87. RaidNotice_FadeInit( self.slot1 );
  88. RaidNotice_FadeInit( self.slot2 );
  89. self.timings = { };
  90. self.timings["RAID_NOTICE_MIN_HEIGHT"] = 20.0;
  91. self.timings["RAID_NOTICE_MAX_HEIGHT"] = 30.0;
  92. self.timings["RAID_NOTICE_SCALE_UP_TIME"] = 0.2;
  93. self.timings["RAID_NOTICE_SCALE_DOWN_TIME"] = 0.4;
  94. end
  95. function RaidWarningFrame_OnEvent(self, event, message)
  96. if ( event == "CHAT_MSG_RAID_WARNING" ) then
  97. message = C_ChatInfo.ReplaceIconAndGroupExpressions(message);
  98. RaidNotice_AddMessage( self, message, ChatTypeInfo["RAID_WARNING"] );
  99. PlaySound(SOUNDKIT.RAID_WARNING);
  100. end
  101. end
  102. ----------- BOSS EMOTE
  103. function RaidBossEmoteFrame_OnLoad(self)
  104. RaidNotice_FadeInit(self.slot1);
  105. RaidNotice_FadeInit(self.slot2);
  106. self.timings = { };
  107. self.timings["RAID_NOTICE_MIN_HEIGHT"] = 20.0;
  108. self.timings["RAID_NOTICE_MAX_HEIGHT"] = 30.0;
  109. self.timings["RAID_NOTICE_SCALE_UP_TIME"] = 0.2;
  110. self.timings["RAID_NOTICE_SCALE_DOWN_TIME"] = 0.4;
  111. self:RegisterEvent("RAID_BOSS_EMOTE");
  112. self:RegisterEvent("RAID_BOSS_WHISPER");
  113. self:RegisterEvent("CLEAR_BOSS_EMOTES");
  114. end
  115. function RaidBossEmoteFrame_OnEvent(self, event, ...)
  116. if (event == "RAID_BOSS_EMOTE" or event == "RAID_BOSS_WHISPER") then
  117. local text, playerName, displayTime, playSound = ...;
  118. local body = format(text, playerName, playerName); --No need for pflag, monsters can't be afk, dnd, or GMs.
  119. local info = ChatTypeInfo[event];
  120. RaidNotice_AddMessage( self, body, info, displayTime );
  121. -- RaidNotice_AddMessage( RaidBossEmoteFrame, "This is a TEST of the MESSAGE!", ChatTypeInfo["RAID_BOSS_EMOTE"] );
  122. if ( playSound ) then
  123. if ( event == "RAID_BOSS_WHISPER" ) then
  124. PlaySound(SOUNDKIT.UI_RAID_BOSS_WHISPER_WARNING);
  125. else
  126. PlaySound(SOUNDKIT.RAID_BOSS_EMOTE_WARNING);
  127. end
  128. end
  129. elseif ( event == "CLEAR_BOSS_EMOTES" ) then
  130. RaidNotice_Clear(self);
  131. end
  132. end