-- SpellNotReadyYet v1.1. Created by Shadowmagé - Stormrage EU -- CONFIG local iconsize; local xoff; local yoff; local tfont; local fontsize = 16; local fdur = 0.7; local function snr_saveall() saved = {} saved["iconsize"] = iconsize saved["xoff"] = xoff saved["yoff"] = yoff saved["tfont"] = tfont saved["fontsize"] = fontsize saved["fdur"] = fdur end iconsize = 40 -- Changes the size of the icon xoff = 0 -- Increase to move right, decrease to move left (note: you can go into minus numbers) yoff = 0 -- Increase to move up, decrease to move down (note: you can go into minus numbers) tfont = "Fonts\\FRIZQT__.TTF" -- The file path for the font you wish to use fontsize = 16 -- Font size fdur = 0.7 -- Duration of the icon appearing on the screen (range between 0.1 and 1, anything above 1 and stuff gets funky) SLASH_SNR1 = '/snr'; function SlashCmdList.SNR(msg) local command, rest = msg:match("^(%S*)%s*(.-)$"); print(command.."-"..rest); if command == "x" and rest ~= "" then xoff = tonumber(rest); elseif command == "y" and rest ~= "" then yoff = tonumber(rest); end snr_saveall(); end ----------------- local _; local frameFlashManager = CreateFrame("FRAME"); local FLASHFRAMES = {}; local UIFrameFlashTimers = {}; local UIFrameFlashTimerRefCount = {}; -- Function to see if a frame is already flashing local function UIFrameIsFlashing(frame) for index, value in pairs(FLASHFRAMES) do if ( value == frame ) then return 1; end end return nil; end -- Function to stop flashing local function UIFrameFlashStop(frame) tDeleteItem(FLASHFRAMES, frame); frame:SetAlpha(1.0); frame.flashTimer = nil; if (frame.syncId) then UIFrameFlashTimerRefCount[frame.syncId] = UIFrameFlashTimerRefCount[frame.syncId]-1; if (UIFrameFlashTimerRefCount[frame.syncId] == 0) then UIFrameFlashTimers[frame.syncId] = nil; UIFrameFlashTimerRefCount[frame.syncId] = nil; end frame.syncId = nil; end if ( frame.showWhenDone ) then frame:Show(); else frame:Hide(); end end -- Called every frame to update flashing frames local function UIFrameFlash_OnUpdate(self, elapsed) local frame; local index = #FLASHFRAMES; -- Update timers for all synced frames for syncId, timer in pairs(UIFrameFlashTimers) do UIFrameFlashTimers[syncId] = timer + elapsed; end while FLASHFRAMES[index] do frame = FLASHFRAMES[index]; frame.flashTimer = frame.flashTimer + elapsed; if ( (frame.flashTimer > frame.flashDuration) and frame.flashDuration ~= -1 ) then UIFrameFlashStop(frame); else local flashTime = frame.flashTimer; local alpha; if (frame.syncId) then flashTime = UIFrameFlashTimers[frame.syncId]; end flashTime = flashTime%(frame.fadeInTime+frame.fadeOutTime+(frame.flashInHoldTime or 0)+(frame.flashOutHoldTime or 0)); if (flashTime < frame.fadeInTime) then alpha = flashTime/frame.fadeInTime; elseif (flashTime < frame.fadeInTime+(frame.flashInHoldTime or 0)) then alpha = 1; elseif (flashTime < frame.fadeInTime+(frame.flashInHoldTime or 0)+frame.fadeOutTime) then alpha = 1 - ((flashTime - frame.fadeInTime - (frame.flashInHoldTime or 0))/frame.fadeOutTime); else alpha = 0; end frame:SetAlpha(alpha); frame:Show(); end -- Loop in reverse so that removing frames is safe index = index - 1; end if ( #FLASHFRAMES == 0 ) then self:SetScript("OnUpdate", nil); end end -- Function to start a frame flashing local function UIFrameFlash(frame, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, syncId) if ( frame ) then local index = 1; -- If frame is already set to flash then return while FLASHFRAMES[index] do if ( FLASHFRAMES[index] == frame ) then return; end index = index + 1; end if (syncId) then frame.syncId = syncId; if (UIFrameFlashTimers[syncId] == nil) then UIFrameFlashTimers[syncId] = 0; UIFrameFlashTimerRefCount[syncId] = 0; end UIFrameFlashTimerRefCount[syncId] = UIFrameFlashTimerRefCount[syncId]+1; else frame.syncId = nil; end -- Time it takes to fade in a flashing frame frame.fadeInTime = fadeInTime; -- Time it takes to fade out a flashing frame frame.fadeOutTime = fadeOutTime; -- How long to keep the frame flashing frame.flashDuration = flashDuration; -- Show the flashing frame when the fadeOutTime has passed frame.showWhenDone = showWhenDone; -- Internal timer frame.flashTimer = 0; -- How long to hold the faded in state frame.flashInHoldTime = flashInHoldTime; -- How long to hold the faded out state frame.flashOutHoldTime = flashOutHoldTime; tinsert(FLASHFRAMES, frame); frameFlashManager:SetScript("OnUpdate", UIFrameFlash_OnUpdate); end end local formatTime = function(s) local day, hour, minute = 86400, 3600, 60 if s >= day then return format("%dd", floor(s/day + 0.5)), s % day elseif s >= hour then return format("%dh", floor(s/hour + 0.5)), s % hour elseif s >= minute then return format("%dm", floor(s/minute + 0.5)), s % minute elseif s >= minute / 12 then return floor(s + 0.5), (s * 100 - floor(s * 100))/100 end return format("%.1f", s), (s * 100 - floor(s * 100))/100 end -- Hides standard UI error spam frame, since we are -- replacing it by our icons UIErrorsFrame:Hide(); local frame = CreateFrame("Frame"); frame:RegisterEvent("UNIT_SPELLCAST_FAILED"); frame:RegisterEvent("UI_ERROR_MESSAGE"); -- frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED"); frame:RegisterEvent("ADDON_LOADED"); local function eventHandler(self, event, ...) -- Fires on spellcast (either suceeded or failed because of cooldown, etc) if event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_SUCCEEDED" then local unit, spellname, spellrank, spellidcounter, id = ...; local start, duration, enabled = GetSpellCooldown(id); local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(id) local seconds = GetTime(); local timeleft = (start + duration - seconds); if name == "Synapse Springs" then else if unit == "player" then local iconframe = CreateFrame("Frame", nil, UIParent) UIFrameFlash(iconframe, 0, fdur, fdur, false, 0, 0) iconframe:SetPoint("CENTER", xoff, yoff) iconframe:SetSize(iconsize, iconsize) iconframe:SetBackdrop({ bgFile = icon }) if event == "UNIT_SPELLCAST_FAILED" then iconframe:SetBackdropColor(1,0.2,0.2); local tr = iconframe:CreateFontString() tr:SetPoint("BOTTOM", 0, 0) tr:SetSize(40, 40) tr:SetFont(tfont, fontsize, "OUTLINE") tr:SetTextColor(1,0.7,0.7) if timeleft < 0 then tr:SetText("ERR") else tr:SetText(formatTime(timeleft)) end end iconframe:SetFrameStrata("BACKGROUND") end end -- fires on UI Error "I need a target!" elseif event == "UI_ERROR_MESSAGE" then local iconframe = CreateFrame("Frame", nil, UIParent) UIFrameFlash(iconframe, 0, fdur, fdur, false, 0, 0) iconframe:SetPoint("CENTER", xoff, yoff) iconframe:SetSize(iconsize, iconsize) iconframe:SetBackdrop({ bgFile = "Interface\\TargetingFrame\\UI-RaidTargetingIcon_7" }) -- iconframe:SetBackdropColor(1,0.2,0.2); iconframe:SetFrameStrata("BACKGROUND") -- load options elseif event == "ADDON_LOADED" then if saved then iconsize = saved["iconsize"] xoff = saved["xoff"] yoff = saved["yoff"] tfont = saved["tfont"] fontsize = saved["fontsize"] fdur = saved["fdur"] end end end frame:SetScript("OnEvent", eventHandler);