Added Details:GetUntitClass(unitId), this call handles the Ambiguate in combatlog's player name when calling UnitClass

This commit is contained in:
Tercio Jose
2023-11-08 20:25:25 -03:00
parent 3b2ba40b29
commit 5e7df0d94a
9 changed files with 66 additions and 32 deletions
+17 -2
View File
@@ -13,8 +13,8 @@
local addonName, Details222 = ...
local version, build, date, tocversion = GetBuildInfo()
Details.build_counter = 12025
Details.alpha_build_counter = 12025 --if this is higher than the regular counter, use it instead
Details.build_counter = 12026
Details.alpha_build_counter = 12026 --if this is higher than the regular counter, use it instead
Details.dont_open_news = true
Details.game_version = version
Details.userversion = version .. " " .. Details.build_counter
@@ -1360,6 +1360,21 @@ if (select(4, GetBuildInfo()) >= 100000) then
end)
end
local classCacheName = Details222.ClassCache.ByName
local classCacheGUID = Details222.ClassCache.ByGUID
function Details222.ClassCache.GetClassFromCache(value)
return classCacheName[value] or classCacheGUID[value]
end
function Details222.ClassCache.AddClassToCache(value, whichCache)
if (whichCache == "name") then
classCacheName[value] = true
elseif (whichCache == "guid") then
classCacheGUID[value] = true
end
end
function Details222.ClassCache.GetClass(value)
local className = Details222.ClassCache.ByName[value] or Details222.ClassCache.ByGUID[value]
if (className) then
+9 -9
View File
@@ -1514,10 +1514,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
@@ -1586,10 +1586,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
@@ -1627,10 +1627,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
local string_output = "pre-potion: "
for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
+1 -1
View File
@@ -458,7 +458,7 @@ end
Details222.GuessSpecSchedules.Schedules[#Details222.GuessSpecSchedules.Schedules+1] = newTimer
end
local _, engClass = UnitClass(actorName or "")
local engClass = Details:GetUnitClass(actorName or "")
if (engClass) then
actorObject.classe = engClass
+2 -2
View File
@@ -1758,7 +1758,7 @@ function Details.Database.StoreEncounter(combat)
player_name = player_name .. "-" .. player_realm
end
local _, _, class = UnitClass(player_name)
local _, _, class = Details:GetUnitClassFull(player_name)
local damage_actor = damage_container_pool [damage_container_hash [player_name]]
if (damage_actor) then
@@ -1771,7 +1771,7 @@ function Details.Database.StoreEncounter(combat)
player_name = player_name .. "-" .. player_realm
end
local _, _, class = UnitClass(player_name)
local _, _, class = Details:GetUnitClassFull(player_name)
local heal_actor = healing_container_pool [healing_container_hash [player_name]]
if (heal_actor) then
+4 -4
View File
@@ -355,7 +355,7 @@
else
local minute, second = _detalhes:GetCombat():GetFormatedCombatTime()
local _, class = _UnitClass(who_name)
local class = Details:GetUnitClass(who_name)
local class_color = "|cFFFF3333"
if (class) then
@@ -457,10 +457,10 @@
local msg
local minute, second = _detalhes:GetCombat():GetFormatedCombatTime()
local _, class = _UnitClass(who_name)
local class = Details:GetUnitClass(who_name)
local class_color = "|cFFFFFFFF"
local _, class2 = _UnitClass(alvo_name)
local class2 = Details:GetUnitClass(alvo_name)
local class_color2 = "|cFFFFFFFF"
if (class) then
@@ -556,7 +556,7 @@
local msg
if (where == 4) then --observer
local _, class = _UnitClass(alvo_name)
local class = Details:GetUnitClass(alvo_name)
local class_color = "|cFFFFFFFF"
if (class) then
@@ -225,9 +225,6 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
self.playerName:SetText(Details:GetOnlyName(self.playerObject.nome))
self.rankText:SetText(self.index) --not in use
--set the player class name
--self.className:SetText(string.lower(_G.UnitClass(self.playerObject.nome) or self.playerObject:Class())) --not in use
--item level
self.itemLevelText:SetText(self.playerObject.ilvl or (playerGear and playerGear.ilevel) or "0")
+22
View File
@@ -174,6 +174,28 @@ do
end
end
---return the class file name of the unit passed
local getFromCache = Details222.ClassCache.GetClassFromCache
local Ambiguate = Ambiguate
local UnitClass = UnitClass
function Details:GetUnitClass(unitId)
local class, classFileName = getFromCache(unitId)
if (not classFileName) then
unitId = Ambiguate(unitId, "none")
classFileName = select(2, UnitClass(unitId))
end
return classFileName
end
---return the class name, class file name and class id of the unit passed
function Details:GetUnitClassFull(unitId)
unitId = Ambiguate(unitId, "none")
local locClassName, classFileName, classId = UnitClass(unitId)
return locClassName, classFileName, classId
end
function Details:GetFullName(unitId)
--playerName, realmName = UnitFullName(unitId) --realm name already has spaces removed
--return playerName .. "-" .. realmName
+1 -1
View File
@@ -157,7 +157,7 @@ local tickerCallback = function(tickerObject)
end
end
addPlayerDamage(UnitName ("player"))
addPlayerDamage(UnitName("player"))
end
function mythicDungeonCharts:OnBossDefeated()
+10 -10
View File
@@ -103,12 +103,12 @@ do
---@param actorName string
---@return string className, number left, number right, number top, number bottom, number red, number green, number blue, number alpha
function Details:GetClass(actorName)
local _, class = UnitClass(actorName)
local unitClass = Details:GetUnitClass(actorName)
if (class) then
local left, right, top, bottom = unpack(Details.class_coords[class])
local r, g, b = unpack(Details.class_colors[class])
return class, left, right, top, bottom, r or 1, g or 1, b or 1, 1
if (unitClass) then
local left, right, top, bottom = unpack(Details.class_coords[unitClass])
local r, g, b = unpack(Details.class_colors[unitClass])
return unitClass, left, right, top, bottom, r or 1, g or 1, b or 1, 1
else
local overallCombatObject = Details:GetCombat(DETAILS_SEGMENTID_OVERALL)
for containerId = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do
@@ -116,12 +116,12 @@ do
local actorObject = actorContainer:GetActor(actorName)
if (actorObject) then
class = actorObject:Class()
if (class) then
unitClass = actorObject:Class()
if (unitClass) then
--found the class of the actor
local left, right, top, bottom = unpack(Details.class_coords[class] or CONST_UNKNOWN_CLASS_COORDS)
local r, g, b = unpack(Details.class_colors[class])
return class, left, right, top, bottom, r or 1, g or 1, b or 1, 1
local left, right, top, bottom = unpack(Details.class_coords[unitClass] or CONST_UNKNOWN_CLASS_COORDS)
local r, g, b = unpack(Details.class_colors[unitClass])
return unitClass, left, right, top, bottom, r or 1, g or 1, b or 1, 1
end
end
end