- Major tooltip redesign now using cooltip.

- Details now support !Nicktag
- Fixed a bug were instances with same attribute were not updating.
- Schedule internal garbage collect if in encounter combat.
- More functions and better communication for Cloud Capture.
- New API _detalhes:FindGUIDFromName (name)
- Added new options for limit number of instances which can be opened.
- New options for custom nickname and avatar.
This commit is contained in:
Tercio
2013-08-27 19:43:46 -03:00
parent efb86a52c0
commit 4bde2e7c5a
24 changed files with 1057 additions and 305 deletions
+120 -42
View File
@@ -150,7 +150,7 @@
function _detalhes:EntrarEmCombate (...)
if (_detalhes.debug) then
print ("Details started a new combat.")
_detalhes:Msg ("(debug) started a new combat.")
end
--> não tem historico, addon foi resetado, a primeira tabela é descartada -- Erase first table is does not have a firts segment history, this occour after reset or first run
@@ -207,17 +207,17 @@
if (not _detalhes:CaptureIsAllEnabled()) then
_detalhes:SendCloudRequest()
if (_detalhes.debug) then
_detalhes:Msg ("Details: CloudRequest()")
_detalhes:Msg ("(debug) requesting a cloud server.")
end
end
else
if (_detalhes.debug) then
_detalhes:Msg ("Details: instance", _detalhes:IsInInstance())
_detalhes:Msg ("(debug) isn't inside a registred instance", _detalhes:IsInInstance())
end
end
else
if (_detalhes.debug) then
_detalhes:Msg ("Details: group and cloud", _detalhes.in_group, _detalhes.cloud_capture)
_detalhes:Msg ("(debug) isn't in group or cloud is turned off", _detalhes.in_group, _detalhes.cloud_capture)
end
end
@@ -234,19 +234,20 @@
end
if (_detalhes.debug) then
print ("Details ended a combat.")
_detalhes:Msg ("(debug) ended a combat.")
end
if (not _detalhes.tabela_vigente.is_boss) then
local inimigo = _detalhes:FindEnemy()
if (inimigo) then
if (_detalhes.debug) then
print ("Details last fight against: " .. inimigo)
_detalhes:Msg ("(debug) enemy recognized", inimigo)
end
end
_detalhes.tabela_vigente.enemy = inimigo
if (_detalhes.debug) then
_detalhes:EqualizeActorsSchedule()
_detalhes:Msg ("(debug) forcing equalize actors behavior.")
_detalhes:EqualizeActorsSchedule (_detalhes.host_of)
end
else
@@ -256,7 +257,7 @@
_detalhes:CaptureSet (false, "heal", false, 30)
if (_detalhes.debug) then
print ("Details found a boss on last fight, freezing parser for 30 seconds.")
_detalhes:Msg ("(debug) found encounter on last fight, freezing parser for 30 seconds.")
end
local bossFunction, bossFunctionType = _detalhes:GetBossFunction (_detalhes.tabela_vigente.is_boss.mapid, _detalhes.tabela_vigente.is_boss.index)
@@ -266,10 +267,12 @@
end
end
_detalhes:EqualizeActorsSchedule()
_detalhes:EqualizeActorsSchedule (_detalhes.host_of)
_detalhes:IniciarColetaDeLixo (true)
else
if (_detalhes.debug) then
_detalhes:EqualizeActorsSchedule()
_detalhes:EqualizeActorsSchedule (_detalhes.host_of)
end
end
end
@@ -301,7 +304,7 @@
local tempo_do_combate = _detalhes.tabela_vigente.end_time - _detalhes.tabela_vigente.start_time
--if ( tempo_do_combate >= _detalhes.minimum_combat_time) then --> tempo minimo precisa ser 5 segundos pra acrecentar a tabela ao historico
if ( tempo_do_combate >= 10) then --> tempo minimo precisa ser 5 segundos pra acrecentar a tabela ao historico
if ( tempo_do_combate >= 5) then --> tempo minimo precisa ser 5 segundos pra acrecentar a tabela ao historico
_detalhes.tabela_historico:adicionar (_detalhes.tabela_vigente) --move a tabela atual para dentro do histórico
else
--> this is a little bit complicated, need a specific function for combat cancellation
@@ -367,14 +370,47 @@
function _detalhes:MakeEqualizeOnActor (player, realm, receivedActor)
local combat = _detalhes:GetCombat ("current")
local damage, heal, energy, misc = _detalhes:GetAllActors ("current", player)
if (not damage and not heal) then
--> add server name
if (not damage and not heal and not energy and not misc) then
--> try adding server name
damage, heal, energy, misc = _detalhes:GetAllActors ("current", player.."-"..realm)
if (not damage and not heal and not energy and not misc) then
--> not found any actor object, so we need to create
local actorName
if (realm ~= GetRealmName()) then
actorName = player.."-"..realm
else
actorName = player
end
local guid = _detalhes:FindGUIDFromName (player)
-- 0x512 normal party
-- 0x514 normal raid
if (guid) then
damage = combat [1]:PegarCombatente (guid, actorName, 0x514, true)
heal = combat [2]:PegarCombatente (guid, actorName, 0x514, true)
energy = combat [3]:PegarCombatente (guid, actorName, 0x514, true)
misc = combat [4]:PegarCombatente (guid, actorName, 0x514, true)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) equalize received actor:", actorName, damage, heal)
end
else
if (_detalhes.debug) then
_detalhes:Msg ("(debug) equalize couldn't get guid for player ",player)
end
end
end
end
local combat = _detalhes:GetCombat ("current")
combat[1].need_refresh = true
combat[2].need_refresh = true
combat[3].need_refresh = true
@@ -429,7 +465,7 @@
end
end
function _detalhes:EqualizeActorsSchedule()
function _detalhes:EqualizeActorsSchedule (host_of)
--> check for pets without owner
for _, actor in _ipairs (_detalhes.tabela_vigente[1]._ActorTable) do
--> have flag and the flag tell us he is a pet
@@ -440,12 +476,21 @@
end
end
end
_detalhes:ScheduleTimer ("EqualizeActors", 2)
--> do not equilize if there is any disabled capture
if (_detalhes:CaptureIsAllEnabled()) then
_detalhes:ScheduleTimer ("EqualizeActors", 2, host_of)
end
end
function _detalhes:EqualizeActors()
function _detalhes:EqualizeActors (host_of)
local damage, heal, energy, misc = _detalhes:GetAllActors ("current", UnitName ("player"))
local damage, heal, energy, misc
if (host_of) then
damage, heal, energy, misc = _detalhes:GetAllActors ("current", host_of)
else
damage, heal, energy, misc = _detalhes:GetAllActors ("current", UnitName ("player"))
end
if (damage) then
damage = {damage.total, damage.damage_taken, damage.friendlyfire_total}
@@ -472,8 +517,13 @@
end
local data = {damage, heal, energy, misc}
_detalhes:SendRaidData ("equalize_actors", data)
if (host_of) then
_detalhes:SendCustomRaidData ("equalize_actors", host_of, nil, data)
_detalhes:EqualizeActors()
else
_detalhes:SendRaidData ("equalize_actors", data)
end
end
@@ -526,23 +576,51 @@
end
--> tooltip fork
function _detalhes:MontaTooltip (qual_barra)
local avatarPoint = {"bottomleft", "topleft", -3, -4}
local backgroundPoint = {{"bottomleft", "topleft", 0, -3}, {"bottomright", "topright", 0, -3}}
local textPoint = {"left", "right", -11, -5}
function _detalhes:MontaTooltip (frame, qual_barra)
GameCooltip:Reset()
GameCooltip:SetType ("tooltip")
GameCooltip:SetOption ("LeftBorderSize", -5)
GameCooltip:SetOption ("RightBorderSize", 5)
GameCooltip:SetOption ("StatusBarTexture", [[Interface\WorldStateFrame\WORLDSTATEFINALSCORE-HIGHLIGHT]]) --[[Interface\Addons\Details\images\bar_flat]]
GameCooltip:SetOwner (frame)
local esta_barra = self.barras [qual_barra] --> barra que o mouse passou em cima e irá mostrar o tooltip
local objeto = esta_barra.minha_tabela --> pega a referencia da tabela --> retorna a classe_damage ou classe_heal
if (not objeto) then --> a barra não possui um objeto
return false
end
_detalhes.popup:Close()
--verifica por tooltips especiais:
if (objeto.dead) then --> é uma barra de dead
return _detalhes:ToolTipDead (self, objeto, esta_barra) --> instância, [morte], barra
end
return objeto:ToolTip (self, qual_barra, esta_barra) --> instância, nº barra, objeto barra
local t = objeto:ToolTip (self, qual_barra, esta_barra) --> instância, nº barra, objeto barra
if (t) then
if (esta_barra.minha_tabela.serial and esta_barra.minha_tabela.serial ~= "") then
local avatar = NickTag:GetNicknameTable (esta_barra.minha_tabela.serial)
if (avatar) then
GameCooltip:SetBannerImage (1, avatar [2], 80, 40, avatarPoint, nil, nil) --> overlay [2] avatar path
--local l, r, t, b = unpack (avatar [5])
--local r, g, b = unpack (avatar [6])
GameCooltip:SetBannerImage (2, avatar [4], 200, 55, backgroundPoint, avatar [5], avatar [6]) --> background
GameCooltip:SetBannerText (1, avatar [1], textPoint) --> text [1] nickname
end
end
return GameCooltip:ShowCooltip()
end
end
function _detalhes.gump:UpdateTooltip (qual_barra, esta_barra, instancia)
return instancia:MontaTooltip (esta_barra, qual_barra)
end
function _detalhes:EndRefresh (instancia, total, tabela_do_combate, showing)
_detalhes:EsconderBarrasNaoUsadas (instancia, showing)
@@ -576,8 +654,8 @@
if (not tabela_do_combate[self.atributo].need_refresh and not forcar) then
return --> não precisa de refresh
else
tabela_do_combate[self.atributo].need_refresh = false
--else
--tabela_do_combate[self.atributo].need_refresh = false
end
if (self.atributo == 1) then --> damage
@@ -603,27 +681,27 @@
end
if (instancia == -1) then
local refresh_poll = {}
for _, esta_instancia in _ipairs (_detalhes.tabela_instancias) do
--> update
for index, esta_instancia in _ipairs (_detalhes.tabela_instancias) do
if (esta_instancia.ativa) then
if (esta_instancia.modo == modo_GROUP or esta_instancia.modo == modo_ALL) then
local atributo = esta_instancia:AtualizarALL (forcar)
if (atributo) then
refresh_poll [#refresh_poll+1] = atributo
esta_instancia:AtualizarALL (forcar)
end
end
end
--> marcar que não precisa ser atualizada
for index, esta_instancia in _ipairs (_detalhes.tabela_instancias) do
if (esta_instancia.ativa and esta_instancia.showing) then
if (esta_instancia.modo == modo_GROUP or esta_instancia.modo == modo_ALL) then
if (esta_instancia.atributo <= 4) then
esta_instancia.showing [esta_instancia.atributo].need_refresh = false
end
end
end
end
for _, atributo in _ipairs (refresh_poll) do
atributo.need_refresh = false
end
if (not forcar) then --atualizar o gump de detalhes também se ele estiver aberto
if (info.ativo) then
return info.jogador:MontaInfo()
+19 -9
View File
@@ -681,15 +681,25 @@
function _detalhes:IniciarColetaDeLixo()
function _detalhes:IniciarColetaDeLixo (forcar)
if (_detalhes.ultima_coleta + _detalhes.intervalo_coleta > _detalhes._tempo + 1) then
return
elseif (_detalhes.in_combat or _InCombatLockdown() or _detalhes:IsInInstance()) then
_detalhes:ScheduleTimer ("IniciarColetaDeLixo", 5)
return
if (not forcar) then
if (_detalhes.ultima_coleta + _detalhes.intervalo_coleta > _detalhes._tempo + 1) then
return
elseif (_detalhes.in_combat or _InCombatLockdown() or _detalhes:IsInInstance()) then
_detalhes:ScheduleTimer ("IniciarColetaDeLixo", 5)
return
end
end
if (_detalhes.debug) then
if (forcar) then
_detalhes:Msg ("collecting garbage with forced state.")
else
_detalhes:Msg ("collecting garbage.")
end
end
_detalhes:ClearParserCache()
local limpados = atributo_damage:ColetarLixo() + atributo_heal:ColetarLixo() + atributo_energy:ColetarLixo() + atributo_misc:ColetarLixo()
@@ -797,7 +807,7 @@
local conteudo = _overall_combat [tipo]._ActorTable
_iter = {index = 1, data = conteudo[1], cleaned = 0} --> ._ActorTable[1] para pegar o primeiro index
collectgarbage()
--collectgarbage()
while (_iter.data) do
@@ -817,9 +827,9 @@
_table_wipe (meus_links)
end
if (tipo == 1 and #new_weak_table > 0) then
--if (tipo == 1 and #new_weak_table > 0) then
-- print (can_garbage, _actor.nome)
end
--end
if (can_garbage or not meus_links) then --> não há referências a este objeto
+30 -18
View File
@@ -39,7 +39,7 @@
local type, player, realm, dversion, arg6, arg7 = select (2, _detalhes:Deserialize (data))
if (_detalhes.debug) then
print ("comm received", type)
_detalhes:Msg ("(debug) network received command", type)
end
if (type == "highfive") then
@@ -59,7 +59,7 @@
local ownerActor = _detalhes.tabela_vigente[1]:PegarCombatente (owner_table[2], owner_table[1], owner_table[3], true)
ownerActor.total = ownerActor.total + petActor.total
if (_detalhes.debug) then
_detalhes:Msg ("Received owner for pet ",nome, "assigned to", owner_table[1])
_detalhes:Msg ("(debug) received owner for pet ",nome, "assigned to", owner_table[1])
end
local combat = _detalhes:GetCombat ("current")
@@ -82,7 +82,7 @@
player = player .."-"..realm
end
if (_detalhes.debug) then
_detalhes:Msg ("Received pet owner request of pet, sending owner")
_detalhes:Msg ("(debug) received pet owner request, sending owner")
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize ("petowner", petserial, petnome, owner_table), "WHISPER", player)
end
@@ -109,12 +109,12 @@
nname = nname.."-"..server
end
if (nname == name) then
actor = container:PegarCombatente (UnitGUID ("raid"..i), name, 0x00000417, true)
actor = container:PegarCombatente (UnitGUID ("raid"..i), name, 0x514, true)
break
end
else
if (UnitName ("raid"..i) == name) then
actor = container:PegarCombatente (UnitGUID ("raid"..i), name, 0x00000417, true)
actor = container:PegarCombatente (UnitGUID ("raid"..i), name, 0x514, true)
break
end
end
@@ -128,12 +128,12 @@
nname = nname.."-"..server
end
if (nname == name) then
actor = container:PegarCombatente (UnitGUID ("party"..i), name, 0x00000417, true)
actor = container:PegarCombatente (UnitGUID ("party"..i), name, 0x514, true)
break
end
else
if (UnitName ("party"..i) == name or _detalhes.playername == name) then
actor = container:PegarCombatente (UnitGUID ("party"..i), name, 0x00000417, true)
actor = container:PegarCombatente (UnitGUID ("party"..i), name, 0x514, true)
break
end
end
@@ -146,7 +146,7 @@
container.need_refresh = true
else
if (_detalhes.debug) then
print ("Actor not found on cloud data received", name, atributo_name)
_detalhes:Msg ("(debug) actor not found on cloud data received", name, atributo_name)
end
end
@@ -177,17 +177,13 @@
end
if (data) then
local export = temp
local container = _detalhes.tabela_vigente [atributo]._ActorTable
for i = 1, math.min (6, #container) do
local actor = container [i]
if (not actor.grupo) then
break
if (actor.grupo) then
export [#export+1] = {actor.nome, actor [atributo_name]}
end
export [#export+1] = {actor.nome, actor [atributo_name]}
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize ("clouddatareceived", atributo, atributo_name, export), "WHISPER", _detalhes.host_of)
@@ -206,7 +202,7 @@
_detalhes.host_by = player
if (_detalhes.debug) then
print ("Details found a cloud for disabled captures.")
_detalhes:Msg ("(debug) cloud found for disabled captures.")
end
_detalhes.cloud_process = _detalhes:ScheduleRepeatingTimer ("RequestData", 7)
@@ -243,6 +239,22 @@
_detalhes:RegisterComm ("details_comm", "RaidComm")
function _detalhes:SendCustomRaidData (type, player, realm, ...)
if (not realm) then
--> check if realm is already inside player name
for _name, _realm in string.gmatch (player, "(%w+)-(%w+)") do
if (_realm) then
player = _name
realm = _realm
end
end
end
if (not realm) then
--> doesn't have realm at all, so we assume the actor is in same realm as player
realm = GetRealmName()
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, player, realm, _detalhes.realversion, ...), "RAID")
end
function _detalhes:SendRaidData (type, ...)
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize (type, UnitName ("player"), GetRealmName(), _detalhes.realversion, ...), "RAID")
end
@@ -256,7 +268,7 @@
function _detalhes:SendPetOwnerRequest (petserial, petnome)
if (_detalhes.debug) then
_detalhes:Msg ("Sent request for a pet",petserial, petnome)
_detalhes:Msg ("(debug) sent request for a pet",petserial, petnome)
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize ("needpetowner", UnitName ("player"), GetRealmName(), _detalhes.realversion, petserial, petnome), "RAID")
end
@@ -271,7 +283,7 @@
end
_detalhes.host_of = player
if (_detalhes.debug) then
_detalhes:Msg ("Sent request for a cloud parser")
_detalhes:Msg ("(debug) sent 'okey' answer for a cloud parser request.")
end
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize ("foundcloud", UnitName ("player"), GetRealmName(), _detalhes.realversion), "WHISPER", player)
end
@@ -282,7 +294,7 @@
for index = 1, #_detalhes.tabela_instancias do
local instancia = _detalhes.tabela_instancias [index]
if (instancia.ativa) then
if (instancia.ativa and _detalhes.host_by) then
local atributo = instancia.atributo
if (atributo == 1 and not _detalhes:CaptureGet ("damage")) then
_detalhes:SendCommMessage ("details_comm", _detalhes:Serialize ("clouddatarequest", atributo, instancia.sub_atributo), "WHISPER", _detalhes.host_by)
+7 -2
View File
@@ -113,7 +113,7 @@
------------------------------------------------------------------------------------------------
--> early checks and fixes
if (who_serial == "0x0000000000000000") then
if (who_flags and _bit_band (who_flags, OBJECT_TYPE_PETS) ~= 0) then --> é um pet
--> pets must have an serial
@@ -1934,21 +1934,26 @@
return
elseif (evento == "GROUP_ROSTER_UPDATE") then
_detalhes.container_pets:BuscarPets()
if (not _detalhes.in_group) then
_detalhes.in_group = IsInGroup() or IsInRaid()
if (_detalhes.in_group) then
--> entrou num grupo
_detalhes:IniciarColetaDeLixo (true)
_detalhes:SendHighFive()
end
else
_detalhes.in_group = IsInGroup() or IsInRaid()
if (not _detalhes.in_group) then
_detalhes:IniciarColetaDeLixo (true)
table.wipe (_detalhes.details_users)
else
_detalhes:CheckDetailsUsers()
end
end
_detalhes.container_pets:BuscarPets()
return
elseif (evento == "PARTY_MEMBERS_CHANGED") then
+23 -8
View File
@@ -113,7 +113,7 @@
--> scale
function _detalhes:Scale (rangeMin, rangeMax, scaleMin, scaleMax, x)
return 1 + (x-rangeMin)*(scaleMax-scaleMin)/(rangeMax-rangeMin)
return 1 + (x - rangeMin) * (scaleMax - scaleMin) / (rangeMax - rangeMin)
end
--> font size
@@ -189,19 +189,34 @@
LastDps = 0
_detalhes:SairDoCombate()
end
function _detalhes:FindGUIDFromName (name)
if (_IsInRaid()) then
for i = 1, _GetNumGroupMembers(), 1 do
local this_name, _ = UnitName ("raid"..i)
if (this_name == name) then
return UnitGUID ("raid"..i)
end
end
elseif (_IsInGroup()) then
for i = 1, _GetNumGroupMembers()-1, 1 do
local this_name, _ = UnitName ("party"..i)
if (this_name == name) then
return UnitGUID ("party"..i)
end
end
end
if (UnitName ("player") == name) then
return UnitGUID ("player")
end
return nil
end
--> Armazena uma label recém criada - Store a new label on the pool
function _detalhes.font_pool:add (_fontstring)
self [#self+1] = _fontstring
end
function gump:UpdateTooltip (qual_barra, esta_barra, instancia)
_GameTooltip:Hide()
_GameTooltip:SetOwner (esta_barra, "ANCHOR_TOPRIGHT")
instancia:MontaTooltip (qual_barra)
_GameTooltip:Show()
end
local function frame_task (self, elapsed)
self.FrameTime = self.FrameTime + elapsed