'/details users' major upgrade

- Stop showing the '/details users' panel again after the user closes the panel.
- Improvements on aura detection at the start and end of an encounter.
- Rewrite on Potion Used custom display.
This commit is contained in:
Tercio Jose
2019-10-19 15:09:10 -03:00
parent 4e8b13a2ef
commit f01394be98
5 changed files with 107 additions and 230 deletions
+5 -4
View File
File diff suppressed because one or more lines are too long
+68 -159
View File
@@ -1225,194 +1225,103 @@
desc = Loc ["STRING_CUSTOM_POT_DEFAULT_DESC"],
source = false,
target = false,
script_version = 5,
script_version = 6,
script = [[
--init:
local combat, instance_container, instance = ...
local total, top, amount = 0, 0, 0
--get the misc actor container
local misc_container = combat:GetActorList ( DETAILS_ATTRIBUTE_MISC )
--do the loop:
for _, player in ipairs ( misc_container ) do
--only player in group
if (player:IsGroupPlayer()) then
local found_potion = false
--get the spell debuff uptime container
local debuff_uptime_container = player.debuff_uptime and player.debuff_uptime_spells and player.debuff_uptime_spells._ActorTable
if (debuff_uptime_container) then
--potion of focus (can't use as pre-potion, so, its amount is always 1
local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID]
if (focus_potion) then
total = total + 1
found_potion = true
if (top < 1) then
top = 1
--only player in group
if (player:IsGroupPlayer()) then
local found_potion = false
--get the spell debuff uptime container
local debuff_uptime_container = player.debuff_uptime and player.debuff_uptime_spells and player.debuff_uptime_spells._ActorTable
if (debuff_uptime_container) then
--potion of focus (can't use as pre-potion, so, its amount is always 1
local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID]
if (focus_potion) then
total = total + 1
found_potion = true
if (top < 1) then
top = 1
end
--add amount to the player
instance_container:AddValue (player, 1)
end
end
--add amount to the player
instance_container:AddValue (player, 1)
end
--get the spell buff uptime container
local buff_uptime_container = player.buff_uptime and player.buff_uptime_spells and player.buff_uptime_spells._ActorTable
if (buff_uptime_container) then
for spellId, _ in pairs (DetailsFramework.PotionIDs) do
local potionUsed = buff_uptime_container [spellId]
if (potionUsed) then
local used = potionUsed.activedamt
if (used and used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
end
end
if (found_potion) then
amount = amount + 1
end
end
--get the spell buff uptime container
local buff_uptime_container = player.buff_uptime and player.buff_uptime_spells and player.buff_uptime_spells._ActorTable
if (buff_uptime_container) then
--potion of the jade serpent
local jade_serpent_potion = buff_uptime_container [DETAILS_INT_POTION_ID]
if (jade_serpent_potion) then
local used = jade_serpent_potion.activedamt
if (used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
--potion of mogu power
local mogu_power_potion = buff_uptime_container [DETAILS_STR_POTION_ID]
if (mogu_power_potion) then
local used = mogu_power_potion.activedamt
if (used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
--mana potion
local mana_potion = buff_uptime_container [DETAILS_MANA_POTION_ID]
if (mana_potion) then
local used = mana_potion.activedamt
if (used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
--potion of prolongued power
local prolongued_power = buff_uptime_container [DETAILS_AGI_POTION_ID]
if (prolongued_power) then
local used = prolongued_power.activedamt
if (used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
--potion of the mountains
local mountains_potion = buff_uptime_container [DETAILS_STAMINA_POTION_ID]
if (mountains_potion) then
local used = mountains_potion.activedamt
if (used > 0) then
total = total + used
found_potion = true
if (used > top) then
top = used
end
--add amount to the player
instance_container:AddValue (player, used)
end
end
end
if (found_potion) then
amount = amount + 1
end
end
end
--return:
return total, top, amount
]],
tooltip = [[
--init:
local player, combat, instance = ...
--get the debuff container for potion of focus
local debuff_uptime_container = player.debuff_uptime and player.debuff_uptime_spells and player.debuff_uptime_spells._ActorTable
if (debuff_uptime_container) then
local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID]
if (focus_potion) then
local focus_potion = debuff_uptime_container [DETAILS_FOCUS_POTION_ID]
if (focus_potion) then
local name, _, icon = GetSpellInfo (DETAILS_FOCUS_POTION_ID)
GameCooltip:AddLine (name, 1) --> can use only 1 focus potion (can't be pre-potion)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
end
end
--get the buff container for all the others potions
--get the misc actor container
local buff_uptime_container = player.buff_uptime and player.buff_uptime_spells and player.buff_uptime_spells._ActorTable
if (buff_uptime_container) then
--potion of the jade serpent
local jade_serpent_potion = buff_uptime_container [DETAILS_INT_POTION_ID]
if (jade_serpent_potion) then
local name, _, icon = GetSpellInfo (DETAILS_INT_POTION_ID)
GameCooltip:AddLine (name, jade_serpent_potion.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
--potion of mogu power
local mogu_power_potion = buff_uptime_container [DETAILS_STR_POTION_ID]
if (mogu_power_potion) then
local name, _, icon = GetSpellInfo (DETAILS_STR_POTION_ID)
GameCooltip:AddLine (name, mogu_power_potion.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
--mana potion
local mana_potion = buff_uptime_container [DETAILS_MANA_POTION_ID]
if (mana_potion) then
local name, _, icon = GetSpellInfo (DETAILS_MANA_POTION_ID)
GameCooltip:AddLine (name, mana_potion.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
--prolongued power
local prolongued_power = buff_uptime_container [DETAILS_AGI_POTION_ID]
if (prolongued_power) then
local name, _, icon = GetSpellInfo (DETAILS_AGI_POTION_ID)
GameCooltip:AddLine (name, prolongued_power.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
--potion of the mountains
local mountains_potion = buff_uptime_container [DETAILS_STAMINA_POTION_ID]
if (mountains_potion) then
local name, _, icon = GetSpellInfo (DETAILS_STAMINA_POTION_ID)
GameCooltip:AddLine (name, mountains_potion.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
for spellId, _ in pairs (DetailsFramework.PotionIDs) do
local potionUsed = buff_uptime_container [spellId]
if (potionUsed) then
local name, _, icon = GetSpellInfo (spellId)
GameCooltip:AddLine (name, potionUsed.activedamt)
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon (icon, 1, 1, _detalhes.tooltip.line_height, _detalhes.tooltip.line_height)
end
end
end
]]
]]
}
local have = false
+18 -58
View File
@@ -26,6 +26,8 @@ local _UnitAura = UnitAura
local _UnitGUID = UnitGUID
local _UnitName = UnitName
local UnitIsUnit = UnitIsUnit
local _string_replace = _detalhes.string.replace --details api
local _detalhes = _G._detalhes
@@ -1297,10 +1299,12 @@ function _detalhes:CatchRaidDebuffUptime (in_or_out) -- "DEBUFF_UPTIME_IN"
if (name and unitCaster) then
local playerGUID = _UnitGUID (unitCaster)
if (playerGUID) then
local playerName, realmName = _UnitName (unitCaster)
if (realmName and realmName ~= "") then
playerName = playerName .. "-" .. realmName
end
_detalhes.parser:add_debuff_uptime (nil, cacheGetTime, playerGUID, playerName, 0x00000417, his_target, _UnitName (target), 0x842, nil, spellid, name, in_or_out)
end
end
@@ -1378,12 +1382,14 @@ function _detalhes:CatchRaidDebuffUptime (in_or_out) -- "DEBUFF_UPTIME_IN"
end
end
--> this shouldn't be hardcoded
local runes_id = {
[175457] = true, -- focus
[175456] = true, --hyper
[175439] = true, --stout
}
--called from control on leave / enter combat
function _detalhes:CatchRaidBuffUptime (in_or_out)
if (_IsInRaid()) then
@@ -1407,11 +1413,14 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura (RaidIndex, buffIndex, nil, "HELPFUL")
if (name and unitCaster == RaidIndex) then
if (name and UnitIsUnit (unitCaster, RaidIndex)) then
_detalhes.parser:add_buff_uptime (nil, cacheGetTime, playerGUID, playerName, 0x00000514, playerGUID, playerName, 0x00000514, 0x0, spellid, name, in_or_out)
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
elseif (runes_id [spellid]) then
focus_augmentation [playerName] = true
end
@@ -1420,59 +1429,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
end
end
end
-- /run print (GetNumSubgroupMembers());for i=1,GetNumSubgroupMembers()do print (UnitName("party"..i))end
--> player sub group
for partyIndex = 1, _GetNumSubgroupMembers() do
local PartyIndex = "party" .. partyIndex
local playerGUID = _UnitGUID (PartyIndex)
if (playerGUID) then
local playerName, realmName = _UnitName (PartyIndex)
if (realmName and realmName ~= "") then
playerName = playerName .. "-" .. realmName
end
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura (PartyIndex, buffIndex, nil, "HELPFUL")
if (name and unitCaster == PartyIndex) then
_detalhes.parser:add_buff_uptime (nil, cacheGetTime, playerGUID, playerName, 0x00000514, playerGUID, playerName, 0x00000514, 0x0, spellid, name, in_or_out)
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
elseif (runes_id [spellid]) then
focus_augmentation [playerName] = true
end
end
end
end
end
end
--> unitCaster return player instead of raidIndex
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("player", buffIndex, nil, "HELPFUL")
if (name and unitCaster == "player") then
local playerName = _UnitName ("player")
local playerGUID = _UnitGUID ("player")
if (playerGUID) then
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
elseif (runes_id [spellid]) then
focus_augmentation [playerName] = true
end
end
_detalhes.parser:add_buff_uptime (nil, cacheGetTime, playerGUID, playerName, 0x00000514, playerGUID, playerName, 0x00000514, 0x0, spellid, name, in_or_out)
end
end
end
if (in_or_out == "BUFF_UPTIME_IN") then
local string_output = "pre-potion: " --> localize-me
@@ -1496,10 +1453,11 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
local pot_usage = {}
local focus_augmentation = {}
for groupIndex = 1, _GetNumGroupMembers()-1 do
--party members
for groupIndex = 1, _GetNumGroupMembers() - 1 do
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("party"..groupIndex, buffIndex, nil, "HELPFUL")
if (name and unitCaster == "party"..groupIndex) then
if (name and UnitIsUnit (unitCaster, "party" .. groupIndex)) then
local playerName, realmName = _UnitName ("party"..groupIndex)
local playerGUID = _UnitGUID ("party"..groupIndex)
@@ -1512,6 +1470,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
if (in_or_out == "BUFF_UPTIME_IN") then
if (_detalhes.PotionList [spellid]) then
pot_usage [playerName] = spellid
elseif (runes_id [spellid]) then
focus_augmentation [playerName] = true
end
@@ -1523,9 +1482,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
end
end
--player it self
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("player", buffIndex, nil, "HELPFUL")
if (name and unitCaster == "player") then
if (name and UnitIsUnit (unitCaster, "player")) then
local playerName = _UnitName ("player")
local playerGUID = _UnitGUID ("player")
if (playerGUID) then
@@ -1566,7 +1526,7 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
for buffIndex = 1, 41 do
local name, _, _, _, _, _, unitCaster, _, _, spellid = _UnitAura ("player", buffIndex, nil, "HELPFUL")
if (name and unitCaster == "player") then
if (name and UnitIsUnit (unitCaster, "player")) then
local playerName = _UnitName ("player")
local playerGUID = _UnitGUID ("player")
+2
View File
@@ -1904,6 +1904,7 @@
--> not yet well know about unnamed buff casters
if (not alvo_name) then
alvo_name = "[*] Unknown shield target"
elseif (not who_name) then
--> no actor name, use spell name instead
who_name = "[*] " .. spellname
@@ -1933,6 +1934,7 @@
if (who_name == alvo_name and raid_members_cache [who_serial] and _in_combat) then
--> call record buffs uptime
parser:add_buff_uptime (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, "BUFF_UPTIME_IN")
elseif (container_pets [who_serial] and container_pets [who_serial][2] == alvo_serial) then
--um pet colocando uma aura do dono
parser:add_buff_uptime (token, time, alvo_serial, alvo_name, alvo_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, "BUFF_UPTIME_IN")
+14 -9
View File
@@ -836,28 +836,28 @@ function SlashCmdList.DETAILS (msg, editbox)
Details.RefreshUserList()
end)
C_Timer.After (0.6, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (0.9, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (1.3, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (1.6, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (3, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (4, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (5, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
C_Timer.After (8, function()
Details.RefreshUserList()
Details.RefreshUserList (true)
end)
elseif (command == "names") then
@@ -1693,7 +1693,12 @@ Damage Update Status: @INSTANCEDAMAGESTATUS
end
end
function Details.RefreshUserList()
function Details.RefreshUserList (ignoreIfHidden)
if (ignoreIfHidden and DetailsUserPanel and not DetailsUserPanel:IsShown()) then
return
end
local newList = DetailsFramework.table.copy ({}, _detalhes.users or {})
table.sort (newList, function(t1, t2)