From 3078eae54e9ed8414a89f6bc446ec7548f90ee8a Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Wed, 21 Dec 2022 09:54:45 -0300 Subject: [PATCH] Added /details m+log; fixed some slash commands not working for Germany --- boot.lua | 7 +--- functions/mythicdungeon.lua | 69 ++++++++++++++++++++++++++++++------- functions/profiles.lua | 3 ++ functions/slash.lua | 49 ++++++++++++++++++++------ 4 files changed, 100 insertions(+), 28 deletions(-) diff --git a/boot.lua b/boot.lua index 05811859..4ef31e1b 100644 --- a/boot.lua +++ b/boot.lua @@ -57,25 +57,20 @@ Details222.PlayerBreakdown = { DamageSpellsCache = {} } - --namespace color Details222.ColorScheme = { ["gradient-background"] = {0.1215, 0.1176, 0.1294, 0.8}, } - function Details222.ColorScheme.GetColorFor(colorScheme) return Details222.ColorScheme[colorScheme] end - --namespace for damage spells (spellTable) Details222.DamageSpells = {} - - --namespace for texture Details222.Textures = {} - --namespace for pet Details222.Pets = {} + Details222.MythicPlus = {} ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --initialization stuff diff --git a/functions/mythicdungeon.lua b/functions/mythicdungeon.lua index 564bd36c..0a136da2 100644 --- a/functions/mythicdungeon.lua +++ b/functions/mythicdungeon.lua @@ -27,6 +27,13 @@ if (not DF.IsTimewalkWoW()) then DetailsMythicPlusFrame:RegisterEvent("START_TIMER") end +function Details222.MythicPlus.LogStep(log) + local today = date("%d/%m/%y %H:%M:%S") + tinsert(Details.mythic_plus_log, 1, today .. "|" .. log) + tremove(Details.mythic_plus_log, 50) +end + + --[[ all mythic segments have: .is_mythic_dungeon_segment = true @@ -50,6 +57,8 @@ function DetailsMythicPlusFrame.MergeSegmentsOnEnd() print("Details!", "MergeSegmentsOnEnd() > starting to merge mythic segments.", "InCombatLockdown():", InCombatLockdown()) end + Details222.MythicPlus.LogStep("MergeSegmentsOnEnd started | creating the overall segment at the end of the run.") + --create a new combat to be the overall for the mythic run Details:EntrarEmCombate() @@ -160,6 +169,7 @@ function DetailsMythicPlusFrame.MergeTrashCleanup (isFromSchedule) --table exists and there's at least one segment if (segmentsToMerge and segmentsToMerge[1]) then + Details222.MythicPlus.LogStep("MergeTrashCleanup started.") --the first segment is the segment where all other trash segments will be added local masterSegment = segmentsToMerge[1] @@ -256,6 +266,8 @@ function DetailsMythicPlusFrame.MergeTrashCleanup (isFromSchedule) Details:InstanciaCallFunction(Details.AtualizaSoloMode_AfertReset) Details:InstanciaCallFunction(Details.ResetaGump) Details:RefreshMainWindow(-1, true) + else + Details222.MythicPlus.LogStep("MergeTrashCleanup | no segments to merge.") end end @@ -266,6 +278,8 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone() print("Details!", "MergeRemainingTrashAfterAllBossesDone() > running, #segments: ", #DetailsMythicPlusFrame.TrashMergeScheduled2, "trash overall table:", DetailsMythicPlusFrame.TrashMergeScheduled2_OverallCombat) end + Details222.MythicPlus.LogStep("running MergeRemainingTrashAfterAllBossesDone.") + local segmentsToMerge = DetailsMythicPlusFrame.TrashMergeScheduled2 local overallCombat = DetailsMythicPlusFrame.TrashMergeScheduled2_OverallCombat @@ -356,6 +370,7 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone() Details:RefreshMainWindow(-1, true) end + Details222.MythicPlus.LogStep("delete_trash_after_merge | concluded") Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED") else --clear the segments to merge table @@ -376,7 +391,7 @@ end --this function is called right after defeat a boss inside a mythic dungeon --it comes from details! control leave combat -function DetailsMythicPlusFrame.BossDefeated (this_is_end_end, encounterID, encounterName, difficultyID, raidSize, endStatus) --hold your breath and count to ten +function DetailsMythicPlusFrame.BossDefeated(this_is_end_end, encounterID, encounterName, difficultyID, raidSize, endStatus) --hold your breath and count to ten if (DetailsMythicPlusFrame.DevelopmentDebug) then print("Details!", "BossDefeated() > boss defeated | SegmentID:", Details.MythicPlus.SegmentID, " | mapID:", Details.MythicPlus.DungeonID) end @@ -398,6 +413,10 @@ function DetailsMythicPlusFrame.BossDefeated (this_is_end_end, encounterID, enco EJID = Details.MythicPlus.ejID, } + local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo() + local mPlusTable = _detalhes.tabela_vigente.is_mythic_dungeon + Details222.MythicPlus.LogStep("BossDefeated | key level: | " .. mythicLevel .. " | " .. (mPlusTable.EncounterName or "") .. " | " .. (mPlusTable.ZoneName or "")) + --check if need to merge the trash for this boss if (_detalhes.mythic_plus.merge_boss_trash and not Details.MythicPlus.IsRestoredState) then --store on an table all segments which should be merged @@ -490,12 +509,15 @@ function DetailsMythicPlusFrame.MythicDungeonFinished (fromZoneLeft) print("Details!", "MythicDungeonFinished() > was in combat, calling SairDoCombate():", InCombatLockdown()) end Details:SairDoCombate() + Details222.MythicPlus.LogStep("MythicDungeonFinished() | Details was in combat.") end local segmentsToMerge = {} --check if there is trash segments after the last boss. need to merge these segments with the trash segment of the last boss - if (_detalhes.mythic_plus.merge_boss_trash and not Details.MythicPlus.IsRestoredState and not fromZoneLeft) then + local bCanMergeBossTrash = _detalhes.mythic_plus.merge_boss_trash + Details222.MythicPlus.LogStep("MythicDungeonFinished() | merge_boss_trash = " .. (bCanMergeBossTrash and "true" or "false")) + if (bCanMergeBossTrash and not Details.MythicPlus.IsRestoredState and not fromZoneLeft) then --is the current combat not a boss fight? --this mean a combat was opened after the last boss of the dungeon was killed if (not Details.tabela_vigente.is_boss and Details.tabela_vigente:GetCombatTime() > 5) then @@ -737,6 +759,9 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even if (combatObject.is_boss) then if (not combatObject.is_boss.killed) then + local encounterName = combatObject.is_boss.encounter + local zoneName = combatObject.is_boss.zone + local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo() --just in case the combat get tagged as boss fight Details.tabela_vigente.is_boss = nil @@ -749,8 +774,10 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even Level = _detalhes.MythicPlus.Level, EJID = _detalhes.MythicPlus.ejID, } + + Details222.MythicPlus.LogStep("COMBAT_PLAYER_LEAVE | wiped on boss | key level: | " .. mythicLevel .. " | " .. (encounterName or "") .. " " .. zoneName) else - DetailsMythicPlusFrame.BossDefeated (false, combatObject.is_boss.id, combatObject.is_boss.name, combatObject.is_boss.diff, 5, 1) + DetailsMythicPlusFrame.BossDefeated(false, combatObject.is_boss.id, combatObject.is_boss.name, combatObject.is_boss.diff, 5, 1) end end @@ -759,6 +786,7 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even elseif (event == "COMBAT_ENCOUNTER_START") then --ignore the event if ignoring mythic dungeon special treatment if (_detalhes.streamer_config.disable_mythic_dungeon) then + Details222.MythicPlus.LogStep("COMBAT_ENCOUNTER_START | streamer_config.disable_mythic_dungeon is true and the code cannot continue.") return end @@ -768,6 +796,7 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even elseif (event == "COMBAT_ENCOUNTER_END") then --ignore the event if ignoring mythic dungeon special treatment if (_detalhes.streamer_config.disable_mythic_dungeon) then + Details222.MythicPlus.LogStep("COMBAT_ENCOUNTER_END | streamer_config.disable_mythic_dungeon is true and the code cannot continue.") return end @@ -775,15 +804,14 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even --nothing elseif (event == "COMBAT_MYTHICDUNGEON_START") then - --print("COMBAT_MYTHICDUNGEON_START", ...) - local lower_instance = _detalhes:GetLowerInstanceNumber() - if (lower_instance) then - lower_instance = _detalhes:GetInstance(lower_instance) - if (lower_instance) then + local lowerInstance = _detalhes:GetLowerInstanceNumber() + if (lowerInstance) then + lowerInstance = _detalhes:GetInstance(lowerInstance) + if (lowerInstance) then C_Timer.After(3, function() - if (lower_instance:IsEnabled()) then + if (lowerInstance:IsEnabled()) then --todo, need localization - lower_instance:InstanceAlert ("Details!" .. " " .. "Damage" .. " " .. "Meter", {[[Interface\AddOns\Details\images\minimap]], 16, 16, false}, 3, {function() end}, false, true) + lowerInstance:InstanceAlert("Details!" .. " " .. "Damage" .. " " .. "Meter", {[[Interface\AddOns\Details\images\minimap]], 16, 16, false}, 3, {function() end}, false, true) end end) end @@ -801,9 +829,23 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even C_Timer.After(0.5, DetailsMythicPlusFrame.OnChallengeModeStart) + --debugging + local mPlusSettings = Details.mythic_plus + local result = "" + for key, value in pairs(Details.mythic_plus) do + if (type(value) ~= "table") then + result = result .. key .. " = " .. tostring(value) .. " | " + end + end + + local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo() + local zoneName, _, _, _, _, _, _, currentZoneID = GetInstanceInfo() + Details222.MythicPlus.LogStep("CHALLENGE_MODE_START | settings: " .. result .. " | level: " .. mythicLevel .. " | zone: " .. zoneName .. " | zoneId: " .. currentZoneID) + elseif (event == "COMBAT_MYTHICDUNGEON_END") then --ignore the event if ignoring mythic dungeon special treatment if (_detalhes.streamer_config.disable_mythic_dungeon) then + Details222.MythicPlus.LogStep("COMBAT_MYTHICDUNGEON_END | streamer_config.disable_mythic_dungeon is true and the code cannot continue.") return end @@ -826,6 +868,7 @@ DetailsMythicPlusFrame:SetScript("OnEvent", function(_, event, ...) --ignore the event if ignoring mythic dungeon special treatment if (_detalhes.streamer_config.disable_mythic_dungeon) then + Details222.MythicPlus.LogStep("ZONE_CHANGED_NEW_AREA | streamer_config.disable_mythic_dungeon is true and the code cannot continue.") return end @@ -835,14 +878,16 @@ DetailsMythicPlusFrame:SetScript("OnEvent", function(_, event, ...) print("Zone changed and the zone is different than the dungeon") end + Details222.MythicPlus.LogStep("ZONE_CHANGED_NEW_AREA | player has left the dungeon and Details! finished the dungeon because of that.") + --send mythic dungeon end event _detalhes:SendEvent("COMBAT_MYTHICDUNGEON_END") --finish the segment - DetailsMythicPlusFrame.BossDefeated (true) + DetailsMythicPlusFrame.BossDefeated(true) --finish the mythic run - DetailsMythicPlusFrame.MythicDungeonFinished (true) + DetailsMythicPlusFrame.MythicDungeonFinished(true) end end end diff --git a/functions/profiles.lua b/functions/profiles.lua index a281a4ca..b61062aa 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1223,6 +1223,9 @@ local default_player_data = { lines_per_column = 12, }, + --mythic plus log + mythic_plus_log = {}, + --force all fonts to have this outline force_font_outline = "", diff --git a/functions/slash.lua b/functions/slash.lua index 8b872b17..2541b1aa 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -26,6 +26,14 @@ end SLASH_DETAILS1, SLASH_DETAILS2, SLASH_DETAILS3 = "/details", "/dt", "/de" +--lower case +local lowerCase_SLASH_CHANGES = string.lower(Loc ["STRING_SLASH_CHANGES"]) +local lowerCase_SLASH_CHANGES_ALIAS1 = string.lower(Loc ["STRING_SLASH_CHANGES_ALIAS1"]) +local lowerCase_CHANGES_ALIAS2 = string.lower(Loc ["STRING_SLASH_CHANGES_ALIAS2"]) +local lowerCase_SLASH_HISTORY = string.lower(Loc ["STRING_SLASH_HISTORY"]) +local lowerCase_SLASH_OPTIONS = string.lower(Loc ["STRING_SLASH_OPTIONS"]) +local lowerCase_SLASH_WORLDBOSS = string.lower(Loc ["STRING_SLASH_WORLDBOSS"]) + function SlashCmdList.DETAILS (msg, editbox) local command, rest = msg:match("^(%S*)%s*(.-)$") @@ -41,7 +49,14 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (command == Loc ["STRING_SLASH_NEW"] or command == "new") then _detalhes:CriarInstancia(nil, true) - elseif (command == Loc ["STRING_SLASH_HISTORY"] or command == "history" or command == "score" or command == "rank" or command == "ranking" or command == "statistics" or command == "stats") then + elseif (command == Loc ["STRING_SLASH_HISTORY"] or + command == "history" or + command == "score" or + command == "rank" or + command == "ranking" or + command == "statistics" or + command == lowerCase_SLASH_HISTORY or + command == "stats") then _detalhes:OpenRaidHistoryWindow() elseif (command == Loc ["STRING_SLASH_TOGGLE"] or command == "toggle") then @@ -194,7 +209,10 @@ function SlashCmdList.DETAILS (msg, editbox) print(Loc ["STRING_DETAILS1"] .. Loc ["STRING_SLASH_CAPTUREON"]) - elseif (command == Loc ["STRING_SLASH_OPTIONS"] or command == "options" or command == "config") then + elseif (command == Loc ["STRING_SLASH_OPTIONS"] or + command == "options" or + command == lowerCase_SLASH_OPTIONS or + command == "config") then if (rest and tonumber(rest)) then local instanceN = tonumber(rest) @@ -214,20 +232,31 @@ function SlashCmdList.DETAILS (msg, editbox) end - elseif (command == Loc ["STRING_SLASH_WORLDBOSS"] or command == "worldboss") then + elseif (command == Loc ["STRING_SLASH_WORLDBOSS"] or command == "worldboss" or command == lowerCase_SLASH_WORLDBOSS) then local questIds = {{"Tarlna the Ageless", 81535}, {"Drov the Ruiner ", 87437}, {"Rukhmar", 87493}} for _, _table in pairs(questIds) do print(format("%s: \124cff%s\124r", _table [1], IsQuestFlaggedCompleted (_table [2]) and "ff0000"..Loc ["STRING_KILLED"] or "00ff00"..Loc ["STRING_ALIVE"])) end - elseif (command == Loc ["STRING_SLASH_CHANGES"] or command == Loc ["STRING_SLASH_CHANGES_ALIAS1"] or command == Loc ["STRING_SLASH_CHANGES_ALIAS2"] or command == "news" or command == "updates") then + elseif ( + command == lowerCase_SLASH_CHANGES or + command == lowerCase_SLASH_CHANGES_ALIAS1 or + command == lowerCase_CHANGES_ALIAS2 or + command == Loc ["STRING_SLASH_CHANGES"] or + command == Loc ["STRING_SLASH_CHANGES_ALIAS1"] or + command == Loc ["STRING_SLASH_CHANGES_ALIAS2"] or + command == "news" or + command == "updates") then _detalhes:OpenNewsWindow() elseif (command == "discord") then _detalhes:CopyPaste ("https://discord.gg/AGSzAZX") + elseif (command == "m+log") then + Details:Dump(Details.mythic_plus_log) + elseif (command == "exitlog") then local newT = {} for _, str in ipairs(_detalhes_global.exit_log) do @@ -857,7 +886,7 @@ function SlashCmdList.DETAILS (msg, editbox) elseif (msg == "version") then Details.ShowCopyValueFrame(Details.GetVersionString()) - elseif (msg == "users" or msg == "version" or msg == "versioncheck") then + elseif (msg == "users" or msg == "versioncheck") then Details.SendHighFive() print(Loc ["STRING_DETAILS1"] .. "highfive sent, HI!") @@ -1846,11 +1875,10 @@ function Details:UpdateUserPanel(usersTable) padding = 2, } - DetailsUserPanel.Header = DetailsFramework:CreateHeader (DetailsUserPanel, headerTable, headerOptions) + DetailsUserPanel.Header = DetailsFramework:CreateHeader(DetailsUserPanel, headerTable, headerOptions) DetailsUserPanel.Header:SetPoint("topleft", DetailsUserPanel, "topleft", 5, headerY) - local scroll_refresh = function(self, data, offset, total_lines) - + local scrollRefresh = function(self, data, offset, total_lines) --store user names shown local userShown = {} local lineId = 1 @@ -1862,7 +1890,8 @@ function Details:UpdateUserPanel(usersTable) local userName, userRealm, userVersion = unpack(userTable) if (not userShown[userName]) then local line = self:GetLine(lineId) - line.UserNameText.text = userName + local onlyUserName = DetailsFramework:RemoveRealmName(userName) + line.UserNameText.text = onlyUserName line.RealmText.text = userRealm line.VersionText.text = userVersion userShown[userName] = true @@ -1925,7 +1954,7 @@ function Details:UpdateUserPanel(usersTable) return line end - local usersScroll = DetailsFramework:CreateScrollBox (DetailsUserPanel, "$parentUsersScroll", scroll_refresh, DetailsUserPanel.Data, scroll_width, scroll_height, scroll_lines, scroll_line_height) + local usersScroll = DetailsFramework:CreateScrollBox (DetailsUserPanel, "$parentUsersScroll", scrollRefresh, DetailsUserPanel.Data, scroll_width, scroll_height, scroll_lines, scroll_line_height) DetailsFramework:ReskinSlider(usersScroll) usersScroll:SetPoint("topleft", DetailsUserPanel, "topleft", 5, scrollY) Details.UserPanel.ScrollBox = usersScroll