diff --git a/Definitions.lua b/Definitions.lua index 78fe596f..68f50813 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -4,6 +4,7 @@ ---@field RegisterStateDriver fun(statedriver: frame, attribute: string, conditional: string) ---@field UnitGUID fun(unit: unit): string ---@field UnitName fun(unit: unit): string +---@field GetCursorPosition fun(): number, number return the position of the cursor on the screen, in pixels, relative to the bottom left corner of the screen. ---@class unixtime : number const @@ -23,7 +24,7 @@ ---@class color : table, string @table(r: red|number, g: green|number, b: blue|number, a: alpha|number) @string(color name) @hex (000000-ffffff) value representing a color, the value must be a table with the following fields: r, g, b, a. r, g, b are numbers between 0 and 1, a is a number between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color) ---@class scale : number @number(0.65-2.40) value representing the scale factor of the UIObject, the value must be between 0.65 and 2.40, the width and height of the UIObject will be multiplied by this value. ---@class texture : string, number is an object that represents a graphical image. Textures are used to display visual elements such as icons, backgrounds, borders, and more. ----@class frame : UIObject represents a container for other UI elements, such as textures, buttons, text, and more. +---@class frame : uiobject represents a container for other UI elements, such as textures, buttons, text, and more. ---@class width : number property that represents the horizontal size of a UI element, such as a frame or a texture. ---@class height : number property that represents the vertical size of a UI element, such as a frame or a texture. ---@class script : string, function is a piece of code that is executed in response to a specific event, such as a button click or a frame update. Scripts can be used to implement behavior and logic for UI elements. @@ -34,30 +35,30 @@ ---@class health : number amount of hit points (health) of a unit. This value can be changed by taking damage or healing. ---@class role : string @string(TANK, HEALER, DAMAGER, NONE) is a string that represents the role of a unit, such as tank, healer, or damage dealer. ----@class UIObject ----@field Show fun(self: UIObject) ----@field Hide fun(self: UIObject) ----@field SetShown fun(self: UIObject, state: boolean) ----@field IsShown fun(self: UIObject) : boolean ----@field SetAllPoints fun(self: UIObject) ----@field SetParent fun(self: UIObject, parent: frame) ----@field SetSize fun(self: UIObject, width: width|number, height: height|number) ----@field SetWidth fun(self: UIObject, width: width|number) ----@field SetHeight fun(self: UIObject, height: height|number) ----@field SetAlpha fun(self: UIObject, alpha: alpha|number) ----@field SetScale fun(self: UIObject, scale: scale|number) ----@field GetWidth fun(self: UIObject) : width|number ----@field GetHeight fun(self: UIObject) : height|number ----@field GetScale fun(self: UIObject) : scale|number ----@field GetAlpha fun(self: UIObject) : alpha|number ----@field GetSize fun(self: UIObject) : width|number, height|number ----@field GetParent fun(self: UIObject) : frame ----@field GetPoint fun(self: UIObject, index: number): string, frame, string, number, number ----@field SetPoint fun(self: UIObject, point: string, relativeFrame: frame, relativePoint: string, xOffset: number, yOffset: number) ----@field ClearAllPoints fun(self: UIObject) ----@field CreateAnimationGroup fun(self: UIObject, name: string|nil, templateName: string|nil) : animationgroup +---@class uiobject +---@field Show fun(self: uiobject) +---@field Hide fun(self: uiobject) +---@field SetShown fun(self: uiobject, state: boolean) +---@field IsShown fun(self: uiobject) : boolean +---@field SetAllPoints fun(self: uiobject) +---@field SetParent fun(self: uiobject, parent: frame) +---@field SetSize fun(self: uiobject, width: width|number, height: height|number) +---@field SetWidth fun(self: uiobject, width: width|number) +---@field SetHeight fun(self: uiobject, height: height|number) +---@field SetAlpha fun(self: uiobject, alpha: alpha|number) +---@field SetScale fun(self: uiobject, scale: scale|number) +---@field GetWidth fun(self: uiobject) : width|number +---@field GetHeight fun(self: uiobject) : height|number +---@field GetScale fun(self: uiobject) : scale|number +---@field GetAlpha fun(self: uiobject) : alpha|number +---@field GetSize fun(self: uiobject) : width|number, height|number +---@field GetParent fun(self: uiobject) : frame +---@field GetPoint fun(self: uiobject, index: number): string, frame, string, number, number +---@field SetPoint fun(self: uiobject, point: "topleft"|"topright"|"bottomleft"|"bottomright"|"top"|"bottom"|"left"|"right"|"center", relativeFrame: uiobject, relativePoint: "topleft"|"topright"|"bottomleft"|"bottomright"|"top"|"bottom"|"left"|"right"|"center", xOffset: number, yOffset: number) +---@field ClearAllPoints fun(self: uiobject) +---@field CreateAnimationGroup fun(self: uiobject, name: string|nil, templateName: string|nil) : animationgroup ----@class animationgroup : UIObject +---@class animationgroup : uiobject ---@field CreateAnimation fun(self: animationgroup, animationType: string, name: string|nil, inheritsFrom: string|nil) : animation ---@field GetAnimation fun(self: animationgroup, name: string) : animation ---@field GetAnimations fun(self: animationgroup) : table @@ -79,7 +80,7 @@ ---@field SetSmoothProgress fun(self: animationgroup, smooth: boolean) ---@field Stop fun(self: animationgroup) ----@class animation : UIObject +---@class animation : uiobject ---@field GetDuration fun(self: animation) : number ---@field GetEndDelay fun(self: animation) : number ---@field GetOrder fun(self: animation) : number @@ -98,7 +99,7 @@ ---@field SetSmoothing fun(self: animation, smoothing: string) ---@field Stop fun(self: animation) ----@class frame : UIObject +---@class frame : uiobject ---@field SetAttribute fun(self: frame, name: string, value: any) ---@field SetScript fun(self: frame, event: string, handler: function) ---@field GetScript fun(self: frame, event: string) : function @@ -125,9 +126,10 @@ ---@field GetObjectType fun(self: frame) : string ---@field GetChildren fun(self: frame) : frame[] ---@field GetRegions fun(self: frame) : region[] ----@field CreateTexture fun(self: frame, name: string|nil, layer: string, inherits: string|nil, subLayer: number|nil) : texture ----@field CreateFontString fun(self: frame, name: string|nil, layer: string, inherits: string|nil, subLayer: number|nil) : fontstring +---@field CreateTexture fun(self: frame, name: string|nil, layer: "background"|"border"|"artwork"|"overlay"|"highlight", inherits: string|nil, subLayer: number|nil) : texture +---@field CreateFontString fun(self: frame, name: string|nil, layer: "background"|"border"|"artwork"|"overlay"|"highlight", inherits: string|nil, subLayer: number|nil) : fontstring ---@field EnableMouse fun(self: frame, enable: boolean) +---@field SetResizable fun(self: frame, enable: boolean) ---@class button : frame ---@field SetNormalTexture fun(self: button, texture: texture) @@ -150,10 +152,10 @@ ---@field GetButtonState fun(self: button, state: string) : boolean ---@field RegisterForClicks fun(self: button, button1: string|nil, button2: string|nil) ----@class fontstring : UIObject ----@field SetDrawLayer fun(self: fontstring, layer: string, subLayer: number|nil) +---@class fontstring : uiobject +---@field SetDrawLayer fun(self: fontstring, layer: "background"|"border"|"artwork"|"overlay"|"highlight", subLayer: number|nil) ---@field SetFont fun(self: fontstring, font: string, size: number, flags: string) ----@field SetText fun(self: fontstring, text: string) +---@field SetText fun(self: fontstring, text: string|number) ---@field GetText fun(self: fontstring) : string ---@field GetFont fun(self: fontstring) : string, number, string ---@field SetShadowColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number) @@ -214,12 +216,12 @@ ---@field GetOrientation fun(self: statusbar) : string ---@field GetReverseFill fun(self: statusbar) : boolean ----@class texture : UIObject ----@field SetDrawLayer fun(self: texture, layer: string, subLayer: number|nil) +---@class texture : uiobject +---@field SetDrawLayer fun(self: texture, layer: "background"|"border"|"artwork"|"overlay"|"highlight", subLayer: number|nil) ---@field SetTexture fun(self: texture, path: string) ---@field SetColorTexture fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number) ---@field SetDesaturated fun(self: texture, desaturate: boolean) ----@field SetBlendMode fun(self: texture, mode: string) +---@field SetBlendMode fun(self: texture, mode: "ADD"|"BLEND"|"DISABLE"|"MOD"|"MOD2X"|"OVERLAY"|"REPLACE"|"SUBTRACT") ---@field SetVertexColor fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number) ---@field SetAlpha fun(self: texture, alpha: number) ---@field GetAlpha fun(self: texture) : number @@ -227,7 +229,6 @@ ---@field SetHeight fun(self: texture, height: number) ---@field GetWidth fun(self: texture) : number ---@field GetHeight fun(self: texture) : number ----@field SetPoint fun(self: texture, point: string, relativeFrame: table, relativePoint: string, xOfs: number, yOfs: number) ---@field GetPoint fun(self: texture, index: number) : string, table, string, number, number ---@field SetShown fun(self: texture, state: boolean) ---@field IsShown fun(self: texture) : boolean @@ -263,6 +264,19 @@ ---@field GetBlendMode fun(self: texture) : string ---@field GetVertexColor fun(self: texture) : number, number, number, number + + + + + + +---@class details +---@field GetInstance fun(self: details) : instance +---@field GetCombat fun(self: details) : combat +---@field GetSpellSchoolFormatedName fun(self: details, spellschool: number) : string +---@field CommaValue fun(self: details, number: number) : string +---@field SumSpellTables fun(self: details, spellTables: spelltable[], targetTable: table) + ---@class combat : table ---@field GetCombatTime fun(combat) ---@field GetDeaths fun(combat) --get the table which contains the deaths of the combat @@ -274,6 +288,8 @@ ---@field SetEndTime fun(combat: combat, time: number) ---@field CopyDeathsFrom fun(combat1: combat, combat2: combat, bMythicPlus: boolean) copy the deaths from combat2 to combat1, use true on bMythicPlus if the combat is from a mythic plus run ---@field GetContainer fun(combat: combat, containerType: number) get an actor container, containerType can be 1 for damage, 2 heal, 3 energy, 4 utility +---@field GetSpellCastAmount fun(combat: combat, actorName: string, spellId: number) get the amount of times a spell was casted +---@field GetSpellUptime fun(combat: combat, actorName: string, spellId: number, auraType: string|nil) get the uptime of a buff or debuff ---@field is_mythic_dungeon_trash boolean ---@field is_mythic_dungeon_run_id number ---@field is_mythic_dungeon_segment boolean @@ -289,24 +305,59 @@ ---@field GetActorTable fun(container: actorcontainer) get the table which contains the actors ---@field ListActors fun(container: actorcontainer) usage: for index, actorObject in container:ListActors() do - ---@class spellcontainer : table +---@field GetSpell fun(container: spellcontainer, spellId: number) get a spell by its id ---@field _ActorTable table ---@class spelltable : table +---@field uptime number +---@field total number +---@field spellschool number +---@field counter number amount of hits +---@field c_amt number critical hits +---@field c_min number +---@field c_max number +---@field c_dmg number +---@field n_amt number normal hits +---@field n_dmg number total damage made by normal hits +---@field n_min number min damage made by normal hits +---@field n_max number max damage made by normal hits +---@field targets table store the [target name] = total value +---@field id number --spellid +---@field successful_casted number successful casted times (only for enemies) +---@field g_amt number glacing hits +---@field g_dmg number +---@field r_amt number --resisted +---@field r_dmg number +---@field b_amt number --blocked +---@field b_dmg number +---@field a_amt number --absorved +---@field a_dmg number ---@class actor : table +---@field GetSpellContainer fun(actor: actor, containerType: string) +---@field Name fun(actor: actor) : string get the name of the actor +---@field Tempo fun(actor: actor) : number get the activity or effective time of the actor +---@field GetPets fun(actor: actor) : table get a table with all pet names that belong to the player +---@field GetSpellList fun(actor: actor) : table +---@field BuildSpellTargetFromBreakdownSpellData fun(actor: actor, bkSpellData: breakdownspelldata) : table +---@field BuildSpellTargetFromSpellTable fun(actor: actor, spellTable: spelltable) : table ---@field debuff_uptime_spells table ---@field buff_uptime_spells table ---@field spells table ---@field cooldowns_defensive_spells table ---@field nome string ---@field serial string +---@field spec number ---@field grupo boolean ---@field fight_component boolean ---@field boss_fight_component boolean ---@field boss boolean ---@field last_event unixtime +---@field total_without_pet number +---@field total number +---@field spell_cast table +---@field pets table ---@class segmentid : number ---@class instanceid : number @@ -344,6 +395,103 @@ ---@field RefreshData fun(instance: instance, force: boolean|nil) ---@field RefreshWindow fun(instance: instance, force: boolean|nil) +---@class breakdownscrolldata : table +---@field totalValue number total done by the actor +---@field combatTime number +---@field [breakdownspelldata] breakdownspelldata indexed part of the table + +---@class breakdownexpandbutton : button +---@field texture texture + +---@class breakdownspellscrollframe : frame + +---@class breakdownspellbar : button +---@field index number +---@field rank number +---@field spellId number +---@field name string +---@field combatTime number +---@field perSecond number +---@field percent number +---@field amountCasts number +---@field average number +---@field castAverage number +---@field onMouseUpTime number GetTime() of when the spellbar got OnMouseUp event +---@field cursorPosX number mouse position when the spellbar got OnMouseDown event +---@field cursorPosY number mouse position when the spellbar got OnMouseDown event +---@field spellTable spelltable +---@field bkSpellData breakdownspelldata +---@field statusBar statusbar +---@field expandButton breakdownexpandbutton +---@field spellIconFrame frame +---@field spellIcon texture +---@field targetsSquareFrame breakdowntargetframe +---@field targetsSquareTexture texture +---@field overlayTexture texture +---@field bIsExpandedSpell boolean +---@field ExpandedChildren breakdownspellbar[] store the spellbars which are expanded from this spellbar (spellbars shown when the expand button is pressed) +---@field InLineTexts fontstring[] +---@field AddFrameToHeaderAlignment fun(self: breakdownspellbar, frame: uiobject) +---@field AlignWithHeader fun(self: breakdownspellbar, header: table, align: string|"left") + +---@class breakdownspelldata : table +---@field id number main spellId to be used on the tooltip, name and icon +---@field total number total done by the spell +---@field counter number amount of hits +---@field spellschool number the school of the spell +---@field expanded boolean if is true the show the nested spells +---@field spellTables spelltable[] +---@field spellIds number[] +---@field petNames string[] +---@field bCanExpand boolean +---@field expandedIndex number +---@field bIsExpanded boolean +---@field c_amt number critical hits +---@field c_min number +---@field c_max number +---@field c_dmg number +---@field n_amt number normal hits +---@field n_dmg number total damage made by normal hits +---@field n_min number min damage made by normal hits +---@field n_max number max damage made by normal hits +---@field successful_casted number successful casted times (only for enemies) +---@field g_amt number glacing hits +---@field g_dmg number +---@field r_amt number --resisted +---@field r_dmg number +---@field b_amt number --blocked +---@field b_dmg number +---@field a_amt number --absorved +---@field a_dmg number + +---@class breakdowntargetframe : frame +---@field spellId number +---@field bkSpellData breakdownspelldata +---@field spellTable spelltable +---@field texture texture +---@field bIsMainLine boolean + +---@class tabframe : frame this is the tab frame object for the breakdown window + +---@class breakdownspellblockcontainer : frame container for the spellblocks in the breakdown window +---@field SpellBlocks breakdownspellblock[] +---@field UpdateBlocks fun(self: breakdownspellblockcontainer) +---@field ClearBlocks fun(self: breakdownspellblockcontainer) +---@field GetBlock fun(self: breakdownspellblockcontainer, index: number) : breakdownspellblock + +---@class breakdownspellblock : statusbar breakdownspellblock object which is created inside the breakdownspellblockcontainer +---@field Lines breakdownspellblockline[] +---@field reportButton button +---@field overlay texture +---@field sparkTexture texture +---@field gradientTexture texture +---@field GetLine fun(self: breakdownspellblock, index: number) : breakdownspellblockline +---@field GetLines fun(self: breakdownspellblock) : breakdownspellblockline, breakdownspellblockline, breakdownspellblockline + +---@class breakdownspellblockline : frame a line inside a breakdownspellblock, there's 3 of them in each breakdownspellblock +---@field leftText fontstring +---@field centerText fontstring +---@field rightText fontstring diff --git a/Details.toc b/Details.toc index 5015b2ae..4a0f7c5a 100644 --- a/Details.toc +++ b/Details.toc @@ -87,6 +87,7 @@ frames\window_playerbreakdown_list.lua frames\window_playerbreakdown_compare.lua frames\window_playerbreakdown_avoidance.lua frames\window_playerbreakdown_auras.lua +frames\window_playerbreakdown_spells.lua frames\window_report.lua frames\window_main.lua frames\window_custom.lua diff --git a/Details_Wrath.toc b/Details_Wrath.toc index 18fd73ce..6ef3fc4f 100644 --- a/Details_Wrath.toc +++ b/Details_Wrath.toc @@ -80,6 +80,7 @@ frames\window_playerbreakdown_list.lua frames\window_playerbreakdown_compare.lua frames\window_playerbreakdown_avoidance.lua frames\window_playerbreakdown_auras.lua +frames\window_playerbreakdown_spells.lua frames\window_report.lua frames\window_main.lua frames\window_custom.lua diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 5196683b..4adfe77a 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 421 +local dversion = 422 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 d1294be9..8fdb8a94 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -5084,6 +5084,15 @@ detailsFramework.HeaderFunctions = { tinsert(self.FramesToAlign, frame) end, + ResetFramesToHeaderAlignment = function(self) + wipe(self.FramesToAlign) + end, + + SetFramesToHeaderAlignment = function(self, ...) + wipe(self.FramesToAlign) + self.FramesToAlign = {...} + end, + GetFramesFromHeaderAlignment = function(self, frame) return self.FramesToAlign or {} end, @@ -5100,16 +5109,18 @@ detailsFramework.HeaderFunctions = { frame:ClearAllPoints() local columnHeader = columnHeaderFrames[i] - local offset = 0 + if (columnHeader) then + local offset = 0 - if (columnHeader.columnAlign == "right") then - offset = columnHeader:GetWidth() - if (frame:GetObjectType() == "FontString") then - frame:SetJustifyH("right") + if (columnHeader.columnAlign == "right") then + offset = columnHeader:GetWidth() + if (frame:GetObjectType() == "FontString") then + frame:SetJustifyH("right") + end end - end - frame:SetPoint(columnHeader.columnAlign, self, anchor, columnHeader.XPosition + columnHeader.columnOffset + offset, 0) + frame:SetPoint(columnHeader.columnAlign, self, anchor, columnHeader.XPosition + columnHeader.columnOffset + offset, 0) + end end end, diff --git a/boot.lua b/boot.lua index 49244b99..abc1b925 100644 --- a/boot.lua +++ b/boot.lua @@ -87,6 +87,7 @@ Details222.Perf = {} Details222.Cooldowns = {} Details222.GarbageCollector = {} + Details222.BreakdownWindow = {} ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --initialization stuff @@ -777,8 +778,9 @@ do local UIParent = UIParent --api locals --Info Window - _detalhes.playerDetailWindow = CreateFrame("Frame", "DetailsPlayerDetailsWindow", UIParent, "BackdropTemplate") + _detalhes.playerDetailWindow = CreateFrame("Frame", "DetailsBreakdownWindow", UIParent, "BackdropTemplate") _detalhes.PlayerDetailsWindow = _detalhes.playerDetailWindow + Details.BreakdownWindow = _detalhes.playerDetailWindow --Event Frame _detalhes.listener = CreateFrame("Frame", nil, UIParent) diff --git a/classes/class_combat.lua b/classes/class_combat.lua index bcdd8cb2..e964dac9 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -180,6 +180,71 @@ return self.alternate_power end + ---return the amount of casts of a spells from an actor + ---@param actorName string + ---@param spellId number + ---@return number + function combate:GetSpellCastAmount(actorName, spellId) + ---@type actorcontainer + local utilityContainer = self:GetContainer(DETAILS_ATTRIBUTE_MISC) + ---@type actor + local actorObject = utilityContainer:GetActor(actorName) + if (actorObject) then + return actorObject.spell_cast[spellId] or 0 + else + return 0 + end + end + + ---return the uptime of a buff from an actor + ---@param actorName string + ---@param spellId number + ---@param auraType string|nil if nil get 'buff' + ---@return number + function combate:GetSpellUptime(actorName, spellId, auraType) + ---@type actorcontainer + local utilityContainer = self:GetContainer(DETAILS_ATTRIBUTE_MISC) + ---@type actor + local actorObject = utilityContainer:GetActor(actorName) + if (actorObject) then + if (auraType) then + ---@type spellcontainer + local buffUptimeContainer = actorObject:GetSpellContainer(auraType) + if (buffUptimeContainer) then + ---@type spelltable + local spellTable = buffUptimeContainer:GetSpell(spellId) + if (spellTable) then + return spellTable.uptime or 0 + end + end + else + do --if not auraType passed, attempt to get the uptime from debuffs first, if it fails, get from buffs + ---@type spellcontainer + local debuffContainer = actorObject:GetSpellContainer("debuff") + if (debuffContainer) then + ---@type spelltable + local spellTable = debuffContainer:GetSpell(spellId) + if (spellTable) then + return spellTable.uptime or 0 + end + end + end + do + ---@type spellcontainer + local buffContainer = actorObject:GetSpellContainer("buff") + if (buffContainer) then + ---@type spelltable + local spellTable = buffContainer:GetSpell(spellId) + if (spellTable) then + return spellTable.uptime or 0 + end + end + end + end + end + return 0 + end + --return the name of the encounter or enemy function combate:GetCombatName(try_find) if (self.is_pvp) then diff --git a/classes/class_damage.lua b/classes/class_damage.lua index f2090439..d52b38e2 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -102,6 +102,41 @@ [73967] = true, --xuen } + --damage mixin + local damageClassMixin = { + ---check which data is shown in the instance and call a function to build the data for a broker + ---@param actor actor + ---@param instance instance + BuildSpellDetails = function(actor, instance, spellId) + local mainSection, subSection = instance:GetDisplay() + local combatObject = instance:GetCombat() + if (subSection == 1 or subSection == 2) then + return actor:BuildSpellDamageDoneDetails(instance, combatObject, spellId) + + elseif (subSection == 3) then + return self:MontaDetalhesDamageTaken (spellid, barra, instancia) + + elseif (subSection == 4) then + return self:MontaDetalhesFriendlyFire (spellid, barra, instancia) + + elseif (subSection == 6) then + if (bitBand(self.flag_original, 0x00000400) ~= 0) then --� um jogador + return self:MontaDetalhesDamageDone (spellid, barra, instancia) + end + return self:MontaDetalhesEnemy (spellid, barra, instancia) + end + end, + + } + + ---prepare data to send to a broker to show details about a spell + ---@param actor actor + ---@param combat combat + ---@param spellId number + damageClassMixin.BuildSpellDamageDoneDetails = function(actor, combat, spellId) + + end + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --exported functions @@ -492,6 +527,7 @@ end setmetatable(newDamageActor, atributo_damage) detailsFramework:Mixin(newDamageActor, Details222.Mixins.ActorMixin) + detailsFramework:Mixin(newDamageActor, damageClassMixin) return newDamageActor end @@ -3090,7 +3126,7 @@ end end end ---@self: actor object +---@self: actor object function Details:SetClassIcon(texture, instance, class) --[[ exported]] local customIcon if (Details.immersion_unit_special_icons) then @@ -4431,135 +4467,187 @@ local getSpellDetails = function(unitGUID, spellName) end end + +--[=[ + current: passando todas as spells para o breakdown, até mesmo as spells que não tem merge é enviado a spell total e a a spellTable logo em seguida + isso forma uma array com o dobro do tamanho e spells duplicadas + + passar as spells repetidas em uma segunda array? + + não passar nada e deixar o sistema aprender sozinho, como o sistema vai saber que precisa por uma arrow na linha? (para expandi-la) + + +--]=] + ------ Damage Done & Dps -function atributo_damage:MontaInfoDamageDone() +function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of spells in the topleft scrollBar in the summary tab + --the goal of this function is to build a list of spells the actor used and send the data to Details! which will delivery to the summary tab actived + --so the script only need to build the list of spells and send it to Details! + ---@type actor local actorObject = self - - local allLines = info.barras1 + ---@type instance local instance = info.instancia - - --damage rank - local combatObject = instance:GetShowingCombat() + ---@type combat + local combatObject = instance:GetCombat() + ---@type number local diff = combatObject:GetDifficulty() - local attribute, subAttribute = instance:GetDisplay() + ---@type string + local playerName = actorObject:Name() + --guild ranking on a boss --check if is a raid encounter and if is heroic or mythic - if (diff and (diff == 15 or diff == 16)) then - local db = Details.OpenStorage() - if (db) then - local bestRank, encounterTable = Details.storage:GetBestFromPlayer (diff, combatObject:GetBossInfo().id, "damage", self.nome, true) - if (bestRank) then - --discover which are the player position in the guild rank - local playerTable, onEncounter, rankPosition = Details.storage:GetPlayerGuildRank (diff, combatObject:GetBossInfo().id, "damage", self.nome, true) - local text1 = self.nome .. " Guild Rank on " .. (combatObject:GetBossInfo().name or "") .. ": |cFFFFFF00" .. (rankPosition or "x") .. "|r Best Dps: |cFFFFFF00" .. Details:ToK2((bestRank[1] or 0) / encounterTable.elapsed) .. "|r (" .. encounterTable.date:gsub(".*%s", "") .. ")" - info:SetStatusbarText (text1, 10, "gray") + do + if (diff and (diff == 15 or diff == 16)) then + local db = Details.OpenStorage() + if (db) then + local bestRank, encounterTable = Details.storage:GetBestFromPlayer(diff, combatObject:GetBossInfo().id, "damage", playerName, true) + if (bestRank) then + --discover which are the player position in the guild rank + local playerTable, onEncounter, rankPosition = Details.storage:GetPlayerGuildRank (diff, combatObject:GetBossInfo().id, "damage", playerName, true) + local text1 = playerName .. " Guild Rank on " .. (combatObject:GetBossInfo().name or "") .. ": |cFFFFFF00" .. (rankPosition or "x") .. "|r Best Dps: |cFFFFFF00" .. Details:ToK2((bestRank[1] or 0) / encounterTable.elapsed) .. "|r (" .. encounterTable.date:gsub(".*%s", "") .. ")" + info:SetStatusbarText (text1, 10, "gray") + else + info:SetStatusbarText() + end else info:SetStatusbarText() end else info:SetStatusbarText() end - else - info:SetStatusbarText() end + ---@type number local totalDamageWithoutPet = actorObject.total_without_pet + ---@type number local actorTotalDamage = actorObject.total - + ---@type table local actorSpellsSorted = {} + ---@type table local actorSpells = actorObject:GetSpellList() - local bShouldMergePlayerAbilities = Details.merge_player_abilities - local bShouldMergePetAbilities = Details.merge_pet_abilities - wipeSpellCache() - --get time type + --get time local actorCombatTime - if (Details.time_type == 1 or not self.grupo) then - actorCombatTime = self:Tempo() + if (Details.time_type == 1 or not actorObject.grupo) then + actorCombatTime = actorObject:Tempo() elseif (Details.time_type == 2) then actorCombatTime = info.instancia.showing:GetCombatTime() end + --actor spells + ---@type {[string]: number} + local alreadyAdded = {} for spellId, spellTable in pairs(actorSpells) do - local spellName, _, spellIcon = _GetSpellInfo(spellId) + ---@cast spellId number + ---@cast spellTable spelltable + + spellTable.ChartData = nil + + ---@type string + local spellName = _GetSpellInfo(spellId) if (spellName) then - local spellTotal = spellTable.total - local spellPercent = spellTable.total / actorTotalDamage * 100 - local nameString = spellName - - --problem: will show the first ability found when hovering over the spell - if (bShouldMergePlayerAbilities) then - local bAlreadyAdded = false - for i = 1, #actorSpellsSorted do - local thisSpell = actorSpellsSorted[i] - if (thisSpell[4] == nameString) then - bAlreadyAdded = true - thisSpell[2] = thisSpell[2] + spellTotal - end - end - - if (not bAlreadyAdded) then - tinsert(actorSpellsSorted, {spellId, spellTotal, spellPercent, nameString, spellIcon, nil, spellTable.spellschool}) - end - - addToSpellCache(actorObject:GetGUID(), spellName, spellTable) + ---@type number in which index the spell with the same name was stored + local index = alreadyAdded[spellName] + if (index) then + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[index] + bkSpellData.spellIds[#bkSpellData.spellIds+1] = spellId + bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable + bkSpellData.petNames[#bkSpellData.petNames+1] = "" + bkSpellData.bCanExpand = true else - tinsert(actorSpellsSorted, {spellId, spellTotal, spellPercent, nameString, spellIcon, nil, spellTable.spellschool}) + ---@type breakdownspelldata + local bkSpellData = { + id = spellId, + spellschool = spellTable.spellschool, + bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, + + spellIds = {spellId}, + spellTables = {spellTable}, --sub spell tables to show if the spell is expanded + petNames = {""}, + } + + actorSpellsSorted[#actorSpellsSorted+1] = bkSpellData + alreadyAdded[spellName] = #actorSpellsSorted end end end - --show damage percentille within item level bracket - - --add pets - local actorPets = self.pets - --local class_color = RAID_CLASS_COLORS [self.classe] and RAID_CLASS_COLORS [self.classe].colorStr - local classColor = "FFCCBBBB" - --local class_color = "FFDDDD44" - + --pets spells + local actorPets = actorObject:GetPets() for _, petName in ipairs(actorPets) do + ---@type actor local petActor = combatObject(DETAILS_ATTRIBUTE_DAMAGE, petName) - if (petActor) then + if (petActor) then --PET local spells = petActor:GetSpellList() - for spellId, spellTable in pairs(spells) do --da foreach em cada spellid do container - local spellName, _, spellIcon = _GetSpellInfo(spellId) - --tinsert(ActorSkillsSortTable, {_spellid, _skill.total, _skill.total/ActorTotalDamage*100, nome .. " |TInterface\\AddOns\\Details\\images\\classes_small_alpha:12:12:0:0:128:128:33:64:96:128|t|c" .. class_color .. PetName:gsub((" <.*"), "") .. "|r", icone, PetActor, _skill.spellschool}) + for spellId, spellTable in pairs(spells) do + ---@cast spellId number + ---@cast spellTable spelltable + + spellTable.ChartData = nil + --PET + ---@type string + local spellName = _GetSpellInfo(spellId) if (spellName) then - local spellTotal = spellTable.total - local spellPercent = spellTable.total / actorTotalDamage * 100 - local nameString = spellName .. " (|c" .. classColor .. petName:gsub((" <.*"), "") .. "|r)" + ---@type number in which index the spell with the same name was stored + local index = alreadyAdded[spellName] + if (index) then --PET + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[index] + bkSpellData.spellIds[#bkSpellData.spellIds+1] = spellId + bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable + bkSpellData.petNames[#bkSpellData.petNames+1] = petName + bkSpellData.bCanExpand = true + else --PET + ---@type breakdownspelldata + local bkSpellData = { + id = spellId, + spellschool = spellTable.spellschool, + expanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, - if (bShouldMergePetAbilities) then - local bAlreadyAdded = false - for i = 1, #actorSpellsSorted do - local thisPetSpellTable = actorSpellsSorted[i] - if (thisPetSpellTable[1] == spellId) then - bAlreadyAdded = true - thisPetSpellTable[2] = thisPetSpellTable[2] + spellTotal - end - end - - if (not bAlreadyAdded) then - tinsert(actorSpellsSorted, {spellId, spellTotal, spellPercent, nameString, spellIcon, petActor, spellTable.spellschool}) - end - - addToSpellCache(actorObject:GetGUID(), spellName, spellTable) --all pet spells are added to later be combined and shown in the spell details - else - tinsert(actorSpellsSorted, {spellId, spellTotal, spellPercent, nameString, spellIcon, petActor, spellTable.spellschool}) + spellIds = {spellId}, + spellTables = {spellTable}, + petNames = {petName}, + } + actorSpellsSorted[#actorSpellsSorted+1] = bkSpellData + alreadyAdded[spellName] = #actorSpellsSorted end end end end end - _table_sort(actorSpellsSorted, Details.Sort2) + for i = 1, #actorSpellsSorted do + ---@type breakdownspelldata + local bkSpellData = actorSpellsSorted[i] + Details:SumSpellTables(bkSpellData.spellTables, bkSpellData) + end - gump:JI_AtualizaContainerBarras (#actorSpellsSorted + 1) + --table.sort(actorSpellsSorted, Details.Sort2) + table.sort(actorSpellsSorted, function(t1, t2) + return t1.total > t2.total + end) + + actorSpellsSorted.totalValue = actorTotalDamage + actorSpellsSorted.combatTime = actorCombatTime + + --actorSpellsSorted has the spell infomation, need to pass to the summary tab + + --cleanup + table.wipe(alreadyAdded) + + --send to the breakdown window + Details222.BreakdownWindow.SendSpellData(actorSpellsSorted, actorObject, combatObject, instance) + + if 1 then return end + + --gump:JI_AtualizaContainerBarras (#actorSpellsSorted + 1) local max_ = actorSpellsSorted[1] and actorSpellsSorted[1][2] or 0 --dano que a primeiro magia vez - local barra --aura bar @@ -4752,12 +4840,9 @@ function atributo_damage:MontaInfoDamageDone() if (barra.mouse_over) then --atualizar o tooltip if (barra.isAlvo) then - --GameTooltip:Hide() - --GameTooltip:SetOwner(barra, "ANCHOR_TOPRIGHT") if (not barra.minha_tabela:MontaTooltipAlvos (barra, index, instance)) then return end - --GameTooltip:Show() end end @@ -5074,7 +5159,7 @@ local MontaDetalhesBuffProcs = function(actor, row, instance) end - +--this build p the 6 rectangle boxes in the right side of the breakdown window summary tab function atributo_damage:MontaDetalhesDamageDone (spellId, spellLine, instance) local spellTable if (spellLine.other_actor) then @@ -5477,7 +5562,7 @@ function atributo_damage:MontaDetalhesDamageDone (spellId, spellLine, instance) end end - DetailsPlayerDetailsWindow_DetalheInfoBG_bg_end6:Hide() + DetailsBreakdownWindow_DetalheInfoBG_bg_end6:Hide() thatRectangle66:SetShown(true) end @@ -6319,6 +6404,8 @@ end function Details.refresh:r_atributo_damage (este_jogador, shadow) --restaura metas do ator detailsFramework:Mixin(este_jogador, Details222.Mixins.ActorMixin) + detailsFramework:Mixin(este_jogador, damageClassMixin) + setmetatable(este_jogador, Details.atributo_damage) este_jogador.__index = Details.atributo_damage --restaura as metas dos containers diff --git a/classes/class_spelldamage.lua b/classes/class_spelldamage.lua index ce4133af..1218115d 100644 --- a/classes/class_spelldamage.lua +++ b/classes/class_spelldamage.lua @@ -34,10 +34,13 @@ id = id, --spellid successful_casted = 0, --successful casted times (only for enemies) - --normal hits + --min damage made by normal hits n_min = 0, + --max damage made by normal hits n_max = 0, + --amount normal hits n_amt = 0, + --total damage of normal hits n_dmg = 0, --critical hits diff --git a/classes/container_spells.lua b/classes/container_spells.lua index bdc52993..3720a48d 100644 --- a/classes/container_spells.lua +++ b/classes/container_spells.lua @@ -40,7 +40,7 @@ local addonName, Details222 = ... ---get the spellTable for the passed spellId ---@param spellId number ---@return table - function container_habilidades:GetSpell (spellId) + function container_habilidades:GetSpell(spellId) return self._ActorTable[spellId] end diff --git a/core/control.lua b/core/control.lua index a800c3e8..823a1d66 100644 --- a/core/control.lua +++ b/core/control.lua @@ -42,6 +42,14 @@ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --details api functions + ---for a number to the current selected abbreviation + ---@param number number + ---@return string + function Details:Format(number) + return Details.ToKFunctions[Details.ps_abbreviation](nil, number) + end + + --try to find the opponent of last fight, can be called during a fight as well function Details:FindEnemy() diff --git a/core/parser.lua b/core/parser.lua index 741bc729..1abc7730 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -322,8 +322,12 @@ [45284] = 188196, --shaman lightining bolt overloaded [228361] = 228360, --shadow priest void erruption - } + + --all totem + --377461 382133 + --377458 377459 + end local bitfield_debuffs = {} diff --git a/core/util.lua b/core/util.lua index bc763f33..2f224f0a 100644 --- a/core/util.lua +++ b/core/util.lua @@ -518,6 +518,7 @@ local left,num,right = _string_match (n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end + function _detalhes:comma_value_raw (n) local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right @@ -677,6 +678,15 @@ return _detalhes.ToKFunctions [_detalhes.ps_abbreviation] end + --alias + ---transfor an integer into a string separating thousands with a comma + ---@param number number + ---@return string + function Details:CommaValue(number) + return Details:comma_value(number) + end + + ------------------------------------------------------------------------------------------------------------ --numerical system diff --git a/frames/window_playerbreakdown.lua b/frames/window_playerbreakdown.lua index e1e7d87f..16b140ab 100644 --- a/frames/window_playerbreakdown.lua +++ b/frames/window_playerbreakdown.lua @@ -1,29 +1,28 @@ -local _detalhes = _G._detalhes +local _detalhes = _G._detalhes local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") local gump = _detalhes.gump local _ local addonName, Details222 = ... + --lua locals ---local _string_len = string.len -local _math_floor = math.floor local ipairs = ipairs local pairs = pairs local type = type +local unpack = unpack + --api locals local CreateFrame = CreateFrame local GetTime = GetTime local _GetSpellInfo = _detalhes.getspellinfo local _GetCursorPosition = GetCursorPosition -local _unpack = unpack +local GameTooltip = GameTooltip -local atributos = _detalhes.atributos local sub_atributos = _detalhes.sub_atributos - local info = _detalhes.playerDetailWindow -local classe_icones = _G.CLASS_ICON_TCOORDS +local breakdownWindow = info local container3_bars_pointFunc local SummaryWidgets = {} @@ -42,13 +41,13 @@ local containerSettings = { spells = { width = 419, height = 290, - point = {"TOPLEFT", DetailsPlayerDetailsWindow, "TOPLEFT", 2, -76}, + point = {"TOPLEFT", breakdownWindow, "TOPLEFT", 2, -76}, scrollHeight = 264, }, targets = { width = 418, height = 150, - point = {"BOTTOMLEFT", DetailsPlayerDetailsWindow, "BOTTOMLEFT", 2, 6 + PLAYER_DETAILS_STATUSBAR_HEIGHT}, + point = {"BOTTOMLEFT", breakdownWindow, "BOTTOMLEFT", 2, 6 + PLAYER_DETAILS_STATUSBAR_HEIGHT}, }, } @@ -114,6 +113,34 @@ function Details:IsBreakdownWindowOpen() return info.ativo end +function Details222.PlayerBreakdown.StartMoving() + breakdownWindow:StartMoving() + breakdownWindow.bIsMoving = true +end + +function Details222.PlayerBreakdown.StopMoving() + if (breakdownWindow.bIsMoving) then + breakdownWindow:StopMovingOrSizing() + breakdownWindow.bIsMoving = false + end +end + +function Details222.PlayerBreakdown.OnMouseDown(frameClicked, button) + if (button == "LeftButton" and not breakdownWindow.bIsMoving) then + breakdownWindow.latestFrameClicked = frameClicked + Details222.PlayerBreakdown.StartMoving() + + elseif (button == "RightButton" and not breakdownWindow.bIsMoving) then + Details:CloseBreakdownWindow() + end +end + +function Details222.PlayerBreakdown.OnMouseUp(button) + if (button == "LeftButton" and breakdownWindow.bIsMoving) then + Details222.PlayerBreakdown.StopMoving() + end +end + --english alias --window object from Details:GetWindow(n) and playerObject from Details:GetPlayer(playerName, attribute) function Details:OpenPlayerBreakdown(windowObject, playerObject, from_att_change) --windowObject = instanceObject @@ -141,6 +168,46 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo return end + if (not breakdownWindow.registeredLibWindow) then + local LibWindow = LibStub("LibWindow-1.1") + breakdownWindow.registeredLibWindow = true + if (LibWindow) then + breakdownWindow.libWindowTable = breakdownWindow.libWindowTable or {} + LibWindow.RegisterConfig(breakdownWindow, breakdownWindow.libWindowTable) + LibWindow.RestorePosition(breakdownWindow) + LibWindow.MakeDraggable(breakdownWindow) + LibWindow.SavePosition(breakdownWindow) + else + breakdownWindow:SetScript("OnMouseDown", function(self, button) + Details222.PlayerBreakdown.OnMouseDown(button) + end) + breakdownWindow:SetScript("OnMouseUp", function(self, button) + Details222.PlayerBreakdown.OnMouseUp(button) + end) + end + end + + ---@type function + local onEventFunction = breakdownWindow:GetScript("OnEvent") + + if (not onEventFunction) then + ---this is a workaround of an issue when a frame calls StartMoving() on the parent, many times the child doesn't receive the OnMouseUp event + ---@param breakdownWindow frame + ---@param event string + ---@param button string + breakdownWindow:SetScript("OnEvent", function(breakdownWindow, event, button) + if (breakdownWindow.bIsMoving and breakdownWindow.latestFrameClicked) then + Details222.PlayerBreakdown.StopMoving() + local OnMouseUp = breakdownWindow.latestFrameClicked:GetScript("OnMouseUp") + if (OnMouseUp) then + OnMouseUp(breakdownWindow.latestFrameClicked, button) + end + breakdownWindow.latestFrameClicked = nil + end + end) + breakdownWindow:RegisterEvent("GLOBAL_MOUSE_UP") + end + --_detalhes.info_jogador armazena o jogador que esta sendo mostrado na janela de detalhes if (info.jogador and info.jogador == jogador and self and info.atributo and self.atributo == info.atributo and self.sub_atributo == info.sub_atributo and not refresh) then _detalhes:FechaJanelaInfo() --se clicou na mesma barra ent�o fecha a janela de detalhes @@ -236,14 +303,11 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo mergePetSpellsLabel:SetAlpha(rightSideBarAlpha) end - --passar os par�metros para dentro da tabela da janela. - info.ativo = true --sinaliza o addon que a janela esta aberta info.atributo = self.atributo --instancia.atributo -> grava o atributo (damage, heal, etc) info.sub_atributo = self.sub_atributo --instancia.sub_atributo -> grava o sub atributo (damage done, dps, damage taken, etc) info.jogador = jogador --de qual jogador (objeto classe_damage) info.instancia = self --salva a refer�ncia da inst�ncia que pediu o info - info.target_text = Loc ["STRING_TARGETS"] .. ":" info.target_member = "total" info.target_persecond = false @@ -276,7 +340,6 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo end if (avatar and avatar [2]) then - info.avatar:SetTexture(avatar [2]) info.avatar_bg:SetTexture(avatar [4]) if (avatar [5]) then @@ -297,9 +360,7 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo info.avatar_attribute:Show() info.nome:Hide() info.atributo_nome:Hide() - else - info.avatar:Hide() info.avatar_bg:Hide() info.avatar_nick:Hide() @@ -311,15 +372,9 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo info.atributo_nome:SetPoint("CENTER", info.nome, "CENTER", 0, 14) - info.no_targets:Hide() - info.no_targets.text:Hide() - gump:TrocaBackgroundInfo (info) - - gump:HidaAllBarrasInfo() - gump:HidaAllBarrasAlvo() - gump:HidaAllDetalheInfo() - - gump:JI_AtualizaContainerBarras (-1) + --need a way to comunicate with the main tab showing spells + --need to send a signal to reset its contents and prepare for a new player + --spellsTab.ResetBars() local classe = jogador.classe @@ -327,29 +382,11 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo classe = "monster" end - --info.classe_icone:SetTexture("Interface\\AddOns\\Details\\images\\"..classe:lower()) --top left info.classe_icone:SetTexture("Interface\\AddOns\\Details\\images\\classes") --top left info.SetClassIcon (jogador, classe) - if (_detalhes.player_details_window.skin == "WoWClassic") then - if (jogador.grupo and IsInRaid() and not avatar) then - for i = 1, GetNumGroupMembers() do - local playerName, realmName = UnitName ("raid" .. i) - if (realmName and realmName ~= "") then - playerName = playerName .. "-" .. realmName - end - if (playerName == jogador.nome) then - SetPortraitTexture (info.classe_icone, "raid" .. i) - info.classe_icone:SetTexCoord(0, 1, 0, 1) - break - end - end - end - end - Details.FadeHandler.Fader(info, 0) Details:UpdateBreakdownPlayerList() - Details:InitializeAurasTab() Details:InitializeCompareTab() @@ -376,11 +413,9 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo if (attributeList[info.atributo][info.sub_atributo]) then local tabReplaced, tabIndex = Details:GetBreakdownTabByName(tab.replaces.tabNameToReplace, tabsShown) if (tabReplaced and tabIndex < index) then - tabReplaced:Hide() tabReplaced.frame:Hide() tinsert(tabsReplaced, tabReplaced) - tremove(tabsShown, tabIndex) tinsert(tabsShown, tabIndex, tab) @@ -410,15 +445,20 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo info.currentTabsInUse = newTabsShown info:ShowTabs() + Details222.BreakdownWindow.CurrentDefaultTab = nil local shownTab for index = 1, #tabsShown do - local tab = tabsShown[index] - if (tab:condition(info.jogador, info.atributo, info.sub_atributo)) then - if (info.selectedTab == tab.tabname) then - tabsShown[index]:Click() - tabsShown[index]:OnShowFunc() - shownTab = tabsShown[index] + local tabButton = tabsShown[index] + if (tabButton:condition(info.jogador, info.atributo, info.sub_atributo)) then + if (tabButton.IsDefaultTab) then + Details222.BreakdownWindow.CurrentDefaultTab = tabButton + end + + if (info.selectedTab == tabButton.tabname) then + tabButton:DoClick() + tabButton:OnShowFunc() + shownTab = tabButton end end end @@ -428,657 +468,98 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo end end --end of "AbreJanelaInfo()" --- for beta todo: info background need a major rewrite -function gump:TrocaBackgroundInfo() --> spells tab - info.bg3_sec_texture:Hide() - info.bg2_sec_texture:Hide() - info.apoio_icone_esquerdo:Show() - info.apoio_icone_direito:Show() +--alias +function Details:CloseBreakdownWindow(bFromEscape) + return _detalhes:FechaJanelaInfo(bFromEscape) +end - info.report_direita:Hide() - - for i = 1, spellInfoSettings.amount do - info ["right_background" .. i]:Show() - end - - if (info.atributo == 1) then --DANO - - if (info.sub_atributo == 1 or info.sub_atributo == 2) then --damage done / dps - info.bg1_sec_texture:SetTexture("") - info.tipo = 1 - - if (info.sub_atributo == 2) then - info.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_DPS"] .. ":") - info.target_persecond = true - else - info.targets:SetText(Loc ["STRING_TARGETS"] .. ":") - end - - elseif (info.sub_atributo == 3) then --damage taken - - --info.bg1_sec_texture:SetTexture([[Interface\AddOns\Details\images\info_window_damagetaken]]) - info.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) - info.bg3_sec_texture:Show() - info.bg2_sec_texture:Show() - info.tipo = 2 - - for i = 1, spellInfoSettings.amount do - info ["right_background" .. i]:Hide() - end - - info.targets:SetText(Loc ["STRING_TARGETS"] .. ":") - info.no_targets:Show() - info.no_targets.text:Show() - - info.apoio_icone_esquerdo:Hide() - info.apoio_icone_direito:Hide() - info.report_direita:Show() - - elseif (info.sub_atributo == 4) then --friendly fire - --info.bg1_sec_texture:SetTexture([[Interface\AddOns\Details\images\info_window_damagetaken]]) - info.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) - info.bg3_sec_texture:Show() - info.bg2_sec_texture:Show() - info.tipo = 3 - - for i = 1, spellInfoSettings.amount do - info ["right_background" .. i]:Hide() - end - - info.targets:SetText(Loc ["STRING_SPELLS"] .. ":") - - info.apoio_icone_esquerdo:Hide() - info.apoio_icone_direito:Hide() - info.report_direita:Show() - - elseif (info.sub_atributo == 6) then --enemies - --info.bg1_sec_texture:SetTexture([[Interface\AddOns\Details\images\info_window_damagetaken]]) - info.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) - info.bg3_sec_texture:Show() - info.bg2_sec_texture:Show() - info.tipo = 3 - - for i = 1, spellInfoSettings.amount do - info ["right_background" .. i]:Hide() - end - - info.targets:SetText(Loc ["STRING_DAMAGE_TAKEN_FROM"]) +function _detalhes:FechaJanelaInfo(fromEscape) + if (info.ativo) then + if (fromEscape) then + Details.FadeHandler.Fader(info, "in") + else + Details.FadeHandler.Fader(info, 1) end + info.ativo = false --sinaliza o addon que a janela esta agora fechada - elseif (info.atributo == 2) then --HEALING - if (info.sub_atributo == 1 or info.sub_atributo == 2 or info.sub_atributo == 3) then --damage done / dps - info.bg1_sec_texture:SetTexture("") - info.tipo = 1 + --_detalhes.info_jogador.detalhes = nil + info.jogador = nil + info.atributo = nil + info.sub_atributo = nil + info.instancia = nil - if (info.sub_atributo == 3) then - info.targets:SetText(Loc ["STRING_OVERHEALED"] .. ":") - info.target_member = "overheal" - info.target_text = Loc ["STRING_OVERHEALED"] .. ":" - elseif (info.sub_atributo == 2) then - info.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_HEAL_HPS"] .. ":") - info.target_persecond = true - else - info.targets:SetText(Loc ["STRING_TARGETS"] .. ":") - end - - elseif (info.sub_atributo == 4) then --Healing taken - info.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) - info.bg3_sec_texture:Show() - info.bg2_sec_texture:Show() - info.tipo = 2 - - for i = 1, spellInfoSettings.amount do - info ["right_background" .. i]:Hide() - end - - info.targets:SetText(Loc ["STRING_TARGETS"] .. ":") - info.no_targets:Show() - info.no_targets.text:Show() - - info.apoio_icone_esquerdo:Hide() - info.apoio_icone_direito:Hide() - info.report_direita:Show() - end - - elseif (info.atributo == 3) then --REGEN - info.bg1_sec_texture:SetTexture("") - info.tipo = 2 - info.targets:SetText("Vindo de:") - - elseif (info.atributo == 4) then --MISC - info.bg1_sec_texture:SetTexture("") - info.tipo = 2 - - info.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + info.nome:SetText("") + info.atributo_nome:SetText("") end end -do --close the breakdown window --> spells tab - --self � qualquer coisa que chamar esta fun��o - ------------------------------------------------------------------------------------------------------------------------------ - -- � chamado pelo click no X e pelo reset do historico +---@type {[number]: boolean} +Details222.BreakdownWindow.ExpandedSpells = {} - --alias - function Details:CloseBreakdownWindow(bFromEscape) - return _detalhes:FechaJanelaInfo(bFromEscape) - end - - function _detalhes:FechaJanelaInfo(fromEscape) - if (info.ativo) then --se a janela tiver aberta - --playerDetailWindow:Hide() - if (fromEscape) then - Details.FadeHandler.Fader(info, "in") - else - Details.FadeHandler.Fader(info, 1) - end - info.ativo = false --sinaliza o addon que a janela esta agora fechada - - --_detalhes.info_jogador.detalhes = nil - info.jogador = nil - info.atributo = nil - info.sub_atributo = nil - info.instancia = nil - - info.nome:SetText("") - info.atributo_nome:SetText("") - - gump:JI_AtualizaContainerBarras (-1) --reseta o frame das barras - end - end +---set a spell as expanded or not in the breakdown window +---@param spellID number +---@param bIsExpanded boolean +function Details222.BreakdownWindow.SetSpellAsExpanded(spellID, bIsExpanded) + Details222.BreakdownWindow.ExpandedSpells[spellID] = bIsExpanded end -do --hide bars on the scrollbars of the window --> spells tab - - --esconde todas as barras das skills na janela de info - ------------------------------------------------------------------------------------------------------------------------------ - function gump:HidaAllBarrasInfo() - local barras = _detalhes.playerDetailWindow.barras1 - for index = 1, #barras, 1 do - barras [index]:Hide() - barras [index].textura:SetStatusBarColor(1, 1, 1, 1) - barras [index].on_focus = false - end - end - - --esconde todas as barras dos alvos do jogador - ------------------------------------------------------------------------------------------------------------------------------ - function gump:HidaAllBarrasAlvo() - local barras = _detalhes.playerDetailWindow.barras2 - for index = 1, #barras, 1 do - barras [index]:Hide() - end - end - - --esconde as 5 barras a direita na janela de info - ------------------------------------------------------------------------------------------------------------------------------ - function gump:HidaAllDetalheInfo() - for i = 1, spellInfoSettings.amount do - gump:HidaDetalheInfo (i) - end - for _, barra in ipairs(info.barras3) do - barra:Hide() - end - _detalhes.playerDetailWindow.spell_icone:SetTexture("") - end -end - ---set scripts on each bar of the scrollbars of the window --> spells tab - --seta os scripts da janela de informa��es - local mouse_down_func = function(self, button) - if (button == "LeftButton") then - info:StartMoving() - info.isMoving = true - elseif (button == "RightButton" and not self.isMoving) then - _detalhes:FechaJanelaInfo() - end - end - - local mouse_up_func = function(self, button) - if (info.isMoving) then - info:StopMovingOrSizing() - info.isMoving = false - end - end - - local function seta_scripts (este_gump) --> spells tab - --Janela - este_gump:SetScript("OnMouseDown", mouse_down_func) - este_gump:SetScript("OnMouseUp", mouse_up_func) - - este_gump.container_barras.gump:SetScript("OnMouseDown", mouse_down_func) - este_gump.container_barras.gump:SetScript("OnMouseUp", mouse_up_func) - - este_gump.container_detalhes:SetScript("OnMouseDown", mouse_down_func) - este_gump.container_detalhes:SetScript("OnMouseUp", mouse_up_func) - - este_gump.container_alvos.gump:SetScript("OnMouseDown", mouse_down_func) - este_gump.container_alvos.gump:SetScript("OnMouseUp", mouse_up_func) - - --bot�o fechar - este_gump.close_button:SetScript("OnClick", function(self) - _detalhes:FechaJanelaInfo() - end) - end - ------------------------------------------------------------------------------------------------------------------------------- -function gump:HidaDetalheInfo (index) --> spells tab - local info = _detalhes.playerDetailWindow.grupos_detalhes [index] - info.nome:SetText("") - info.nome2:SetText("") - info.dano:SetText("") - info.dano_porcento:SetText("") - info.dano_media:SetText("") - info.dano_dps:SetText("") - info.bg:Hide() -end - ---cria a barra de detalhes a direita da janela de informa��es ------------------------------------------------------------------------------------------------------------------------------- - -local detalhe_infobg_onenter = function(self) - Details.FadeHandler.Fader(self.overlay, "OUT") - Details.FadeHandler.Fader(self.reportar, "OUT") -end - -local detalhe_infobg_onleave = function(self) - Details.FadeHandler.Fader(self.overlay, "IN") - Details.FadeHandler.Fader(self.reportar, "IN") -end - -local detalhes_inforeport_onenter = function(self) - Details.FadeHandler.Fader(self:GetParent().overlay, "OUT") - Details.FadeHandler.Fader(self, "OUT") -end -local detalhes_inforeport_onleave = function(self) - Details.FadeHandler.Fader(self:GetParent().overlay, "IN") - Details.FadeHandler.Fader(self, "IN") -end - -local getFrameFromDetailInfoBlock = function(self) - return self.bg -end - -function gump:CriaDetalheInfo(index) --> spells tab - local spellInfoBlock = {} - spellInfoBlock.GetFrame = getFrameFromDetailInfoBlock - - spellInfoBlock.bg = CreateFrame("StatusBar", "DetailsPlayerDetailsWindow_DetalheInfoBG" .. index, _detalhes.playerDetailWindow.container_detalhes, "BackdropTemplate") - --spellInfoBlock.bg:SetStatusBarTexture("") --Interface\\AddOns\\Details\\images\\bar_detalhes2 - --bar_detalhes2 bar_background - spellInfoBlock.bg:SetStatusBarTexture("Interface\\AddOns\\Details\\images\\bar_background") --Interface\\AddOns\\Details\\images\\bar_detalhes2 - spellInfoBlock.bg:SetStatusBarColor(1, 1, 1, .84) - spellInfoBlock.bg:SetMinMaxValues(0, 100) - spellInfoBlock.bg:SetValue(100) - spellInfoBlock.bg:SetSize(320, 47) - - spellInfoBlock.nome = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontNormal") - spellInfoBlock.nome2 = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.dano = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.dano_porcento = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.dano_media = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.dano_dps = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - - spellInfoBlock.middleStringUp = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.middleStringDown = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - spellInfoBlock.middleStringMiddle = spellInfoBlock.bg:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - - spellInfoBlock.bg.overlay = spellInfoBlock.bg:CreateTexture("DetailsPlayerDetailsWindow_DetalheInfoBG_Overlay" .. index, "ARTWORK") - spellInfoBlock.bg.overlay:SetTexture("Interface\\AddOns\\Details\\images\\overlay_detalhes") - spellInfoBlock.bg.overlay:SetWidth(341) - spellInfoBlock.bg.overlay:SetHeight(61) - spellInfoBlock.bg.overlay:SetPoint("TOPLEFT", spellInfoBlock.bg, "TOPLEFT", -7, 6) - Details.FadeHandler.Fader(spellInfoBlock.bg.overlay, 1) - - spellInfoBlock.bg.reportar = gump:NewDetailsButton (spellInfoBlock.bg, nil, nil, _detalhes.Reportar, _detalhes.playerDetailWindow, 10+index, 16, 16, - "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport1") - spellInfoBlock.bg.reportar:SetPoint("BOTTOMLEFT", spellInfoBlock.bg.overlay, "BOTTOMRIGHT", -33, 10) - Details.FadeHandler.Fader(spellInfoBlock.bg.reportar, 1) - - spellInfoBlock.bg:SetScript("OnEnter", detalhe_infobg_onenter) - spellInfoBlock.bg:SetScript("OnLeave", detalhe_infobg_onleave) - - spellInfoBlock.bg.reportar:SetScript("OnEnter", detalhes_inforeport_onenter) - spellInfoBlock.bg.reportar:SetScript("OnLeave", detalhes_inforeport_onleave) - - spellInfoBlock.bg_end = spellInfoBlock.bg:CreateTexture("DetailsPlayerDetailsWindow_DetalheInfoBG_bg_end" .. index, "BACKGROUND") - spellInfoBlock.bg_end:SetHeight(40) - spellInfoBlock.bg_end:SetTexture("Interface\\AddOns\\Details\\images\\bar_detalhes2_end") - - _detalhes.playerDetailWindow.grupos_detalhes[index] = spellInfoBlock -end - -function info:SetDetailInfoConfigs(texture, color, x, y) --> spells tab - for i = 1, spellInfoSettings.amount do - if (texture) then - info.grupos_detalhes[i].bg:SetStatusBarTexture(texture) - end - - if (color) then - local texture = info.grupos_detalhes[i].bg:GetStatusBarTexture() - texture:SetVertexColor(unpack(color)) - end - - if (x or y) then - gump:SetaDetalheInfoAltura(i, x, y) - end - end +---get the state of the expanded for a spell +---@param spellID number +---@return boolean +function Details222.BreakdownWindow.IsSpellExpanded(spellID) + return Details222.BreakdownWindow.ExpandedSpells[spellID] end --determina qual a pocis�o que a barra de detalhes vai ocupar ------------------------------------------------------------------------------------------------------------------------------ --namespace -Details222.BreakdownWindow = {} -function Details222.BreakdownWindow.GetBlockIndex(index) +function Details222.BreakdownWindow.GetBlockIndex(index) --getting the infomation from the new spells tab, this will be depreccated soon return Details.playerDetailWindow.grupos_detalhes[index] end -function gump:SetaDetalheInfoAltura(index, xmod, ymod) - local spellInfoBlock = _detalhes.playerDetailWindow.grupos_detalhes[index] - --local janela = _detalhes.playerDetailWindow.container_detalhes - --local altura = {-10, -63, -118, -173, -228, -279} - --altura = altura[index] - - local background - local yOffset = -74 - ((index-1) * 79.5) - - if (index == 1) then - _detalhes.playerDetailWindow.right_background1:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background1 - - elseif (index == 2) then - _detalhes.playerDetailWindow.right_background2:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background2 - - elseif (index == 3) then - _detalhes.playerDetailWindow.right_background3:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background3 - - elseif (index == 4) then - _detalhes.playerDetailWindow.right_background4:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background4 - - elseif (index == 5) then - _detalhes.playerDetailWindow.right_background5:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background5 - - elseif (index == 6) then - _detalhes.playerDetailWindow.right_background6:SetPoint("topleft", _detalhes.playerDetailWindow, "topleft", 357 + (xmod or 0), yOffset) - background = _detalhes.playerDetailWindow.right_background6 - - end - - background:SetHeight(75) - - --3 textos da esquerda e direita - local yOffset = -3 - local xOffset = 3 - local right = -1 - - spellInfoBlock.nome:SetPoint("TOPLEFT", background, "TOPLEFT", xOffset, yOffset + (-2)) - spellInfoBlock.dano:SetPoint("TOPLEFT", background, "TOPLEFT", xOffset, yOffset + (-24)) - spellInfoBlock.dano_media:SetPoint("TOPLEFT", background, "TOPLEFT", xOffset, yOffset + (-44)) - - spellInfoBlock.nome2:SetPoint("TOPRIGHT", background, "TOPRIGHT", -xOffset + right, yOffset + (-4)) - spellInfoBlock.dano_porcento:SetPoint("TOPRIGHT", background, "TOPRIGHT", -xOffset + right, yOffset + (-24)) - spellInfoBlock.dano_dps:SetPoint("TOPRIGHT", background, "TOPRIGHT", -xOffset + right, yOffset + (-44)) - - spellInfoBlock.middleStringUp:SetPoint("center", background, "center", 0, 0) - spellInfoBlock.middleStringUp:SetPoint("top", background, "top", 0, -7) - - spellInfoBlock.middleStringDown:SetPoint("center", background, "center", 0, 0) - spellInfoBlock.middleStringDown:SetPoint("bottom", background, "bottom", 0, 19) - - spellInfoBlock.middleStringMiddle:SetPoint("center", background, "center", 0, 6) - - spellInfoBlock.bg:SetPoint("TOPLEFT", background, "TOPLEFT", 1, -1) - spellInfoBlock.bg:SetHeight(background:GetHeight() - 2) - spellInfoBlock.bg:SetWidth(background:GetWidth()) - - spellInfoBlock.bg_end:SetPoint("LEFT", spellInfoBlock.bg, "LEFT", spellInfoBlock.bg:GetValue()*2.19, 0) - spellInfoBlock.bg_end:SetHeight(background:GetHeight()-2) - spellInfoBlock.bg_end:SetWidth(6) - spellInfoBlock.bg_end:SetAlpha(.75) - - spellInfoBlock.bg.overlay:SetWidth(background:GetWidth() + 24) - spellInfoBlock.bg.overlay:SetHeight(background:GetHeight() + 16) - - spellInfoBlock.bg:Hide() -end - ---seta o conte�do da barra de detalhes ------------------------------------------------------------------------------------------------------------------------------- -function gump:SetaDetalheInfoTexto(index, data, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - local spellInfoBlock = _detalhes.playerDetailWindow.grupos_detalhes[index] - - if (data) then - if (type(data) == "table") then - spellInfoBlock.bg:SetValue(data.p) - spellInfoBlock.bg:SetStatusBarColor(data.c[1], data.c[2], data.c[3], data.c[4] or 1) - else - local percentAmount = data - spellInfoBlock.bg:SetValue(percentAmount) - spellInfoBlock.bg:SetStatusBarColor(1, 1, 1, .5) +---receives spell data to show in the summary tab +---@param data table +---@param actorObject actor +---@param combatObject combat +---@param instance instance +function Details222.BreakdownWindow.SendSpellData(data, actorObject, combatObject, instance) + --need to get the tab showing the summary and transmit the data to it + local tab = Details222.BreakdownWindow.CurrentDefaultTab + if (tab) then + --tab is the tab button + if (tab.OnReceiveSpellData) then + tab.OnReceiveSpellData(data, actorObject, combatObject, instance) end - - spellInfoBlock.bg_end:Show() - spellInfoBlock.bg_end:SetPoint("LEFT", spellInfoBlock.bg, "LEFT", (spellInfoBlock.bg:GetValue() * (spellInfoBlock.bg:GetWidth( ) / 100)) - 3, 0) -- 2.19 - spellInfoBlock.bg:Show() - end - - if (spellInfoBlock.IsPet) then - spellInfoBlock.bg.PetIcon:Hide() - spellInfoBlock.bg.PetText:Hide() - spellInfoBlock.bg.PetDps:Hide() - Details.FadeHandler.Fader(spellInfoBlock.bg.overlay, "IN") - spellInfoBlock.IsPet = false - end - - if (arg1) then - spellInfoBlock.nome:SetText(arg1) - end - - if (arg2) then - spellInfoBlock.dano:SetText(arg2) - end - - if (arg3) then - spellInfoBlock.dano_porcento:SetText(arg3) - end - - if (arg4) then - spellInfoBlock.dano_media:SetText(arg4) - end - - if (arg5) then - spellInfoBlock.dano_dps:SetText(arg5) - end - - if (arg6) then - spellInfoBlock.nome2:SetText(arg6) - end - - if (arg7) then - spellInfoBlock.middleStringUp:SetText(arg7) - else - spellInfoBlock.middleStringUp:SetText("") - end - - if (arg8) then - spellInfoBlock.middleStringDown:SetText(arg8) - else - spellInfoBlock.middleStringDown:SetText("") - end - - if (arg9) then - spellInfoBlock.middleStringMiddle:SetText(arg9) - else - spellInfoBlock.middleStringMiddle:SetText("") - end - - spellInfoBlock.nome:Show() - spellInfoBlock.dano:Show() - spellInfoBlock.dano_porcento:Show() - spellInfoBlock.dano_media:Show() - spellInfoBlock.dano_dps:Show() - spellInfoBlock.nome2:Show() - spellInfoBlock.middleStringUp:Show() - spellInfoBlock.middleStringDown:Show() - spellInfoBlock.middleStringDown:Show() - spellInfoBlock.middleStringMiddle:Show() -end - ---cria as 5 caixas de detalhes infos que ser�o usados ------------------------------------------------------------------------------------------------------------------------------- -local function cria_barras_detalhes() - _detalhes.playerDetailWindow.grupos_detalhes = {} - for i = 1, spellInfoSettings.amount do - gump:CriaDetalheInfo (i) - gump:SetaDetalheInfoAltura(i) end end --cria os textos em geral da janela info ------------------------------------------------------------------------------------------------------------------------------- -local function cria_textos (este_gump, SWW) - este_gump.nome = este_gump:CreateFontString(nil, "OVERLAY", "QuestFont_Large") - este_gump.nome:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 105, -54) +function breakdownWindow.CreateTexts(SWW) + breakdownWindow.nome = breakdownWindow:CreateFontString(nil, "OVERLAY", "QuestFont_Large") + breakdownWindow.nome:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 105, -54) - este_gump.atributo_nome = este_gump:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + breakdownWindow.atributo_nome = breakdownWindow:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - este_gump.targets = SWW:CreateFontString(nil, "OVERLAY", "QuestFont_Large") - este_gump.targets:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 24, -273) - este_gump.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + breakdownWindow.avatar = breakdownWindow:CreateTexture(nil, "overlay") + breakdownWindow.avatar_bg = breakdownWindow:CreateTexture(nil, "overlay") + breakdownWindow.avatar_attribute = breakdownWindow:CreateFontString(nil, "overlay", "GameFontHighlightSmall") + breakdownWindow.avatar_nick = breakdownWindow:CreateFontString(nil, "overlay", "QuestFont_Large") + breakdownWindow.avatar:SetDrawLayer("overlay", 3) + breakdownWindow.avatar_bg:SetDrawLayer("overlay", 2) + breakdownWindow.avatar_nick:SetDrawLayer("overlay", 4) - este_gump.avatar = este_gump:CreateTexture(nil, "overlay") - este_gump.avatar_bg = este_gump:CreateTexture(nil, "overlay") - este_gump.avatar_attribute = este_gump:CreateFontString(nil, "overlay", "GameFontHighlightSmall") - este_gump.avatar_nick = este_gump:CreateFontString(nil, "overlay", "QuestFont_Large") - este_gump.avatar:SetDrawLayer("overlay", 3) - este_gump.avatar_bg:SetDrawLayer("overlay", 2) - este_gump.avatar_nick:SetDrawLayer("overlay", 4) + breakdownWindow.avatar:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 60, -10) + breakdownWindow.avatar_bg:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 60, -12) + breakdownWindow.avatar_bg:SetSize(275, 60) - este_gump.avatar:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 60, -10) - este_gump.avatar_bg:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 60, -12) - este_gump.avatar_bg:SetSize(275, 60) + breakdownWindow.avatar_nick:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 195, -54) - este_gump.avatar_nick:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 195, -54) - - este_gump.avatar:Hide() - este_gump.avatar_bg:Hide() - este_gump.avatar_nick:Hide() + breakdownWindow.avatar:Hide() + breakdownWindow.avatar_bg:Hide() + breakdownWindow.avatar_nick:Hide() end ---esquerdo superior -local function cria_container_barras (este_gump, SWW) - local container_barras_window = CreateFrame("ScrollFrame", "Details_Info_ContainerBarrasScroll", SWW, "BackdropTemplate") - local container_barras = CreateFrame("Frame", "Details_Info_ContainerBarras", container_barras_window, "BackdropTemplate") - - container_barras:SetAllPoints(container_barras_window) - container_barras:SetWidth(300) - container_barras:SetHeight(150) - container_barras:EnableMouse(true) - container_barras:SetMovable(true) - - container_barras_window:SetWidth(300) - container_barras_window:SetHeight(145) - container_barras_window:SetScrollChild(container_barras) - container_barras_window:SetPoint("TOPLEFT", este_gump, "TOPLEFT", 21, -76) - - container_barras_window:SetScript("OnSizeChanged", function(self) - container_barras:SetSize(self:GetSize()) - end) - - gump:NewScrollBar (container_barras_window, container_barras, 6, -17) - container_barras_window.slider:Altura (117) - container_barras_window.slider:cimaPoint (0, 1) - container_barras_window.slider:baixoPoint (0, -3) - - container_barras_window.ultimo = 0 - - container_barras_window.gump = container_barras - --container_barras_window.slider = slider_gump - este_gump.container_barras = container_barras_window - -end - -function gump:JI_AtualizaContainerBarras (amt) - local container = _detalhes.playerDetailWindow.container_barras - - if (amt >= 9 and container.ultimo ~= amt) then - local tamanho = (CONST_BAR_HEIGHT + 1) * amt - container.gump:SetHeight(tamanho) - container.slider:Update() - container.ultimo = amt - - elseif (amt < 8 and container.slider.ativo) then - container.slider:Update (true) - container.gump:SetHeight(140) - container.scroll_ativo = false - container.ultimo = 0 - end -end - -function gump:JI_AtualizaContainerAlvos (amt) - - local container = _detalhes.playerDetailWindow.container_alvos - - if (amt >= 6 and container.ultimo ~= amt) then - local tamanho = (CONST_TARGET_HEIGHT + 1) * amt - container.gump:SetHeight(tamanho) - container.slider:Update() - container.ultimo = amt - - elseif (amt <= 5 and container.slider.ativo) then - container.slider:Update (true) - container.gump:SetHeight(100) - container.scroll_ativo = false - container.ultimo = 0 - end -end - ---container direita -local function cria_container_detalhes (este_gump, SWW) - local container_detalhes = CreateFrame("Frame", "Details_Info_ContainerDetalhes", SWW, "BackdropTemplate") - - container_detalhes:SetPoint("TOPRIGHT", este_gump, "TOPRIGHT", -74, -76) - container_detalhes:SetWidth(220) - container_detalhes:SetHeight(270) - container_detalhes:EnableMouse(true) - container_detalhes:SetResizable(false) - container_detalhes:SetMovable(true) - - este_gump.container_detalhes = container_detalhes -end - ---esquerdo inferior -local function cria_container_alvos (este_gump, SWW) - local container_alvos_window = CreateFrame("ScrollFrame", "Details_Info_ContainerAlvosScroll", SWW, "BackdropTemplate") - local container_alvos = CreateFrame("Frame", "Details_Info_ContainerAlvos", container_alvos_window, "BackdropTemplate") - - container_alvos:SetAllPoints(container_alvos_window) - container_alvos:SetWidth(300) - container_alvos:SetHeight(100) - container_alvos:EnableMouse(true) - container_alvos:SetMovable(true) - - container_alvos_window:SetWidth(300) - container_alvos_window:SetHeight(100) - container_alvos_window:SetScrollChild(container_alvos) - container_alvos_window:SetPoint("BOTTOMLEFT", este_gump, "BOTTOMLEFT", 20, 6) --56 default - - container_alvos_window:SetScript("OnSizeChanged", function(self) - container_alvos:SetSize(self:GetSize()) - end) - - gump:NewScrollBar (container_alvos_window, container_alvos, 7, 4) - container_alvos_window.slider:Altura (88) - container_alvos_window.slider:cimaPoint (0, 1) - container_alvos_window.slider:baixoPoint (0, -3) - - container_alvos_window.gump = container_alvos - este_gump.container_alvos = container_alvos_window -end local default_icon_change = function(jogador, classe) if (classe ~= "UNKNOW" and classe ~= "UNGROUPPLAYER") then @@ -1095,7 +576,7 @@ local default_icon_change = function(jogador, classe) else if (jogador.enemy) then if (_detalhes.class_coords [_detalhes.faction_against]) then - info.classe_icone:SetTexCoord(_unpack(_detalhes.class_coords [_detalhes.faction_against])) + info.classe_icone:SetTexCoord(unpack(_detalhes.class_coords [_detalhes.faction_against])) if (_detalhes.faction_against == "Horde") then info.nome:SetTextColor(1, 91/255, 91/255, 1) else @@ -1113,17 +594,17 @@ end function _detalhes:InstallPDWSkin(skin_name, func) if (not skin_name) then return false -- sem nome - elseif (_detalhes.playerdetailwindow_skins [skin_name]) then + elseif (_detalhes.playerdetailwindow_skins[skin_name]) then return false -- ja existe end - _detalhes.playerdetailwindow_skins [skin_name] = func + _detalhes.playerdetailwindow_skins[skin_name] = func return true end function _detalhes:ApplyPDWSkin(skin_name) --already built - if (not DetailsPlayerDetailsWindow.Loaded) then + if (not DetailsBreakdownWindow.Loaded) then if (skin_name) then _detalhes.player_details_window.skin = skin_name end @@ -1131,7 +612,7 @@ function _detalhes:ApplyPDWSkin(skin_name) end --hide extra frames - local window = DetailsPlayerDetailsWindow + local window = DetailsBreakdownWindow if (window.extra_frames) then for framename, frame in pairs(window.extra_frames) do frame:Hide() @@ -1169,11 +650,11 @@ function _detalhes:ApplyPDWSkin(skin_name) end function _detalhes:SetPlayerDetailsWindowTexture (texture) - DetailsPlayerDetailsWindow.bg1:SetTexture(texture) + DetailsBreakdownWindow.bg1:SetTexture(texture) end function _detalhes:SetPDWBarConfig (texture) - local window = DetailsPlayerDetailsWindow + local window = DetailsBreakdownWindow if (texture) then _detalhes.player_details_window.bar_texture = texture @@ -1192,10 +673,10 @@ function _detalhes:SetPDWBarConfig (texture) end local default_skin = function()end -_detalhes:InstallPDWSkin ("WoWClassic", {func = default_skin, author = "Details! Team", version = "v1.0", desc = "Default skin."}) +_detalhes:InstallPDWSkin("WoWClassic", {func = default_skin, author = "Details! Team", version = "v1.0", desc = "Default skin."}) --deprecated local elvui_skin = function() - local window = DetailsPlayerDetailsWindow + local window = DetailsBreakdownWindow window.bg1:SetTexture([[Interface\AddOns\Details\images\background]], true) window.bg1:SetAlpha(0.7) window.bg1:SetVertexColor(0.27, 0.27, 0.27) @@ -1206,8 +687,6 @@ local elvui_skin = function() window:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]}) window:SetBackdropColor(1, 1, 1, 0.3) window:SetBackdropBorderColor(0, 0, 0, 1) - window.bg_icone_bg:Hide() - window.bg_icone:Hide() local bgs_alpha = 0.6 window.leftbars1_backgound:SetPoint("topleft", window.container_barras, "topleft", -2, 3) @@ -1281,16 +760,11 @@ local elvui_skin = function() window.container_alvos:SetSize(containerSettings.targets.width, containerSettings.targets.height) --texts - window.targets:SetPoint("topleft", window.container_alvos, "topleft", 3, 18) window.nome:SetPoint("TOPLEFT", window, "TOPLEFT", 105, -48) --report button window.topleft_report:SetPoint("BOTTOMLEFT", window.container_barras, "TOPLEFT", 43, 2) - --icons - window.apoio_icone_direito:SetBlendMode("ADD") - window.apoio_icone_esquerdo:SetBlendMode("ADD") - --no targets texture window.no_targets:SetPoint("BOTTOMLEFT", window, "BOTTOMLEFT", 3, 6) window.no_targets:SetSize(418, 150) @@ -1496,17 +970,20 @@ local elvui_skin = function() window.container_alvos.slider.thumb:SetVertexColor(0.6, 0.6, 0.6, 0.95) --class icon - window.SetClassIcon = function(player, class) - if (player.spellicon) then - window.classe_icone:SetTexture(player.spellicon) + ---set the spell, spec or class icon + ---@param actorObject actor + ---@param class string|nil + window.SetClassIcon = function(actorObject, class) + if (actorObject.spellicon) then + window.classe_icone:SetTexture(actorObject.spellicon) window.classe_icone:SetTexCoord(.1, .9, .1, .9) - elseif (player.spec) then + elseif (actorObject.spec) then window.classe_icone:SetTexture([[Interface\AddOns\Details\images\spec_icons_normal_alpha]]) - window.classe_icone:SetTexCoord(_unpack(_detalhes.class_specs_coords [player.spec])) + window.classe_icone:SetTexCoord(unpack(_detalhes.class_specs_coords [actorObject.spec])) --esta_barra.icone_classe:SetVertexColor(1, 1, 1) else - local coords = CLASS_ICON_TCOORDS [class] + local coords = CLASS_ICON_TCOORDS[class] if (coords) then info.classe_icone:SetTexture([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]]) local l, r, t, b = unpack(coords) @@ -1520,7 +997,8 @@ local elvui_skin = function() end end end -_detalhes:InstallPDWSkin ("ElvUI", {func = elvui_skin, author = "Details! Team", version = "v1.0", desc = "Skin compatible with ElvUI addon."}) + + --search key: ~create ~inicio ~start function gump:CriaJanelaInfo() @@ -1540,10 +1018,12 @@ function gump:CriaJanelaInfo() breakdownFrame:SetResizable(false) breakdownFrame:SetMovable(true) - breakdownFrame.SummaryWindowWidgets = CreateFrame("frame", "DetailsPlayerDetailsWindowSummaryWidgets", breakdownFrame, "BackdropTemplate") + --host the textures and fontstring of the default frame of the player breakdown window + breakdownFrame.SummaryWindowWidgets = CreateFrame("frame", "DetailsBreakdownWindowSummaryWidgets", breakdownFrame, "BackdropTemplate") local SWW = breakdownFrame.SummaryWindowWidgets SWW:SetAllPoints() table.insert(SummaryWidgets, SWW) --where SummaryWidgets is declared: at the header of the file, what is the purpose of this table? + --what is the summary window: is the frame where all the widgets for the summary tab are created DetailsFramework:CreateScaleBar(breakdownFrame, Details.player_details_window) breakdownFrame:SetScale(Details.player_details_window.scale) @@ -1563,61 +1043,27 @@ function gump:CriaJanelaInfo() breakdownFrame.close_button:SetPoint("TOPRIGHT", breakdownFrame, "TOPRIGHT", 5, -8) breakdownFrame.close_button:SetText("X") breakdownFrame.close_button:SetFrameLevel(breakdownFrame:GetFrameLevel()+5) + breakdownFrame.close_button:SetScript("OnClick", function(self) + Details:CloseBreakdownWindow() + end) --�cone da magia selecionada para mais detalhes (is this a window thing or tab thing?) --or this is even in use? - breakdownFrame.bg_icone_bg = breakdownFrame:CreateTexture(nil, "ARTWORK") - breakdownFrame.bg_icone_bg:SetPoint("TOPRIGHT", breakdownFrame, "TOPRIGHT", -15, -12) - breakdownFrame.bg_icone_bg:SetTexture("Interface\\AddOns\\Details\\images\\icone_bg_fundo") - breakdownFrame.bg_icone_bg:SetDrawLayer("ARTWORK", -1) - breakdownFrame.bg_icone_bg:Show() - - breakdownFrame.bg_icone = breakdownFrame:CreateTexture(nil, "OVERLAY") - breakdownFrame.bg_icone:SetPoint("TOPRIGHT", breakdownFrame, "TOPRIGHT", -15, -12) - breakdownFrame.bg_icone:SetTexture("Interface\\AddOns\\Details\\images\\icone_bg") - breakdownFrame.bg_icone:Show() --title DetailsFramework:NewLabel(breakdownFrame, breakdownFrame, nil, "title_string", Loc ["STRING_PLAYER_DETAILS"] .. " (|cFFFF8811Under Maintenance|r)", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255}) breakdownFrame.title_string:SetPoint("center", breakdownFrame, "center") breakdownFrame.title_string:SetPoint("top", breakdownFrame, "top", 0, -18) - --spell icon is still in use? what's the difference from the bg_icone? - breakdownFrame.spell_icone = breakdownFrame:CreateTexture(nil, "ARTWORK") - breakdownFrame.spell_icone:SetPoint("BOTTOMRIGHT", breakdownFrame.bg_icone, "BOTTOMRIGHT", -19, 2) - breakdownFrame.spell_icone:SetWidth(35) - breakdownFrame.spell_icone:SetHeight(34) - breakdownFrame.spell_icone:SetDrawLayer("ARTWORK", 0) - breakdownFrame.spell_icone:Show() - breakdownFrame.spell_icone:SetTexCoord(4/64, 60/64, 4/64, 60/64) - - --coisinhas do lado do icone - is this still in use? - breakdownFrame.apoio_icone_esquerdo = breakdownFrame:CreateTexture(nil, "ARTWORK") - breakdownFrame.apoio_icone_direito = breakdownFrame:CreateTexture(nil, "ARTWORK") - breakdownFrame.apoio_icone_esquerdo:SetTexture("Interface\\PaperDollInfoFrame\\PaperDollSidebarTabs") - breakdownFrame.apoio_icone_direito:SetTexture("Interface\\PaperDollInfoFrame\\PaperDollSidebarTabs") - - local apoio_altura = 13/256 - breakdownFrame.apoio_icone_esquerdo:SetTexCoord(0, 1, 0, apoio_altura) - breakdownFrame.apoio_icone_direito:SetTexCoord(0, 1, apoio_altura+(1/256), apoio_altura+apoio_altura) - - breakdownFrame.apoio_icone_esquerdo:SetPoint("bottomright", breakdownFrame.bg_icone, "bottomleft", 42, 0) - breakdownFrame.apoio_icone_direito:SetPoint("bottomleft", breakdownFrame.bg_icone, "bottomright", -17, 0) - - breakdownFrame.apoio_icone_esquerdo:SetWidth(64) - breakdownFrame.apoio_icone_esquerdo:SetHeight(13) - breakdownFrame.apoio_icone_direito:SetWidth(64) - breakdownFrame.apoio_icone_direito:SetHeight(13) - breakdownFrame.topright_text1 = breakdownFrame:CreateFontString(nil, "overlay", "GameFontNormal") breakdownFrame.topright_text1:SetPoint("bottomright", breakdownFrame, "topright", -18 - (94 * (1-1)), -36) breakdownFrame.topright_text1:SetJustifyH("right") - _detalhes.gump:SetFontSize(breakdownFrame.topright_text1, 10) + DetailsFramework:SetFontSize(breakdownFrame.topright_text1, 10) breakdownFrame.topright_text2 = breakdownFrame:CreateFontString(nil, "overlay", "GameFontNormal") breakdownFrame.topright_text2:SetPoint("bottomright", breakdownFrame, "topright", -18 - (94 * (1-1)), -48) breakdownFrame.topright_text2:SetJustifyH("right") - _detalhes.gump:SetFontSize(breakdownFrame.topright_text2, 10) + DetailsFramework:SetFontSize(breakdownFrame.topright_text2, 10) --what goes in the top right text? - looks like it's not in use function breakdownFrame:SetTopRightTexts(text1, text2, size, color, font) @@ -1626,6 +1072,7 @@ function gump:CriaJanelaInfo() else breakdownFrame.topright_text1:SetText("") end + if (text2) then breakdownFrame.topright_text2:SetText(text2) else @@ -1633,147 +1080,30 @@ function gump:CriaJanelaInfo() end if (size and type(size) == "number") then - _detalhes.gump:SetFontSize(breakdownFrame.topright_text1, size) - _detalhes.gump:SetFontSize(breakdownFrame.topright_text2, size) + DetailsFramework:SetFontSize(breakdownFrame.topright_text1, size) + DetailsFramework:SetFontSize(breakdownFrame.topright_text2, size) end + if (color) then - _detalhes.gump:SetFontColor(breakdownFrame.topright_text1, color) - _detalhes.gump:SetFontColor(breakdownFrame.topright_text2, color) + DetailsFramework:SetFontColor(breakdownFrame.topright_text1, color) + DetailsFramework:SetFontColor(breakdownFrame.topright_text2, color) end + if (font) then - _detalhes.gump:SetFontFace (breakdownFrame.topright_text1, font) - _detalhes.gump:SetFontFace (breakdownFrame.topright_text2, font) + DetailsFramework:SetFontFace (breakdownFrame.topright_text1, font) + DetailsFramework:SetFontFace (breakdownFrame.topright_text2, font) end end - local alpha_bgs = 1 + --create the texts shown on the window + breakdownWindow.CreateTexts(SWW) - local este_gump = breakdownFrame - - -- backgrounds das 5 boxes do lado direito - local right_background_X = 457 - local right_background_Y = {-85, -136, -191, -246, -301} - - for i = 1, spellInfoSettings.amount do - local right_background1 = CreateFrame("frame", "DetailsPlayerDetailsWindow_right_background" .. i, SWW, "BackdropTemplate") - right_background1:EnableMouse(false) - right_background1:SetPoint("topleft", este_gump, "topleft", right_background_X, right_background_Y [i]) - right_background1:SetSize(220, 43) - Details.gump:ApplyStandardBackdrop(right_background1) - este_gump ["right_background" .. i] = right_background1 - - local gradientDown = DetailsFramework:CreateTexture(right_background1, {gradient = "vertical", fromColor = {0, 0, 0, 0.1}, toColor = "transparent"}, 1, 43, "artwork", {0, 1, 0, 1}) - gradientDown:SetPoint("bottoms") - end - - -- fundos especiais de friendly fire e outros - este_gump.bg1_sec_texture = SWW:CreateTexture("DetailsPlayerDetailsWindow_BG1_SEC_Texture", "BORDER") - este_gump.bg1_sec_texture:SetDrawLayer("BORDER", 4) - este_gump.bg1_sec_texture:SetPoint("topleft", este_gump.bg1, "topleft", 450, -86) - este_gump.bg1_sec_texture:SetHeight(462) - este_gump.bg1_sec_texture:SetWidth(264) - - este_gump.bg2_sec_texture = SWW:CreateTexture("DetailsPlayerDetailsWindow_BG2_SEC_Texture", "BORDER") - este_gump.bg2_sec_texture:SetDrawLayer("BORDER", 3) - este_gump.bg2_sec_texture:SetPoint("topleft", este_gump.bg1_sec_texture, "topleft", 8, 0) - este_gump.bg2_sec_texture:SetPoint("bottomright", este_gump.bg1_sec_texture, "bottomright", -30, 0) - este_gump.bg2_sec_texture:SetTexture([[Interface\Glues\CREDITS\Warlords\Shadowmoon_Color_jlo3]]) - este_gump.bg2_sec_texture:SetDesaturated(true) - este_gump.bg2_sec_texture:SetAlpha(0.3) - este_gump.bg2_sec_texture:Hide() - - este_gump.bg3_sec_texture = SWW:CreateTexture("DetailsPlayerDetailsWindow_BG3_SEC_Texture", "BORDER") - este_gump.bg3_sec_texture:SetDrawLayer("BORDER", 2) - este_gump.bg3_sec_texture:SetPoint("topleft", este_gump.bg2_sec_texture, "topleft", 0, 0) - este_gump.bg3_sec_texture:SetPoint("bottomright", este_gump.bg2_sec_texture, "bottomright", 0, 0) - este_gump.bg3_sec_texture:Hide() - - este_gump.no_targets = SWW:CreateTexture("DetailsPlayerDetailsWindow_no_targets", "overlay") - este_gump.no_targets:SetPoint("BOTTOMLEFT", este_gump, "BOTTOMLEFT", 20, 6) - este_gump.no_targets:SetSize(301, 100) - este_gump.no_targets:SetTexture([[Interface\QUESTFRAME\UI-QUESTLOG-EMPTY-TOPLEFT]]) - este_gump.no_targets:SetTexCoord(0.015625, 1, 0.01171875, 0.390625) - este_gump.no_targets:SetDesaturated(true) - este_gump.no_targets:SetAlpha(.7) - este_gump.no_targets.text = SWW:CreateFontString(nil, "overlay", "GameFontNormal") - este_gump.no_targets.text:SetPoint("center", este_gump.no_targets, "center") - este_gump.no_targets.text:SetText(Loc ["STRING_NO_TARGET_BOX"]) - este_gump.no_targets.text:SetTextColor(1, 1, 1, .4) - este_gump.no_targets:Hide() - - --cria os textos da janela - cria_textos (este_gump, SWW) - - --cria o frama que vai abrigar as barras das habilidades - cria_container_barras (este_gump, SWW) - - --cria o container que vai abrirgar as 5 barras de detalhes - cria_container_detalhes (este_gump, SWW) - - --cria o container onde vai abrigar os alvos do jogador - cria_container_alvos (este_gump, SWW) - - local leftbars1_backgound = CreateFrame("frame", "DetailsPlayerDetailsWindow_Left_SpellsBackground", SWW, "BackdropTemplate") - leftbars1_backgound:EnableMouse(false) - leftbars1_backgound:SetSize(303, 149) - leftbars1_backgound:SetAlpha(alpha_bgs) - leftbars1_backgound:SetFrameLevel(SWW:GetFrameLevel()) - Details.gump:ApplyStandardBackdrop(leftbars1_backgound) - este_gump.leftbars1_backgound = leftbars1_backgound - - local leftbars2_backgound = CreateFrame("frame", "DetailsPlayerDetailsWindow_Left_TargetBackground", SWW, "BackdropTemplate") - leftbars2_backgound:EnableMouse(false) - leftbars2_backgound:SetSize(303, 122) - leftbars2_backgound:SetAlpha(alpha_bgs) - leftbars2_backgound:SetFrameLevel(SWW:GetFrameLevel()) - Details.gump:ApplyStandardBackdrop(leftbars2_backgound) - este_gump.leftbars2_backgound = leftbars2_backgound - - leftbars1_backgound:SetPoint("topleft", este_gump.container_barras, "topleft", -3, 3) - leftbars1_backgound:SetPoint("bottomright", este_gump.container_barras, "bottomright", 3, -3) - leftbars2_backgound:SetPoint("topleft", este_gump.container_alvos, "topleft", -3, 23) - leftbars2_backgound:SetPoint("bottomright", este_gump.container_alvos, "bottomright", 3, 0) - - --cria as 5 barras de detalhes a direita da janela - cria_barras_detalhes() - - --seta os scripts dos frames da janela - seta_scripts (este_gump) - - --vai armazenar os objetos das barras de habilidade - este_gump.barras1 = {} - - --vai armazenar os objetos das barras de alvos - este_gump.barras2 = {} - - --vai armazenar os objetos das barras da caixa especial da direita - este_gump.barras3 = {} - - este_gump.SetClassIcon = default_icon_change - - --bot�o de reportar da caixa da esquerda, onde fica as barras principais - este_gump.report_esquerda = gump:NewDetailsButton (SWW, este_gump, nil, _detalhes.Reportar, este_gump, 1, 16, 16, - "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport2") - este_gump.report_esquerda:SetPoint("BOTTOMLEFT", este_gump.container_barras, "TOPLEFT", 33, 3) - este_gump.report_esquerda:SetFrameLevel(este_gump:GetFrameLevel()+2) - este_gump.topleft_report = este_gump.report_esquerda - - --bot�o de reportar da caixa dos alvos - este_gump.report_alvos = gump:NewDetailsButton (SWW, este_gump, nil, _detalhes.Reportar, este_gump, 3, 16, 16, - "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport3") - este_gump.report_alvos:SetPoint("BOTTOMRIGHT", este_gump.container_alvos, "TOPRIGHT", -2, -1) - este_gump.report_alvos:SetFrameLevel(3) --solved inactive problem - - --bot�o de reportar da caixa da direita, onde est�o os 5 quadrados - este_gump.report_direita = gump:NewDetailsButton (SWW, este_gump, nil, _detalhes.Reportar, este_gump, 2, 16, 16, - "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport4") - este_gump.report_direita:SetPoint("TOPRIGHT", este_gump, "TOPRIGHT", -10, -70) - este_gump.report_direita:Show() + breakdownFrame.SetClassIcon = default_icon_change --statusbar - local statusBar = CreateFrame("frame", nil, este_gump, "BackdropTemplate") - statusBar:SetPoint("bottomleft", este_gump, "bottomleft") - statusBar:SetPoint("bottomright", este_gump, "bottomright") + local statusBar = CreateFrame("frame", nil, breakdownFrame, "BackdropTemplate") + statusBar:SetPoint("bottomleft", breakdownFrame, "bottomleft") + statusBar:SetPoint("bottomright", breakdownFrame, "bottomright") statusBar:SetHeight(PLAYER_DETAILS_STATUSBAR_HEIGHT) DetailsFramework:ApplyStandardBackdrop(statusBar) statusBar:SetAlpha(PLAYER_DETAILS_STATUSBAR_ALPHA) @@ -1781,9 +1111,9 @@ function gump:CriaJanelaInfo() statusBar.Text = DetailsFramework:CreateLabel(statusBar) statusBar.Text:SetPoint("left", 2, 0) - function este_gump:SetStatusbarText (text, fontSize, fontColor) + function breakdownFrame:SetStatusbarText(text, fontSize, fontColor) if (not text) then - este_gump:SetStatusbarText ("Details! Damage Meter | Use '/details stats' for statistics", 10, "gray") + breakdownFrame:SetStatusbarText("Details! Damage Meter | Use '/details stats' for statistics", 10, "gray") return end statusBar.Text.text = text @@ -1792,113 +1122,82 @@ function gump:CriaJanelaInfo() end --set default text - este_gump:SetStatusbarText() + breakdownFrame:SetStatusbarText() --apply default skin - _detalhes:ApplyPDWSkin() + --_detalhes:ApplyPDWSkin() -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---tabs +--tabs ~tabs + function breakdownFrame:ShowTabs() + local tabsShown = 0 + local secondRowIndex = 1 + local breakLine = 6 --the tab it'll start the second line - --tabs: - --tab default + local tablePool = Details:GetBreakdownTabsInUse() - local iconTableSummary = { - texture = [[Interface\AddOns\Details\images\icons]], - coords = {238/512, 255/512, 0, 18/512}, - width = 16, - height = 16, - } + for index = 1, #tablePool do + local tab = tablePool[index] - _detalhes:CreatePlayerDetailsTab("Summary", Loc ["STRING_SPELLS"], --[1] tab name [2] localized name - function(tabOBject, playerObject) --[3] condition - if (playerObject) then - return true - else - return false - end - end, - nil, --[4] fill function - function() --[5] onclick - for _, tab in ipairs(Details:GetBreakdownTabsInUse()) do - tab.frame:Hide() - end - end, - nil, --[6] oncreate - iconTableSummary --[7] icon table - ) + if (tab:condition(info.jogador, info.atributo, info.sub_atributo) and not tab.replaced) then + --test if can show the tutorial for the comparison tab + if (tab.tabname == "Compare") then + --_detalhes:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", false) + if (not _detalhes:GetTutorialCVar("DETAILS_INFO_TUTORIAL1")) then + _detalhes:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", true) - -- ~tab ~tabs - function este_gump:ShowTabs() - local tabsShown = 0 - local secondRowIndex = 1 - local breakLine = 6 --th tab it'll start the second line - - local tablePool = Details:GetBreakdownTabsInUse() - - for index = 1, #tablePool do - local tab = tablePool[index] - - if (tab:condition(info.jogador, info.atributo, info.sub_atributo) and not tab.replaced) then - --test if can show the tutorial for the comparison tab - if (tab.tabname == "Compare") then - --_detalhes:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", false) - if (not _detalhes:GetTutorialCVar("DETAILS_INFO_TUTORIAL1")) then - _detalhes:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", true) - - local alert = CreateFrame("frame", "DetailsInfoPopUp1", info, "DetailsHelpBoxTemplate") - alert.ArrowUP:Show() - alert.ArrowGlowUP:Show() - alert.Text:SetText(Loc ["STRING_INFO_TUTORIAL_COMPARISON1"]) - alert:SetPoint("bottom", tab.widget or tab, "top", 5, 28) - alert:Show() - end + local alert = CreateFrame("frame", "DetailsInfoPopUp1", info, "DetailsHelpBoxTemplate") + alert.ArrowUP:Show() + alert.ArrowGlowUP:Show() + alert.Text:SetText(Loc ["STRING_INFO_TUTORIAL_COMPARISON1"]) + alert:SetPoint("bottom", tab.widget or tab, "top", 5, 28) + alert:Show() end + end - tab:Show() - tabsShown = tabsShown + 1 + tab:Show() + tabsShown = tabsShown + 1 - tab:ClearAllPoints() + tab:ClearAllPoints() - --get the button width - local buttonTemplate = gump:GetTemplate("button", "DETAILS_TAB_BUTTON_TEMPLATE") - local buttonWidth = buttonTemplate.width + 1 + --get the button width + local buttonTemplate = gump:GetTemplate("button", "DETAILS_TAB_BUTTON_TEMPLATE") + local buttonWidth = buttonTemplate.width + 1 - --pixelutil might not be compatible with classic wow - if (PixelUtil) then - PixelUtil.SetSize(tab, buttonTemplate.width, buttonTemplate.height) - if (tabsShown >= breakLine) then --next row of icons - PixelUtil.SetPoint(tab, "bottomright", info, "topright", -514 + (buttonWidth * (secondRowIndex)), -50) - secondRowIndex = secondRowIndex + 1 - else - PixelUtil.SetPoint(tab, "bottomright", info, "topright", -514 + (buttonWidth * tabsShown), -72) - end + --pixelutil might not be compatible with classic wow + if (PixelUtil) then + PixelUtil.SetSize(tab, buttonTemplate.width, buttonTemplate.height) + if (tabsShown >= breakLine) then --next row of icons + PixelUtil.SetPoint(tab, "bottomright", info, "topright", -514 + (buttonWidth * (secondRowIndex)), -50) + secondRowIndex = secondRowIndex + 1 else - tab:SetSize(buttonTemplate.width, buttonTemplate.height) - if (tabsShown >= breakLine) then --next row of icons - tab:SetPoint("bottomright", info, "topright", -514 + (buttonWidth * (secondRowIndex)), -50) - secondRowIndex = secondRowIndex + 1 - else - tab:SetPoint("bottomright", info, "topright", -514 + (buttonWidth * tabsShown), -72) - end + PixelUtil.SetPoint(tab, "bottomright", info, "topright", -514 + (buttonWidth * tabsShown), -72) end - - tab:SetAlpha(0.8) else - tab.frame:Hide() - tab:Hide() + tab:SetSize(buttonTemplate.width, buttonTemplate.height) + if (tabsShown >= breakLine) then --next row of icons + tab:SetPoint("bottomright", info, "topright", -514 + (buttonWidth * (secondRowIndex)), -50) + secondRowIndex = secondRowIndex + 1 + else + tab:SetPoint("bottomright", info, "topright", -514 + (buttonWidth * tabsShown), -72) + end end - end - if (tabsShown < 2) then - tablePool[1]:SetPoint("BOTTOMLEFT", info.container_barras, "TOPLEFT", 490 - (94 * (1-0)), 1) + tab:SetAlpha(0.8) + else + tab.frame:Hide() + tab:Hide() end - - --selected by default - tablePool[1]:Click() end - este_gump:SetScript("OnHide", function(self) + if (tabsShown < 2) then + tablePool[1]:SetPoint("BOTTOMLEFT", info.container_barras, "TOPLEFT", 490 - (94 * (1-0)), 1) + end + + --selected by default + tablePool[1]:Click() + end + breakdownFrame:SetScript("OnHide", function(self) _detalhes:FechaJanelaInfo() for _, tab in ipairs(_detalhes.player_details_tabs) do tab:Hide() @@ -1906,42 +1205,52 @@ function gump:CriaJanelaInfo() end end) - este_gump.tipo = 1 --tipo da janela // 1 = janela normal - - return este_gump - + breakdownFrame.tipo = 1 --tipo da janela // 1 = janela normal + return breakdownFrame end info.selectedTab = "Summary" -function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, fillfunction, onclick, oncreate, iconSettings, replace) - if (not tabname) then - tabname = "unnamed" +function _detalhes:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFunc, tabOnClickFunc, onCreateFunc, iconSettings, replace, bIsDefaultTab) --~tab + if (not tabName) then + tabName = "unnamed" end --create a button for the tab - local newTabButton = gump:CreateButton(info, onclick, 20, 20, nil, nil, nil, nil, nil, "DetailsPlayerBreakdownWindowTab" .. tabname) + --tabOnClickFunc + local newTabButton = gump:CreateButton(info, function()end, 20, 20, nil, nil, nil, nil, nil, breakdownWindow:GetName() .. "TabButton" .. tabName .. math.random(1, 1000)) newTabButton:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") - if (tabname == "Summary") then + if (tabName == "Summary") then newTabButton:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") end - newTabButton:SetText(localized_name) + + newTabButton.IsDefaultTab = bIsDefaultTab + + newTabButton:SetText(locName) newTabButton:SetFrameStrata("HIGH") newTabButton:SetFrameLevel(info:GetFrameLevel()+1) newTabButton:Hide() - newTabButton.condition = condition - newTabButton.tabname = tabname - newTabButton.localized_name = localized_name - newTabButton.onclick = onclick - newTabButton.fillfunction = fillfunction + newTabButton.condition = conditionFunc + newTabButton.tabname = tabName + newTabButton.localized_name = locName + newTabButton.onclick = tabOnClickFunc + newTabButton.fillfunction = fillFunc newTabButton.last_actor = {} - newTabButton.frame = CreateFrame("frame", "DetailsPDWTabFrame" .. tabname, UIParent,"BackdropTemplate") - newTabButton.frame:SetParent(info) - newTabButton.frame:SetFrameStrata("HIGH") - newTabButton.frame:SetFrameLevel(info:GetFrameLevel()+5) - newTabButton.frame:EnableMouse(true) + ---@type tabframe + local tabFrame = CreateFrame("frame", breakdownWindow:GetName() .. "TabFrame" .. tabName .. math.random(1, 1000), UIParent, "BackdropTemplate") + DetailsFramework:ApplyStandardBackdrop(tabFrame) + newTabButton.tabFrame = tabFrame + newTabButton.frame = tabFrame + + tabFrame:SetParent(info) + tabFrame:SetFrameStrata("HIGH") + tabFrame:SetFrameLevel(info:GetFrameLevel()+5) + tabFrame:EnableMouse(true) + tabFrame:SetPoint("topleft", breakdownWindow, "topleft", 0, -70) + tabFrame:SetPoint("bottomright", breakdownWindow, "bottomright", 0, 20) + tabFrame:Hide() if (iconSettings) then local texture = iconSettings.texture @@ -1958,80 +1267,63 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f end if (newTabButton.fillfunction) then - newTabButton.frame:SetScript("OnShow", function() + tabFrame:SetScript("OnShow", function() if (newTabButton.last_actor == info.jogador) then return end newTabButton.last_actor = info.jogador - newTabButton:fillfunction (info.jogador, info.instancia.showing) + newTabButton:fillfunction(info.jogador, info.instancia.showing) end) end - if (oncreate) then - oncreate (newTabButton, newTabButton.frame) + if (onCreateFunc) then + onCreateFunc(newTabButton, tabFrame) end - newTabButton.frame:SetBackdrop({ - edgeFile = [[Interface\Buttons\WHITE8X8]], - edgeSize = 1, - bgFile = [[Interface\AddOns\Details\images\background]], - tileSize = 64, - tile = true, - insets = {left = 0, right = 0, top = 0, bottom = 0}} - ) - - newTabButton.frame:SetBackdropColor(0, 0, 0, 0.3) - newTabButton.frame:SetBackdropBorderColor(.3, .3, .3, 0) - - newTabButton.frame:SetPoint("TOPLEFT", info.container_barras, "TOPLEFT", 0, 2) - --newTabButton.frame:SetPoint("bottomright", info, "bottomright", -3, 3) --issue with: Action[SetPoint] failed because[SetPoint would result in anchor family connection]: attempted from: DetailsPlayerDetailsWindow:SetPoint. - newTabButton.frame:SetSize(569, 274) - - newTabButton.frame:Hide() - newTabButton.replaces = replace - _detalhes.player_details_tabs [#_detalhes.player_details_tabs+1] = newTabButton + _detalhes.player_details_tabs[#_detalhes.player_details_tabs+1] = newTabButton - if (not onclick) then - --hide all tabs - newTabButton.OnShowFunc = function(self) - self = self.MyObject or self + local onTabClickCallback = function(self) + self = self.MyObject or self - for _, tab in ipairs(Details:GetBreakdownTabsInUse()) do - tab.frame:Hide() - tab:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") - end - - self:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") - self.frame:Show() - info.selectedTab = self.tabname + for _, tab in ipairs(Details:GetBreakdownTabsInUse()) do + tab.frame:Hide() + tab:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") end + self:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") + info.selectedTab = self.tabname + end + + if (not tabOnClickFunc) then + newTabButton.OnShowFunc = function(self) + --hide all tab frames, reset the template on all tabs + --then set the template on this tab and set as selected tab + onTabClickCallback(self) + --show the tab frame + tabFrame:Show() + end newTabButton:SetScript("OnClick", newTabButton.OnShowFunc) else --custom newTabButton.OnShowFunc = function(self) - self = self.MyObject or self - - for _, tab in ipairs(Details:GetBreakdownTabsInUse()) do - tab.frame:Hide() - tab:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") - end - - self:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") - - info.selectedTab = self.tabname + --hide all tab frames, reset the template on all tabs + --then set the template on this tab and set as selected tab + onTabClickCallback(self) --run onclick func - local result, errorText = pcall(self.onclick) + local result, errorText = pcall(tabOnClickFunc, newTabButton, tabFrame) if (not result) then - print(errorText) + print("error on running tabOnClick function:", errorText) end end - newTabButton:SetScript("OnClick", newTabButton.OnShowFunc) end + function newTabButton:DoClick() + self:GetScript("OnClick")(self) + end + newTabButton:SetScript("PostClick", function(self) CurrentTab = self.tabname or self.MyObject.tabname @@ -2046,755 +1338,5 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f end end) - return newTabButton, newTabButton.frame -end - -function _detalhes.playerDetailWindow:monta_relatorio (botao) - local atributo = info.atributo - local sub_atributo = info.sub_atributo - local player = info.jogador - local instancia = info.instancia - - local amt = _detalhes.report_lines - - if (not player) then - _detalhes:Msg("Player not found.") - return - end - - local report_lines - - if (botao == 1) then --bot�o da esquerda - - - if (atributo == 1 and sub_atributo == 4) then --friendly fire - report_lines = {"Details!: " .. player.nome .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_FRIENDLYFIRE"] .. ":"} - - elseif (atributo == 1 and sub_atributo == 3) then --damage taken - report_lines = {"Details!: " .. player.nome .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_TAKEN"] .. ":"} - - else - -- report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_SPELLSOF"] .. " " .. player.nome .. " (" .. _detalhes.sub_atributos [atributo].lista [sub_atributo] .. ")"} - report_lines = {"Details!: " .. player.nome .. " - " .. _detalhes.sub_atributos [atributo].lista [sub_atributo] .. ""} - - end - - for index, barra in ipairs(info.barras1) do - if (barra:IsShown()) then - local spellid = barra.show - if (atributo == 1 and sub_atributo == 4) then --friendly fire - report_lines [#report_lines+1] = barra.lineText1:GetText() .. ": " .. barra.lineText4:GetText() - - elseif (type(spellid) == "number" and spellid > 10) then - local link = GetSpellLink(spellid) - report_lines [#report_lines+1] = index .. ". " .. link .. ": " .. barra.lineText4:GetText() - else - local spellname = barra.lineText1:GetText():gsub((".*%."), "") - spellname = spellname:gsub("|c%x%x%x%x%x%x%x%x", "") - spellname = spellname:gsub("|r", "") - report_lines [#report_lines+1] = index .. ". " .. spellname .. ": " .. barra.lineText4:GetText() - end - end - if (index == amt) then - break - end - end - - elseif (botao == 3) then --bot�o dos alvos - - if (atributo == 1 and sub_atributo == 3) then - print(Loc ["STRING_ACTORFRAME_NOTHING"]) - return - end - - report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTARGETS"] .. " " .. _detalhes.sub_atributos [1].lista [1] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome} - - for index, barra in ipairs(info.barras2) do - if (barra:IsShown()) then - report_lines [#report_lines+1] = barra.lineText1:GetText().." -> ".. barra.lineText4:GetText() - end - if (index == amt) then - break - end - end - - elseif (botao == 2) then --bot�o da direita - - --diferentes tipos de amostragem na caixa da direita - --dano --damage done --dps --heal - if ((atributo == 1 and (sub_atributo == 1 or sub_atributo == 2)) or (atributo == 2)) then - if (not player.detalhes) then - print(Loc ["STRING_ACTORFRAME_NOTHING"]) - return - end - local nome = _GetSpellInfo(player.detalhes) - report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [atributo].lista [sub_atributo] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome, - Loc ["STRING_ACTORFRAME_SPELLDETAILS"] .. ": " .. nome} - - for i = 1, 5 do - - --pega os dados dos quadrados --Aqui mostra o resumo de todos os quadrados... - local caixa = info.grupos_detalhes [i] - if (caixa.bg:IsShown()) then - - local linha = "" - - local nome2 = caixa.nome2:GetText() --golpes - if (nome2 and nome2 ~= "") then - if (i == 1) then - linha = linha..nome2.." / " - else - linha = linha..caixa.nome:GetText().." "..nome2.." / " - end - end - - local dano = caixa.dano:GetText() --dano - if (dano and dano ~= "") then - linha = linha..dano.." / " - end - - local media = caixa.dano_media:GetText() --media - if (media and media ~= "") then - linha = linha..media.." / " - end - - local dano_dps = caixa.dano_dps:GetText() - if (dano_dps and dano_dps ~= "") then - linha = linha..dano_dps.." / " - end - - local dano_porcento = caixa.dano_porcento:GetText() - if (dano_porcento and dano_porcento ~= "") then - linha = linha..dano_porcento.." " - end - - report_lines [#report_lines+1] = linha - - end - - if (i == amt) then - break - end - end - - --dano --damage tanken (mostra as magias que o alvo usou) - elseif ( (atributo == 1 and sub_atributo == 3) or atributo == 3) then - if (player.detalhes) then - report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [1].lista [1] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.detalhes.. " " .. Loc ["STRING_ACTORFRAME_REPORTAT"] .. " " .. player.nome} - for index, barra in ipairs(info.barras3) do - if (barra:IsShown()) then - report_lines [#report_lines+1] = barra.lineText1:GetText().." ....... ".. barra.lineText4:GetText() - end - if (index == amt) then - break - end - end - else - report_lines = {} - end - end - - elseif (botao >= 11) then --primeira caixa dos detalhes - botao = botao - 10 - - local nome - if (type(spellid) == "string") then - --is a pet - else - nome = _GetSpellInfo(player.detalhes) - local spelllink = GetSpellLink(player.detalhes) - if (spelllink) then - nome = spelllink - end - end - - if (not nome) then - nome = "" - end - report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [atributo].lista [sub_atributo].. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome, - Loc ["STRING_ACTORFRAME_SPELLDETAILS"] .. ": " .. nome} - - local caixa = info.grupos_detalhes [botao] - - local linha = "" - local nome2 = caixa.nome2:GetText() --golpes - if (nome2 and nome2 ~= "") then - if (i == 1) then - linha = linha..nome2.." / " - else - linha = linha..caixa.nome:GetText().." "..nome2.." / " - end - end - - local dano = caixa.dano:GetText() --dano - if (dano and dano ~= "") then - linha = linha..dano.." / " - end - - local media = caixa.dano_media:GetText() --media - if (media and media ~= "") then - linha = linha..media.." / " - end - - local dano_dps = caixa.dano_dps:GetText() - if (dano_dps and dano_dps ~= "") then - linha = linha..dano_dps.." / " - end - - local dano_porcento = caixa.dano_porcento:GetText() - if (dano_porcento and dano_porcento ~= "") then - linha = linha..dano_porcento.." " - end - - --remove a cor da school - linha = linha:gsub("|c%x?%x?%x?%x?%x?%x?%x?%x?", "") - linha = linha:gsub("|r", "") - - report_lines [#report_lines+1] = linha - - end - - return instancia:envia_relatorio (report_lines) -end - -local row_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - insets = {left = 0, right = 0, top = 0, bottom = 0}} -local row_backdrop_onleave = {bgFile = "", edgeFile = "", tile = true, tileSize = 16, edgeSize = 32, - insets = {left = 1, right = 1, top = 0, bottom = 1}} - -local row_on_enter = function(self) - if (info.fading_in or info.faded) then - return - end - - self.mouse_over = true - - for index, block in pairs(_detalhes.playerDetailWindow.grupos_detalhes) do - detalhe_infobg_onleave (block.bg) - end - - --aumenta o tamanho da barra - self:SetHeight(CONST_BAR_HEIGHT + 1) - --poe a barra com alfa 1 ao inv�s de 0.9 - self:SetAlpha(1) - - --troca a cor da barra enquanto o mouse estiver em cima dela - self:SetBackdrop(row_backdrop) - self:SetBackdropColor(0.8, 0.8, 0.8, 0.3) - - if (self.isAlvo) then --monta o tooltip do alvo - --talvez devesse escurecer a janela no fundo... pois o tooltip � transparente e pode confundir - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - - if (self.spellid == "enemies") then --damage taken enemies - if (not self.minha_tabela or not self.minha_tabela:MontaTooltipDamageTaken (self, self._index, info.instancia)) then -- > poderia ser aprimerado para uma tailcall - return - end - GameTooltip:Show() - self:SetHeight(CONST_TARGET_HEIGHT + 1) - return - end - - if (not self.minha_tabela or not self.minha_tabela:MontaTooltipAlvos (self, self._index, info.instancia)) then -- > poderia ser aprimerado para uma tailcall - return - end - - elseif (self.isMain) then - if (IsShiftKeyDown()) then - if (type(self.show) == "number") then - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - GameTooltip:AddLine(Loc ["ABILITY_ID"] .. ": " .. self.show) - GameTooltip:Show() - end - end - - if (self.show == 98021) then - GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") - GameTooltip:AddLine(Loc ["STRING_SPIRIT_LINK_TOTEM_DESC"]) - GameTooltip:Show() - end - - --da zoom no icone - self.icone:SetWidth(CONST_BAR_HEIGHT + 2) - self.icone:SetHeight(CONST_BAR_HEIGHT + 2) - --poe a alfa do icone em 1.0 - self.icone:SetAlpha(1) - - --mostrar temporariamente o conteudo da barra nas caixas de detalhes - if (not info.mostrando) then --n�o esta mostrando nada na direita - info.mostrando = self --agora o mostrando � igual a esta barra - info.mostrando_mouse_over = true --o conteudo da direta esta sendo mostrado pq o mouse esta passando por cima do bagulho e n�o pq foi clicado - info.showing = self._index --diz o index da barra que esta sendo mostrado na direita - - info.jogador.detalhes = self.show --minha tabela = jogador = jogador.detales = spellid ou nome que esta sendo mostrado na direita - info.jogador:MontaDetalhes (self.show, self, info.instancia) --passa a spellid ou nome e a barra - end - elseif (self.isDetalhe and type(self.show) == "number") then - GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") - Details:GameTooltipSetSpellByID(self.show) - GameTooltip:Show() - end -end - -local row_on_leave = function(self) - if (self.fading_in or self.faded or not self:IsShown() or self.hidden) then - return - end - - self.mouse_over = false - - --diminui o tamanho da barra - self:SetHeight(CONST_BAR_HEIGHT) - --volta com o alfa antigo da barra que era de 0.9 - self:SetAlpha(0.9) - - --volto o background ao normal - self:SetBackdrop(row_backdrop_onleave) - self:SetBackdropBorderColor(0, 0, 0, 0) - self:SetBackdropColor(0, 0, 0, 0) - - GameTooltip:Hide() - - GameCooltip:Hide() - - if (self.isMain) then - --retira o zoom no icone - self.icone:SetWidth(CONST_BAR_HEIGHT) - self.icone:SetHeight(CONST_BAR_HEIGHT) - --volta com a alfa antiga da barra - self.icone:SetAlpha(1) - - --remover o conte�do que estava sendo mostrado na direita - if (info.mostrando_mouse_over) then - info.mostrando = nil - info.mostrando_mouse_over = false - info.showing = nil - - info.jogador.detalhes = nil - gump:HidaAllDetalheInfo() - end - - elseif (self.isAlvo) then - self:SetHeight(CONST_TARGET_HEIGHT) - elseif (self.isDetalhe) then - self:SetHeight(16) - end -end - -local row_on_mousedown = function(self, button) - if (self.fading_in) then - return - end - - self.mouse_down = GetTime() - local x, y = _GetCursorPosition() - self.x = _math_floor(x) - self.y = _math_floor(y) - - if (button == "RightButton" and not info.isMoving) then - _detalhes:FechaJanelaInfo() - - elseif (not info.isMoving and button == "LeftButton" and not self.isDetalhe) then - info:StartMoving() - info.isMoving = true - end -end - -local row_on_mouseup = function(self, button) - if (self.fading_in) then - return - end - - if (info.isMoving and button == "LeftButton" and not self.isDetalhe) then - info:StopMovingOrSizing() - info.isMoving = false - end - - local x, y = _GetCursorPosition() - x = _math_floor(x) - y = _math_floor(y) - if ((self.mouse_down+0.4 > GetTime() and (x == self.x and y == self.y)) or (x == self.x and y == self.y)) then - --setar os textos - - if (self.isMain) then --se n�o for uma barra de alvo - - local barra_antiga = info.mostrando - if (barra_antiga and not info.mostrando_mouse_over) then - - barra_antiga.textura:SetStatusBarColor(1, 1, 1, 1) --volta a textura normal - barra_antiga.on_focus = false --n�o esta mais no foco - - --clicou na mesma barra - if (barra_antiga == self) then --> - info.mostrando_mouse_over = true - return - - --clicou em outra barra - else --clicou em outra barra e trocou o foco - barra_antiga:SetAlpha(.9) --volta a alfa antiga - - info.mostrando = self - info.showing = i - - info.jogador.detalhes = self.show - info.jogador:MontaDetalhes (self.show, self) - - self:SetAlpha(1) - self.textura:SetStatusBarColor(129/255, 125/255, 69/255, 1) - self.on_focus = true - return - end - end - - --nao tinha barras pressionadas - info.mostrando_mouse_over = false - self:SetAlpha(1) - self.textura:SetStatusBarColor(129/255, 125/255, 69/255, 1) - self.on_focus = true - end - end -end - -local function SetBarraScripts (esta_barra, instancia, i) - esta_barra._index = i - - esta_barra:SetScript("OnEnter", row_on_enter) - esta_barra:SetScript("OnLeave", row_on_leave) - - esta_barra:SetScript("OnMouseDown", row_on_mousedown) - esta_barra:SetScript("OnMouseUp", row_on_mouseup) -end - -local function CriaTexturaBarra(newLine) - newLine.textura = CreateFrame("StatusBar", nil, newLine, "BackdropTemplate") - newLine.textura:SetFrameLevel(newLine:GetFrameLevel()-1) - newLine.textura:SetAllPoints(newLine) - newLine.textura:SetAlpha(0.5) - newLine.textura:Show() - - local textureObject = newLine.textura:CreateTexture(nil, "artwork") - local texturePath = SharedMedia:Fetch("statusbar", _detalhes.player_details_window.bar_texture) - textureObject:SetTexture(texturePath) - newLine.textura:SetStatusBarTexture(textureObject) - newLine.textura:SetStatusBarColor(.5, .5, .5, 1) - --newLine.textura:SetColorFill(.5, .5, .5, 1) --(r, g, b, a) --only in 10.0? - newLine.textura:SetMinMaxValues(0, 100) - - local backgroundTexture = newLine.textura:CreateTexture(nil, "background") - backgroundTexture:SetAllPoints() - backgroundTexture:SetColorTexture(.5, .5, .5, 0.18) - newLine.textura.bg = backgroundTexture - - if (newLine.targets) then - newLine.targets:SetParent(newLine.textura) - newLine.targets:SetFrameLevel(newLine.textura:GetFrameLevel()+2) - end - - --create the left text - newLine.lineText1 = newLine:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - newLine.lineText1:SetPoint("LEFT", newLine.icone, "RIGHT", 2, 0) - newLine.lineText1:SetJustifyH("LEFT") - newLine.lineText1:SetTextColor(1,1,1,1) - newLine.lineText1:SetNonSpaceWrap(true) - newLine.lineText1:SetWordWrap(false) - - --create the rigth text - newLine.lineText4 = newLine:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - if (newLine.targets) then - newLine.lineText4:SetPoint("RIGHT", newLine.targets, "LEFT", -2, 0) - else - newLine.lineText4:SetPoint("RIGHT", newLine, "RIGHT", -2, 0) - end - newLine.lineText4:SetJustifyH("RIGHT") - newLine.lineText4:SetTextColor(1,1,1,1) -end - -local miniframe_func_on_enter = function(self) - local barra = self:GetParent() - if (barra.show and type(barra.show) == "number") then - local spellname = _GetSpellInfo(barra.show) - if (spellname) then - GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") - _detalhes:GameTooltipSetSpellByID (barra.show) - GameTooltip:Show() - end - end - barra:GetScript("OnEnter")(barra) -end - -local miniframe_func_on_leave = function(self) - GameTooltip:Hide() - self:GetParent():GetScript("OnLeave")(self:GetParent()) -end - -local target_on_enter = function(self) - local barra = self:GetParent():GetParent() - - if (barra.show and type(barra.show) == "number") then - local actor = barra.other_actor or info.jogador - local spell = actor.spells and actor.spells:PegaHabilidade (barra.show) - if (spell) then - - local ActorTargetsSortTable = {} - local ActorTargetsContainer - local total = 0 - - if (spell.isReflection) then - ActorTargetsContainer = spell.extra - else - local attribute, sub_attribute = info.instancia:GetDisplay() - if (attribute == 1 or attribute == 3) then - ActorTargetsContainer = spell.targets - else - if (sub_attribute == 3) then --overheal - ActorTargetsContainer = spell.targets_overheal - elseif (sub_attribute == 6) then --absorbs - ActorTargetsContainer = spell.targets_absorbs - else - ActorTargetsContainer = spell.targets - end - end - end - - --add and sort - for target_name, amount in pairs(ActorTargetsContainer) do - ActorTargetsSortTable [#ActorTargetsSortTable+1] = {target_name, amount or 0} - total = total + (amount or 0) - end - table.sort (ActorTargetsSortTable, _detalhes.Sort2) - - local spellname = _GetSpellInfo(barra.show) - - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - GameTooltip:AddLine(barra.index .. ". " .. spellname) - GameTooltip:AddLine(info.target_text) - GameTooltip:AddLine(" ") - - --get time type - local meu_tempo - if (_detalhes.time_type == 1 or not actor.grupo) then - meu_tempo = actor:Tempo() - elseif (_detalhes.time_type == 2) then - meu_tempo = info.instancia.showing:GetCombatTime() - end - - local SelectedToKFunction = _detalhes.ToKFunctions [_detalhes.ps_abbreviation] - - if (spell.isReflection) then - _detalhes:FormatCooltipForSpells() - GameCooltip:SetOwner(self, "bottomright", "top", 4, -2) - - _detalhes:AddTooltipSpellHeaderText ("Spells Reflected", {1, 0.9, 0.0, 1}, 1, select(3, _GetSpellInfo(spell.id)), 0.1, 0.9, 0.1, 0.9) --localize-me - _detalhes:AddTooltipHeaderStatusbar (1, 1, 1, 0.4) - - GameCooltip:AddIcon(select(3, _GetSpellInfo(spell.id)), 1, 1, 16, 16, .1, .9, .1, .9) - _detalhes:AddTooltipHeaderStatusbar (1, 1, 1, 0.5) - - local topDamage = ActorTargetsSortTable[1] and ActorTargetsSortTable[1][2] - - for index, target in ipairs(ActorTargetsSortTable) do - if (target [2] > 0) then - local spellId = target[1] - local damageDone = target[2] - local spellName, _, spellIcon = _GetSpellInfo(spellId) - GameCooltip:AddLine(spellName, SelectedToKFunction (_, damageDone) .. " (" .. floor(damageDone / topDamage * 100) .. "%)") - GameCooltip:AddIcon(spellIcon, 1, 1, 16, 16, .1, .9, .1, .9) - _detalhes:AddTooltipBackgroundStatusbar (false, damageDone / topDamage * 100) - end - end - - GameCooltip:Show() - - self.texture:SetAlpha(1) - self:SetAlpha(1) - barra:GetScript("OnEnter")(barra) - return - else - for index, target in ipairs(ActorTargetsSortTable) do - if (target [2] > 0) then - local class = _detalhes:GetClass(target [1]) - if (class and _detalhes.class_coords [class]) then - local cords = _detalhes.class_coords [class] - if (info.target_persecond) then - GameTooltip:AddDoubleLine (index .. ". |TInterface\\AddOns\\Details\\images\\classes_small_alpha:14:14:0:0:128:128:"..cords[1]*128 ..":"..cords[2]*128 ..":"..cords[3]*128 ..":"..cords[4]*128 .."|t " .. target [1], _detalhes:comma_value ( _math_floor(target [2] / meu_tempo) ), 1, 1, 1, 1, 1, 1) - else - GameTooltip:AddDoubleLine (index .. ". |TInterface\\AddOns\\Details\\images\\classes_small_alpha:14:14:0:0:128:128:"..cords[1]*128 ..":"..cords[2]*128 ..":"..cords[3]*128 ..":"..cords[4]*128 .."|t " .. target [1], SelectedToKFunction (_, target [2]), 1, 1, 1, 1, 1, 1) - end - else - if (info.target_persecond) then - GameTooltip:AddDoubleLine (index .. ". " .. target [1], _detalhes:comma_value ( _math_floor(target [2] / meu_tempo)), 1, 1, 1, 1, 1, 1) - else - GameTooltip:AddDoubleLine (index .. ". " .. target [1], SelectedToKFunction (_, target [2]), 1, 1, 1, 1, 1, 1) - end - end - end - end - end - - GameTooltip:Show() - else - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - GameTooltip:AddLine(barra.index .. ". " .. barra.show) - GameTooltip:AddLine(info.target_text) - GameTooltip:AddLine(Loc ["STRING_NO_TARGET"], 1, 1, 1) - GameTooltip:AddLine(Loc ["STRING_MORE_INFO"], 1, 1, 1) - GameTooltip:Show() - end - else - GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - GameTooltip:AddLine(barra.index .. ". " .. barra.show) - GameTooltip:AddLine(info.target_text) - GameTooltip:AddLine(Loc ["STRING_NO_TARGET"], 1, 1, 1) - GameTooltip:AddLine(Loc ["STRING_MORE_INFO"], 1, 1, 1) - GameTooltip:Show() - end - - self.texture:SetAlpha(1) - self:SetAlpha(1) - barra:GetScript("OnEnter")(barra) -end - -local target_on_leave = function(self) - GameTooltip:Hide() - GameCooltip:Hide() - self:GetParent():GetParent():GetScript("OnLeave")(self:GetParent():GetParent()) - self.texture:SetAlpha(.7) - self:SetAlpha(.7) -end - -function gump:CriaNovaBarraInfo1(instancia, index) - if (_detalhes.playerDetailWindow.barras1[index]) then - return - end - - local parentFrame = info.container_barras.gump - - local newLine = CreateFrame("Button", "Details_infobox1_bar_" .. index, parentFrame, "BackdropTemplate") - newLine:SetHeight(CONST_BAR_HEIGHT) - newLine.index = index - - local y = (index-1) * (CONST_BAR_HEIGHT + 1) - y = y * -1 - - newLine:SetPoint("LEFT", parentFrame, "LEFT", CONST_BAR_HEIGHT, 0) - newLine:SetPoint("RIGHT", parentFrame, "RIGHT") - newLine:SetPoint("TOP", parentFrame, "TOP", 0, y) - newLine:SetFrameLevel(parentFrame:GetFrameLevel() + 1) - newLine:SetAlpha(1) - newLine:EnableMouse(true) - newLine:RegisterForClicks("LeftButtonDown","RightButtonUp") - newLine.isMain = true - - --create a square frame which is placed at the right side of the line to show which targets for damaged by the spell - newLine.targets = CreateFrame("frame", "$parentTargets", newLine, "BackdropTemplate") - newLine.targets:SetPoint("right", newLine, "right", 0, 0) - newLine.targets:SetSize(CONST_BAR_HEIGHT-1, CONST_BAR_HEIGHT-1) - newLine.targets:SetAlpha(.7) - newLine.targets:SetScript("OnEnter", target_on_enter) - newLine.targets:SetScript("OnLeave", target_on_leave) - newLine.targets.texture = newLine.targets:CreateTexture(nil, "overlay") - newLine.targets.texture:SetTexture([[Interface\MINIMAP\TRACKING\Target]]) - newLine.targets.texture:SetAllPoints() - newLine.targets.texture:SetDesaturated(true) - newLine.targets.texture:SetAlpha(1) - - --create the icon to show the spell icon - newLine.icone = newLine:CreateTexture(nil, "OVERLAY") - newLine.icone:SetWidth(CONST_BAR_HEIGHT-2) - newLine.icone:SetHeight(CONST_BAR_HEIGHT-2) - newLine.icone:SetPoint("RIGHT", newLine, "LEFT", 0, 0) - newLine.icone:SetAlpha(1) - --frame which will show the spell tooltip - newLine.miniframe = CreateFrame("frame", nil, newLine, "BackdropTemplate") - newLine.miniframe:SetSize(CONST_BAR_HEIGHT * 2, CONST_BAR_HEIGHT-2) - newLine.miniframe:SetPoint("right", newLine, "left", CONST_BAR_HEIGHT, 0) - newLine.miniframe:SetScript("OnEnter", miniframe_func_on_enter) - newLine.miniframe:SetScript("OnLeave", miniframe_func_on_leave) - - CriaTexturaBarra(newLine) - SetBarraScripts (newLine, instancia, index) - - info.barras1[index] = newLine - newLine.textura:SetStatusBarColor(1, 1, 1, 1) - newLine.on_focus = false - - return newLine -end - -function gump:CriaNovaBarraInfo2(instancia, index) - if (_detalhes.playerDetailWindow.barras2 [index]) then - print("erro a barra "..index.." ja existe na janela de detalhes...") - return - end - - local janela = info.container_alvos.gump - - local esta_barra = CreateFrame("Button", "Details_infobox2_bar_"..index, info.container_alvos.gump, "BackdropTemplate") - esta_barra:SetHeight(CONST_TARGET_HEIGHT) - - local y = (index-1) * (CONST_TARGET_HEIGHT + 1) - y = y*-1 --baixo - - esta_barra:SetPoint("LEFT", janela, "LEFT", CONST_TARGET_HEIGHT, 0) - esta_barra:SetPoint("RIGHT", janela, "RIGHT", 0, 0) - esta_barra:SetPoint("TOP", janela, "TOP", 0, y) - esta_barra:SetFrameLevel(janela:GetFrameLevel() + 1) - - esta_barra:EnableMouse(true) - esta_barra:RegisterForClicks ("LeftButtonDown","RightButtonUp") - - --icone - esta_barra.icone = esta_barra:CreateTexture(nil, "OVERLAY") - esta_barra.icone:SetWidth(CONST_TARGET_HEIGHT) - esta_barra.icone:SetHeight(CONST_TARGET_HEIGHT) - esta_barra.icone:SetPoint("RIGHT", esta_barra, "LEFT", 0, 0) - - CriaTexturaBarra(esta_barra) - - esta_barra:SetAlpha(ALPHA_BLEND_AMOUNT) - esta_barra.icone:SetAlpha(1) - - esta_barra.isAlvo = true - - SetBarraScripts(esta_barra, instancia, index) - - info.barras2 [index] = esta_barra --barra adicionada - - return esta_barra -end - -function gump:CriaNovaBarraInfo3 (instancia, index) - if (_detalhes.playerDetailWindow.barras3 [index]) then - print("erro a barra "..index.." ja existe na janela de detalhes...") - return - end - - local janela = info.container_detalhes - - local esta_barra = CreateFrame("Button", "Details_infobox3_bar_"..index, janela, "BackdropTemplate") - esta_barra:SetHeight(16) - - local y = (index-1) * 17 - y = y*-1 - container3_bars_pointFunc (esta_barra, index) - esta_barra:EnableMouse(true) - - --icone - esta_barra.icone = esta_barra:CreateTexture(nil, "OVERLAY") - esta_barra.icone:SetWidth(14) - esta_barra.icone:SetHeight(14) - esta_barra.icone:SetPoint("LEFT", esta_barra, "LEFT", 0, 0) - - CriaTexturaBarra(esta_barra) - - esta_barra:SetAlpha(0.9) - esta_barra.icone:SetAlpha(1) - - esta_barra.isDetalhe = true - - SetBarraScripts (esta_barra, instancia, index) - - info.barras3 [index] = esta_barra --barra adicionada - - return esta_barra -end + return newTabButton, tabFrame +end \ No newline at end of file diff --git a/frames/window_playerbreakdown_list.lua b/frames/window_playerbreakdown_list.lua index 6b46d39d..448420e8 100644 --- a/frames/window_playerbreakdown_list.lua +++ b/frames/window_playerbreakdown_list.lua @@ -30,7 +30,7 @@ } function breakdownWindowPlayerList.CreatePlayerListFrame() - local f = _G.DetailsPlayerDetailsWindow + local f = _G.DetailsBreakdownWindow local refreshPlayerList = function(self, data, offset, totalLines) --update the scroll diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua new file mode 100644 index 00000000..e7e387d9 --- /dev/null +++ b/frames/window_playerbreakdown_spells.lua @@ -0,0 +1,1907 @@ + +local addonName, Details222 = ... +local spellsTab = {} +local breakdownWindow = Details.BreakdownWindow +local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) +local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") +local unpack = unpack +local GetTime = GetTime +local GetCursorPosition = GetCursorPosition +local CreateFrame = CreateFrame +local GetSpellLink = GetSpellLink +local _GetSpellInfo = Details.GetSpellInfo +local GameTooltip = GameTooltip +local IsShiftKeyDown = IsShiftKeyDown +local DF = DetailsFramework + +--Expose the object to the global namespace +DetailsSpellBreakdownTab = spellsTab + +local iconTableSummary = { + texture = [[Interface\AddOns\Details\images\icons]], + coords = {238/512, 255/512, 0, 18/512}, + width = 16, + height = 16, +} + +local spellBlockContainerSettings = { + amount = 6, --amount of block the container have + lineAmount = 3, --amount of line each block have +} + +local spellBreakdownSettings = {} + +local row_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + insets = {left = 0, right = 0, top = 0, bottom = 0}} +local row_backdrop_onleave = {bgFile = "", edgeFile = "", tile = true, tileSize = 16, edgeSize = 32, + insets = {left = 1, right = 1, top = 0, bottom = 1}} + +local CONST_BAR_HEIGHT = 20 +local CONST_TARGET_HEIGHT = 18 + +local CONST_SPELLSCROLL_WIDTH = 435 +local CONST_SPELLSCROLL_HEIGHT = 311 +local CONST_SPELLSCROLL_AMTLINES = 14 +local CONST_SPELLSCROLL_LINEHEIGHT = 20 + +Details.SpellGroups = { + [193473] = 15407, --mind flay +} + +function spellsTab.GetActor() + return spellsTab.currentActor +end + +function spellsTab.GetCombat() + return spellsTab.combatObject +end + +function spellsTab.GetInstance() + return spellsTab.instance +end + +---return the breakdownspellscrollframe object, there's only one of this in the breakdown window +---@return breakdownspellscrollframe +function spellsTab.GetSpellScrollContainer() + return spellsTab.TabFrame.SpellScrollFrame +end + +---return the breakdownspellblockcontainer object, there's only one of this in the breakdown window +---@return breakdownspellblockcontainer +function spellsTab.GetSpellBlockContainer() + return spellsTab.TabFrame.SpellBlockContainer +end + +---@type {name: string, width: number, label: string, align: string, enabled: boolean}[] +local columnInfo = { + {name = "icon", width = 22, label = "", align = "center", enabled = true,}, + {name = "target", width = 22, label = "", align = "center", enabled = true}, + {name = "rank", label = "#", width = 16, align = "center", enabled = true}, + {name = "expand", label = "^", width = 16, align = "center", enabled = true}, + {name = "name", label = "spell name", width = 246, align = "left", enabled = true}, + {name = "amount", label = "total", width = 50, align = "left", enabled = true}, + {name = "persecond", label = "ps", width = 50, align = "left", enabled = false}, + {name = "percent", label = "%", width = 50, align = "left", enabled = true}, + {name = "casts", label = "casts", width = 40, align = "left", enabled = false}, + {name = "critpercent", label = "crit %", width = 40, align = "left", enabled = false}, + {name = "hits", label = "hits", width = 40, align = "left", enabled = false}, + {name = "castavg", label = "cast avg", width = 50, align = "left", enabled = false}, + {name = "uptime", label = "uptime", width = 45, align = "left", enabled = false}, +} + +--store the current spellbar selected, this is used to lock the spellblock container to the spellbar selected +spellsTab.selectedSpellBar = nil + +---selected a breakdownspellbar, locking into the bar +---when a breakdownspellbar is selected, all the other breakdownspellbar has it's hover over disabled +---@param spellBar breakdownspellbar +function spellsTab.SelectSpellBar(spellBar) + --if already has a spellbar selected, unselect it + if (spellsTab.HasSelectedSpellBar()) then --unselect and stop the function if the bar selected is the same as the one being selected + if (spellsTab.GetSelectedSpellBar() == spellBar) then + spellsTab.UnSelectSpellBar() + return + else + spellsTab.UnSelectSpellBar() + end + end + + --it is only selecting the bar is the mouse down elapsed 0.4 seconds or more + + --as the spell block container get an update when hovering over + --update the spell block container for the breakdownspellbar just selected + --this is necessary since a previous breakdownspellbar could have been selected and prevented this breakdownspellbar to update on hover over + ---@type function + local onEnterScript = spellBar:GetScript("OnEnter") + if (onEnterScript) then + onEnterScript(spellBar) + end + + --set the new breakdownspellbar as selected + spellsTab.selectedSpellBar = spellBar + spellsTab.selectedSpellBar.overlayTexture:Show() +end + +---deselect the breakdownspellbar +function spellsTab.UnSelectSpellBar() + if (spellsTab.selectedSpellBar) then + spellsTab.selectedSpellBar.overlayTexture:Hide() + end + spellsTab.selectedSpellBar = nil +end + +---get the spellbar currently selected +---@return breakdownspellbar +function spellsTab.GetSelectedSpellBar() + return spellsTab.selectedSpellBar +end + +---return true if there's a spell bar selected +---@return boolean +function spellsTab.HasSelectedSpellBar() + return spellsTab.selectedSpellBar ~= nil +end + +function spellsTab.OnShownTab() + --unselect any selected breakdownspellbar + spellsTab.UnSelectSpellBar() + --reset the spell blocks + spellsTab.GetSpellBlockContainer():ClearBlocks() +end + + +function spellsTab.BuildHeaderTable() + local headerTable = {} + for i = 1, #columnInfo do + local columnData = columnInfo[i] + if (columnData.enabled) then + headerTable[#headerTable+1] = { + text = columnData.label, + width = columnData.width, + name = columnData.name, + --align = column.align, + } + end + end + return headerTable +end + +--called when the tab is getting created +function spellsTab.OnCreateTabCallback(tabButton, tabFrame) + spellBreakdownSettings = Details.breakdown_spell_tab + + --create the scrollbar to show the spells in the breakdown window + ---@type breakdownspellscrollframe + local spellScrollContainer = spellsTab.CreateSpellScrollContainer(tabFrame) --finished + + --create the 6 spell blocks in the right side of the breakdown window + --these blocks show the spell info like normal hits, critical hits, average, etc + ---@type breakdownspellblockcontainer + local spellBlockContainer = spellsTab.CreateSpellBlockContainer(tabFrame) + spellsTab.SpellBlockContainer = spellBlockContainer + spellBlockContainer:SetPoint("topleft", spellScrollContainer, "topright", 26, 0) + + --create the targets container + spellsTab.CreateTargetContainer(tabFrame) + + --craete special backgrounds (still needed?) + spellsTab.CreateSpecialBackgrounds(tabFrame) + + --create the report buttons for each container + spellsTab.CreateReportButtons(tabFrame) + + --these bars table are kinda deprecated now: + + --store the spell bars for the spell container + tabFrame.barras1 = {} + --store the target bars for the target container + tabFrame.barras2 = {} + --store the special bars shown in the right side of the breakdown window, this is only shown when spellBlocks aren't in use + tabFrame.barras3 = {} + + spellsTab.TabFrame = tabFrame +end + +function spellsTab.TrocaBackgroundInfo(tabFrame) --> spells tab | to be refactored | called fom OpenJanelaInfo function + tabFrame.bg3_sec_texture:Hide() + tabFrame.bg2_sec_texture:Hide() + tabFrame.report_direita:Hide() + + if (breakdownWindow.atributo == 1) then --damage + if (breakdownWindow.sub_atributo == 1 or breakdownWindow.sub_atributo == 2) then --damage done / dps + tabFrame.bg1_sec_texture:SetTexture("") + tabFrame.tipo = 1 + + if (breakdownWindow.sub_atributo == 2) then + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_DPS"] .. ":") + tabFrame.target_persecond = true + else + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + end + + elseif (breakdownWindow.sub_atributo == 3) then --damage taken + tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) + tabFrame.bg3_sec_texture:Show() + tabFrame.bg2_sec_texture:Show() + tabFrame.tipo = 2 + + for i = 1, spellBlockContainerSettings.amount do + tabFrame["right_background" .. i]:Hide() + end + + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + tabFrame.no_targets:Show() + tabFrame.no_targets.text:Show() + tabFrame.report_direita:Show() + + elseif (breakdownWindow.sub_atributo == 4) then --friendly fire + tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) + tabFrame.bg3_sec_texture:Show() + tabFrame.bg2_sec_texture:Show() + tabFrame.tipo = 3 + + for i = 1, spellBlockContainerSettings.amount do + tabFrame["right_background" .. i]:Hide() + end + + tabFrame.targets:SetText(Loc ["STRING_SPELLS"] .. ":") + tabFrame.report_direita:Show() + + elseif (breakdownWindow.sub_atributo == 6) then --enemies + tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) + tabFrame.bg3_sec_texture:Show() + tabFrame.bg2_sec_texture:Show() + tabFrame.tipo = 3 + + for i = 1, spellBlockContainerSettings.amount do + tabFrame["right_background" .. i]:Hide() + end + + tabFrame.targets:SetText(Loc ["STRING_DAMAGE_TAKEN_FROM"]) + end + + elseif (breakdownWindow.atributo == 2) then --healing + if (breakdownWindow.sub_atributo == 1 or breakdownWindow.sub_atributo == 2 or breakdownWindow.sub_atributo == 3) then --damage done / dps + tabFrame.bg1_sec_texture:SetTexture("") + tabFrame.tipo = 1 + + if (breakdownWindow.sub_atributo == 3) then + tabFrame.targets:SetText(Loc ["STRING_OVERHEALED"] .. ":") + tabFrame.target_member = "overheal" + tabFrame.target_text = Loc ["STRING_OVERHEALED"] .. ":" + + elseif (breakdownWindow.sub_atributo == 2) then + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_HEAL_HPS"] .. ":") + tabFrame.target_persecond = true + + else + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + end + + elseif (breakdownWindow.sub_atributo == 4) then --Healing taken + tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4) + tabFrame.bg3_sec_texture:Show() + tabFrame.bg2_sec_texture:Show() + tabFrame.tipo = 2 + + for i = 1, spellBlockContainerSettings.amount do + tabFrame ["right_background" .. i]:Hide() + end + + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + tabFrame.no_targets:Show() + tabFrame.no_targets.text:Show() + tabFrame.report_direita:Show() + end + + elseif (breakdownWindow.atributo == 3) then --energy + tabFrame.bg1_sec_texture:SetTexture("") + tabFrame.tipo = 2 + tabFrame.targets:SetText("Vindo de:") + + elseif (breakdownWindow.atributo == 4) then --utility + tabFrame.bg1_sec_texture:SetTexture("") + tabFrame.tipo = 2 + + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") + end +end + +do --hide bars functions + --hide all the bars of the skills in the window info + function spellsTab.HidaAllBarrasInfo() + local allBars = _detalhes.playerDetailWindow.barras1 + for index = 1, #allBars, 1 do + allBars[index]:Hide() + allBars[index].textura:SetStatusBarColor(1, 1, 1, 1) + allBars[index].on_focus = false + end + end + + --hide all the bars of the player's targets + function spellsTab.HidaAllBarrasAlvo() + local allBars = _detalhes.playerDetailWindow.barras2 + for index = 1, #allBars, 1 do + allBars[index]:Hide() + end + end + + --hide the 5 bars on the right side of the window + function spellsTab.HidaAllDetalheInfo() --there's a call from the breakdown file yet + for i = 1, spellBlockContainerSettings.amount do + spellsTab.HidaDetalheInfo(i) + end + + --breakdownWindow.barras3 will not exists anymore soon + --for _, thisBar in ipairs(breakdownWindow.barras3) do + -- thisBar:Hide() + --end + --_detalhes.playerDetailWindow.spell_icone:SetTexture("") + end + + function spellsTab.ResetBars() + spellsTab.HidaAllBarrasInfo() + spellsTab.HidaAllBarrasAlvo() + spellsTab.HidaAllDetalheInfo() + end + + function spellsTab.HidaDetalheInfo(index) --> spells tab this is getting called from class damage and heal + local info = _detalhes.playerDetailWindow.grupos_detalhes[index] + info.nome:SetText("") + info.nome2:SetText("") + info.dano:SetText("") + info.dano_porcento:SetText("") + info.dano_media:SetText("") + info.dano_dps:SetText("") + info.bg:Hide() + end +end + +--bar scripts +local onMouseDownCallback = function(self, button) + local hostFrame = breakdownWindow + + if (button == "LeftButton") then + hostFrame:StartMoving() + hostFrame.isMoving = true + + elseif (button == "RightButton" and not self.isMoving) then + Details:CloseBreakdownWindow() + end +end + +local onMouseUpCallback = function(self, button) + local hostFrame = breakdownWindow + + if (hostFrame.isMoving) then + hostFrame:StopMovingOrSizing() + hostFrame.isMoving = false + end +end + +function spellsTab.ApplyScripts() + local hostFrame = breakdownWindow --cannot be breakdown window, it should be the frame of the tab + hostFrame.SpellScrollFrame.gump:SetScript("OnMouseDown", onMouseDownCallback) + hostFrame.SpellScrollFrame.gump:SetScript("OnMouseUp", onMouseUpCallback) + + hostFrame.container_detalhes:SetScript("OnMouseDown", onMouseDownCallback) + hostFrame.container_detalhes:SetScript("OnMouseUp", onMouseUpCallback) + + hostFrame.container_alvos.gump:SetScript("OnMouseDown", onMouseDownCallback) + hostFrame.container_alvos.gump:SetScript("OnMouseUp", onMouseUpCallback) +end + +function spellsTab.CreateReportButtons(tabFrame) + --spell list report button + tabFrame.report_esquerda = Details.gump:NewDetailsButton(tabFrame, tabFrame, nil, _detalhes.Reportar, tabFrame, 1, 16, 16, "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport2") + tabFrame.report_esquerda:SetPoint("bottomleft", tabFrame.SpellScrollFrame, "TOPLEFT", 33, 3) + tabFrame.report_esquerda:SetFrameLevel(tabFrame:GetFrameLevel()+2) + tabFrame.topleft_report = tabFrame.report_esquerda + + --targets report button + tabFrame.report_alvos = Details.gump:NewDetailsButton(tabFrame, tabFrame, nil, _detalhes.Reportar, tabFrame, 3, 16, 16, "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport3") + tabFrame.report_alvos:SetPoint("bottomright", tabFrame.container_alvos, "TOPRIGHT", -2, -1) + tabFrame.report_alvos:SetFrameLevel(3) --solved inactive problem + + --special barras in the right report button + tabFrame.report_direita = Details.gump:NewDetailsButton(tabFrame, tabFrame, nil, _detalhes.Reportar, tabFrame, 2, 16, 16, "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport4") + tabFrame.report_direita:SetPoint("TOPRIGHT", tabFrame, "TOPRIGHT", -10, -70) + tabFrame.report_direita:Show() +end + +---------------------------------------------------------------------- +--> scripts + +--create a details bar on the right side of the window +local onEnterSpellBlock = function(spellBlock) --info background is the 6 bars in the right side of the window? + Details.FadeHandler.Fader(spellBlock.overlay, "OUT") + Details.FadeHandler.Fader(spellBlock.reportButton, "OUT") +end + +local onLeaveSpellBlock = function(spellBlock) + Details.FadeHandler.Fader(spellBlock.overlay, "IN") + Details.FadeHandler.Fader(spellBlock.reportButton, "IN") +end + +local onEnterInfoReport = function(self) + Details.FadeHandler.Fader(self:GetParent().overlay, "OUT") + Details.FadeHandler.Fader(self, "OUT") +end + +local onLeaveInfoReport = function(self) + Details.FadeHandler.Fader(self:GetParent().overlay, "IN") + Details.FadeHandler.Fader(self, "IN") +end + +---run this function when the mouse hover over a breakdownspellbar +---@param spellBar breakdownspellbar +local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por nomes nas funções e formatar as linhas das funcções + --all values from spellBar are cached values + + --check if there's a spellbar selected, if there's one, ignore the mouseover + if (spellsTab.HasSelectedSpellBar()) then + return + end + + ---@type instance + local instance = spellsTab.GetInstance() + + ---@type number, number + local mainAttribute, subAttribute = instance:GetDisplay() + + ---@type breakdownspellblockcontainer + local spellBlockContainer = spellsTab.GetSpellBlockContainer() + spellBlockContainer:ClearBlocks() + + ---@type number + local spellId = spellBar.spellId + + ---@type number + local elapsedTime = spellBar.combatTime --this should be actorObject:Tempo() + + ---@type spelltable + local spellTable = spellBar.spellTable + + if (IsShiftKeyDown()) then + if (type(spellId) == "number") then + GameCooltip:Preset(2) + GameCooltip:SetOwner(spellBar, "ANCHOR_TOPRIGHT") + GameCooltip:AddLine(Loc ["ABILITY_ID"] .. ": " .. spellBar.spellId) + GameCooltip:Show() + end + end + + if (spellId == 98021) then --spirit link totem + GameTooltip:SetOwner(spellBar, "ANCHOR_TOPLEFT") + GameTooltip:AddLine(Loc ["STRING_SPIRIT_LINK_TOTEM_DESC"]) + GameTooltip:Show() + end + + if (mainAttribute == DETAILS_ATTRIBUTE_DAMAGE and subAttribute == DETAILS_SUBATTRIBUTE_DAMAGEDONE) then + ---@type number + local blockIndex = 1 + + ---@type number + local totalHits = spellTable.counter + + --damage section showing damage done sub section + --get the first spell block to use as summary + ---@type breakdownspellblock + local summaryBlock = spellBlockContainer:GetBlock(blockIndex) + summaryBlock:Show() + blockIndex = blockIndex + 1 + + do --update the texts in the summary block + local blockLine1, blockLine2, blockLine3 = summaryBlock:GetLines() + + blockLine1.leftText:SetText(Loc ["STRING_CAST"] .. ": " .. spellBar.amountCasts) --total amount of casts + blockLine1.rightText:SetText(Loc ["STRING_HITS"]..": " .. totalHits) --hits and uptime + + blockLine2.leftText:SetText(Loc ["STRING_DAMAGE"]..": " .. Details:Format(spellTable.total)) --total damage + blockLine2.rightText:SetText(Details:GetSpellSchoolFormatedName(spellTable.spellschool)) --spell school + + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:Format(spellBar.average)) --average damage + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellBar.perSecond)) --dps + end + + --check if there's normal hits and build the block + ---@type number + local normalHitsAmt = spellTable.n_amt + + --problem: spellTable is in facts bkSpellTable, fuck! + if (not normalHitsAmt) then + print(spellTable.spellTables, spellTable.petNames) + dumpt(spellTable) + return + end + + if (normalHitsAmt > 0) then + ---@type breakdownspellblock + local normalHitsBlock = spellBlockContainer:GetBlock(blockIndex) + normalHitsBlock:Show() + blockIndex = blockIndex + 1 + + local percent = normalHitsAmt / math.max(totalHits, 0.0001) * 100 + normalHitsBlock:SetValue(percent) + normalHitsBlock.sparkTexture:SetPoint("left", normalHitsBlock, "left", percent / 100 * normalHitsBlock:GetWidth() + spellBreakdownSettings.blockspell_spark_offset, 0) + normalHitsBlock:SetStatusBarColor(1, 1, 1, .5) + + local blockLine1, blockLine2, blockLine3 = normalHitsBlock:GetLines() + blockLine1.leftText:SetText(Loc ["STRING_NORMAL_HITS"]) + blockLine1.rightText:SetText(normalHitsAmt .. " [|cFFC0C0C0" .. string.format("%.1f", normalHitsAmt / math.max(totalHits, 0.0001) * 100) .. "%|r]") + + blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_min)) + blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.n_max)) + + local normalAverage = spellTable.n_dmg / math.max(normalHitsAmt, 0.0001) + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(normalAverage)) + + local tempo = (elapsedTime * spellTable.n_dmg) / math.max(spellTable.total, 0.001) + local normalAveragePercent = spellBar.average / normalAverage * 100 + local normalTempoPercent = normalAveragePercent * tempo / 100 + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.n_dmg / normalTempoPercent)) + end + + ---@type number + local criticalHitsAmt = spellTable.c_amt + if (criticalHitsAmt > 0) then + ---@type breakdownspellblock + local critHitsBlock = spellBlockContainer:GetBlock(blockIndex) + critHitsBlock:Show() + blockIndex = blockIndex + 1 + + local percent = criticalHitsAmt / math.max(totalHits, 0.0001) * 100 + critHitsBlock:SetValue(percent) + critHitsBlock.sparkTexture:SetPoint("left", critHitsBlock, "left", percent / 100 * critHitsBlock:GetWidth() + spellBreakdownSettings.blockspell_spark_offset, 0) + critHitsBlock:SetStatusBarColor(1, 1, 1, .5) + + local blockLine1, blockLine2, blockLine3 = critHitsBlock:GetLines() + blockLine1.leftText:SetText(Loc ["STRING_CRITICAL_HITS"]) + blockLine1.rightText:SetText(criticalHitsAmt .. " [|cFFC0C0C0" .. string.format("%.1f", criticalHitsAmt / math.max(totalHits, 0.0001) * 100) .. "%|r]") + + blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_min)) + blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_max)) + + local critAverage = spellTable.c_dmg / math.max(criticalHitsAmt, 0.0001) + blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(critAverage)) + + local tempo = (elapsedTime * spellTable.c_dmg) / math.max(spellTable.total, 0.001) + local critAveragePercent = spellBar.average / critAverage * 100 + local critTempoPercent = critAveragePercent * tempo / 100 + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.c_dmg / critTempoPercent)) + end + end + + --effects on entering the bar line + spellBar:SetHeight(CONST_SPELLSCROLL_LINEHEIGHT + 1) + spellBar:SetAlpha(1) + spellBar.spellIcon:SetSize(CONST_SPELLSCROLL_LINEHEIGHT + 2, CONST_SPELLSCROLL_LINEHEIGHT + 2) + spellBar.spellIcon:SetAlpha(1) +end + +---run this function when the mouse leaves a breakdownspellbar +---@param spellBar breakdownspellbar +local onLeaveBreakdownSpellBar = function(spellBar) + --diminui o tamanho da barra + spellBar:SetHeight(CONST_SPELLSCROLL_LINEHEIGHT) + --volta com o alfa antigo da barra que era de 0.9 + spellBar:SetAlpha(0.9) + + --volto o background ao normal + spellBar:SetBackdrop(row_backdrop_onleave) + spellBar:SetBackdropBorderColor(0, 0, 0, 0) + spellBar:SetBackdropColor(0, 0, 0, 0) + + GameTooltip:Hide() + GameCooltip:Hide() + + if (spellBar.isMain) then + --retira o zoom no icone + spellBar.spellIcon:SetSize(CONST_SPELLSCROLL_LINEHEIGHT, CONST_SPELLSCROLL_LINEHEIGHT) + spellBar.spellIcon:SetAlpha(1) + + --remover o conte�do que estava sendo mostrado na direita + if (breakdownWindow.mostrando_mouse_over) then + breakdownWindow.mostrando = nil + breakdownWindow.mostrando_mouse_over = false + breakdownWindow.showing = nil + breakdownWindow.jogador.detalhes = nil + spellsTab.HidaAllDetalheInfo() + end + + elseif (spellBar.isAlvo) then + spellBar:SetHeight(CONST_TARGET_HEIGHT) + + elseif (spellBar.isDetalhe) then + spellBar:SetHeight(16) + end +end + +---on mouse down a breakdownspellbar in the breakdown window +---@param spellBar breakdownspellbar +---@param button string +local onMouseDownBreakdownSpellBar = function(spellBar, button) + local x, y = _G.GetCursorPosition() + spellBar.cursorPosX = math.floor(x) + spellBar.cursorPosY = math.floor(y) + Details222.PlayerBreakdown.OnMouseDown(spellBar, button) +end + +---on mouse up a breakdownspellbar in the breakdown window +---@param spellBar breakdownspellbar +---@param button string +local onMouseUpBreakdownSpellBar = function(spellBar, button) + if (spellBar.onMouseUpTime == GetTime()) then + return + end + + spellBar.onMouseUpTime = GetTime() + + ---@type number, number + local x, y = _G.GetCursorPosition() + x = math.floor(x) + y = math.floor(y) + + ---@type boolean + local bIsMouseInTheSamePosition = (x == spellBar.cursorPosX) and (y == spellBar.cursorPosY) + + --if the mouse is in the same position, then the user clicked the bar + --clicking the bar activate the lock mechanism + if (bIsMouseInTheSamePosition) then + spellsTab.SelectSpellBar(spellBar) + end +end + + +local onEnterSpellIconFrame = function(self) + local line = self:GetParent() + if (line.spellId and type(line.spellId) == "number") then + local spellName = _GetSpellInfo(line.spellId) + if (spellName) then + GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") + Details:GameTooltipSetSpellByID(line.spellId) + GameTooltip:Show() + end + end + line:GetScript("OnEnter")(line) +end + +local onLeaveSpellIconFrame = function(self) + GameTooltip:Hide() + self:GetParent():GetScript("OnLeave")(self:GetParent()) +end + +-------------------------------------------------------------------------------------------------------------------------------------------- + +local spellBlockMixin = { + ---get one of the three lines containing fontstrings to show data + ---line 1 is the top line, line 2 is the middle line and line 3 is the bottom line + ---@param self breakdownspellblock + ---@param lineIndex number + ---@return breakdownspellblockline + GetLine = function(self, lineIndex) + ---@type breakdownspellblockline + local line = self.Lines[lineIndex] + return line + end, + + ---return all lines in the spell block, all spell block have 3 lines + ---@param self breakdownspellblock + ---@return breakdownspellblockline, breakdownspellblockline, breakdownspellblockline + GetLines = function(self) + return unpack(self.Lines) + end, +} + +---create a spell block into the spellcontainer +---@param spellBlockContainer breakdownspellblockcontainer +---@param index number +---@return breakdownspellblock +function spellsTab.CreateSpellBlock(spellBlockContainer, index) --~breakdownspellblock ~create ~spellblocks + ---@type breakdownspellblock + local spellBlock = CreateFrame("statusbar", "$parentBlock" .. index, spellBlockContainer, "BackdropTemplate") + DetailsFramework:Mixin(spellBlock, spellBlockMixin) + local t = spellBlock:CreateTexture(nil, "artwork") + t:SetColorTexture(1, 1, 1, 1) + spellBlock:SetStatusBarTexture(t) --debug + --spellBlock:SetStatusBarTexture("Interface\\AddOns\\Details\\images\\bar_background") + spellBlock:SetStatusBarColor(1, 1, 1, .84) + spellBlock:SetMinMaxValues(0, 100) + spellBlock:SetValue(100) + spellBlock:SetScript("OnEnter", onEnterSpellBlock) + spellBlock:SetScript("OnLeave", onLeaveSpellBlock) + + --create the lines which will host the texts + spellBlock.Lines = {} + for i = 1, spellBlockContainerSettings.lineAmount do + ---@type breakdownspellblockline + local line = CreateFrame("frame", "$parentLine" .. i, spellBlock) + --DetailsFramework:ApplyStandardBackdrop(line) + spellBlock.Lines[i] = line + + line.leftText = line:CreateFontString("$parentLeftText", "overlay", "GameFontHighlightSmall") + line.centerText = line:CreateFontString("$parentLeftText", "overlay", "GameFontHighlightSmall") + line.rightText = line:CreateFontString("$parentLeftText", "overlay", "GameFontHighlightSmall") + + line.leftText:SetPoint("left", line, "left", 2, 0) + line.leftText:SetJustifyH("left") + line.centerText:SetPoint("center", line, "center", 0, 0) + line.centerText:SetJustifyH("center") + line.rightText:SetPoint("right", line, "right", -2, 0) + line.rightText:SetJustifyH("right") + end + + --overlay texture which fade in and out when the spell block is hovered over + --is only possible to hover over a spell block when the spellbar is selected + spellBlock.overlay = spellBlock:CreateTexture("$parentOverlay", "artwork") + spellBlock.overlay:SetTexture("Interface\\AddOns\\Details\\images\\overlay_detalhes") + spellBlock.overlay:SetColorTexture(1, 0, 0, 1) + spellBlock.overlay:SetAllPoints() + Details.FadeHandler.Fader(spellBlock.overlay, 1) --hide + + --report button, also only shown when the spell block is hovered over + spellBlock.reportButton = Details.gump:NewDetailsButton(spellBlock, nil, nil, Details.Reportar, Details.playerDetailWindow, 10 + index, 16, 16, + "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport1") + Details.FadeHandler.Fader(spellBlock.reportButton, 1) --hide + spellBlock.reportButton:SetScript("OnEnter", onEnterInfoReport) + spellBlock.reportButton:SetScript("OnLeave", onLeaveInfoReport) + + --spark texture + spellBlock.sparkTexture = spellBlock:CreateTexture("$parentOverlaySparkTexture", "overlay") + spellBlock.sparkTexture:SetTexture("Interface\\AddOns\\Details\\images\\bar_detalhes2_end") + spellBlock.sparkTexture:SetBlendMode("ADD") + + local gradientDown = DetailsFramework:CreateTexture(spellBlock, {gradient = "vertical", fromColor = {0, 0, 0, 0.1}, toColor = "transparent"}, 1, 43, "background", {0, 1, 0, 1}) + gradientDown:SetPoint("bottoms") + spellBlock.gradientTexture = gradientDown + + return spellBlock +end + +local spellBlockContainerMixin = { + ---refresh all the spellblocks in the container ~UpdateBlocks + ---this function adjust the frame properties, does not update the data shown on them + ---@param self breakdownspellblockcontainer + UpdateBlocks = function(self) --~update + ---@type number, number + local width, height = spellBreakdownSettings.blockcontainer_width, spellBreakdownSettings.blockcontainer_height + local blockHeight = spellBreakdownSettings.blockspell_height + self:SetSize(width, height) + + for i = 1, #self.SpellBlocks do + ---@type breakdownspellblock + local spellBlock = self.SpellBlocks[i] + + spellBlock:SetSize(width - 2, blockHeight) + spellBlock:SetPoint("topleft", self, "topleft", 1, (blockHeight * (i - 1) - i) * -1 - (i*2)) + spellBlock.sparkTexture:SetSize(spellBreakdownSettings.blockspell_spark_width, blockHeight) + spellBlock.sparkTexture:SetShown(spellBreakdownSettings.blockspell_spark_show) + spellBlock.sparkTexture:SetVertexColor(unpack(spellBreakdownSettings.blockspell_spark_color)) + spellBlock.reportButton:SetPoint("bottomright", spellBlock.overlay, "bottomright", -2, 2) + spellBlock.gradientTexture:SetHeight(blockHeight) + + --update the lines + local previousLine + for o = 1, spellBlockContainerSettings.lineAmount do + ---@type breakdownspellblockline + local line = spellBlock.Lines[o] + line:SetSize(width - 2, spellBreakdownSettings.blockspellline_height) + if (previousLine) then + line:SetPoint("topleft", previousLine, "bottomleft", 0, -2) + else + line:SetPoint("topleft", spellBlock, "topleft", 1, -2) + end + previousLine = line + end + end + end, + + ---@param self breakdownspellblockcontainer + ClearBlocks = function(self) + for i = 1, #self.SpellBlocks do + ---@type breakdownspellblock + local spellBlock = self.SpellBlocks[i] + spellBlock:Hide() + + --clear the text shown in their lines + for o = 1, 3 do + spellBlock.Lines[o].leftText:SetText("") + spellBlock.Lines[o].centerText:SetText("") + spellBlock.Lines[o].rightText:SetText("") + end + end + end, + + ---get a breakdownspellblock from the container + ---@param self breakdownspellblockcontainer + ---@param index number + ---@return breakdownspellblock + GetBlock = function(self, index) + return self.SpellBlocks[index] + end, +} + +---create the spell blocks which shows the critical hits, normal hits, etc +---@param tabFrame tabframe +---@return breakdownspellblockcontainer +function spellsTab.CreateSpellBlockContainer(tabFrame) + --create the container which will hold the spell blocks + ---@type breakdownspellblockcontainer + local spellBlockContainer = CreateFrame("Frame", "$parentSpellBlockContainer", tabFrame, "BackdropTemplate") + spellBlockContainer:EnableMouse(true) + spellBlockContainer:SetResizable(false) + spellBlockContainer:SetMovable(true) + DetailsFramework:Mixin(spellBlockContainer, spellBlockContainerMixin) + DetailsFramework:ApplyStandardBackdrop(spellBlockContainer) + tabFrame.SpellBlockContainer = spellBlockContainer + + spellBlockContainer.SpellBlocks = {} + + for i = 1, spellBlockContainerSettings.amount do + ---@type breakdownspellblock + local spellBlock = spellsTab.CreateSpellBlock(spellBlockContainer, i) + table.insert(spellBlockContainer.SpellBlocks, spellBlock) + --size and point are set on ~UpdateBlocks + end + + spellBlockContainer:UpdateBlocks() + + return spellBlockContainer +end + +function spellsTab.CreateTargetContainer(tabFrame) + local container_alvos_window = CreateFrame("ScrollFrame", "Details_Info_ContainerAlvosScroll", tabFrame, "BackdropTemplate") + local container_alvos = CreateFrame("Frame", "Details_Info_ContainerAlvos", container_alvos_window, "BackdropTemplate") + + container_alvos:SetAllPoints(container_alvos_window) + container_alvos:SetSize(300, 100) + container_alvos:EnableMouse(true) + container_alvos:SetMovable(true) + + container_alvos_window:SetSize(300, 100) + container_alvos_window:SetScrollChild(container_alvos) + container_alvos_window:SetPoint("bottomleft", tabFrame, "bottomleft", 20, 6) --56 default + + container_alvos_window:SetScript("OnSizeChanged", function(self) + container_alvos:SetSize(self:GetSize()) + end) + + _detalhes.gump:NewScrollBar(container_alvos_window, container_alvos, 7, 4) + container_alvos_window.slider:Altura(88) + container_alvos_window.slider:cimaPoint(0, 1) + container_alvos_window.slider:baixoPoint(0, -3) + + container_alvos_window.gump = container_alvos + tabFrame.container_alvos = container_alvos_window + + tabFrame.targets = tabFrame:CreateFontString(nil, "OVERLAY", "QuestFont_Large") + tabFrame.targets:SetPoint("TOPLEFT", tabFrame, "TOPLEFT", 24, -273) + tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":") +end + +--logistics: class_damage build the list of spells, send it to window_playerbreakdown, which gets the current summary tab and send the data for it +--in this tab, the data is sent to the refresh function + +local onClickExpandButton = function(expandButton, button) + ---@type breakdownspellbar + local spellBar = expandButton:GetParent() + ---@type table + local scrolFrame = spellBar:GetParent() + ---@type boolean + local bIsSpellExpaded = expandButton.bIsSpellExpaded + + --check if the one of the expanded bars was a selected spellbar and deselect + --get the current selected spellbar + ---@type breakdownspellbar + local selectedSpellBar = spellsTab.GetSelectedSpellBar() + + if (bIsSpellExpaded) then --it's already expended, it'll close the expanded spellbars + --check if the selected spellbar is one of the expanded spellbars and deselect it + for i = 1, #spellBar.ExpandedChildren do + ---@type breakdownspellbar + local expandedSpellBar = spellBar.ExpandedChildren[i] + if (expandedSpellBar == selectedSpellBar) then + --deselect the spellbar + spellsTab.UnSelectSpellBar() + break + end + end + else + spellsTab.UnSelectSpellBar() + end + + --todo: check is any other bar has expanded state true, and close the expand (or not) + + --toggle this spell expand mode + Details222.BreakdownWindow.SetSpellAsExpanded(expandButton.spellId, not bIsSpellExpaded) + --refresh the scrollFrame + scrolFrame:Refresh() +end + +---update a line using the data passed +---@param spellBar breakdownspellbar +---@param index number spell position (from best to wrost) +---@param actorName string +---@param combatObject combat +---@param scrollFrame table +---@param headerTable table +---@param bkSpellData breakdownspelldata +---@param bkSpellStableIndex number +---@param totalValue number +---@param maxValue number +---@param bIsMainLine boolean if true this is the line which has all the values of the spell merged +local updateSpellBar = function(spellBar, index, actorName, combatObject, scrollFrame, headerTable, bkSpellData, bkSpellStableIndex, totalValue, maxValue, bIsMainLine) + --scrollFrame is defined as a table which is false, scrollFrame is a frame + + local textIndex = 1 + for headerIndex = 1, #headerTable do + ---@type number + local spellId + ---@type number + local value + ---@type spelltable + local spellTable + + local petName = "" + + spellBar.bkSpellData = bkSpellData + + if (bIsMainLine) then + spellTable = bkSpellData + value = bkSpellData.total + spellId = bkSpellData.id + petName = bkSpellData.petNames[bkSpellStableIndex] + else + spellTable = bkSpellData.spellTables[bkSpellStableIndex] + value = spellTable.total + spellId = spellTable.id + petName = bkSpellData.petNames[bkSpellStableIndex] + spellBar.bIsExpandedSpell = true + end + + spellBar.spellId = spellId + + ---@cast spellTable spelltable + spellBar.spellTable = spellTable + + ---@type number + local amtCasts = combatObject:GetSpellCastAmount(actorName, spellId) + spellBar.amountCasts = amtCasts + ---@type number + local uptime = combatObject:GetSpellUptime(actorName, spellId) + ---@type number + local combatTime = combatObject:GetCombatTime() + ---@type string, number, string + local spellName, _, spellIcon = Details.GetSpellInfo(spellId) + + if (petName ~= "") then + spellName = spellName .. " (" .. petName .. ")" + end + + spellBar.spellId = spellId + spellBar.spellIconFrame.spellId = spellId + + --statusbar size by percent, statusbar color by school + spellBar.statusBar:SetValue(value / maxValue * 100) + local r, g, b = Details:GetSpellSchoolColor(spellTable.spellschool or 1) + spellBar.statusBar:SetStatusBarColor(r, g, b, 1) + + spellBar.average = value / spellTable.counter + spellBar.combatTime = combatTime + + ---@type fontstring + local text = spellBar.InLineTexts[textIndex] + local header = headerTable[headerIndex] + + if (header.name == "icon") then --ok + spellBar.spellIcon:Show() + spellBar.spellIcon:SetTexture(spellIcon) + spellBar:AddFrameToHeaderAlignment(spellBar.spellIconFrame) + + elseif (header.name == "target") then --the tab does not have knownledge about the targets of the spell, it must be passed over + ---@type breakdowntargetframe + local targetsSquareFrame = spellBar.targetsSquareFrame + targetsSquareFrame:Show() + targetsSquareFrame.spellId = spellId + targetsSquareFrame.bkSpellData = spellTable + targetsSquareFrame.spellTable = spellTable + targetsSquareFrame.bIsMainLine = bIsMainLine + spellBar:AddFrameToHeaderAlignment(targetsSquareFrame) + + elseif (header.name == "rank") then --ok + text:SetText(index) + spellBar:AddFrameToHeaderAlignment(text) + spellBar.rank = index + textIndex = textIndex + 1 + + elseif (header.name == "expand") then + text:SetText("") + spellBar:AddFrameToHeaderAlignment(spellBar.expandButton) + textIndex = textIndex + 1 + + if (bkSpellData.bCanExpand and bIsMainLine) then + spellBar.expandButton:Show() + local bIsSpellExpaded = Details222.BreakdownWindow.IsSpellExpanded(spellId) + + spellBar.expandButton.spellId = spellId + spellBar.expandButton.bIsSpellExpaded = bIsSpellExpaded + spellBar.expandButton:SetScript("OnClick", onClickExpandButton) + + --update the texture taking the state of the expanded value + spellBar.expandButton.texture:SetTexture(bIsSpellExpaded and [[Interface\BUTTONS\Arrow-Up-Down]] or [[Interface\BUTTONS\Arrow-Down-Down]]) + end + + elseif (header.name == "name") then --ok + text:SetText(spellName) + spellBar.name = spellName + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "amount") then --ok + text:SetText(Details:Format(value)) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "persecond") then --ok + spellBar.perSecond = value / combatTime + + ---@type string + local perSecondFormatted = Details:Format(spellBar.perSecond) + text:SetText(perSecondFormatted) + + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "percent") then --ok + spellBar.percent = value / totalValue * 100 + ---@type string + local percentFormatted = string.format("%.1f", spellBar.percent) .. "%" + text:SetText(percentFormatted) + + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "casts") then --the tab doesn't have information about the amount of casts + text:SetText(amtCasts) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "critpercent") then --the tab does not have this information + text:SetText(string.format("%.1f", spellTable.c_amt / (spellTable.counter) * 100) .. "%") + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "hits") then --ok + text:SetText(spellTable.counter) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "castavg") then --ok + spellBar.castAverage = value / amtCasts + text:SetText(Details:Format(spellBar.castAverage)) + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + + elseif (header.name == "uptime") then --need to get the uptime of the spell with the biggest uptime + text:SetText(string.format("%.1f", uptime / combatTime * 100) .. "%") + spellBar:AddFrameToHeaderAlignment(text) + textIndex = textIndex + 1 + end + end + + spellBar:AlignWithHeader(scrollFrame.Header, "left") +end + +---get a spell bar from the scroll box, if it doesn't exist, return nil +---@param scrollFrame table +---@param lineIndex number +---@return breakdownspellbar +local getSpellBar = function(scrollFrame, lineIndex) + ---@type breakdownspellbar + local spellBar = scrollFrame:GetLine(lineIndex) + + spellBar.bIsExpandedSpell = false + + table.wipe(spellBar.ExpandedChildren) + + --reset header alignment + spellBar:ResetFramesToHeaderAlignment() + + --reset columns, hiding them + spellBar.spellIcon:Hide() + spellBar.expandButton:Hide() + spellBar.targetsSquareFrame:Hide() + for inLineIndex = 1, #spellBar.InLineTexts do + spellBar.InLineTexts[inLineIndex]:SetText("") + end + + return spellBar +end + +---refresh the data shown in the spells scroll box +---@param scrollFrame table +---@param scrollData breakdownscrolldata +---@param offset number +---@param totalLines number +local refreshFunc = function(scrollFrame, scrollData, offset, totalLines) --~refresh spells + ---@type number + local maxValue = scrollData[1] and scrollData[1].total + ---@type number + local totalValue = scrollData.totalValue + + ---@type actor + local actorObject = spellsTab.GetActor() + ---@type string + local actorName = actorObject:Name() + + ---@type combat + local combatObject = spellsTab.GetCombat() + ---@type instance + local instanceObject = spellsTab.GetInstance() + + local headerTable = spellsTab.BuildHeaderTable() + scrollFrame.Header:SetHeaderTable(headerTable) + + local lineIndex = 1 + for i = 1, totalLines do + local index = i + offset + + ---@type breakdownspelldata + local bkSpellData = scrollData[index] + + if (bkSpellData) then + --before getting a line, check if the data for the line is a expanded line and if the spell is expanded + local expandedIndex = bkSpellData.expandedIndex + local spellId = bkSpellData.id + local value = math.floor(bkSpellData.total) + + ---@type number[] + local spellIds = bkSpellData.spellIds --array with spellIds + ---@type spelltable[] + local spellTables = bkSpellData.spellTables --array with spellTables + ---@type number + local spellTablesAmount = #spellTables + ---@type string[] + local petNames = bkSpellData.petNames --array with pet names + ---@type boolean + + ---called mainSpellBar because it is the line that shows the sum of all spells merged (if any) + ---@type breakdownspellbar + local mainSpellBar = getSpellBar(scrollFrame, lineIndex) + do + --main line of the spell, where the sum of all spells merged is shown + if (mainSpellBar) then + lineIndex = lineIndex + 1 + local bIsMainLine = true + updateSpellBar(mainSpellBar, index, actorName, combatObject, scrollFrame, headerTable, bkSpellData, 1, totalValue, maxValue, bIsMainLine) + end + end + + --then it adds the lines for each spell merged, but it cannot use the bkSpellData, it needs the spellTable + if (bkSpellData.bIsExpanded and spellTablesAmount > 1) then + ---@type number spellTableIndex is the same counter as bkSpellStableIndex + for spellTableIndex = 1, spellTablesAmount do + ---@type breakdownspellbar + local spellBar = getSpellBar(scrollFrame, lineIndex) + if (spellBar) then + lineIndex = lineIndex + 1 + ---@type string + local petName = petNames[spellTableIndex] + ---@type string + local nameToUse = petName ~= "" and petName or actorName + local bIsMainLine = false + updateSpellBar(spellBar, index, nameToUse, combatObject, scrollFrame, headerTable, bkSpellData, spellTableIndex, totalValue, maxValue, bIsMainLine) + mainSpellBar.ExpandedChildren[#mainSpellBar.ExpandedChildren + 1] = spellBar + end + end + end + + if (lineIndex > totalLines) then + break + end + end + end +end + +---creates a scrollframe which show breakdownspellbar to show the spells used by an actor +---@param tabFrame tabframe +---@return breakdownspellscrollframe +function spellsTab.CreateSpellScrollContainer(tabFrame) + --replace this with a framework scrollframe + local scrollFrame = DF:CreateScrollBox(tabFrame, "$parentSpellScroll", refreshFunc, {}, CONST_SPELLSCROLL_WIDTH, CONST_SPELLSCROLL_HEIGHT, CONST_SPELLSCROLL_AMTLINES, CONST_SPELLSCROLL_LINEHEIGHT) + DF:ReskinSlider(scrollFrame) + DF:ApplyStandardBackdrop(scrollFrame) + scrollFrame:SetPoint("topleft", tabFrame, "topleft", 5, -5) --need to set the points + scrollFrame:EnableMouse(true) + scrollFrame:SetMovable(true) + tabFrame.SpellScrollFrame = scrollFrame + + function scrollFrame:RefreshMe(data) + self:SetData(data) + self:Refresh() + end + + --~header + local headerOptions = { + padding = 2, + header_height = 14, + } + + local headerTable = spellsTab.BuildHeaderTable() + + scrollFrame.Header = DetailsFramework:CreateHeader(scrollFrame, headerTable, headerOptions) + scrollFrame.Header:SetPoint("topleft", scrollFrame, "topleft", 0, 0) + + --create the scroll lines + for i = 1, CONST_SPELLSCROLL_AMTLINES do + scrollFrame:CreateLine(spellsTab.CreateSpellBar) + end + + return scrollFrame +end + +--special backgrounds -- fundos especiais de friendly fire e outros +function spellsTab.CreateSpecialBackgrounds(tabFrame) + tabFrame.no_targets = tabFrame:CreateTexture("DetailsBreakdownWindow_no_targets", "overlay") + tabFrame.no_targets:SetPoint("bottomleft", tabFrame, "bottomleft", 20, 6) + tabFrame.no_targets:SetSize(301, 100) + tabFrame.no_targets:SetTexture([[Interface\QUESTFRAME\UI-QUESTLOG-EMPTY-TOPLEFT]]) + tabFrame.no_targets:SetTexCoord(0.015625, 1, 0.01171875, 0.390625) + tabFrame.no_targets:SetDesaturated(true) + tabFrame.no_targets:SetAlpha(.7) + tabFrame.no_targets.text = tabFrame:CreateFontString(nil, "overlay", "GameFontNormal") + tabFrame.no_targets.text:SetPoint("center", tabFrame.no_targets, "center") + tabFrame.no_targets.text:SetText(Loc ["STRING_NO_TARGET_BOX"]) + tabFrame.no_targets.text:SetTextColor(1, 1, 1, .4) + tabFrame.no_targets:Hide() +end + +---on enter function for the spell target frame +---@param targetFrame breakdowntargetframe +local onEnterSpellTarget = function(targetFrame) + --the spell target frame is created in the statusbar which is placed above the line frame + local lineBar = targetFrame:GetParent():GetParent() + local spellId = targetFrame.spellId + + ---@type actor + local actorObject = Details:GetPlayerObjectFromBreakdownWindow() + + local targets + if (targetFrame.bIsMainLine) then + ---@type breakdownspelldata + local bkSpellData = targetFrame.bkSpellData + targets = actorObject:BuildSpellTargetFromBreakdownSpellData(bkSpellData) + else + local spellTable = targetFrame.spellTable + targets = actorObject:BuildSpellTargetFromSpellTable(spellTable) + end + + ---@type number the top value of targets + local topValue = targets[1] and targets[1][2] or 0 + + local cooltip = GameCooltip + cooltip:Preset(2) + + for targetIndex, targetTable in ipairs(targets) do + local targetName = targetTable[1] + local value = targetTable[2] + cooltip:AddLine(targetIndex .. ". " .. targetName, Details:Format(value)) + GameCooltip:AddIcon([[Interface\MINIMAP\TRACKING\Target]], 1, 1, 14, 14) + Details:AddTooltipBackgroundStatusbar(false, value / topValue * 100) + end + + cooltip:SetOwner(targetFrame) + cooltip:Show() + + if true then return end + + do + if (spellId and type(spellId) == "number") then + ---@type actor + local actorObject = lineBar.other_actor or breakdownWindow.jogador + local spellTable = actorObject.spells and actorObject.spells:GetSpell(spellId) + + if (spellTable) then + local spellsSortedResult = {} + local targetContainer + local total = 0 + + if (spellTable.isReflection) then + targetContainer = spellTable.extra + else + local attribute, subAttribute = breakdownWindow.instancia:GetDisplay() + if (attribute == 1 or attribute == 3) then + targetContainer = spellTable.targets + else + if (subAttribute == 3) then --overheal + targetContainer = spellTable.targets_overheal + + elseif (subAttribute == 6) then --absorbs + targetContainer = spellTable.targets_absorbs + + else + targetContainer = spellTable.targets + end + end + end + + --add and sort + for targetName, amount in pairs(targetContainer) do + if (amount > 0) then + spellsSortedResult[#spellsSortedResult+1] = {targetName, amount} + total = total + amount + end + end + table.sort(spellsSortedResult, Details.Sort2) + + local spellName, _, spellIcon = _GetSpellInfo(spellId) + + GameTooltip:SetOwner(targetFrame, "ANCHOR_TOPRIGHT") + GameTooltip:AddLine(lineBar.index .. ". " .. spellName) + GameTooltip:AddLine(Loc ["STRING_TARGETS"] .. ":") + GameTooltip:AddLine(" ") + + --get time type + local timeElapsed + if (Details.time_type == 1 or not actorObject.grupo) then + timeElapsed = actorObject:Tempo() + elseif (Details.time_type == 2) then + timeElapsed = breakdownWindow.instancia.showing:GetCombatTime() + end + + local abbreviationFunction = Details.ToKFunctions[Details.ps_abbreviation] + + if (spellTable.isReflection) then + Details:FormatCooltipForSpells() + GameCooltip:SetOwner(targetFrame, "bottomright", "top", 4, -2) + + Details:AddTooltipSpellHeaderText("Spells Reflected", {1, 0.9, 0.0, 1}, 1, select(3, _GetSpellInfo(spellTable.id)), 0.1, 0.9, 0.1, 0.9) --localize-me + Details:AddTooltipHeaderStatusbar(1, 1, 1, 0.4) + + GameCooltip:AddIcon(select(3, _GetSpellInfo(spellTable.id)), 1, 1, 16, 16, .1, .9, .1, .9) + Details:AddTooltipHeaderStatusbar(1, 1, 1, 0.5) + + local topAmount = spellsSortedResult[1] and spellsSortedResult[1][2] + + for index, targetTable in ipairs(spellsSortedResult) do + local targetName = targetTable[1] + local amount = targetTable[2] + + GameCooltip:AddLine(spellName, abbreviationFunction(_, amount) .. " (" .. math.floor(amount / topAmount * 100) .. "%)") + GameCooltip:AddIcon(spellIcon, 1, 1, 16, 16, .1, .9, .1, .9) + Details:AddTooltipBackgroundStatusbar(false, amount / topAmount * 100) + end + + GameCooltip:Show() + + targetFrame.texture:SetAlpha(1) + targetFrame:SetAlpha(1) + lineBar:GetScript("OnEnter")(lineBar) + return + else + for index, targetTable in ipairs(spellsSortedResult) do + local targetName = targetTable[1] + local amount = targetTable[2] + + local class = Details:GetClass(targetName) + if (class and Details.class_coords[class]) then + local cords = Details.class_coords[class] + if (breakdownWindow.target_persecond) then + GameTooltip:AddDoubleLine(index .. ". |TInterface\\AddOns\\Details\\images\\classes_small_alpha:14:14:0:0:128:128:"..cords[1]*128 ..":"..cords[2]*128 ..":"..cords[3]*128 ..":"..cords[4]*128 .."|t " .. targetName, Details:comma_value(math.floor(amount / timeElapsed)), 1, 1, 1, 1, 1, 1) + else + GameTooltip:AddDoubleLine(index .. ". |TInterface\\AddOns\\Details\\images\\classes_small_alpha:14:14:0:0:128:128:"..cords[1]*128 ..":"..cords[2]*128 ..":"..cords[3]*128 ..":"..cords[4]*128 .."|t " .. targetName, abbreviationFunction(_, amount), 1, 1, 1, 1, 1, 1) + end + else + if (breakdownWindow.target_persecond) then + GameTooltip:AddDoubleLine(index .. ". " .. targetName, Details:comma_value(math.floor(amount / timeElapsed)), 1, 1, 1, 1, 1, 1) + else + GameTooltip:AddDoubleLine(index .. ". " .. targetName, abbreviationFunction(_, amount), 1, 1, 1, 1, 1, 1) + end + end + end + end + + GameTooltip:Show() + else + GameTooltip:SetOwner(targetFrame, "ANCHOR_TOPRIGHT") + GameTooltip:AddLine(lineBar.index .. ". " .. lineBar.spellId) + GameTooltip:AddLine(breakdownWindow.target_text) + GameTooltip:AddLine(Loc ["STRING_NO_TARGET"], 1, 1, 1) + GameTooltip:AddLine(Loc ["STRING_MORE_INFO"], 1, 1, 1) + GameTooltip:Show() + end + else + GameTooltip:SetOwner(targetFrame, "ANCHOR_TOPRIGHT") + GameTooltip:AddLine(lineBar.index .. ". " .. lineBar.spellId) + GameTooltip:AddLine(breakdownWindow.target_text) + GameTooltip:AddLine(Loc ["STRING_NO_TARGET"], 1, 1, 1) + GameTooltip:AddLine(Loc ["STRING_MORE_INFO"], 1, 1, 1) + GameTooltip:Show() + end + + targetFrame.texture:SetAlpha(.7) + targetFrame:SetAlpha(1) + lineBar:GetScript("OnEnter")(lineBar) + end +end + +local onLeaveSpellTarget = function(self) + GameTooltip:Hide() + GameCooltip:Hide() + self:GetParent():GetParent():GetScript("OnLeave")(self:GetParent():GetParent()) + self.texture:SetAlpha(.7) + self:SetAlpha(.7) +end + +---create a spellbar within the spell scroll +---@param self breakdownspellscrollframe +---@param index number +---@return breakdownspellbar +function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~create ~createline + ---@type breakdownspellbar + local spellBar = CreateFrame("button", self:GetName() .. "SpellBar" .. index, self, "BackdropTemplate") + spellBar:SetHeight(CONST_SPELLSCROLL_LINEHEIGHT) + spellBar.index = index + local y = (index-1) * CONST_SPELLSCROLL_LINEHEIGHT * -1 + (1 * -index) - 15 + spellBar:SetPoint("topleft", self, "topleft", 0, y) + spellBar:SetPoint("topright", self, "topright", 0, y) + spellBar:SetFrameLevel(self:GetFrameLevel() + 1) + spellBar:EnableMouse(true) + spellBar:RegisterForClicks("LeftButtonDown", "RightButtonUp") + spellBar:SetScript("OnEnter", onEnterBreakdownSpellBar) + spellBar:SetScript("OnLeave", onLeaveBreakdownSpellBar) + spellBar:SetScript("OnMouseDown", onMouseDownBreakdownSpellBar) + spellBar:SetScript("OnMouseUp", onMouseUpBreakdownSpellBar) + spellBar.onMouseUpTime = 0 + spellBar.ExpandedChildren = {} + + DF:Mixin(spellBar, DF.HeaderFunctions) + + ---@type statusbar + local statusBar = CreateFrame("StatusBar", "$parentStatusBar", spellBar, "BackdropTemplate") + statusBar:SetFrameLevel(spellBar:GetFrameLevel()-1) + statusBar:SetAllPoints() + statusBar:SetAlpha(0.5) + statusBar:SetMinMaxValues(0, 100) + statusBar:SetValue(50) + spellBar.statusBar = statusBar + + ---@type texture + local statusBarTexture = statusBar:CreateTexture("$parentTexture", "artwork") + statusBarTexture:SetTexture(SharedMedia:Fetch("statusbar", "Details Hyanda")) + statusBar:SetStatusBarTexture(statusBarTexture) + statusBar:SetStatusBarColor(1, 1, 1, 1) + + ---create the overlay texture to use when the spellbar is selected + ---@type texture + local statusBarOverlayTexture = statusBar:CreateTexture("$parentTextureOverlay", "overlay", nil, 7) + statusBarOverlayTexture:SetTexture([[Interface/AddOns/Details/images/overlay_indicator_1]]) + statusBarOverlayTexture:SetVertexColor(1, 1, 1, 0.2) + statusBarOverlayTexture:SetAllPoints() + statusBarOverlayTexture:Hide() + spellBar.overlayTexture = statusBarOverlayTexture + statusBar.overlayTexture = statusBarOverlayTexture + + ---@type texture + local hightlightTexture = statusBar:CreateTexture("$parentTextureHighlight", "highlight") + hightlightTexture:SetColorTexture(1, 1, 1, 0.2) + hightlightTexture:SetAllPoints() + statusBar.highlightTexture = hightlightTexture + + ---@type texture + local backgroundTexture = statusBar:CreateTexture("$parentTextureBackground", "background") + backgroundTexture:SetAllPoints() + backgroundTexture:SetColorTexture(.1, .1, .1, 0.38) + statusBar.backgroundTexture = backgroundTexture + + --button to expand the bar when there's spells merged + ---@type breakdownexpandbutton + local expandButton = CreateFrame("button", "$parentExpandButton", spellBar, "BackdropTemplate") + expandButton:SetSize(CONST_BAR_HEIGHT, CONST_BAR_HEIGHT) + expandButton:RegisterForClicks("LeftButtonDown") + spellBar.expandButton = expandButton + + ---@type texture + local expandButtonTexture = expandButton:CreateTexture("$parentTexture", "artwork") + expandButtonTexture:SetPoint("center", expandButton, "center", 0, 0) + expandButtonTexture:SetSize(CONST_BAR_HEIGHT-2, CONST_BAR_HEIGHT-2) + expandButton.texture = expandButtonTexture + + --frame which will show the spell tooltip + ---@type frame + local spellIconFrame = CreateFrame("frame", "$parentIconFrame", spellBar, "BackdropTemplate") + spellIconFrame:SetSize(CONST_BAR_HEIGHT - 2, CONST_BAR_HEIGHT - 2) + spellIconFrame:SetScript("OnEnter", onEnterSpellIconFrame) + spellIconFrame:SetScript("OnLeave", onLeaveSpellIconFrame) + spellBar.spellIconFrame = spellIconFrame + + --create the icon to show the spell texture + ---@type texture + local spellIcon = spellIconFrame:CreateTexture("$parentTexture", "overlay") + spellIcon:SetAllPoints() + spellIcon:SetTexCoord(.1, .9, .1, .9) + spellBar.spellIcon = spellIcon + + --create a square frame which is placed at the right side of the line to show which targets for damaged by the spell + ---@type breakdowntargetframe + local targetsSquareFrame = CreateFrame("frame", "$parentTargetsFrame", statusBar, "BackdropTemplate") + targetsSquareFrame:SetSize(CONST_SPELLSCROLL_LINEHEIGHT, CONST_SPELLSCROLL_LINEHEIGHT) + targetsSquareFrame:SetAlpha(.7) + targetsSquareFrame:SetScript("OnEnter", onEnterSpellTarget) + targetsSquareFrame:SetScript("OnLeave", onLeaveSpellTarget) + targetsSquareFrame:SetFrameLevel(statusBar:GetFrameLevel()+2) + spellBar.targetsSquareFrame = targetsSquareFrame + + ---@type texture + local targetTexture = targetsSquareFrame:CreateTexture("$parentTexture", "overlay") + targetTexture:SetTexture([[Interface\MINIMAP\TRACKING\Target]]) + targetTexture:SetAllPoints() + targetTexture:SetDesaturated(true) + spellBar.targetsSquareTexture = targetTexture + targetsSquareFrame.texture = targetTexture + + spellBar:AddFrameToHeaderAlignment(spellIconFrame) + spellBar:AddFrameToHeaderAlignment(targetsSquareFrame) + + --create texts + ---@type fontstring[] + spellBar.InLineTexts = {} + + for i = 1, 16 do + ---@type fontstring + local fontString = spellBar:CreateFontString("$parentFontString" .. i, "overlay", "GameFontHighlightSmall") + fontString:SetJustifyH("left") + fontString:SetTextColor(1, 1, 1, 1) + fontString:SetNonSpaceWrap(true) + fontString:SetWordWrap(false) + spellBar["lineText" .. i] = fontString + spellBar.InLineTexts[i] = fontString + fontString:SetTextColor(1, 1, 1, 1) + spellBar:AddFrameToHeaderAlignment(fontString) + end + + spellBar:AlignWithHeader(self.Header, "left") + + spellBar.on_focus = false + + return spellBar +end + + +--[=[ +function gump:CriaNovaBarraInfo2(instance, index) --not used on this file, used on class damage, heal, etc + if (_detalhes.playerDetailWindow.barras2[index]) then + return + end + + local janela = info.container_alvos.gump + + local newBar = CreateFrame("Button", "Details_infobox2_bar_" .. index, info.container_alvos.gump, "BackdropTemplate") + newBar:SetHeight(CONST_TARGET_HEIGHT) + + local y = (index-1) * (CONST_TARGET_HEIGHT + 1) + y = y* - 1 + + newBar:SetPoint("LEFT", janela, "LEFT", CONST_TARGET_HEIGHT, 0) + newBar:SetPoint("RIGHT", janela, "RIGHT", 0, 0) + newBar:SetPoint("TOP", janela, "TOP", 0, y) + newBar:SetFrameLevel(janela:GetFrameLevel() + 1) + newBar:EnableMouse(true) + newBar:RegisterForClicks("LeftButtonDown","RightButtonUp") + + --icon + newBar.icone = newBar:CreateTexture(nil, "OVERLAY") + newBar.icone:SetWidth(CONST_TARGET_HEIGHT) + newBar.icone:SetHeight(CONST_TARGET_HEIGHT) + newBar.icone:SetPoint("RIGHT", newBar, "LEFT", 0, 0) + + CriaTexturaBarra(newBar) + + newBar:SetAlpha(ALPHA_BLEND_AMOUNT) + newBar.icone:SetAlpha(1) + + newBar.isAlvo = true + + SetBarraScripts(newBar, instance, index) + + info.barras2[index] = newBar --barra adicionada + + return newBar +end + +function gump:CriaNovaBarraInfo3(instance, index) --not used on this file, used on class damage, heal, etc + if (_detalhes.playerDetailWindow.barras3[index]) then + return + end + + local janela = info.container_detalhes + + local newBar = CreateFrame("button", "Details_infobox3_bar_" .. index, janela, "BackdropTemplate") + newBar:SetHeight(16) + + local y = (index-1) * 17 + y = y*-1 + + container3_bars_pointFunc(newBar, index) --what this fun does? + newBar:EnableMouse(true) + + --icon + newBar.icone = newBar:CreateTexture(nil, "OVERLAY") + newBar.icone:SetWidth(14) + newBar.icone:SetHeight(14) + newBar.icone:SetPoint("LEFT", newBar, "LEFT", 0, 0) + + CriaTexturaBarra(newBar) + + newBar:SetAlpha(0.9) + newBar.icone:SetAlpha(1) + + newBar.isDetalhe = true + + SetBarraScripts(newBar, instance, index) + + info.barras3[index] = newBar + + return newBar +end +--]=] + +----------------------------------------------------------------------------------------------------------------------- +--> report data + +function spellsTab.monta_relatorio(botao) + ---@type attributeid + local mainSection = breakdownWindow.atributo + ---@type attributeid + local subSection = breakdownWindow.sub_atributo + ---@type actor + local player = breakdownWindow.jogador + ---@type instance + local instance = breakdownWindow.instancia + ---@type number + local amt = _detalhes.report_lines + + local tabFrame = spellsTab.TabFrame + + if (not player) then + _detalhes:Msg("Player not found.") + return + end + + local report_lines + + if (botao == 1) then --spell data + if (mainSection == 1 and subSection == 4) then --friendly fire + report_lines = {"Details!: " .. player.nome .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_FRIENDLYFIRE"] .. ":"} + + elseif (mainSection == 1 and subSection == 3) then --damage taken + report_lines = {"Details!: " .. player.nome .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_TAKEN"] .. ":"} + + else + report_lines = {"Details!: " .. player.nome .. " - " .. _detalhes.sub_atributos [mainSection].lista [subSection] .. ""} + end + + for index, barra in ipairs(tabFrame.barras1) do + if (barra:IsShown()) then + local spellid = barra.show + if (mainSection == 1 and subSection == 4) then --friendly fire + report_lines [#report_lines+1] = barra.lineText1:GetText() .. ": " .. barra.lineText4:GetText() + + elseif (type(spellid) == "number" and spellid > 10) then + local link = GetSpellLink(spellid) + report_lines [#report_lines+1] = index .. ". " .. link .. ": " .. barra.lineText4:GetText() + else + local spellname = barra.lineText1:GetText():gsub((".*%."), "") + spellname = spellname:gsub("|c%x%x%x%x%x%x%x%x", "") + spellname = spellname:gsub("|r", "") + report_lines [#report_lines+1] = index .. ". " .. spellname .. ": " .. barra.lineText4:GetText() + end + end + + if (index == amt) then + break + end + end + + elseif (botao == 3) then --targets + if (mainSection == 1 and subSection == 3) then + print(Loc ["STRING_ACTORFRAME_NOTHING"]) + return + end + + report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTARGETS"] .. " " .. _detalhes.sub_atributos [1].lista [1] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome} + + for index, barra in ipairs(tabFrame.barras2) do + if (barra:IsShown()) then + report_lines[#report_lines+1] = barra.lineText1:GetText().. " -> " .. barra.lineText4:GetText() + end + if (index == amt) then + break + end + end + + elseif (botao == 2) then --spell blocks + --dano --damage done --dps --heal + if ((mainSection == 1 and (subSection == 1 or subSection == 2)) or (mainSection == 2)) then + if (not player.detalhes) then + print(Loc ["STRING_ACTORFRAME_NOTHING"]) + return + end + + local nome = _GetSpellInfo(player.detalhes) + + report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [mainSection].lista [subSection] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome, + Loc ["STRING_ACTORFRAME_SPELLDETAILS"] .. ": " .. nome} + + for i = 1, 5 do + local caixa = _detalhes.playerDetailWindow.grupos_detalhes[i] + if (caixa.bg:IsShown()) then + + local linha = "" + + local nome2 = caixa.nome2:GetText() --golpes + if (nome2 and nome2 ~= "") then + if (i == 1) then + linha = linha..nome2 .. " / " + else + linha = linha .. caixa.nome:GetText() .. " " .. nome2 .. " / " + end + end + + local dano = caixa.dano:GetText() --dano + if (dano and dano ~= "") then + linha = linha .. dano .. " / " + end + + local media = caixa.dano_media:GetText() --media + if (media and media ~= "") then + linha = linha..media .. " / " + end + + local dano_dps = caixa.dano_dps:GetText() + if (dano_dps and dano_dps ~= "") then + linha = linha..dano_dps.." / " + end + + local dano_porcento = caixa.dano_porcento:GetText() + if (dano_porcento and dano_porcento ~= "") then + linha = linha..dano_porcento.." " + end + + report_lines [#report_lines+1] = linha + end + + if (i == amt) then + break + end + end + + --dano --damage tanken + elseif ( (mainSection == 1 and subSection == 3) or mainSection == 3) then + if (player.detalhes) then + report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [1].lista [1] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.detalhes.. " " .. Loc ["STRING_ACTORFRAME_REPORTAT"] .. " " .. player.nome} + for index, barra in ipairs(tabFrame.barras3) do + if (barra:IsShown()) then + report_lines [#report_lines+1] = barra.lineText1:GetText() .. " ....... " .. barra.lineText4:GetText() + end + if (index == amt) then + break + end + end + else + report_lines = {} + end + end + + elseif (botao >= 11) then --primeira caixa dos detalhes + botao = botao - 10 + + local nome + if (type(spellid) == "string") then --unknown spellid value + --is a pet + else + nome = _GetSpellInfo(player.detalhes) + local spelllink = GetSpellLink(player.detalhes) + if (spelllink) then + nome = spelllink + end + end + + if (not nome) then + nome = "" + end + + report_lines = {"Details! " .. Loc ["STRING_ACTORFRAME_REPORTTO"] .. " " .. _detalhes.sub_atributos [mainSection].lista [subSection].. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] .. " " .. player.nome, + Loc ["STRING_ACTORFRAME_SPELLDETAILS"] .. ": " .. nome} + + local caixa = _detalhes.playerDetailWindow.grupos_detalhes[botao] + + local linha = "" + local nome2 = caixa.nome2:GetText() --golpes + if (nome2 and nome2 ~= "") then + if (botao == 1) then + linha = linha .. nome2 .. " / " + else + linha = linha .. caixa.nome:GetText() .. " " .. nome2 .. " / " + end + end + + local dano = caixa.dano:GetText() --dano + if (dano and dano ~= "") then + linha = linha..dano.." / " + end + + local media = caixa.dano_media:GetText() --media + if (media and media ~= "") then + linha = linha..media.." / " + end + + local dano_dps = caixa.dano_dps:GetText() + if (dano_dps and dano_dps ~= "") then + linha = linha..dano_dps.." / " + end + + local dano_porcento = caixa.dano_porcento:GetText() + if (dano_porcento and dano_porcento ~= "") then + linha = linha..dano_porcento.." " + end + + --remove a cor da school + linha = linha:gsub("|c%x?%x?%x?%x?%x?%x?%x?%x?", "") + linha = linha:gsub("|r", "") + + report_lines [#report_lines+1] = linha + end + + return instance:envia_relatorio(report_lines) +end + +----------------------------------------------------------------------------------------------------------------------- +--> create the new tab +function Details.InitializeSpellBreakdownTab() + local tabButton, tabFrame = Details:CreatePlayerDetailsTab( + "Summary", --[1] tab name + Loc ["STRING_SPELLS"], --[2] localized name + function(tabOBject, playerObject) --[3] condition + if (playerObject) then + return true + else + return false + end + end, + + function() --[4] fill function + --spellsTab.JI_AtualizaContainerBarras(-1) --not in use anymore + spellsTab.TabFrame.no_targets:Hide() --this is nil + spellsTab.TabFrame.no_targets.text:Hide() + + spellsTab.OnShownTab() + --spellsTab.TrocaBackgroundInfo(spellsTab.TabFrame) + end, + + function(tabButton, tabFrame) --[5] onclick + tabFrame:Show() + end, + + spellsTab.OnCreateTabCallback, --[6] oncreate + iconTableSummary, --[7] icon table + nil, --[8] replace tab + true --[9] is default tab + ) + + spellsTab.TabButton = tabButton + spellsTab.TabFrame = tabFrame + + ---on receive data from a class + ---@param data table + ---@param actorObject actor + ---@param combatObject combat + ---@param instance instance + function tabButton.OnReceiveSpellData(data, actorObject, combatObject, instance) + spellsTab.currentActor = actorObject + spellsTab.combatObject = combatObject + spellsTab.instance = instance + spellsTab.TabFrame.SpellScrollFrame:RefreshMe(data) + end +end + diff --git a/functions/mixin.lua b/functions/mixin.lua index ebf43b46..42a07392 100644 --- a/functions/mixin.lua +++ b/functions/mixin.lua @@ -4,7 +4,6 @@ local detailsFramework = _G.DetailsFramework local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0", true) local addonName, Details222 = ... - Details222.Mixins.ActorMixin = { ---return a spellContainer from an actor ---@param actor actor @@ -39,4 +38,138 @@ Details222.Mixins.ActorMixin = { return spellTable end end, -} \ No newline at end of file + + ---return a table containing pet names + ---@param actor actor + ---@return table + GetPets = function(actor) + return actor.pets + end, + + ---return a table containing spellTables + ---@param actor actor + ---@return table + GetSpellList = function(actor) + return actor.spells._ActorTable + end, + + ---this function sums all the targets of all spellTables conteining on a 'breakdownspelldata' + ---@param actor actor + ---@param bkSpellData breakdownspelldata + ---@param targetTableName string + ---@return table + BuildSpellTargetFromBreakdownSpellData = function(actor, bkSpellData, targetTableName) + targetTableName = targetTableName or "targets" + + local spellTables = bkSpellData.spellTables + + ---@type table store the index of the target name in the result table + local cacheIndex = {} + ---@type table store the result which is returned by this function + local result = {} + + for i = 1, #spellTables do + ---@type spelltable + local spellTable = spellTables[i] + ---@type table + local targets = spellTable[targetTableName] + + for targetName, value in pairs(targets) do + local index = cacheIndex[targetName] + if (index) then + result[index][2] = result[index][2] + value + else + result[#result+1] = {targetName, value} + cacheIndex[targetName] = #result + end + end + end + + table.sort(result, function(t1, t2) + return t1[2] > t2[2] + end) + + return result + end, + + ---this function receives a target table name and return a table containing the targets and the damage done in order of bigger to lower value + ---@param actor actor + ---@param spellTable spelltable + ---@param targetTableName string + ---@return table + BuildSpellTargetFromSpellTable = function(actor, spellTable, targetTableName) + targetTableName = targetTableName or "targets" + + ---@type table[] store the result which is returned by this function + local result = {} + + ---@type table + local targets = spellTable[targetTableName] + + for targetName, value in pairs(targets) do + ---@cast targetName string + ---@cast value number + result[#result+1] = {targetName, value} + end + + table.sort(result, function(t1, t2) + return t1[2] > t2[2] + end) + + return result + end, + + + +} + +--need to transfer the function bellow to another file + +--this are the fields from spellTable that can be summed +local spellTable_FieldsToSum = { + ["counter"] = true, + ["total"] = true, + ["c_amt"] = true, + ["c_min"] = true, + ["c_max"] = true, + ["c_dmg"] = true, + ["n_amt"] = true, + ["n_dmg"] = true, + ["n_min"] = true, + ["n_max"] = true, + ["successful_casted"] = true, + ["g_amt"] = true, + ["g_dmg"] = true, + ["r_amt"] = true, + ["r_dmg"] = true, + ["b_amt"] = true, + ["b_dmg"] = true, + ["a_amt"] = true, + ["a_dmg"] = true, +} + +---get the array of spelltables and sum each spellTable with the first spellTable found or on targetTable +---only sum the keys found in the spellTable_FieldsToSum table +---@param spellTables table[] +---@param targetTable table +function Details:SumSpellTables(spellTables, targetTable) + local amtSpellTables = #spellTables + + if (amtSpellTables == 0) then + return + end + + targetTable = targetTable or spellTables[1] + + for i = 1, amtSpellTables do + ---@type spelltable + local spellTable = spellTables[i] + if (spellTable) then + for key, value in pairs(spellTable) do + if (spellTable_FieldsToSum[key]) then + targetTable[key] = (targetTable[key] or 0) + value + end + end + end + end +end \ No newline at end of file diff --git a/functions/profiles.lua b/functions/profiles.lua index 3ad287bd..81d9e161 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1407,6 +1407,18 @@ local default_global_data = { }, }, + --breakdown spell tab + breakdown_spell_tab = { + blockcontainer_width = 430, + blockcontainer_height = 270, + blockspell_height = 50, + blockspellline_height = 13, + blockspell_spark_offset = -2, + blockspell_spark_width = 2, + blockspell_spark_show = true, + blockspell_spark_color = {1, 1, 1, 0.7}, + }, + --profile by spec profile_by_spec = {}, diff --git a/images/overlay_indicator_1.blp b/images/overlay_indicator_1.blp new file mode 100644 index 00000000..df711c37 Binary files /dev/null and b/images/overlay_indicator_1.blp differ diff --git a/images/overlay_indicator_2.tga b/images/overlay_indicator_2.tga new file mode 100644 index 00000000..addcc492 Binary files /dev/null and b/images/overlay_indicator_2.tga differ diff --git a/startup.lua b/startup.lua index e08fcd8e..b9450a2c 100644 --- a/startup.lua +++ b/startup.lua @@ -77,6 +77,8 @@ function Details:StartMeUp() Details:InitializePlaterIntegrationWindow() Details:InitializeMacrosWindow() + Details.InitializeSpellBreakdownTab() + if (Details.ocd_tracker.show_options) then Details:InitializeCDTrackerWindow() end