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.

866 lines
31 KiB

4 years ago
local Details = _G.Details
local C_Timer = _G.C_Timer
local libwindow = LibStub("LibWindow-1.1")
function Details:OpenEventTrackerOptions(bFromOptionsPanel)
4 years ago
if (not _G.DetailsEventTrackerOptions) then
local DF = DetailsFramework
local optionsPanel = DF:CreateSimplePanel(UIParent, 700, 400, "Details! Event Tracker Options", "DetailsEventTrackerOptions")
optionsPanel:SetPoint("center", _G.UIParent, "center")
optionsPanel:SetScript("OnMouseDown", nil)
optionsPanel:SetScript("OnMouseUp", nil)
local LibWindow = LibStub("LibWindow-1.1")
LibWindow.RegisterConfig(optionsPanel, _detalhes.event_tracker.options_frame)
LibWindow.MakeDraggable(optionsPanel)
LibWindow.RestorePosition(optionsPanel)
3 years ago
local options_text_template = DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = DF:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = DF:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")
3 years ago
--frame strata options
local set_frame_strata = function(_, _, strata)
4 years ago
Details.event_tracker.frame.strata = strata
Details:UpdateEventTrackerFrame()
end
local strataTable = {}
strataTable [1] = {value = "BACKGROUND", label = "BACKGROUND", onclick = set_frame_strata}
strataTable [2] = {value = "LOW", label = "LOW", onclick = set_frame_strata}
strataTable [3] = {value = "MEDIUM", label = "MEDIUM", onclick = set_frame_strata}
strataTable [4] = {value = "HIGH", label = "HIGH", onclick = set_frame_strata}
strataTable [5] = {value = "DIALOG", label = "DIALOG", onclick = set_frame_strata}
3 years ago
--font options
local set_font_shadow= function(_, _, shadow)
4 years ago
Details.event_tracker.font_shadow = shadow
Details:UpdateEventTrackerFrame()
end
local fontShadowTable = {}
fontShadowTable [1] = {value = "NONE", label = "None", onclick = set_font_shadow}
fontShadowTable [2] = {value = "OUTLINE", label = "Outline", onclick = set_font_shadow}
fontShadowTable [3] = {value = "THICKOUTLINE", label = "Thick Outline", onclick = set_font_shadow}
3 years ago
local on_select_text_font = function(self, fixed_value, value)
4 years ago
Details.event_tracker.font_face = value
Details:UpdateEventTrackerFrame()
end
3 years ago
--texture options
local set_bar_texture = function(_, _, value)
4 years ago
Details.event_tracker.line_texture = value
Details:UpdateEventTrackerFrame()
end
4 years ago
local SharedMedia = _G.LibStub:GetLibrary ("LibSharedMedia-3.0")
local textures = SharedMedia:HashTable ("statusbar")
local texTable = {}
for name, texturePath in pairs(textures) do
4 years ago
texTable [#texTable + 1] = {value = name, label = name, statusbar = texturePath, onclick = set_bar_texture}
end
3 years ago
table.sort (texTable, function(t1, t2) return t1.label < t2.label end)
3 years ago
--options table
4 years ago
local options = {
always_boxfirst = true,
--language_addonId = addonId,
3 years ago
{type = "label", get = function() return "Frame Settings:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")},
4 years ago
--enabled
{
type = "toggle",
get = function() return Details.event_tracker.enabled end,
3 years ago
set = function(self, fixedparam, value)
4 years ago
Details.event_tracker.enabled = not Details.event_tracker.enabled
Details:LoadFramesForBroadcastTools()
end,
desc = "Enabled",
name = "Enabled",
text_template = options_text_template,
},
--locked
{
type = "toggle",
get = function() return Details.event_tracker.frame.locked end,
set = function(self, fixedparam, value)
4 years ago
Details.event_tracker.frame.locked = not Details.event_tracker.frame.locked
Details:UpdateEventTrackerFrame()
end,
desc = "Locked",
name = "Locked",
text_template = options_text_template,
},
--showtitle
{
type = "toggle",
get = function() return Details.event_tracker.frame.show_title end,
set = function(self, fixedparam, value)
4 years ago
Details.event_tracker.frame.show_title = not Details.event_tracker.frame.show_title
Details:UpdateEventTrackerFrame()
end,
desc = "Show Title",
name = "Show Title",
text_template = options_text_template,
},
--backdrop color
{
type = "color",
get = function()
return {Details.event_tracker.frame.backdrop_color[1], Details.event_tracker.frame.backdrop_color[2], Details.event_tracker.frame.backdrop_color[3], Details.event_tracker.frame.backdrop_color[4]}
4 years ago
end,
set = function(self, r, g, b, a)
4 years ago
local color = Details.event_tracker.frame.backdrop_color
color[1], color[2], color[3], color[4] = r, g, b, a
Details:UpdateEventTrackerFrame()
end,
desc = "Backdrop Color",
name = "Backdrop Color",
text_template = options_text_template,
},
--statra
{
type = "select",
get = function() return Details.event_tracker.frame.strata end,
values = function() return strataTable end,
name = "Frame Strata"
},
{type = "breakline"},
3 years ago
{type = "label", get = function() return "Line Settings:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")},
4 years ago
--line height
{
type = "range",
get = function() return Details.event_tracker.line_height end,
set = function(self, fixedparam, value)
4 years ago
Details.event_tracker.line_height = value
Details:UpdateEventTrackerFrame()
end,
min = 4,
max = 32,
step = 1,
name = "Line Height",
text_template = options_text_template,
},
--line texture
{
type = "select",
get = function() return Details.event_tracker.line_texture end,
values = function() return texTable end,
name = "Line Texture",
},
--line color
{
type = "color",
get = function()
return {Details.event_tracker.line_color[1], Details.event_tracker.line_color[2], Details.event_tracker.line_color[3], Details.event_tracker.line_color[4]}
4 years ago
end,
set = function(self, r, g, b, a)
4 years ago
local color = Details.event_tracker.line_color
color[1], color[2], color[3], color[4] = r, g, b, a
Details:UpdateEventTrackerFrame()
end,
desc = "Line Color",
name = "Line Color",
text_template = options_text_template,
},
--font size
{
type = "range",
get = function() return Details.event_tracker.font_size end,
set = function(self, fixedparam, value)
4 years ago
Details.event_tracker.font_size = value
Details:UpdateEventTrackerFrame()
end,
min = 4,
max = 32,
step = 1,
name = "Font Size",
text_template = options_text_template,
},
--font color
{
type = "color",
get = function()
return {Details.event_tracker.font_color[1], Details.event_tracker.font_color[2], Details.event_tracker.font_color[3], Details.event_tracker.font_color[4]}
4 years ago
end,
set = function(self, r, g, b, a)
4 years ago
local color = Details.event_tracker.font_color
color[1], color[2], color[3], color[4] = r, g, b, a
Details:UpdateEventTrackerFrame()
end,
desc = "Font Color",
name = "Font Color",
text_template = options_text_template,
},
--font shadow
{
type = "select",
get = function() return Details.event_tracker.font_shadow end,
values = function() return fontShadowTable end,
name = "Font Shadow"
},
--font face
{
type = "select",
get = function() return Details.event_tracker.font_face end,
values = function() return DF:BuildDropDownFontList (on_select_text_font) end,
name = "Font Face",
text_template = options_text_template,
},
{type = "blank"},
{
type = "toggle",
get = function() return _detalhes.event_tracker.show_crowdcontrol_pvp end,
set = function(self, fixedparam, value)
_detalhes.event_tracker.show_crowdcontrol_pvp = value
end,
desc = "Show Crowd Control (Arena & BG)",
name = "Show Crowd Control when inside a PvP zone",
text_template = options_text_template,
},
{
type = "toggle",
get = function() return _detalhes.event_tracker.show_crowdcontrol_pvm end,
set = function(self, fixedparam, value)
_detalhes.event_tracker.show_crowdcontrol_pvm = value
end,
desc = "Show Crowd Control (Dungeon & Raid)",
name = "Show Crowd Control when inside a PvE zone",
text_template = options_text_template,
},
4 years ago
}
DF:BuildMenu(optionsPanel, options, 7, -30, 500, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
optionsPanel:SetScript("OnHide", function()
3 years ago
--reopen the options panel
if (optionsPanel.FromOptionsPanel) then
3 years ago
C_Timer.After(0.2, function()
4 years ago
Details:OpenOptionsWindow(Details:GetInstance(1))
end)
end
end)
end
_G.DetailsEventTrackerOptions:RefreshOptions()
_G.DetailsEventTrackerOptions:Show()
_G.DetailsEventTrackerOptions.FromOptionsPanel = bFromOptionsPanel
4 years ago
end
function Details:CreateEventTrackerFrame(parentObject, name)
4 years ago
local DF = _detalhes.gump
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
--> screen frame
local screenFrame = CreateFrame("frame", name, parentObject or UIParent,"BackdropTemplate")
screenFrame:SetPoint("center", UIParent, "center")
4 years ago
if (not DetailsFramework.IsDragonflight() and not DetailsFramework.IsWotLKWowWithRetailAPI()) then
screenFrame:SetMinResize (150, 40)
screenFrame:SetMaxResize (800, 1024)
3 years ago
else
--f:SetResizeBounds(150, 40, 800, 1024)
end
screenFrame:SetSize(_detalhes.event_tracker.frame.width, _detalhes.event_tracker.frame.height)
screenFrame:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
screenFrame:SetBackdropColor(unpack(_detalhes.event_tracker.frame.backdrop_color))
screenFrame:EnableMouse(true)
screenFrame:SetMovable(true)
screenFrame:SetResizable(true)
screenFrame:SetClampedToScreen(true)
3 years ago
local LibWindow = LibStub("LibWindow-1.1")
LibWindow.RegisterConfig(screenFrame, _detalhes.event_tracker.frame)
LibWindow.MakeDraggable(screenFrame)
LibWindow.RestorePosition(screenFrame)
--> two resizers
local leftResize, rightResize = DF:CreateResizeGrips(screenFrame)
leftResize:SetScript("OnMouseDown", function(self)
if (not screenFrame.resizing and not _detalhes.event_tracker.frame.locked) then
screenFrame.resizing = true
screenFrame:StartSizing("bottomleft")
4 years ago
end
end)
leftResize:SetScript("OnMouseUp", function(self)
if (screenFrame.resizing) then
screenFrame.resizing = false
screenFrame:StopMovingOrSizing()
_detalhes.event_tracker.frame.width = screenFrame:GetWidth()
_detalhes.event_tracker.frame.height = screenFrame:GetHeight()
4 years ago
end
end)
rightResize:SetScript("OnMouseDown", function(self)
if (not screenFrame.resizing and not _detalhes.event_tracker.frame.locked) then
screenFrame.resizing = true
screenFrame:StartSizing("bottomright")
4 years ago
end
end)
rightResize:SetScript("OnMouseUp", function(self)
if (screenFrame.resizing) then
screenFrame.resizing = false
screenFrame:StopMovingOrSizing()
_detalhes.event_tracker.frame.width = screenFrame:GetWidth()
_detalhes.event_tracker.frame.height = screenFrame:GetHeight()
4 years ago
end
end)
screenFrame:SetScript("OnSizeChanged", function(self)
--on size changed code
4 years ago
end)
--> scroll frame
3 years ago
--frame config
4 years ago
local scroll_line_amount = 1
local scroll_width = 195
local header_size = 20
3 years ago
--on tick script
local lineOnTick = function(self, deltaTime)
--when this event occured on combat log
4 years ago
local gameTime = self.GameTime
3 years ago
--calculate how much time elapsed since the event got triggered
4 years ago
local elapsedTime = GetTime() - gameTime
--set the bar animation
4 years ago
local animationPercent = min (elapsedTime, 1)
3 years ago
self.Statusbar:SetValue(animationPercent)
3 years ago
--set the spark location
4 years ago
if (animationPercent < 1) then
3 years ago
self.Spark:SetPoint("left", self, "left", (self:GetWidth() * animationPercent) - 10, 0)
4 years ago
if (not self.Spark:IsShown()) then
self.Spark:Show()
end
else
if (self.Spark:IsShown()) then
self.Spark:Hide()
end
end
end
3 years ago
--create a line on the scroll frame
local scroll_createline = function(self, index)
local line = CreateFrame("frame", "$parentLine" .. index, self,"BackdropTemplate")
line:EnableMouse(false)
line.Index = index --hack to not trigger error on UpdateWorldTrackerLines since Index is set after this function is ran
3 years ago
--set its backdrop
line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}})
--line:SetBackdropColor(1, 1, 1, 0.75)
3 years ago
--statusbar
local statusbar = CreateFrame("statusbar", "$parentStatusBar", line,"BackdropTemplate")
4 years ago
statusbar:SetAllPoints()
3 years ago
local statusbartexture = statusbar:CreateTexture(nil, "border")
statusbar:SetStatusBarTexture(statusbartexture)
statusbar:SetMinMaxValues(0, 1)
statusbar:SetValue(0)
3 years ago
local statusbarspark = statusbar:CreateTexture(nil, "artwork")
statusbarspark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]])
statusbarspark:SetSize(16, 30)
statusbarspark:SetBlendMode("ADD")
4 years ago
statusbarspark:Hide()
3 years ago
--create the icon textures and texts - they are all statusbar childs
local lefticon = statusbar:CreateTexture("$parentLeftIcon", "overlay")
lefticon:SetPoint("left", line, "left", 0, 0)
3 years ago
local righticon = statusbar:CreateTexture("$parentRightIcon", "overlay")
righticon:SetPoint("right", line, "right", 0, 0)
3 years ago
local lefttext = statusbar:CreateFontString("$parentLeftText", "overlay", "GameFontNormal")
DF:SetFontSize(lefttext, 9)
lefttext:SetPoint("left", lefticon, "right", 2, 0)
lefttext.__languageId = "enUS"
3 years ago
local righttext = statusbar:CreateFontString("$parentRightText", "overlay", "GameFontNormal")
DF:SetFontSize(righttext, 9)
righttext:SetPoint("right", righticon, "left", -2, 0)
3 years ago
lefttext:SetJustifyH("left")
righttext:SetJustifyH("right")
3 years ago
local actionicon = statusbar:CreateTexture("$parentRightIcon", "overlay")
actionicon:SetPoint("center", line, "center")
4 years ago
3 years ago
--set members
4 years ago
line.LeftIcon = lefticon
line.RightIcon = righticon
line.LeftText = lefttext
line.RightText = righttext
line.Statusbar = statusbar
line.StatusbarTexture = statusbartexture
line.Spark = statusbarspark
line.ActionIcon = actionicon
3 years ago
--set some parameters
4 years ago
_detalhes:UpdateWorldTrackerLines (line)
3 years ago
--set scripts
line:SetScript("OnUpdate", lineOnTick)
4 years ago
return line
end
3 years ago
--some consts to help work with indexes
4 years ago
local SPELLTYPE_COOLDOWN = "cooldown"
local SPELLTYPE_INTERRUPT = "interrupt"
local SPELLTYPE_OFFENSIVE = "offensive"
local SPELLTYPE_CROWDCONTROL = "crowdcontrol"
4 years ago
local ABILITYTABLE_SPELLTYPE = 1
local ABILITYTABLE_SPELLID = 2
local ABILITYTABLE_CASTERNAME = 3
local ABILITYTABLE_TARGETNAME = 4
local ABILITYTABLE_TIME = 5
local ABILITYTABLE_EXTRASPELLID = 6
local ABILITYTABLE_GAMETIME = 7
local ABILITYTABLE_CASTERSERIAL = 8
local ABILITYTABLE_ISENEMY = 9
local ABILITYTABLE_TARGETSERIAL = 10
local get_spec_or_class = function(serial, unitName)
4 years ago
local class
local spec = _detalhes.cached_specs [serial]
if (not spec) then
local _, engClass = UnitClass(unitName)
4 years ago
if (engClass) then
class = engClass
else
local locClass, engClass, locRace, engRace, gender = GetPlayerInfoByGUID (serial)
if (engClass) then
class = engClass
end
end
end
4 years ago
return spec, class
end
3 years ago
local get_player_icon = function(spec, class)
4 years ago
if (spec) then
3 years ago
return [[Interface\AddOns\Details\images\spec_icons_normal]], unpack(_detalhes.class_specs_coords [spec])
4 years ago
elseif (class) then
3 years ago
return [[Interface\AddOns\Details\images\classes_small]], unpack(_detalhes.class_coords [class])
4 years ago
else
return [[Interface\AddOns\Details\images\classes_plus]], 0.50390625, 0.62890625, 0, 0.125
end
end
local add_role_and_class_color = function(unitName, unitSerial)
3 years ago
--get the actor object
local actor = _detalhes.tabela_vigente[1]:GetActor(unitName)
4 years ago
if (actor) then
3 years ago
--remove realm name
unitName = _detalhes:GetOnlyName(unitName)
4 years ago
local class, spec, role = actor.classe, actor.spec, actor.role
if (not class) then
spec, class = get_spec_or_class (unitSerial, unitName)
4 years ago
end
3 years ago
--add the class color
4 years ago
if (_detalhes.player_class [class]) then
3 years ago
--is a player, add the class color
unitName = _detalhes:AddColorString (unitName, class)
4 years ago
end
4 years ago
--add the role icon
if (role ~= "NONE") then
3 years ago
--have a role
unitName = _detalhes:AddRoleIcon (unitName, role, _detalhes.event_tracker.line_height)
4 years ago
end
4 years ago
else
local spec, class = get_spec_or_class (unitSerial, unitName)
unitName = _detalhes:GetOnlyName(unitName)
4 years ago
if (class) then
3 years ago
--add the class color
4 years ago
if (_detalhes.player_class [class]) then
3 years ago
--is a player, add the class color
unitName = _detalhes:AddColorString (unitName, class)
4 years ago
end
end
end
return unitName
4 years ago
end
4 years ago
local get_text_size = function()
local iconsSpace = _detalhes.event_tracker.line_height * 3
local textSpace = 4
local saveSpace = 14
local availableSpace = (screenFrame:GetWidth() - iconsSpace - textSpace - saveSpace) / 2
4 years ago
return availableSpace
end
3 years ago
local shrink_string = function(fontstring, size)
4 years ago
local text = fontstring:GetText()
local loops = 20
while (fontstring:GetStringWidth() > size and loops > 0) do
text = strsub (text, 1, #text-1)
3 years ago
fontstring:SetText(text)
4 years ago
loops = loops - 1
end
4 years ago
return fontstring
end
4 years ago
--refresh the scroll frame
3 years ago
local scroll_refresh = function(self, data, offset, total_lines)
4 years ago
local textSize = get_text_size()
4 years ago
for i = 1, total_lines do
local index = i + offset
local ability = data [index]
4 years ago
if (ability) then
local line = self:GetLine (i)
4 years ago
local spec, class = get_spec_or_class (ability [ABILITYTABLE_CASTERSERIAL], ability [ABILITYTABLE_CASTERNAME])
local texture, L, R, T, B = get_player_icon (spec, class)
3 years ago
line.LeftIcon:SetTexture(texture)
line.LeftIcon:SetTexCoord(L, R, T, B)
local sourceName = ability[ABILITYTABLE_CASTERNAME]
--[=[language system test
if (math.random(3) == 2) then
sourceName = "Снизуслева"
elseif (math.random(3) == 3) then
sourceName = "質下方的材質"
elseif (math.random(4) == 1) then
sourceName = "주문 별 받은 피해"
end
--]=]
local sourceNameNoRealm = _detalhes:GetOnlyName(sourceName)
--need to use the language system from details framework to detect which language is being used
local languageId = DF.Language.DetectLanguageId(sourceNameNoRealm)
--print("lenaguage detected:", languageId, sourceNameNoRealm)
if (languageId ~= line.LeftText.__languageId) then
--get a font to use with this language
local fontPath = DF.Language.GetFontForLanguageID(languageId)
if (fontPath) then
if (languageId == "enUS") then
DF:SetFontFace(line.LeftText, _detalhes.event_tracker.font_face)
else
DF:SetFontFace(line.LeftText, fontPath)
end
line.LeftText.__languageId = languageId
end
end
line.LeftText:SetText(sourceNameNoRealm)
4 years ago
if (ability [ABILITYTABLE_ISENEMY]) then
3 years ago
line:SetBackdropColor(1, .3, .3, 0.5)
4 years ago
else
3 years ago
line:SetBackdropColor(1, 1, 1, 0.5)
4 years ago
end
4 years ago
if (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_COOLDOWN) then
3 years ago
local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID])
line.RightIcon:SetTexture(spellIcon)
line.RightIcon:SetTexCoord(.06, .94, .06, .94)
4 years ago
local targetName = ability [ABILITYTABLE_TARGETNAME]
if (targetName) then
local targetSerial = ability [ABILITYTABLE_TARGETSERIAL]
targetName = add_role_and_class_color (targetName, targetSerial)
end
3 years ago
line.RightText:SetText(targetName or spellName)
3 years ago
line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]])
line.ActionIcon:SetTexCoord(0, 0.125, 0, 1)
4 years ago
elseif (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_OFFENSIVE) then
3 years ago
local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID])
line.RightIcon:SetTexture(spellIcon)
line.RightIcon:SetTexCoord(.06, .94, .06, .94)
line.RightText:SetText(spellName)
3 years ago
line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]])
line.ActionIcon:SetTexCoord(0.127, 0.25, 0, 1)
4 years ago
elseif (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_INTERRUPT) then
3 years ago
local spellNameInterrupted, _, spellIconInterrupted = GetSpellInfo(ability [ABILITYTABLE_EXTRASPELLID])
line.RightIcon:SetTexture(spellIconInterrupted)
line.RightIcon:SetTexCoord(.06, .94, .06, .94)
line.RightText:SetText(spellNameInterrupted)
3 years ago
line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]])
line.ActionIcon:SetTexCoord(0.251, 0.375, 0, 1)
4 years ago
elseif (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_CROWDCONTROL) then
3 years ago
local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID])
line.RightIcon:SetTexture(spellIcon)
line.RightIcon:SetTexCoord(.06, .94, .06, .94)
4 years ago
local targetName = ability [ABILITYTABLE_TARGETNAME]
if (targetName) then
local targetSerial = ability [ABILITYTABLE_TARGETSERIAL]
targetName = add_role_and_class_color (targetName, targetSerial)
end
line.RightText:SetText(targetName or spellName or "")
3 years ago
line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]])
line.ActionIcon:SetTexCoord(0.376, 0.5, 0, 1)
4 years ago
end
4 years ago
shrink_string (line.LeftText, textSize)
shrink_string (line.RightText, textSize)
3 years ago
--set when the ability was registered on combat log
4 years ago
line.GameTime = ability [ABILITYTABLE_GAMETIME]
line:Show()
end
end
end
4 years ago
--title text
local TitleString = screenFrame:CreateFontString(nil, "overlay", "GameFontNormal")
TitleString:SetPoint("top", screenFrame, "top", 0, -3)
3 years ago
TitleString:SetText("Details!: Event Tracker")
local TitleBackground = screenFrame:CreateTexture(nil, "artwork")
3 years ago
TitleBackground:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
TitleBackground:SetVertexColor(.1, .1, .1, .9)
TitleBackground:SetPoint("topleft", screenFrame, "topleft")
TitleBackground:SetPoint("topright", screenFrame, "topright")
3 years ago
TitleBackground:SetHeight(header_size)
3 years ago
--table with spells showing on the scroll frame
4 years ago
local CurrentShowing = {}
3 years ago
--scrollframe
local scrollframe = DF:CreateScrollBox (screenFrame, "$parentScrollFrame", scroll_refresh, CurrentShowing, scroll_width, 400, scroll_line_amount, _detalhes.event_tracker.line_height, scroll_createline, true, true)
scrollframe:SetPoint("topleft", screenFrame, "topleft", 0, -header_size)
scrollframe:SetPoint("topright", screenFrame, "topright", 0, -header_size)
scrollframe:SetPoint("bottomleft", screenFrame, "bottomleft", 0, 0)
scrollframe:SetPoint("bottomright", screenFrame, "bottomright", 0, 0)
3 years ago
--update line - used by 'UpdateWorldTrackerLines' function
local update_line = function(line)
3 years ago
--get the line index
4 years ago
local index = line.Index
3 years ago
--update left text
DF:SetFontColor(line.LeftText, _detalhes.event_tracker.font_color)
4 years ago
DF:SetFontFace (line.LeftText, _detalhes.event_tracker.font_face)
3 years ago
DF:SetFontSize(line.LeftText, _detalhes.event_tracker.font_size)
4 years ago
DF:SetFontOutline (line.LeftText, _detalhes.event_tracker.font_shadow)
3 years ago
--update right text
DF:SetFontColor(line.RightText, _detalhes.event_tracker.font_color)
4 years ago
DF:SetFontFace (line.RightText, _detalhes.event_tracker.font_face)
3 years ago
DF:SetFontSize(line.RightText, _detalhes.event_tracker.font_size)
4 years ago
DF:SetFontOutline (line.RightText, _detalhes.event_tracker.font_shadow)
3 years ago
--adjust where the line is anchored
line:SetPoint("topleft", line:GetParent(), "topleft", 1, -0.5 -((index-1)*(_detalhes.event_tracker.line_height+1)))
line:SetPoint("topright", line:GetParent(), "topright", -1, -0.5 -((index-1)*(_detalhes.event_tracker.line_height+1)))
3 years ago
--set its height
line:SetHeight(_detalhes.event_tracker.line_height)
3 years ago
--set texture
4 years ago
local texture = SharedMedia:Fetch ("statusbar", _detalhes.event_tracker.line_texture)
3 years ago
line.StatusbarTexture:SetTexture(texture)
line.StatusbarTexture:SetVertexColor(unpack(_detalhes.event_tracker.line_color))
3 years ago
--set icon size
line.LeftIcon:SetSize(_detalhes.event_tracker.line_height, _detalhes.event_tracker.line_height)
line.RightIcon:SetSize(_detalhes.event_tracker.line_height, _detalhes.event_tracker.line_height)
line.ActionIcon:SetSize(_detalhes.event_tracker.line_height-4, _detalhes.event_tracker.line_height-4)
line.ActionIcon:SetAlpha(0.65)
4 years ago
end
4 years ago
-- /run _detalhes.event_tracker.font_shadow = 24
-- /run _detalhes:UpdateWorldTrackerLines()
4 years ago
function _detalhes:UpdateWorldTrackerLines (line)
3 years ago
--don't run if the featured hasn't loaded
if (not screenFrame) then
4 years ago
return
end
4 years ago
if (line) then
update_line (line)
else
3 years ago
--update all lines
for index, line in ipairs(scrollframe:GetFrames()) do
4 years ago
update_line (line)
end
scrollframe:SetFramesHeight (_detalhes.event_tracker.line_height)
scrollframe:Refresh()
end
end
4 years ago
function _detalhes:UpdateEventTrackerFrame()
3 years ago
--don't run if the featured hasn't loaded
if (not screenFrame) then
4 years ago
return
end
screenFrame:SetSize(_detalhes.event_tracker.frame.width, _detalhes.event_tracker.frame.height)
LibWindow.RegisterConfig(screenFrame, _detalhes.event_tracker.frame)
LibWindow.RestorePosition(screenFrame)
4 years ago
scrollframe:OnSizeChanged()
4 years ago
if (_detalhes.event_tracker.frame.locked) then
screenFrame:EnableMouse(false)
leftResize:Hide()
rightResize:Hide()
4 years ago
else
screenFrame:EnableMouse(true)
leftResize:Show()
rightResize:Show()
4 years ago
end
4 years ago
if (_detalhes.event_tracker.frame.show_title) then
TitleString:Show()
TitleBackground:Show()
scrollframe:SetPoint("topleft", screenFrame, "topleft", 0, -header_size)
scrollframe:SetPoint("topright", screenFrame, "topright", 0, -header_size)
4 years ago
else
TitleString:Hide()
TitleBackground:Hide()
scrollframe:SetPoint("topleft", screenFrame, "topleft", 0, 0)
scrollframe:SetPoint("topright", screenFrame, "topright", 0, 0)
4 years ago
end
screenFrame:SetBackdropColor(unpack(_detalhes.event_tracker.frame.backdrop_color))
3 years ago
scrollframe.__background:SetVertexColor(unpack(_detalhes.event_tracker.frame.backdrop_color))
screenFrame:SetFrameStrata(_detalhes.event_tracker.frame.strata)
4 years ago
_detalhes:UpdateWorldTrackerLines()
scrollframe:Refresh()
end
4 years ago
--create the first line
for i = 1, 1 do
4 years ago
scrollframe:CreateLine (scroll_createline)
end
screenFrame.scrollframe = scrollframe
3 years ago
scrollframe:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16})
scrollframe:SetBackdropColor(0, 0, 0, 0)
3 years ago
--get tables used inside the combat parser
4 years ago
local cooldownListFromFramework = DetailsFramework.CooldownsAllDeffensive
local attackCooldownsFromFramework = DetailsFramework.CooldownsAttack
local crowdControlFromFramework = DetailsFramework.CrowdControlSpells
3 years ago
local combatLog = CreateFrame("frame")
combatLog:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
4 years ago
local OBJECT_TYPE_PLAYER = 0x00000400
local OBJECT_TYPE_ENEMY = 0x00000040
3 years ago
--combat parser
local is_player = function(flag)
4 years ago
if (not flag) then
return false
end
3 years ago
return bit.band(flag, OBJECT_TYPE_PLAYER) ~= 0
4 years ago
end
3 years ago
local is_enemy = function(flag)
4 years ago
if (not flag) then
return false
end
3 years ago
return bit.band(flag, OBJECT_TYPE_ENEMY) ~= 0
4 years ago
end
local defensiveCDType = {
[2] = true,
[3] = true,
[4] = true,
}
3 years ago
combatLog:SetScript("OnEvent", function(self, event)
4 years ago
local time, token, hidding, caster_serial, caster_name, caster_flags, caster_flags2, target_serial, target_name, target_flags, target_flags2, spellid, spellname, spelltype, extraSpellID, extraSpellName, extraSchool = CombatLogGetCurrentEventInfo()
local added = false
--get the spell info from the Open Raid Lib
local spellInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellid]
3 years ago
--defensive cooldown
if (token == "SPELL_CAST_SUCCESS" and (spellInfo and defensiveCDType[spellInfo.type]) and is_player (caster_flags)) then
3 years ago
tinsert(CurrentShowing, 1, {SPELLTYPE_COOLDOWN, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial})
4 years ago
added = true
3 years ago
--offensive cooldown
elseif (token == "SPELL_CAST_SUCCESS" and (spellInfo and spellInfo.type == 1 and spellInfo.cooldown and spellInfo.cooldown >= 90) and is_player (caster_flags)) then
3 years ago
tinsert(CurrentShowing, 1, {SPELLTYPE_OFFENSIVE, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial})
4 years ago
added = true
3 years ago
--crowd control
elseif (token == "SPELL_CAST_SUCCESS" and spellInfo and spellInfo.type == 8) then
4 years ago
--check if isnt a pet
if (caster_flags and is_player(caster_flags)) then
--the target is a player
if (_detalhes.event_tracker.show_crowdcontrol_pvp) then
if (_detalhes.zone_type == "arena" or _detalhes.zone_type == "pvp" or _detalhes.zone_type == "none") then
tinsert(CurrentShowing, 1, {SPELLTYPE_CROWDCONTROL, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial})
added = true
end
end
if (_detalhes.event_tracker.show_crowdcontrol_pvm) then
if (_detalhes.zone_type == "party" or _detalhes.zone_type == "raid") then
tinsert(CurrentShowing, 1, {SPELLTYPE_CROWDCONTROL, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial})
added = true
end
end
4 years ago
end
3 years ago
--spell interrupt
4 years ago
elseif (token == "SPELL_INTERRUPT") then
if (caster_flags and is_player (caster_flags)) then
tinsert(CurrentShowing, 1, {SPELLTYPE_INTERRUPT, spellid, caster_name, target_name, time, extraSpellID, GetTime(), caster_serial, is_enemy (caster_flags), target_serial})
added = true
end
4 years ago
end
4 years ago
if (added) then
local amountOfLines = scrollframe:GetNumFramesShown()
local amountToShow = #CurrentShowing
4 years ago
if (amountToShow > amountOfLines) then
3 years ago
tremove(CurrentShowing, amountToShow)
4 years ago
end
scrollframe:Refresh()
end
4 years ago
end)
4 years ago
_detalhes.Broadcaster_EventTrackerLoaded = true
_detalhes.Broadcaster_EventTrackerFrame = screenFrame
screenFrame:Hide()
4 years ago
end