- Added te first batch of API 2.0 (file functions/api2.lua)

This commit is contained in:
Tercioo
2019-03-23 19:35:49 -03:00
parent 020bb1bcda
commit 625b1124bd
5 changed files with 536 additions and 71 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
local dversion = 145
local dversion = 146
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
+21
View File
@@ -2204,6 +2204,24 @@ function DF:ShowPromptPanel (message, func_true, func_false)
end
end)
f.ShowAnimation = DF:CreateAnimationHub (f, function()
f:SetBackdropBorderColor (0, 0, 0, 0)
f.TitleBar:SetBackdropBorderColor (0, 0, 0, 0)
end, function()
f:SetBackdropBorderColor (0, 0, 0, 1)
f.TitleBar:SetBackdropBorderColor (0, 0, 0, 1)
end)
DF:CreateAnimation (f.ShowAnimation, "scale", 1, .075, .2, .2, 1.1, 1.1, "center", 0, 0)
DF:CreateAnimation (f.ShowAnimation, "scale", 2, .075, 1, 1, .90, .90, "center", 0, 0)
f.FlashTexture = f:CreateTexture (nil, "overlay")
f.FlashTexture:SetColorTexture (1, 1, 1, 1)
f.FlashTexture:SetAllPoints()
f.FlashAnimation = DF:CreateAnimationHub (f.FlashTexture, function() f.FlashTexture:Show() end, function() f.FlashTexture:Hide() end)
DF:CreateAnimation (f.FlashAnimation, "alpha", 1, .075, 0, .25)
DF:CreateAnimation (f.FlashAnimation, "alpha", 2, .075, .35, 0)
f:Hide()
DF.promtp_panel = f
end
@@ -2215,6 +2233,9 @@ function DF:ShowPromptPanel (message, func_true, func_false)
DF.promtp_panel.button_false.false_function = func_false
DF.promtp_panel:Show()
DF.promtp_panel.ShowAnimation:Play()
DF.promtp_panel.FlashAnimation:Play()
end
+14 -18
View File
File diff suppressed because one or more lines are too long
+479 -52
View File
@@ -12,9 +12,9 @@ local getCombatObject = function (segmentNumber)
local combatObject
--select which segment to use, use low level variables for performance
if (segment == -1) then
if (segmentNumber == -1) then
combatObject = _detalhes.tabela_overall
elseif (segment == 0) then
elseif (segmentNumber == 0) then
combatObject = _detalhes.tabela_vigente
else
combatObject = _detalhes.tabela_historico.tabelas [segment]
@@ -28,37 +28,46 @@ local getActorObjectFromCombat = function (combatObject, containerID, actorName)
return combatObject [containerID]._ActorTable [index]
end
local getUnitName = function (unitId)
local unitName, serverName = UnitName (unitId)
if (unitName) then
if (serverName and serverName ~= "") then
return unitName .. "-" .. serverName
else
return unitName
end
else
return unitId
end
end
--api
Details.API_Description = {}
--[=[
Details:GetPlayerDamage ( playerName, segment = 0 )
returns the damage of player or npc, must pass the full player name (with realm name if the player is from a different realm), pet names must have the owner name.
Details.SegmentElapsedTime (segment)
--=]=]
Details.API_Description.GetPlayerDamage = {
desc = "Returns the damage of player or npc, must pass the full player name (with realm name if the player is from a different realm), pet names must have the owner name.",
Details.API_Description.SegmentElapsedTime = {
desc = "Return the total elapsed time of a segment.",
parameters = {
{
name = "playerName",
desc = "Name of the player, pet, npc. Must be the exactly name with realm included if the player isn't from the same server as you.",
},
{
name = "segment",
type = "number",
desc = "Which segment to retrive the player damage, default value is current segment. Use -1 for overall data or value from 1 to 25 for other segments.",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "playerDamage",
name = "segmentElapsedTime",
type = "number",
desc = "Number (float) representing the player damage.",
desc = "Number representing the elapsed time of a combat.",
}
},
}
function Details.GetPlayerDamage (playerName, segment)
function Details.SegmentElapsedTime (segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
@@ -66,47 +75,38 @@ function Details.GetPlayerDamage (playerName, segment)
return 0
end
local playerObject = getActorObjectFromCombat (combatObject, 1, playerName)
if (not playerObject) then
return 0
end
return playerObject.total or 0
return combatObject:GetCombatTime()
end
--[=[
Details:GetPlayerDamageOnUnit ( playerName, unitName, segment = 0 )
returns the damage of player or npc in a specific target
Details.UnitDamage (unitId, segment)
--=]=]
Details.API_Description.GetPlayerDamageOnUnit = {
desc = "Returns the damage of player or npc in a specific target.",
Details.API_Description.UnitDamage = {
desc = "Query the damage of a unit.",
parameters = {
{
name = "playerName",
desc = "Name of the player, pet, npc. Must be the exactly name with realm included if the player isn't from the same server as you.",
},
{
name = "unitName",
desc = "Name of the unit target.",
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "segment",
type = "number",
desc = "Which segment to retrive the player damage, default value is current segment. Use -1 for overall data or value from 1 to 25 for other segments.",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "damageOnTarget",
name = "unitDamage",
type = "number",
desc = "Number (float) representing the player damage on the unit target.",
desc = "Number representing the unit damage.",
}
},
}
function Details.GetPlayerDamageOnUnit (playerName, unitName, segment)
function Details.UnitDamage (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
@@ -114,45 +114,472 @@ function Details.GetPlayerDamageOnUnit (playerName, unitName, segment)
return 0
end
local playerObject = getActorObjectFromCombat (combatObject, 1, playerName)
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
return playerObject.targets [unitName] or 0
return floor (playerObject.total or 0)
end
--[=[
Details.UnitSpellDamage (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitSpellDamage = {
desc = "Query the total damage done of a spell casted by the unit.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "spellId",
type = "number",
desc = "Id of a spell to query the damage done. Accept spell names.",
required = true,
},
{
name = "segment",
default = "0",
type = "number",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "unitSpellDamage",
type = "number",
desc = "Number representing the spell damage done.",
}
},
}
function Details.UnitSpellDamage (unitId, spellId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
if (type (spellId) == "string") then
local newSpellId = select (7, GetSpellInfo (spellId))
if (not newSpellId) then
local passedSpellName = spellId:lower()
for damageSpellId, spellInfo in pairs (playerObject.spells._ActorTable) do
local spellName = GetSpellInfo (damageSpellId)
if (spellName:lower() == passedSpellName) then
spellId = damageSpellId
break
end
end
else
spellId = newSpellId
end
end
local spell = playerObject.spells._ActorTable [spellId]
return spell and spell.total or 0
end
--[=[
Details.UnitSpells (unitId, segment)
--=]=]
Details.API_Description.UnitSpells = {
desc = "Return a numeric table with spells IDs used by the unit.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "unitSpellDamage",
type = "number",
desc = "Number representing the spell damage done.",
}
},
}
function Details.UnitSpells (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return {}
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return {}
end
local unitSpells = playerObject.spells._ActorTable
local resultTable = {}
for spellId, spellObject in pairs (unitSpells) do
resultTable [#resultTable + 1] = spellId
end
return resultTable
end
--[=[
Details.UnitDamageTaken (unitId, segment)
--=]=]
Details.API_Description.UnitDamageTaken = {
desc = "Query the unit damage taken.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "unitDamageTaken",
type = "number",
desc = "Number representing the damage taken by the unit.",
}
},
}
function Details.UnitDamageTaken (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
return playerObject.damage_taken
end
--[=[
Details.UnitDamageOnUnit (unitId, targetUnitId, segment)
--=]=]
Details.API_Description.UnitDamageOnUnit = {
desc = "Query the unit damage done on another unit.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "targetUnitId",
type = "string",
desc = "Name or ID of an unit, example: 'Thrall', 'Jaina', 'player', 'target', 'raid5'.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "unitDamageOnUnit",
type = "number",
desc = "Number representing the damage done by the unit on the target unit.",
}
},
}
function Details.UnitDamageOnUnit (unitId, targetUnitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
local targetName = getUnitName (targetUnitId)
return playerObject.targets [targetName] or 0
end
--[=[
Details.UnitDamageTakenFromSpell (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitDamageTakenFromSpell = {
desc = "Query the unit damage taken from a spell.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "spellId",
type = "number",
desc = "Id of a spell to query its damage to an unit. Accept spell names.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "unitDamageTakenFromSpell",
type = "number",
desc = "Number representing the damage taken by the unit from a spell.",
}
},
}
function Details.UnitDamageTakenFromSpell (unitId, spellId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local damageContainer = combatObject:GetContainer (DETAILS_ATTRIBUTE_DAMAGE)
local totalDamageTaken = 0
local spellName = GetSpellInfo (spellId) or spellId
for i = 1, #damageContainer._ActorTable do
local playerObject = damageContainer._ActorTable [i]
local unitSpells = playerObject.spells._ActorTable
for spellId, spellObject in pairs (unitSpells) do
local thisSpellName = GetSpellInfo (spellId)
if (thisSpellName == spellName) then
totalDamageTaken = totalDamageTaken + (spellObject.targets [unitName] or 0)
end
end
end
return totalDamageTaken
end
--[=[
Details.UnitDamageInfo (unitId, segment)
--=]=]
Details.API_Description.UnitDamageInfo = {
desc = "Return a table with damage information.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "damageInfo",
type = "table",
desc = "Table containing damage information, keys are: .total, .totalWithoutPet, .damageAbsorbed, .damageTaken, .friendlyFire and .activityTime",
}
},
}
function Details.UnitDamageInfo (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local damageInfo = {
total = 0,
totalWithoutPet = 0,
damageAbsorbed = 0,
damageTaken = 0,
friendlyFire = 0,
activityTime = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return damageInfo
end
damageInfo.total = floor (playerObject.total)
damageInfo.totalWithoutPet = floor (playerObject.total_without_pet)
damageInfo.damageAbsorbed = floor (playerObject.totalabsorbed)
damageInfo.damageTaken = floor (playerObject.damage_taken)
damageInfo.friendlyFire = playerObject.friendlyfire_total
damageInfo.activityTime = playerObject:Tempo()
return damageInfo
end
--[=[
Details.UnitSpellInfo (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitSpellInfo = {
desc = "Return a table with the spell damage information.",
parameters = {
{
name = "unitId",
type = "string",
desc = "The ID of an unit, example: 'player', 'target', 'raid5'. Accept unit names.",
required = true,
},
{
name = "spellId",
type = "number",
desc = "Id of a spell to query its damage to an unit. Accept spell names.",
required = true,
},
{
name = "segment",
type = "number",
default = "0",
desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.",
},
},
returnValues = {
{
name = "spellDamageInfo",
type = "table",
desc = "Table containing damage information, keys are: '.total', '.spellId', '.count', '.name', '.casted', '.regularMin', '.regularMax', '.regularAmount', '.regularDamage', '.criticalMin', '.criticalMax', '.criticalAmount', '.criticalDamage'",
}
},
}
function Details.UnitSpellInfo (unitId, spellId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local spellInfo = {
total = 0,
spellId = 0,
count = 0,
name = "",
casted = 0,
regularMin = 0,
regularMax = 0,
regularAmount = 0,
regularDamage = 0,
criticalMin = 0,
criticalMax = 0,
criticalAmount = 0,
criticalDamage = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return spellInfo
end
local miscPlayerObject = getActorObjectFromCombat (combatObject, 4, unitName)
local spellName = GetSpellInfo (spellId) or spellId
local spellObject
for thisSpellId, thisSpellObject in pairs (playerObject.spells._ActorTable) do
local thisSpellName = GetSpellInfo (thisSpellId)
if (thisSpellName == spellName) then
spellObject = thisSpellObject
spellId = thisSpellId
if (miscPlayerObject) then
local castedAmount = miscPlayerObject.spell_cast and miscPlayerObject.spell_cast [spellId]
if (castedAmount) then
spellInfo.casted = castedAmount
else
for castedSpellId, castedAmount in pairs (miscPlayerObject.spell_cast) do
local castedSpellName = GetSpellInfo (castedSpellId)
if (castedSpellName == spellName) then
spellInfo.casted = castedAmount
end
end
end
end
break
end
end
spellInfo.total = spellObject.total
spellInfo.count = spellObject.counter
spellInfo.spellId = spellId
spellInfo.name = spellName
spellInfo.regularMin = spellObject.n_min
spellInfo.regularMax = spellObject.n_max
spellInfo.regularAmount = spellObject.n_amt
spellInfo.regularDamage = spellObject.n_dmg
spellInfo.criticalMin = spellObject.c_min
spellInfo.criticalMax = spellObject.c_max
spellInfo.criticalAmount = spellObject.c_amt
spellInfo.criticalDamage = spellObject.c_dmg
--[=[
return spellInfo
end
--=]=]
--[=[
--=]=]
--stop auto complete: doo ende endp elsez
+21
View File
@@ -42,6 +42,27 @@ function Details:GetCombatFromBreakdownWindow()
return info.instancia and info.instancia.showing
end
--return the window that requested to open the player breakdown window
function Details:GetActiveWindowFromBreakdownWindow()
return info.instancia
end
--return if the breakdown window is showing damage or heal
function Details:GetDisplayTypeFromBreakdownWindow()
return info.atributo, info.sub_atributo
end
--return the actor object in use by the breakdown window
function Details:GetPlayerObjectFromBreakdownWindow()
return info.jogador
end
--english alias
--window object from Details:GetWindow(n) and playerObject from Details:GetPlayer(playerName, attribute)
function Details:OpenPlayerBreakdown (windowObject, playerObject)
windowObject:AbreJanelaInfo (playerObject)
end
function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDown, ControlKeyDown)
--print (debugstack())