From 5aac0bd37742186b1af98f864756659d5eb57a6b Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sat, 17 Aug 2024 11:27:16 -0300 Subject: [PATCH] Fixing battleground naming bug, fixed tooltip border --- core/control.lua | 14 ++++++++-- core/gears.lua | 8 +++++- core/parser.lua | 71 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 87 insertions(+), 6 deletions(-) diff --git a/core/control.lua b/core/control.lua index 8fda97787..b7705ed8d 100644 --- a/core/control.lua +++ b/core/control.lua @@ -1467,15 +1467,23 @@ if (not Details.GameCooltipFrame1Shadow) then Details.GameCooltipFrame1Shadow = GameCooltipFrame1:CreateTexture(nil, "background") Details.GameCooltipFrame1Shadow:SetTexture([[Interface\AddOns\Details\images\shadow_square.png]], nil, nil, "TRILINEAR") - local offset = 4 - Details.GameCooltipFrame1Shadow:SetPoint("topleft", GameCooltipFrame1, "topleft", -offset, offset) - Details.GameCooltipFrame1Shadow:SetPoint("bottomright", GameCooltipFrame1, "bottomright", offset, -offset) GameCooltipFrame1:HookScript("OnHide", function(self) Details.GameCooltipFrame1Shadow:Hide() end) end if (Details.tooltip.show_border_shadow) then + local offset = 1 + if (GameCooltipFrame1:GetHeight() > 200) then + offset = 4 + elseif (GameCooltipFrame1:GetHeight() > 150) then + offset = 3 + elseif (GameCooltipFrame1:GetHeight() > 80) then + offset = 2 + end + + Details.GameCooltipFrame1Shadow:SetPoint("topleft", GameCooltipFrame1, "topleft", -offset, offset) + Details.GameCooltipFrame1Shadow:SetPoint("bottomright", GameCooltipFrame1, "bottomright", offset, -offset) Details.GameCooltipFrame1Shadow:Show() else Details.GameCooltipFrame1Shadow:Hide() diff --git a/core/gears.lua b/core/gears.lua index a8d98d3d2..298640a72 100644 --- a/core/gears.lua +++ b/core/gears.lua @@ -797,6 +797,11 @@ Details222.Parser.EventFrame:SetScript("OnEvent", function(self, event, ...) return end + if (isntanceType == "pvp" or isntanceType == "arena") then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEventPVP) + return + end + if (event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA") then if (bConsiderGroupMembers) then --check if any group member is in combat @@ -848,11 +853,12 @@ function detailsEnterInCombatListener:OnEvent() end end - function Details222.Parser.GetState() local parserEngine = Details222.parser_frame:GetScript("OnEvent") if (parserEngine == Details222.Parser.OnParserEvent) then return "STATE_REGULAR" + elseif (parserEngine == Details222.Parser.OnParserEventPVP) then + return "STATE_PVP" elseif (parserEngine == Details222.Parser.OnParserEventOutOfCombat) then return "STATE_RESTRICTED" end diff --git a/core/parser.lua b/core/parser.lua index 704d828da..b88c6d619 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -115,6 +115,10 @@ --pets local petCache = petContainer.Pets + --store the unit names from all group members + ---@type table + local group_roster_name_cache = {} + --ignore deaths local ignore_death_cache = {} --cache @@ -6197,9 +6201,39 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 return Details.in_group end + local update_persistant_unitname_cache = function() + local unitIdCache + + if (IsInRaid()) then + unitIdCache = Details222.UnitIdCache.Raid + else + unitIdCache = Details222.UnitIdCache.Party + end + + for i, unitId in ipairs(unitIdCache) do + if (UnitExists(unitId)) then + local unitGUID = UnitGUID(unitId) + if (unitGUID) then + if (not group_roster_name_cache[unitGUID]) then + local unitFullName = Details:GetFullName(unitId) + if (unitFullName) then + group_roster_name_cache[unitGUID] = unitFullName + end + end + end + else + break + end + end + end + function Details.parser_functions:GROUP_ROSTER_UPDATE(...) + local bIsInGroup = IsInGroup() or IsInRaid() + + update_persistant_unitname_cache() + if (not Details.in_group) then - Details.in_group = IsInGroup() or IsInRaid() + Details.in_group = bIsInGroup if (Details.in_group) then --player entered in a group, cleanup and set the new enviromnent @@ -6219,7 +6253,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end else - Details.in_group = IsInGroup() or IsInRaid() + Details.in_group = bIsInGroup if (not Details.in_group) then --player left the group, run routines to cleanup the environment @@ -6361,6 +6395,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 --load auto run code Details222.AutoRunCode.StartAutoRun() + update_persistant_unitname_cache() + Details.isLoaded = true end @@ -6602,9 +6638,38 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 -- ~parserstart ~startparser ~cleu ~parser function Details222.Parser.OnParserEvent() local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12 = CombatLogGetCurrentEventInfo() + local func = token_list[token] + if (func) then + who_name = group_roster_name_cache[who_serial] or who_name + target_name = group_roster_name_cache[target_serial] or target_name + return func(nil, token, time, who_serial, who_name, who_flags, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) + end + end + + function Details222.Parser.OnParserEventPVP() + local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12 = CombatLogGetCurrentEventInfo() local func = token_list[token] + if (func) then + if (group_roster_name_cache[who_serial]) then + who_name = group_roster_name_cache[who_serial] + else + if (who_serial:match("^Pl")) then + who_name = who_name:gsub("-%a+$", "") + group_roster_name_cache[who_serial] = who_name + end + end + + if (group_roster_name_cache[target_serial]) then + target_name = group_roster_name_cache[target_serial] + else + if (target_serial:match("^Pl")) then + target_name = target_name:gsub("-%a+$", "") + group_roster_name_cache[target_serial] = target_name + end + end + return func(nil, token, time, who_serial, who_name, who_flags, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) end end @@ -6630,6 +6695,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12 = CombatLogGetCurrentEventInfo() local func = out_of_combat_interresting_events[token] if (func) then + who_name = group_roster_name_cache[who_serial] or who_name + target_name = group_roster_name_cache[target_serial] or target_name return func(nil, token, time, who_serial, who_name, who_flags, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) end end