Time Machine overhaul

This commit is contained in:
Tercio Jose
2023-06-08 22:01:34 -03:00
parent fb724bed5c
commit 631b3ceaa0
10 changed files with 368 additions and 314 deletions
+29 -4
View File
@@ -1,10 +1,13 @@
---@alias spellschool number
---@class details
---@field SpellTableMixin spelltablemixin
---@field GetInstance fun(self: details) : instance
---@field GetWindow fun(self: details) : instance this is an alias of GetInstance
---@field GetCombat fun(self: details) : combat
---@field GetSpellSchoolFormatedName fun(self: details, spellschool: number) : string
---@field GetSpellSchoolFormatedName fun(self: details, spellschool: spellschool) : string
---@field CommaValue fun(self: details, number: number) : string
---@field CreateEventListener fun(self: details) : table
@@ -127,9 +130,11 @@
---@class actor : table
---@field owner actor
---@field tipo number the container type
---@field ownerName string name of the owner of the pet, a pet without an owner is considered an orphan and be suitable for garbage collection
---@field pets table<number, string>
---@field arena_enemy boolean if true the actor is an enemy in an arena match
---@field dps_started boolean if true the actor started to do damage or healing
---@field start_time unixtime when this actor started to be tracked
---@field end_time number when this actor stopped to be tracked, end_time - start_time is the activity time of the actor
---@field displayName string actor name shown in the regular window
@@ -154,6 +159,7 @@
---@field total_without_pet number
---@field total number
---@field targets targettable
---@field GetSpell fun(actor: actor, spellId: number) : spelltable
---@field BuildSpellTargetFromBreakdownSpellData fun(actor: actor, bkSpellData: spelltableadv) : table
---@field BuildSpellTargetFromSpellTable fun(actor: actor, spellTable: spelltable) : table
---@field raid_targets table<number, number>
@@ -363,9 +369,10 @@
---@field expandedIndex number
---@field bIsExpanded boolean
---@field statusBarValue number
---@field npcId npcid
---@field actorName string --when showing an actor header, this is the actor name
---@field bIsActorHeader boolean is this is true, the spellbar is an actor header, which is a bar with the actor name with the actor spells nested
---@field actorIcon texture
---@field bIsActorHeader boolean if this is true, the spellbar is an actor header, which is a bar with the actor name with the actor spells nested
---@field actorIcon textureid|texturepath
---@class bknesteddata : {spellId: number, spellTable: spelltable, actorName: string, value: number, bIsActorHeader: boolean} fills .nestedData table in spelltableadv, used to store the nested spells data, 'value' is set when the breakdown sort the values by the selected header
@@ -428,6 +435,14 @@
---@field TabFrame breakdownspellstab
---@field mainAttribute number
---@field subAttribute number
---@field TargetScrollFrame breakdowntargetscrollframe
---@field PhaseScrollFrame breakdownphasescrollframe
---@field GenericScrollFrame breakdowngenericscrollframe
---@field SpellContainerFrame df_framecontainer
---@field BlocksContainerFrame df_framecontainer
---@field TargetsContainerFrame df_framecontainer
---@field PhaseContainerFrame df_framecontainer
---@field GenericContainerFrame df_framecontainer
---@field GetActor fun() : actor
---@field GetCombat fun() : combat
---@field GetInstance fun() : instance
@@ -454,6 +469,16 @@
---@field CreateTargetBar fun(self: breakdowntargetscrollframe, index: number) : breakdowntargetbar
---@field CreateSpellBar fun(self: breakdownspellscrollframe, index: number) : breakdownspellbar
---@class timemachine : table
---@field Ticker fun() runs each second and check if actors are performing damage and healing actions, if the actor isn't, stop the activity time of that actor
---@field Start fun() start the time machine, called once from the start.lua
---@field Cleanup fun() check for actors with __destroyed flag and remove them from the time machine
---@field Restart fun() reset all data inside the time machine
---@field AddActor fun(actor: actor) add the actor to the time machine
---@field RemoveActor fun(actor: actor) remove the actor from the time machine
---@field StopTime fun(actor: actor) stop the time of the actor
---@field SetOrGetPauseState fun(actor: actor, bPause: boolean|nil) : boolean|nil set or get the pause state of the actor, if bPause is nil, then it will return the current pause state
---@class details222 : table
---@field TimeMachine timemachine
+103 -33
View File
@@ -4,7 +4,100 @@
--size: corresponds to the height and height of an object, it is measure in pixels, must be bigger than zero.
--scale: the size of an object is multiplied by this value, it is measure in percentage, must be between 0.65 and 2.40.
--alpha: corresponds to the transparency of an object, the bigger is the value less transparent is the object, it is measure in percentage, must be between 0 and 1, zero is fully transparent and one is fully opaque.
--controller: abstract term to define who's in control of an entity, can be the server or a player.
--npc: an entity shown in the 3d world with a name and a health bar, can be friendly or hostile, can be interacted with, always controlled by the server.
--player: is an entity that represents a player character, the controller is always player.
--pet: represents a npc controlled by the server and can accept commands from the player.
--guadians: represents a npc, the server has the possess of the controller, don't accept commands like pets, helps attacking the enemies of the npc or player.
--role: is a string that represents the role of a unit, such as tank, healer, or damage dealer. only players can have a role.
---@alias role
---| "TANK"
---| "HEALER"
---| "DAMAGER"
---| "NONE"
---@alias anchorpoint
---| "topleft"
---| "topright"
---| "bottomleft"
---| "bottomright"
---| "top"
---| "bottom"
---| "left"
---| "right"
---| "center"
---@alias framestrata
---| "background"
---| "low"
---| "medium"
---| "high"
---| "dialog"
---| "fullscreen"
---| "fullscreen_dialog"
---| "tooltip"
---| "BACKGROUND"
---| "LOW"
---| "MEDIUM"
---| "HIGH"
---| "DIALOG"
---| "FULLSCREEN"
---| "FULLSCREEN_DIALOG"
---| "TOOLTIP"
---@alias sizingpoint
---| "top"
---| "topright"
---| "right"
---| "bottomright"
---| "bottom"
---| "bottomleft"
---| "left"
---| "topleft"
---@alias drawlayer
---| "background"
---| "border"
---| "artwork"
---| "overlay"
---| "highlight"
---@alias buttontype
---| "AnyUp"
---| "AnyDown"
---| "LeftButtonDown"
---| "LeftButtonUp"
---| "MiddleButtonUp"
---| "MiddleButtonDown"
---| "RightButtonDown"
---| "RightButtonUp"
---| "Button4Up"
---| "Button4Down"
---| "Button5Up"
---| "Button5Down"
---@alias width number property that represents the horizontal size of a UI element, such as a frame or a texture. Gotten from the first result of GetWidth() or from the first result of GetSize(). It is expected a GetWidth() or GetSize() when the type 'height' is used.
---@alias height number property that represents the vertical size of a UI element, such as a frame or a texture. Gotten from the first result of GetHeight() or from the second result of GetSize(). It is expected a GetHeight() or GetSize() when the type 'height' is used.
---@alias red number color value representing the red component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@alias green number color value representing the green component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@alias blue number color value representing the blue component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@alias alpha number @number(0-1.0) value representing the alpha (transparency) of a UIObject, the value must be between 0 and 1. 0 is fully transparent, 1 is fully opaque.
---@alias unit string string that represents a unit in the game, such as the player, a party member, or a raid member.
---@alias health number amount of hit points (health) of a unit. This value can be changed by taking damage or healing.
---@alias spellid number each spell in the game has a unique spell id, this id can be used to identify a spell.
---@alias actorname string name of a unit
---@alias spellname string name of a spell
---@alias actorid string unique id of a unit (GUID)
---@alias serial string unique id of a unit (GUID)
---@alias 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)
---@alias 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.
---@alias 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.
---@alias event string is a notification that is sent to a frame when something happens, such as a button click or a frame update. Events can be used to trigger scripts.
---@alias backdrop table @table(bgFile: string, edgeFile: string, tile: edgeSize: number, backgroundColor: color, borderColor: color) is a table that contains information about the backdrop of a frame. The backdrop is the background of a frame, which can be a solid color, a gradient, or a texture.
---@alias npcid number a number that identifies a specific npc in the game.
---@alias textureid number each texture from the game client has an id.
---@alias texturepath string access textures from addons.
---@class _G
---@field RegisterAttributeDriver fun(statedriver: frame, attribute: string, conditional: string)
@@ -34,29 +127,6 @@
---@class objectsize : {height: number, width: number}
---@class texturetable : {texture: string, coords: texturecoords, size: objectsize}
---@class spellid : number
---@class actorname : string
---@class spellname : string
---@class actorid : string
---@class red : number color value representing the red component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@class green : number color value representing the green component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@class blue : number color value representing the blue component of a color, the value must be between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@class alpha : number @number(0-1.0) value representing the alpha (transparency) of a UIObject, the value must be between 0 and 1. 0 is fully transparent, 1 is fully opaque.
---@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. Gotten from the first result of GetWidth() or from the first result of GetSize(). It is expected a GetWidth() or GetSize() when the type 'width' is used.
---@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. Gotten from the first result of GetHeight() or from the second result of GetSize(). It is expected a GetHeight() or GetSize() when the type 'height' is used.
---@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.
---@class event : string is a notification that is sent to a frame when something happens, such as a button click or a frame update. Events can be used to trigger scripts.
---@class framestrata : string @string(BACKGROUND, LOW, MEDIUM, HIGH, DIALOG, FULLSCREEN, FULLSCREEN_DIALOG, TOOLTIP) property that determines the stacking order of frames. Higher strata values indicate frames that should be displayed on top of frames with lower strata values.
---@class backdrop : table @table(bgFile: string, edgeFile: string, tile: edgeSize: number, backgroundColor: color, borderColor: color) is a table that contains information about the backdrop of a frame. The backdrop is the background of a frame, which can be a solid color, a gradient, or a texture.
---@class unit : string string that represents a unit in the game, such as the player, a party member, or a raid member.
---@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 point : string @string(topleft, topright, bottomleft, bottomright, top, bottom, left, right, center) is a string that represents a point on a frame. Points are used to position frames relative to each other.
---@class uiobject
---@field GetObjectType fun(self: uiobject) : string
---@field Show fun(self: uiobject) make the object be shown on the user screen
@@ -78,7 +148,7 @@
---@field GetParent fun(self: uiobject) : frame
---@field GetPoint fun(self: uiobject, index: number): string, frame, string, number, number
---@field GetCenter fun(self: uiobject): 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 SetPoint fun(self: uiobject, point: anchorpoint, relativeFrame: uiobject, relativePoint: anchorpoint, xOffset: number, yOffset: number)
---@field ClearAllPoints fun(self: uiobject)
---@field CreateAnimationGroup fun(self: uiobject, name: string|nil, templateName: string|nil) : animationgroup
@@ -128,7 +198,7 @@
---@field SetAttribute fun(self: frame, name: string, value: any)
---@field SetScript fun(self: frame, event: string, handler: function|nil)
---@field GetScript fun(self: frame, event: string) : function
---@field SetFrameStrata fun(self: frame, strata: framestrata|"background"|"low"|"medium"|"high"|"dialog"|"fullscreen"|"fullscreen_dialog"|"tooltip")
---@field SetFrameStrata fun(self: frame, strata: framestrata)
---@field SetFrameLevel fun(self: frame, level: number)
---@field SetClampedToScreen fun(self: frame, clamped: boolean)
---@field SetClampRectInsets fun(self: frame, left: number, right: number, top: number, bottom: number)
@@ -143,19 +213,19 @@
---@field SetPropagateGamepadInput fun(self: frame, propagate: boolean)
---@field StartMoving fun(self: frame)
---@field IsMovable fun(self: frame) : boolean
---@field StartSizing fun(self: frame, point: "top"|"topright"|"right"|"bottomright"|"bottom"|"bottomleft"|"left"|"topleft")
---@field StartSizing fun(self: frame, sizingpoint: sizingpoint|nil)
---@field StopMovingOrSizing fun(self: frame)
---@field GetAttribute fun(self: frame, name: string) : any
---@field GetFrameLevel fun(self: frame) : number
---@field GetFrameStrata fun(self: frame) : framestrata|string
---@field GetFrameStrata fun(self: frame) : framestrata
---@field GetNumChildren fun(self: frame) : number
---@field GetNumPoints fun(self: frame) : number
---@field GetNumRegions fun(self: frame) : number
---@field GetName 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: "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 CreateTexture fun(self: frame, name: string|nil, layer: drawlayer, inherits: string|nil, subLayer: number|nil) : texture
---@field CreateFontString fun(self: frame, name: string|nil, layer: drawlayer, inherits: string|nil, subLayer: number|nil) : fontstring
---@field EnableMouse fun(self: frame, enable: boolean)
---@field SetResizable fun(self: frame, enable: boolean)
---@field EnableMouseWheel fun(self: frame, enable: boolean)
@@ -183,7 +253,7 @@
---@field GetFontString fun(self: button) : fontstring
---@field SetButtonState fun(self: button, state: string, enable: boolean)
---@field GetButtonState fun(self: button, state: string) : boolean
---@field RegisterForClicks fun(self: button, button1: nil|"AnyUp"|"AnyDown"|"LeftButtonDown"|"LeftButtonUp"|"MiddleButtonUp"|"MiddleButtonDown"|"RightButtonDown"|"RightButtonUp"|"Button4Up"|"Button4Down"|"Button5Up"|"Button5Down", button2: nil|"AnyUp"|"AnyDown"|"LeftButtonDown"|"LeftButtonUp"|"MiddleButtonUp"|"MiddleButtonDown"|"RightButtonDown"|"RightButtonUp"|"Button4Up"|"Button4Down"|"Button5Up"|"Button5Down")
---@field RegisterForClicks fun(self: button, button1: nil|buttontype, button2: nil|buttontype, button3: nil|buttontype, button4: nil|buttontype)
---@field GetNormalTexture fun(self: button) : texture
---@field GetPushedTexture fun(self: button) : texture
---@field GetHighlightTexture fun(self: button) : texture
@@ -191,7 +261,7 @@
---@class statusbar : frame
---@field SetStatusBarColor fun(self: statusbar, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetStatusBarTexture fun(self: statusbar, path: string)
---@field SetStatusBarTexture fun(self: statusbar, path: string|texture)
---@field GetStatusBarTexture fun(self: statusbar) : texture
---@field SetMinMaxValues fun(self: statusbar, minValue: number, maxValue: number)
---@field SetValue fun(self: statusbar, value: number)
@@ -217,7 +287,7 @@
---@class region : uiobject
---@class fontstring : region
---@field SetDrawLayer fun(self: fontstring, layer: "background"|"border"|"artwork"|"overlay"|"highlight", subLayer: number|nil)
---@field SetDrawLayer fun(self: fontstring, layer: drawlayer, subLayer: number|nil)
---@field SetFont fun(self: fontstring, font: string, size: number, flags: string)
---@field SetText fun(self: fontstring, text: string|number)
---@field GetText fun(self: fontstring) : string
@@ -264,7 +334,7 @@
---@field GetTextTruncateLines fun(self: fontstring) : number
---@class texture : region
---@field SetDrawLayer fun(self: texture, layer: "background"|"border"|"artwork"|"overlay"|"highlight", subLayer: number|nil)
---@field SetDrawLayer fun(self: texture, layer: drawlayer, subLayer: number|nil)
---@field SetTexture fun(self: texture, path: string)
---@field SetAtlas fun(self: texture, atlas: string)
---@field SetColorTexture fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number|nil)
+4 -4
View File
@@ -732,8 +732,8 @@ end
if (self [1]) then
for _, jogador in ipairs(self [1]._ActorTable) do --damage
if (jogador:Iniciar()) then -- retorna se ele esta com o dps ativo
jogador:TerminarTempo()
jogador:Iniciar (false) --trava o dps do jogador
Details222.TimeMachine.StopTime(jogador)
jogador:Iniciar(false) --lock the actor timer
else
if (jogador.start_time == 0) then
jogador.start_time = _tempo
@@ -747,8 +747,8 @@ end
if (self [2]) then
for _, jogador in ipairs(self [2]._ActorTable) do --healing
if (jogador:Iniciar()) then -- retorna se ele esta com o dps ativo
jogador:TerminarTempo()
jogador:Iniciar (false) --trava o dps do jogador
Details222.TimeMachine.StopTime(jogador)
jogador:Iniciar(false) --lock the actor timer
else
if (jogador.start_time == 0) then
jogador.start_time = _tempo
+5 -2
View File
@@ -4618,6 +4618,7 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel
local bkSpellData = {
bIsActorHeader = true, --tag this spelltable as an actor header, when the actor is the header it will nest the spells use by this actor
actorName = petName,
npcId = petActor.aID,
id = 0,
spellschool = 0,
bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(petName),
@@ -4670,6 +4671,8 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel
---@type spelltableadv
local bkSpellData = {
id = spellId,
actorName = petName,
npcId = petActor.aID,
spellschool = spellTable.spellschool,
bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId),
bCanExpand = false,
@@ -6146,10 +6149,10 @@ function damageClass:Iniciar (iniciar)
return self.dps_started --retorna se o dps esta aberto ou fechado para este jogador
elseif (iniciar) then
self.dps_started = true
self:RegistrarNaTimeMachine() --coloca ele da timeMachine
Details222.TimeMachine.AddActor(self)
else
self.dps_started = false
self:DesregistrarNaTimeMachine() --retira ele da timeMachine
Details222.TimeMachine.RemoveActor(self)
end
end
+3 -2
View File
@@ -2071,6 +2071,7 @@ function healingClass:MontaInfoHealingDone()
---@type spelltableadv
local bkSpellData = {
id = spellId,
actorName = petName,
spellschool = spellTable.spellschool,
expanded = Details222.BreakdownWindow.IsSpellExpanded(spellId),
bCanExpand = false,
@@ -2772,10 +2773,10 @@ function healingClass:Iniciar (iniciar)
return self.iniciar_hps --retorna se o dps esta aberto ou fechado para este jogador
elseif (iniciar) then
self.iniciar_hps = true
self:RegistrarNaTimeMachine() --coloca ele da timeMachine
Details222.TimeMachine.AddActor(self)
else
self.iniciar_hps = false
self:DesregistrarNaTimeMachine() --retira ele da timeMachine
Details222.TimeMachine.RemoveActor(self)
end
end
+9 -29
View File
@@ -309,22 +309,14 @@ function segmentClass:AddCombat(combatObject)
---@cast actorObject actor
--clear last events table
actorObject.last_events_table = nil
--unregister from time machine
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in containerHeal:ListActors() do
---@cast actorObject actor
--clear last events table
actorObject.last_events_table = nil
--unregister from time machine
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
if (Details.trash_auto_remove) then
@@ -335,14 +327,10 @@ function segmentClass:AddCombat(combatObject)
if ((thirdCombat.is_trash and not thirdCombat.is_boss) or(thirdCombat.is_temporary)) then
--verify again the time machine
for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
--remove
@@ -403,14 +391,10 @@ function segmentClass:AddCombat(combatObject)
--check time machine
for _, actorObject in combatObjectToBeRemoved:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in combatObjectToBeRemoved:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do
if (actorObject.timeMachine) then
actorObject:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(actorObject)
end
--remove it
@@ -553,7 +537,7 @@ function segmentClass:ResetAllCombatData()
Details:Destroy(Details.cache_healing_group)
--reinicia a time machine
timeMachine:Reiniciar()
Details222.TimeMachine.Restart()
Details:UpdateParserGears()
if (not InCombatLockdown() and not UnitAffectingCombat("player")) then
@@ -605,14 +589,10 @@ end
--verificar novamente a time machine
for _, jogador in ipairs(_terceiro_combate [1]._ActorTable) do --damage
if (jogador.timeMachine) then
jogador:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(jogador)
end
for _, jogador in ipairs(_terceiro_combate [2]._ActorTable) do --heal
if (jogador.timeMachine) then
jogador:DesregistrarNaTimeMachine()
end
Details222.TimeMachine.RemoveActor(jogador)
end
--remover
_table_remove(self.tabelas, 3)
+5 -3
View File
@@ -512,6 +512,7 @@ local classTypeUtility = Details.atributos.misc
Details:DestroyActor(actorObject, actorContainer, overallCombatObject)
end
end
actorContainer:Cleanup()
end
end
@@ -532,6 +533,7 @@ local classTypeUtility = Details.atributos.misc
end
end
end
actorContainer:Cleanup()
end
end
@@ -591,6 +593,7 @@ local classTypeUtility = Details.atributos.misc
end
end
end
actorContainer:Cleanup()
end
end
@@ -690,8 +693,6 @@ local classTypeUtility = Details.atributos.misc
Details:InstanciaCallFunction(Details.reset_window)
end
Details:TimeMachineMaintenance()
--cleanup backlisted pets within the handler of actor containers
Details:PetContainerCleanup()
Details:ClearCCPetsBlackList()
@@ -761,7 +762,7 @@ local classTypeUtility = Details.atributos.misc
if (canCollect) then
amountCleaned = amountCleaned + 1
if (containerId == 1 or containerId == 2) then --damage or healing
Details.timeMachine:UnregisterActor(actorObject)
Details222.TimeMachine.RemoveActor(actorObject)
end
--remove the actor from the container
Details:DestroyActor(actorObject, actorContainer, combatObject)
@@ -782,6 +783,7 @@ local classTypeUtility = Details.atributos.misc
orphansCleaned = orphansCleaned + 1
end
end
actorContainer:Cleanup()
end
-2
View File
@@ -2268,7 +2268,6 @@
if (ownerActor.end_time) then
ownerActor.end_time = nil
else
--meu_dono:IniciarTempo (_tempo)
ownerActor.start_time = _tempo
end
end
@@ -2276,7 +2275,6 @@
if (sourceActor.end_time) then --o combate terminou, reabrir o tempo
sourceActor.end_time = nil
else
--este_jogador:IniciarTempo (_tempo)
sourceActor.start_time = _tempo
end
end
+208 -233
View File
@@ -1,274 +1,249 @@
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local _detalhes = _G.Details
local _tempo = time()
local addonName, Details222 = ...
local Details = _G.Details
local _
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--local pointers
local ipairs = ipairs
local _time = _G.time
local tinsert = table.insert --lua local
local ipairs = ipairs --lua local
local pairs = pairs --lua local
local _math_floor = math.floor --lua local
local _time = time --lua local
local GetTime = GetTime --api local
local timeMachine = _detalhes.timeMachine --details local
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local timeMachine = Details.timeMachine
local _tempo = _time()
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--core
timeMachine.ligada = false
timeMachine.bIsEnabled = false
local calc_for_pvp = function(self)
for tipo, tabela in pairs(self.tabelas) do
for nome, jogador in ipairs(tabela) do
if (jogador) then
if (jogador.last_event+3 > _tempo) then --okey o jogador esta dando dps
if (jogador.on_hold) then --o dps estava pausado, retornar a ativa
jogador:HoldOn (false)
end
else
if (not jogador.on_hold) then --no ta pausado, precisa por em pausa
--verifica se esta castando alguma coisa que leve + que 3 segundos
jogador:HoldOn (true)
end
end
local calculateTimeFor_PvP = function(self)
for attributeType, thisDatabase in ipairs(self.playerDatabase) do
for actorObject in pairs(thisDatabase) do
if (not actorObject.last_event) then
print("actor without last event, is destroyed?", actorObject.__destroyed, actorObject.__destroyedBy)
end
end
end
end
local calc_for_pve = function(self)
for tipo, tabela in pairs(self.tabelas) do
for nome, jogador in ipairs(tabela) do
if (jogador) then
if (jogador.last_event+10 > _tempo) then --okey o jogador esta dando dps
if (jogador.on_hold) then --o dps estava pausado, retornar a ativa
jogador:HoldOn (false)
end
else
if (not jogador.on_hold) then --no ta pausado, precisa por em pausa
--verifica se esta castando alguma coisa que leve + que 10 segundos
jogador:HoldOn (true)
end
if (actorObject.last_event + 3 > _tempo) then
if (actorObject.on_hold) then --the timer is on pause, turn it on
Details222.TimeMachine.SetOrGetPauseState(actorObject, false)
end
end
end
end
end
function timeMachine:Core()
_tempo = _time()
_detalhes._tempo = _tempo
_detalhes:UpdateGears()
if (_detalhes.is_in_battleground or _detalhes.is_in_arena) then
return calc_for_pvp (self)
else
return calc_for_pve (self)
end
end
function timeMachine:TurnOn()
return timeMachine:Ligar()
end
function timeMachine:Ligar()
self.atualizador = self:ScheduleRepeatingTimer ("Core", 1)
self.ligada = true
self.tabelas = {{}, {}} --1 dano 2 cura
local danos = _detalhes.tabela_vigente[1]._ActorTable
for _, jogador in ipairs(danos) do
if (jogador.dps_started) then
jogador:RegistrarNaTimeMachine()
end
end
end
function timeMachine:TurnOff()
return timeMachine:Desligar()
end
function timeMachine:Desligar()
self.ligada = false
self.tabelas = nil
if (self.atualizador) then
self:CancelTimer(self.atualizador)
self.atualizador = nil
end
end
function timeMachine:Reiniciar()
Details:Destroy(self.tabelas[1])
Details:Destroy(self.tabelas[2])
self.tabelas = {{}, {}} --1 dano 2 cura
end
function timeMachine:UnregisterActor(actorObject)
return actorObject:DesregistrarNaTimeMachine()
end
function _detalhes:DesregistrarNaTimeMachine()
if (not timeMachine.ligada) then
return
end
local timeMachineContainer = timeMachine.tabelas [self.tipo]
local actorTimeMachineID = self.timeMachine
if (timeMachineContainer [actorTimeMachineID] == self) then
self:TerminarTempo()
self.timeMachine = nil
timeMachineContainer [actorTimeMachineID] = false
end
end
function _detalhes:RegistrarNaTimeMachine()
if (not timeMachine.ligada) then
return
end
local esta_tabela = timeMachine.tabelas [self.tipo]
tinsert(esta_tabela, self)
self.timeMachine = #esta_tabela
end
function Details:TimeMachineMaintenance()
for tipo, tabela in ipairs(timeMachine.tabelas) do
local t = {}
local removed = 0
for index, jogador in ipairs(tabela) do
if (jogador) then
t [#t+1] = jogador
jogador.timeMachine = #t
else
removed = removed + 1
if (not actorObject.on_hold) then --not in pause, need to pause
--check if the player is casting something that takes more than 3 seconds
Details222.TimeMachine.SetOrGetPauseState(actorObject, true)
end
end
end
timeMachine.tabelas [tipo] = t
if (_detalhes.debug) then
--_detalhes:Msg("timemachine r"..removed.."| e"..#t.."| t"..tipo)
end
end
end
function _detalhes:Tempo()
local calculateTimeFor_PvE = function(self)
for attributeType, thisDatabase in ipairs(self.playerDatabase) do
for actorObject in pairs(thisDatabase) do
if (not actorObject.last_event) then
print("actor without last event, is destroyed?", actorObject.__destroyed, actorObject.__destroyedBy)
end
if (actorObject.last_event + 10 > _tempo) then
if (actorObject.on_hold) then --the timer is on pause, turn it on
Details222.TimeMachine.SetOrGetPauseState(actorObject, false)
end
else
if (not actorObject.on_hold) then --not in pause, need to pause
--check if the player is casting something that takes more than 3 seconds
Details222.TimeMachine.SetOrGetPauseState(actorObject, true)
end
end
end
end
end
function Details222.TimeMachine.Ticker()
_tempo = _time()
Details._tempo = _tempo
Details:UpdateGears()
if (Details.is_in_battleground or Details.is_in_arena) then
return calculateTimeFor_PvP(timeMachine)
else
return calculateTimeFor_PvE(timeMachine)
end
end
function Details222.TimeMachine.Start()
timeMachine.updateTicker = Details.Schedules.NewTicker(1, Details222.TimeMachine.Ticker)
timeMachine.bIsEnabled = true
---@type table<actor, boolean>
local storeDamageActors = setmetatable({}, Details.weaktable)
---@type table<actor, boolean>
local storeHealingActors = setmetatable({}, Details.weaktable)
---@type {key1: table<actor, boolean>, key2: table<actor, boolean>}
timeMachine.playerDatabase = {
storeDamageActors, --store damage actors
storeHealingActors --store healing actors
}
---@type combat
local currentCombat = Details:GetCurrentCombat()
---@type actorcontainer
local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
for _, actorObject in damageContainer:ListActors() do
---@cast actorObject actor
if (actorObject.dps_started) then
Details222.TimeMachine.AddActor(actorObject)
end
end
end
---remove actors with __destroyed flag
function Details222.TimeMachine.Cleanup()
for attributeType, thisDatabase in ipairs(timeMachine.playerDatabase) do
for actorObject in pairs(thisDatabase) do
if (actorObject.__destroyed) then
thisDatabase[actorObject] = nil
end
end
end
end
function Details222.TimeMachine.Restart()
Details:Destroy(timeMachine.playerDatabase[1])
Details:Destroy(timeMachine.playerDatabase[2])
---@type table<actor, boolean>
local storeDamageActors = setmetatable({}, Details.weaktable)
---@type table<actor, boolean>
local storeHealingActors = setmetatable({}, Details.weaktable)
---@type {key1: table<actor, boolean>, key2: table<actor, boolean>}
timeMachine.playerDatabase = {
storeDamageActors, --store damage actors
storeHealingActors --store healing actors
}
end
---@param actorObject actor
function Details222.TimeMachine.RemoveActor(actorObject)
local thisDatabase = timeMachine.playerDatabase[actorObject.tipo]
--check if the database exists, the type could be wrong due to passing an resource or utility actor
if (thisDatabase) then
if (thisDatabase[actorObject]) then
thisDatabase[actorObject] = nil
end
end
end
function Details222.TimeMachine.AddActor(actorObject)
local thisDatabase = timeMachine.playerDatabase[actorObject.tipo]
if (thisDatabase) then
thisDatabase[actorObject] = true
end
end
function Details222.TimeMachine.StopTime(actorObject)
if (actorObject.end_time) then
return
end
if (actorObject.on_hold) then
Details222.TimeMachine.SetOrGetPauseState(actorObject, false)
end
actorObject.end_time = _tempo
end
---get the pause state or pause/unpause the timer of the player
---@param actorObject actor
---@param bIsPaused boolean|nil
function Details222.TimeMachine.SetOrGetPauseState(actorObject, bIsPaused)
if (bIsPaused == nil) then
return actorObject.on_hold --return if the timer is paused or not
elseif (bIsPaused) then --if true - pause the timer
if (not actorObject.last_event) then
print("actor without last event, is destroyed?", actorObject.__destroyed, actorObject.__destroyedBy)
end
actorObject.delay = math.floor(actorObject.last_event) --_tempo - 10
if (actorObject.delay < actorObject.start_time) then
actorObject.delay = actorObject.start_time
end
actorObject.on_hold = true
else --if false - unpause the timer
local diff = _tempo - actorObject.delay - 1
if (diff > 0) then
actorObject.start_time = actorObject.start_time + diff
end
actorObject.on_hold = false
end
end
---@param self actor
function Details:Tempo()
if (self.pvp) then
--pvp timer
if (self.end_time) then --o tempo do jogador esta trancado
local t = self.end_time - self.start_time
if (t < 3) then
t = 3
if (self.end_time) then --the timer of the player is locked
local timer = self.end_time - self.start_time
if (timer < 3) then
timer = 3
end
return t
elseif (self.on_hold) then --o tempo esta em pausa
local t = self.delay - self.start_time
if (t < 3) then
t = 3
return timer
elseif (self.on_hold) then --the timer is paused
local timer = self.delay - self.start_time
if (timer < 3) then
timer = 3
end
return t
return timer
else
if (self.start_time == 0) then
return 3
end
local t = _tempo - self.start_time
if (t < 3) then
if (_detalhes.in_combat) then
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
local timer = _tempo - self.start_time
if (timer < 3) then
if (Details.in_combat) then
local combat_time = Details.tabela_vigente:GetCombatTime()
if (combat_time < 3) then
return combat_time
end
end
t = 3
timer = 3
end
return t
return timer
end
else
--pve timer
if (self.end_time) then --o tempo do jogador esta trancado
local t = self.end_time - self.start_time
if (t < 10) then
t = 10
if (self.end_time) then --the timer of the player is locked
local timer = self.end_time - self.start_time
if (timer < 10) then
timer = 10
end
return t
elseif (self.on_hold) then --o tempo esta em pausa
local t = self.delay - self.start_time
if (t < 10) then
t = 10
return timer
elseif (self.on_hold) then --the timer is paused
local timer = self.delay - self.start_time
if (timer < 10) then
timer = 10
end
return t
return timer
else
if (self.start_time == 0) then
return 10
end
local t = _tempo - self.start_time
if (t < 10) then
if (_detalhes.in_combat) then
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
if (combat_time < 10) then
return combat_time
local timer = _tempo - self.start_time
if (timer < 10) then
if (Details.in_combat) then
---@type combat
local currentCombat = Details:GetCurrentCombat()
local combatTime = currentCombat:GetCombatTime()
if (combatTime < 10) then
return combatTime
end
end
t = 10
timer = 10
end
return t
return timer
end
end
end
function _detalhes:IniciarTempo (tempo)
self.start_time = tempo
end
function _detalhes:TerminarTempo()
if (self.end_time) then
return
end
if (self.on_hold) then
self:HoldOn (false)
end
self.end_time = _tempo
end
--diz se o dps deste jogador esta em pausa
function _detalhes:HoldOn (pausa)
if (pausa == nil) then
return self.on_hold --retorna se o dps esta aberto ou fechado para este jogador
elseif (pausa) then --true - colocar como inativo
self.delay = _math_floor(self.last_event) --_tempo - 10
if (self.delay < self.start_time) then
self.delay = self.start_time
end
self.on_hold = true
else --false - retornar a atividade
local diff = _tempo - self.delay - 1
if (diff > 0) then
self.start_time = self.start_time + diff
end
--if (_tempo - self.start_time < 20) then
-- self.start_time = self.start_time - 1
--end
self.on_hold = false
end
end
function _detalhes:PrintTimeMachineIndexes()
print("timemachine damage", #timeMachine.tabelas [1])
print("timemachine heal", #timeMachine.tabelas [2])
end
end
+2 -2
View File
@@ -41,7 +41,7 @@ function Details:StartMeUp()
--healing, hps, overheal, healing taken
Details.row_singleclick_overwrite[2] = {true, true, true, true, false, Details.atributo_heal.ReportSingleDamagePreventedLine}
--mana, rage, energy, runepower
Details.row_singleclick_overwrite[3] = {true, true, true, true}
Details.row_singleclick_overwrite[3] = {true, true, true, true} --missing other resources and alternate power
--cc breaks, ress, interrupts, dispells, deaths
Details.row_singleclick_overwrite[4] = {true, true, true, true, Details.atributo_misc.ReportSingleDeadLine, Details.atributo_misc.ReportSingleCooldownLine, Details.atributo_misc.ReportSingleBuffUptimeLine, Details.atributo_misc.ReportSingleDebuffUptimeLine}
@@ -113,7 +113,7 @@ function Details:StartMeUp()
Details:GetLowerInstanceNumber()
--start time machine
Details.timeMachine:TurnOn()
Details222.TimeMachine.Start()
--update abbreviation shortcut
Details.atributo_damage:UpdateSelectedToKFunction()