You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2616 lines
88 KiB

3 years ago
4 years ago
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
3 years ago
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LDB and LibStub("LibDBIcon-1.0", true)
local LibWindow = LibStub("LibWindow-1.1")
4 years ago
local _
---need cleanup Loc ["STRING_MEMORY_ALERT_BUTTON"],
3 years ago
--create the plugin object
4 years ago
-- "Details_StreamOverlay" is the old name
3 years ago
local StreamOverlay = _detalhes:NewPluginObject("Details_Streamer", DETAILSPLUGIN_ALWAYSENABLED)
--tinsert(UISpecialFrames, "Details_StreamOverlays")
--main frame (shortcut)
4 years ago
local SOF = StreamOverlay.Frame
3 years ago
--shortcut for details framework
local playerName
4 years ago
StreamOverlay.CurrentVersion = "v1.2"
3 years ago
--mantaing the tables for casts, has hash indexes of numbers pointing to tables, tables inside store data of the UNIT_CAST events
--also mantain information about the cast, if is done, interrupted, channeled, instant.
4 years ago
--Target = the target of the spell casted or the spellname if is a death table
--Id = the CastId from UNIT_CAST events.
--CastStart = GetTime from the cast start.
--HasCastTime = if true, isn't a instant cast.
--Interrupted = if the cast has been interrupted (any interrupt even walk).
--Done = the cast is done and isn't more relevant to track updates.
--Percent = cast percentage, used to update the statusbar.
--Death = this is a event from death tables.
local CastsTable = {}
3 years ago
--store bars references
4 years ago
StreamOverlay.battle_lines = {}
3 years ago
--store the information to be shown on bars, like text, icon, colors
4 years ago
StreamOverlay.battle_content = {}
StreamOverlay.squares = {}
-- StreamOverlay:UpdateLines() = update the bar text, icons and statusbar. Uses battle_lines and battle_content tables.
-- StreamOverlay:NewText() = adds a new line to battle_content and call update.
-- StreamOverlay:CreateBattleLine() = create a new line on the frame and add to battle_lines table.
-- StreamOverlay:SetBattleLineStyle (row, index) = update bar config like font size, bar height, etc,
-- StreamOverlay:RefreshInUse (line) = check if the bar still need to be shown in the screen or if can hide. Runs every 1 minute.
-- StreamOverlay:Refresh() = check if need to create more lines after a resize.
-- StreamOverlay:GetSpellInformation (spellid) = get information about the spell, if is a cooldown, defense, neutral, class, etc.
-- StreamOverlay:CastStart (castid) = called from the UNIT_CAST parser, it starts a cast when isn't a instant cast.
-- StreamOverlay:CastFinished (castid) = called from the UNIT_CAST parser, finish a cast.
-- track_spell_cast() runs on tick, check CastsTables updating ongoing spell casting, updates cast percentage.
-- StreamOverlay.OnDeath hook deaths from details! and show here (if player only).
--frame listening to UNIT_CAST events
3 years ago
local eventFrame = CreateFrame("frame")
4 years ago
--max left and right text sizes, is updated later in a function
3 years ago
local text1Size, text2Size = 200, 200
4 years ago
--icon size, is updated later in a function
3 years ago
local iconSize = 16
4 years ago
--default icon for an attack on a monster
3 years ago
local defaultAttackIcon = [[Interface\CURSOR\UnableAttack]]
4 years ago
local function CreatePluginFrames()
3 years ago
--shortcut for details fade function
4 years ago
local fader = Details.FadeHandler.Fader
3 years ago
function StreamOverlay:OnDetailsEvent(event, ...)
if (event == "HIDE") then --plugin hidded, disabled
4 years ago
self.open = false
3 years ago
elseif (event == "SHOW") then --plugin hidded, disabled
4 years ago
self.open = true
elseif (event == "PLUGIN_DISABLED") then
StreamOverlay:OnDisablePlugin()
3 years ago
4 years ago
elseif (event == "DETAILS_STARTED") then
StreamOverlay:OnEnablePlugin()
3 years ago
4 years ago
elseif (event == "PLUGIN_ENABLED") then
StreamOverlay:OnEnablePlugin()
3 years ago
4 years ago
end
end
function StreamOverlay:OnEnablePlugin()
3 years ago
--show the frame and restore position
4 years ago
SOF:Show()
3 years ago
--restore size and location
4 years ago
StreamOverlay:RestoreWindowSizeAndLocation()
3 years ago
--refresh the frame
4 years ago
StreamOverlay:Refresh()
StreamOverlay:SetBackgroundColor()
StreamOverlay:CreateMinimapIcon()
3 years ago
--enable the minimap icon
LDBIcon:Refresh("DetailsStreamer", StreamOverlay.db.minimap)
4 years ago
StreamOverlay:SetLocked()
3 years ago
--install the death hook
Details:InstallHook(DETAILS_HOOK_DEATH, StreamOverlay.OnDeath)
4 years ago
3 years ago
--enable event listener
eventFrame:RegisterMyEvents()
4 years ago
3 years ago
--enable the tick update
eventFrame:SetScript("OnUpdate", eventFrame.track_spell_cast)
4 years ago
3 years ago
--refresh dps frame
4 years ago
StreamOverlay:UpdateDpsHpsFrameConfig()
end
function StreamOverlay:OnDisablePlugin()
3 years ago
--shutdown the tick update
eventFrame:SetScript("OnUpdate", nil)
4 years ago
3 years ago
--disable the event listener
eventFrame:UnregisterMyEvents()
4 years ago
3 years ago
--unistall the death hook
4 years ago
Details:UnInstallHook (DETAILS_HOOK_DEATH, StreamOverlay.OnDeath)
3 years ago
--shutdown minimap icon
4 years ago
StreamOverlay:CreateMinimapIcon()
local realstate = StreamOverlay.db.minimap.hide
StreamOverlay.db.minimap.hide = true
LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap)
StreamOverlay.db.minimap.hide = realstate
3 years ago
--save position, size and hide the frame
4 years ago
StreamOverlay:SaveWindowSizeAnLocation()
SOF:Hide()
3 years ago
--refresh dps frame
4 years ago
StreamOverlay:UpdateDpsHpsFrameConfig (true)
end
3 years ago
--title bar, only shown when the frame isn't locked
local titlebar = CreateFrame("frame", "DetailsStreamerTitlebar", SOF, "BackdropTemplate")
titlebar:SetHeight(20)
titlebar:SetPoint("bottomleft", SOF, "topleft")
titlebar:SetPoint("bottomright", SOF, "topright")
titlebar:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
titlebar:SetBackdropColor(.1, .1, .1, .9)
titlebar.text = titlebar:CreateFontString(nil, "overlay", "GameFontNormal")
titlebar.text:SetPoint("center", titlebar, "center")
titlebar.text:SetText("Details! Streamer: Action Tracker")
titlebar:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self)
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
GameTooltip:AddLine("|cFFFF7700Left Click|r: Open Options\n|cFFFF7700Right Click|r: Lock the Frame\n|cFFFF7700Slash Command|r: /streamer")
4 years ago
GameTooltip:Show()
end)
3 years ago
titlebar:SetScript("OnLeave", function()
4 years ago
GameTooltip:Hide()
end)
3 years ago
SOF:SetScript("OnMouseDown", function(self)
4 years ago
end)
3 years ago
SOF:SetScript("OnMouseUp", function(self)
4 years ago
end)
3 years ago
titlebar:SetScript("OnMouseDown", function(self, button)
4 years ago
if (not SOF.moving and not StreamOverlay.db.main_frame_locked) then
SOF:StartMoving()
SOF.moving = true
SOF.movingAt = GetTime()
end
end)
3 years ago
titlebar:SetScript("OnMouseUp", function(self, button)
4 years ago
if (SOF.movingAt) then
if (SOF.moving) then
SOF.moving = false
SOF:StopMovingOrSizing()
StreamOverlay:SaveWindowSizeAnLocation()
end
if (SOF.movingAt+0.200 < GetTime()) then
return
end
SOF.movingAt = nil
end
if (button == "LeftButton") then
--open options
StreamOverlay.OpenOptionsPanel()
elseif (button == "RightButton") then
--lock the frame
StreamOverlay:SetLocked (not StreamOverlay.db.main_frame_locked)
if (StreamOverlayOptionsPanel) then
StreamOverlayOptionsPanel:RefreshOptions()
end
end
end)
3 years ago
--main frame parameters
SOF:SetPoint("center", UIParent, "center")
SOF:SetSize(300, 500)
SOF:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
SOF:EnableMouse(true)
SOF:SetMovable(true)
SOF:SetResizable(true)
SOF:SetClampedToScreen(true)
pcall(function()
if (DetailsFramework.IsDragonflight()) then
SOF:SetResizeBounds(150, 10, 800, 1024)
else
SOF:SetMinResize(150, 10)
SOF:SetMaxResize(800, 1024)
end
end)
4 years ago
function StreamOverlay:SaveWindowSizeAnLocation()
3 years ago
--save size first
4 years ago
StreamOverlay.db.main_frame_size [1] = SOF:GetWidth()
StreamOverlay.db.main_frame_size [2] = SOF:GetHeight()
3 years ago
--save main frame position
LibWindow.RegisterConfig(SOF, StreamOverlay.db)
LibWindow.SavePosition(SOF)
--save the dps frame position
LibWindow.RegisterConfig(StreamerOverlayDpsHpsFrame, StreamOverlay.db.per_second)
LibWindow.SavePosition(StreamerOverlayDpsHpsFrame)
4 years ago
end
function StreamOverlay:RestoreWindowSizeAndLocation()
3 years ago
--restore the size first
SOF:SetSize(unpack(StreamOverlay.db.main_frame_size))
--set the main window location
LibWindow.RegisterConfig(SOF, StreamOverlay.db)
LibWindow.RestorePosition(SOF)
LibWindow.SavePosition(SOF)
--set the dps frame location
LibWindow.RegisterConfig(StreamerOverlayDpsHpsFrame, StreamOverlay.db.per_second)
LibWindow.RestorePosition(StreamerOverlayDpsHpsFrame)
LibWindow.SavePosition(StreamerOverlayDpsHpsFrame)
--set the frame strata
SOF:SetFrameStrata(StreamOverlay.db.main_frame_strata)
StreamerOverlayDpsHpsFrame:SetFrameStrata(StreamOverlay.db.main_frame_strata)
4 years ago
end
3 years ago
--two resizers
local left_resize = CreateFrame("button", "DetailsStreamerLeftResizer", SOF, "BackdropTemplate")
local right_resize = CreateFrame("button", "DetailsStreamerRightResizer", SOF, "BackdropTemplate")
left_resize:SetPoint("bottomleft", SOF, "bottomleft")
right_resize:SetPoint("bottomright", SOF, "bottomright")
left_resize:SetSize(16, 16)
right_resize:SetSize(16, 16)
right_resize:SetNormalTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
right_resize:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
right_resize:SetPushedTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
left_resize:SetNormalTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
left_resize:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
left_resize:SetPushedTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
left_resize:GetNormalTexture():SetTexCoord(1, 0, 0, 1)
left_resize:GetHighlightTexture():SetTexCoord(1, 0, 0, 1)
left_resize:GetPushedTexture():SetTexCoord(1, 0, 0, 1)
left_resize:SetScript("OnMouseDown", function(self)
4 years ago
if (not SOF.resizing and not StreamOverlay.db.main_frame_locked) then
SOF.resizing = true
3 years ago
SOF:StartSizing("bottomleft")
4 years ago
end
end)
3 years ago
left_resize:SetScript("OnMouseUp", function(self)
4 years ago
if (SOF.resizing) then
SOF.resizing = false
SOF:StopMovingOrSizing()
StreamOverlay:Refresh()
StreamOverlay:SaveWindowSizeAnLocation()
end
end)
3 years ago
right_resize:SetScript("OnMouseDown", function(self)
4 years ago
if (not SOF.resizing and not StreamOverlay.db.main_frame_locked) then
SOF.resizing = true
3 years ago
SOF:StartSizing("bottomright")
4 years ago
end
end)
3 years ago
right_resize:SetScript("OnMouseUp", function(self)
4 years ago
if (SOF.resizing) then
SOF.resizing = false
SOF:StopMovingOrSizing()
StreamOverlay:Refresh()
StreamOverlay:SaveWindowSizeAnLocation()
end
end)
3 years ago
SOF:SetScript("OnSizeChanged", function(self)
4 years ago
StreamOverlay:Refresh()
end)
3 years ago
SOF:SetScript("OnMouseDown", function(self)
4 years ago
if (not SOF.moving and not StreamOverlay.db.main_frame_locked) then
SOF:StartMoving()
SOF.moving = true
end
end)
3 years ago
SOF:SetScript("OnMouseUp", function(self)
4 years ago
if (SOF.moving) then
SOF.moving = false
SOF:StopMovingOrSizing()
StreamOverlay:SaveWindowSizeAnLocation()
end
end)
3 years ago
--scroll frame
local autoscroll = CreateFrame("scrollframe", "Details_StreamOverlayScrollFrame", SOF, "FauxScrollFrameTemplate, BackdropTemplate")
autoscroll:SetScript("OnVerticalScroll", function(self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, StreamOverlay.UpdateLines) end)
4 years ago
3 years ago
--looks like this isn't working
4 years ago
function StreamOverlay:ClearAll()
if (StreamOverlay.db.use_square_mode) then
for index = 1, #StreamOverlay.squares do
local square = StreamOverlay.squares[index]
if (square) then
square.in_use = 1
end
end
StreamOverlay:UpdateSquares()
else
for index = 1, #StreamOverlay.battle_lines do
local line = StreamOverlay.battle_lines [index]
if (line) then
line.in_use = 1
end
end
StreamOverlay:UpdateLines()
end
end
function StreamOverlay:UpdateCooldownFrame(square, inCooldown, startTime, endTime, castInfo)
if (castInfo and castInfo.Interrupted and castInfo.InterruptedPct) then
CooldownFrame_SetDisplayAsPercentage(square.cooldown, abs(castInfo.InterruptedPct - 1))
--square.interruptedTexture:Show()
return
end
if (endTime and endTime < GetTime()) then
CooldownFrame_Clear(square.cooldown)
square.cooldown:Hide()
return
end
if (inCooldown) then
local duration = endTime - startTime
CooldownFrame_Set(square.cooldown, startTime, duration, duration > 0, true)
square.cooldown:Show()
else
CooldownFrame_Clear(square.cooldown)
square.cooldown:Hide()
end
end
function StreamOverlay:CreateSquareBox()
3 years ago
local index = #StreamOverlay.squares + 1
local newSquare = CreateFrame("frame", "StreamOverlaySquare" .. index, SOF, "BackdropTemplate")
newSquare:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
newSquare:SetBackdropBorderColor(0, 0, 0, 0)
newSquare.squareIndex = index
4 years ago
3 years ago
newSquare.texture = newSquare:CreateTexture(nil, "artwork")
newSquare.texture:SetAllPoints()
4 years ago
3 years ago
newSquare.interruptedTexture = newSquare:CreateTexture(nil, "overlay")
newSquare.interruptedTexture:SetColorTexture(1, 0, 0, 0.4)
newSquare.interruptedTexture:SetAllPoints()
newSquare.interruptedTexture:Hide()
4 years ago
3 years ago
local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", newSquare, "CooldownFrameTemplate, BackdropTemplate")
4 years ago
cooldownFrame:SetAllPoints()
cooldownFrame:EnableMouse(false)
3 years ago
cooldownFrame:SetHideCountdownNumbers(true)
newSquare.cooldown = cooldownFrame
4 years ago
3 years ago
StreamOverlay.squares[#StreamOverlay.squares+1] = newSquare
newSquare.in_use = 1
newSquare:Hide()
4 years ago
3 years ago
StreamOverlay:SetSquareStyle(newSquare, index)
StreamOverlay:ReorderSquares()
end
4 years ago
3 years ago
function StreamOverlay:ReorderSquares()
local direction = StreamOverlay.db.square_grow_direction
for index = 1, #StreamOverlay.squares do
local thisSquare = StreamOverlay.squares[index]
thisSquare:ClearAllPoints()
if (direction == "right") then --growing from left to right
if (index == 1) then
thisSquare:SetPoint("topleft", SOF, "topleft", 2, 0)
else
thisSquare:SetPoint("left", StreamOverlay.squares[index - 1], "right", 2, 0)
end
else
if (index == 1) then
thisSquare:SetPoint("topright", SOF, "topright", -2, 0)
else
thisSquare:SetPoint("right", StreamOverlay.squares[index - 1], "left", -2, 0)
end
4 years ago
end
end
end
3 years ago
function StreamOverlay:UpdateSquares()
for index = 1, StreamOverlay.total_lines do
StreamOverlay:UpdateSquare(index)
end
end
4 years ago
function StreamOverlay:UpdateSquare(index)
local square = StreamOverlay.squares[index]
local data = StreamOverlay.battle_content[index]
if (data) then
3 years ago
square.texture:SetTexture(data[1])
4 years ago
square.texture:SetTexCoord(5/64, 59/64, 5/64, 59/64)
--percentage
local castinfo = CastsTable[data.CastID]
local percent = castinfo and castinfo.Percent or 0
if (percent > 100) then
percent = 100
end
local startTime = data.startTime
local endTime = data.endTime
StreamOverlay:UpdateCooldownFrame(square, true, startTime, endTime, castinfo)
3 years ago
4 years ago
if (castinfo.Interrupted) then
--square.interruptedTexture:Show()
else
square.interruptedTexture:Hide()
end
square.in_use = data.CastStart
StreamOverlay:RefreshInUse(square)
else
square.in_use = 1
StreamOverlay:RefreshInUse(square)
end
end
3 years ago
--iterate each bar and update its text, icons and statusbar
4 years ago
function StreamOverlay:UpdateLines()
if (StreamOverlay.db.use_square_mode) then
return
end
3 years ago
FauxScrollFrame_Update(autoscroll, StreamOverlay.total_lines, StreamOverlay.total_lines, 20)
for index = 1, StreamOverlay.total_lines do
--here gets the bar and the table with the information to shown on the bar
4 years ago
local data = StreamOverlay.battle_content [index]
local line = StreamOverlay.battle_lines [index]
if (data) then
3 years ago
--left
line.icon1:SetTexture(data [1])
line.icon1:SetTexCoord(5/64, 59/64, 5/64, 59/64)
4 years ago
local text = data [2]
3 years ago
line.text1:SetText(text)
4 years ago
local loops = 20
3 years ago
while (line.text1:GetStringWidth() > text1Size and loops > 0) do
4 years ago
text = strsub (text, 1, #text-1)
3 years ago
line.text1:SetText(text)
4 years ago
loops = loops - 1 --just to be safe
end
3 years ago
--right
4 years ago
local text = data [6]
3 years ago
line.text2:SetText(text)
4 years ago
local loops = 20
3 years ago
while (line.text2:GetStringWidth() > text2Size and loops > 0) do
4 years ago
text = strsub (text, 1, #text-1)
3 years ago
line.text2:SetText(text)
4 years ago
loops = loops - 1 --just to be safe
end
if (text == "") then
line.icon2:Hide()
line.arrow:Hide()
else
line.icon2:Show()
line.arrow:Show()
end
if (data[7]) then
3 years ago
line.text2:SetTextColor(data[7].r, data[7].g, data[7].b)
4 years ago
else
3 years ago
line.text2:SetTextColor(1, 1, 1)
4 years ago
end
3 years ago
line.icon2:SetTexture(data [4])
line.icon2:SetTexCoord(unpack(data [5]))
if (data [4] == defaultAttackIcon) then
line.icon2:SetSize(iconSize*0.8, iconSize*0.8)
line.icon2:SetPoint("left", line, "center", 8, 0)
line.text2:SetPoint("left", line.icon2, "right", 5, 0)
4 years ago
else
3 years ago
line.icon2:SetSize(iconSize, iconSize)
line.icon2:SetPoint("left", line, "center", 8, 0)
line.text2:SetPoint("left", line.icon2, "right", 5, 0)
4 years ago
end
3 years ago
--background
line:SetBackdropColor(unpack(data [8]))
4 years ago
if (data [9]) then
3 years ago
line:SetBackdropBorderColor(unpack(data [9]))
4 years ago
else
3 years ago
line:SetBackdropBorderColor(0, 0, 0, 0)
4 years ago
end
3 years ago
--percentage
4 years ago
local castinfo = CastsTable [data.CastID]
local percent = castinfo and castinfo.Percent or 0
if (percent > 100) then
percent = 100
end
3 years ago
line.statusbar:SetValue(percent)
4 years ago
if (StreamOverlay.db.use_spark) then
line.spark:Show()
else
line.spark:Hide()
end
if (castinfo.Success) then
3 years ago
line.spark:SetVertexColor(1, 1, 1, 0.4)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0)
4 years ago
elseif (castinfo.Interrupted) then
3 years ago
line.spark:SetVertexColor(1, 0, 0, 0.4)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0)
4 years ago
end
line.in_use = data.CastStart
StreamOverlay:RefreshInUse (line)
else
line.in_use = 1
StreamOverlay:RefreshInUse (line)
end
end
end
function StreamOverlay:NewText (icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, ID, CastStart, startTime, endTime)
if (StreamOverlay.ShowingDeath) then
StreamOverlay.ShowingDeath = nil
StreamOverlay:ClearAll()
end
--CastStart from the cast_send
3 years ago
table.insert(StreamOverlay.battle_content, 1, {icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, CastID = ID, CastStart = CastStart, startTime = startTime, endTime = endTime})
4 years ago
table.remove (StreamOverlay.battle_content, StreamOverlay.total_lines+1)
if (StreamOverlay.db.use_square_mode) then
StreamOverlay:UpdateSquares()
else
StreamOverlay:UpdateLines()
end
end
function StreamOverlay:CreateBattleLine()
local index = #StreamOverlay.battle_lines+1
3 years ago
local f = CreateFrame("frame", "StreamOverlayBar" .. index, SOF, "BackdropTemplate")
local statusbar = CreateFrame("StatusBar", "StreamOverlayBar" .. index .. "StatusBar", f, "BackdropTemplate")
local statusbar_texture = statusbar:CreateTexture(nil, "border")
statusbar_texture:SetTexture(1, 1, 1, 0.15)
statusbar:SetStatusBarColor(0, 0, 0, 0)
statusbar:SetStatusBarTexture(statusbar_texture)
statusbar:SetMinMaxValues(0, 100)
statusbar:SetValue(0)
local statusbar_spark = statusbar:CreateTexture(nil, "artwork")
statusbar_spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
statusbar_spark:SetSize(16, 50)
statusbar_spark:SetBlendMode("ADD")
4 years ago
statusbar_spark:Hide()
local h = (index-1) * StreamOverlay.db.row_spacement * -1
3 years ago
f:SetPoint("topleft", SOF, "topleft", 0, h)
f:SetPoint("topright", SOF, "topright", 0, h)
4 years ago
--backdrop color not editable
3 years ago
f:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
f:SetBackdropBorderColor(0, 0, 0, 0)
--f:SetBackdropColor(0, 0, 0, 0)
4 years ago
3 years ago
local icon1 = statusbar:CreateTexture(nil, "overlay")
local icon2 = statusbar:CreateTexture(nil, "overlay")
4 years ago
3 years ago
local arrow = statusbar:CreateTexture(nil, "overlay")
4 years ago
3 years ago
local text1 = statusbar:CreateFontString(nil, "overlay", "GameFontNormal")
local text2 = statusbar:CreateFontString(nil, "overlay", "GameFontNormal")
4 years ago
3 years ago
icon1:SetPoint("left", f, "left", 2, 0) --player spell icon
text1:SetPoint("left", icon1, "right", 2, 0) --player spell name
4 years ago
3 years ago
arrow:SetPoint("center", f, "center") --separate player spell and targets
4 years ago
3 years ago
icon2:SetPoint("left", f, "center", 10, 0)
text2:SetPoint("left", icon2, "right", 3, 0)
4 years ago
3 years ago
statusbar:SetPoint("topleft", f, "topleft", 0, 0)
statusbar:SetPoint("bottomright", f, "bottomright", 0, 0)
4 years ago
f.icon1 = icon1
f.icon2 = icon2
f.text1 = text1
f.text2 = text2
f.arrow = arrow
f.statusbar = statusbar
f.statusbar_texture = statusbar_texture
f.spark = statusbar_spark
StreamOverlay.battle_lines [#StreamOverlay.battle_lines+1] = f
f.in_use = 1
f:Hide()
StreamOverlay:SetBattleLineStyle (f)
end
function StreamOverlay:RefreshAllBattleLineStyle()
if (StreamOverlay.db.use_square_mode) then
return
end
3 years ago
for i, row in ipairs(StreamOverlay.battle_lines) do
4 years ago
StreamOverlay:SetBattleLineStyle (row, i)
end
3 years ago
--update the dps hps frame text
4 years ago
StreamOverlay:SetFontFace (StreamerOverlayDpsHpsFrameText, SharedMedia:Fetch ("font", StreamOverlay.db.font_face))
3 years ago
StreamOverlay:SetFontColor(StreamerOverlayDpsHpsFrameText, StreamOverlay.db.font_color)
4 years ago
end
function StreamOverlay:RefreshAllBoxesStyle()
if (not StreamOverlay.db.use_square_mode) then
return
end
3 years ago
for i, square in ipairs(StreamOverlay.squares) do
4 years ago
StreamOverlay:SetSquareStyle(square, i)
end
end
function StreamOverlay:SetSquareStyle(square, index)
local options = StreamOverlay.db
square:SetSize(StreamOverlay.db.square_size, StreamOverlay.db.square_size)
end
function StreamOverlay:SetBattleLineStyle (row, index)
local options = StreamOverlay.db
3 years ago
row:SetHeight(StreamOverlay.db.row_height)
4 years ago
if (index) then
local h = (index-1) * StreamOverlay.db.row_spacement * -1
3 years ago
row:SetPoint("topleft", SOF, "topleft", 0, h)
row:SetPoint("topright", SOF, "topright", 0, h)
4 years ago
end
3 years ago
StreamOverlay:SetFontSize(row.text1, StreamOverlay.db.font_size)
StreamOverlay:SetFontSize(row.text2, StreamOverlay.db.font_size)
4 years ago
local font = SharedMedia:Fetch ("font", StreamOverlay.db.font_face)
StreamOverlay:SetFontFace (row.text1, font)
StreamOverlay:SetFontFace (row.text2, font)
3 years ago
StreamOverlay:SetFontColor(row.text1, StreamOverlay.db.font_color)
StreamOverlay:SetFontColor(row.text2, StreamOverlay.db.font_color)
4 years ago
3 years ago
iconSize = StreamOverlay.db.row_height-4
row.icon1:SetSize(iconSize, iconSize)
row.icon2:SetSize(iconSize, iconSize)
4 years ago
local current_texture = row.icon2:GetTexture()
3 years ago
if (current_texture == defaultAttackIcon) then
row.icon2:SetSize(iconSize*0.8, iconSize*0.8)
row.icon2:SetPoint("left", row, "center", 8, 0)
row.text2:SetPoint("left", row.icon2, "right", 5, 0)
4 years ago
else
3 years ago
row.icon2:SetPoint("left", row, "center", 8, 0)
row.text2:SetPoint("left", row.icon2, "right", 5, 0)
4 years ago
end
if (row.text2:GetText() == "") then
row.icon2:Hide()
row.arrow:Hide()
else
row.icon2:Show()
row.arrow:Show()
end
3 years ago
local texture = SharedMedia:Fetch("statusbar", StreamOverlay.db.row_texture)
row.statusbar_texture:SetTexture(texture)
row.statusbar_texture:SetVertexColor(unpack(StreamOverlay.db.row_color))
row.arrow:SetTexture(StreamOverlay.db.arrow_texture)
row.arrow:SetSize(StreamOverlay.db.arrow_size, StreamOverlay.db.arrow_size)
row.arrow:SetVertexColor(unpack(StreamOverlay.db.arrow_color))
row.arrow:SetPoint("center", row, "center", StreamOverlay.db.arrow_anchor_x, StreamOverlay.db.arrow_anchor_y)
4 years ago
end
3 years ago
function StreamOverlay:RefreshInUse(line)
4 years ago
local now = GetTime()
3 years ago
local i = -1 --was nil before from _G["i"]
4 years ago
if (line) then
local line_in_use = line.in_use or 1
local content_in_use = StreamOverlay.battle_content [i] and StreamOverlay.battle_content [i].CastStart or 1
3 years ago
if (max(line_in_use, content_in_use) + 60 < now) then
4 years ago
fader (nil, line, "in")
else
fader (nil, line, "out")
end
else
if (not StreamOverlay.db.use_square_mode) then
for i = 1, #StreamOverlay.battle_lines do
local line = StreamOverlay.battle_lines[i]
local line_in_use = line.in_use or 1
local content_in_use = StreamOverlay.battle_content [i] and StreamOverlay.battle_content [i].CastStart or 1
3 years ago
if (max(line_in_use, content_in_use) + 60 < now) then
4 years ago
fader (nil, StreamOverlay.battle_lines [i], "in")
else
fader (nil, StreamOverlay.battle_lines [i], "out")
end
end
else
for i = 1, #StreamOverlay.squares do
local line = StreamOverlay.squares[i]
local line_in_use = line.in_use or 1
local content_in_use = StreamOverlay.battle_content[i] and StreamOverlay.battle_content[i].CastStart or 1
3 years ago
if (max(line_in_use, content_in_use) + 60 < now) then
4 years ago
fader (nil, StreamOverlay.squares[i], "in")
else
fader (nil, StreamOverlay.squares[i], "out")
end
end
end
end
end
C_Timer.NewTicker(60, StreamOverlay.RefreshInUse)
3 years ago
4 years ago
function StreamOverlay:Refresh()
if (StreamOverlay.db.use_square_mode) then
--hide any line created
for i = 1, #StreamOverlay.battle_lines do
StreamOverlay.battle_lines[i]:Hide()
end
3 years ago
local amountOfSquares = StreamOverlay.db.square_amount
StreamOverlay.total_lines = amountOfSquares
4 years ago
3 years ago
if (amountOfSquares > #StreamOverlay.squares) then
for i = #StreamOverlay.squares + 1, amountOfSquares do
4 years ago
StreamOverlay:CreateSquareBox()
end
3 years ago
for i = 1, amountOfSquares do
4 years ago
StreamOverlay.squares[i]:Show()
end
3 years ago
elseif (#StreamOverlay.squares > amountOfSquares) then
for i = #StreamOverlay.squares, amountOfSquares + 1, -1 do
StreamOverlay.squares[i]:Hide()
4 years ago
end
3 years ago
for i = 1, amountOfSquares do
StreamOverlay.squares[i]:Show()
4 years ago
end
else
3 years ago
for i = 1, amountOfSquares do
4 years ago
StreamOverlay.squares[i]:Show()
end
end
StreamOverlay:UpdateSquares()
StreamOverlay:RefreshInUse()
else --showing lines
--hide any square created
for i = 1, #StreamOverlay.squares do
StreamOverlay.squares[i]:Hide()
end
3 years ago
--how many lines fit in the frame
local amountOfLines = math.floor(SOF:GetHeight() / StreamOverlay.db.row_spacement)
4 years ago
3 years ago
if (amountOfLines < 0) then
amountOfLines = 0
4 years ago
end
3 years ago
StreamOverlay.total_lines = amountOfLines
if (amountOfLines == 0) then
4 years ago
for i = 1, #StreamOverlay.battle_lines do
3 years ago
StreamOverlay.battle_lines[i]:Hide()
4 years ago
end
return
end
3 years ago
-- need create more lines
if (amountOfLines > #StreamOverlay.battle_lines) then
for i = #StreamOverlay.battle_lines + 1, amountOfLines do
4 years ago
StreamOverlay:CreateBattleLine()
end
3 years ago
for i = 1, amountOfLines do
4 years ago
StreamOverlay.battle_lines[i]:Show()
end
3 years ago
elseif (#StreamOverlay.battle_lines > amountOfLines) then
for i = #StreamOverlay.battle_lines, amountOfLines + 1, -1 do
StreamOverlay.battle_lines[i]:Hide()
4 years ago
end
3 years ago
for i = 1, amountOfLines do
StreamOverlay.battle_lines[i]:Show()
4 years ago
end
else
3 years ago
for i = 1, amountOfLines do
StreamOverlay.battle_lines[i]:Show()
4 years ago
end
end
local width = SOF:GetWidth() / 2
3 years ago
text1Size, text2Size = width - 28, width - 30
4 years ago
StreamOverlay:UpdateLines()
StreamOverlay:RefreshInUse()
end
end
3 years ago
function StreamOverlay:SetBackgroundColor(r, g, b, a)
4 years ago
if (not r) then
3 years ago
r, g, b, a = unpack(StreamOverlay.db.main_frame_color)
4 years ago
else
local c = StreamOverlay.db.main_frame_color
c[1], c[2], c[3], c[4] = r, g, b, a
end
3 years ago
SOF:SetBackdropColor(r, g, b, a)
4 years ago
end
3 years ago
function StreamOverlay:ApplyBackgroundColor(r, g, b, a)
SOF:SetBackdropColor(r, g, b, a)
end
end
4 years ago
local COLOR_HARMFUL = {.9, .5, .5, .4}
local COLOR_HELPFUL = {.1, .9, .1, .4}
local COLOR_ATTKCOOLDOWN = {1, 1, 0, .6}
local COLOR_DEFECOOLDOWN = {1, 1, 1, .6}
local COLOR_BORDER_DEFAULT = {0, 0, 0, 0}
local COLOR_BORDER_ABSORB = {1, 1, 0, 0.5}
local HarmfulSpellsTable = StreamOverlay.HarmfulSpells
local HelpfulSpellsTable = StreamOverlay.HelpfulSpells
local AttackCooldownSpellsTable = StreamOverlay.AttackCooldownSpells
local ClassSpellsTable = StreamOverlay.MiscClassSpells
local CooldownTable = StreamOverlay.DefensiveCooldownSpells
local ClassColorsTable = StreamOverlay.class_colors
local ClassSpellList = StreamOverlay.ClassSpellList
local AbsorbSpellsTable = StreamOverlay.AbsorbSpells
3 years ago
local ignoredSpells = {
4 years ago
[49821] = true, --mind sear ticks
[121557] = true, --angelic feather walkon
}
3 years ago
--spell types:
-- 1 attack cooldown
-- 2 personal defensive cooldown
-- 3 targetted defensive cooldown
-- 4 raid defensive cooldown
-- 5 personal utility cooldown
-- 6 interrupt
local spellTypeColor = {
[1] = COLOR_ATTKCOOLDOWN,
[2] = COLOR_DEFECOOLDOWN,
[3] = COLOR_DEFECOOLDOWN,
[4] = COLOR_DEFECOOLDOWN,
}
function StreamOverlay:GetSpellInformation(spellId)
local _, _, icon = GetSpellInfo(spellId)
4 years ago
local backgroundcolor
3 years ago
local spellInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId]
if (spellInfo) then
backgroundcolor = spellTypeColor[spellInfo.type]
end
if (HarmfulSpellsTable[spellId]) then
4 years ago
backgroundcolor = COLOR_HARMFUL
3 years ago
elseif (HelpfulSpellsTable[spellId]) then
4 years ago
backgroundcolor = COLOR_HELPFUL
3 years ago
elseif (AttackCooldownSpellsTable[spellId]) then
4 years ago
backgroundcolor = COLOR_ATTKCOOLDOWN
3 years ago
elseif (CooldownTable[spellId]) then
4 years ago
backgroundcolor = COLOR_DEFECOOLDOWN
3 years ago
elseif (ClassSpellsTable[spellId]) then
local class = ClassSpellList [spellId]
4 years ago
backgroundcolor = ClassColorsTable [class]
3 years ago
4 years ago
else
3 years ago
if (not backgroundcolor) then
backgroundcolor = COLOR_HARMFUL
end
4 years ago
end
3 years ago
4 years ago
local bordercolor
3 years ago
if (AbsorbSpellsTable[spellId]) then
4 years ago
bordercolor = COLOR_BORDER_ABSORB
else
bordercolor = COLOR_BORDER_DEFAULT
end
return icon, backgroundcolor, bordercolor
end
local RoleIcons = "Interface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES"
local RoleIconsCoord = {
["TANK"] = {0, 0.28125, 0.328125, 0.625},
["HEALER"] = {0.3125, 0.59375, 0, 0.296875},
["DAMAGER"] = {0.3125, 0.59375, 0.328125, 0.625},
["NONE"] = {0.3125, 0.59375, 0.328125, 0.625}
}
local DefaultCoords = {0, 1, 0, 1}
local DefaultColor = {r=1, g=1, b=1}
local PetCoords = {0.25, 0.49609375, 0.75, 1}
3 years ago
local parse_target_name = function(target)
return StreamOverlay:GetOnlyName(target)
4 years ago
end
3 years ago
local parse_target_icon = function(targetObject, target)
4 years ago
local icon2, icon2coords, pclass
if (targetObject) then
local role = targetObject.role
pclass = targetObject.classe
if (role) then
icon2 = RoleIcons
icon2coords = RoleIconsCoord [role]
else
local class = targetObject.classe
if (class == "PET") then
icon2 = [[Interface\AddOns\Details\images\classes_small_alpha]]
icon2coords = PetCoords
elseif (class and RAID_CLASS_COLORS [class]) then
if (targetObject.spec) then
icon2 = [[Interface\AddOns\Details\images\spec_icons_normal_alpha]]
icon2coords = Details.class_specs_coords [targetObject.spec]
else
local spec_from_cache = Details.cached_specs [targetObject.serial]
if (spec_from_cache) then
icon2 = [[Interface\AddOns\Details\images\spec_icons_normal_alpha]]
icon2coords = Details.class_specs_coords [spec_from_cache]
else
icon2 = [[Interface\AddOns\Details\images\classes_small_alpha]]
icon2coords = Details.class_coords [class]
end
end
else
3 years ago
local _, class = UnitClass(targetObject.nome)
4 years ago
if (class) then
icon2 = [[Interface\AddOns\Details\images\classes_small_alpha]]
icon2coords = Details.class_coords [class]
else
icon2 = ""
icon2coords = DefaultCoords
end
end
end
else
3 years ago
local _, class = UnitClass(target)
4 years ago
if (class) then
icon2 = [[Interface\AddOns\Details\images\classes_small_alpha]]
icon2coords = Details.class_coords [class]
pclass = class
else
icon2 = ""
icon2coords = DefaultCoords
end
end
if (icon2 == "") then
icon2 = [[Interface\CURSOR\Attack]]
icon2 = [[Interface\CURSOR\UnableAttack]]
icon2coords = {1, 0, 0, 1}
end
return icon2, icon2coords, pclass
end
3 years ago
local parse_target_color = function(class)
4 years ago
local color2 = RAID_CLASS_COLORS [class]
return color2
end
function StreamOverlay:CastStart (castGUID)
local spellid = CastsTable [castGUID].SpellId
local target = CastsTable [castGUID].Target
local caststart = CastsTable [castGUID].CastStart
local startTime = CastsTable [castGUID].CastTimeStart
local endTime = CastsTable [castGUID].CastTimeEnd
3 years ago
if (ignoredSpells [spellid]) then
4 years ago
return
end
local icon, backgroundcolor, bordercolor = StreamOverlay:GetSpellInformation (spellid)
3 years ago
local spellname, _, spellicon = GetSpellInfo(spellid)
4 years ago
3 years ago
local targetObject = Details:GetActor("current", 1, target) or Details:GetActor("current", 2, target)
4 years ago
local icon2, icon2coords, class = parse_target_icon (targetObject, target)
local color2
if (icon2 == RoleIcons) then
color2 = parse_target_color (class)
if (not color2) then
color2 = DefaultColor
end
else
color2 = DefaultColor
end
target = parse_target_name (target)
StreamOverlay:NewText (spellicon, spellname, color1, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castGUID, caststart, startTime, endTime)
end
function StreamOverlay:CastFinished (castid)
local spellid = CastsTable [castid].SpellId
local target = CastsTable [castid].Target
local caststart = CastsTable [castid].CastStart
local hascasttime = CastsTable [castid].HasCastTime
3 years ago
if (ignoredSpells [spellid]) then
4 years ago
return
end
if (hascasttime) then
--just finished a casted cast
CastsTable [castid].Success = true
else
--just casted a instant spell
local icon, backgroundcolor, bordercolor = StreamOverlay:GetSpellInformation (spellid)
3 years ago
local spellname, _, spellicon = GetSpellInfo(spellid)
4 years ago
3 years ago
local targetObject = Details:GetActor("current", 1, target) or Details:GetActor("current", 2, target)
4 years ago
local icon2, icon2coords, class = parse_target_icon (targetObject, target)
local color2
if (icon2 == RoleIcons) then
color2 = parse_target_color (class)
if (not color2) then
color2 = DefaultColor
end
else
color2 = DefaultColor
end
target = parse_target_name (target)
StreamOverlay:NewText (spellicon, spellname, nil, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castid, caststart, GetTime(), GetTime()+1.2)
end
end
3 years ago
eventFrame.track_spell_cast = function()
4 years ago
if (not StreamOverlay.db.use_square_mode) then
for i = 1, #StreamOverlay.battle_content do
local content = StreamOverlay.battle_content [i]
local line = StreamOverlay.battle_lines [i]
local castinfo = CastsTable [content.CastID]
if (not castinfo.Done) then
3 years ago
--is being casted?
4 years ago
if (castinfo.HasCastTime) then
if (castinfo.Success) then
3 years ago
--okey it's done
4 years ago
castinfo.Done = true
castinfo.Percent = 100
3 years ago
line.statusbar:SetValue(100)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0)
4 years ago
--line.spark:Hide()
elseif (castinfo.Interrupted) then
3 years ago
--has been interrupted
4 years ago
castinfo.Done = true
3 years ago
line.spark:SetVertexColor(1, 0.7, 0)
4 years ago
elseif (castinfo.IsChanneled) then
3 years ago
--casting a channeled spell
4 years ago
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo ("player")
if (name) then
startTime = startTime / 1000
endTime = endTime / 1000
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
3 years ago
percent = math.abs(percent - 100)
4 years ago
castinfo.Percent = percent
3 years ago
line.statusbar:SetValue(percent)
4 years ago
if (StreamOverlay.db.use_spark) then
line.spark:Show()
else
line.spark:Hide()
end
3 years ago
line.spark:SetVertexColor(1, 1, 1, 1)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
4 years ago
end
else
3 years ago
--still casting
local spell, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo("player")
4 years ago
if (spell) then
startTime = startTime / 1000
endTime = endTime / 1000
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
castinfo.Percent = percent
3 years ago
line.statusbar:SetValue(percent)
4 years ago
if (StreamOverlay.db.use_spark) then
line.spark:Show()
else
line.spark:Hide()
end
3 years ago
line.spark:SetVertexColor(1, 1, 1, 1)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
4 years ago
end
end
else
3 years ago
--it's instant cast
4 years ago
if (castinfo.CastStart+1.2 < GetTime()) then
castinfo.Done = true
castinfo.Percent = 100
3 years ago
line.statusbar:SetValue(100)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0)
4 years ago
--line.spark:Hide()
else
local startTime = castinfo.CastStart
local endTime = (castinfo.CastStart + 1.2)
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
castinfo.Percent = percent
3 years ago
line.statusbar:SetValue(percent)
4 years ago
if (StreamOverlay.db.use_spark) then
line.spark:Show()
else
line.spark:Hide()
end
3 years ago
line.spark:SetVertexColor(1, 1, 1, 1)
line.spark:SetPoint("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0)
4 years ago
end
end
line.in_use = GetTime()
end
end
else
for i = 1, #StreamOverlay.battle_content do
local content = StreamOverlay.battle_content[i]
local line = StreamOverlay.squares[i]
local castinfo = CastsTable[content.CastID]
3 years ago
StreamOverlay:ApplyBackgroundColor(0, 0, 0, 0)
4 years ago
if (not castinfo.Done and line) then
3 years ago
--is being casted?
4 years ago
if (castinfo.HasCastTime) then
if (castinfo.Success) then
3 years ago
--okey it's done
4 years ago
castinfo.Done = true
castinfo.Percent = 100
StreamOverlay:UpdateCooldownFrame(line, false)
elseif (castinfo.Interrupted) then
3 years ago
--has been interrupted
4 years ago
castinfo.Done = true
local totalTime = castinfo.CastTimeEnd - castinfo.CastTimeStart
local pct = castinfo.CastTimeEnd - GetTime()
castinfo.InterruptedPct = pct / totalTime
elseif (castinfo.IsChanneled) then
3 years ago
--casting a channeled spell
4 years ago
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo ("player")
if (name) then
startTime = startTime / 1000
endTime = endTime / 1000
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
3 years ago
percent = math.abs(percent - 100)
4 years ago
castinfo.Percent = percent
StreamOverlay:UpdateCooldownFrame(line, true, startTime, endTime, castinfo)
end
else
3 years ago
--still casting
4 years ago
local spell, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo ("player")
if (spell) then
startTime = startTime / 1000
endTime = endTime / 1000
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
castinfo.Percent = percent
StreamOverlay:UpdateCooldownFrame(line, true, startTime, endTime, castinfo)
end
end
else
3 years ago
--it's instant cast
4 years ago
if (castinfo.CastStart+1.2 < GetTime()) then
castinfo.Done = true
castinfo.Percent = 100
StreamOverlay:UpdateCooldownFrame(line, false)
else
local startTime = castinfo.CastStart
local endTime = (castinfo.CastStart + 1.2)
local diff = endTime - startTime
local current = GetTime() - startTime
local percent = current / diff * 100
castinfo.Percent = percent
StreamOverlay:UpdateCooldownFrame(line, true, startTime, endTime, castinfo)
end
end
line.in_use = GetTime()
elseif (castinfo.Done and line) then
if (castinfo.Interrupted and castinfo.InterruptedPct) then
StreamOverlay:UpdateCooldownFrame(line, true, castinfo.CastTimeStart, castinfo.InterruptedTime, castinfo)
end
end
end
end
end
3 years ago
function eventFrame:RegisterMyEvents()
eventFrame:RegisterEvent ("UNIT_SPELLCAST_START")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_SENT")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_SUCCEEDED")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTED")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_FAILED_QUIET")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_FAILED")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_DELAYED")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_START")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_STOP")
if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then
eventFrame:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE")
eventFrame:RegisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
4 years ago
end
end
3 years ago
function eventFrame:UnregisterMyEvents()
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_START")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_SENT")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_SUCCEEDED")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTED")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_FAILED_QUIET")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_FAILED")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_DELAYED")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_START")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_STOP")
if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE")
eventFrame:UnregisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
4 years ago
end
end
local lastspell, lastcastid, lastchannelid, ischanneling, lastspellID
local channelspells = {}
local lastChannelSpell = ""
local APM = 0
local ACTIONS = 0
local ACTIONS_EVENT_TIME = {}
3 years ago
local AMP_Tick = C_Timer.NewTicker(1, function()
4 years ago
APM = ACTIONS * 60
ACTIONS = 0
end)
3 years ago
local APM_FRAME = CreateFrame("frame", "DetailsAPMFrame", UIParent, "BackdropTemplate")
4 years ago
APM_FRAME:RegisterEvent ("PLAYER_STARTED_MOVING")
APM_FRAME:RegisterEvent ("PLAYER_STOPPED_MOVING")
3 years ago
APM_FRAME:SetScript("OnEvent", function()
4 years ago
ACTIONS = ACTIONS + 1
end)
3 years ago
eventFrame:SetScript("OnEvent", function(self, event, ...)
4 years ago
if (event ~= "UNIT_SPELLCAST_SENT" and event ~= "UNIT_SPELLCAST_SUCCEEDED" and ACTIONS_EVENT_TIME [event] ~= GetTime()) then
ACTIONS = ACTIONS + 1
ACTIONS_EVENT_TIME [event] = GetTime()
end
if (event == "UNIT_SPELLCAST_SENT") then
local unitID, target, castGUID, spellID = ...
--local unitID, spell, rank, target, id = ...
3 years ago
local spell = GetSpellInfo(spellID)
4 years ago
if (unitID == "player") then
CastsTable [castGUID] = {Target = target or "", Id = castGUID, CastStart = GetTime()}
lastChannelSpell = castGUID
lastspell = spell
lastspellID = spellID
lastcastid = castGUID
end
elseif (event == "UNIT_SPELLCAST_START") then
--spell, rank, id,
local unitID, castGUID, spellID = ...
if (unitID == "player" and CastsTable [castGUID]) then
CastsTable [castGUID].SpellId = spellID
CastsTable [castGUID].HasCastTime = true
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo("player")
CastsTable [castGUID].CastTimeStart = startTime / 1000
CastsTable [castGUID].CastTimeEnd = endTime / 1000
StreamOverlay:CastStart(castGUID)
end
elseif (event == "UNIT_SPELLCAST_INTERRUPTED") then
--local unitID, spell, rank, id, spellID = ...
local unitID, castGUID, spellID = ...
if (unitID == "player" and CastsTable [castGUID]) then
CastsTable [castGUID].Interrupted = true
CastsTable [castGUID].InterruptedTime = GetTime()
end
3 years ago
--channels isn't passing the CastID / cast id for channels is always Zero.
4 years ago
elseif (event == "UNIT_SPELLCAST_CHANNEL_STOP") then
--local unitID, spell, rank, id, spellID = ...
local unitID, castGUID, spellID = ...
if (unitID == "player") then
castGUID = lastchannelid
if (not CastsTable [castGUID]) then
castGUID = lastChannelSpell
if (not castGUID or not CastsTable [castGUID]) then
return
end
end
CastsTable [castGUID].Interrupted = true
CastsTable [castGUID].InterruptedTime = GetTime()
ischanneling = false
lastchannelid = nil
end
elseif (event == "UNIT_SPELLCAST_CHANNEL_START") then
local unitID, castGUID, spellID = ...
if (unitID == "player" and (CastsTable [castGUID] or spellID == lastspellID)) then
if (castGUID == "" or not castGUID) then
castGUID = lastcastid
end
if (ischanneling) then
3 years ago
--channel updated
4 years ago
CastsTable [lastchannelid].Interrupted = true
CastsTable [lastchannelid].InterruptedTime = GetTime()
end
if (not CastsTable [castGUID]) then
castGUID = lastChannelSpell
end
CastsTable [castGUID].HasCastTime = true
CastsTable [castGUID].IsChanneled = true
CastsTable [castGUID].SpellId = spellID
lastchannelid = castGUID
ischanneling = true
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellId = UnitChannelInfo("player")
CastsTable [castGUID].CastTimeStart = startTime / 1000
CastsTable [castGUID].CastTimeEnd = endTime / 1000
local spell = GetSpellInfo(spellID)
channelspells[spell] = true
StreamOverlay:CastStart(castGUID)
end
elseif (event == "UNIT_SPELLCAST_SUCCEEDED") then
--local unitID, spell, rank, id, spellID = ...
local unitID, castGUID, spellID = ...
3 years ago
local spell = GetSpellInfo(spellID)
4 years ago
if (unitID == "player" and CastsTable[castGUID] and not channelspells [spell]) then
if (CastsTable[castGUID].HasCastTime and not CastsTable[castGUID].IsChanneled) then
3 years ago
--a cast (non channeled) just successful finished
4 years ago
CastsTable [castGUID].Success = true
StreamOverlay:CastFinished (castGUID)
elseif (not CastsTable[castGUID].HasCastTime) then
3 years ago
--instant cast finished
4 years ago
CastsTable [castGUID].SpellId = spellID
CastsTable [castGUID].Success = true
StreamOverlay:CastFinished (castGUID)
end
end
end
end)
3 years ago
local format_time = function(v) return "-" .. format("%.2f", v) end
4 years ago
--when the player die, show the events before the death
function StreamOverlay.OnDeath (_, token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, death_table, last_cooldown, death_at_combattime, max_health)
3 years ago
if (alvo_serial ~= UnitGUID("player")) then
4 years ago
return
end
StreamOverlay:ClearAll()
for i = 1, #death_table do
local ev = death_table [i]
3 years ago
if (ev and type(ev) == "table" and ev[1] and type(ev[1]) == "boolean") then
--it's a damage
4 years ago
local spellid = ev[2]
local amount = ev[3]
local attime = ev[4]
local health = ev[5]
local source = ev[6]
local absorbed = ev[7]
--get the actor from details
3 years ago
local sourceObject = Details:GetActor("current", 1, source)
4 years ago
local classIcon, l, r, t, b
if (sourceObject) then
classIcon, l, r, t, b = StreamOverlay:GetClassIcon (sourceObject.classe)
else
3 years ago
classIcon, l, r, t, b = defaultAttackIcon, 0, 1, 0, 1
4 years ago
end
--spellname
local spellname, _, spellicon = StreamOverlay.getspellinfo (spellid)
3 years ago
source = StreamOverlay:GetOnlyName(source)
4 years ago
local CastInfoIndex = i * -1
local percent = health / max_health * 100
percent = math.min (percent, 100)
--HasCastTime has to be true, this can't be considered a instant cast
--Done = won't be touch during cast bar updates
--Percent is used on the bar text updates
--Interrupted / Death is irrelevant at this point because the bar is flagged as Done
CastsTable [CastInfoIndex] = {Target = spellname, Id = CastInfoIndex, CastStart = GetTime(), HasCastTime = true, Interrupted = true, Done = true, Percent = percent, Death = true}
local at = format_time (time - attime)
local damage_color = "|cFFFFFFFF"
if (amount > 100000) then
damage_color = "|cFFFF3300"
elseif (amount > 75000) then
damage_color = "|cFFFF6600"
elseif (amount > 50000) then
damage_color = "|cFFFF9900"
elseif (amount > 25000) then
damage_color = "|cFFFFAA00"
elseif (amount > 10000) then
damage_color = "|cFFFFFF66"
elseif (amount > 5000) then
damage_color = "|cFFFFFFAA"
end
--adds the text to the line
StreamOverlay:NewText (spellicon, at .. " | " .. damage_color .. StreamOverlay:ToK2 (amount) .. "|r (" .. spellname .. ")", {1, 1, 1, 1}, classIcon, {l, r, t, b}, source, {r=1, g=1, b=1}, {1, 1, 1, 0.6}, {0, 0, 0}, CastInfoIndex, GetTime())
-- :NewText (icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, ID, CastStart)
end
end
StreamOverlay.ShowingDeath = true
end
3 years ago
--passes the new lock state
4 years ago
--the window is click throught when locked
function StreamOverlay:SetLocked (state)
if (state == nil) then
state = StreamOverlay.db.main_frame_locked
end
if (state) then
3 years ago
--is locked
4 years ago
StreamOverlay.db.main_frame_locked = true
DetailsStreamerTitlebar:Hide()
DetailsStreamerLeftResizer:Hide()
DetailsStreamerRightResizer:Hide()
3 years ago
SOF:EnableMouse(false)
4 years ago
else
3 years ago
--not locked
4 years ago
StreamOverlay.db.main_frame_locked = false
DetailsStreamerTitlebar:Show()
DetailsStreamerLeftResizer:Show()
DetailsStreamerRightResizer:Show()
3 years ago
SOF:EnableMouse(true)
4 years ago
end
StreamOverlay:UpdateDpsHpsFrameConfig()
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------
--on screen hps dps
3 years ago
local screen_frame = CreateFrame("frame", "StreamerOverlayDpsHpsFrame", UIParent, "BackdropTemplate")
screen_frame:SetSize(70, 20)
screen_frame:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
screen_frame:SetBackdropColor(.1, .1, .1, .9)
screen_frame:SetMovable(true)
4 years ago
screen_frame:Hide()
3 years ago
screen_frame:SetPoint("center", UIParent, "center")
screen_frame:SetScript("OnMouseDown", function(self)
4 years ago
if (not screen_frame.moving and not StreamOverlay.db.main_frame_locked) then
screen_frame:StartMoving()
screen_frame.moving = true
screen_frame.movingAt = GetTime()
end
end)
3 years ago
screen_frame:SetScript("OnMouseUp", function(self)
4 years ago
if (screen_frame.movingAt) then
if (screen_frame.moving) then
screen_frame.moving = false
screen_frame:StopMovingOrSizing()
StreamOverlay:SaveWindowSizeAnLocation()
end
if (screen_frame.movingAt+0.200 < GetTime()) then
return
end
screen_frame.movingAt = nil
StreamOverlay.OpenOptionsPanel()
end
end)
3 years ago
screen_frame:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self)
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
GameTooltip:AddLine("|cFFFF7700Left Click|r: Open Options\n|cFFFF7700Slash Command|r: /streamer")
4 years ago
GameTooltip:Show()
end)
3 years ago
screen_frame:SetScript("OnLeave", function()
4 years ago
GameTooltip:Hide()
end)
3 years ago
local screen_frame_text = screen_frame:CreateFontString("StreamerOverlayDpsHpsFrameText", "overlay", "GameFontNormal")
screen_frame_text:SetPoint("center", screen_frame, "center")
4 years ago
screen_frame.text = screen_frame_text
local screen_frame_attribute = 1
local format_function
function StreamOverlay:UpdateDpsHpsFrameConfig (PluginDisabled)
if (PluginDisabled) then
if (StreamOverlay.DpsHpsTick) then
StreamOverlay.DpsHpsTick:Cancel()
StreamOverlay.DpsHpsTick = nil
end
screen_frame:Hide()
return
end
local db = StreamOverlay.db.per_second
3 years ago
StreamOverlay:SetFontSize(screen_frame.text, db.size)
4 years ago
StreamOverlay:SetFontOutline (screen_frame.text, db.font_shadow)
3 years ago
screen_frame:SetScale(db.scale)
4 years ago
screen_frame_attribute = db.attribute_type
format_function = Details:GetCurrentToKFunction()
if (StreamOverlay.db.main_frame_locked) then
3 years ago
screen_frame:SetBackdrop(nil)
screen_frame:EnableMouse(false)
4 years ago
else
3 years ago
screen_frame:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
screen_frame:SetBackdropColor(.1, .1, .1, .9)
screen_frame:EnableMouse(true)
4 years ago
end
if (db.enabled) then
screen_frame:Show()
if (StreamOverlay.DpsHpsTick) then
StreamOverlay.DpsHpsTick:Cancel()
StreamOverlay.DpsHpsTick = nil
end
3 years ago
StreamOverlay.DpsHpsTick = C_Timer.NewTicker(db.update_speed, StreamOverlay.UpdateDpsHpsFrame)
4 years ago
else
screen_frame:Hide()
if (StreamOverlay.DpsHpsTick) then
StreamOverlay.DpsHpsTick:Cancel()
StreamOverlay.DpsHpsTick = nil
end
end
3 years ago
--update the dps hps frame text
4 years ago
StreamOverlay:SetFontFace (StreamerOverlayDpsHpsFrameText, SharedMedia:Fetch ("font", StreamOverlay.db.font_face))
3 years ago
StreamOverlay:SetFontColor(StreamerOverlayDpsHpsFrameText, StreamOverlay.db.font_color)
4 years ago
end
function StreamOverlay:UpdateDpsHpsFrame()
3 years ago
--low level actor parsing - we can just use Details:GetActor(), but is faster without having to call functions
4 years ago
local container = _detalhes.tabela_vigente [screen_frame_attribute]
3 years ago
local actor = container._ActorTable [container._NameIndexTable [playerName]]
4 years ago
if (actor) then
3 years ago
screen_frame_text:SetText(format_function (_, actor.total / _detalhes.tabela_vigente:GetCombatTime()))
4 years ago
else
if (StreamOverlay.db.per_second.attribute_type == 1) then
3 years ago
screen_frame_text:SetText("DPS")
4 years ago
else
3 years ago
screen_frame_text:SetText("HPS")
4 years ago
end
end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
function StreamOverlay.OpenOptionsPanel (fromOptionsPanel)
4 years ago
if (not StreamOverlayOptionsPanel) then
3 years ago
local detailsFramework = Details:GetFramework()
local options_text_template = detailsFramework:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = detailsFramework:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = detailsFramework:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = detailsFramework:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")
local optionsFrame = StreamOverlay:CreatePluginOptionsFrame("StreamOverlayOptionsPanel", "Details! Streamer: Action Tracker", 1)
optionsFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
optionsFrame:SetBackdropColor(0, 0, 0, 0.5)
optionsFrame:SetBackdropBorderColor(0, 0, 0, 1)
optionsFrame:SetWidth(535)
optionsFrame:SetHeight(655)
if (StreamOverlayWelcomeWindow) then
if (StreamOverlayWelcomeWindow:IsShown()) then
StreamOverlayWelcomeWindow:Hide()
end
end
local statusBar = DetailsFramework:CreateStatusBar(optionsFrame)
statusBar.text = statusBar:CreateFontString(nil, "overlay", "GameFontNormal")
statusBar.text:SetPoint("left", statusBar, "left", 5, 0)
statusBar.text:SetText("By Terciob | From Details! Damage Meter Streamer Plugin")
DetailsFramework:SetFontSize(statusBar.text, 11)
DetailsFramework:SetFontColor(statusBar.text, "gray")
StreamOverlayOptionsPanelBackgroundBigDog:ClearAllPoints()
StreamOverlayOptionsPanelBackgroundBigDog:SetPoint("bottomright", statusBar, "topright", 0, 0)
local selectModeFrame = CreateFrame("frame", nil, optionsFrame, "BackdropTemplate")
DetailsFramework:ApplyStandardBackdrop(selectModeFrame)
selectModeFrame:SetPoint("topleft", optionsFrame, "topleft", 5, -95)
selectModeFrame:SetSize(optionsFrame:GetWidth() - 10, 120)
local selectedFrame = CreateFrame("frame", nil, selectModeFrame, "BackdropTemplate")
selectedFrame:SetSize(260, 81)
selectedFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 3})
selectedFrame:SetBackdropBorderColor(1, 1, 0, 0.75)
local selectClassicMode = function()
StreamOverlay.db.use_square_mode = false
StreamOverlay:Refresh()
selectedFrame:SetPoint("topleft", selectModeFrame.classicModeSelectButton.widget, "topleft", -3, 3)
selectedFrame:SetSize(238, 84)
end
local selectSquareMode = function()
StreamOverlay.db.use_square_mode = true
StreamOverlay:Refresh()
selectedFrame:SetPoint("topleft", selectModeFrame.squareModeSelectButton.widget, "topleft", -6, 3)
selectedFrame:SetSize(240, 84)
end
local selectModeLabel = DetailsFramework:CreateLabel(selectModeFrame, "Select Mode (test casting some spells)", 14, "orange")
selectModeLabel:SetPoint("top", optionsFrame, "top", 0, -100)
local classicModeSelectButton = DetailsFramework:CreateButton(selectModeFrame, selectClassicMode, 256, 77, "")
classicModeSelectButton:SetPoint("topleft", optionsFrame, "topleft", 15, -120)
local classicModeTexture = classicModeSelectButton:CreateTexture(nil, "overlay")
classicModeTexture:SetTexture([[Interface\Addons\Details_Streamer\images\tracker_full]])
classicModeTexture:SetAllPoints()
classicModeTexture:SetTexCoord(0, 1, .15, .75)
local squareModeSelectButton = DetailsFramework:CreateButton(selectModeFrame, selectSquareMode, 200, 77, "")
squareModeSelectButton:SetPoint("left", classicModeSelectButton, "right", 0, 0)
local squareModeTexture = squareModeSelectButton:CreateTexture(nil, "overlay")
squareModeTexture:SetTexture([[Interface\Addons\Details_Streamer\images\tracker_square]])
squareModeTexture:SetPoint("center", 25, -10)
selectModeFrame.classicModeSelectButton = classicModeSelectButton
selectModeFrame.squareModeSelectButton = squareModeSelectButton
if (StreamOverlay.db.use_square_mode) then
selectSquareMode()
else
selectClassicMode()
end
4 years ago
-- select texture
3 years ago
local setRowTexture = function(_, _, value)
4 years ago
StreamOverlay.db.row_texture = value
StreamOverlay:RefreshAllBattleLineStyle()
end
3 years ago
local textures = SharedMedia:HashTable("statusbar")
4 years ago
local textureTable = {}
3 years ago
for name, texturePath in pairs(textures) do
textureTable[#textureTable+1] = {value = name, label = name, statusbar = texturePath, onclick = setRowTexture}
4 years ago
end
3 years ago
table.sort(textureTable, function(t1, t2) return t1.label < t2.label end)
--select font
local setFontFace = function(_, _, value)
4 years ago
StreamOverlay.db.font_face = value
StreamOverlay:RefreshAllBattleLineStyle()
end
3 years ago
local fontObjects = SharedMedia:HashTable("font")
4 years ago
local fontTable = {}
3 years ago
for name, fontPath in pairs(fontObjects) do
fontTable[#fontTable+1] = {value = name, label = name, onclick = setFontFace, font = fontPath, descfont = name}
4 years ago
end
3 years ago
table.sort(fontTable, function(t1, t2) return t1.label < t2.label end)
4 years ago
-- select arrow
local arrows = {
[[Interface\CHATFRAME\ChatFrameExpandArrow]],
[[Interface\CHATFRAME\UI-InChatFriendsArrow]],
[[Interface\MONEYFRAME\Arrow-Right-Disabled]],
[[Interface\OPTIONSFRAME\VoiceChat-Play]],
[[Interface\MINIMAP\TrapInactive_HammerGold]],
[[Interface\MINIMAP\Vehicle-HammerGold-1]],
[[Interface\GossipFrame\BattleMasterGossipIcon]],
[[Interface\GROUPFRAME\UI-GROUP-MAINASSISTICON]],
[[Interface\GROUPFRAME\UI-GROUP-MAINTANKICON]],
[[Interface\HELPFRAME\HelpIcon-ItemRestoration]],
[[Interface\PetBattles\DeadPetIcon]],
[[Interface\BattlefieldFrame\Battleground-Alliance]],
[[Interface\BattlefieldFrame\Battleground-Horde]],
[[Interface\Buttons\UI-SliderBar-Button-Vertical]],
[[Interface\Buttons\UI-SpellbookIcon-NextPage-Up]],
[[Interface\Buttons\UI-StopButton]],
[[Interface\COMMON\friendship-heart]],
[[Interface\COMMON\friendship-FistHuman]],
[[Interface\COMMON\VOICECHAT-MUTED]],
[[Interface\Glues\LOGIN\Glues-CheckBox-Check]],
[[Interface\PvPRankBadges\PvPRank06]],
[[Interface\Scenarios\ScenarioIcon-Boss]],
[[Interface\Tooltips\ReforgeGreenArrow]],
}
3 years ago
local setArrowTextureCallback = function(_, _, value)
4 years ago
StreamOverlay.db.arrow_texture = value
StreamOverlay:RefreshAllBattleLineStyle()
end
3 years ago
4 years ago
local arrowIconTable = {}
3 years ago
for _, arrow in ipairs(arrows) do
arrowIconTable[#arrowIconTable+1] = {value = arrow, label = arrow:gsub("Interface(.*)\\", ""), onclick = setArrowTextureCallback, icon = arrow}
4 years ago
end
3 years ago
4 years ago
--
3 years ago
local setWindowStrataCallback = function(_, _, strata)
4 years ago
StreamOverlay.db.main_frame_strata = strata
3 years ago
SOF:SetFrameStrata(strata)
StreamerOverlayDpsHpsFrame:SetFrameStrata(strata)
4 years ago
end
local strataTable = {
3 years ago
{value = "BACKGROUND", label = "Background", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Green]], iconcolor = {0, .5, 0, .8}, texcoord = nil},
{value = "LOW", label = "Low", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Green]] , texcoord = nil},
{value = "MEDIUM", label = "Medium", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , texcoord = nil},
{value = "HIGH", label = "High", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , iconcolor = {1, .7, 0, 1}, texcoord = nil},
{value = "DIALOG", label = "Dialog", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Red]] , iconcolor = {1, 0, 0, 1}, texcoord = nil},
4 years ago
}
3 years ago
4 years ago
--
3 years ago
local setTextPerSecondTypeCallback = function(_, _, value)
4 years ago
StreamOverlay.db.per_second.attribute_type = value
end
local attributeTable = {
3 years ago
{value = 1, label = "DPS", onclick = setTextPerSecondTypeCallback},
{value = 2, label = "HPS", onclick = setTextPerSecondTypeCallback},
4 years ago
}
3 years ago
--
4 years ago
3 years ago
local squareGrowOptions = {
{value = "right", label = "RIGHT", onclick = function() StreamOverlay.db.square_grow_direction = "right"; StreamOverlay:ReorderSquares() end},
{value = "left", label = "LEFT", onclick = function() StreamOverlay.db.square_grow_direction = "left"; StreamOverlay:ReorderSquares() end},
}
4 years ago
3 years ago
local options = {
4 years ago
{
type = "toggle",
name = "Locked",
desc = "Can't move or interact within the frame when it's locked.",
order = 1,
get = function() return StreamOverlay.db.main_frame_locked end,
3 years ago
set = function(self, fixedParam, val)
4 years ago
StreamOverlay:SetLocked (not StreamOverlay.db.main_frame_locked)
end,
},
3 years ago
{
type = "toggle",
name = "Minimap Icon",
desc = "Show/Hide minimap icon.",
order = 1,
get = function() return not StreamOverlay.db.minimap.hide end,
set = function(self, fixedParam, val)
StreamOverlay.db.minimap.hide = not StreamOverlay.db.minimap.hide
if (LDBIcon) then
LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap)
end
end,
},
4 years ago
{
type = "color",
get = function() return StreamOverlay.db.main_frame_color end,
3 years ago
set = function(self, r, g, b, a)
4 years ago
StreamOverlay:SetBackgroundColor (r, g, b, a)
end,
desc = "Color used on the background.",
name = "Background Color"
},
3 years ago
{
type = "range",
get = function() return StreamOverlay.db.scale or 1 end,
set = function(self, fixedparam, value) StreamOverlay.db.scale = value; StreamOverlay.Frame:SetScale(value) end,
min = 0.6,
max = 2,
step = 0.1,
desc = "Scale",
name = "Scale",
usedecimals = true,
},
{type = "blank"},
4 years ago
{
type = "range",
get = function() return StreamOverlay.db.row_height end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.row_height = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = 10,
max = 30,
step = 1,
desc = "How hight is each bar.",
name = "Bar Height",
},
{
type = "range",
get = function() return StreamOverlay.db.row_spacement end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.row_spacement = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = 8,
max = 31,
step = 1,
desc = "How much space each bar use.",
name = "Bar Space",
},
{
type = "select",
get = function() return StreamOverlay.db.row_texture end,
values = function() return textureTable end,
desc = "Which texture is used on bars.",
name = "Bar Texture"
},
{
type = "color",
get = function() return StreamOverlay.db.row_color end,
3 years ago
set = function(self, r, g, b, a)
4 years ago
local c = StreamOverlay.db.row_color
c[1], c[2], c[3], c[4] = r, g, b, a
StreamOverlay:RefreshAllBattleLineStyle()
end,
desc = "Color used on the background.",
name = "Bar Color"
},
{type = "space"},
{
type = "range",
get = function() return StreamOverlay.db.font_size end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.font_size = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = 8,
max = 32,
step = 1,
desc = "The size of the text.",
name = "Text Size",
},
{
type = "select",
get = function() return StreamOverlay.db.font_face end,
values = function() return fontTable end,
desc = "Font used on texts.",
name = "Text Font"
},
{
type = "color",
get = function() return StreamOverlay.db.font_color end,
3 years ago
set = function(self, r, g, b, a)
4 years ago
local c = StreamOverlay.db.font_color
c[1], c[2], c[3], c[4] = r, g, b, a
StreamOverlay:RefreshAllBattleLineStyle()
end,
desc = "Color used on texts.",
name = "Text Color"
},
{type = "space"},
{
type = "toggle",
name = "Show Dps/Hps",
desc = "Show in the screen your current Dps or Hps.",
order = 1,
get = function() return StreamOverlay.db.per_second.enabled end,
3 years ago
set = function(self, fixedParam, val)
4 years ago
StreamOverlay.db.per_second.enabled = not StreamOverlay.db.per_second.enabled
-- update hps dps frame
StreamOverlay:UpdateDpsHpsFrameConfig()
end,
},
{
type = "select",
get = function() return StreamOverlay.db.per_second.attribute_type end,
values = function() return attributeTable end,
desc = "Show DPS or HPS.",
name = "Show"
},
{
type = "range",
get = function() return StreamOverlay.db.per_second.size end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.per_second.size = value;
4 years ago
-- update hps dps frame
StreamOverlay:UpdateDpsHpsFrameConfig()
end,
min = 8,
max = 32,
step = 1,
desc = "The size of the text.",
name = "Dps/Hps Text Size",
},
{
type = "range",
get = function() return StreamOverlay.db.per_second.scale end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.per_second.scale = value;
4 years ago
-- update hps dps frame
StreamOverlay:UpdateDpsHpsFrameConfig()
end,
min = 0.65,
max = 1.5,
step = 1,
desc = "The size of the text.",
name = "Dps/Hps Scale",
usedecimals = true,
},
{
type = "range",
get = function() return StreamOverlay.db.per_second.update_speed end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.per_second.update_speed = value;
4 years ago
-- update hps dps frame
StreamOverlay:UpdateDpsHpsFrameConfig()
end,
min = 0.016,
max = 1,
step = 0.016,
desc = "How fast the frame get updated.",
name = "Dps/Hps Update Speed",
usedecimals = true,
},
{
type = "toggle",
name = "Dps/Hps Text Shadow",
desc = "Enable text shadow.",
order = 1,
get = function() return StreamOverlay.db.per_second.font_shadow end,
3 years ago
set = function(self, fixedParam, val)
4 years ago
StreamOverlay.db.per_second.font_shadow = not StreamOverlay.db.per_second.font_shadow
-- update hps dps frame
StreamOverlay:UpdateDpsHpsFrameConfig()
end,
},
3 years ago
{type = "breakline"},
4 years ago
{
3 years ago
type = "range",
get = function() return StreamOverlay.db.square_amount end,
set = function(self, fixedparam, value)
StreamOverlay.db.square_amount = value
StreamOverlay:Refresh()
end,
min = 3,
max = 16,
step = 1,
desc = "Square Amount",
name = "Square Amount",
},
{
type = "range",
get = function() return StreamOverlay.db.square_size end,
set = function(self, fixedparam, value)
StreamOverlay.db.square_size = value
StreamOverlay:RefreshAllBoxesStyle()
4 years ago
end,
3 years ago
min = 10,
max = 256,
step = 1,
desc = "Square Size",
name = "Square Size",
4 years ago
},
3 years ago
{
type = "select",
get = function() return StreamOverlay.db.square_grow_direction end,
values = function() return squareGrowOptions end,
desc = "Square Direction",
name = "Square Direction",
},
{type = "blank"},
4 years ago
{
type = "select",
get = function() return StreamOverlay.db.arrow_texture end,
values = function() return arrowIconTable end,
desc = "The icon used on the middle of the bar",
name = "Arrow Icon"
},
3 years ago
4 years ago
{
type = "range",
get = function() return StreamOverlay.db.arrow_size end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.arrow_size = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = 6,
max = 32,
step = 1,
desc = "The size of the arrow.",
name = "Arrow Size",
},
3 years ago
4 years ago
{
type = "color",
get = function() return StreamOverlay.db.arrow_color end,
3 years ago
set = function(self, r, g, b, a)
4 years ago
local c = StreamOverlay.db.arrow_color
c[1], c[2], c[3], c[4] = r, g, b, a
StreamOverlay:RefreshAllBattleLineStyle()
end,
desc = "The color used on the arrow.",
name = "Arrow Color"
},
{
type = "range",
get = function() return StreamOverlay.db.arrow_anchor_x end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.arrow_anchor_x = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = -16,
max = 16,
step = 1,
desc = "Adjust the arrow positioning on X axis.",
name = "Arrow Anchor X",
},
{
type = "range",
get = function() return StreamOverlay.db.arrow_anchor_y end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.arrow_anchor_y = value; StreamOverlay:RefreshAllBattleLineStyle() end,
4 years ago
min = -16,
max = 16,
step = 1,
desc = "Adjust the arrow positioning on Y axis.",
name = "Arrow Anchor Y",
},
{type = "space"},
{
type = "range",
get = function() return StreamOverlay.db.main_frame_size[1] end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.main_frame_size[1] = value; StreamOverlay:RestoreWindowSizeAndLocation() end,
4 years ago
min = 150,
max = 800,
step = 1,
desc = "Adjust the window width.",
name = "Window Width",
},
{
type = "range",
get = function() return StreamOverlay.db.main_frame_size[2] end,
3 years ago
set = function(self, fixedparam, value) StreamOverlay.db.main_frame_size[2] = value; StreamOverlay:RestoreWindowSizeAndLocation() end,
4 years ago
min = 40,
max = 1024,
step = 1,
desc = "Adjust the window height.",
name = "Window Height",
},
{
type = "select",
get = function() return StreamOverlay.db.main_frame_strata end,
values = function() return strataTable end,
desc = "How high the frame is placed in your interface, high values makes it be shown above backpack, talents frame, etc.",
name = "Window Strata"
},
{type = "space"},
{
type = "toggle",
name = "Show Spark",
desc = "Show or hide the spark at bars",
order = 1,
get = function() return StreamOverlay.db.use_spark end,
3 years ago
set = function(self, fixedParam, val)
4 years ago
StreamOverlay.db.use_spark = not StreamOverlay.db.use_spark
end,
},
}
3 years ago
detailsFramework:BuildMenu(optionsFrame, options, 15, -235, 860, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
4 years ago
--select profile dropdown
3 years ago
local selectProfile = function(_, _, profileName)
local pname = UnitName("player") .. " - " .. GetRealmName()
4 years ago
3 years ago
--save the current config on the profile
4 years ago
local current_profile = Details_StreamerDB.characters [pname]
local current_ptable = Details_StreamerDB.profiles [current_profile]
_detalhes.table.overwrite (current_ptable, StreamOverlay.db) --overwrite the profile with the local settings
3 years ago
--get the selected profile and overwrite the settings
4 years ago
local ptable = Details_StreamerDB.profiles [profileName]
3 years ago
_detalhes.table.deploy(ptable, StreamOverlay.DefaultConfigTable) --update with any new config from the default table
4 years ago
_detalhes.table.overwrite (StreamOverlay.db, ptable) --overwrite the local settings with the profile settings
Details_StreamerDB.characters [pname] = profileName
3 years ago
--restore size and location
4 years ago
StreamOverlay:RestoreWindowSizeAndLocation()
3 years ago
--set locked and the backdrop color
4 years ago
StreamOverlay:SetLocked (StreamOverlay.db.main_frame_locked)
3 years ago
StreamOverlay:SetBackgroundColor (unpack(StreamOverlay.db.main_frame_color))
4 years ago
3 years ago
--update the minimap icon
4 years ago
if (LDBIcon) then
LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap)
end
3 years ago
--update all settings
4 years ago
StreamOverlay:RefreshAllBattleLineStyle()
3 years ago
--update the options panel
optionsFrame:RefreshOptions()
4 years ago
end
local select_profile_fill = function()
local t = {}
3 years ago
for profileName, _ in pairs(Details_StreamerDB.profiles) do
t [#t+1] = {value = profileName, label = profileName, onclick = selectProfile}
4 years ago
end
return t
end
3 years ago
local label_profile = Details.gump:CreateLabel(optionsFrame, "Profile" .. ": ", Details.gump:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
local dropdown_profile = Details.gump:CreateDropDown (optionsFrame, select_profile_fill, nil, 160, 20, "dropdown_profile", nil, Details.gump:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
dropdown_profile:SetPoint("left", label_profile, "right", 2, 0)
label_profile:SetPoint("topleft", optionsFrame, "topleft", 15, -65)
4 years ago
local pname = UnitName ("player") .. " - " .. GetRealmName()
3 years ago
dropdown_profile:Select(Details_StreamerDB.characters [pname])
4 years ago
3 years ago
--new profile button
4 years ago
if (not Details_StreamerDB.profiles [pname]) then
local add_profile = function()
--profile name
local pname = UnitName ("player") .. " - " .. GetRealmName()
--default if is first run
Details_StreamerDB.characters [pname] = pname
--load dbtable
Details_StreamerDB.profiles [pname] = {}
_detalhes.table.overwrite (Details_StreamerDB.profiles [pname], StreamOverlay.db)
3 years ago
_detalhes.table.deploy(Details_StreamerDB.profiles [pname], StreamOverlay.DefaultConfigTable) --update with any new config from the default table
4 years ago
--StreamOverlay.db = Details_StreamerDB.profiles [pname] --no can't change the local database table
3 years ago
optionsFrame.NewProfileButton:Hide()
4 years ago
3 years ago
--update all settings
4 years ago
StreamOverlay:RefreshAllBattleLineStyle()
3 years ago
--update the options panel
optionsFrame:RefreshOptions()
dropdown_profile:Select(Details_StreamerDB.characters [pname])
4 years ago
end
3 years ago
optionsFrame.NewProfileButton = Details.gump:CreateButton(optionsFrame, add_profile, 60, 18, "New Profiile", _, _, _, _, _, _, Details.gump:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"), Details.gump:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
optionsFrame.NewProfileButton:SetPoint("left", dropdown_profile, "right", 4, 0)
4 years ago
end
--enable / disable plugin button
local toggle_OnOff = function()
local pluginStable = Details:GetPluginSavedTable("DETAILS_PLUGIN_STREAM_OVERLAY")
local pluginObject = Details:GetPlugin("DETAILS_PLUGIN_STREAM_OVERLAY")
if (pluginStable.enabled) then
pluginStable.enabled = false
pluginObject.__enabled = false
Details:SendEvent("PLUGIN_DISABLED", pluginObject)
3 years ago
optionsFrame.toggleButton.text = "Start Plugin"
4 years ago
else
pluginStable.enabled = true
pluginObject.__enabled = true
Details:SendEvent("PLUGIN_ENABLED", pluginObject)
3 years ago
optionsFrame.toggleButton.text = "Disable Plugin"
4 years ago
end
end
--get the plugin state
local pluginStable = Details:GetPluginSavedTable("DETAILS_PLUGIN_STREAM_OVERLAY")
3 years ago
local toggleButton = DetailsFramework:CreateButton(optionsFrame, toggle_OnOff, 120, 20, pluginStable.enabled and "Disable Plugin" or "Start Plugin")
toggleButton:SetPoint("topleft", optionsFrame, "topleft", 15, -35)
4 years ago
toggleButton:SetTemplate(DetailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
3 years ago
optionsFrame.toggleButton = toggleButton
4 years ago
3 years ago
optionsFrame:SetScript("OnHide", function()
4 years ago
if (StreamOverlay.FromOptionsPanel) then
3 years ago
--reopen the options panel
C_Timer.After(0.2, function()
4 years ago
Details:OpenOptionsWindow(Details:GetInstance(1))
end)
end
end)
3 years ago
optionsFrame:SetScript("OnShow", function()
local pluginStable = Details:GetPluginSavedTable("DETAILS_PLUGIN_STREAM_OVERLAY")
local pluginObject = Details:GetPlugin("DETAILS_PLUGIN_STREAM_OVERLAY")
if (pluginObject) then
if (pluginStable.enabled) then
toggleButton:SetText("Disable Plugin")
else
toggleButton:SetText("Enable Plugin")
end
end
end)
4 years ago
end
StreamOverlayOptionsPanel:Show()
3 years ago
StreamOverlay.FromOptionsPanel = fromOptionsPanel
if (fromOptionsPanel) then
4 years ago
if (DetailsOptionsWindow) then
3 years ago
C_Timer.After(0.2, function()
4 years ago
DetailsOptionsWindow:Hide()
end)
end
end
end
function StreamOverlay:OnEvent (_, event, ...)
if (event == "ADDON_LOADED") then
3 years ago
local AddonName = select(1, ...)
4 years ago
if (AddonName == "Details_Streamer") then
3 years ago
playerName = UnitName ("player")
4 years ago
if (_G._detalhes) then
if (DetailsFramework.IsClassicWow()) then
return
end
3 years ago
--create widgets
4 years ago
CreatePluginFrames()
3 years ago
--core version required
4 years ago
local MINIMAL_DETAILS_VERSION_REQUIRED = 80
local default_options_table = {
use_square_mode = false,
square_size = 32,
square_amount = 5,
3 years ago
square_grow_direction = "right",
4 years ago
main_frame_locked = false,
main_frame_color = {0, 0, 0, .2},
main_frame_size = {250, 230},
main_frame_strata = "LOW",
row_height = 20,
row_spacement = 21,
row_texture = "Details Serenity",
row_color = {.1, .1, .1, 0.4},
font_size = 10,
font_face = "Friz Quadrata TT",
font_color = {1, 1, 1, 1},
arrow_texture = [[Interface\CHATFRAME\ChatFrameExpandArrow]],
arrow_size = 10,
arrow_color = {1, 1, 1, .5},
arrow_anchor_x = 0,
arrow_anchor_y = 0,
minimap = {hide = false, radius = 160, minimapPos = 160},
use_spark = true,
per_second = {
enabled = false,
size = 32,
scale = 1.5,
font_shadow = true,
attribute_type = 1,
update_speed = 0.05,
},
is_first_run = true,
}
StreamOverlay.DefaultConfigTable = default_options_table
3 years ago
--Install
4 years ago
local install, saveddata = _G._detalhes:InstallPlugin ("TOOLBAR", "Action Tracker", [[Interface\MINIMAP\MOVIERECORDINGICON]], StreamOverlay, "DETAILS_PLUGIN_STREAM_OVERLAY", MINIMAL_DETAILS_VERSION_REQUIRED, "Terciob", StreamOverlay.CurrentVersion, default_options_table)
3 years ago
if (type(install) == "table" and install.error) then
print(install.error)
4 years ago
end
Details_StreamerDB = Details_StreamerDB or {characters = {}, profiles = {}}
StreamOverlay:CreateMinimapIcon()
StreamOverlay:SetPluginDescription ("Show in real time the spells you are casting.\n\nThe viewer can now follow what you are doing, what spells you are casting, learn your rotation.\n\nAlso tells who is the target and its class/spec on raiding or role if you are in arena.\n\nWhen you die, the panel is filled with your death log.")
if (StreamOverlay.db.is_first_run) then --problem with setting the plugin as disabled
3 years ago
if (Details:GetTutorialCVar("STREAMER_PLUGIN_FIRSTRUN")) then
4 years ago
Details:DisablePlugin ("DETAILS_PLUGIN_STREAM_OVERLAY")
StreamOverlay.db.is_first_run = false
else
Details:DisablePlugin ("DETAILS_PLUGIN_STREAM_OVERLAY")
end
end
3 years ago
if (StreamOverlay.db.is_first_run and not Details:GetTutorialCVar("STREAMER_PLUGIN_FIRSTRUN")) then
4 years ago
local show_frame = function()
3 years ago
4 years ago
if ((DetailsWelcomeWindow and DetailsWelcomeWindow:IsShown()) or not StreamOverlay.db.is_first_run) then
return
end
3 years ago
4 years ago
StreamOverlay.ShowWelcomeFrame:Cancel()
3 years ago
local welcomeWindow = CreateFrame("frame", "StreamOverlayWelcomeWindow", UIParent, "BackdropTemplate")
welcomeWindow:SetPoint("center", UIParent, "center")
welcomeWindow:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
welcomeWindow:SetBackdropColor(0, 0, 0, 0.5)
welcomeWindow:SetBackdropBorderColor(0, 0, 0, 1)
welcomeWindow:SetSize(740, 270)
DetailsFramework:ApplyStandardBackdrop(welcomeWindow)
local icon = welcomeWindow:CreateTexture(nil, "overlay")
icon:SetTexture([[Interface\MINIMAP\MOVIERECORDINGICON]])
local title = welcomeWindow:CreateFontString(nil, "overlay", "GameFontNormal")
title:SetText("Details!: Action Tracker (plugin)")
StreamOverlay:SetFontSize(title, 20)
local youtubeTwitchIcons = welcomeWindow:CreateTexture(nil, "overlay")
youtubeTwitchIcons:SetTexture([[Interface\AddOns\Details\images\icons2]])
youtubeTwitchIcons:SetTexCoord(0, 109/512, 370/512, 413/512)
youtubeTwitchIcons:SetSize(109, 413 - 370)
youtubeTwitchIcons:SetPoint("topleft", welcomeWindow, "topleft", 123, -61)
local text1 = welcomeWindow:CreateFontString(nil, "overlay", "GameFontNormal")
text1:SetText("SHOW TO YOUR VIEWERS YOUR ROTATION\nThis way they can learn while watching your content")
local text2 = welcomeWindow:CreateFontString(nil, "overlay", "GameFontNormal")
text2:SetText("Use the command:")
local text3 = welcomeWindow:CreateFontString(nil, "overlay", "GameFontNormal")
text3:SetText("/streamer")
4 years ago
DetailsFramework:SetFontSize(text3, 16)
3 years ago
icon:SetPoint("topleft", welcomeWindow, "topleft", 10, -20)
title:SetPoint("left", icon, "right", 10, 0)
text1:SetPoint("topleft", welcomeWindow, "topleft", 10, -120)
text2:SetPoint("center", text1, "center", 0, -40)
text3:SetPoint("center", text2, "center", 0, -16)
local image1 = welcomeWindow:CreateTexture(nil, "overlay")
4 years ago
image1:SetTexture([[Interface\AddOns\Details_Streamer\streamer_plugin_lines]])
3 years ago
image1:SetPoint("topleft", welcomeWindow, "topleft", 410, -6)
4 years ago
image1:SetSize(512, 256)
local close_func = function()
StreamOverlay.db.is_first_run = false
Details:SetTutorialCVar ("STREAMER_PLUGIN_FIRSTRUN", true)
3 years ago
welcomeWindow:Hide()
4 years ago
end
3 years ago
local close = Details.gump:CreateButton(welcomeWindow, close_func, 120, 20, "Okay", nil, nil, nil, nil, nil, nil, Details.gump:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
close:SetPoint("center", text3, "center", 0, -50)
4 years ago
end
3 years ago
StreamOverlay.ShowWelcomeFrame = C_Timer.NewTicker(5, show_frame)
4 years ago
end
--wipe (StreamOverlay.db)
SOF:RegisterEvent ("PLAYER_LOGOUT")
--profile name
SOF.PlayerNameProfile = UnitName("player") .. " - " .. GetRealmName()
local pname = SOF.PlayerNameProfile
--default if is first run
local next_pname = next (Details_StreamerDB.profiles or {})
Details_StreamerDB.characters [pname] = Details_StreamerDB.characters [pname] or next_pname or pname
--load dbtable
local ptable = Details_StreamerDB.profiles [ Details_StreamerDB.characters [pname] ] or {} --already existen config set or empty table
_detalhes.table.overwrite (StreamOverlay.db, ptable) --profile overwrite the local settings
3 years ago
_detalhes.table.deploy(ptable, StreamOverlay.db) --local settings deploy stuff which non exist on profile
4 years ago
Details_StreamerDB.profiles [ Details_StreamerDB.characters [pname] ] = ptable
end
end
elseif (event == "PLAYER_LOGOUT") then
local pname = UnitName("player") .. " - " .. GetRealmName()
--print(Details_Streamer.PlayerNameProfile)
Details_StreamerDB.profiles [ Details_StreamerDB.characters [pname] ] = StreamOverlay.db
end
end
3 years ago
--create minimap icon
4 years ago
function StreamOverlay:CreateMinimapIcon()
if (StreamOverlay.minimap_icon_created) then
return
end
StreamOverlay.minimap_icon_created = true
3 years ago
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LDB and LibStub("LibDBIcon-1.0", true)
4 years ago
if LDB then
local minimapIcon = LDB:NewDataObject ("DetailsStreamer", {
type = "data source",
icon = [[Interface\MINIMAP\MOVIERECORDINGICON]],
3 years ago
OnClick = function(self, button)
4 years ago
if (button == "LeftButton") then
StreamOverlay.OpenOptionsPanel()
elseif (button == "RightButton") then
StreamOverlay.db.minimap.hide = not StreamOverlay.db.minimap.hide
if (LDBIcon) then
LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap)
end
end
end,
3 years ago
OnTooltipShow = function(tooltip)
tooltip:AddLine("Details!: Action Tracker", 1, 1, 1)
tooltip:AddLine("|cFFFF7700Left Click|r: open options.")
tooltip:AddLine("|cFFFF7700Right Click|r: hide this icon.")
4 years ago
end,
})
if (minimapIcon and not LDBIcon:IsRegistered ("DetailsStreamer")) then
LDBIcon:Register ("DetailsStreamer", minimapIcon, StreamOverlay.db.minimap)
end
end
end
SLASH_STREAMER1, SLASH_STREAMER2 = "/streamer", "/detailsstreamer"
function SlashCmdList.STREAMER (msg, editbox)
local command, rest = msg:match ("^(%S*)%s*(.-)$")
3 years ago
--open options panel
4 years ago
StreamOverlay.OpenOptionsPanel()
end
--[[ extrair lista das magias
3 years ago
local editbox = CreateFrame("editbox", nil, UIParent)
editbox:SetSize(300, 700)
editbox:SetPoint("topleft", UIParent, "topleft")
editbox:SetBackdrop({bgFile = "Interface\\AddOns\\Details\\images\\background", tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
editbox:SetBackdropColor(0, 0, 0, .2)
editbox:SetAutoFocus(false)
4 years ago
editbox:ClearFocus()
editbox:SetMultiLine (true)
3 years ago
editbox:SetFontObject(GameFontHighlightSmall)
4 years ago
editbox:SetJustifyH("CENTER")
editbox:EnableMouse(true)
3 years ago
editbox:SetText("")
editbox:SetScript("OnEscapePressed", function() editbox:ClearFocus() end)
editbox:SetScript("OnEditFocusGained", function() editbox:HighlightText() end)
4 years ago
local list = ""
local harmful_spells = StreamOverlay.HarmfulSpells
local helpful_spells = StreamOverlay.HelpfulSpells
if (not harmful_spells [spellid] and not helpful_spells [spellid]) then
3 years ago
if (bit.band(who_flags, 0x00000400) ~= 0 and who_name) then
4 years ago
local text = editbox:GetText()
3 years ago
if (not list:find(spellid) and not text:find(spellid)) then
4 years ago
3 years ago
local class = _detalhes:GetClass(who_name) or "unknow"
4 years ago
if (class ~= "unknow") then
text = text .. "\n"..spellid .. " " .. spellname .. " " .. class
3 years ago
editbox:SetText(text)
4 years ago
end
end
end
end
--]]
--endd
--doo