From 717723272661fe69b3a9c10bb457f6d6d0d57d64 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 16 Aug 2024 13:39:02 -0300 Subject: [PATCH] A round of general bug fixes --- core/control.lua | 7 ++++-- core/gears.lua | 34 ++++++++++++++++++----------- core/network.lua | 2 +- core/parser.lua | 29 ++++++++++++++---------- frames/window_options2_sections.lua | 23 +++++++++++++++++-- 5 files changed, 66 insertions(+), 29 deletions(-) diff --git a/core/control.lua b/core/control.lua index 821f7d684..b88276a18 100644 --- a/core/control.lua +++ b/core/control.lua @@ -437,9 +437,11 @@ end function Details:ScheduleSyncPlayerActorData() + --do not sync if in battleground or arena if ((IsInGroup() or IsInRaid()) and (Details.zone_type == "party" or Details.zone_type == "raid")) then - --do not sync if in battleground or arena - Details:SendCharacterData() + --do a random delay + local delay = RandomFloatInRange(1, 4) + C_Timer.After(delay, Details.SendCharacterData) end end @@ -1354,6 +1356,7 @@ GameCooltip:SetOption("TextColor", Details.tooltip.fontcolor) GameCooltip:SetOption("TextColorRight", Details.tooltip.fontcolor_right) GameCooltip:SetOption("TextShadow", Details.tooltip.fontshadow and "OUTLINE") + GameCooltip:SetOption("TextContour", Details.tooltip.fontcontour) GameCooltip:SetOption("LeftBorderSize", -0) --offset between the left border and the left icon, default: 10 + offset GameCooltip:SetOption("RightBorderSize", 0) --offset between the right border and the right icon, default: -10 + offset diff --git a/core/gears.lua b/core/gears.lua index 6c87b93c7..a8d98d3d2 100644 --- a/core/gears.lua +++ b/core/gears.lua @@ -839,6 +839,16 @@ Details222.Parser.EventFrame:SetScript("OnEvent", function(self, event, ...) end end) +--create a details listener which registers the combat enter event, create the function to receive the registerted event ad call the Details222.Parser.EventFrame:OnEvent with player_regen_disable +local detailsEnterInCombatListener = Details:CreateEventListener() +detailsEnterInCombatListener:RegisterEvent("COMBAT_PLAYER_ENTER") --COMBAT_PLAYER_ENTER from events.lua, this event is triggered when Details! enter in combat +function detailsEnterInCombatListener:OnEvent() + if (Details222.Parser.GetState() == "STATE_RESTRICTED") then + Details222.Parser.EventFrame:GetScript("OnEvent")(Details222.Parser.EventFrame, "PLAYER_REGEN_DISABLED") + end +end + + function Details222.Parser.GetState() local parserEngine = Details222.parser_frame:GetScript("OnEvent") if (parserEngine == Details222.Parser.OnParserEvent) then @@ -2175,7 +2185,7 @@ local MAX_INSPECT_AMOUNT = 1 local MIN_ILEVEL_TO_STORE = 50 local LOOP_TIME = 7 -function Details:IlvlFromNetwork(player, realm, core, serialNumber, itemLevel, talentsSelected, currentSpec) +function Details:IlvlFromNetwork(unitName, realmName, coreVersion, unitGUID, itemLevel, talentsSelected, currentSpec) if (Details.debug and false) then local talents = "Invalid Talents" if (type(talentsSelected) == "table") then @@ -2184,44 +2194,44 @@ function Details:IlvlFromNetwork(player, realm, core, serialNumber, itemLevel, t talents = talents .. talentsSelected [i] .. "," end end - Details222.DebugMsg("Received PlayerInfo Data: " ..(player or "Invalid Player Name") .. " | " ..(itemLevel or "Invalid Item Level") .. " | " ..(currentSpec or "Invalid Spec") .. " | " .. talents .. " | " ..(serialNumber or "Invalid Serial")) + Details222.DebugMsg("Received PlayerInfo Data: " ..(unitName or "Invalid Player Name") .. " | " ..(itemLevel or "Invalid Item Level") .. " | " ..(currentSpec or "Invalid Spec") .. " | " .. talents .. " | " ..(unitGUID or "Invalid Serial")) end - if (not player) then + if (not unitName) then return end --older versions of details wont send serial nor talents nor spec - if (not serialNumber or not itemLevel or not talentsSelected or not currentSpec) then + if (not unitGUID or not itemLevel or not talentsSelected or not currentSpec) then --if any data is invalid, abort return end --won't inspect this actor - Details.trusted_characters[serialNumber] = true + Details.trusted_characters[unitGUID] = true - if (type(serialNumber) ~= "string") then + if (type(unitGUID) ~= "string") then return end --store the item level if (type(itemLevel) == "number") then - Details.item_level_pool[serialNumber] = {name = player, ilvl = itemLevel, time = time()} + Details.item_level_pool[unitGUID] = {name = unitName, ilvl = itemLevel, time = time()} end --store talents if (type(talentsSelected) == "table") then if (talentsSelected[1]) then - Details.cached_talents[serialNumber] = talentsSelected + Details.cached_talents[unitGUID] = talentsSelected end elseif (type(talentsSelected) == "string" and talentsSelected ~= "") then - Details.cached_talents[serialNumber] = talentsSelected + Details.cached_talents[unitGUID] = talentsSelected end --store the spec the player is playing if (type(currentSpec) == "number") then - Details.cached_specs[serialNumber] = currentSpec + Details.cached_specs[unitGUID] = currentSpec end end @@ -2574,9 +2584,7 @@ function ilvl_core:ZoneChanged(zone_type) end function ilvl_core:OnEnter() - if (IsInRaid()) then - Details:SendCharacterData() - end + Details:SendCharacterData() if (can_start_loop()) then ilvl_core:Reset() diff --git a/core/network.lua b/core/network.lua index fd41005c6..3ca1514bc 100644 --- a/core/network.lua +++ b/core/network.lua @@ -169,7 +169,7 @@ end --vertical, horizonal tree - if (DetailsFramework.IsDragonflight()) then + if (DetailsFramework.IsDragonflightAndBeyond()) then talentsAsString = detailsFramework:GetDragonlightTalentString() end diff --git a/core/parser.lua b/core/parser.lua index d49d3ea58..704d828da 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -941,8 +941,7 @@ end end - --local spellInfo = C_Spell.GetSpellInfo(spellId) - --print("1 spell:", spellId, spellInfo.name) + local spellInfo = C_Spell.GetSpellInfo(spellId) Details222.StartCombat(sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags) else --entrar em combate se for dot e for do jogador e o ultimo combate ter sido a mais de 10 segundos atr�s @@ -953,7 +952,6 @@ --can't start a combat with a dot with the latest combat finished less than 10 seconds ago if (Details.last_combat_time + 10 < _tempo) then - --print("2 spell:", spellId) Details222.StartCombat(sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags) end end @@ -1186,22 +1184,25 @@ thisEvent[3] = amount --amount of damage or healing thisEvent[4] = time --parser time - --current unit heal + --current unit healh if (targetActor.arena_enemy) then --this is an arena enemy, get the heal with the unit Id local unitId = Details.arena_enemies[targetName] if (not unitId) then unitId = Details:GuessArenaEnemyUnitId(targetName) end + if (unitId) then - thisEvent[5] = UnitHealth(unitId) / UnitHealthMax(unitId) + local health = UnitHealth(unitId) + local maxHealth = max(UnitHealthMax(unitId), SMALL_FLOAT) + thisEvent[5] = health / maxHealth else thisEvent[5] = cacheAnything.arenaHealth[targetName] or 100000 end cacheAnything.arenaHealth[targetName] = thisEvent[5] else - thisEvent[5] = UnitHealth(targetName) / UnitHealthMax(targetName) + thisEvent[5] = UnitHealth(targetName) / max(UnitHealthMax(targetName), SMALL_FLOAT) end thisEvent[6] = sourceName --source name @@ -1302,7 +1303,7 @@ thisEvent[2] = spellId --spellid || false if this is a battle ress line thisEvent[3] = amount --amount of damage or healing thisEvent[4] = time --parser time - thisEvent[5] = UnitHealth(targetName) / UnitHealthMax(targetName) --current unit heal + thisEvent[5] = UnitHealth(targetName) / max(UnitHealthMax(targetName), SMALL_FLOAT) --current unit heal thisEvent[6] = sourceName --source name thisEvent[7] = absorbed thisEvent[8] = spellType or school @@ -2662,12 +2663,12 @@ unitId = Details:GuessArenaEnemyUnitId(targetName) end if (unitId) then - thisEvent[5] = UnitHealth(unitId) / UnitHealthMax(unitId) + thisEvent[5] = UnitHealth(unitId) / max(UnitHealthMax(unitId), SMALL_FLOAT) else thisEvent[5] = 0 end else - thisEvent[5] = UnitHealth(targetName) / UnitHealthMax(targetName) + thisEvent[5] = UnitHealth(targetName) / max(UnitHealthMax(targetName), SMALL_FLOAT) end thisEvent[6] = sourceName @@ -6599,7 +6600,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 local eraNamedSpellsToID = {} -- ~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() @@ -6610,15 +6610,22 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end --open world out of combat spell damage - local outofcombat_spell_damage = function(unused, token, time, whoGUID, whoName, whoFlags, targetGUID, targetName, targetFlags) + local outofcombat_spell_damage = function(unused, token, time, whoGUID, whoName, whoFlags, targetGUID, targetName, targetFlags, targetFlags2, ...) --identify if the attacker is a group member + local IS_GROUP_OBJECT = 0x00000007 + local bIsValidGroupMember = bitBand(whoFlags, IS_GROUP_OBJECT) ~= 0 + if (bIsValidGroupMember) then + token_list[token](nil, token, time, whoGUID, whoName, whoFlags, targetGUID, targetName, targetFlags, targetFlags2, ...) + end end local out_of_combat_interresting_events = { ["SPELL_SUMMON"] = parser.summon, + ["SWING_DAMAGE"] = outofcombat_spell_damage, ["SPELL_DAMAGE"] = outofcombat_spell_damage, } + --OutOfCombat parser is only used in open world to avoid getting information from people that are outside of the group function Details222.Parser.OnParserEventOutOfCombat() 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] diff --git a/frames/window_options2_sections.lua b/frames/window_options2_sections.lua index 55a03ea5b..f236ef5d8 100644 --- a/frames/window_options2_sections.lua +++ b/frames/window_options2_sections.lua @@ -3740,7 +3740,7 @@ do end end - if (pluginObject.OpenOptionsPanel) then + if (rawget(pluginObject, "OpenOptionsPanel")) then DF:NewButton(bframe, nil, "$parentOptionsButton"..i, "OptionsButton"..i, 86, 18, pluginObject.OpenOptionsPanel, nil, nil, nil, Loc ["STRING_OPTIONS_PLUGINS_OPTIONS"], nil, options_button_template) bframe ["OptionsButton"..i]:SetPoint("topleft", anchorFrame, "topleft", 510, y-0) bframe ["OptionsButton"..i]:SetTextColor(button_color_rgb) @@ -4310,10 +4310,29 @@ do Details.tooltip.fontshadow = value afterUpdate() end, - name = Loc ["STRING_OPTIONS_TEXT_LOUTILINE"], + name = Loc ["STRING_OPTIONS_TEXT_OUTLINE"], desc = Loc ["STRING_OPTIONS_TOOLTIPS_FONTSHADOW_DESC"], }, + {--shadow color + type = "color", + get = function() + local r, g, b, a = unpack(Details.tooltip.fontcontour) + return {r, g, b, a} + end, + set = function(self, r, g, b, a) + local color = Details.tooltip.fontcontour + color[1] = r + color[2] = g + color[3] = b + color[4] = a + afterUpdate() + end, + name = "Shadow Color", + desc = "Color of the text shadow", + hidden = true, + }, + {--text size type = "range", get = function() return Details.tooltip.fontsize end,