From 09601d7e11de36f9a0c691fa0470b37716c4c61a Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sat, 9 Jan 2021 13:18:08 -0300 Subject: [PATCH] Added "Square" mode to Details! Streamer plugin --- Libs/DF/fw.lua | 2 +- Libs/DF/panel.lua | 8 +- Libs/DF/spells.lua | 8 + plugins/Details_Streamer/Details_Streamer.lua | 678 +++++++++++++----- 4 files changed, 512 insertions(+), 184 deletions(-) diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 044b88e4..afe4c410 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 227 +local dversion = 228 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index 65713aaa..35e0a3dd 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -5139,7 +5139,7 @@ DF.IconRowFunctions = { newIconFrame.CountdownText:SetPoint (self.options.text_anchor or "center", newIconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0) newIconFrame.CountdownText:Hide() - newIconFrame.StackText = cooldownFrame:CreateFontString (nil, "overlay", "GameFontNormal") + newIconFrame.StackText = newIconFrame:CreateFontString (nil, "overlay", "GameFontNormal") --newIconFrame.StackText:SetPoint ("bottomright") newIconFrame.StackText:SetPoint (self.options.stack_text_anchor or "center", newIconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0) newIconFrame.StackText:Hide() @@ -6080,7 +6080,7 @@ function DF:PassLoadFilters (loadTable, encounterID) canCheckTalents = false for _, specID in ipairs (specsForThisClass) do - if (loadTable.spec [specID]) then + if (loadTable.spec [specID] or loadTable.spec [specID..""]) then --theres a talent for this class canCheckTalents = true break @@ -6092,7 +6092,7 @@ function DF:PassLoadFilters (loadTable, encounterID) local specIndex = DetailsFramework.GetSpecialization() if (specIndex) then local specID = DetailsFramework.GetSpecializationInfo (specIndex) - if (not loadTable.spec [specID]) then + if (not loadTable.spec [specID] or loadTable.spec [specID..""]) then return false end else @@ -6316,7 +6316,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) name = specName, set = f.OnRadioCheckboxClick, param = specID, - get = function() return f.OptionsTable.spec [specID] end, + get = function() return f.OptionsTable.spec [specID] or f.OptionsTable.spec [specID..""] end, texture = specIcon, }) end diff --git a/Libs/DF/spells.lua b/Libs/DF/spells.lua index c19400d5..2ee6c5d4 100644 --- a/Libs/DF/spells.lua +++ b/Libs/DF/spells.lua @@ -787,6 +787,14 @@ DF.CrowdControlSpells = { [118905] = "SHAMAN", --Static Charge (Capacitor Totem) [51514] = "SHAMAN", --Hex + [210873] = "SHAMAN", --Hex (Compy) + [211004] = "SHAMAN", --Hex (Spider) + [211010] = "SHAMAN", --Hex (Snake) + [211015] = "SHAMAN", --Hex (Cockroach) + [269352] = "SHAMAN", --Hex (Skeletal Hatchling) + [277778] = "SHAMAN", --Hex (Zandalari Tendonripper) + [277784] = "SHAMAN", --Hex (Wicker Mongrel) + [309328] = "SHAMAN", --Hex (Living Honey) [64695] = "SHAMAN", --Earthgrab (talent) [197214] = "SHAMAN", --Sundering (talent) diff --git a/plugins/Details_Streamer/Details_Streamer.lua b/plugins/Details_Streamer/Details_Streamer.lua index 00e3141e..a7699181 100644 --- a/plugins/Details_Streamer/Details_Streamer.lua +++ b/plugins/Details_Streamer/Details_Streamer.lua @@ -34,11 +34,13 @@ StreamOverlay.battle_lines = {} --> store the information to be shown on bars, like text, icon, colors 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 the hide. Runs every 1 minutes. +-- 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. @@ -207,7 +209,7 @@ local function CreatePluginFrames() SOF:SetMovable (true) SOF:SetResizable (true) SOF:SetClampedToScreen (true) - SOF:SetMinResize (150, 40) + SOF:SetMinResize (150, 10) SOF:SetMaxResize (800, 1024) function StreamOverlay:SaveWindowSizeAnLocation() @@ -305,29 +307,146 @@ local function CreatePluginFrames() end) - - - --> 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) --> looks like this isn't working function StreamOverlay:ClearAll() - for index = 1, #StreamOverlay.battle_lines do - local line = StreamOverlay.battle_lines [index] - if (line) then - line.in_use = 1 + 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 - StreamOverlay:UpdateLines() 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() + local index = #StreamOverlay.squares+1 - + local f = CreateFrame("frame", "StreamOverlaySquare" .. index, SOF, "BackdropTemplate") + 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.squareIndex = index + + f.texture = f:CreateTexture(nil, "artwork") + f.texture:SetAllPoints() + + f.interruptedTexture = f:CreateTexture(nil, "overlay") + f.interruptedTexture:SetColorTexture(1, 0, 0, 0.4) + f.interruptedTexture:SetAllPoints() + + local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", f, "CooldownFrameTemplate, BackdropTemplate") + cooldownFrame:SetAllPoints() + cooldownFrame:EnableMouse(false) + cooldownFrame:SetHideCountdownNumbers(true) + f.cooldown = cooldownFrame + + if (index == 1) then + f:SetPoint("topleft", SOF, "topleft", 2, 0) + else + f:SetPoint("left", StreamOverlay.squares[index - 1], "right", 2, 0) + end + + StreamOverlay.squares [#StreamOverlay.squares+1] = f + + f.in_use = 1 + f:Hide() + + StreamOverlay:SetSquareStyle(f, index) + end + + function StreamOverlay:UpdateSquares() + local direction = StreamOverlay.db.grow_direction + + if (direction == "right") then + for index = 1, StreamOverlay.total_lines do + StreamOverlay:UpdateSquare(index) + end + else + for index = #StreamOverlay.total_lines, 1, -1 do + StreamOverlay:UpdateSquare(index) + end + end + end + + function StreamOverlay:UpdateSquare(index) + local square = StreamOverlay.squares[index] + + local data = StreamOverlay.battle_content[index] + if (data) then + square.texture:SetTexture(data [1]) + 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) + + 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 + --> iterate each bar and update its text, icons and statusbar function StreamOverlay:UpdateLines() + if (StreamOverlay.db.use_square_mode) then + return + end + FauxScrollFrame_Update (autoscroll, StreamOverlay.total_lines, StreamOverlay.total_lines, 20) for index = 1, StreamOverlay.total_lines do @@ -413,6 +532,7 @@ local function CreatePluginFrames() if (castinfo.Success) then line.spark:SetVertexColor (1, 1, 1, 0.4) line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0) + elseif (castinfo.Interrupted) then line.spark:SetVertexColor (1, 0, 0, 0.4) line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 8, 0) @@ -427,16 +547,21 @@ local function CreatePluginFrames() end end - function StreamOverlay:NewText (icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, ID, CastStart) - + 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 - - table.insert (StreamOverlay.battle_content, 1, {icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, CastID = ID, CastStart = CastStart}) + + --CastStart from the cast_send + table.insert (StreamOverlay.battle_content, 1, {icon1, text1, color1, icon2, icon2coords, text2, color2, backgroundcolor, bordercolor, CastID = ID, CastStart = CastStart, startTime = startTime, endTime = endTime}) table.remove (StreamOverlay.battle_content, StreamOverlay.total_lines+1) - StreamOverlay:UpdateLines (autoscroll) + + if (StreamOverlay.db.use_square_mode) then + StreamOverlay:UpdateSquares() + else + StreamOverlay:UpdateLines() + end end function StreamOverlay:CreateBattleLine() @@ -501,11 +626,14 @@ local function CreatePluginFrames() f:Hide() StreamOverlay:SetBattleLineStyle (f) - end function StreamOverlay:RefreshAllBattleLineStyle() + if (StreamOverlay.db.use_square_mode) then + return + end + for i, row in ipairs (StreamOverlay.battle_lines) do StreamOverlay:SetBattleLineStyle (row, i) end @@ -514,7 +642,22 @@ local function CreatePluginFrames() StreamOverlay:SetFontFace (StreamerOverlayDpsHpsFrameText, SharedMedia:Fetch ("font", StreamOverlay.db.font_face)) StreamOverlay:SetFontColor (StreamerOverlayDpsHpsFrameText, StreamOverlay.db.font_color) end + + function StreamOverlay:RefreshAllBoxesStyle() + if (not StreamOverlay.db.use_square_mode) then + return + end + + for i, square in ipairs (StreamOverlay.squares) do + 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 @@ -571,6 +714,7 @@ local function CreatePluginFrames() function StreamOverlay:RefreshInUse (line) local now = GetTime() + local i = -1 --was nil before from _G["i"] 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 @@ -581,73 +725,117 @@ local function CreatePluginFrames() fader (nil, line, "out") end else - 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 + 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 - if (max (line_in_use, content_in_use) + 60 < now) then - fader (nil, StreamOverlay.battle_lines [i], "in") - else - fader (nil, StreamOverlay.battle_lines [i], "out") + if (max (line_in_use, content_in_use) + 60 < now) then + 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 + + if (max (line_in_use, content_in_use) + 60 < now) then + fader (nil, StreamOverlay.squares[i], "in") + else + fader (nil, StreamOverlay.squares[i], "out") + end + end + end end end - C_Timer.NewTicker (60, StreamOverlay.RefreshInUse) + C_Timer.NewTicker(60, StreamOverlay.RefreshInUse) function StreamOverlay:Refresh() - --> how many lines fit in the frame - local amt = math.floor (SOF:GetHeight() / StreamOverlay.db.row_spacement) + if (StreamOverlay.db.use_square_mode) then - if (amt < 0) then - amt = 0 - end - - StreamOverlay.total_lines = amt - - if (amt == 0) then - for i = 1, #StreamOverlay.battle_lines do - StreamOverlay.battle_lines [i]:Hide() + local amt = StreamOverlay.db.square_amount + StreamOverlay.total_lines = amt + + if (amt > #StreamOverlay.squares) then + for i = #StreamOverlay.squares+1, amt do + StreamOverlay:CreateSquareBox() + end + for i = 1, amt do + StreamOverlay.squares[i]:Show() + end + + elseif (#StreamOverlay.squares > amt) then + for i = #StreamOverlay.squares, amt+1, -1 do + StreamOverlay.squares [i]:Hide() + end + for i = 1, amt do + StreamOverlay.squares [i]:Show() + end + + else + for i = 1, amt do + StreamOverlay.squares[i]:Show() + end end - return - end - - --> need create more lines - if (amt > #StreamOverlay.battle_lines) then - for i = #StreamOverlay.battle_lines+1, amt do - StreamOverlay:CreateBattleLine() - end - for i = 1, amt do - StreamOverlay.battle_lines [i]:Show() + + StreamOverlay:UpdateSquares() + StreamOverlay:RefreshInUse() + else + + --> how many lines fit in the frame + local amt = math.floor (SOF:GetHeight() / StreamOverlay.db.row_spacement) + + if (amt < 0) then + amt = 0 end - elseif (#StreamOverlay.battle_lines > amt) then - for i = #StreamOverlay.battle_lines, amt+1, -1 do - StreamOverlay.battle_lines [i]:Hide() + StreamOverlay.total_lines = amt + + if (amt == 0) then + for i = 1, #StreamOverlay.battle_lines do + StreamOverlay.battle_lines [i]:Hide() + end + return end - for i = 1, amt do - StreamOverlay.battle_lines [i]:Show() - end - else - for i = 1, amt do - StreamOverlay.battle_lines [i]:Show() - end - end - local width = SOF:GetWidth() / 2 - text1_size, text2_size = width - 28, width - 30 - - --for i = 1, #StreamOverlay.battle_lines do - -- StreamOverlay.battle_lines [i].text1:SetWidth (text1_size) - -- StreamOverlay.battle_lines [i].text2:SetWidth (text2_size) - --end - - StreamOverlay:UpdateLines() - StreamOverlay:RefreshInUse() + --> need create more lines + if (amt > #StreamOverlay.battle_lines) then + for i = #StreamOverlay.battle_lines+1, amt do + StreamOverlay:CreateBattleLine() + end + for i = 1, amt do + StreamOverlay.battle_lines[i]:Show() + end + + elseif (#StreamOverlay.battle_lines > amt) then + for i = #StreamOverlay.battle_lines, amt+1, -1 do + StreamOverlay.battle_lines [i]:Hide() + end + for i = 1, amt do + StreamOverlay.battle_lines [i]:Show() + end + else + for i = 1, amt do + StreamOverlay.battle_lines [i]:Show() + end + end + + local width = SOF:GetWidth() / 2 + text1_size, text2_size = width - 28, width - 30 + + StreamOverlay:UpdateLines() + StreamOverlay:RefreshInUse() + end end function StreamOverlay:SetBackgroundColor (r, g, b, a) @@ -675,8 +863,7 @@ local HarmfulSpellsTable = StreamOverlay.HarmfulSpells local HelpfulSpellsTable = StreamOverlay.HelpfulSpells local AttackCooldownSpellsTable = StreamOverlay.AttackCooldownSpells local ClassSpellsTable = StreamOverlay.MiscClassSpells -local CooldownTable1 = StreamOverlay.DefensiveCooldownSpells -local CooldownTable2 = StreamOverlay.DefensiveCooldownSpellsNoBuff +local CooldownTable = StreamOverlay.DefensiveCooldownSpells local ClassColorsTable = StreamOverlay.class_colors local ClassSpellList = StreamOverlay.ClassSpellList local AbsorbSpellsTable = StreamOverlay.AbsorbSpells @@ -701,7 +888,7 @@ function StreamOverlay:GetSpellInformation (spellid) elseif (AttackCooldownSpellsTable [spellid]) then backgroundcolor = COLOR_ATTKCOOLDOWN - elseif (CooldownTable1 [spellid] or CooldownTable2 [spellid]) then + elseif (CooldownTable [spellid]) then backgroundcolor = COLOR_DEFECOOLDOWN elseif (ClassSpellsTable [spellid]) then @@ -713,6 +900,7 @@ function StreamOverlay:GetSpellInformation (spellid) end + local bordercolor if (AbsorbSpellsTable [spellid]) then bordercolor = COLOR_BORDER_ABSORB else @@ -801,11 +989,14 @@ local parse_target_color = function (class) return color2 end -function StreamOverlay:CastStart (castid) - local spellid = CastsTable [castid].SpellId - local target = CastsTable [castid].Target - local caststart = CastsTable [castid].CastStart - +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 + if (ban_spells [spellid]) then return end @@ -828,8 +1019,7 @@ function StreamOverlay:CastStart (castid) target = parse_target_name (target) - StreamOverlay:NewText (spellicon, spellname, color1, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castid, caststart) - + StreamOverlay:NewText (spellicon, spellname, color1, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castGUID, caststart, startTime, endTime) end function StreamOverlay:CastFinished (castid) @@ -868,65 +1058,93 @@ function StreamOverlay:CastFinished (castid) target = parse_target_name (target) - StreamOverlay:NewText (spellicon, spellname, color1, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castid, caststart) + StreamOverlay:NewText (spellicon, spellname, nil, icon2, icon2coords, target, color2, backgroundcolor, bordercolor, castid, caststart, GetTime(), GetTime()+1.2) end end listener.track_spell_cast = function() - for i = 1, #StreamOverlay.battle_content do + 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 - local content = StreamOverlay.battle_content [i] - local line = StreamOverlay.battle_lines [i] - local castinfo = CastsTable [content.CastID] - - if (not castinfo.Done) then - - --> is being casted? - if (castinfo.HasCastTime) then - if (castinfo.Success) then - --> okey it's done - castinfo.Done = true - castinfo.Percent = 100 - line.statusbar:SetValue (100) - line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0) - --line.spark:Hide() - - elseif (castinfo.Interrupted) then - --> has been interrupted - castinfo.Done = true - line.spark:SetVertexColor (1, 0.7, 0) - - elseif (castinfo.IsChanneled) then - --> casting a channeled spell - local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo ("player") - - if (name) then - startTime = startTime / 1000 - endTime = endTime / 1000 + --> is being casted? + if (castinfo.HasCastTime) then + if (castinfo.Success) then + --> okey it's done + castinfo.Done = true + castinfo.Percent = 100 + line.statusbar:SetValue (100) + line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0) + --line.spark:Hide() - local diff = endTime - startTime - local current = GetTime() - startTime - local percent = current / diff * 100 - percent = math.abs (percent - 100) - castinfo.Percent = percent - line.statusbar:SetValue (percent) - if (StreamOverlay.db.use_spark) then - line.spark:Show() - else - line.spark:Hide() + elseif (castinfo.Interrupted) then + --> has been interrupted + castinfo.Done = true + line.spark:SetVertexColor (1, 0.7, 0) + + elseif (castinfo.IsChanneled) then + --> casting a channeled spell + 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 + percent = math.abs (percent - 100) + castinfo.Percent = percent + line.statusbar:SetValue (percent) + if (StreamOverlay.db.use_spark) then + line.spark:Show() + else + line.spark:Hide() + end + line.spark:SetVertexColor (1, 1, 1, 0.5 + (percent/100)) + line.spark:SetVertexColor (1, 1, 1, 1) + line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0) + end + + else + --> still casting + 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 + line.statusbar:SetValue (percent) + if (StreamOverlay.db.use_spark) then + line.spark:Show() + else + line.spark:Hide() + end + line.spark:SetVertexColor (1, 1, 1, 0.5 + (percent/100)) + line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0) end - line.spark:SetVertexColor (1, 1, 1, 0.5 + (percent/100)) - line.spark:SetVertexColor (1, 1, 1, 1) - line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0) end - + else - --> still casting - local spell, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo ("player") - if (spell) then - startTime = startTime / 1000 - endTime = endTime / 1000 + --> it's instant cast + if (castinfo.CastStart+1.2 < GetTime()) then + castinfo.Done = true + castinfo.Percent = 100 + line.statusbar:SetValue (100) + line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0) + --line.spark:Hide() + else + local startTime = castinfo.CastStart + local endTime = (castinfo.CastStart + 1.2) local diff = endTime - startTime local current = GetTime() - startTime @@ -934,50 +1152,101 @@ listener.track_spell_cast = function() local percent = current / diff * 100 castinfo.Percent = percent line.statusbar:SetValue (percent) + if (StreamOverlay.db.use_spark) then line.spark:Show() else line.spark:Hide() end + line.spark:SetVertexColor (1, 1, 1, 0.5 + (percent/100)) line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0) end end - else - --> it's instant cast - if (castinfo.CastStart+1.2 < GetTime()) then - castinfo.Done = true - castinfo.Percent = 100 - line.statusbar:SetValue (100) - line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * 100) - 8, 0) - --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 - line.statusbar:SetValue (percent) - - if (StreamOverlay.db.use_spark) then - line.spark:Show() + 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] + + if (not castinfo.Done and line) then + + --> is being casted? + if (castinfo.HasCastTime) then + if (castinfo.Success) then + --> okey it's done + castinfo.Done = true + castinfo.Percent = 100 + StreamOverlay:UpdateCooldownFrame(line, false) + + elseif (castinfo.Interrupted) then + --> has been interrupted + castinfo.Done = true + local totalTime = castinfo.CastTimeEnd - castinfo.CastTimeStart + local pct = castinfo.CastTimeEnd - GetTime() + castinfo.InterruptedPct = pct / totalTime + + elseif (castinfo.IsChanneled) then + --> casting a channeled spell + 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 + percent = math.abs (percent - 100) + castinfo.Percent = percent + StreamOverlay:UpdateCooldownFrame(line, true, startTime, endTime, castinfo) + end + else - line.spark:Hide() + --> still casting + 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 - line.spark:SetVertexColor (1, 1, 1, 0.5 + (percent/100)) - line.spark:SetPoint ("left", line.statusbar, "left", (line.statusbar:GetWidth() / 100 * percent) - 6, 0) - end + else + --> it's instant cast + 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 - - line.in_use = GetTime() end - end end @@ -1015,7 +1284,7 @@ function listener:UnregisterMyEvents() listener:UnregisterEvent ("UNIT_SPELLCAST_STOP") end -local lastspell, lastcastid, lastchannelid, ischanneling +local lastspell, lastcastid, lastchannelid, ischanneling, lastspellID local channelspells = {} local lastChannelSpell = "" @@ -1034,17 +1303,15 @@ APM_FRAME:SetScript ("OnEvent", function() end) listener:SetScript ("OnEvent", function (self, event, ...) - -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" 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 = ... - spell = GetSpellInfo (spellID) + local spell = GetSpellInfo (spellID) if (unitID == "player") then CastsTable [castGUID] = {Target = target or "", Id = castGUID, CastStart = GetTime()} @@ -1061,7 +1328,12 @@ end if (unitID == "player" and CastsTable [castGUID]) then CastsTable [castGUID].SpellId = spellID CastsTable [castGUID].HasCastTime = true - StreamOverlay:CastStart (castGUID) + + 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 @@ -1070,6 +1342,7 @@ end if (unitID == "player" and CastsTable [castGUID]) then CastsTable [castGUID].Interrupted = true + CastsTable [castGUID].InterruptedTime = GetTime() end --> channels isn't passing the CastID / cast id for channels is always Zero. @@ -1087,6 +1360,7 @@ end end end CastsTable [castGUID].Interrupted = true + CastsTable [castGUID].InterruptedTime = GetTime() ischanneling = false lastchannelid = nil end @@ -1103,6 +1377,7 @@ end if (ischanneling) then --> channel updated CastsTable [lastchannelid].Interrupted = true + CastsTable [lastchannelid].InterruptedTime = GetTime() end if (not CastsTable [castGUID]) then @@ -1114,11 +1389,15 @@ end 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 + local spell = GetSpellInfo(spellID) + channelspells[spell] = true - StreamOverlay:CastStart (castGUID) + StreamOverlay:CastStart(castGUID) end elseif (event == "UNIT_SPELLCAST_SUCCEEDED") then @@ -1156,7 +1435,7 @@ function StreamOverlay.OnDeath (_, token, time, who_serial, who_name, who_flags, for i = 1, #death_table do local ev = death_table [i] - if (ev and ev[1] and type (ev[1]) == "boolean") then + if (ev and type (ev) == "table" and ev[1] and type (ev[1]) == "boolean") then --> it's a damage local spellid = ev[2] local amount = ev[3] @@ -1463,16 +1742,53 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) {value = 1, label = "DPS", onclick = set_attribute}, {value = 2, label = "HPS", onclick = set_attribute}, } - -- + local options = { - + { + get = function() return StreamOverlay.db.use_square_mode end, + set = function (self, fixedParam, value) + StreamOverlay.db.use_square_mode = value + end, + type = "toggle", + name = "Use Square Mode", + desc = "You need to /reload after change.", + }, + { + 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() + end, + min = 10, + max = 256, + step = 1, + desc = "Square Size", + name = "Square Size", + }, + + {type = "space"}, + { 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, - set = function (self, val) + set = function (self, fixedParam, val) StreamOverlay:SetLocked (not StreamOverlay.db.main_frame_locked) end, }, @@ -1572,7 +1888,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "Show in the screen your current Dps or Hps.", order = 1, get = function() return StreamOverlay.db.per_second.enabled end, - set = function (self, val) + set = function (self, fixedParam, val) StreamOverlay.db.per_second.enabled = not StreamOverlay.db.per_second.enabled -- update hps dps frame StreamOverlay:UpdateDpsHpsFrameConfig() @@ -1637,7 +1953,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "Enable text shadow.", order = 1, get = function() return StreamOverlay.db.per_second.font_shadow end, - set = function (self, val) + set = function (self, fixedParam, val) StreamOverlay.db.per_second.font_shadow = not StreamOverlay.db.per_second.font_shadow -- update hps dps frame StreamOverlay:UpdateDpsHpsFrameConfig() @@ -1652,7 +1968,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "Show/Hide minimap icon.", order = 1, get = function() return not StreamOverlay.db.minimap.hide end, - set = function (self, val) + set = function (self, fixedParam, val) StreamOverlay.db.minimap.hide = not StreamOverlay.db.minimap.hide if (LDBIcon) then LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap) @@ -1754,7 +2070,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "Show or hide the spark at bars", order = 1, get = function() return StreamOverlay.db.use_spark end, - set = function (self, val) + set = function (self, fixedParam, val) StreamOverlay.db.use_spark = not StreamOverlay.db.use_spark @@ -1890,6 +2206,11 @@ function StreamOverlay:OnEvent (_, event, ...) local MINIMAL_DETAILS_VERSION_REQUIRED = 80 local default_options_table = { + + use_square_mode = false, + square_size = 32, + square_amount = 5, + main_frame_locked = false, main_frame_color = {0, 0, 0, .2}, main_frame_size = {250, 230}, @@ -1909,6 +2230,8 @@ function StreamOverlay:OnEvent (_, event, ...) arrow_anchor_y = 0, minimap = {hide = false, radius = 160, minimapPos = 160}, + + grow_direction = "right", use_spark = true, @@ -2012,9 +2335,6 @@ function StreamOverlay:OnEvent (_, event, ...) _detalhes.table.deploy (ptable, StreamOverlay.db) --local settings deploy stuff which non exist on profile Details_StreamerDB.profiles [ Details_StreamerDB.characters [pname] ] = ptable - - - end end