From 17ef2644838ba6fb5946db9be12bb6de9b676c50 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 28 Feb 2023 21:53:59 -0300 Subject: [PATCH] big update on Event Tracker --- Libs/DF/languages.lua | 32 +- frames/window_eventtracker.lua | 550 +++++++++++++++++++-------------- 2 files changed, 339 insertions(+), 243 deletions(-) diff --git a/Libs/DF/languages.lua b/Libs/DF/languages.lua index 2c054cf6..c65de24d 100644 --- a/Libs/DF/languages.lua +++ b/Libs/DF/languages.lua @@ -187,9 +187,9 @@ local fontLanguageCompatibility = { ["itIT"] = 1, ["ptBR"] = 1, ["zhCN"] = 2, - ["zhTW"] = 2, - ["koKR"] = 3, - ["ruRU"] = 4, + ["zhTW"] = 3, + ["koKR"] = 4, + ["ruRU"] = 5, } --this table contains all the registered languages with their name and fonts @@ -210,18 +210,40 @@ local languagesAvailable = { zhTW = {text = "繁體中文", font = [[Fonts\blei00d.TTF]]}, } +local ignoredCharacters = {} +local punctuations = ".,;:!?-–—()[]{}'\"`/\\@_+*^%$#&~=<>|" +for character in punctuations:gmatch("[%z\1-\127\194-\244][\128-\191]*") do + ignoredCharacters[character] = true +end + +local accentedLetters = "áàâäãåæçéèêëíìîïñóòôöõøœúùûüýÿ" +for character in accentedLetters:gmatch("[%z\1-\127\194-\244][\128-\191]*") do + ignoredCharacters[character] = true +end + --store a list of letters, characters and symbols used on each language ---@type table DF.LanguageKnowledge = DF.LanguageKnowledge or {} +local latinAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +for character in latinAlphabet:gmatch("[%z\1-\127\194-\244][\128-\191]*") do + DF.LanguageKnowledge[character] = CONST_LANGUAGEID_ENUS +end + ---register the letters and symbols used on phrases ---@param languageId any ---@param languageTable any local registerCharacters = function(languageId, languageTable) for stringId, textString in pairs(languageTable) do for character in textString:gmatch("[%z\1-\127\194-\244][\128-\191]*") do - if (not DF.LanguageKnowledge[character]) then - DF.LanguageKnowledge[character] = languageId + if (not ignoredCharacters[character]) then + if (not DF.LanguageKnowledge[character]) then + if (fontLanguageCompatibility[languageId] == 1) then + DF.LanguageKnowledge[character] = CONST_LANGUAGEID_ENUS + else + DF.LanguageKnowledge[character] = languageId + end + end end end end diff --git a/frames/window_eventtracker.lua b/frames/window_eventtracker.lua index 38b650f7..d02f9315 100644 --- a/frames/window_eventtracker.lua +++ b/frames/window_eventtracker.lua @@ -1,30 +1,29 @@ - local Details = _G.Details local C_Timer = _G.C_Timer local libwindow = LibStub("LibWindow-1.1") -function Details:OpenEventTrackerOptions (from_options_panel) - +function Details:OpenEventTrackerOptions(bFromOptionsPanel) if (not _G.DetailsEventTrackerOptions) then - - local DF = _detalhes.gump - - local f = DF:CreateSimplePanel(_G.UIParent, 700, 400, "Details! Event Tracker Options", "DetailsEventTrackerOptions") - f:SetPoint("center", _G.UIParent, "center") - f:SetScript("OnMouseDown", nil) - f:SetScript("OnMouseUp", nil) - local LibWindow = _G.LibStub("LibWindow-1.1") - LibWindow.RegisterConfig(f, _detalhes.event_tracker.options_frame) - LibWindow.MakeDraggable(f) - LibWindow.RestorePosition(f) - + + 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) + 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") - + --frame strata options local set_frame_strata = function(_, _, strata) Details.event_tracker.frame.strata = strata @@ -36,7 +35,7 @@ function Details:OpenEventTrackerOptions (from_options_panel) 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} - + --font options local set_font_shadow= function(_, _, shadow) Details.event_tracker.font_shadow = shadow @@ -46,29 +45,31 @@ function Details:OpenEventTrackerOptions (from_options_panel) 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} - + local on_select_text_font = function(self, fixed_value, value) Details.event_tracker.font_face = value Details:UpdateEventTrackerFrame() end - + --texture options - local set_bar_texture = function(_, _, value) + local set_bar_texture = function(_, _, value) Details.event_tracker.line_texture = value Details:UpdateEventTrackerFrame() end - + local SharedMedia = _G.LibStub:GetLibrary ("LibSharedMedia-3.0") local textures = SharedMedia:HashTable ("statusbar") local texTable = {} - for name, texturePath in pairs(textures) do + for name, texturePath in pairs(textures) do texTable [#texTable + 1] = {value = name, label = name, statusbar = texturePath, onclick = set_bar_texture} end table.sort (texTable, function(t1, t2) return t1.label < t2.label end) - + --options table local options = { - + always_boxfirst = true, + --language_addonId = addonId, + {type = "label", get = function() return "Frame Settings:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")}, --enabled { @@ -86,7 +87,7 @@ function Details:OpenEventTrackerOptions (from_options_panel) { type = "toggle", get = function() return Details.event_tracker.frame.locked end, - set = function(self, fixedparam, value) + set = function(self, fixedparam, value) Details.event_tracker.frame.locked = not Details.event_tracker.frame.locked Details:UpdateEventTrackerFrame() end, @@ -98,7 +99,7 @@ function Details:OpenEventTrackerOptions (from_options_panel) { type = "toggle", get = function() return Details.event_tracker.frame.show_title end, - set = function(self, fixedparam, value) + set = function(self, fixedparam, value) Details.event_tracker.frame.show_title = not Details.event_tracker.frame.show_title Details:UpdateEventTrackerFrame() end, @@ -109,10 +110,10 @@ function Details:OpenEventTrackerOptions (from_options_panel) --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]} + 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]} end, - set = function(self, r, g, b, a) + set = function(self, r, g, b, a) local color = Details.event_tracker.frame.backdrop_color color[1], color[2], color[3], color[4] = r, g, b, a Details:UpdateEventTrackerFrame() @@ -134,7 +135,7 @@ function Details:OpenEventTrackerOptions (from_options_panel) { type = "range", get = function() return Details.event_tracker.line_height end, - set = function(self, fixedparam, value) + set = function(self, fixedparam, value) Details.event_tracker.line_height = value Details:UpdateEventTrackerFrame() end, @@ -154,10 +155,10 @@ function Details:OpenEventTrackerOptions (from_options_panel) --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]} + 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]} end, - set = function(self, r, g, b, a) + set = function(self, r, g, b, a) local color = Details.event_tracker.line_color color[1], color[2], color[3], color[4] = r, g, b, a Details:UpdateEventTrackerFrame() @@ -170,7 +171,7 @@ function Details:OpenEventTrackerOptions (from_options_panel) { type = "range", get = function() return Details.event_tracker.font_size end, - set = function(self, fixedparam, value) + set = function(self, fixedparam, value) Details.event_tracker.font_size = value Details:UpdateEventTrackerFrame() end, @@ -183,10 +184,10 @@ function Details:OpenEventTrackerOptions (from_options_panel) --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]} + 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]} end, - set = function(self, r, g, b, a) + set = function(self, r, g, b, a) local color = Details.event_tracker.font_color color[1], color[2], color[3], color[4] = r, g, b, a Details:UpdateEventTrackerFrame() @@ -210,13 +211,36 @@ function Details:OpenEventTrackerOptions (from_options_panel) 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, + }, } - DF:BuildMenu (f, options, 7, -30, 500, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template) - - f:SetScript("OnHide", function() + 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() --reopen the options panel - if (f.FromOptionsPanel) then + if (optionsPanel.FromOptionsPanel) then C_Timer.After(0.2, function() Details:OpenOptionsWindow(Details:GetInstance(1)) end) @@ -226,97 +250,93 @@ function Details:OpenEventTrackerOptions (from_options_panel) _G.DetailsEventTrackerOptions:RefreshOptions() _G.DetailsEventTrackerOptions:Show() - _G.DetailsEventTrackerOptions.FromOptionsPanel = from_options_panel + _G.DetailsEventTrackerOptions.FromOptionsPanel = bFromOptionsPanel end -function Details:CreateEventTrackerFrame(parent, name) - +function Details:CreateEventTrackerFrame(parentObject, name) local DF = _detalhes.gump local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0") - - --main farame - local f = CreateFrame("frame", name, parent or UIParent,"BackdropTemplate") - f:SetPoint("center", UIParent, "center") + + --> screen frame + local screenFrame = CreateFrame("frame", name, parentObject or UIParent,"BackdropTemplate") + screenFrame:SetPoint("center", UIParent, "center") if (not DetailsFramework.IsDragonflight() and not DetailsFramework.IsWotLKWowWithRetailAPI()) then - f:SetMinResize (150, 40) - f:SetMaxResize (800, 1024) + screenFrame:SetMinResize (150, 40) + screenFrame:SetMaxResize (800, 1024) else --f:SetResizeBounds(150, 40, 800, 1024) end - f:SetSize(_detalhes.event_tracker.frame.width, _detalhes.event_tracker.frame.height) + 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) - f:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}) - f:SetBackdropColor(unpack(_detalhes.event_tracker.frame.backdrop_color)) - f:EnableMouse(true) - f:SetMovable(true) - f:SetResizable(true) - f:SetClampedToScreen(true) - local LibWindow = LibStub("LibWindow-1.1") - LibWindow.RegisterConfig(f, _detalhes.event_tracker.frame) - LibWindow.MakeDraggable(f) - LibWindow.RestorePosition(f) - - --two resizers - - local left_resize, right_resize = DF:CreateResizeGrips (f) - - left_resize:SetScript("OnMouseDown", function(self) - if (not f.resizing and not _detalhes.event_tracker.frame.locked) then - f.resizing = true - f:StartSizing("bottomleft") + 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") end end) - left_resize:SetScript("OnMouseUp", function(self) - if (f.resizing) then - f.resizing = false - f:StopMovingOrSizing() - _detalhes.event_tracker.frame.width = f:GetWidth() - _detalhes.event_tracker.frame.height = f:GetHeight() + 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() end end) - right_resize:SetScript("OnMouseDown", function(self) - if (not f.resizing and not _detalhes.event_tracker.frame.locked) then - f.resizing = true - f:StartSizing("bottomright") + rightResize:SetScript("OnMouseDown", function(self) + if (not screenFrame.resizing and not _detalhes.event_tracker.frame.locked) then + screenFrame.resizing = true + screenFrame:StartSizing("bottomright") end end) - right_resize:SetScript("OnMouseUp", function(self) - if (f.resizing) then - f.resizing = false - f:StopMovingOrSizing() - _detalhes.event_tracker.frame.width = f:GetWidth() - _detalhes.event_tracker.frame.height = f:GetHeight() + 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() end end) - - f:SetScript("OnSizeChanged", function(self) - + + screenFrame:SetScript("OnSizeChanged", function(self) + --on size changed code end) - - --scroll frame - + + --> scroll frame --frame config - local scroll_line_amount = 1 local scroll_width = 195 local header_size = 20 - + --on tick script local lineOnTick = function(self, deltaTime) --when this event occured on combat log local gameTime = self.GameTime - + --calculate how much time elapsed since the event got triggered local elapsedTime = GetTime() - gameTime - - --set the bar animation: + + --set the bar animation local animationPercent = min (elapsedTime, 1) self.Statusbar:SetValue(animationPercent) - + --set the spark location if (animationPercent < 1) then self.Spark:SetPoint("left", self, "left", (self:GetWidth() * animationPercent) - 10, 0) @@ -329,18 +349,17 @@ function Details:CreateEventTrackerFrame(parent, name) end end end - + --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 - + --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) - + --statusbar local statusbar = CreateFrame("statusbar", "$parentStatusBar", line,"BackdropTemplate") statusbar:SetAllPoints() @@ -348,31 +367,32 @@ function Details:CreateEventTrackerFrame(parent, name) statusbar:SetStatusBarTexture(statusbartexture) statusbar:SetMinMaxValues(0, 1) statusbar:SetValue(0) - + local statusbarspark = statusbar:CreateTexture(nil, "artwork") statusbarspark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]]) statusbarspark:SetSize(16, 30) statusbarspark:SetBlendMode("ADD") statusbarspark:Hide() - + --create the icon textures and texts - they are all statusbar childs local lefticon = statusbar:CreateTexture("$parentLeftIcon", "overlay") lefticon:SetPoint("left", line, "left", 0, 0) - + local righticon = statusbar:CreateTexture("$parentRightIcon", "overlay") righticon:SetPoint("right", line, "right", 0, 0) - + local lefttext = statusbar:CreateFontString("$parentLeftText", "overlay", "GameFontNormal") DF:SetFontSize(lefttext, 9) lefttext:SetPoint("left", lefticon, "right", 2, 0) - + lefttext.__languageId = "enUS" + local righttext = statusbar:CreateFontString("$parentRightText", "overlay", "GameFontNormal") DF:SetFontSize(righttext, 9) righttext:SetPoint("right", righticon, "left", -2, 0) - + lefttext:SetJustifyH("left") righttext:SetJustifyH("right") - + local actionicon = statusbar:CreateTexture("$parentRightIcon", "overlay") actionicon:SetPoint("center", line, "center") @@ -388,19 +408,19 @@ function Details:CreateEventTrackerFrame(parent, name) --set some parameters _detalhes:UpdateWorldTrackerLines (line) - + --set scripts line:SetScript("OnUpdate", lineOnTick) - + return line end - + --some consts to help work with indexes local SPELLTYPE_COOLDOWN = "cooldown" local SPELLTYPE_INTERRUPT = "interrupt" local SPELLTYPE_OFFENSIVE = "offensive" local SPELLTYPE_CROWDCONTROL = "crowdcontrol" - + local ABILITYTABLE_SPELLTYPE = 1 local ABILITYTABLE_SPELLID = 2 local ABILITYTABLE_CASTERNAME = 3 @@ -411,12 +431,12 @@ function Details:CreateEventTrackerFrame(parent, name) local ABILITYTABLE_CASTERSERIAL = 8 local ABILITYTABLE_ISENEMY = 9 local ABILITYTABLE_TARGETSERIAL = 10 - - local get_spec_or_class = function(serial, name) + + local get_spec_or_class = function(serial, unitName) local class local spec = _detalhes.cached_specs [serial] if (not spec) then - local _, engClass = UnitClass(name) + local _, engClass = UnitClass(unitName) if (engClass) then class = engClass else @@ -426,10 +446,10 @@ function Details:CreateEventTrackerFrame(parent, name) end end end - + return spec, class end - + local get_player_icon = function(spec, class) if (spec) then return [[Interface\AddOns\Details\images\spec_icons_normal]], unpack(_detalhes.class_specs_coords [spec]) @@ -439,59 +459,58 @@ function Details:CreateEventTrackerFrame(parent, name) return [[Interface\AddOns\Details\images\classes_plus]], 0.50390625, 0.62890625, 0, 0.125 end end - - local add_role_and_class_color = function(player_name, player_serial) - + + local add_role_and_class_color = function(unitName, unitSerial) --get the actor object - local actor = _detalhes.tabela_vigente[1]:GetActor(player_name) - + local actor = _detalhes.tabela_vigente[1]:GetActor(unitName) + if (actor) then --remove realm name - player_name = _detalhes:GetOnlyName(player_name) - + unitName = _detalhes:GetOnlyName(unitName) + local class, spec, role = actor.classe, actor.spec, actor.role if (not class) then - spec, class = get_spec_or_class (player_serial, player_name) + spec, class = get_spec_or_class (unitSerial, unitName) end - + --add the class color if (_detalhes.player_class [class]) then --is a player, add the class color - player_name = _detalhes:AddColorString (player_name, class) + unitName = _detalhes:AddColorString (unitName, class) end - + --add the role icon if (role ~= "NONE") then --have a role - player_name = _detalhes:AddRoleIcon (player_name, role, _detalhes.event_tracker.line_height) + unitName = _detalhes:AddRoleIcon (unitName, role, _detalhes.event_tracker.line_height) end - + else - local spec, class = get_spec_or_class (player_serial, player_name) - player_name = _detalhes:GetOnlyName(player_name) - + local spec, class = get_spec_or_class (unitSerial, unitName) + unitName = _detalhes:GetOnlyName(unitName) + if (class) then --add the class color if (_detalhes.player_class [class]) then --is a player, add the class color - player_name = _detalhes:AddColorString (player_name, class) + unitName = _detalhes:AddColorString (unitName, class) end end end - - return player_name + + return unitName end - + local get_text_size = function() local iconsSpace = _detalhes.event_tracker.line_height * 3 local textSpace = 4 local saveSpace = 14 - - local availableSpace = (f:GetWidth() - iconsSpace - textSpace - saveSpace) / 2 - + + local availableSpace = (screenFrame:GetWidth() - iconsSpace - textSpace - saveSpace) / 2 + return availableSpace end - + local shrink_string = function(fontstring, size) local text = fontstring:GetText() local loops = 20 @@ -500,56 +519,89 @@ function Details:CreateEventTrackerFrame(parent, name) fontstring:SetText(text) loops = loops - 1 end - + return fontstring end - + --refresh the scroll frame local scroll_refresh = function(self, data, offset, total_lines) - + local textSize = get_text_size() - + for i = 1, total_lines do local index = i + offset local ability = data [index] - + if (ability) then local line = self:GetLine (i) - + local spec, class = get_spec_or_class (ability [ABILITYTABLE_CASTERSERIAL], ability [ABILITYTABLE_CASTERNAME]) local texture, L, R, T, B = get_player_icon (spec, class) line.LeftIcon:SetTexture(texture) line.LeftIcon:SetTexCoord(L, R, T, B) - line.LeftText:SetText(_detalhes:GetOnlyName(ability [ABILITYTABLE_CASTERNAME])) - + + --[=[language system test + local sourceName = ability[ABILITYTABLE_CASTERNAME] + 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) + if (ability [ABILITYTABLE_ISENEMY]) then line:SetBackdropColor(1, .3, .3, 0.5) else line:SetBackdropColor(1, 1, 1, 0.5) end - + if (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_COOLDOWN) then local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID]) line.RightIcon:SetTexture(spellIcon) line.RightIcon:SetTexCoord(.06, .94, .06, .94) - + 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) - + line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]]) line.ActionIcon:SetTexCoord(0, 0.125, 0, 1) - + elseif (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_OFFENSIVE) then local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID]) line.RightIcon:SetTexture(spellIcon) line.RightIcon:SetTexCoord(.06, .94, .06, .94) line.RightText:SetText(spellName) - + line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]]) line.ActionIcon:SetTexCoord(0.127, 0.25, 0, 1) @@ -558,10 +610,10 @@ function Details:CreateEventTrackerFrame(parent, name) line.RightIcon:SetTexture(spellIconInterrupted) line.RightIcon:SetTexCoord(.06, .94, .06, .94) line.RightText:SetText(spellNameInterrupted) - + line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]]) line.ActionIcon:SetTexCoord(0.251, 0.375, 0, 1) - + elseif (ability [ABILITYTABLE_SPELLTYPE] == SPELLTYPE_CROWDCONTROL) then local spellName, _, spellIcon = GetSpellInfo(ability [ABILITYTABLE_SPELLID]) line.RightIcon:SetTexture(spellIcon) @@ -572,57 +624,57 @@ function Details:CreateEventTrackerFrame(parent, name) local targetSerial = ability [ABILITYTABLE_TARGETSERIAL] targetName = add_role_and_class_color (targetName, targetSerial) end - + line.RightText:SetText(targetName or "unknown target") - + line.ActionIcon:SetTexture([[Interface\AddOns\Details\images\event_tracker_icons]]) line.ActionIcon:SetTexCoord(0.376, 0.5, 0, 1) end - + shrink_string (line.LeftText, textSize) shrink_string (line.RightText, textSize) - + --set when the ability was registered on combat log line.GameTime = ability [ABILITYTABLE_GAMETIME] line:Show() end end end - + --title text - local TitleString = f:CreateFontString(nil, "overlay", "GameFontNormal") - TitleString:SetPoint("top", f, "top", 0, -3) + local TitleString = screenFrame:CreateFontString(nil, "overlay", "GameFontNormal") + TitleString:SetPoint("top", screenFrame, "top", 0, -3) TitleString:SetText("Details!: Event Tracker") - local TitleBackground = f:CreateTexture(nil, "artwork") + local TitleBackground = screenFrame:CreateTexture(nil, "artwork") TitleBackground:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) TitleBackground:SetVertexColor(.1, .1, .1, .9) - TitleBackground:SetPoint("topleft", f, "topleft") - TitleBackground:SetPoint("topright", f, "topright") + TitleBackground:SetPoint("topleft", screenFrame, "topleft") + TitleBackground:SetPoint("topright", screenFrame, "topright") TitleBackground:SetHeight(header_size) - + --table with spells showing on the scroll frame local CurrentShowing = {} - + --scrollframe - local scrollframe = DF:CreateScrollBox (f, "$parentScrollFrame", scroll_refresh, CurrentShowing, scroll_width, 400, scroll_line_amount, _detalhes.event_tracker.line_height, scroll_createline, true, true) - scrollframe:SetPoint("topleft", f, "topleft", 0, -header_size) - scrollframe:SetPoint("topright", f, "topright", 0, -header_size) - scrollframe:SetPoint("bottomleft", f, "bottomleft", 0, 0) - scrollframe:SetPoint("bottomright", f, "bottomright", 0, 0) - + 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) + --update line - used by 'UpdateWorldTrackerLines' function local update_line = function(line) - + --get the line index local index = line.Index - + --update left text DF:SetFontColor(line.LeftText, _detalhes.event_tracker.font_color) DF:SetFontFace (line.LeftText, _detalhes.event_tracker.font_face) DF:SetFontSize(line.LeftText, _detalhes.event_tracker.font_size) DF:SetFontOutline (line.LeftText, _detalhes.event_tracker.font_shadow) - + --update right text DF:SetFontColor(line.RightText, _detalhes.event_tracker.font_color) DF:SetFontFace (line.RightText, _detalhes.event_tracker.font_face) @@ -630,33 +682,33 @@ function Details:CreateEventTrackerFrame(parent, name) DF:SetFontOutline (line.RightText, _detalhes.event_tracker.font_shadow) --adjust where the line is anchored - line:SetPoint("topleft", line:GetParent(), "topleft", 0, -((index-1)*(_detalhes.event_tracker.line_height+1))) - line:SetPoint("topright", line:GetParent(), "topright", 0, -((index-1)*(_detalhes.event_tracker.line_height+1))) - + 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))) + --set its height line:SetHeight(_detalhes.event_tracker.line_height) - + --set texture local texture = SharedMedia:Fetch ("statusbar", _detalhes.event_tracker.line_texture) line.StatusbarTexture:SetTexture(texture) line.StatusbarTexture:SetVertexColor(unpack(_detalhes.event_tracker.line_color)) - + --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) end - + -- /run _detalhes.event_tracker.font_shadow = 24 -- /run _detalhes:UpdateWorldTrackerLines() - + function _detalhes:UpdateWorldTrackerLines (line) --don't run if the featured hasn't loaded - if (not f) then + if (not screenFrame) then return end - + if (line) then update_line (line) else @@ -668,67 +720,67 @@ function Details:CreateEventTrackerFrame(parent, name) scrollframe:Refresh() end end - + function _detalhes:UpdateEventTrackerFrame() --don't run if the featured hasn't loaded - if (not f) then + if (not screenFrame) then return end - - f:SetSize(_detalhes.event_tracker.frame.width, _detalhes.event_tracker.frame.height) - LibWindow.RegisterConfig(f, _detalhes.event_tracker.frame) - LibWindow.RestorePosition(f) + + screenFrame:SetSize(_detalhes.event_tracker.frame.width, _detalhes.event_tracker.frame.height) + LibWindow.RegisterConfig(screenFrame, _detalhes.event_tracker.frame) + LibWindow.RestorePosition(screenFrame) scrollframe:OnSizeChanged() - + if (_detalhes.event_tracker.frame.locked) then - f:EnableMouse(false) - left_resize:Hide() - right_resize:Hide() + screenFrame:EnableMouse(false) + leftResize:Hide() + rightResize:Hide() else - f:EnableMouse(true) - left_resize:Show() - right_resize:Show() + screenFrame:EnableMouse(true) + leftResize:Show() + rightResize:Show() end - + if (_detalhes.event_tracker.frame.show_title) then TitleString:Show() TitleBackground:Show() - scrollframe:SetPoint("topleft", f, "topleft", 0, -header_size) - scrollframe:SetPoint("topright", f, "topright", 0, -header_size) + scrollframe:SetPoint("topleft", screenFrame, "topleft", 0, -header_size) + scrollframe:SetPoint("topright", screenFrame, "topright", 0, -header_size) else TitleString:Hide() TitleBackground:Hide() - scrollframe:SetPoint("topleft", f, "topleft", 0, 0) - scrollframe:SetPoint("topright", f, "topright", 0, 0) + scrollframe:SetPoint("topleft", screenFrame, "topleft", 0, 0) + scrollframe:SetPoint("topright", screenFrame, "topright", 0, 0) end - - f:SetBackdropColor(unpack(_detalhes.event_tracker.frame.backdrop_color)) + + screenFrame:SetBackdropColor(unpack(_detalhes.event_tracker.frame.backdrop_color)) scrollframe.__background:SetVertexColor(unpack(_detalhes.event_tracker.frame.backdrop_color)) - - f:SetFrameStrata(_detalhes.event_tracker.frame.strata) - + + screenFrame:SetFrameStrata(_detalhes.event_tracker.frame.strata) + _detalhes:UpdateWorldTrackerLines() scrollframe:Refresh() end - + --create the first line - for i = 1, 1 do + for i = 1, 1 do scrollframe:CreateLine (scroll_createline) end - f.scrollframe = scrollframe + screenFrame.scrollframe = scrollframe scrollframe:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16}) scrollframe:SetBackdropColor(0, 0, 0, 0) - + --get tables used inside the combat parser local cooldownListFromFramework = DetailsFramework.CooldownsAllDeffensive local attackCooldownsFromFramework = DetailsFramework.CooldownsAttack local crowdControlFromFramework = DetailsFramework.CrowdControlSpells - + local combatLog = CreateFrame("frame") combatLog:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") local OBJECT_TYPE_PLAYER = 0x00000400 local OBJECT_TYPE_ENEMY = 0x00000040 - + --combat parser local is_player = function(flag) if (not flag) then @@ -742,50 +794,72 @@ function Details:CreateEventTrackerFrame(parent, name) end return bit.band(flag, OBJECT_TYPE_ENEMY) ~= 0 end - + + local defensiveCDType = { + [2] = true, + [3] = true, + [4] = true, + } + combatLog:SetScript("OnEvent", function(self, event) - + 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] + --defensive cooldown - if (token == "SPELL_CAST_SUCCESS" and (cooldownListFromFramework [spellid]) and is_player (caster_flags)) then + if (token == "SPELL_CAST_SUCCESS" and (spellInfo and defensiveCDType[spellInfo.type]) and is_player (caster_flags)) then tinsert(CurrentShowing, 1, {SPELLTYPE_COOLDOWN, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial}) added = true - + --offensive cooldown - elseif (token == "SPELL_CAST_SUCCESS" and (attackCooldownsFromFramework [spellid]) and is_player (caster_flags)) then + elseif (token == "SPELL_CAST_SUCCESS" and (spellInfo and spellInfo.type == 1 and spellInfo.cooldown and spellInfo.cooldown >= 90) and is_player (caster_flags)) then tinsert(CurrentShowing, 1, {SPELLTYPE_OFFENSIVE, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial}) added = true - + --crowd control - elseif (token == "SPELL_AURA_APPLIED" and (crowdControlFromFramework [spellid])) then + elseif (token == "SPELL_CAST_SUCCESS" and spellInfo and spellInfo.type == 8) then --check if isnt a pet - if (target_flags and is_player (target_flags)) then - tinsert(CurrentShowing, 1, {SPELLTYPE_CROWDCONTROL, spellid, caster_name, target_name, time, false, GetTime(), caster_serial, is_enemy (caster_flags), target_serial}) - added = true + 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 end - + --spell interrupt elseif (token == "SPELL_INTERRUPT") then - tinsert(CurrentShowing, 1, {SPELLTYPE_INTERRUPT, spellid, caster_name, target_name, time, extraSpellID, GetTime(), caster_serial, is_enemy (caster_flags), target_serial}) - added = true - + 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 end - + if (added) then local amountOfLines = scrollframe:GetNumFramesShown() local amountToShow = #CurrentShowing - + if (amountToShow > amountOfLines) then tremove(CurrentShowing, amountToShow) end scrollframe:Refresh() end - + end) - + _detalhes.Broadcaster_EventTrackerLoaded = true - _detalhes.Broadcaster_EventTrackerFrame = f - f:Hide() + _detalhes.Broadcaster_EventTrackerFrame = screenFrame + screenFrame:Hide() end