From 00f04959cbff13e8ccacb68fc6e41d165c2b2d08 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 9 Jul 2024 12:47:24 -0300 Subject: [PATCH] added commentator stuff, general code cleanup and better formatting, some deprecated code removed --- API General.txt | 11 - boot.lua | 42 +- classes/class_damage.lua | 43 +- classes/class_instance.lua | 4 +- classes/container_actors.lua | 6 +- classes/container_segments.lua | 2 +- core/control.lua | 700 +++++--------- core/gears.lua | 1064 ++++++++++++--------- core/network.lua | 7 - core/parser.lua | 230 ++--- core/windows.lua | 28 +- frames/window_main.lua | 934 +++++++++--------- frames/window_mythicplus/window_chart.lua | 7 +- frames/window_spellcategory.lua | 2 +- frames/window_welcome.lua | 4 +- functions/commentator.lua | 90 ++ functions/mythicdungeon/data_capture.lua | 2 +- functions/mythicdungeon/segments.lua | 4 +- functions/slash.lua | 4 +- startup.lua | 14 +- 20 files changed, 1602 insertions(+), 1596 deletions(-) create mode 100644 functions/commentator.lua diff --git a/API General.txt b/API General.txt index ab9294d4..5d7d8c5d 100644 --- a/API General.txt +++ b/API General.txt @@ -1,15 +1,4 @@ -======================================= -Background Tasks -======================================= - -Details:RegisterBackgroundTask (name, func, priority, ...) -register a function to be called while the player isn't in: combat, group, raid instances. -priority determines the interval time and support "LOW", "MEDIUM", "HIGH" values. - -Details:UnregisterBackgroundTask (name) -unregister a background task. - ======================================= Item Level ======================================= diff --git a/boot.lua b/boot.lua index 01c465fd..d9f4fd70 100644 --- a/boot.lua +++ b/boot.lua @@ -1,8 +1,9 @@ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --global name declaration ---local _StartDebugTime = debugprofilestop() print(debugprofilestop() - _StartDebugTime) +--use lua-language-server annotations to help the linter: --https://github.com/LuaLS/lua-language-server/wiki/Annotations#documenting-types ---updated the lib open raid for v11 +--follow definitions declared in the file definitions.lua +--follow game api definitions in the file LibLuaServer.lua local _ = nil _G.Details = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0") @@ -24,6 +25,7 @@ Details.game_version = version Details.userversion = version .. " " .. Details.build_counter Details.realversion = 158 --core version, this is used to check API version for scripts and plugins (see alias below) + Details.gametoc = tvs Details.APIVersion = Details.realversion --core version Details.version = Details.userversion .. " (core " .. Details.realversion .. ")" --simple stirng to show to players @@ -37,6 +39,7 @@ Details.BFACORE = 131 --core version on BFA launch Details.SHADOWLANDSCORE = 143 --core version on Shadowlands launch Details.DRAGONFLIGHT = 147 --core version on Dragonflight launch + Details.V11CORE = 158 --core version on V11 launch Details = Details @@ -102,9 +105,8 @@ Details222.DamageSpells = {} --namespace for texture Details222.Textures = {} - Details222.Debug = {} - + Details222.Tvs = tvs --namespace for pet Details222.Pets = {} Details222.PetContainer = { @@ -167,6 +169,8 @@ [1473] = {}, } + Details222.Parser = {} + Details222.Actors = {} Details222.CurrentDPS = { @@ -529,9 +533,9 @@ do --armazenas as fun��es do parser - All parse functions _detalhes.parser = {} _detalhes.parser_functions = {} - _detalhes.parser_frame = CreateFrame("Frame") + Details222.parser_frame = CreateFrame("Frame") + Details222.parser_frame:Hide() _detalhes.pvp_parser_frame = CreateFrame("Frame") - _detalhes.parser_frame:Hide() _detalhes.MacroList = { {Name = "Click on Your Own Bar", Desc = "To open the player details window on your character, like if you click on your bar in the damage window. The number '1' is the window number where it'll click.", MacroText = "/script Details:OpenPlayerDetails(1)"}, @@ -1269,13 +1273,37 @@ do end end + local bIsDump = false + local waitForSpellLoad = CreateFrame("frame") + if (C_EventUtils.IsEventValid("SPELL_TEXT_UPDATE")) then + waitForSpellLoad:RegisterEvent("SPELL_TEXT_UPDATE") + waitForSpellLoad:SetScript("OnEvent", function(self, event, spellId) + if (bIsDump) then + dumpt(spellId) + end + end) + end + function dumpt(value) --[[GLOBAL]] --check if this is a spellId local spellId = tonumber(value) if (spellId) then local spellInfo = {Details222.GetSpellInfo(spellId)} if (type(spellInfo[1]) == "string") then - return Details:Dump(spellInfo) + local desc = C_Spell.GetSpellDescription and C_Spell.GetSpellDescription(spellId) or GetSpellDescription(spellId) + if (not desc or desc == "") then + bIsDump = true + return + end + + if (C_Spell.GetSpellInfo) then + Details:Dump({desc, C_Spell.GetSpellInfo(spellId)}) + return + else + return Details:Dump({desc, spellInfo}) + end + + bIsDump = false end end diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 7b4e0f3b..3c164f97 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -2586,19 +2586,20 @@ end --space between string4 and string3 (usually dps is 4 and total value is 3) for lineId = 1, self:GetNumLinesShown() do local thisLine = self:GetLine(lineId) + if (thisLine) then + --check strings 3 and 4 + if (thisLine.lineText4:GetText() ~= "" and thisLine.lineText3:GetText() ~= "") then + --the length of the far right string determines the space between it and the next string in the left + local stringLength = thisLine.lineText4:GetStringWidth() + maxStringLength_StringFour = stringLength > maxStringLength_StringFour and stringLength or maxStringLength_StringFour + end - --check strings 3 and 4 - if (thisLine.lineText4:GetText() ~= "" and thisLine.lineText3:GetText() ~= "") then - --the length of the far right string determines the space between it and the next string in the left - local stringLength = thisLine.lineText4:GetStringWidth() - maxStringLength_StringFour = stringLength > maxStringLength_StringFour and stringLength or maxStringLength_StringFour - end - - --check strings 2 and 3 - if (thisLine.lineText2:GetText() ~= "" and thisLine.lineText3:GetText() ~= "") then - --the length of the middle string determines the space between it and the next string in the left - local stringLength = thisLine.lineText3:GetStringWidth() - maxStringLength_StringThree = stringLength > maxStringLength_StringThree and stringLength or maxStringLength_StringThree + --check strings 2 and 3 + if (thisLine.lineText2:GetText() ~= "" and thisLine.lineText3:GetText() ~= "") then + --the length of the middle string determines the space between it and the next string in the left + local stringLength = thisLine.lineText3:GetStringWidth() + maxStringLength_StringThree = stringLength > maxStringLength_StringThree and stringLength or maxStringLength_StringThree + end end end @@ -2619,7 +2620,9 @@ end --update the lines for lineId = 1, self:GetNumLinesShown() do local thisLine = self:GetLine(lineId) - thisLine.lineText3:SetPoint("right", thisLine.statusbar, "right", -newOffset, profileYOffset) + if (thisLine) then + thisLine.lineText3:SetPoint("right", thisLine.statusbar, "right", -newOffset, profileYOffset) + end end end @@ -2640,7 +2643,9 @@ end --update the lines for lineId = 1, self:GetNumLinesShown() do local thisLine = self:GetLine(lineId) - thisLine.lineText2:SetPoint("right", thisLine.statusbar, "right", -newOffset, profileYOffset) + if (thisLine) then + thisLine.lineText2:SetPoint("right", thisLine.statusbar, "right", -newOffset, profileYOffset) + end end end end @@ -2651,7 +2656,7 @@ end --check if there's something showing in this line --check if the line is shown and if the text exists for sanitization - if (thisLine.minha_tabela and thisLine:IsShown() and thisLine.lineText1:GetText()) then + if (thisLine and thisLine.minha_tabela and thisLine:IsShown() and thisLine.lineText1:GetText()) then local playerNameFontString = thisLine.lineText1 local text2 = thisLine.lineText2 local text3 = thisLine.lineText3 @@ -2663,10 +2668,10 @@ end DetailsFramework:TruncateTextSafe(playerNameFontString, self.cached_bar_width - totalWidth) --this avoid truncated strings with ... --these commented lines are for to create a cache and store the name already truncated there to safe performance - --local truncatedName = playerNameFontString:GetText() - --local actorObject = thisLine.minha_tabela - --actorObject.name_cached = truncatedName - --actorObject.name_cached_time = GetTime() + --local truncatedName = playerNameFontString:GetText() + --local actorObject = thisLine.minha_tabela + --actorObject.name_cached = truncatedName + --actorObject.name_cached_time = GetTime() end end end diff --git a/classes/class_instance.lua b/classes/class_instance.lua index 31f608cf..59dbcf4b 100644 --- a/classes/class_instance.lua +++ b/classes/class_instance.lua @@ -2594,7 +2594,7 @@ function Details:AtualizaSegmentos_AfterCombat(instancia) instancia.v_barras = true instancia:ResetaGump() instancia:RefreshMainWindow(true) - Details:AtualizarJanela (instancia) + Details:UpdateWindow (instancia) elseif (segmento < Details.segments_amount and segmento > 0) then instancia.showing = segmentsTable[segmento] @@ -2605,7 +2605,7 @@ function Details:AtualizaSegmentos_AfterCombat(instancia) instancia.v_barras = true instancia:ResetaGump() instancia:RefreshMainWindow(true) - Details:AtualizarJanela (instancia) + Details:UpdateWindow (instancia) end end diff --git a/classes/container_actors.lua b/classes/container_actors.lua index 7f893f18..073c61a2 100644 --- a/classes/container_actors.lua +++ b/classes/container_actors.lua @@ -306,7 +306,7 @@ end return ipairs(self._ActorTable) end - ---return a table for all actors stored in this Container + ---return a table with actor[] for all actors stored in this container ---@return table function actorContainer:GetActorTable() return self._ActorTable @@ -315,8 +315,8 @@ end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --internals - ---create a new actor container, can be a damage container, heal container, enemy container or utility container - ---actors can be added by using newContainer.GetOrCreateActor + ---create a new actor container, can be a damage container, heal container, resource container or utility container + ---actors can be added by using the method newContainer:GetOrCreateActor(actorGuid, actorName, actorFlags, bShouldCreateActor) ---actors can be retrieved using the same function above ---@param containerType number ---@param combatObject table diff --git a/classes/container_segments.lua b/classes/container_segments.lua index 3fdc1165..51c797b5 100644 --- a/classes/container_segments.lua +++ b/classes/container_segments.lua @@ -26,7 +26,7 @@ function Details:ResetSegmentOverallData() return segmentClass:ResetOverallData() end ---reset segments and overall data +--erase all combat data stored function Details:ResetSegmentData() return segmentClass:ResetAllCombatData() end diff --git a/core/control.lua b/core/control.lua index 1b7c2736..ae2ad417 100644 --- a/core/control.lua +++ b/core/control.lua @@ -1,34 +1,32 @@ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - local _detalhes = _G.Details - local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) + local Details = _G.Details + local Loc = LibStub("AceLocale-3.0"):GetLocale( "Details" ) local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") local _tempo = time() - local _ local addonName, Details222 = ... + ---@type detailsframework local detailsFramework = DetailsFramework + local _ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --local pointers - local _math_max = math.max --lua local - local ipairs = ipairs --lua local - local pairs = pairs --lua local - local bitBand = bit.band --lua local - - local GetInstanceInfo = GetInstanceInfo --wow api local - local UnitExists = UnitExists --wow api local - local UnitGUID = UnitGUID --wow api local + local max = math.max + local ipairs = ipairs + local pairs = pairs + local bitBand = bit.band + local GetInstanceInfo = GetInstanceInfo + local UnitExists = UnitExists + local UnitGUID = UnitGUID local GetTime = GetTime - local IsAltKeyDown = IsAltKeyDown local IsShiftKeyDown = IsShiftKeyDown local IsControlKeyDown = IsControlKeyDown - local atributo_damage = Details.atributo_damage - local atributo_heal = Details.atributo_heal - local atributo_energy = Details.atributo_energy - local atributo_misc = Details.atributo_misc - local atributo_custom = Details.atributo_custom + local damageClass = Details.atributo_damage + local healingClass = Details.atributo_heal + local resourceClass = Details.atributo_energy + local utilityClass = Details.atributo_misc + local customClass = Details.atributo_custom local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned @@ -36,12 +34,12 @@ --constants local groupMode = Details.modos.group local everythingMode = Details.modos.all - local attributeDamage = Details.atributos.dano - local OBJECT_TYPE_PETS = 0x00003000 + local damageAttributeId = Details.atributos.dano ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --details api functions ---for a number to the current selected abbreviation + --Details.ps_abbreviation tell the current abbreviation type ---@param number number ---@return string function Details:Format(number) @@ -67,7 +65,7 @@ if (playerActorObject) then local targets = playerActorObject.targets - --make an array of targets {{targetName, amount}} + ---@type table[] local targetsArray = {} for targetName, amount in pairs(targets) do table.insert(targetsArray, {targetName, amount}) @@ -83,23 +81,27 @@ end end - for _, actor in ipairs(currentCombat[attributeDamage]._ActorTable) do - if (not actor.grupo and not actor.owner and not actor.nome:find("[*]") and bitBand(actor.flag_original, 0x00000060) ~= 0) then --0x20+0x40 neutral + enemy reaction - for name, _ in pairs(actor.targets) do - if (name == Details.playername) then - return actor.nome + ---@type actorcontainer + local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + for _, actor in damageContainer:ListActors() do + ---@cast actor actor + if (not actor:IsGroupPlayer() and not actor.owner and not actor.nome:find("[*]") and bitBand(actor.flag_original, 0x00000060) ~= 0) then --0x20+0x40 neutral + enemy reaction + for targetName in pairs(actor.targets) do + if (targetName == Details.playername) then + return actor:Name() else - local targetActor = currentCombat(attributeDamage, name) - if (targetActor and targetActor.grupo) then - return actor.nome + local targetActor = damageContainer:GetActor(targetName) + if (targetActor and targetActor:IsGroupPlayer()) then + return actor:Name() end end end end end - for _, actor in ipairs(currentCombat[attributeDamage]._ActorTable) do - if (actor.grupo and not actor.owner) then + for _, actor in damageContainer:ListActors() do + ---@cast actor actor + if (actor:IsGroupPlayer() and not actor.owner) then for targetName, _ in pairs(actor.targets) do return targetName end @@ -109,7 +111,7 @@ return Loc ["STRING_UNKNOW"] end - --try get the current encounter name during the encounter + --create and set a table in the current combat, this table store information about the boss in the current combat local createBossTable = function(t, zoneName, zoneMapID, difficultyID) local bossTable = { index = 0, @@ -169,39 +171,35 @@ end function Details:ReadBossFrames() + ---@type combat local currentCombat = Details:GetCurrentCombat() - if (currentCombat.is_boss) then - return --no need to check + if (currentCombat:GetBossInfo()) then + return --the combat already has a bossInfo end if (Details.encounter_table.name) then - - --store the encounter time inside the encounter table for the encounter plugin - Details.encounter_table.start = GetTime() - Details.encounter_table ["end"] = nil --- local encounterID = Details.encounter_table.id - Details.encounter_table.id = encounterID - Details.encounter_table.name = encounterName - Details.encounter_table.diff = difficultyID - Details.encounter_table.size = raidSize - Details.encounter_table.zone = zoneName - Details.encounter_table.mapid = zoneMapID + local encounterID = Details.encounter_table.id + local encounterName = Details.encounter_table.name + local zoneName = Details.encounter_table.zone + local zoneMapID = Details.encounter_table.mapid + local difficultyID = Details.encounter_table.diff local encounterTable = Details.encounter_table - return foundEncounterInfo(encounterTable.index, encounterTable.name, encounterTable.zone, encounterTable.mapid, encounterTable.diff, encounterTable.id) + return foundEncounterInfo(encounterTable.index, encounterName, zoneName, zoneMapID, difficultyID, encounterID) end - for index = 1, 5 do - if (UnitExists("boss" .. index)) then - local bossGuid = UnitGUID("boss" .. index) + for index = 1, #Details222.UnitIdCache.Boss do + local bossUnitId = Details222.UnitIdCache.Boss[index] + if (UnitExists(bossUnitId)) then + local bossGuid = UnitGUID(bossUnitId) if (bossGuid) then - local serial = Details:GetNpcIdFromGuid(bossGuid) - if (serial) then + local npcId = Details:GetNpcIdFromGuid(bossGuid) + if (npcId) then local zoneName, _, difficultyID, _, _, _, _, zoneMapID = GetInstanceInfo() local bossIds = Details:GetBossIds(zoneMapID) if (bossIds) then - local bossIndex = bossIds[serial] + local bossIndex = bossIds[npcId] if (bossIndex) then if (Details.debug) then Details:Msg("(debug) boss found:", Details:GetBossName(zoneMapID, bossIndex)) @@ -218,26 +216,26 @@ --try to get the encounter name after the encounter (can be called during the combat as well) function Details:FindBoss(noJournalSearch) if (Details.encounter_table.name) then - local encounter_table = Details.encounter_table - return foundEncounterInfo(encounter_table.index, encounter_table.name, encounter_table.zone, encounter_table.mapid, encounter_table.diff, encounter_table.id) + local encounterTable = Details.encounter_table + return foundEncounterInfo(encounterTable.index, encounterTable.name, encounterTable.zone, encounterTable.mapid, encounterTable.diff, encounterTable.id) end + ---@type combat local currentCombat = Details:GetCurrentCombat() local zoneName, instanceType, difficultyID, _, _, _, _, zoneMapID = GetInstanceInfo() local bossIds = Details:GetBossIds(zoneMapID) if (bossIds) then - local actorContainer = currentCombat[attributeDamage]._ActorTable - if (actorContainer) then - for index, actorObject in ipairs(actorContainer) do - if (not actorObject.grupo) then - local serial = Details:GetNpcIdFromGuid(actorObject.serial) - if (serial) then - local bossIndex = bossIds[serial] - if (bossIndex) then - actorObject.boss = true - return foundEncounterInfo(bossIndex, Details:GetBossName(zoneMapID, bossIndex), zoneName, zoneMapID, difficultyID) - end + ---@type actorcontainer + local damageContainer = currentCombat:GetContainer(damageAttributeId) + for index, actorObject in damageContainer:ListActors() do + if (not actorObject:IsGroupPlayer()) then + local npcId = Details:GetNpcIdFromGuid(actorObject.serial) + if (npcId) then + local bossIndex = bossIds[npcId] + if (bossIndex) then + actorObject.boss = true + return foundEncounterInfo(bossIndex, Details:GetBossName(zoneMapID, bossIndex), zoneName, zoneMapID, difficultyID) end end end @@ -247,18 +245,17 @@ noJournalSearch = true --disabling the scan on encounter journal if (not noJournalSearch) then - local in_instance = IsInInstance() --garrison returns party as instance type. - if ((instanceType == "party" or instanceType == "raid") and in_instance) then - local boss_list = Details:GetCurrentDungeonBossListFromEJ() - if (boss_list) then - local ActorsContainer = currentCombat[attributeDamage]._ActorTable - if (ActorsContainer) then - for index, Actor in ipairs(ActorsContainer) do - if (not Actor.grupo) then - if (boss_list [Actor.nome]) then - Actor.boss = true - return createBossTable (boss_list [Actor.nome], zoneName, zoneMapID, difficultyID) - end + local bIsInInstance = IsInInstance() --garrison returns party as instance type. + if ((instanceType == "party" or instanceType == "raid") and bIsInInstance) then + local bossList = Details:GetCurrentDungeonBossListFromEJ() + if (bossList) then + ---@type actorcontainer + local damageContainer = currentCombat:GetContainer(damageAttributeId) + for index, actorObject in damageContainer:ListActors() do + if (not actorObject:IsGroupPlayer()) then + if (bossList[actorObject:Name()]) then + actorObject.boss = true + return createBossTable (bossList [actorObject:Name()], zoneName, zoneMapID, difficultyID) end end end @@ -294,6 +291,7 @@ --iterate over the segments table from the most recent to the oldest, check if the combatObject of the segment has is_boss and get the encounter Id from the member is_boss.id for i = 1, #segmentsTable do + ---@type combat local combatObject = segmentsTable[i] if (combatObject.is_boss) then table.insert(resultTable, 1, combatObject.is_boss.id) @@ -304,18 +302,25 @@ end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + --internal functions function Details:StartCombat(...) - return Details:EntrarEmCombate (...) + return Details:EntrarEmCombate(...) end - -- ~start ~inicio ~novo �ovo - function Details:EntrarEmCombate (...) + function Details:EntrarEmCombate(...) + Details:Msg("deprecated path on control.lua") + print(debugstack()) + return Details222.StartCombat(...) + end + + -- ~start + function Details222.StartCombat(...) if (Details.debug) then Details:Msg("(debug) |cFFFFFF00started a new combat|r|cFFFF7700", Details.encounter_table and Details.encounter_table.name or "") --local from = debugstack(2, 1, 0) --print("from:", from) - DetailsParserDebugFrame:Show() + --DetailsParserDebugFrame:Show() end local segmentsTable = Details:GetCombatSegments() @@ -384,16 +389,14 @@ Details:CatchRaidDebuffUptime("DEBUFF_UPTIME_IN") Details:UptadeRaidMembersCache() - --Details222.TimeCapture.StartCombatTimer(Details.tabela_vigente) - --we already have boss information? build .is_boss table - if (Details.encounter_table.id and Details.encounter_table ["start"] >= GetTime() - 3 and not Details.encounter_table ["end"]) then - local encounter_table = Details.encounter_table + if (Details.encounter_table.id and Details.encounter_table["start"] >= GetTime() - 3 and not Details.encounter_table["end"]) then + local encounterTable = Details.encounter_table --boss_found will trigger "COMBAT_BOSS_FOUND" event, but at this point of the combat creation is safe to send it - foundEncounterInfo (encounter_table.index, encounter_table.name, encounter_table.zone, encounter_table.mapid, encounter_table.diff, encounter_table.id) + foundEncounterInfo (encounterTable.index, encounterTable.name, encounterTable.zone, encounterTable.mapid, encounterTable.diff, encounterTable.id) else --if we don't have this infor right now, lets check in few seconds dop - if (Details.EncounterInformation [Details.zone_id]) then + if (Details.EncounterInformation[Details.zone_id]) then Details:ScheduleTimer("ReadBossFrames", 1) Details:ScheduleTimer("ReadBossFrames", 30) end @@ -407,27 +410,8 @@ Details.host_of = nil Details.host_by = nil - if (Details.in_group and Details.cloud_capture) then - if (Details:IsInInstance() or Details.debug) then - if (not Details:CaptureIsAllEnabled()) then - Details:ScheduleSendCloudRequest() - --if (Details.debug) then - -- Details:Msg("(debug) requesting a cloud server.") - --end - end - else - --if (Details.debug) then - -- Details:Msg("(debug) isn't inside a registred instance", Details:IsInInstance()) - --end - end - else - --if (Details.debug) then - -- Details:Msg("(debug) isn't in group or cloud is turned off", Details.in_group, Details.cloud_capture) - --end - end - --hide / alpha / switch in combat - for index, instancia in ipairs(Details.tabela_instancias) do + for index, instancia in ipairs(Details:GetAllInstances()) do if (instancia.ativa) then instancia:CheckSwitchOnCombatStart(true) end @@ -452,18 +436,6 @@ Details:StopTestBarUpdate() end - function Details:DelayedSyncAlert() - local lower_instance = Details:GetLowerInstanceNumber() - if (lower_instance) then - lower_instance = Details:GetInstance(lower_instance) - if (lower_instance) then - if (not lower_instance:HaveInstanceAlert()) then - lower_instance:InstanceAlert (Loc ["STRING_EQUILIZING"], {[[Interface\COMMON\StreamCircle]], 22, 22, true}, 5, {function() end}) - end - end - end - end - function Details:ScheduleSyncPlayerActorData() if ((IsInGroup() or IsInRaid()) and (Details.zone_type == "party" or Details.zone_type == "raid")) then --do not sync if in battleground or arena @@ -519,21 +491,17 @@ --still didn't find the boss if (not currentCombat.is_boss) then - local ZoneName, _, DifficultyID, _, _, _, _, ZoneMapID = GetInstanceInfo() - local findboss = Details:GetRaidBossFindFunction(ZoneMapID) + local zoneName, _, difficultyID, _, _, _, _, zoneMapID = GetInstanceInfo() + local findboss = Details:GetRaidBossFindFunction(zoneMapID) if (findboss) then - local BossIndex = findboss() - if (BossIndex) then - foundEncounterInfo(BossIndex, Details:GetBossName(ZoneMapID, BossIndex), ZoneName, ZoneMapID, DifficultyID) + local bossIndex = findboss() + if (bossIndex) then + foundEncounterInfo(bossIndex, Details:GetBossName(zoneMapID, bossIndex), zoneName, zoneMapID, difficultyID) end end end end - if (currentCombat.is_challenge or Details.debug) then - --Details222.AuraScan.Stop() --combat ended (m+ active) - end - Details:OnCombatPhaseChanged() --stop combat ticker @@ -556,7 +524,7 @@ currentCombat.player_last_events = {} --flag instance type - local zoneName, instanceType, DifficultyID, DifficultyName, _, _, _, zoneMapID = GetInstanceInfo() + local zoneName, instanceType, difficultyID, difficultyName, _, _, _, zoneMapID = GetInstanceInfo() currentCombat.instance_type = instanceType if (not currentCombat.is_boss and bIsFromEncounterEnd and type(bIsFromEncounterEnd) == "table") then @@ -581,8 +549,8 @@ encounter = encounterName, zone = zoneName, mapid = zoneMapID, - diff = DifficultyID, - diff_string = DifficultyName, + diff = difficultyID, + diff_string = difficultyName, ej_instance_id = ejid or 0, id = encounterID, unixtime = time() @@ -732,9 +700,7 @@ end --schedule sync - Details:EqualizeActorsSchedule(Details.host_of) if (Details:GetEncounterEqualize(currentCombat.is_boss.mapid, currentCombat.is_boss.index)) then - Details:ScheduleTimer("DelayedSyncAlert", 3) end end @@ -829,7 +795,7 @@ end currentCombat.resincked = true - Details:InstanceCallDetailsFunc(Details.AtualizarJanela) + Details:InstanceCallDetailsFunc(Details.UpdateWindow) if (Details.solo) then --code to update "solo" plugins, there's no solo plugins for details! at the moment if (Details.SoloTables.CombatID == Details:GetOrSetCombatId()) then --significa que o solo mode validou o combate, como matar um bixo muito low level com uma s� porrada @@ -920,12 +886,12 @@ --enemies local enemiesAmount = GetNumArenaOpponentSpecs and GetNumArenaOpponentSpecs() or 5 - Details:Destroy(_detalhes.arena_enemies) + Details:Destroy(Details.arena_enemies) for i = 1, enemiesAmount do local enemyName = Details:GetFullName("arena" .. i) if (enemyName) then - _detalhes.arena_enemies[enemyName] = "arena" .. i + Details.arena_enemies[enemyName] = "arena" .. i end end end @@ -933,21 +899,21 @@ --attempt to get the arena unitId for an actor --this function is called from containerActors while reading the actor flag and parser when managing deathlog function Details:GuessArenaEnemyUnitId(unitName) - for i = 1, 5 do - local unitId = "arena" .. i + for i = 1, #Details222.UnitIdCache.Arena do + local unitId = Details222.UnitIdCache.Arena[i] local enemyName = Details:GetFullName(unitId) if (enemyName == unitName) then - _detalhes.arena_enemies[enemyName] = unitId + Details.arena_enemies[enemyName] = unitId return unitId end end end local string_arena_enemyteam_damage = [[ - local combat = Details:GetCombat("current") + local combat = Details:GetCurrentCombat() local total = 0 - for _, actor in combat[1]:ListActors() do + for _, actor in combat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do if (actor.arena_enemy) then total = total + actor.total end @@ -957,10 +923,10 @@ ]] local string_arena_myteam_damage = [[ - local combat = Details:GetCombat("current") + local combat = Details:GetCurrentCombat() local total = 0 - for _, actor in combat[1]:ListActors() do + for _, actor in combat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do if (actor.arena_ally) then total = total + actor.total end @@ -970,10 +936,10 @@ ]] local string_arena_enemyteam_heal = [[ - local combat = Details:GetCombat("current") + local combat = Details:GetCurrentCombat() local total = 0 - for _, actor in combat[2]:ListActors() do + for _, actor in combat:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do if (actor.arena_enemy) then total = total + actor.total end @@ -983,10 +949,10 @@ ]] local string_arena_myteam_heal = [[ - local combat = Details:GetCombat("current") + local combat = Details:GetCurrentCombat() local total = 0 - for _, actor in combat[2]:ListActors() do + for _, actor in combat:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do if (actor.arena_ally) then total = total + actor.total end @@ -1005,21 +971,23 @@ Details:SairDoCombate() end - --registra os gr�ficos - Details:TimeDataRegister ("Your Team Damage", string_arena_myteam_damage, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) - Details:TimeDataRegister ("Enemy Team Damage", string_arena_enemyteam_damage, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) + --register chart data + Details:TimeDataRegister("Your Team Damage", string_arena_myteam_damage, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) + Details:TimeDataRegister("Enemy Team Damage", string_arena_enemyteam_damage, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) - Details:TimeDataRegister ("Your Team Healing", string_arena_myteam_heal, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) - Details:TimeDataRegister ("Enemy Team Healing", string_arena_enemyteam_heal, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) + Details:TimeDataRegister("Your Team Healing", string_arena_myteam_heal, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) + Details:TimeDataRegister("Enemy Team Healing", string_arena_enemyteam_heal, nil, "Details!", "v1.0", [[Interface\ICONS\Ability_DualWield]], true, true) Details.lastArenaStartTime = GetTime() - --inicia um novo combate - Details:EntrarEmCombate() + Details222.StartCombat() - --sinaliza que esse combate � arena - Details.tabela_vigente.arena = true - Details.tabela_vigente.is_arena = {name = Details.zone_name, zone = Details.zone_name, mapid = Details.zone_id} + ---@type combat + local currentCombat = Details:GetCurrentCombat() + + --set this combat as an arena segment type + currentCombat.arena = true + currentCombat.is_arena = {name = Details.zone_name, zone = Details.zone_name, mapid = Details.zone_id} Details:SendEvent("COMBAT_ARENA_START") @@ -1050,10 +1018,9 @@ if (Details.start_arena) then Details:CancelTimer(Details.start_arena, true) end + Details.start_arena = Details:ScheduleTimer("CreateArenaSegment", timeSeconds) Details:GetPlayersInArena() - - --CHAT_MSG_BG_SYSTEM_NEUTRAL - "The Arena battle has begun!"" end function Details:EnteredInArena() @@ -1078,11 +1045,11 @@ Details:CancelTimer(Details.start_arena, true) end - Details:TimeDataUnregister ("Your Team Damage") - Details:TimeDataUnregister ("Enemy Team Damage") + Details:TimeDataUnregister("Your Team Damage") + Details:TimeDataUnregister("Enemy Team Damage") - Details:TimeDataUnregister ("Your Team Healing") - Details:TimeDataUnregister ("Enemy Team Healing") + Details:TimeDataUnregister("Your Team Healing") + Details:TimeDataUnregister("Enemy Team Healing") Details:SendEvent("COMBAT_ARENA_END") @@ -1090,282 +1057,107 @@ Details:SetWindowUpdateSpeed(Details.update_speed) end - local validSpells = { - [220893] = {class = "ROGUE", spec = 261, maxPercent = 0.075, container = 1, commID = "MISSDATA_ROGUE_SOULRIP"}, - --[11366] = {class = "MAGE", spec = 63, maxPercent = 0.9, container = 1, commID = "MISSDATA_ROGUE_SOULRIP"}, - } - - function Details:CanSendMissData() - if (not IsInRaid() and not IsInGroup()) then - return - end - local _, playerClass = UnitClass("player") - local specIndex = DetailsFramework.GetSpecialization() - local playerSpecID - if (specIndex) then - playerSpecID = DetailsFramework.GetSpecializationInfo(specIndex) - end - - if (playerSpecID and playerClass) then - for spellID, t in pairs(validSpells) do - if (playerClass == t.class and playerSpecID == t.spec) then - Details:SendMissData (spellID, t.container, Details.network.ids [t.commID]) - end - end - end - return false - end - - function Details:SendMissData (spellID, containerType, commID) - local combat = Details.tabela_vigente - if (combat) then - local damageActor = combat (containerType, Details.playername) - if (damageActor) then - local spell = damageActor.spells:GetSpell (spellID) - if (spell) then - local data = { - [1] = containerType, - [2] = spellID, - [3] = spell.total, - [4] = spell.counter - } - - if (Details.debug) then - Details:Msg("(debug) sending miss data packet:", spellID, containerType, commID) - end - - Details:SendRaidOrPartyData (commID, data) - end - end - end - end - - function Details.HandleMissData (playerName, data) - local combat = Details.tabela_vigente - - if (Details.debug) then - Details:Msg("(debug) miss data received from:", playerName, "spellID:", data [2], data [3], data [4]) - end - - if (combat) then - local containerType = data[1] - if (type(containerType) ~= "number" or containerType < 1 or containerType > 4) then - return - end - - local damageActor = combat (containerType, playerName) - if (damageActor) then - local spellID = data[2] --a spellID has been passed? - if (not spellID or type(spellID) ~= "number") then - return - end - - local validateSpell = validSpells [spellID] - if (not validateSpell) then --is a valid spell? - return - end - - --does the target player fit in the spell requirement on OUR end? - local class, spec, maxPercent = validateSpell.class, validateSpell.spec, validateSpell.maxPercent - if (class ~= damageActor.classe or spec ~= damageActor.spec) then - return - end - - local total, counter = data[3], data[4] - if (type(total) ~= "number" or type(counter) ~= "number") then - return - end - - if (total > (damageActor.total * maxPercent)) then - return - end - - local spellObject = damageActor.spells:PegaHabilidade (spellID, true) - if (spellObject) then - if (spellObject.total < total and total > 0 and damageActor.nome ~= Details.playername) then - local difference = total - spellObject.total - if (difference > 0) then - spellObject.total = total - spellObject.counter = counter - damageActor.total = damageActor.total + difference - - combat [containerType].need_refresh = true - - if (Details.debug) then - Details:Msg("(debug) miss data successful added from:", playerName, data [2], "difference:", difference) - end - end - end - end - end - end - end - - function Details:MakeEqualizeOnActor (player, realm, receivedActor) - if (true) then --disabled for testing - return - end - end - - function Details:EqualizeActorsSchedule(host_of) - --store pets sent through 'needpetowner' - Details.sent_pets = Details.sent_pets or {n = time()} - if (Details.sent_pets.n+20 < time()) then - Details:Destroy(Details.sent_pets) - Details.sent_pets.n = time() - end - - --do not equilize if there is any disabled capture - --if (Details:CaptureIsAllEnabled()) then - Details:ScheduleTimer("EqualizeActors", 2+math.random()+math.random() , host_of) - --end - end - - function Details:EqualizeActors (host_of) - - --Disabling the sync. Since WoD combatlog are sent between player on phased zones during encounters. - if (not host_of or true) then --full disabled for testing - return - end - - if (Details.debug) then - Details:Msg("(debug) sending equilize actor data") - end - - local damage, heal, energy, misc - - if (host_of) then - damage, heal, energy, misc = Details:GetAllActors("current", host_of) - else - damage, heal, energy, misc = Details:GetAllActors("current", Details.playername) - end - - if (damage) then - damage = {damage.total or 0, damage.damage_taken or 0, damage.friendlyfire_total or 0} - else - damage = {0, 0, 0} - end - - if (heal) then - heal = {heal.total or 0, heal.totalover or 0, heal.healing_taken or 0} - else - heal = {0, 0, 0} - end - - if (energy) then - energy = {energy.mana or 0, energy.e_rage or 0, energy.e_energy or 0, energy.runepower or 0} - else - energy = {0, 0, 0, 0} - end - - if (misc) then - misc = {misc.interrupt or 0, misc.dispell or 0} - else - misc = {0, 0} - end - - local data = {damage, heal, energy, misc} - - --envia os dados do proprio host pra ele antes - if (host_of) then - Details:SendRaidDataAs (Details.network.ids.CLOUD_EQUALIZE, host_of, nil, data) - Details:EqualizeActors() - else - Details:SendRaidData (Details.network.ids.CLOUD_EQUALIZE, data) - end - - end - function Details:FlagActorsOnPvPCombat() - for class_type, container in ipairs(Details.tabela_vigente) do - for _, actor in ipairs(container._ActorTable) do - actor.pvp_component = true + ---@type combat + local currentCombat = Details:GetCurrentCombat() + for containerId = 1, 4 do + ---@type actorcontainer + local container = currentCombat:GetContainer(containerId) + for _, actorObject in container:ListActors() do + actorObject.pvp_component = true end end end function Details:FlagActorsOnBossFight() - for class_type, container in ipairs(Details.tabela_vigente) do - for _, actor in ipairs(container._ActorTable) do - actor.boss_fight_component = true + ---@type combat + local currentCombat = Details:GetCurrentCombat() + for containerId = 1, 4 do + ---@type actorcontainer + local container = currentCombat:GetContainer(containerId) + for _, actorObject in container:ListActors() do + actorObject.boss_fight_component = true end end end - local fight_component = function(energy_container, misc_container, name) - local on_energy = energy_container._ActorTable [energy_container._NameIndexTable [name]] - if (on_energy) then - on_energy.fight_component = true + local findAndMarkActorAsFightComponent = function(resourceContainer, utilityContainer, actorName) + local resourceActor = resourceContainer:GetActor(actorName) + if (resourceActor) then + resourceActor.fight_component = true end - local on_misc = misc_container._ActorTable [misc_container._NameIndexTable [name]] - if (on_misc) then - on_misc.fight_component = true + + local utilityActor = utilityContainer:GetActor(actorName) + if (utilityActor) then + utilityActor.fight_component = true end end function Details:FlagActorsOnCommonFight() + ---@type combat local currentCombat = Details:GetCurrentCombat() - local damage_container = currentCombat[1] - local healing_container = currentCombat[2] - local energy_container = currentCombat[3] - local misc_container = currentCombat[4] + local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + local healContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL) + local resourceContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_ENERGY) + local utilityContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_MISC) local mythicDungeonRun = currentCombat.is_mythic_dungeon_segment - for class_type, container in ipairs({damage_container, healing_container}) do - - for _, actor in ipairs(container._ActorTable) do - + for classType, actorContainer in ipairs({damageContainer, healContainer}) do + for _, actor in actorContainer:ListActors() do if (mythicDungeonRun) then actor.fight_component = true end - if (actor.grupo) then - if (class_type == 1 or class_type == 2) then - for target_name, amount in pairs(actor.targets) do - local target_object = container._ActorTable [container._NameIndexTable [target_name]] - if (target_object) then - target_object.fight_component = true - fight_component (energy_container, misc_container, target_name) + if (actor:IsGroupPlayer()) then + if (classType == DETAILS_ATTRIBUTE_DAMAGE or classType == DETAILS_ATTRIBUTE_HEAL) then + for targetName, amount in pairs(actor.targets) do + local targetObject = actorContainer:GetActor(targetName) + if (targetObject) then + targetObject.fight_component = true + findAndMarkActorAsFightComponent(resourceContainer, utilityContainer, targetName) end end - if (class_type == 1) then - for damager_actor, _ in pairs(actor.damage_from) do - local target_object = container._ActorTable [container._NameIndexTable [damager_actor]] - if (target_object) then - target_object.fight_component = true - fight_component (energy_container, misc_container, damager_actor) + + if (classType == DETAILS_ATTRIBUTE_DAMAGE) then + for damagerName in pairs(actor.damage_from) do + local targetObject = actorContainer:GetActor(damagerName) + if (targetObject) then + targetObject.fight_component = true + findAndMarkActorAsFightComponent(resourceContainer, utilityContainer, damagerName) end end - elseif (class_type == 2) then - for healer_actor, _ in pairs(actor.healing_from) do - local target_object = container._ActorTable [container._NameIndexTable [healer_actor]] - if (target_object) then - target_object.fight_component = true - fight_component (energy_container, misc_container, healer_actor) + + elseif (classType == DETAILS_ATTRIBUTE_HEAL) then + for healerName in pairs(actor.healing_from) do + local targetObject = actorContainer:GetActor(healerName) + if (targetObject) then + targetObject.fight_component = true + findAndMarkActorAsFightComponent(resourceContainer, utilityContainer, healerName) end end end end end end - end end - function Details:AtualizarJanela (instancia, _segmento) - if (_segmento) then --apenas atualizar janelas que estejam mostrando o segmento solicitado - if (_segmento == instancia.segmento) then - instancia:TrocaTabela(instancia, instancia.segmento, instancia.atributo, instancia.sub_atributo, true) + function Details:UpdateWindow(instance, segmentId) + if (segmentId) then + if (segmentId == instance.segmento) then + local displayId, subDisplayId = instance:GetDisplay() + instance:TrocaTabela(instance, instance:GetSegment(), displayId, subDisplayId, true) end else - if (instancia.modo == groupMode or instancia.modo == everythingMode) then - instancia:TrocaTabela(instancia, instancia.segmento, instancia.atributo, instancia.sub_atributo, true) + if (instance.modo == groupMode or instance.modo == everythingMode) then + local displayId, subDisplayId = instance:GetDisplay() + instance:TrocaTabela(instance, instance:GetSegment(), displayId, subDisplayId, true) end end end - function Details:PostponeInstanceToCurrent (instance) + function Details:PostponeInstanceToCurrent(instance) if ( not instance.last_interaction or ( @@ -1377,7 +1169,7 @@ ) then instance._postponing_current = nil if (instance.segmento == 0) then - return Details:TrocaSegmentoAtual (instance) + return Details:TrocaSegmentoAtual(instance) else return end @@ -1388,55 +1180,57 @@ instance._postponing_current = Details:ScheduleTimer("PostponeInstanceToCurrent", 1, instance) end - function Details:TrocaSegmentoAtual (instancia, is_encounter) - if (instancia.segmento == 0 and instancia.baseframe and instancia.ativa) then + function Details:TrocaSegmentoAtual(instance, bIsEncounter) + if (instance.segmento == 0 and instance.baseframe and instance.ativa) then - if (not is_encounter) then - if (instancia.is_interacting) then - if (not instancia.last_interaction or instancia.last_interaction < _tempo) then - instancia.last_interaction = _tempo or time() + if (not bIsEncounter) then + if (instance.is_interacting) then + if (not instance.last_interaction or instance.last_interaction < _tempo) then + instance.last_interaction = _tempo or time() end end - if ((instancia.last_interaction and (instancia.last_interaction+3 > Details._tempo)) or (DetailsReportWindow and DetailsReportWindow:IsShown()) or (Details.BreakdownWindowFrame:IsShown())) then + if ((instance.last_interaction and (instance.last_interaction+3 > Details._tempo)) or (DetailsReportWindow and DetailsReportWindow:IsShown()) or (Details.BreakdownWindowFrame:IsShown())) then --postpone - instancia._postponing_current = Details:ScheduleTimer("PostponeInstanceToCurrent", 1, instancia) + instance._postponing_current = Details:ScheduleTimer("PostponeInstanceToCurrent", 1, instance) return end end - --print("==> Changing the Segment now! - control.lua 1220") - - instancia.last_interaction = _tempo - 4 --pode setar, completou o ciclo - instancia._postponing_current = nil - instancia.showing = Details.tabela_vigente - instancia:ResetaGump() - Details.FadeHandler.Fader(instancia, "in", nil, "barras") + instance.last_interaction = _tempo - 4 --pode setar, completou o ciclo + instance._postponing_current = nil + instance.showing = Details.tabela_vigente + instance:ResetaGump() + Details.FadeHandler.Fader(instance, "in", nil, "barras") end end - function Details:SetTrashSuppression (n) + function Details:SetTrashSuppression(n) assert(type(n) == "number", "SetTrashSuppression expects a number on index 1.") if (n < 0) then n = 0 end Details.instances_suppress_trash = n end + function Details:CheckFor_SuppressedWindowsOnEncounterFound() for _, instance in Details:ListInstances() do if (instance.ativa and instance.baseframe and (not instance.last_interaction or instance.last_interaction > _tempo) and instance.segmento == 0) then - Details:TrocaSegmentoAtual (instance, true) + Details:TrocaSegmentoAtual(instance, true) end end end + function Details:CheckFor_EnabledTrashSuppression() if (Details.HasTrashSuppression and Details.HasTrashSuppression > _tempo) then self.last_interaction = Details.HasTrashSuppression end end + function Details:SetTrashSuppressionAfterEncounter() Details:InstanceCall("CheckFor_EnabledTrashSuppression") end + function Details:CheckFor_TrashSuppressionOnEncounterEnd() if (Details.instances_suppress_trash > 0) then Details.HasTrashSuppression = _tempo + Details.instances_suppress_trash @@ -1467,8 +1261,8 @@ local avatarTextColor = {1, 1, 1, 1} function Details:AddTooltipReportLineText() - GameCooltip:AddLine (Loc ["STRING_CLICK_REPORT_LINE1"], Loc ["STRING_CLICK_REPORT_LINE2"]) - GameCooltip:AddStatusBar (100, 1, 0, 0, 0, 0.8) + GameCooltip:AddLine(Loc ["STRING_CLICK_REPORT_LINE1"], Loc ["STRING_CLICK_REPORT_LINE2"]) + GameCooltip:AddStatusBar(100, 1, 0, 0, 0, 0.8) end function Details:AddTooltipBackgroundStatusbar(side, value, useSpark, statusBarColor) @@ -1507,22 +1301,22 @@ r, g, b, a = detailsFramework:ParseColors(statusBarColor) end local rBG, gBG, bBG, aBG = unpack(Details.tooltip.background) - GameCooltip:AddStatusBar (value, 1, r, g, b, a, useSpark, {value = 100, color = {rBG, gBG, bBG, aBG}, texture = [[Interface\AddOns\Details\images\bar_serenity]]}) + GameCooltip:AddStatusBar(value, 1, r, g, b, a, useSpark, {value = 100, color = {rBG, gBG, bBG, aBG}, texture = [[Interface\AddOns\Details\images\bar_serenity]]}) else - GameCooltip:AddStatusBar (value, 2, unpack(Details.tooltip.bar_color)) + GameCooltip:AddStatusBar(value, 2, unpack(Details.tooltip.bar_color)) end end - function Details:AddTooltipHeaderStatusbar (r, g, b, a) + function Details:AddTooltipHeaderStatusbar(r, g, b, a) local r, g, b, a, statusbarGlow, backgroundBar = unpack(Details.tooltip.header_statusbar) - GameCooltip:AddStatusBar (100, 1, r, g, b, a, statusbarGlow, backgroundBar, "Skyline") + GameCooltip:AddStatusBar(100, 1, r, g, b, a, statusbarGlow, backgroundBar, "Skyline") end -- /run local a,b=Details.tooltip.header_statusbar,0.3;a[1]=b;a[2]=b;a[3]=b;a[4]=0.8; function Details:AddTooltipSpellHeaderText(headerText, headerColor, amount, iconTexture, L, R, T, B, separator, iconSize) if (separator and separator == true) then - GameCooltip:AddLine ("", "", nil, nil, 1, 1, 1, 1, 8) + GameCooltip:AddLine("", "", nil, nil, 1, 1, 1, 1, 8) return end @@ -1531,13 +1325,13 @@ end if (Details.tooltip.show_amount) then - GameCooltip:AddLine (headerText, "x" .. amount .. "", nil, headerColor, 1, 1, 1, .4, Details.tooltip.fontsize_title) + GameCooltip:AddLine(headerText, "x" .. amount .. "", nil, headerColor, 1, 1, 1, .4, Details.tooltip.fontsize_title) else - GameCooltip:AddLine (headerText, nil, nil, headerColor, nil, Details.tooltip.fontsize_title) + GameCooltip:AddLine(headerText, nil, nil, headerColor, nil, Details.tooltip.fontsize_title) end if (iconTexture) then - GameCooltip:AddIcon (iconTexture, 1, 1, iconSize, iconSize, L or 0, R or 1, T or 0, B or 1) + GameCooltip:AddIcon(iconTexture, 1, 1, iconSize, iconSize, L or 0, R or 1, T or 0, B or 1) end end @@ -1573,7 +1367,7 @@ function Details:BuildInstanceBarTooltip(frame) local GameCooltip = GameCooltip Details:FormatCooltipForSpells() - GameCooltip:SetOption("MinWidth", _math_max(230, self.baseframe:GetWidth()*0.98)) + GameCooltip:SetOption("MinWidth", max(230, self.baseframe:GetWidth()*0.98)) local myPoint = Details.tooltip.anchor_point local anchorPoint = Details.tooltip.anchor_relative @@ -1718,19 +1512,19 @@ --local startTime = debugprofilestop() if (self.atributo == 1) then --damage - --[[return]] atributo_damage:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) + --[[return]] damageClass:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) elseif (self.atributo == 2) then --heal - --[[return]] atributo_heal:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) + --[[return]] healingClass:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) elseif (self.atributo == 3) then --energy - --[[return]] atributo_energy:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) + --[[return]] resourceClass:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) elseif (self.atributo == 4) then --outros - --[[return]] atributo_misc:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) + --[[return]] utilityClass:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) elseif (self.atributo == 5) then --ocustom - --[[return]] atributo_custom:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) + --[[return]] customClass:RefreshWindow(self, combatObject, bForceRefresh, nil, needRefresh) end --[[if (Details222.Perf.WindowUpdateC) then @@ -1833,22 +1627,22 @@ --core function Details:AutoEraseConfirm() - local panel = _G.DetailsEraseDataConfirmation - if (not panel) then - panel = CreateFrame("frame", "DetailsEraseDataConfirmation", UIParent, "BackdropTemplate") - panel:SetSize(400, 85) - panel:SetPoint("center", UIParent) + local dataEraseConfirmationFrame = _G.DetailsEraseDataConfirmation + if (not dataEraseConfirmationFrame) then + dataEraseConfirmationFrame = CreateFrame("frame", "DetailsEraseDataConfirmation", UIParent, "BackdropTemplate") + dataEraseConfirmationFrame:SetSize(400, 85) + dataEraseConfirmationFrame:SetPoint("center", UIParent) - DetailsFramework:AddRoundedCornersToFrame(panel, Details.PlayerBreakdown.RoundedCornerPreset) + DetailsFramework:AddRoundedCornersToFrame(dataEraseConfirmationFrame, Details.PlayerBreakdown.RoundedCornerPreset) local LibWindow = LibStub("LibWindow-1.1") - LibWindow.RegisterConfig(panel, Details.ask_to_erase_frame) - LibWindow.MakeDraggable(panel) - LibWindow.RestorePosition(panel) + LibWindow.RegisterConfig(dataEraseConfirmationFrame, Details.ask_to_erase_frame) + LibWindow.MakeDraggable(dataEraseConfirmationFrame) + LibWindow.RestorePosition(dataEraseConfirmationFrame) - panel:SetScript("OnMouseDown", function(self, button) + dataEraseConfirmationFrame:SetScript("OnMouseDown", function(self, button) if (button == "RightButton") then - panel:Hide() + dataEraseConfirmationFrame:Hide() end end) @@ -1859,20 +1653,18 @@ - both --]=] - local text = Details.gump:CreateLabel(panel, Loc ["STRING_OPTIONS_CONFIRM_ERASE"], nil, nil, "GameFontNormal") - text:SetPoint("center", panel, "center") - text:SetPoint("top", panel, "top", 0, -10) + local text = detailsFramework:CreateLabel(dataEraseConfirmationFrame, Loc ["STRING_OPTIONS_CONFIRM_ERASE"], nil, nil, "GameFontNormal") + text:SetPoint("center", dataEraseConfirmationFrame, "center") + text:SetPoint("top", dataEraseConfirmationFrame, "top", 0, -10) - local no = Details.gump:CreateButton(panel, function() panel:Hide() end, 90, 20, Loc ["STRING_NO"]) - no:SetPoint("bottomleft", panel, "bottomleft", 30, 10) - no:InstallCustomTexture(nil, nil, nil, nil, true) + local noButton = detailsFramework:CreateButton(dataEraseConfirmationFrame, function() dataEraseConfirmationFrame:Hide() end, 90, 20, Loc ["STRING_NO"]) + noButton:SetPoint("bottomleft", dataEraseConfirmationFrame, "bottomleft", 30, 10) - local yes = Details.gump:CreateButton(panel, function() panel:Hide(); Details.tabela_historico:ResetAllCombatData() end, 90, 20, Loc ["STRING_YES"]) - yes:SetPoint("bottomright", panel, "bottomright", -30, 10) - yes:InstallCustomTexture(nil, nil, nil, nil, true) + local yesButton = detailsFramework:CreateButton(dataEraseConfirmationFrame, function() dataEraseConfirmationFrame:Hide(); Details:ResetSegmentData() end, 90, 20, Loc ["STRING_YES"]) + yesButton:SetPoint("bottomright", dataEraseConfirmationFrame, "bottomright", -30, 10) end - panel:Show() + dataEraseConfirmationFrame:Show() end function Details:CheckForAutoErase(mapId) @@ -1885,7 +1677,7 @@ elseif (Details.segments_auto_erase == 3) then --erase C_Timer.After(2, function() - Details.tabela_historico:ResetAllCombatData() + Details:ResetSegmentData() end) end else @@ -1895,7 +1687,7 @@ Details:ScheduleTimer("AutoEraseConfirm", 1) elseif (Details.segments_auto_erase == 3) then --erase - Details.tabela_historico:ResetAllCombatData() + Details:ResetSegmentData() end end end diff --git a/core/gears.lua b/core/gears.lua index 3dff2082..e09ad4cd 100644 --- a/core/gears.lua +++ b/core/gears.lua @@ -1,180 +1,183 @@ -local _detalhes = _G.Details + +local Details = _G.Details local addonName, Details222 = ... -local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) +local Loc = LibStub("AceLocale-3.0"):GetLocale( "Details" ) +local _ local UnitGUID = UnitGUID local UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned -local select = select -local floor = floor local GetNumGroupMembers = GetNumGroupMembers local GetSpellInfo = Details222.GetSpellInfo +local select = select +local floor = floor local CONST_INSPECT_ACHIEVEMENT_DISTANCE = 1 --Compare Achievements, 28 yards local CONST_SPELLBOOK_GENERAL_TABID = 1 local CONST_SPELLBOOK_CLASSSPELLS_TABID = 2 local storageDebug = false --remember to turn this to false! -local instancesToStoreData = _detalhes.InstancesToStoreData +local instancesToStoreData = Details.InstancesToStoreData -function _detalhes:UpdateGears() - _detalhes:UpdateParser() - _detalhes:UpdateControl() - _detalhes:UpdateCombat() -end - -function _detalhes:GetCoreVersion() - return _detalhes.realversion +function Details:UpdateGears() + Details:UpdateParser() + Details:UpdateControl() + Details:UpdateCombat() end ------------------------------------------------------------------------------------------------------------ --chat hooks - _detalhes.chat_embed = _detalhes:CreateEventListener() - _detalhes.chat_embed.startup = true + Details.chat_embed = Details:CreateEventListener() + Details.chat_embed.startup = true - _detalhes.chat_embed.hook_settabname = function(frame, name, doNotSave) + Details.chat_embed.hook_settabname = function(frame, name, doNotSave) if (not doNotSave) then - if (_detalhes.chat_tab_embed.enabled and _detalhes.chat_tab_embed.tab_name ~= "") then - if (_detalhes.chat_tab_embed_onframe == frame) then - _detalhes.chat_tab_embed.tab_name = name - _detalhes:DelayOptionsRefresh (_detalhes:GetInstance(1)) + if (Details.chat_tab_embed.enabled and Details.chat_tab_embed.tab_name ~= "") then + if (Details.chat_tab_embed_onframe == frame) then + Details.chat_tab_embed.tab_name = name + Details:DelayOptionsRefresh(Details:GetInstance(1)) end end end end - _detalhes.chat_embed.hook_closetab = function(frame, fallback) - if (_detalhes.chat_tab_embed.enabled and _detalhes.chat_tab_embed.tab_name ~= "") then - if (_detalhes.chat_tab_embed_onframe == frame) then - _detalhes.chat_tab_embed.enabled = false - _detalhes.chat_tab_embed.tab_name = "" - _detalhes.chat_tab_embed_onframe = nil - _detalhes:DelayOptionsRefresh (_detalhes:GetInstance(1)) - _detalhes.chat_embed:ReleaseEmbed() + + Details.chat_embed.hook_closetab = function(frame, fallback) + if (Details.chat_tab_embed.enabled and Details.chat_tab_embed.tab_name ~= "") then + if (Details.chat_tab_embed_onframe == frame) then + Details.chat_tab_embed.enabled = false + Details.chat_tab_embed.tab_name = "" + Details.chat_tab_embed_onframe = nil + Details:DelayOptionsRefresh(Details:GetInstance(1)) + Details.chat_embed:ReleaseEmbed() end end end - hooksecurefunc ("FCF_SetWindowName", _detalhes.chat_embed.hook_settabname) - hooksecurefunc ("FCF_Close", _detalhes.chat_embed.hook_closetab) - function _detalhes.chat_embed:SetTabSettings (tab_name, is_enabled, is_single) + hooksecurefunc("FCF_SetWindowName", Details.chat_embed.hook_settabname) + hooksecurefunc("FCF_Close", Details.chat_embed.hook_closetab) - local current_enabled_state = _detalhes.chat_tab_embed.enabled - local current_name = _detalhes.chat_tab_embed.tab_name - local current_is_single = _detalhes.chat_tab_embed.single_window + function Details.chat_embed:SetTabSettings(tab_name, bNewStateEnabled, is_single) + local current_enabled_state = Details.chat_tab_embed.enabled + local current_name = Details.chat_tab_embed.tab_name + local current_is_single = Details.chat_tab_embed.single_window - tab_name = tab_name or _detalhes.chat_tab_embed.tab_name - if (is_enabled == nil) then - is_enabled = _detalhes.chat_tab_embed.enabled + tab_name = tab_name or Details.chat_tab_embed.tab_name + if (bNewStateEnabled == nil) then + bNewStateEnabled = Details.chat_tab_embed.enabled end if (is_single == nil) then - is_single = _detalhes.chat_tab_embed.single_window + is_single = Details.chat_tab_embed.single_window end - _detalhes.chat_tab_embed.tab_name = tab_name or "" - _detalhes.chat_tab_embed.enabled = is_enabled - _detalhes.chat_tab_embed.single_window = is_single + Details.chat_tab_embed.tab_name = tab_name or "" + Details.chat_tab_embed.enabled = bNewStateEnabled + Details.chat_tab_embed.single_window = is_single if (current_name ~= tab_name) then --rename the tab on chat frame - local ChatFrame = _detalhes.chat_embed:GetTab (current_name) + local ChatFrame = Details.chat_embed:GetTab(current_name) if (ChatFrame) then - FCF_SetWindowName (ChatFrame, tab_name, false) + FCF_SetWindowName(ChatFrame, tab_name, false) end end - if (is_enabled) then + if (bNewStateEnabled) then --was disabled, so we need to save the current window positions. if (not current_enabled_state) then - local window1 = _detalhes:GetInstance(1) + local window1 = Details:GetInstance(1) if (window1) then window1:SaveMainWindowPosition() if (window1.libwindow) then local pos = window1:CreatePositionTable() - _detalhes.chat_tab_embed.w1_pos = pos + Details.chat_tab_embed.w1_pos = pos end end - local window2 = _detalhes:GetInstance(2) + + local window2 = Details:GetInstance(2) if (window2) then window2:SaveMainWindowPosition() if (window2.libwindow) then local pos = window2:CreatePositionTable() - _detalhes.chat_tab_embed.w2_pos = pos + Details.chat_tab_embed.w2_pos = pos end end + elseif (not is_single and current_is_single) then - local window2 = _detalhes:GetInstance(2) + local window2 = Details:GetInstance(2) if (window2) then window2:SaveMainWindowPosition() if (window2.libwindow) then local pos = window2:CreatePositionTable() - _detalhes.chat_tab_embed.w2_pos = pos + Details.chat_tab_embed.w2_pos = pos end end end --need to make the embed - _detalhes.chat_embed:DoEmbed() + Details.chat_embed:DoEmbed() else --need to release the frame if (current_enabled_state) then - _detalhes.chat_embed:ReleaseEmbed() + Details.chat_embed:ReleaseEmbed() end end end - function _detalhes.chat_embed:CheckChatEmbed (is_startup) - if (_detalhes.chat_tab_embed.enabled) then - _detalhes.chat_embed:DoEmbed (is_startup) + function Details.chat_embed:CheckChatEmbed(bIsStartup) + if (Details.chat_tab_embed.enabled) then + Details.chat_embed:DoEmbed(bIsStartup) end end - --dom --- /run _detalhes.chat_embed:SetTabSettings ("Dano", true, false) --- /run _detalhes.chat_embed:SetTabSettings (nil, false, false) +--debug +-- /run _detalhes.chat_embed:SetTabSettings("Dano", true, false) +-- /run _detalhes.chat_embed:SetTabSettings(nil, false, false) -- /dump _detalhes.chat_tab_embed.tab_name - function _detalhes.chat_embed:DelayedChatEmbed (is_startup) - _detalhes.chat_embed.startup = nil - _detalhes.chat_embed:DoEmbed() + function Details.chat_embed:DelayedChatEmbed() + Details.chat_embed.startup = nil + Details.chat_embed:DoEmbed() end - function _detalhes.chat_embed:DoEmbed (is_startup) - if (_detalhes.chat_embed.startup and not is_startup) then - if (_detalhes.AddOnStartTime + 5 < GetTime()) then - _detalhes.chat_embed.startup = nil + function Details.chat_embed:DoEmbed(bIsStartup) + if (Details.chat_embed.startup and not bIsStartup) then + if (Details.AddOnStartTime + 5 < GetTime()) then + Details.chat_embed.startup = nil else return end end - if (is_startup) then - return _detalhes.chat_embed:ScheduleTimer("DelayedChatEmbed", 5) + + if (bIsStartup) then + return Details.chat_embed:ScheduleTimer("DelayedChatEmbed", 5) end - local tabname = _detalhes.chat_tab_embed.tab_name - if (_detalhes.chat_tab_embed.enabled and tabname ~= "") then - local ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname) + local tabname = Details.chat_tab_embed.tab_name - if (not ChatFrame) then - FCF_OpenNewWindow (tabname) - ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname) + if (Details.chat_tab_embed.enabled and tabname ~= "") then + local chatFrame, chatFrameTab, chatFrameBackground = Details.chat_embed:GetTab(tabname) + + if (not chatFrame) then + FCF_OpenNewWindow(tabname) + chatFrame, chatFrameTab, chatFrameBackground = Details.chat_embed:GetTab(tabname) end - if (ChatFrame) then - for index, t in pairs(ChatFrame.messageTypeList) do - ChatFrame_RemoveMessageGroup (ChatFrame, t) - ChatFrame.messageTypeList [index] = nil + if (chatFrame) then + for index, t in pairs(chatFrame.messageTypeList) do + ChatFrame_RemoveMessageGroup(chatFrame, t) + chatFrame.messageTypeList [index] = nil end - _detalhes.chat_tab_embed_onframe = ChatFrame + Details.chat_tab_embed_onframe = chatFrame - if (_detalhes.chat_tab_embed.single_window) then + if (Details.chat_tab_embed.single_window) then --only one window - local window1 = _detalhes:GetInstance(1) + local window1 = Details:GetInstance(1) window1:UngroupInstance() window1.baseframe:ClearAllPoints() - window1.baseframe:SetParent(ChatFrame) + window1.baseframe:SetParent(chatFrame) window1.rowframe:SetParent(window1.baseframe) window1.rowframe:ClearAllPoints() @@ -184,29 +187,28 @@ end window1.windowSwitchButton:ClearAllPoints() window1.windowSwitchButton:SetAllPoints() - local y_up = window1.toolbar_side == 1 and -20 or 0 - local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) + local topOffset = window1.toolbar_side == 1 and -20 or 0 + local bottomOffset =(window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) - window1.baseframe:SetPoint("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset) - window1.baseframe:SetPoint("bottomright", ChatFrameBackground, "bottomright", _detalhes.chat_tab_embed.x_offset, y_down) + window1.baseframe:SetPoint("topleft", chatFrameBackground, "topleft", 0, topOffset + Details.chat_tab_embed.y_offset) + window1.baseframe:SetPoint("bottomright", chatFrameBackground, "bottomright", Details.chat_tab_embed.x_offset, bottomOffset) - window1:LockInstance (true) + window1:LockInstance(true) window1:SaveMainWindowPosition() - local window2 = _detalhes:GetInstance(2) + local window2 = Details:GetInstance(2) if (window2 and window2.baseframe) then - if (window2.baseframe:GetParent() == ChatFrame) then + if (window2.baseframe:GetParent() == chatFrame) then --need to detach - _detalhes.chat_embed:ReleaseEmbed (true) + Details.chat_embed:ReleaseEmbed(true) end end - else --window #1 and #2 - local window1 = _detalhes:GetInstance(1) - local window2 = _detalhes:GetInstance(2) + local window1 = Details:GetInstance(1) + local window2 = Details:GetInstance(2) if (not window2) then - window2 = _detalhes:CriarInstancia() + window2 = Details:CriarInstancia() end window1:UngroupInstance() @@ -214,8 +216,8 @@ end window1.baseframe:ClearAllPoints() window2.baseframe:ClearAllPoints() - window1.baseframe:SetParent(ChatFrame) - window2.baseframe:SetParent(ChatFrame) + window1.baseframe:SetParent(chatFrame) + window2.baseframe:SetParent(chatFrame) window1.rowframe:SetParent(window1.baseframe) window2.rowframe:SetParent(window2.baseframe) @@ -226,44 +228,44 @@ end window2.windowSwitchButton:ClearAllPoints() window2.windowSwitchButton:SetAllPoints() - window1:LockInstance (true) - window2:LockInstance (true) + window1:LockInstance(true) + window2:LockInstance(true) local statusbar_enabled1 = window1.show_statusbar local statusbar_enabled2 = window2.show_statusbar Details:Destroy(window1.snap) Details:Destroy(window2.snap) - window1.snap [3] = 2; window2.snap [1] = 1; + window1.snap[3] = 2; window2.snap[1] = 1; window1.horizontalSnap = true; window2.horizontalSnap = true - local y_up = window1.toolbar_side == 1 and -20 or 0 - local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) + local topOffset = window1.toolbar_side == 1 and -20 or 0 + local bottomOffset = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0) - local width = ChatFrameBackground:GetWidth() / 2 - local height = ChatFrameBackground:GetHeight() - y_down + y_up + local width = chatFrameBackground:GetWidth() / 2 + local height = chatFrameBackground:GetHeight() - bottomOffset + topOffset - window1.baseframe:SetSize(width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset) - window2.baseframe:SetSize(width + (_detalhes.chat_tab_embed.x_offset/2), height + _detalhes.chat_tab_embed.y_offset) + window1.baseframe:SetSize(width +(Details.chat_tab_embed.x_offset/2), height + Details.chat_tab_embed.y_offset) + window2.baseframe:SetSize(width +(Details.chat_tab_embed.x_offset/2), height + Details.chat_tab_embed.y_offset) - window1.baseframe:SetPoint("topleft", ChatFrameBackground, "topleft", 0, y_up + _detalhes.chat_tab_embed.y_offset) - window2.baseframe:SetPoint("topright", ChatFrameBackground, "topright", _detalhes.chat_tab_embed.x_offset, y_up + _detalhes.chat_tab_embed.y_offset) + window1.baseframe:SetPoint("topleft", chatFrameBackground, "topleft", 0, topOffset + Details.chat_tab_embed.y_offset) + window2.baseframe:SetPoint("topright", chatFrameBackground, "topright", Details.chat_tab_embed.x_offset, topOffset + Details.chat_tab_embed.y_offset) window1:SaveMainWindowPosition() window2:SaveMainWindowPosition() - -- /dump ChatFrame3Background:GetSize() + --/dump ChatFrame3Background:GetSize() end end end end - function _detalhes.chat_embed:ReleaseEmbed (second_window) + function Details.chat_embed:ReleaseEmbed(bSecondWindow) --release - local window1 = _detalhes:GetInstance(1) - local window2 = _detalhes:GetInstance(2) + local window1 = Details:GetInstance(1) + local window2 = Details:GetInstance(2) - if (second_window) then + if (bSecondWindow) then window2:UngroupInstance() window2.baseframe:ClearAllPoints() window2.baseframe:SetParent(UIParent) @@ -272,12 +274,12 @@ end window2.windowSwitchButton:SetParent(UIParent) window2.baseframe:SetPoint("center", UIParent, "center", 200, 0) window2.rowframe:SetPoint("center", UIParent, "center", 200, 0) - window2:LockInstance (false) + window2:LockInstance(false) window2:SaveMainWindowPosition() - local previous_pos = _detalhes.chat_tab_embed.w2_pos + local previous_pos = Details.chat_tab_embed.w2_pos if (previous_pos) then - window2:RestorePositionFromPositionTable (previous_pos) + window2:RestorePositionFromPositionTable(previous_pos) end return end @@ -288,16 +290,15 @@ end window1.windowSwitchButton:SetParent(UIParent) window1.baseframe:SetPoint("center", UIParent, "center") window1.rowframe:SetPoint("center", UIParent, "center") - window1:LockInstance (false) + window1:LockInstance(false) window1:SaveMainWindowPosition() - local previous_pos = _detalhes.chat_tab_embed.w1_pos + local previous_pos = Details.chat_tab_embed.w1_pos if (previous_pos) then - window1:RestorePositionFromPositionTable (previous_pos) + window1:RestorePositionFromPositionTable(previous_pos) end - if (not _detalhes.chat_tab_embed.single_window and window2) then - + if (not Details.chat_tab_embed.single_window and window2) then window2:UngroupInstance() window2.baseframe:ClearAllPoints() window2.baseframe:SetParent(UIParent) @@ -305,18 +306,18 @@ end window2.windowSwitchButton:SetParent(UIParent); window2.baseframe:SetPoint("center", UIParent, "center", 200, 0) window2.rowframe:SetPoint("center", UIParent, "center", 200, 0) - window2:LockInstance (false) + window2:LockInstance(false) window2:SaveMainWindowPosition() - local previous_pos = _detalhes.chat_tab_embed.w2_pos - if (previous_pos) then - window2:RestorePositionFromPositionTable (previous_pos) + local previousPos = Details.chat_tab_embed.w2_pos + if (previousPos) then + window2:RestorePositionFromPositionTable(previousPos) end end end - function _detalhes.chat_embed:GetTab (tabname) - tabname = tabname or _detalhes.chat_tab_embed.tab_name + function Details.chat_embed:GetTab(tabname) + tabname = tabname or Details.chat_tab_embed.tab_name for i = 1, 20 do local tabtext = _G ["ChatFrame" .. i .. "Tab"] if (tabtext) then @@ -346,87 +347,102 @@ end ------------------------------------------------------------------------------------------------------------ -function _detalhes:SetDeathLogLimit(limit) - if (limit and type(limit) == "number" and limit >= 8) then - _detalhes.deadlog_events = limit +function Details:SetDeathLogLimit(limitAmount) + if (limitAmount and type(limitAmount) == "number" and limitAmount >= 8) then + Details.deadlog_events = limitAmount local combatObject = Details:GetCurrentCombat() - for player_name, event_table in pairs(combatObject.player_last_events) do - if (limit > #event_table) then - for i = #event_table + 1, limit do - event_table [i] = {} + for playerName, eventTable in pairs(combatObject.player_last_events) do + if (limitAmount > #eventTable) then + for i = #eventTable + 1, limitAmount do + eventTable [i] = {} end else - event_table.n = 1 - for _, t in ipairs(event_table) do + eventTable.n = 1 + for _, t in ipairs(eventTable) do Details:Destroy(t) end end end - _detalhes:UpdateParserGears() + Details:UpdateParserGears() end end ------------------------------------------------------------------------------------------------------------ -function _detalhes:TrackSpecsNow (track_everything) +function Details:TrackSpecsNow(bTrackEverything) + local specSpellList = Details.SpecSpellList + ---@type combat + local currentCombat = Details:GetCurrentCombat() - local spelllist = _detalhes.SpecSpellList - - if (not track_everything) then - for _, actor in _detalhes.tabela_vigente[1]:ListActors() do + if (not bTrackEverything) then + local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) --DETAILS_ATTRIBUTE_DAMAGE is the integer 1, container 1 store damage data + for _, actor in damageContainer:ListActors() do + ---@cast actor actor if (actor:IsPlayer()) then - for spellid, spell in pairs(actor:GetSpellList()) do - if (spelllist [spell.id]) then - actor:SetSpecId(spelllist[spell.id]) - _detalhes.cached_specs [actor.serial] = actor.spec + for spellId, spellTable in pairs(actor:GetSpellList()) do + if (specSpellList[spellTable.id]) then + actor:SetSpecId(specSpellList[spellTable.id]) + Details.cached_specs[actor.serial] = actor.spec break end end end end - for _, actor in _detalhes.tabela_vigente[2]:ListActors() do + local healContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL) --DETAILS_ATTRIBUTE_HEAL is the integer 2, container 2 store heal data + for _, actor in healContainer:ListActors() do + ---@cast actor actor if (actor:IsPlayer()) then - for spellid, spell in pairs(actor:GetSpellList()) do - if (spelllist [spell.id]) then - actor:SetSpecId(spelllist[spell.id]) - _detalhes.cached_specs [actor.serial] = actor.spec + for spellId, spellTable in pairs(actor:GetSpellList()) do + if (specSpellList[spellTable.id]) then + actor:SetSpecId(specSpellList[spellTable.id]) + Details.cached_specs[actor.serial] = actor.spec break end end end end else - local combatlist = {} + ---@type combat[] + local combatList = {} + ---@type combat[] local segmentsTable = Details:GetCombatSegments() - for _, combat in ipairs(segmentsTable) do - tinsert(combatlist, combat) - end - tinsert(combatlist, _detalhes.tabela_vigente) - tinsert(combatlist, _detalhes.tabela_overall) + ---@type combat + local combatOverall = Details:GetOverallCombat() - for _, combat in ipairs(combatlist) do - for _, actor in combat[1]:ListActors() do + for _, combat in ipairs(segmentsTable) do + tinsert(combatList, combat) + end + + tinsert(combatList, currentCombat) + tinsert(combatList, combatOverall) + + for _, combatObject in ipairs(combatList) do + local damageContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + for _, actor in damageContainer:ListActors() do + ---@cast actor actor if (actor:IsPlayer()) then - for spellid, spell in pairs(actor:GetSpellList()) do - if (spelllist [spell.id]) then - actor:SetSpecId(spelllist[spell.id]) - _detalhes.cached_specs [actor.serial] = actor.spec + for spellId, spellTable in pairs(actor:GetSpellList()) do + if (specSpellList[spellTable.id]) then + actor:SetSpecId(specSpellList[spellTable.id]) + Details.cached_specs[actor.serial] = actor.spec break end end end end - for _, actor in combat[2]:ListActors() do + local healContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL) + for _, actor in healContainer:ListActors() do + ---@cast actor actor if (actor:IsPlayer()) then - for spellid, spell in pairs(actor:GetSpellList()) do - if (spelllist [spell.id]) then - actor:SetSpecId(spelllist[spell.id]) - _detalhes.cached_specs [actor.serial] = actor.spec + for spellId, spellTable in pairs(actor:GetSpellList()) do + if (specSpellList[spellTable.id]) then + actor:SetSpecId(specSpellList[spellTable.id]) + Details.cached_specs[actor.serial] = actor.spec break end end @@ -434,51 +450,47 @@ function _detalhes:TrackSpecsNow (track_everything) end end end - end -function _detalhes:ResetSpecCache (forced) +function Details:ResetSpecCache(forced) + local bIsInInstance = IsInInstance() - local isininstance = IsInInstance() + if (forced or (not bIsInInstance and not Details.in_group)) then + Details:Destroy(Details.cached_specs) - if (forced or (not isininstance and not _detalhes.in_group)) then - Details:Destroy(_detalhes.cached_specs) - - if (_detalhes.track_specs) then - local my_spec = DetailsFramework.GetSpecialization() - if (type(my_spec) == "number") then - local spec_number = DetailsFramework.GetSpecializationInfo(my_spec) - if (type(spec_number) == "number") then - local pguid = UnitGUID(_detalhes.playername) - if (pguid) then - _detalhes.cached_specs [pguid] = spec_number + if (Details.track_specs) then + local playerSpec = DetailsFramework.GetSpecialization() + if (type(playerSpec) == "number") then + local specId = DetailsFramework.GetSpecializationInfo(playerSpec) + if (type(specId) == "number") then + local playerGuid = UnitGUID(Details.playername) + if (playerGuid) then + Details.cached_specs[playerGuid] = specId end end end end - elseif (_detalhes.in_group and not isininstance) then - Details:Destroy(_detalhes.cached_specs) + elseif (Details.in_group and not bIsInInstance) then + Details:Destroy(Details.cached_specs) - if (_detalhes.track_specs) then + if (Details.track_specs) then if (IsInRaid()) then - local c_combat_dmg = _detalhes.tabela_vigente [1] - local c_combat_heal = _detalhes.tabela_vigente [2] - for i = 1, GetNumGroupMembers(), 1 do - local name = Details:GetFullName("raid" .. i) - local index = c_combat_dmg._NameIndexTable [name] - if (index) then - local actor = c_combat_dmg._ActorTable [index] - if (actor and actor.grupo and actor.spec) then - _detalhes.cached_specs [actor.serial] = actor.spec - end + ---@type combat + local currentCombat = Details:GetCurrentCombat() + local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + local healContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL) + local unitIdRaidCache = Details222.UnitIdCache.Raid + + for i = 1, GetNumGroupMembers() do + local unitName = Details:GetFullName(unitIdRaidCache[i]) + local actorObject = damageContainer:GetActor(unitName) + if (actorObject and actorObject.spec) then + Details.cached_specs[actorObject.serial] = actorObject.spec else - index = c_combat_heal._NameIndexTable [name] - if (index) then - local actor = c_combat_heal._ActorTable [index] - if (actor and actor.grupo and actor.spec) then - _detalhes.cached_specs [actor.serial] = actor.spec - end + actorObject = healContainer:GetActor(unitName) + if (actorObject and actorObject.spec) then + Details.cached_specs[actorObject.serial] = actorObject.spec end end end @@ -492,17 +504,17 @@ local specialserials = { ["3209-082F39F5"] = true, --quick } -function _detalhes:RefreshUpdater(suggested_interval) - local updateInterval = suggested_interval or _detalhes.update_speed +function Details:RefreshUpdater(intervalAmount) + local updateInterval = intervalAmount or Details.update_speed - if (_detalhes.streamer_config.faster_updates) then + if (Details.streamer_config.faster_updates) then --force 60 updates per second updateInterval = 0.016 end - if (_detalhes.atualizador) then + if (Details.atualizador) then --_detalhes:CancelTimer(_detalhes.atualizador) - Details.Schedules.Cancel(_detalhes.atualizador) + Details.Schedules.Cancel(Details.atualizador) end local specialSerial = UnitGUID("player") and UnitGUID("player"):gsub("Player%-", "") @@ -510,45 +522,45 @@ function _detalhes:RefreshUpdater(suggested_interval) --_detalhes.atualizador = _detalhes:ScheduleRepeatingTimer("RefreshMainWindow", updateInterval, -1) --_detalhes.atualizador = Details.Schedules.NewTicker(updateInterval, Details.RefreshMainWindow, Details, -1) - _detalhes.atualizador = C_Timer.NewTicker(updateInterval, Details.RefreshAllMainWindowsTemp) + Details.atualizador = C_Timer.NewTicker(updateInterval, Details.RefreshAllMainWindowsTemp) end ---set the amount of time between each update of all windows ----@param interval number? +---@param newInterval number? ---@param bNoSave boolean? -function Details:SetWindowUpdateSpeed(interval, bNoSave) - if (not interval) then - interval = Details.update_speed +function Details:SetWindowUpdateSpeed(newInterval, bNoSave) + if (not newInterval) then + newInterval = Details.update_speed end - if (type(interval) ~= "number") then - interval = Details.update_speed or 0.3 + if (type(newInterval) ~= "number") then + newInterval = Details.update_speed or 0.3 end if (not bNoSave) then - Details.update_speed = interval + Details.update_speed = newInterval end - Details:RefreshUpdater(interval) + Details:RefreshUpdater(newInterval) end -function _detalhes:SetUseAnimations(enabled, nosave) - if (enabled == nil) then - enabled = _detalhes.use_row_animations +function Details:SetUseAnimations(bEnableAnimations, bNoSave) + if (bEnableAnimations == nil) then + bEnableAnimations = Details.use_row_animations end - if (not nosave) then - _detalhes.use_row_animations = enabled + if (not bNoSave) then + Details.use_row_animations = bEnableAnimations end - _detalhes.is_using_row_animations = enabled + Details.is_using_row_animations = bEnableAnimations end -function _detalhes:HavePerformanceProfileEnabled() - return _detalhes.performance_profile_enabled +function Details:HavePerformanceProfileEnabled() + return Details.performance_profile_enabled end -_detalhes.PerformanceIcons = { +Details.PerformanceIcons = { ["RaidFinder"] = {icon = [[Interface\PvPRankBadges\PvPRank15]], color = {1, 1, 1, 1}}, ["Raid15"] = {icon = [[Interface\PvPRankBadges\PvPRank15]], color = {1, .8, 0, 1}}, ["Raid30"] = {icon = [[Interface\PvPRankBadges\PvPRank15]], color = {1, .8, 0, 1}}, @@ -559,49 +571,46 @@ _detalhes.PerformanceIcons = { ["Dungeon"] = {icon = [[Interface\PvPRankBadges\PvPRank01]], color = {1, 1, 1, 1}}, } -function _detalhes:CheckForPerformanceProfile() - - local performanceType = _detalhes:GetPerformanceRaidType() - - local profile = _detalhes.performance_profiles [performanceType] +function Details:CheckForPerformanceProfile() + local performanceType = Details:GetPerformanceRaidType() + local profile = Details.performance_profiles[performanceType] if (profile and profile.enabled) then - _detalhes:SetWindowUpdateSpeed(profile.update_speed, true) - _detalhes:SetUseAnimations(profile.use_row_animations, true) - _detalhes:CaptureSet(profile.damage, "damage") - _detalhes:CaptureSet(profile.heal, "heal") - _detalhes:CaptureSet(profile.energy, "energy") - _detalhes:CaptureSet(profile.miscdata, "miscdata") - _detalhes:CaptureSet(profile.aura, "aura") + Details:SetWindowUpdateSpeed(profile.update_speed, true) + Details:SetUseAnimations(profile.use_row_animations, true) + Details:CaptureSet(profile.damage, "damage") + Details:CaptureSet(profile.heal, "heal") + Details:CaptureSet(profile.energy, "energy") + Details:CaptureSet(profile.miscdata, "miscdata") + Details:CaptureSet(profile.aura, "aura") - if (not _detalhes.performance_profile_lastenabled or _detalhes.performance_profile_lastenabled ~= performanceType) then - _detalhes:InstanceAlert (Loc ["STRING_OPTIONS_PERFORMANCE_PROFILE_LOAD"] .. performanceType, {_detalhes.PerformanceIcons [performanceType].icon, 14, 14, false, 0, 1, 0, 1, unpack(_detalhes.PerformanceIcons [performanceType].color)} , 5, {_detalhes.empty_function}) + if (not Details.performance_profile_lastenabled or Details.performance_profile_lastenabled ~= performanceType) then + Details:InstanceAlert(Loc ["STRING_OPTIONS_PERFORMANCE_PROFILE_LOAD"] .. performanceType, {Details.PerformanceIcons [performanceType].icon, 14, 14, false, 0, 1, 0, 1, unpack(Details.PerformanceIcons [performanceType].color)} , 5, {Details.empty_function}) end - _detalhes.performance_profile_enabled = performanceType - _detalhes.performance_profile_lastenabled = performanceType + Details.performance_profile_enabled = performanceType + Details.performance_profile_lastenabled = performanceType else - _detalhes:SetWindowUpdateSpeed(_detalhes.update_speed) - _detalhes:SetUseAnimations(_detalhes.use_row_animations) - _detalhes:CaptureSet(_detalhes.capture_real ["damage"], "damage") - _detalhes:CaptureSet(_detalhes.capture_real ["heal"], "heal") - _detalhes:CaptureSet(_detalhes.capture_real ["energy"], "energy") - _detalhes:CaptureSet(_detalhes.capture_real ["miscdata"], "miscdata") - _detalhes:CaptureSet(_detalhes.capture_real ["aura"], "aura") - _detalhes.performance_profile_enabled = nil + Details:SetWindowUpdateSpeed(Details.update_speed) + Details:SetUseAnimations(Details.use_row_animations) + Details:CaptureSet(Details.capture_real ["damage"], "damage") + Details:CaptureSet(Details.capture_real ["heal"], "heal") + Details:CaptureSet(Details.capture_real ["energy"], "energy") + Details:CaptureSet(Details.capture_real ["miscdata"], "miscdata") + Details:CaptureSet(Details.capture_real ["aura"], "aura") + Details.performance_profile_enabled = nil end end -function _detalhes:GetPerformanceRaidType() +function Details:GetPerformanceRaidType() + local name, instanceType, difficulty, difficultyName, maxPlayers = GetInstanceInfo() - local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo() - - if (type == "none") then + if (instanceType == "none") then return nil end - if (type == "pvp") then + if (instanceType == "pvp") then if (maxPlayers == 40) then return "Battleground40" elseif (maxPlayers == 15) then @@ -611,11 +620,11 @@ function _detalhes:GetPerformanceRaidType() end end - if (type == "arena") then + if (instanceType == "arena") then return "Arena" end - if (type == "raid") then + if (instanceType == "raid") then --mythic if (difficulty == 15) then return "Mythic" @@ -643,78 +652,175 @@ function _detalhes:GetPerformanceRaidType() end end - if (type == "party") then + if (instanceType == "party") then return "Dungeon" end return nil end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --background tasks - -local background_tasks = {} -local task_timers = { +local backgroundTasks = {} +local taskTimers = { ["LOW"] = 30, ["MEDIUM"] = 18, ["HIGH"] = 10, } -function _detalhes:RegisterBackgroundTask (name, func, priority, ...) - +function Details:RegisterBackgroundTask(name, func, priority, ...) + if true then return end assert(type(self) == "table", "RegisterBackgroundTask 'self' must be a table.") assert(type(name) == "string", "RegisterBackgroundTask param #1 must be a string.") if (type(func) == "string") then - assert(type(self [func]) == "function", "RegisterBackgroundTask param #2 function not found on main object.") + assert(type(self[func]) == "function", "RegisterBackgroundTask param #2 function not found on main object.") else assert(type(func) == "function", "RegisterBackgroundTask param #2 expect a function or function name.") end priority = priority or "LOW" - priority = string.upper (priority) - if (not task_timers [priority]) then + priority = string.upper(priority) + + if (not taskTimers[priority]) then priority = "LOW" end - if (background_tasks [name]) then - background_tasks [name].func = func - background_tasks [name].priority = priority - background_tasks [name].args = {...} - background_tasks [name].args_amt = select("#", ...) - background_tasks [name].object = self + if (backgroundTasks[name]) then + backgroundTasks[name].func = func + backgroundTasks[name].priority = priority + backgroundTasks[name].args = {...} + backgroundTasks[name].args_amt = select("#", ...) + backgroundTasks[name].object = self return else - background_tasks [name] = {func = func, lastexec = time(), priority = priority, nextexec = time() + task_timers [priority] * 60, args = {...}, args_amt = select("#", ...), object = self} + backgroundTasks[name] = {func = func, lastexec = time(), priority = priority, nextexec = time() + taskTimers [priority] * 60, args = {...}, args_amt = select("#", ...), object = self} end end -function _detalhes:UnregisterBackgroundTask (name) - background_tasks [name] = nil +function Details:UnregisterBackgroundTask(name) + backgroundTasks[name] = nil end -function _detalhes:DoBackgroundTasks() - if (_detalhes:GetZoneType() ~= "none" or _detalhes:InGroup()) then +function Details:DoBackgroundTasks() + if (Details:GetZoneType() ~= "none" or Details:InGroup()) then return end local t = time() - for taskName, taskTable in pairs(background_tasks) do + for taskName, taskTable in pairs(backgroundTasks) do if (t > taskTable.nextexec) then if (type(taskTable.func) == "string") then - taskTable.object [taskTable.func] (taskTable.object, unpack(taskTable.args, 1, taskTable.args_amt)) + taskTable.object[taskTable.func](taskTable.object, unpack(taskTable.args, 1, taskTable.args_amt)) else - taskTable.func (unpack(taskTable.args, 1, taskTable.args_amt)) + taskTable.func(unpack(taskTable.args, 1, taskTable.args_amt)) end - taskTable.nextexec = random (30, 120) + t + (task_timers [taskTable.priority] * 60) + taskTable.nextexec = math.random(30, 120) + t + (taskTimers[taskTable.priority] * 60) end end end -_detalhes.background_tasks_loop = _detalhes:ScheduleRepeatingTimer ("DoBackgroundTasks", 120) +Details.background_tasks_loop = Details:ScheduleRepeatingTimer("DoBackgroundTasks", 120) + +------ +local hasGroupMemberInCombat = function() + --iterate over party or raid members and check if any one of them are in combat, if any are return true + if (not IsInRaid()) then + --summing the player as the party unitId cache do include the player unitId and the GetNumGroupMembers() doesn't count the player + local amountOfPartyMembers = GetNumGroupMembers() + 1 + for i, unitId in ipairs(Details222.UnitIdCache.Party) do + if (i <= amountOfPartyMembers) then + if (UnitAffectingCombat(unitId)) then + return true + end + else + break + end + end + else + local amountOfPartyMembers = GetNumGroupMembers() + for i, unitId in ipairs(Details222.UnitIdCache.Raid) do + if (i <= amountOfPartyMembers) then + if (UnitAffectingCombat(unitId)) then + return true + end + else + break + end + end + end + + return false +end + +local checkForGroupCombat_Ticker = function() + if (hasGroupMemberInCombat()) then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + else + Details222.parser_frame:SetScript("OnEvent", nil) + Details222.Parser.EventFrame.ticker:Cancel() + Details222.Parser.EventFrame.ticker = nil + end +end + +local bConsiderGroupMembers = false +Details222.Parser.Handler = {} +Details222.Parser.EventFrame = CreateFrame("frame") +Details222.Parser.EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") +Details222.Parser.EventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA") +Details222.Parser.EventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") +Details222.Parser.EventFrame:RegisterEvent("PLAYER_REGEN_DISABLED") +Details222.Parser.EventFrame:SetScript("OnEvent", function(self, event, ...) + local bIsOpenWorld = select(2, GetInstanceInfo()) == "none" + + if (not bIsOpenWorld) then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + return + end + + if (event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED_NEW_AREA") then + if (bConsiderGroupMembers) then + if (hasGroupMemberInCombat()) then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + + --initiate a ticker to check if a unit in the group is still in combat + if (not Details222.Parser.EventFrame.ticker) then + Details222.Parser.EventFrame.ticker = C_Timer.NewTicker(1, checkForGroupCombat_Ticker) + end + else + Details222.parser_frame:SetScript("OnEvent", nil) + end + else + if (UnitAffectingCombat("player")) then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + else + Details222.parser_frame:SetScript("OnEvent", nil) + end + end + + elseif (event == "PLAYER_REGEN_DISABLED") then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + + elseif (event == "PLAYER_REGEN_ENABLED") then + if (bConsiderGroupMembers) then + if (hasGroupMemberInCombat()) then + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + + --initiate a ticker to check if a unit in the group is still in combat + if (not Details222.Parser.EventFrame.ticker) then + Details222.Parser.EventFrame.ticker = C_Timer.NewTicker(1, checkForGroupCombat_Ticker) + end + else + Details222.parser_frame:SetScript("OnEvent", nil) + end + else + Details222.parser_frame:SetScript("OnEvent", nil) + end + end +end) + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --storage stuff ~storage @@ -722,9 +828,9 @@ _detalhes.background_tasks_loop = _detalhes:ScheduleRepeatingTimer ("DoBackgroun local CONST_ADDONNAME_DATASTORAGE = "Details_DataStorage" --global database -_detalhes.storage = {} +Details.storage = {} -function _detalhes.storage:OpenRaidStorage() +function Details.storage:OpenRaidStorage() --check if the storage is already loaded if (not IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then local loaded, reason = LoadAddOn(CONST_ADDONNAME_DATASTORAGE) @@ -736,8 +842,8 @@ function _detalhes.storage:OpenRaidStorage() --get the storage table local db = DetailsDataStorage - if (not db and _detalhes.CreateStorageDB) then - db = _detalhes:CreateStorageDB() + if (not db and Details.CreateStorageDB) then + db = Details:CreateStorageDB() if (not db) then return end @@ -748,8 +854,8 @@ function _detalhes.storage:OpenRaidStorage() return db end -function _detalhes.storage:HaveDataForEncounter(diff, encounter_id, guild_name) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:HaveDataForEncounter(diff, encounter_id, guild_name) + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -778,20 +884,20 @@ function _detalhes.storage:HaveDataForEncounter(diff, encounter_id, guild_name) end end -function _detalhes.storage:GetBestFromGuild (diff, encounter_id, role, dps, guild_name) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:GetBestFromGuild(diff, encounter_id, role, dps, guild_name) + local db = Details.storage:OpenRaidStorage() if (not db) then return end if (not guild_name) then - guild_name = GetGuildInfo ("player") + guild_name = GetGuildInfo("player") end if (not guild_name) then - if (_detalhes.debug) then - _detalhes:Msg("(debug) GetBestFromGuild() guild name invalid.") + if (Details.debug) then + Details:Msg("(debug) GetBestFromGuild() guild name invalid.") end return end @@ -847,21 +953,21 @@ function _detalhes.storage:GetBestFromGuild (diff, encounter_id, role, dps, guil return t, onencounter end -function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playername, dps, guild_name) +function Details.storage:GetPlayerGuildRank(diff, encounter_id, role, playername, dps, guild_name) - local db = _detalhes.storage:OpenRaidStorage() + local db = Details.storage:OpenRaidStorage() if (not db) then return end if (not guild_name) then - guild_name = GetGuildInfo ("player") + guild_name = GetGuildInfo("player") end if (not guild_name) then - if (_detalhes.debug) then - _detalhes:Msg("(debug) GetBestFromGuild() guild name invalid.") + if (Details.debug) then + Details:Msg("(debug) GetBestFromGuild() guild name invalid.") end return end @@ -923,7 +1029,7 @@ function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playern tinsert(t, playerTable) end - table.sort (t, dps and _detalhes.Sort2 or _detalhes.Sort1) + table.sort(t, dps and Details.Sort2 or Details.Sort1) for i = 1, #t do if (t[i][5] == playername) then @@ -935,8 +1041,8 @@ function _detalhes.storage:GetPlayerGuildRank (diff, encounter_id, role, playern end -function _detalhes.storage:GetBestFromPlayer (diff, encounter_id, role, playername, dps) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:GetBestFromPlayer(diff, encounter_id, role, playername, dps) + local db = Details.storage:OpenRaidStorage() if (not db) then print("DB noot found on GetBestFromPlayer()") @@ -990,19 +1096,19 @@ function _detalhes.storage:GetBestFromPlayer (diff, encounter_id, role, playerna return best, onencounter end -function _detalhes.storage:DBGuildSync() +function Details.storage:DBGuildSync() - _detalhes:SendGuildData ("GS", "R") + Details:SendGuildData("GS", "R") end local OnlyFromCurrentRaidTier = true local encounter_is_current_tier = function(encounterID) if (OnlyFromCurrentRaidTier) then - local mapID = _detalhes:GetInstanceIdFromEncounterId (encounterID) + local mapID = Details:GetInstanceIdFromEncounterId(encounterID) if (mapID) then --if isn'y the mapID in the table to save data - if (not _detalhes.InstancesToStoreData [mapID]) then + if (not Details.InstancesToStoreData [mapID]) then return false end else @@ -1040,7 +1146,7 @@ local hasRecentRequestedEncounterSyncId = function(encounterSyncId) local minTime = encounterSyncId - 120 local maxTime = encounterSyncId + 120 - for requestedID in pairs(_detalhes.RecentRequestedIDs) do + for requestedID in pairs(Details.RecentRequestedIDs) do if (requestedID >= minTime and requestedID <= maxTime) then return true end @@ -1058,8 +1164,8 @@ local getBossIdsForCurrentExpansion = function() end --remote call RoS -function _detalhes.storage:GetIDsToGuildSync() - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:GetIDsToGuildSync() + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -1088,30 +1194,30 @@ function _detalhes.storage:GetIDsToGuildSync() end end - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. #encounterSyncIds .. " IDs.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] sending " .. #encounterSyncIds .. " IDs.") end return encounterSyncIds end --local call RoC - received the encounterSyncIds - need to know which fights is missing -function _detalhes.storage:CheckMissingIDsToGuildSync(encounterSyncIds) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:CheckMissingIDsToGuildSync(encounterSyncIds) + local db = Details.storage:OpenRaidStorage() if (not db) then return end if (type(encounterSyncIds) ~= "table") then - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] RoC encounterSyncIds isn't a table.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] RoC encounterSyncIds isn't a table.") end return end --prevent to request the same fight from multiple people - _detalhes.RecentRequestedIDs = _detalhes.RecentRequestedIDs or {} + Details.RecentRequestedIDs = Details.RecentRequestedIDs or {} --store the IDs which need to be sync local requestEncounterSyncIds = {} @@ -1121,29 +1227,29 @@ function _detalhes.storage:CheckMissingIDsToGuildSync(encounterSyncIds) if (not hasEncounterByEncounterSyncId(db, encounterSyncId)) then if (not hasRecentRequestedEncounterSyncId(encounterSyncId)) then tinsert(requestEncounterSyncIds, encounterSyncId) - _detalhes.RecentRequestedIDs[encounterSyncId] = true + Details.RecentRequestedIDs[encounterSyncId] = true end end end - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoC-EncounterSync] RoS found " .. #requestEncounterSyncIds .. " encounters out dated.") + if (Details.debug) then + Details:Msg("(debug) [RoC-EncounterSync] RoS found " .. #requestEncounterSyncIds .. " encounters out dated.") end return requestEncounterSyncIds end --remote call RoS - build the encounter list from the encounterSyncIds -function _detalhes.storage:BuildEncounterDataToGuildSync(encounterSyncIds) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:BuildEncounterDataToGuildSync(encounterSyncIds) + local db = Details.storage:OpenRaidStorage() if (not db) then return end if (type(encounterSyncIds) ~= "table") then - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] IDsList isn't a table.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] IDsList isn't a table.") end return end @@ -1155,8 +1261,8 @@ function _detalhes.storage:BuildEncounterDataToGuildSync(encounterSyncIds) local currentTable = {} tinsert(encounterList, currentTable) - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] the client requested " .. #encounterSyncIds .. " encounters.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] the client requested " .. #encounterSyncIds .. " encounters.") end for index, encounterSyncId in ipairs(encounterSyncIds) do @@ -1186,8 +1292,8 @@ function _detalhes.storage:BuildEncounterDataToGuildSync(encounterSyncIds) end end - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] sending " .. amtToSend .. " encounters.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] sending " .. amtToSend .. " encounters.") end return encounterList @@ -1195,15 +1301,15 @@ end --local call RoC - add the fights to the client db -function _detalhes.storage:AddGuildSyncData(data, source) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:AddGuildSyncData(data, source) + local db = Details.storage:OpenRaidStorage() if (not db) then return end local addedAmount = 0 - _detalhes.LastGuildSyncReceived = GetTime() + Details.LastGuildSyncReceived = GetTime() local allowedBosses = getBossIdsForCurrentExpansion() for difficultyId, encounterIdTable in pairs(data) do @@ -1227,18 +1333,18 @@ function _detalhes.storage:AddGuildSyncData(data, source) addedAmount = addedAmount + 1 else - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] received a duplicated encounter table.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] received a duplicated encounter table.") end end else - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] received an old tier encounter.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] received an old tier encounter.") end end else - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] received an invalid encounter table.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] received an invalid encounter table.") end end end @@ -1247,8 +1353,8 @@ function _detalhes.storage:AddGuildSyncData(data, source) end end - if (_detalhes.debug) then - _detalhes:Msg("(debug) [RoS-EncounterSync] added " .. addedAmount .. " to database.") + if (Details.debug) then + Details:Msg("(debug) [RoS-EncounterSync] added " .. addedAmount .. " to database.") end if (_G.DetailsRaidHistoryWindow and _G.DetailsRaidHistoryWindow:IsShown()) then @@ -1257,8 +1363,8 @@ function _detalhes.storage:AddGuildSyncData(data, source) end end -function _detalhes.storage:ListDiffs() - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:ListDiffs() + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -1271,8 +1377,8 @@ function _detalhes.storage:ListDiffs() return resultTable end -function _detalhes.storage:ListEncounters(difficultyId) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:ListEncounters(difficultyId) + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -1297,8 +1403,8 @@ function _detalhes.storage:ListEncounters(difficultyId) return resultTable end -function _detalhes.storage:GetPlayerData(difficultyId, dungeonEncounterID, playerName) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:GetPlayerData(difficultyId, dungeonEncounterID, playerName) + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -1363,8 +1469,8 @@ function _detalhes.storage:GetPlayerData(difficultyId, dungeonEncounterID, playe return resultTable end -function _detalhes.storage:GetEncounterData(difficultyId, dungeonEncounterID, guildName) - local db = _detalhes.storage:OpenRaidStorage() +function Details.storage:GetEncounterData(difficultyId, dungeonEncounterID, guildName) + local db = Details.storage:OpenRaidStorage() if (not db) then return @@ -1403,33 +1509,36 @@ end local createStorageTables = function() --get the storage table - local db = DetailsDataStorage + local storageDatabase = DetailsDataStorage - if (not db and Details.CreateStorageDB) then - db = Details:CreateStorageDB() - if (not db) then + if (not storageDatabase and Details.CreateStorageDB) then + storageDatabase = Details:CreateStorageDB() + if (not storageDatabase) then return end - elseif (not db) then + elseif (not storageDatabase) then return end - return db + return storageDatabase end -function _detalhes.ScheduleLoadStorage() +function Details.ScheduleLoadStorage() + do return end + if (InCombatLockdown() or UnitAffectingCombat("player")) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! storage scheduled to load (player in combat).") end - _detalhes.schedule_storage_load = true + + Details.schedule_storage_load = true return else if (not IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then local loaded, reason = LoadAddOn(CONST_ADDONNAME_DATASTORAGE) if (not loaded) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't load storage, may be the addon is disabled.") end return @@ -1440,25 +1549,25 @@ function _detalhes.ScheduleLoadStorage() end if (IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then - _detalhes.schedule_storage_load = nil - _detalhes.StorageLoaded = true - if (_detalhes.debug) then + Details.schedule_storage_load = nil + Details.StorageLoaded = true + if (Details.debug) then print("|cFFFFFF00Details! storage loaded.") end else - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! fail to load storage, scheduled once again.") end - _detalhes.schedule_storage_load = true + Details.schedule_storage_load = true end end -function _detalhes.GetStorage() +function Details.GetStorage() return DetailsDataStorage end --this function is used on the breakdown window to show ranking and on the main window when hovering over the spec icon -function _detalhes.OpenStorage() +function Details.OpenStorage() --if the player is in combat, this function return false, if failed to load by other reason it returns nil do return end @@ -1467,7 +1576,7 @@ function _detalhes.OpenStorage() if (not IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then --can't open it during combat if (InCombatLockdown() or UnitAffectingCombat("player")) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't load storage due to combat.") end return false @@ -1475,7 +1584,7 @@ function _detalhes.OpenStorage() local loaded, reason = LoadAddOn(CONST_ADDONNAME_DATASTORAGE) if (not loaded) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't load storage, may be the addon is disabled.") end return @@ -1484,7 +1593,7 @@ function _detalhes.OpenStorage() local db = createStorageTables() if (db and IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then - _detalhes.StorageLoaded = true + Details.StorageLoaded = true end return DetailsDataStorage @@ -1503,7 +1612,7 @@ function Details.Database.LoadDB() if (not IsAddOnLoaded(CONST_ADDONNAME_DATASTORAGE)) then local loaded, reason = LoadAddOn(CONST_ADDONNAME_DATASTORAGE) if (not loaded) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't save the encounter, couldn't load DataStorage, may be the addon is disabled.") end return @@ -1513,16 +1622,16 @@ function Details.Database.LoadDB() --get the storage table local db = _G.DetailsDataStorage - if (not db and _detalhes.CreateStorageDB) then - db = _detalhes:CreateStorageDB() + if (not db and Details.CreateStorageDB) then + db = Details:CreateStorageDB() if (not db) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't save the encounter, couldn't load DataStorage, may be the addon is disabled.") end return end elseif (not db) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't save the encounter, couldn't load DataStorage, may be the addon is disabled.") end return @@ -1541,11 +1650,12 @@ function Details.Database.GetBossKillsDB(db) return totalKillsDataBase end +---@param combat combat function Details.Database.StoreWipe(combat) - combat = combat or _detalhes.tabela_vigente + combat = combat or Details.tabela_vigente if (not combat) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: combat not found.") end return @@ -1554,7 +1664,7 @@ function Details.Database.StoreWipe(combat) local _, _, _, _, _, _, _, mapID = GetInstanceInfo() if (not instancesToStoreData[mapID]) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: instance not allowed.") end return @@ -1564,7 +1674,7 @@ function Details.Database.StoreWipe(combat) local dungeonEncounterID = bossInfo and bossInfo.id if (not dungeonEncounterID) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: encounter ID not found.") end return @@ -1573,7 +1683,7 @@ function Details.Database.StoreWipe(combat) --get the difficulty local difficultyId = combat:GetDifficulty() - --database + --load database local db = Details.Database.LoadDB() if (not db) then return @@ -1596,7 +1706,17 @@ function Details.Database.StoreWipe(combat) if (IsInRaid()) then totalKillsDataBase[dungeonEncounterID] = totalKillsDataBase[dungeonEncounterID] or {} - totalKillsDataBase[dungeonEncounterID][difficultyId] = totalKillsDataBase[dungeonEncounterID][difficultyId] or {kills = 0, wipes = 0, time_fasterkill = 0, time_fasterkill_when = 0, time_incombat = 0, dps_best = 0, dps_best_when = 0, dps_best_raid = 0, dps_best_raid_when = 0} + totalKillsDataBase[dungeonEncounterID][difficultyId] = totalKillsDataBase[dungeonEncounterID][difficultyId] or { + kills = 0, + wipes = 0, + time_fasterkill = 0, + time_fasterkill_when = 0, + time_incombat = 0, + dps_best = 0, + dps_best_when = 0, + dps_best_raid = 0, + dps_best_raid_when = 0 + } local bossData = totalKillsDataBase[dungeonEncounterID][difficultyId] bossData.wipes = bossData.wipes + 1 @@ -1609,11 +1729,12 @@ function Details.Database.StoreWipe(combat) end end +---@param combat combat function Details.Database.StoreEncounter(combat) - combat = combat or _detalhes.tabela_vigente + combat = combat or Details:GetCurrentCombat() if (not combat) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: combat not found.") end return @@ -1622,7 +1743,7 @@ function Details.Database.StoreEncounter(combat) local _, _, _, _, _, _, _, mapID = GetInstanceInfo() if (not instancesToStoreData[mapID]) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: instance not allowed.") end return @@ -1632,7 +1753,7 @@ function Details.Database.StoreEncounter(combat) local encounter_id = encounterInfo and encounterInfo.id if (not encounter_id) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: encounter ID not found.") end return @@ -1709,7 +1830,7 @@ function Details.Database.StoreEncounter(combat) --check the guild name local match = 0 - local guildName = GetGuildInfo ("player") + local guildName = GetGuildInfo("player") local raidSize = GetNumGroupMembers() or 0 if (not storageDebug) then @@ -1722,13 +1843,13 @@ function Details.Database.StoreEncounter(combat) end if (match < raidSize * 0.75 and not storageDebug) then - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: can't save the encounter, need at least 75% of players be from your guild.") end return end else - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: player isn't in a guild.") end return @@ -1740,7 +1861,7 @@ function Details.Database.StoreEncounter(combat) local this_combat_data = { damage = {}, healing = {}, - date = date ("%H:%M %d/%m/%y"), + date = date("%H:%M %d/%m/%y"), time = time(), servertime = GetServerTime(), elapsed = combat:GetCombatTime(), @@ -1765,7 +1886,7 @@ function Details.Database.StoreEncounter(combat) local damage_actor = damage_container_pool [damage_container_hash [player_name]] if (damage_actor) then local guid = UnitGUID("raid" .. i) - this_combat_data.damage [player_name] = {floor(damage_actor.total), _detalhes.item_level_pool [guid] and _detalhes.item_level_pool [guid].ilvl or 0, class or 0} + this_combat_data.damage [player_name] = {floor(damage_actor.total), Details.item_level_pool [guid] and Details.item_level_pool [guid].ilvl or 0, class or 0} end elseif (role == "HEALER" or role == "SUPPORT") then @@ -1776,7 +1897,7 @@ function Details.Database.StoreEncounter(combat) local heal_actor = healing_container_pool [healing_container_hash [player_name]] if (heal_actor) then local guid = UnitGUID("raid" .. i) - this_combat_data.healing [player_name] = {floor(heal_actor.total), _detalhes.item_level_pool [guid] and _detalhes.item_level_pool [guid].ilvl or 0, class or 0} + this_combat_data.healing [player_name] = {floor(heal_actor.total), Details.item_level_pool [guid] and Details.item_level_pool [guid].ilvl or 0, class or 0} end end end @@ -1784,12 +1905,12 @@ function Details.Database.StoreEncounter(combat) --add the encounter data tinsert(encounter_database, this_combat_data) - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: combat data added to encounter database.") end local myrole = UnitGroupRolesAssigned("player") - local mybest, onencounter = _detalhes.storage:GetBestFromPlayer (diff, encounter_id, myrole, _detalhes.playername, true) --get dps or hps + local mybest, onencounter = Details.storage:GetBestFromPlayer(diff, encounter_id, myrole, Details.playername, true) --get dps or hps local mybest2 = mybest and mybest[1] or 0 if (mybest and onencounter) then @@ -1797,42 +1918,42 @@ function Details.Database.StoreEncounter(combat) local d_one = 0 if (myrole == "DAMAGER" or myrole == "TANK") then - d_one = combat (1, _detalhes.playername) and combat (1, _detalhes.playername).total / combat:GetCombatTime() + d_one = combat(1, Details.playername) and combat(1, Details.playername).total / combat:GetCombatTime() elseif (myrole == "HEALER") then - d_one = combat (2, _detalhes.playername) and combat (2, _detalhes.playername).total / combat:GetCombatTime() + d_one = combat(2, Details.playername) and combat(2, Details.playername).total / combat:GetCombatTime() end if (myBestDps > d_one) then - if (not _detalhes.deny_score_messages) then - print(Loc ["STRING_DETAILS1"] .. format(Loc ["STRING_SCORE_NOTBEST"], _detalhes:ToK2 (d_one), _detalhes:ToK2 (myBestDps), onencounter.date, mybest[2])) + if (not Details.deny_score_messages) then + print(Loc ["STRING_DETAILS1"] .. format(Loc ["STRING_SCORE_NOTBEST"], Details:ToK2(d_one), Details:ToK2(myBestDps), onencounter.date, mybest[2])) end else - if (not _detalhes.deny_score_messages) then - print(Loc ["STRING_DETAILS1"] .. format(Loc ["STRING_SCORE_BEST"], _detalhes:ToK2 (d_one))) + if (not Details.deny_score_messages) then + print(Loc ["STRING_DETAILS1"] .. format(Loc ["STRING_SCORE_BEST"], Details:ToK2(d_one))) end end end - local lower_instance = _detalhes:GetLowerInstanceNumber() + local lower_instance = Details:GetLowerInstanceNumber() if (lower_instance) then - local instance = _detalhes:GetInstance(lower_instance) + local instance = Details:GetInstance(lower_instance) if (instance) then local my_role = UnitGroupRolesAssigned("player") if (my_role == "TANK") then my_role = "DAMAGER" end local raid_name = GetInstanceInfo() - local func = {_detalhes.OpenRaidHistoryWindow, _detalhes, raid_name, encounter_id, diff, my_role, guildName} + local func = {Details.OpenRaidHistoryWindow, Details, raid_name, encounter_id, diff, my_role, guildName} --local icon = {[[Interface\AddOns\Details\images\icons]], 16, 16, false, 434/512, 466/512, 243/512, 273/512} local icon = {[[Interface\PvPRankBadges\PvPRank08]], 16, 16, false, 0, 1, 0, 1} - if (not _detalhes.deny_score_messages) then - instance:InstanceAlert (Loc ["STRING_GUILDDAMAGERANK_WINDOWALERT"], icon, _detalhes.update_warning_timeout, func, true) + if (not Details.deny_score_messages) then + instance:InstanceAlert(Loc ["STRING_GUILDDAMAGERANK_WINDOWALERT"], icon, Details.update_warning_timeout, func, true) end end end else - if (_detalhes.debug) then + if (Details.debug) then print("|cFFFFFF00Details! Storage|r: raid difficulty must be heroic or mythic.") end end @@ -1841,10 +1962,10 @@ end -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --inspect stuff -_detalhes.ilevel = {} -local ilvl_core = _detalhes:CreateEventListener() +Details.ilevel = {} +local ilvl_core = Details:CreateEventListener() ilvl_core.amt_inspecting = 0 -_detalhes.ilevel.core = ilvl_core +Details.ilevel.core = ilvl_core ilvl_core:RegisterEvent("GROUP_ONENTER", "OnEnter") ilvl_core:RegisterEvent("GROUP_ONLEAVE", "OnLeave") @@ -1855,7 +1976,7 @@ ilvl_core:RegisterEvent("ZONE_TYPE_CHANGED", "ZoneChanged") local inspecting = {} ilvl_core.forced_inspects = {} -function ilvl_core:HasQueuedInspec (unitName) +function ilvl_core:HasQueuedInspec(unitName) local guid = UnitGUID(unitName) if (guid) then return ilvl_core.forced_inspects [guid] @@ -1875,8 +1996,8 @@ local MAX_INSPECT_AMOUNT = 1 local MIN_ILEVEL_TO_STORE = 1 local LOOP_TIME = 7 -function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel, talentsSelected, currentSpec) - if (_detalhes.debug and false) then +function Details:IlvlFromNetwork(player, realm, core, serialNumber, itemLevel, talentsSelected, currentSpec) + if (Details.debug and false) then local talents = "Invalid Talents" if (type(talentsSelected) == "table") then talents = "" @@ -1884,7 +2005,7 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel 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: " ..(player or "Invalid Player Name") .. " | " ..(itemLevel or "Invalid Item Level") .. " | " ..(currentSpec or "Invalid Spec") .. " | " .. talents .. " | " ..(serialNumber or "Invalid Serial")) end if (not player) then @@ -1898,7 +2019,7 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel end --won't inspect this actor - _detalhes.trusted_characters[serialNumber] = true + Details.trusted_characters[serialNumber] = true if (type(serialNumber) ~= "string") then return @@ -1906,30 +2027,31 @@ function _detalhes:IlvlFromNetwork (player, realm, core, serialNumber, itemLevel --store the item level if (type(itemLevel) == "number") then - _detalhes.item_level_pool[serialNumber] = {name = player, ilvl = itemLevel, time = time()} + Details.item_level_pool[serialNumber] = {name = player, ilvl = itemLevel, time = time()} end --store talents if (type(talentsSelected) == "table") then if (talentsSelected[1]) then - _detalhes.cached_talents[serialNumber] = talentsSelected + Details.cached_talents[serialNumber] = talentsSelected end elseif (type(talentsSelected) == "string" and talentsSelected ~= "") then - _detalhes.cached_talents[serialNumber] = talentsSelected + Details.cached_talents[serialNumber] = talentsSelected end --store the spec the player is playing if (type(currentSpec) == "number") then - _detalhes.cached_specs[serialNumber] = currentSpec + Details.cached_specs[serialNumber] = currentSpec end end --test ---/run _detalhes.ilevel:CalcItemLevel ("player", UnitGUID("player"), true) +--/run _detalhes.ilevel:CalcItemLevel("player", UnitGUID("player"), true) --/run wipe(_detalhes.item_level_pool) -function ilvl_core:CalcItemLevel (unitid, guid, shout) +function ilvl_core:CalcItemLevel(unitid, guid, shout) + if (type(unitid) == "table") then shout = unitid [3] guid = unitid [2] @@ -1942,12 +2064,12 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) --register if (average > 0) then if (shout) then - _detalhes:Msg(UnitName(unitid) .. " item level: " .. average) + Details:Msg(UnitName(unitid) .. " item level: " .. average) end if (average > MIN_ILEVEL_TO_STORE) then local unitName = Details:GetFullName(unitid) - _detalhes.item_level_pool [guid] = {name = unitName, ilvl = average, time = time()} + Details.item_level_pool [guid] = {name = unitName, ilvl = average, time = time()} end end @@ -1957,7 +2079,7 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) if (type(ilvl_core.forced_inspects [guid].callback) == "function") then local okey, errortext = pcall(ilvl_core.forced_inspects[guid].callback, guid, unitid, ilvl_core.forced_inspects[guid].param1, ilvl_core.forced_inspects[guid].param2) if (not okey) then - _detalhes:Msg("Error on QueryInspect callback: " .. errortext) + Details:Msg("Error on QueryInspect callback: " .. errortext) end end ilvl_core.forced_inspects [guid] = nil @@ -1968,7 +2090,7 @@ function ilvl_core:CalcItemLevel (unitid, guid, shout) end end -_detalhes.ilevel.CalcItemLevel = ilvl_core.CalcItemLevel +Details.ilevel.CalcItemLevel = ilvl_core.CalcItemLevel inspect_frame:SetScript("OnEvent", function(self, event, ...) local guid @@ -2013,17 +2135,17 @@ inspect_frame:SetScript("OnEvent", function(self, event, ...) end end) -function ilvl_core:InspectTimeOut (guid) +function ilvl_core:InspectTimeOut(guid) inspecting [guid] = nil ilvl_core.amt_inspecting = ilvl_core.amt_inspecting - 1 end -function ilvl_core:ReGetItemLevel (t) +function ilvl_core:ReGetItemLevel(t) local unitid, guid, is_forced, try_number = unpack(t) - return ilvl_core:GetItemLevel (unitid, guid, is_forced, try_number) + return ilvl_core:GetItemLevel(unitid, guid, is_forced, try_number) end -function ilvl_core:GetItemLevel (unitid, guid, is_forced, try_number) +function ilvl_core:GetItemLevel(unitid, guid, is_forced, try_number) --ddouble check if (not is_forced and (UnitAffectingCombat("player") or InCombatLockdown())) then return @@ -2050,13 +2172,13 @@ function ilvl_core:GetItemLevel (unitid, guid, is_forced, try_number) inspecting [guid] = {unitid, ilvl_core:ScheduleTimer("InspectTimeOut", 12, guid)} ilvl_core.amt_inspecting = ilvl_core.amt_inspecting + 1 - NotifyInspect (unitid) + NotifyInspect(unitid) end local NotifyInspectHook = function(unitid) --not in use local unit = unitid:gsub("%d+", "") - if ((IsInRaid() or IsInGroup()) and (_detalhes:GetZoneType() == "raid" or _detalhes:GetZoneType() == "party")) then + if ((IsInRaid() or IsInGroup()) and(Details:GetZoneType() == "raid" or Details:GetZoneType() == "party")) then local guid = UnitGUID(unitid) local name = Details:GetFullName(unitid) if (guid and name and not inspecting [guid]) then @@ -2072,7 +2194,7 @@ local NotifyInspectHook = function(unitid) --not in use end end end -hooksecurefunc ("NotifyInspect", NotifyInspectHook) +hooksecurefunc("NotifyInspect", NotifyInspectHook) function ilvl_core:Reset() ilvl_core.raid_id = 1 @@ -2084,7 +2206,7 @@ function ilvl_core:Reset() end end -function ilvl_core:QueryInspect (unitName, callback, param1) +function ilvl_core:QueryInspect(unitName, callback, param1) local unitid if (IsInRaid()) then @@ -2124,7 +2246,7 @@ function ilvl_core:QueryInspect (unitName, callback, param1) end ilvl_core.forced_inspects [guid] = {callback = callback, param1 = param1} - ilvl_core:GetItemLevel (unitid, guid, true) + ilvl_core:GetItemLevel(unitid, guid, true) if (ilvl_core.clear_queued_list) then ilvl_core:CancelTimer(ilvl_core.clear_queued_list) @@ -2165,17 +2287,17 @@ function ilvl_core:Loop() end --if already inspecting or the actor is in the list of trusted actors - if (inspecting [guid] or _detalhes.trusted_characters [guid]) then + if (inspecting [guid] or Details.trusted_characters [guid]) then return end - local ilvl_table = _detalhes.ilevel:GetIlvl (guid) + local ilvl_table = Details.ilevel:GetIlvl(guid) if (ilvl_table and ilvl_table.time + 3600 > time()) then ilvl_core.raid_id = ilvl_core.raid_id + 1 return end - ilvl_core:GetItemLevel (unitid, guid) + ilvl_core:GetItemLevel(unitid, guid) ilvl_core.raid_id = ilvl_core.raid_id + 1 end @@ -2196,25 +2318,25 @@ end function ilvl_core:LeaveCombat() if (can_start_loop()) then ilvl_core:Reset() - ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer ("Loop", LOOP_TIME) + ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer("Loop", LOOP_TIME) end end -function ilvl_core:ZoneChanged (zone_type) +function ilvl_core:ZoneChanged(zone_type) if (can_start_loop()) then ilvl_core:Reset() - ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer ("Loop", LOOP_TIME) + ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer("Loop", LOOP_TIME) end end function ilvl_core:OnEnter() if (IsInRaid()) then - _detalhes:SendCharacterData() + Details:SendCharacterData() end if (can_start_loop()) then ilvl_core:Reset() - ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer ("Loop", LOOP_TIME) + ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer("Loop", LOOP_TIME) end end @@ -2226,19 +2348,19 @@ function ilvl_core:OnLeave() end --ilvl API -function _detalhes.ilevel:IsTrackerEnabled() - return _detalhes.track_item_level +function Details.ilevel:IsTrackerEnabled() + return Details.track_item_level end -function _detalhes.ilevel:TrackItemLevel (bool) +function Details.ilevel:TrackItemLevel(bool) if (type(bool) == "boolean") then if (bool) then - _detalhes.track_item_level = true + Details.track_item_level = true if (can_start_loop()) then ilvl_core:Reset() - ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer ("Loop", LOOP_TIME) + ilvl_core.loop_process = ilvl_core:ScheduleRepeatingTimer("Loop", LOOP_TIME) end else - _detalhes.track_item_level = false + Details.track_item_level = false if (ilvl_core.loop_process) then ilvl_core:CancelTimer(ilvl_core.loop_process) ilvl_core.loop_process = nil @@ -2247,22 +2369,22 @@ function _detalhes.ilevel:TrackItemLevel (bool) end end -function _detalhes.ilevel:GetPool() - return _detalhes.item_level_pool +function Details.ilevel:GetPool() + return Details.item_level_pool end -function _detalhes.ilevel:GetIlvl (guid) - return _detalhes.item_level_pool [guid] +function Details.ilevel:GetIlvl(guid) + return Details.item_level_pool [guid] end -function _detalhes.ilevel:GetInOrder() +function Details.ilevel:GetInOrder() local order = {} - for guid, t in pairs(_detalhes.item_level_pool) do + for guid, t in pairs(Details.item_level_pool) do order[#order+1] = {t.name, t.ilvl or 0, t.time} end - table.sort(order, _detalhes.Sort2) + table.sort(order, Details.Sort2) return order end @@ -2271,36 +2393,36 @@ function Details.ilevel:ClearIlvl(guid) Details.item_level_pool[guid] = nil end -function _detalhes:GetTalents (guid) - return _detalhes.cached_talents [guid] +function Details:GetTalents(guid) + return Details.cached_talents [guid] end -function _detalhes:GetSpecFromSerial (guid) - return _detalhes.cached_specs [guid] +function Details:GetSpecFromSerial(guid) + return Details.cached_specs [guid] end -------------------------------------------------------------------------------------------------------------------------------------------- --compress data -- ~compress ~zip ~export ~import ~deflate ~serialize -function Details:CompressData (data, dataType) - local LibDeflate = LibStub:GetLibrary ("LibDeflate") - local LibAceSerializer = LibStub:GetLibrary ("AceSerializer-3.0") +function Details:CompressData(data, dataType) + local LibDeflate = LibStub:GetLibrary("LibDeflate") + local LibAceSerializer = LibStub:GetLibrary("AceSerializer-3.0") --check if there isn't funtions in the data to export local dataCopied = DetailsFramework.table.copytocompress({}, data) if (LibDeflate and LibAceSerializer) then - local dataSerialized = LibAceSerializer:Serialize (dataCopied) + local dataSerialized = LibAceSerializer:Serialize(dataCopied) if (dataSerialized) then - local dataCompressed = LibDeflate:CompressDeflate (dataSerialized, {level = 9}) + local dataCompressed = LibDeflate:CompressDeflate(dataSerialized, {level = 9}) if (dataCompressed) then if (dataType == "print") then - local dataEncoded = LibDeflate:EncodeForPrint (dataCompressed) + local dataEncoded = LibDeflate:EncodeForPrint(dataCompressed) return dataEncoded elseif (dataType == "comm") then - local dataEncoded = LibDeflate:EncodeForWoWAddonChannel (dataCompressed) + local dataEncoded = LibDeflate:EncodeForWoWAddonChannel(dataCompressed) return dataEncoded end end @@ -2308,9 +2430,9 @@ function Details:CompressData (data, dataType) end end -function Details:DecompressData (data, dataType) - local LibDeflate = LibStub:GetLibrary ("LibDeflate") - local LibAceSerializer = LibStub:GetLibrary ("AceSerializer-3.0") +function Details:DecompressData(data, dataType) + local LibDeflate = LibStub:GetLibrary("LibDeflate") + local LibAceSerializer = LibStub:GetLibrary("AceSerializer-3.0") if (LibDeflate and LibAceSerializer) then @@ -2318,29 +2440,29 @@ function Details:DecompressData (data, dataType) if (dataType == "print") then - data = DetailsFramework:Trim (data) + data = DetailsFramework:Trim(data) - dataCompressed = LibDeflate:DecodeForPrint (data) + dataCompressed = LibDeflate:DecodeForPrint(data) if (not dataCompressed) then Details:Msg("couldn't decode the data.") return false end elseif (dataType == "comm") then - dataCompressed = LibDeflate:DecodeForWoWAddonChannel (data) + dataCompressed = LibDeflate:DecodeForWoWAddonChannel(data) if (not dataCompressed) then Details:Msg("couldn't decode the data.") return false end end - local dataSerialized = LibDeflate:DecompressDeflate (dataCompressed) + local dataSerialized = LibDeflate:DecompressDeflate(dataCompressed) if (not dataSerialized) then Details:Msg("couldn't uncompress the data.") return false end - local okay, data = LibAceSerializer:Deserialize (dataSerialized) + local okay, data = LibAceSerializer:Deserialize(dataSerialized) if (not okay) then Details:Msg("couldn't unserialize the data.") return false @@ -2380,15 +2502,15 @@ end --oldschool talent tree do - function _detalhes:GetRoleFromSpec (specId) + function _detalhes:GetRoleFromSpec(specId) return Details.specToRole [specId] or "NONE" end - - function Details.IsValidSpecId (specId) + + function Details.IsValidSpecId(specId) return Details.validSpecIds [specId] end - function Details.GetClassicSpecByTalentTexture (talentTexture) + function Details.GetClassicSpecByTalentTexture(talentTexture) return Details.textureToSpec [talentTexture] or nil end end @@ -2453,7 +2575,7 @@ function Details.GetPlayTimeOnClass() local playedTime = expansionTable[className] if (playedTime) then - playedTime = playedTime + (GetTime() - Details.GetStartupTime()) + playedTime = playedTime +(GetTime() - Details.GetStartupTime()) return playedTime end end @@ -2471,7 +2593,7 @@ function Details.GetPlayTimeOnClassString() local expansionLevel = GetExpansionLevel() local expansionName = _G["EXPANSION_NAME" .. GetExpansionLevel()] - return "|cffffff00Time played this class (" .. expansionName .. "): " .. days .. " " .. hours .. " " .. minutes + return "|cffffff00Time played this class(" .. expansionName .. "): " .. days .. " " .. hours .. " " .. minutes end hooksecurefunc("ChatFrame_DisplayTimePlayed", function() @@ -2616,7 +2738,7 @@ function Details222.Cache.DoMaintenance() Details:Destroy(Details.npcid_pool) --preserve ignored npcs npcId - for npcId in pairs (Details.npcid_ignored) do + for npcId in pairs(Details.npcid_ignored) do Details.npcid_pool[npcId] = npcIdPoolBackup[npcId] end Details.latest_npcid_pool_access = currentTime diff --git a/core/network.lua b/core/network.lua index b2ed2af3..e16df605 100644 --- a/core/network.lua +++ b/core/network.lua @@ -370,11 +370,6 @@ end end - function Details.network.HandleMissData(player, realm, coreVersion, data) - --soul rip from akaari's soul (LEGION ONLY) - --deprecated - end - function Details.network.ReceivedEnemyPlayer(player, realm, coreVersion, data) --deprecated end @@ -394,8 +389,6 @@ [CONST_GUILD_SYNC] = Details.network.GuildSync, - [CONST_ROGUE_SR] = Details.network.HandleMissData, --soul rip from akaari's soul (LEGION ONLY) - [CONST_PVP_ENEMY] = Details.network.ReceivedEnemyPlayer, [DETAILS_PREFIX_COACH] = Details.network.Coach, --coach feature diff --git a/core/parser.lua b/core/parser.lua index 374627e5..e6647a2c 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -623,7 +623,7 @@ Details:Msg(Details.WhoAggroTimer.HitBy) end - Details:EntrarEmCombate(sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags) + 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 if (token == "SPELL_PERIODIC_DAMAGE" and sourceName == Details.playername) then @@ -633,7 +633,7 @@ --faz o calculo dos 10 segundos if (Details.last_combat_time + 10 < _tempo) then - Details:EntrarEmCombate(sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags) + Details222.StartCombat(sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags) end end end @@ -2772,86 +2772,84 @@ --MISC search key: ~buffuptime ~buffsuptime | ----------------------------------------------------------------------------------------------------------------------------------------- - function parser:add_bad_debuff_uptime (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spellschool, in_out, stack_amount) - - if (not alvo_name) then + function parser:add_bad_debuff_uptime(token, time, sourceGuid, sourceName, sourceFlags, targetGuid, targetName, targetFlags, targetsFlags2, spellId, spellName, spellSchool, sInOrOut, stackSize) + if (not targetName) then --no target name, just quit return - elseif (not who_name) then + elseif (not sourceName) then --no actor name, use spell name instead - who_name = "[*] "..spellname + sourceName = "[*] "..spellName end ------------------------------------------------------------------------------------------------ --get actors --nome do debuff ser� usado para armazenar o nome do ator - local este_jogador = misc_cache [spellname] - if (not este_jogador) then --pode ser um desconhecido ou um pet - este_jogador = _current_misc_container:GetOrCreateActor (who_serial, spellname, who_flags, true) - misc_cache [spellname] = este_jogador + local sourceActor = misc_cache[spellName] + if (not sourceActor) then --pode ser um desconhecido ou um pet + sourceActor = _current_misc_container:GetOrCreateActor (sourceGuid, spellName, sourceFlags, true) + misc_cache[spellName] = sourceActor end ------------------------------------------------------------------------------------------------ --build containers on the fly - - if (not este_jogador.debuff_uptime) then - este_jogador.boss_debuff = true - este_jogador.damage_twin = who_name - este_jogador.spellschool = spellschool - este_jogador.damage_spellid = spellid - este_jogador.debuff_uptime = 0 - este_jogador.debuff_uptime_spells = spellContainerClass:CreateSpellContainer (container_misc) - este_jogador.debuff_uptime_targets = {} + if (not sourceActor.debuff_uptime) then + sourceActor.boss_debuff = true + sourceActor.damage_twin = sourceName + sourceActor.spellschool = spellSchool + sourceActor.damage_spellid = spellId + sourceActor.debuff_uptime = 0 + sourceActor.debuff_uptime_spells = spellContainerClass:CreateSpellContainer (container_misc) + sourceActor.debuff_uptime_targets = {} end ------------------------------------------------------------------------------------------------ --add amount - --update last event - este_jogador.last_event = _tempo + sourceActor.last_event = _tempo --actor target - local este_alvo = este_jogador.debuff_uptime_targets [alvo_name] + local este_alvo = sourceActor.debuff_uptime_targets [targetName] if (not este_alvo) then este_alvo = Details.atributo_misc:CreateBuffTargetObject() - este_jogador.debuff_uptime_targets [alvo_name] = este_alvo + sourceActor.debuff_uptime_targets [targetName] = este_alvo end - if (in_out == "DEBUFF_UPTIME_IN") then + if (sInOrOut == "DEBUFF_UPTIME_IN") then este_alvo.actived = true este_alvo.activedamt = este_alvo.activedamt + 1 if (este_alvo.actived_at and este_alvo.actived) then este_alvo.uptime = este_alvo.uptime + _tempo - este_alvo.actived_at - este_jogador.debuff_uptime = este_jogador.debuff_uptime + _tempo - este_alvo.actived_at + sourceActor.debuff_uptime = sourceActor.debuff_uptime + _tempo - este_alvo.actived_at end + este_alvo.actived_at = _tempo --death log --record death log - local t = last_events_cache [alvo_name] + local t = last_events_cache[targetName] if (not t) then - t = _current_combat:CreateLastEventsTable (alvo_name) + t = _current_combat:CreateLastEventsTable(targetName) end local i = t.n - local this_event = t [i] + local thisEvent = t[i] - if (not this_event) then + if (not thisEvent) then return Details:Msg("Parser Event Error -> Set to 16 DeathLogs and /reload", i, _amount_of_last_events) end - this_event [1] = 4 --4 = debuff aplication - this_event [2] = spellid --spellid - this_event [3] = 1 - this_event [4] = time --parser time - this_event [5] = UnitHealth(Details:Ambiguate(alvo_name)) --current unit heal - this_event [6] = who_name --source name - this_event [7] = false - this_event [8] = false - this_event [9] = false - this_event [10] = false + thisEvent[1] = 4 --4 = debuff aplication + thisEvent[2] = spellId --spellid + thisEvent[3] = 1 + thisEvent[4] = time --parser time + thisEvent[5] = UnitHealth(Details:Ambiguate(targetName)) --current unit heal + thisEvent[6] = sourceName --source name + thisEvent[7] = false + thisEvent[8] = false + thisEvent[9] = false + thisEvent[10] = false i = i + 1 @@ -2861,10 +2859,10 @@ t.n = i end - elseif (in_out == "DEBUFF_UPTIME_REFRESH") then + elseif (sInOrOut == "DEBUFF_UPTIME_REFRESH") then if (este_alvo.actived_at and este_alvo.actived) then este_alvo.uptime = este_alvo.uptime + _tempo - este_alvo.actived_at - este_jogador.debuff_uptime = este_jogador.debuff_uptime + _tempo - este_alvo.actived_at + sourceActor.debuff_uptime = sourceActor.debuff_uptime + _tempo - este_alvo.actived_at end este_alvo.actived_at = _tempo este_alvo.actived = true @@ -2874,44 +2872,58 @@ --local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId = UnitAura (alvo_name, spellname, nil, "HARMFUL") --UnitAura ("Kastfall", "Gulp Frog Toxin", nil, "HARMFUL") +--6/27 15:06:18.113 SPELL_AURA_APPLIED_DOSE,Creature-0-2085-2657-20918-227617-0000FDAA05,"Cosmic Simulacrum",0xa48,0x0,Player-4184-005CFB2D,"nil",0x511,0x0,459273,"Cosmic Shards",0x20,DEBUFF,4 +--6/27 15:06:18.114 SPELL_AURA_REFRESH,Creature-0-2085-2657-20918-227617-0000FDAA05,"Cosmic Simulacrum",0xa48,0x0,Player-4184-005CFB2D,"nil",0x511,0x0,459273,"Cosmic Shards",0x20,DEBUFF + --record death log - local t = last_events_cache [alvo_name] + local t = last_events_cache[targetName] if (not t) then - t = _current_combat:CreateLastEventsTable (alvo_name) + t = _current_combat:CreateLastEventsTable(targetName) end local i = t.n - local this_event = t [i] - - if (not this_event) then - return Details:Msg("Parser Event Error -> Set to 16 DeathLogs and /reload", i, _amount_of_last_events) + local bCanAdd = true + local previousEvent = t[i-1] + if (previousEvent) then + if (previousEvent[1] == 4 and previousEvent[2] == spellId and detailsFramework.Math.IsNearlyEqual(time, previousEvent[4], 0.01)) then + --don't repeat the application of the same debuff + bCanAdd = false + end end - this_event [1] = 4 --4 = debuff aplication - this_event [2] = spellid --spellid - this_event [3] = stack_amount or 1 - this_event [4] = time --parser time - this_event [5] = UnitHealth(Details:Ambiguate(alvo_name)) --current unit heal - this_event [6] = who_name --source name - this_event [7] = false - this_event [8] = false - this_event [9] = false - this_event [10] = false + if (bCanAdd) then + local thisEvent = t[i] - i = i + 1 + if (not thisEvent) then + return Details:Msg("Parser Event Error -> Set to 16 DeathLogs and /reload", i, _amount_of_last_events) + end - if (i == _amount_of_last_events+1) then - t.n = 1 - else - t.n = i + thisEvent[1] = 4 --4 = debuff aplication + thisEvent[2] = spellId --spellid + thisEvent[3] = stackSize or 1 + thisEvent[4] = time --parser time + thisEvent[5] = UnitHealth(Details:Ambiguate(targetName)) --current unit heal + thisEvent[6] = sourceName --source name + thisEvent[7] = false + thisEvent[8] = false + thisEvent[9] = false + thisEvent[10] = false + + i = i + 1 + + if (i == _amount_of_last_events+1) then + t.n = 1 + else + t.n = i + end end - elseif (in_out == "DEBUFF_UPTIME_OUT") then + elseif (sInOrOut == "DEBUFF_UPTIME_OUT") then if (este_alvo.actived_at and este_alvo.actived) then este_alvo.uptime = este_alvo.uptime + Details._tempo - este_alvo.actived_at - este_jogador.debuff_uptime = este_jogador.debuff_uptime + _tempo - este_alvo.actived_at --token = actor misc object + sourceActor.debuff_uptime = sourceActor.debuff_uptime + _tempo - este_alvo.actived_at --token = actor misc object end este_alvo.activedamt = este_alvo.activedamt - 1 @@ -4033,6 +4045,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 --get the index of the last event recorded local lastIndex = recordedEvents.n + --here the event log gets reordered as in the parser it work with index recycling if (lastIndex < _amount_of_last_events+1 and not recordedEvents[lastIndex][4]) then --the last events table amount of indexes is less than the amount of events to store for i = 1, lastIndex-1 do @@ -4072,7 +4085,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 local enemyCastCache = enemy_cast_cache --as multiple enemies can have casted the same spell at the same time, iterate over the enemyCastCache and merge the casts that happened really close to each other - --transfer the casts that happened within the the events window of the player death to a new indexed table + --transfer the casts that happened within the event window of the player death to a new indexed table local enemyCastCacheIndexed = {} if (bHadDeathEvent) then for time, enemyCastTable in pairs(enemyCastCache) do @@ -4132,6 +4145,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end end + --verify if a cooldown near the death event was used if (thisPlayer.last_cooldown) then --create a new event to show the latest cooldown the player used before death and add it to the list of events before death local eventType = 3 --last cooldown used @@ -4155,6 +4169,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 eventsBeforePlayerDeath[#eventsBeforePlayerDeath+1] = eventTable end + + local maxHealth if (thisPlayer.arena_enemy) then --this is an arena enemy, get the heal with the unit Id @@ -4750,7 +4766,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end if (not _in_combat) then - Details:EntrarEmCombate() + Details222.StartCombat() end _current_combat.pvp = true @@ -5050,11 +5066,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 if (_in_combat) then Details:SairDoCombate() end - Details:EntrarEmCombate() + Details222.StartCombat() end if (not Details:CaptureGet("damage")) then - Details:EntrarEmCombate() + Details222.StartCombat() end --essa parte do solo mode ainda sera usada? @@ -5595,7 +5611,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end Details.lastBattlegroundStartTime = GetTime() - Details:StartCombat() + Details222.StartCombat() if (Details.debug) then Details:Msg("(debug) a battleground has started.") @@ -5899,7 +5915,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 -- ~parserstart ~startparser ~cleu ~parser Details.UnitNameCache = {} - function Details.OnParserEvent(self, event, ...) + function Details222.Parser.OnParserEvent(self, event, ...) 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] @@ -5914,79 +5930,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 if (not parserDebug[token]) then parserDebug[token] = true - --print(token) end - - if (token == "SPELL_DAMAGE") then - if (A13 ~= nil or unknown1 ~= nil or unknown2 ~= nil or unknown3 ~= nil or unknown4 ~= nil or unknown5) then - --print(time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, spellId, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) - end - --print(time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, spellId, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) - - if (spellName == "Fate Mirror") then - --print(time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, spellId, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) - end - end - - if (token == "SPELL_AURA_APPLIED") then - --print(spellName) - end - - --local func = token_list[token] - --if (func) then - -- return func(nil, token, time, who_serial, who_name, who_flags, target_serial, target_name, target_flags, target_flags2, spellId, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) - --end - - --[=[ getspellinfo - ["1"] = "Spatial Paradox", buff - ["3"] = 5199645, - ["4"] = 0, - ["5"] = 0, - ["6"] = 100, - ["7"] = 406789, - ["8"] = 5199645, - - ["1"] = "Spatial Paradox", buff - ["3"] = 5199645, - ["4"] = 0, - ["5"] = 0, - ["6"] = 60, - ["7"] = 406732, - ["8"] = 5199645, - - ["1"] = "Ebon Might", --spell cast start - ["3"] = 5061347, - ["4"] = 1473, - ["5"] = 0, - ["6"] = 0, - ["7"] = 395152, - ["8"] = 5061347, - --]=] - - if (sourceSerial == UnitGUID("player")) then - GLOB = GLOB or {} - --table.insert(GLOB, {time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, spellId, spellName, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18}) - --print(time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, spellId, spellName, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) - end - - if (token == "SPELL_CAST_START") then - if (sourceSerial == UnitGUID("player")) then - --print(token, spellName, spellId) - end - end - - --Prescience, Fate Mirror, Ebon Might, Breath of Eons, Shifting Sands - - --offline cleu: - --6/30 14:25:28.988 SPELL_DAMAGE,Player-5764-0001609B,"Mikito-Fyrakk",0x518,0x0,Creature-0-5770-2444-8-198594-00009DF6EF,"Cleave Training Dummy",0x30a28,0x0,44425,"Arcane Barrage",0x40,0000000000000000,0000000000000000,0,0,0,0,0,0,-1,0,0,0,0.00,0.00,2112,0.0000,0,18252,18251,-1,64,0,0,0,nil,nil,nil - --6/30 14:25:28.988 SPELL_DAMAGE_SUPPORT,Player-5764-0001609B,"Mikito-Fyrakk",0x518,0x0,Creature-0-5770-2444-8-198594-00009DF6EF,"Cleave Training Dummy",0x30a28,0x0,395152,"Ebon Might",0xc,0000000000000000,0000000000000000,0,0,0,0,0,0,-1,0,0,0,0.00,0.00,2112,0.0000,0,2572,2571,-1,64,0,0,0,nil,nil,nil,Player-5764-0001FACE end - if (false and "I'm debugging something") then - Details.parser_frame:SetScript("OnEvent", Details.OnParserEventDebug) - else - Details.parser_frame:SetScript("OnEvent", Details.OnParserEvent) - end + Details222.parser_frame:SetScript("OnEvent", Details222.Parser.OnParserEvent) + Details222.PFrame = Details222.parser_frame function Details:UpdateParser() _tempo = Details._tempo diff --git a/core/windows.lua b/core/windows.lua index 7ed0968e..8ea645ea 100644 --- a/core/windows.lua +++ b/core/windows.lua @@ -641,7 +641,7 @@ for _, instancia in ipairs(self.stretchToo) do instancia.baseframe:SetWidth(self.baseframe:GetWidth()) local mod = (self.baseframe:GetWidth() - instancia.baseframe._place.largura) / 2 - instancia:RestoreMainWindowPositionNoResize (instancia.baseframe._place, mod, nil) + instancia:RestoreMainWindowPositionNoResize(instancia.baseframe._place, mod, nil) instancia:BaseFrameSnap() end end @@ -656,7 +656,7 @@ else mod = - (self.baseframe:GetHeight() - instancia.baseframe._place.altura) / 2 end - instancia:RestoreMainWindowPositionNoResize (instancia.baseframe._place, nil, mod) + instancia:RestoreMainWindowPositionNoResize(instancia.baseframe._place, nil, mod) instancia:BaseFrameSnap() end end @@ -667,7 +667,7 @@ for _, instancia in ipairs(self.stretchToo) do instancia.baseframe:SetHeight(self.baseframe:GetHeight()) local mod = (self.baseframe:GetHeight() - (instancia.baseframe._place.altura or instancia.baseframe:GetHeight())) / 2 - instancia:RestoreMainWindowPositionNoResize (instancia.baseframe._place, nil, mod) + instancia:RestoreMainWindowPositionNoResize(instancia.baseframe._place, nil, mod) end elseif (self.baseframe.stretch_direction == "bottom") then @@ -675,18 +675,18 @@ instancia.baseframe:SetHeight(self.baseframe:GetHeight()) local mod = (self.baseframe:GetHeight() - instancia.baseframe._place.altura) / 2 mod = mod * -1 - instancia:RestoreMainWindowPositionNoResize (instancia.baseframe._place, nil, mod) + instancia:RestoreMainWindowPositionNoResize(instancia.baseframe._place, nil, mod) end end end if (self.stretch_button_side == 2) then - self:StretchButtonAnchor (2) + self:StretchButtonAnchor(2) end --reajusta o freeze if (self.freezed) then - Details:Freeze (self) + Details:Freeze(self) end -- -4 difere a precis�o de quando a barra ser� adicionada ou apagada da barra @@ -701,7 +701,7 @@ local meio = self.baseframe:GetWidth() / 2 local novo_local = meio - 25 - self.rows_fit_in_window = floor( self.baseframe.BoxBarrasAltura / self.row_height) + self.rows_fit_in_window = floor(self.baseframe.BoxBarrasAltura / self.row_height) --verifica se precisa criar mais barras if (self.rows_fit_in_window > #self.barras) then--verifica se precisa criar mais barras @@ -717,12 +717,16 @@ --seta a largura das barras if (self.bar_mod and self.bar_mod ~= 0) then for index = 1, self.rows_fit_in_window do - self.barras [index]:SetWidth(self.baseframe:GetWidth()+self.bar_mod) + if (self.barras[index]) then + self.barras[index]:SetWidth(self.baseframe:GetWidth()+self.bar_mod) + end end else local rightOffset = self.row_info.row_offsets.right for index = 1, self.rows_fit_in_window do - self.barras [index]:SetWidth(self.baseframe:GetWidth()+self.row_info.space.right + rightOffset) + if (self.barras[index]) then + self.barras[index]:SetWidth(self.baseframe:GetWidth()+self.row_info.space.right + rightOffset) + end end end @@ -731,8 +735,8 @@ if (not A) then --primeira vez que o resize esta sendo usado, no caso no startup do addon ou ao criar uma nova inst�ncia --hida as barras n�o usadas for i = 1, self.rows_created, 1 do - Details.FadeHandler.Fader(self.barras [i], 1) - self.barras [i].on = false + Details.FadeHandler.Fader(self.barras[i], 1) + self.barras[i].on = false end return end @@ -834,7 +838,7 @@ if (tabela._custom) then tabela (esta_barra, self) elseif (tabela._refresh_window) then - tabela:_refresh_window (esta_barra, self) + tabela:_refresh_window(esta_barra, self) else tabela:RefreshBarra(esta_barra, self, true) end diff --git a/frames/window_main.lua b/frames/window_main.lua index cd456ea4..974d2de9 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -7,6 +7,7 @@ local segmentos = Details.segmentos ---@type detailsframework local gump = Details.gump +local DF = gump local _ ---@type detailsframework @@ -15,7 +16,6 @@ local detailsFramework = DetailsFramework --lua locals local ceil = math.ceil local floor = math.floor -local _math_max = math.max local ipairs = ipairs local pairs = pairs local abs = _G.abs @@ -40,7 +40,7 @@ _ = nil --constants local baseframe_strata = "LOW" local defaultBackdropSt = { - bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, + bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 12, insets = {left = 0, right = 0, top = 0, bottom = 0}} local CONST_ROWFRAME_ALPHA = 0.975036 @@ -60,6 +60,10 @@ function Details:ScheduleUpdate(instancia) end end +local GetSpellLink = GetSpellLink or C_Spell.GetSpellLink --api local +local GetSpellInfo = Details222.GetSpellInfo --api local +local _GetSpellInfo = Details.getspellinfo --details api + --skins TCoords local DEFAULT_SKIN = [[Interface\AddOns\Details\images\skins\classic_skin]] local COORDS_LEFT_BALL = {0.15625, 0.2802734375, 0.08203125, 0.2060546875} -- 160 287 84 211 @@ -90,10 +94,13 @@ end tile=true, insets = {top=0, right=0, left=0, bottom=0} } + local menus_backdropcolor = {.2, .2, .2, 0.85} local menus_backdropcolor_sec = {.2, .2, .2, 0.90} local menus_bordercolor = {0, 0, 0, .25} + local authorInfo = detailsFramework.AuthorInfo + --menus are ignoring the value set on the profile Details.menu_backdrop_config = { menus_backdrop = menus_backdrop, @@ -159,6 +166,7 @@ function Details:RefreshScrollBar(x) --x = amount of bars being refreshed end --self é a janela das barras +--this function was used in the past when the scroll bar was still a thing local function move_barras(self, elapsed) self._move_func.time = self._move_func.time+elapsed if (self._move_func.time > 0.01) then @@ -172,7 +180,7 @@ local function move_barras(self, elapsed) self._move_func.instancia.bgdisplay_loc = self._move_func.instancia.bgdisplay_loc + self._move_func.inc --inc � -1 ou 1 e ir� crescer ou diminuir a janela for index = 1, self._move_func.instancia.rows_fit_in_window do - self._move_func.instancia.barras [index]:SetWidth(self:GetWidth()+self._move_func.instancia.bgdisplay_loc-3) + self._move_func.instancia.barras[index]:SetWidth(self:GetWidth()+self._move_func.instancia.bgdisplay_loc-3) end self._move_func.instancia.bgdisplay:SetPoint("bottomright", self, "bottomright", self._move_func.instancia.bgdisplay_loc, 0) @@ -180,14 +188,15 @@ local function move_barras(self, elapsed) --verifica o tamanho do text for i = 1, #self._move_func.instancia.barras do - local esta_barra = self._move_func.instancia.barras [i] - Details:name_space (esta_barra) + local esta_barra = self._move_func.instancia.barras[i] + Details:name_space(esta_barra) end end end end --self � a inst�ncia +--another function for the scroll bar, it is deprecated now function Details:MoveBarrasTo(destino) local janela = self.baseframe @@ -207,8 +216,8 @@ function Details:MoveBarrasTo(destino) end --almost deprecated +--scrollbar isn't in use for years function Details:MostrarScrollBar(sem_animacao) - if (self.rolagem) then return end @@ -225,7 +234,7 @@ function Details:MostrarScrollBar(sem_animacao) local mover_para = self.largura_scroll*-1 if (not sem_animacao and Details.animate_scroll) then - self:MoveBarrasTo (mover_para) + self:MoveBarrasTo(mover_para) else --set size of rows for index = 1, self.rows_fit_in_window do @@ -259,12 +268,10 @@ function Details:MostrarScrollBar(sem_animacao) if (main.isLocked) then main.lock_button:SetPoint("bottomright", main, "bottomright", self.largura_scroll*-1, 0) end - end --almost deprecated -function Details:EsconderScrollBar (sem_animacao, force) - +function Details:EsconderScrollBar(sem_animacao, force) if (not self.rolagem) then return end @@ -279,10 +286,10 @@ function Details:EsconderScrollBar (sem_animacao, force) local main = self.baseframe if (not sem_animacao and Details.animate_scroll) then - self:MoveBarrasTo (self.row_info.space.right + 3) --> + self:MoveBarrasTo(self.row_info.space.right + 3) --> else for index = 1, self.rows_fit_in_window do - self.barras [index]:SetWidth(self.baseframe:GetWidth() - 5) ---5 space between row end and window right border + self.barras[index]:SetWidth(self.baseframe:GetWidth() - 5) ---5 space between row end and window right border end self.bgdisplay:SetPoint("bottomright", self.baseframe, "bottomright", 0, 0) -- voltar o background na poci��o inicial self.bar_mod = 0 -- zera o bar mod, uma vez que as barras v�o estar na pocis�o inicial @@ -302,12 +309,14 @@ function Details:EsconderScrollBar (sem_animacao, force) end end +--when the mouse leaves a instance window local function OnLeaveMainWindow(instancia, self) instancia.is_interacting = false instancia:SetMenuAlpha(nil, nil, nil, nil, true) instancia:SetAutoHideMenu(nil, nil, true) instancia:RefreshAttributeTextSize() + --alone mode has been deprecated for 9 years if (instancia.modo ~= Details._detalhes_props["MODO_ALONE"] and not instancia.baseframe.isLocked) then --resizes, lock and ungroup buttons if (not Details.disable_lock_ungroup_buttons) then @@ -320,6 +329,7 @@ local function OnLeaveMainWindow(instancia, self) --stretch button Details.FadeHandler.Fader(instancia.baseframe.button_stretch, "ALPHA", 0) + --alone mode has been deprecated for 9 years elseif (instancia.modo ~= Details._detalhes_props["MODO_ALONE"] and instancia.baseframe.isLocked) then --resizes, lock and ungroup buttons if (not Details.disable_lock_ungroup_buttons) then @@ -330,8 +340,10 @@ local function OnLeaveMainWindow(instancia, self) Details.FadeHandler.Fader(instancia.baseframe.button_stretch, "ALPHA", 0) end end + Details.OnLeaveMainWindow = OnLeaveMainWindow +--when the mouse cursor enters a instance window local function OnEnterMainWindow(instancia, self) instancia.is_interacting = true instancia:SetMenuAlpha(nil, nil, nil, nil, true) @@ -389,11 +401,13 @@ end Details.OnEnterMainWindow = OnEnterMainWindow -local function VPL (instancia, esta_instancia) +--functions to calculate the snapping feature + +local function VPL(instance, esta_instancia) --conferir esquerda - if (instancia.ponto4.x-0.5 < esta_instancia.ponto1.x) then --a janela esta a esquerda - if (instancia.ponto4.x+20 > esta_instancia.ponto1.x) then --a janela esta a menos de 20 pixels de dist�ncia - if (instancia.ponto4.y < esta_instancia.ponto1.y + 100 and instancia.ponto4.y > esta_instancia.ponto1.y - 100) then --a janela esta a +20 ou -20 pixels de dist�ncia na vertical + if (instance.ponto4.x-0.5 < esta_instancia.ponto1.x) then --a janela esta a esquerda + if (instance.ponto4.x+20 > esta_instancia.ponto1.x) then --a janela esta a menos de 20 pixels de dist�ncia + if (instance.ponto4.y < esta_instancia.ponto1.y + 100 and instance.ponto4.y > esta_instancia.ponto1.y - 100) then --a janela esta a +20 ou -20 pixels de dist�ncia na vertical return 1 end end @@ -401,11 +415,11 @@ local function VPL (instancia, esta_instancia) return nil end -local function VPB (instancia, esta_instancia) +local function VPB(instance, esta_instancia) --conferir baixo - if (instancia.ponto1.y+(20 * instancia.window_scale) < esta_instancia.ponto2.y - (16 * esta_instancia.window_scale)) then --a janela esta em baixo - if (instancia.ponto1.x > esta_instancia.ponto2.x-100 and instancia.ponto1.x < esta_instancia.ponto2.x+100) then --a janela esta a 20 pixels de dist�ncia para a esquerda ou para a direita - if (instancia.ponto1.y+(20 * instancia.window_scale) > esta_instancia.ponto2.y - (36 * esta_instancia.window_scale)) then --esta a 20 pixels de dist�ncia + if (instance.ponto1.y+(20 * instance.window_scale) < esta_instancia.ponto2.y - (16 * esta_instancia.window_scale)) then --a janela esta em baixo + if (instance.ponto1.x > esta_instancia.ponto2.x-100 and instance.ponto1.x < esta_instancia.ponto2.x+100) then --a janela esta a 20 pixels de dist�ncia para a esquerda ou para a direita + if (instance.ponto1.y+(20 * instance.window_scale) > esta_instancia.ponto2.y - (36 * esta_instancia.window_scale)) then --esta a 20 pixels de dist�ncia return 2 end end @@ -413,11 +427,11 @@ local function VPB (instancia, esta_instancia) return nil end -local function VPR (instancia, esta_instancia) +local function VPR(instance, esta_instancia) --conferir lateral direita - if (instancia.ponto2.x+0.5 > esta_instancia.ponto3.x) then --a janela esta a direita - if (instancia.ponto2.x-20 < esta_instancia.ponto3.x) then --a janela esta a menos de 20 pixels de dist�ncia - if (instancia.ponto2.y < esta_instancia.ponto3.y + 100 and instancia.ponto2.y > esta_instancia.ponto3.y - 100) then --a janela esta a +20 ou -20 pixels de dist�ncia na vertical + if (instance.ponto2.x+0.5 > esta_instancia.ponto3.x) then --a janela esta a direita + if (instance.ponto2.x-20 < esta_instancia.ponto3.x) then --a janela esta a menos de 20 pixels de dist�ncia + if (instance.ponto2.y < esta_instancia.ponto3.y + 100 and instance.ponto2.y > esta_instancia.ponto3.y - 100) then --a janela esta a +20 ou -20 pixels de dist�ncia na vertical return 3 end end @@ -425,11 +439,11 @@ local function VPR (instancia, esta_instancia) return nil end -local function VPT (instancia, esta_instancia) +local function VPT(instance, esta_instancia) --conferir cima - if (instancia.ponto3.y - (16 * instancia.window_scale) > esta_instancia.ponto4.y + (20 * esta_instancia.window_scale)) then --a janela esta em cima - if (instancia.ponto3.x > esta_instancia.ponto4.x-100 and instancia.ponto3.x < esta_instancia.ponto4.x+100) then --a janela esta a 20 pixels de dist�ncia para a esquerda ou para a direita - if (esta_instancia.ponto4.y+(40 * esta_instancia.window_scale) > instancia.ponto3.y - (16 * instancia.window_scale)) then + if (instance.ponto3.y - (16 * instance.window_scale) > esta_instancia.ponto4.y + (20 * esta_instancia.window_scale)) then --a janela esta em cima + if (instance.ponto3.x > esta_instancia.ponto4.x-100 and instance.ponto3.x < esta_instancia.ponto4.x+100) then --a janela esta a 20 pixels de dist�ncia para a esquerda ou para a direita + if (esta_instancia.ponto4.y+(40 * esta_instancia.window_scale) > instance.ponto3.y - (16 * instance.window_scale)) then return 4 end end @@ -437,11 +451,25 @@ local function VPT (instancia, esta_instancia) return nil end -Details.VPT, Details.VPR, Details.VPB, Details.VPL = VPT, VPR, VPB, VPL +Details.VPT = VPT +Details.VPR = VPR +Details.VPB = VPB +Details.VPL = VPL -local color_red = {1, 0.2, 0.2} -local color_green = {0.2, 1, 0.2} -local pixels_per_arrow = 50 +local colorRedTable = {1, 0.2, 0.2} +local colorGreenTable = {0.2, 1, 0.2} +local pixelsPerArrow = 50 +local commentador = C_Commentator or {FollowUnit = function()end, FollowPlayer = function()end} + +local tempo_movendo +local precisa_ativar +local instancia_alvo +local tempo_fades +local nao_anexados +local flash_bounce +local start_draw_lines +local instance_ids_shown +local need_show_group_guide local show_instance_ids = function() for id, instance in Details:ListInstances() do @@ -524,16 +552,16 @@ local update_line = function(self, target_frame) self.instance:AtualizaPontos() target_frame.instance:AtualizaPontos() - local color = color_red + local color = colorRedTable local _R, _T, _L, _B = VPL (self.instance, target_frame.instance), VPB (self.instance, target_frame.instance), VPR (self.instance, target_frame.instance), VPT (self.instance, target_frame.instance) if (_R or _T or _L or _B) then - color = color_green + color = colorGreenTable end - for i = 0, (distance/pixels_per_arrow) do - local x = distance - (i * pixels_per_arrow) + for i = 0, (distance/pixelsPerArrow) do + local x = distance - (i * pixelsPerArrow) x = x * cos(angle) - local y = distance - (i * pixels_per_arrow) + local y = distance - (i * pixelsPerArrow) y = y * sin(angle) local ball = guide_balls [i] @@ -554,10 +582,7 @@ local update_line = function(self, target_frame) end -local tempo_movendo, precisa_ativar, instancia_alvo, tempo_fades, nao_anexados, flash_bounce, start_draw_lines, instance_ids_shown, need_show_group_guide - local movement_onupdate = function(self, elapsed) - if (start_draw_lines and start_draw_lines > 0.95) then update_line (self, instancia_alvo.baseframe) elseif (start_draw_lines) then @@ -703,7 +728,7 @@ local movement_onupdate = function(self, elapsed) end local function move_janela(baseframe, iniciando, instancia, just_updating) - instancia_alvo = Details.tabela_instancias [instancia.meu_id-1] + instancia_alvo = Details:GetAllInstances() [instancia.meu_id-1] if (Details.disable_window_groups) then instancia_alvo = nil end @@ -912,7 +937,7 @@ local function move_janela(baseframe, iniciando, instancia, just_updating) end end - for _, esta_instancia in ipairs(Details.tabela_instancias) do + for _, esta_instancia in ipairs(Details:GetAllInstances()) do if (not esta_instancia:IsAtiva() and esta_instancia.iniciada) then esta_instancia:ResetaGump() @@ -936,7 +961,7 @@ local function move_janela(baseframe, iniciando, instancia, just_updating) end --salva pos de todas as janelas - for _, ins in ipairs(Details.tabela_instancias) do + for _, ins in ipairs(Details:GetAllInstances()) do if (ins:IsEnabled()) then ins:SaveMainWindowPosition() ins:RestoreMainWindowPosition() @@ -1095,7 +1120,7 @@ local function instancias_horizontais (instancia, largura, esquerda, direita) if (esquerda) then for lado, esta_instancia in pairs(instancia.snap) do if (lado == 1) then --movendo para esquerda - local instancia = Details.tabela_instancias [esta_instancia] + local instancia = Details:GetAllInstances() [esta_instancia] instancia.baseframe:SetWidth(largura) instancia.auto_resize = true instancia:ReajustaGump() @@ -1109,7 +1134,7 @@ local function instancias_horizontais (instancia, largura, esquerda, direita) if (direita) then for lado, esta_instancia in pairs(instancia.snap) do if (lado == 3) then --movendo para esquerda - local instancia = Details.tabela_instancias [esta_instancia] + local instancia = Details:GetAllInstances() [esta_instancia] instancia.baseframe:SetWidth(largura) instancia.auto_resize = true instancia:ReajustaGump() @@ -1125,7 +1150,7 @@ local function instancias_verticais (instancia, altura, esquerda, direita) if (esquerda) then for lado, esta_instancia in pairs(instancia.snap) do if (lado == 1) then --movendo para esquerda - local instancia = Details.tabela_instancias [esta_instancia] + local instancia = Details:GetAllInstances() [esta_instancia] if (instancia:IsEnabled()) then instancia.baseframe:SetHeight(altura) instancia.auto_resize = true @@ -1141,7 +1166,7 @@ local function instancias_verticais (instancia, altura, esquerda, direita) if (direita) then for lado, esta_instancia in pairs(instancia.snap) do if (lado == 3) then --movendo para esquerda - local instancia = Details.tabela_instancias [esta_instancia] + local instancia = Details:GetAllInstances() [esta_instancia] if (instancia:IsEnabled()) then instancia.baseframe:SetHeight(altura) instancia.auto_resize = true @@ -1166,11 +1191,17 @@ end function Details:InstanciasVerticais(instance) instance = self or instance + --instances that are above the current instance local on_top = {} + + --instances that are below the current instance local on_bottom = {} + + --id of the current instance local id = instance:GetId() --lower instances + --this is getting the instance of ID - 1, this is the reason why details windows always snap with the previous window local this_instance = Details:GetInstance(id-1) if (this_instance) then --top side @@ -1227,36 +1258,36 @@ function Details:InstanciasVerticais(instance) end --calc top clamp - local top_clamp = 0 - local bottom_clamp = 0 + local topClampPixels = 0 + local bottomClampPixels = 0 if (instance.toolbar_side == 1) then - top_clamp = top_clamp + 20 + topClampPixels = topClampPixels + 20 elseif (instance.toolbar_side == 2) then - bottom_clamp = bottom_clamp + 20 + bottomClampPixels = bottomClampPixels + 20 end if (instance.show_statusbar) then - bottom_clamp = bottom_clamp + 14 + bottomClampPixels = bottomClampPixels + 14 end - for cid, this_instance in ipairs(on_top) do - if (this_instance.show_statusbar) then - top_clamp = top_clamp + 14 + for cid, thisInstance in ipairs(on_top) do + if (thisInstance.show_statusbar) then + topClampPixels = topClampPixels + 14 end - top_clamp = top_clamp + 20 - top_clamp = top_clamp + this_instance.baseframe:GetHeight() + topClampPixels = topClampPixels + 20 + topClampPixels = topClampPixels + thisInstance.baseframe:GetHeight() end - for cid, this_instance in ipairs(on_bottom) do - if (this_instance.show_statusbar) then - bottom_clamp = bottom_clamp + 14 + for cid, thisInstance in ipairs(on_bottom) do + if (thisInstance.show_statusbar) then + bottomClampPixels = bottomClampPixels + 14 end - bottom_clamp = bottom_clamp + 20 - bottom_clamp = bottom_clamp + this_instance.baseframe:GetHeight() - table.insert(on_top, this_instance) + bottomClampPixels = bottomClampPixels + 20 + bottomClampPixels = bottomClampPixels + thisInstance.baseframe:GetHeight() + table.insert(on_top, thisInstance) end - return on_top, bottom_clamp, top_clamp + return on_top, bottomClampPixels, topClampPixels end --[[ @@ -1279,11 +1310,11 @@ function Details:InstanciasHorizontais(instancia) local checking = instancia - local check_index_anterior = Details.tabela_instancias [instancia.meu_id-1] + local check_index_anterior = Details:GetAllInstances() [instancia.meu_id-1] if (check_index_anterior and check_index_anterior:IsEnabled()) then --possiu uma inst�ncia antes de mim if (check_index_anterior.snap[3] and check_index_anterior.snap[3] == instancia.meu_id) then --o index negativo vai para a esquerda for i = instancia.meu_id-1, 1, -1 do - local esta_instancia = Details.tabela_instancias [i] + local esta_instancia = Details:GetAllInstances() [i] if (esta_instancia.snap[3]) then if (esta_instancia.snap[3] == checking.meu_id) then linha_horizontal [#linha_horizontal+1] = esta_instancia @@ -1297,7 +1328,7 @@ function Details:InstanciasHorizontais(instancia) elseif (check_index_anterior.snap[1] and check_index_anterior.snap[1] == instancia.meu_id) then --o index negativo vai para a direita for i = instancia.meu_id-1, 1, -1 do - local esta_instancia = Details.tabela_instancias [i] + local esta_instancia = Details:GetAllInstances() [i] if (esta_instancia.snap[1]) then if (esta_instancia.snap[1] == checking.meu_id) then linha_horizontal [#linha_horizontal+1] = esta_instancia @@ -1313,11 +1344,11 @@ function Details:InstanciasHorizontais(instancia) checking = instancia - local check_index_posterior = Details.tabela_instancias [instancia.meu_id+1] + local check_index_posterior = Details:GetAllInstances() [instancia.meu_id+1] if (check_index_posterior and check_index_posterior:IsEnabled()) then if (check_index_posterior.snap[3] and check_index_posterior.snap[3] == instancia.meu_id) then --o index posterior vai para a esquerda - for i = instancia.meu_id+1, #Details.tabela_instancias do - local esta_instancia = Details.tabela_instancias [i] + for i = instancia.meu_id+1, #Details:GetAllInstances() do + local esta_instancia = Details:GetAllInstances() [i] if (esta_instancia.snap[3]) then if (esta_instancia.snap[3] == checking.meu_id) then linha_horizontal [#linha_horizontal+1] = esta_instancia @@ -1330,8 +1361,8 @@ function Details:InstanciasHorizontais(instancia) end elseif (check_index_posterior.snap[1] and check_index_posterior.snap[1] == instancia.meu_id) then --o index posterior vai para a direita - for i = instancia.meu_id+1, #Details.tabela_instancias do - local esta_instancia = Details.tabela_instancias [i] + for i = instancia.meu_id+1, #Details:GetAllInstances() do + local esta_instancia = Details:GetAllInstances() [i] if (esta_instancia.snap[1]) then if (esta_instancia.snap[1] == checking.meu_id) then linha_horizontal [#linha_horizontal+1] = esta_instancia @@ -1501,7 +1532,7 @@ local resizeScriptsOnMouseUp = function(self, button) Details:SendEvent("DETAILS_INSTANCE_ENDRESIZE", nil, self._instance) if (self._instance.eh_tudo) then - for _, esta_instancia in ipairs(Details.tabela_instancias) do + for _, esta_instancia in ipairs(Details:GetAllInstances()) do if (esta_instancia:IsAtiva() and esta_instancia.modo ~= Details._detalhes_props["MODO_ALONE"]) then esta_instancia.baseframe:ClearAllPoints() esta_instancia:SaveMainWindowPosition() @@ -1509,7 +1540,7 @@ local resizeScriptsOnMouseUp = function(self, button) end end - for _, esta_instancia in ipairs(Details.tabela_instancias) do + for _, esta_instancia in ipairs(Details:GetAllInstances()) do if (esta_instancia:IsAtiva() and esta_instancia ~= self._instance and esta_instancia.modo ~= Details._detalhes_props["MODO_ALONE"]) then esta_instancia.baseframe:SetWidth(largura) esta_instancia.baseframe:SetHeight(altura) @@ -1527,7 +1558,7 @@ local resizeScriptsOnMouseUp = function(self, button) self._instance:BaseFrameSnap() - for _, esta_instancia in ipairs(Details.tabela_instancias) do + for _, esta_instancia in ipairs(Details:GetAllInstances()) do if (esta_instancia:IsAtiva()) then esta_instancia:SaveMainWindowPosition() esta_instancia:RestoreMainWindowPosition() @@ -2425,21 +2456,20 @@ local setLineScripts = function(line, instance, index) line.SetValue = setBarValue end -function Details:ReportSingleLine (instancia, barra) - +function Details:ReportSingleLine(instance, windowLine) local reportar - if (instancia.atributo == 5) then --custom - + local displayId = instance:GetDisplay() + if (displayId == 5) then --custom --dump cooltip local GameCooltip = GameCooltip if (GameCooltipFrame1:IsShown()) then - local actor_name = barra.lineText1:GetText() or "" + local actor_name = windowLine.lineText1:GetText() or "" actor_name = actor_name:gsub((".*%."), "") - if (instancia.segmento == -1) then --overall - reportar = {"Details!: " .. Loc["STRING_OVERALL"] .. " " .. instancia.customName .. ": " .. actor_name .. " " .. Loc["STRING_CUSTOM_REPORT"]} + if (instance.segmento == -1) then --overall + reportar = {"Details!: " .. Loc["STRING_OVERALL"] .. " " .. instance.customName .. ": " .. actor_name .. " " .. Loc["STRING_CUSTOM_REPORT"]} else - reportar = {"Details!: " .. instancia.customName .. ": " .. actor_name .. " " .. Loc["STRING_CUSTOM_REPORT"]} + reportar = {"Details!: " .. instance.customName .. ": " .. actor_name .. " " .. Loc["STRING_CUSTOM_REPORT"]} end local amt = GameCooltip.Indexes @@ -2448,23 +2478,22 @@ function Details:ReportSingleLine (instancia, barra) reportar [#reportar+1] = (i-1) .. ". " .. left_text .. " ... " .. right_text end else - reportar = {"Details!: " .. instancia.customName .. ": " .. Loc["STRING_CUSTOM_REPORT"]} - reportar [#reportar+1] = barra.lineText1:GetText() .. " " .. barra.lineText4:GetText() + reportar = {"Details!: " .. instance.customName .. ": " .. Loc["STRING_CUSTOM_REPORT"]} + reportar [#reportar+1] = windowLine.lineText1:GetText() .. " " .. windowLine.lineText4:GetText() --reportar [#reportar+1] = (i-1) .. ". " .. left_text .. " ... " .. right_text end else - reportar = {"Details!: " .. Loc["STRING_REPORT"] .. " " .. Details.sub_atributos [instancia.atributo].lista [instancia.sub_atributo]} - reportar [#reportar+1] = barra.lineText1:GetText() .. " " .. barra.lineText4:GetText() + reportar = {"Details!: " .. Loc["STRING_REPORT"] .. " " .. Details.sub_atributos [displayId].lista [instance.sub_atributo]} + reportar [#reportar+1] = windowLine.lineText1:GetText() .. " " .. windowLine.lineText4:GetText() end - - return Details:Reportar (reportar, {_no_current = true, _no_inverse = true, _custom = true}) + return Details:Reportar(reportar, {_no_current = true, _no_inverse = true, _custom = true}) end -- ~stretch -local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) +local function button_stretch_scripts(baseframe, backgrounddisplay, instancia) local button = baseframe.button_stretch button:SetScript("OnEnter", function(self) @@ -2473,6 +2502,7 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) Details.FadeHandler.Fader(self, "ALPHA", 1) end end) + button:SetScript("OnLeave", function(self) self.mouse_over = false Details.FadeHandler.Fader(self, "ALPHA", 0) @@ -2506,16 +2536,17 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) if (instancia.stretch_button_side == 1) then baseframe:StartSizing("top") baseframe.stretch_direction = "top" + elseif (instancia.stretch_button_side == 2) then baseframe:StartSizing("bottom") baseframe.stretch_direction = "bottom" end + ---@type instance[] local linha_horizontal = {} - local checking = instancia for i = instancia.meu_id-1, 1, -1 do - local esta_instancia = Details.tabela_instancias [i] + local esta_instancia = Details:GetAllInstances() [i] if ((esta_instancia.snap[1] and esta_instancia.snap[1] == checking.meu_id) or (esta_instancia.snap[3] and esta_instancia.snap[3] == checking.meu_id)) then linha_horizontal [#linha_horizontal+1] = esta_instancia checking = esta_instancia @@ -2525,8 +2556,8 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) end checking = instancia - for i = instancia.meu_id+1, #Details.tabela_instancias do - local esta_instancia = Details.tabela_instancias [i] + for i = instancia.meu_id+1, #Details:GetAllInstances() do + local esta_instancia = Details:GetAllInstances() [i] if ((esta_instancia.snap[1] and esta_instancia.snap[1] == checking.meu_id) or (esta_instancia.snap[3] and esta_instancia.snap[3] == checking.meu_id)) then linha_horizontal [#linha_horizontal+1] = esta_instancia checking = esta_instancia @@ -2566,11 +2597,9 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) Details:SetWindowUpdateSpeed(0.3, true) Details.stretch_changed_update_speed = true end - end) button:SetScript("OnMouseUp", function(self, button) - if (button ~= "LeftButton") then return end @@ -2597,35 +2626,35 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) baseframe.stretch_direction = nil if (instancia.stretchToo and #instancia.stretchToo > 0) then - for _, esta_instancia in ipairs(instancia.stretchToo) do - esta_instancia.baseframe:StopMovingOrSizing() - esta_instancia.baseframe.isResizing = false - esta_instancia:RestoreMainWindowPosition (esta_instancia.baseframe._place) - esta_instancia:ReajustaGump() - esta_instancia.baseframe.isStretching = false - if (esta_instancia.need_rolagem) then - esta_instancia:MostrarScrollBar(true) + for _, thisInstance in ipairs(instancia.stretchToo) do + thisInstance.baseframe:StopMovingOrSizing() + thisInstance.baseframe.isResizing = false + thisInstance:RestoreMainWindowPosition (thisInstance.baseframe._place) + thisInstance:ReajustaGump() + thisInstance.baseframe.isStretching = false + if (thisInstance.need_rolagem) then + thisInstance:MostrarScrollBar(true) end - Details:SendEvent("DETAILS_INSTANCE_SIZECHANGED", nil, esta_instancia) + Details:SendEvent("DETAILS_INSTANCE_SIZECHANGED", nil, thisInstance) - local _r, _g, _b, _a = esta_instancia.baseframe:GetBackdropColor() - gump:GradientEffect(esta_instancia.baseframe, "frame", _r, _g, _b, _a, instancia.bg_r, instancia.bg_g, instancia.bg_b, instancia.bg_alpha, 0.5) + local _r, _g, _b, _a = thisInstance.baseframe:GetBackdropColor() + gump:GradientEffect(thisInstance.baseframe, "frame", _r, _g, _b, _a, instancia.bg_r, instancia.bg_g, instancia.bg_b, instancia.bg_alpha, 0.5) - if (esta_instancia.wallpaper.enabled) then - _r, _g, _b = esta_instancia.baseframe.wallpaper:GetVertexColor() - _a = esta_instancia.baseframe.wallpaper:GetAlpha() - gump:GradientEffect(esta_instancia.baseframe.wallpaper, "texture", _r, _g, _b, _a, _r, _g, _b, esta_instancia.wallpaper.alpha, 1.0) + if (thisInstance.wallpaper.enabled) then + _r, _g, _b = thisInstance.baseframe.wallpaper:GetVertexColor() + _a = thisInstance.baseframe.wallpaper:GetAlpha() + gump:GradientEffect(thisInstance.baseframe.wallpaper, "texture", _r, _g, _b, _a, _r, _g, _b, thisInstance.wallpaper.alpha, 1.0) end - esta_instancia.baseframe:SetFrameStrata(esta_instancia.strata) - esta_instancia.rowframe:SetFrameStrata(esta_instancia.strata) - esta_instancia:StretchButtonAlwaysOnTop() + thisInstance.baseframe:SetFrameStrata(thisInstance.strata) + thisInstance.rowframe:SetFrameStrata(thisInstance.strata) + thisInstance:StretchButtonAlwaysOnTop() - Details:SendEvent("DETAILS_INSTANCE_ENDSTRETCH", nil, esta_instancia.baseframe) + Details:SendEvent("DETAILS_INSTANCE_ENDSTRETCH", nil, thisInstance.baseframe) - esta_instancia:RefreshBars() - esta_instancia:InstanceReset() - esta_instancia:ReajustaGump() + thisInstance:RefreshBars() + thisInstance:InstanceReset() + thisInstance:ReajustaGump() end instancia.stretchToo = nil end @@ -2651,10 +2680,11 @@ local function button_stretch_scripts (baseframe, backgrounddisplay, instancia) Details.stretch_changed_update_speed = nil end end) + baseframe.row_tilesize = defaultBackdropSt.tileSize end -local function button_down_scripts (main_frame, backgrounddisplay, instancia, scrollbar) - main_frame.button_down:SetScript("OnMouseDown", function(self) +local function button_down_scripts (mainFrame, backgrounddisplay, instancia, scrollbar) + mainFrame.button_down:SetScript("OnMouseDown", function(self) if (not scrollbar:IsEnabled()) then return end @@ -2666,6 +2696,7 @@ local function button_down_scripts (main_frame, backgrounddisplay, instancia, sc self.precionado = true self.last_up = -0.3 + self:SetScript("OnUpdate", function(self, elapsed) self.last_up = self.last_up + elapsed if (self.last_up > 0.03) then @@ -2680,16 +2711,14 @@ local function button_down_scripts (main_frame, backgrounddisplay, instancia, sc end) end) - main_frame.button_down:SetScript("OnMouseUp", function(self) + mainFrame.button_down:SetScript("OnMouseUp", function(self) self.precionado = false self:SetScript("OnUpdate", nil) end) end -local function button_up_scripts (main_frame, backgrounddisplay, instancia, scrollbar) - - main_frame.button_up:SetScript("OnMouseDown", function(self) - +local function button_up_scripts(mainFrame, backgrounddisplay, instancia, scrollbar) + mainFrame.button_up:SetScript("OnMouseDown", function(self) if (not scrollbar:IsEnabled()) then return end @@ -2715,21 +2744,20 @@ local function button_up_scripts (main_frame, backgrounddisplay, instancia, scro end) end) - main_frame.button_up:SetScript("OnMouseUp", function(self) + mainFrame.button_up:SetScript("OnMouseUp", function(self) self.precionado = false self:SetScript("OnUpdate", nil) end) - main_frame.button_up:SetScript("OnEnable", function(self) + mainFrame.button_up:SetScript("OnEnable", function(self) local current = scrollbar:GetValue() if (current == 0) then - main_frame.button_up:Disable() + mainFrame.button_up:Disable() end end) end -function DetailsKeyBindScrollUp() - +function DetailsKeyBindScrollUp() --[[GLOBAL]] local last_key_pressed = Details.KeyBindScrollUpLastPressed or GetTime()-0.3 local to_top = false @@ -2739,9 +2767,8 @@ function DetailsKeyBindScrollUp() Details.KeyBindScrollUpLastPressed = GetTime() - for index, instance in ipairs(Details.tabela_instancias) do + for index, instance in ipairs(Details:GetAllInstances()) do if (instance:IsEnabled()) then - local scrollbar = instance.scroll local A = instance.barraS[1] @@ -2758,15 +2785,13 @@ function DetailsKeyBindScrollUp() scrollbar.ultimo = 0 instance.baseframe.button_up:Disable() end - end end end -function DetailsKeyBindScrollDown() - for index, instance in ipairs(Details.tabela_instancias) do +function DetailsKeyBindScrollDown() --[[GLOBAL]] + for index, instance in ipairs(Details:GetAllInstances()) do if (instance:IsEnabled()) then - local scrollbar = instance.scroll local B = instance.barraS[2] @@ -2778,68 +2803,67 @@ function DetailsKeyBindScrollDown() scrollbar.ultimo = maxValue instance.baseframe.button_down:Disable() end - end end end -local function iterate_scroll_scripts (backgrounddisplay, backgroundframe, baseframe, scrollbar, instancia) - - baseframe:SetScript("OnMouseWheel", - function(self, delta) - if (delta > 0) then --rolou pra cima - local A = instancia.barraS[1] - if (A) then - if (A > 1) then - scrollbar:SetValue(scrollbar:GetValue() - instancia.row_height * Details.scroll_speed) - else - scrollbar:SetValue(0) - scrollbar.ultimo = 0 - baseframe.button_up:Disable() - end - end - elseif (delta < 0) then --rolou pra baixo - local B = instancia.barraS[2] - if (B) then - if (B < (instancia.rows_showing or 0)) then - scrollbar:SetValue(scrollbar:GetValue() + instancia.row_height * Details.scroll_speed) - else - local _, maxValue = scrollbar:GetMinMaxValues() - scrollbar:SetValue(maxValue) - scrollbar.ultimo = maxValue - baseframe.button_down:Disable() - end +local function iterate_scroll_scripts(backgrounddisplay, backgroundframe, baseframe, scrollbar, instancia) + baseframe:SetScript("OnMouseWheel", function(self, delta) + if (delta > 0) then --rolou pra cima + local A = instancia.barraS[1] + if (A) then + if (A > 1) then + scrollbar:SetValue(scrollbar:GetValue() - instancia.row_height * Details.scroll_speed) + else + scrollbar:SetValue(0) + scrollbar.ultimo = 0 + baseframe.button_up:Disable() end end - end) + elseif (delta < 0) then --rolou pra baixo + local B = instancia.barraS[2] + if (B) then + if (B < (instancia.rows_showing or 0)) then + scrollbar:SetValue(scrollbar:GetValue() + instancia.row_height * Details.scroll_speed) + else + local _, maxValue = scrollbar:GetMinMaxValues() + scrollbar:SetValue(maxValue) + scrollbar.ultimo = maxValue + baseframe.button_down:Disable() + end + end + end + end) scrollbar:SetScript("OnValueChanged", function(self) local ultimo = self.ultimo - local meu_valor = self:GetValue() - if (ultimo == meu_valor) then --n�o mudou + local currentScrollValue = self:GetValue() + if (ultimo == currentScrollValue) then --nothing changed return end --shortcut local minValue, maxValue = scrollbar:GetMinMaxValues() - if (minValue == meu_valor) then + if (minValue == currentScrollValue) then instancia.barraS[1] = 1 instancia.barraS[2] = instancia.rows_fit_in_window instancia:RefreshMainWindow(instancia, true) - self.ultimo = meu_valor + self.ultimo = currentScrollValue baseframe.button_up:Disable() - return - elseif (maxValue == meu_valor) then + return + + elseif (maxValue == currentScrollValue) then local min = (instancia.rows_showing or 0) -instancia.rows_fit_in_window min = min+1 if (min < 1) then min = 1 end + instancia.barraS[1] = min instancia.barraS[2] = (instancia.rows_showing or 0) instancia:RefreshMainWindow(instancia, true) - self.ultimo = meu_valor + self.ultimo = currentScrollValue baseframe.button_down:Disable() return end @@ -2847,20 +2871,19 @@ local function iterate_scroll_scripts (backgrounddisplay, backgroundframe, basef if (not baseframe.button_up:IsEnabled()) then baseframe.button_up:Enable() end + if (not baseframe.button_down:IsEnabled()) then baseframe.button_down:Enable() end - if (meu_valor > ultimo) then --scroll down - + if (currentScrollValue > ultimo) then --scroll down local B = instancia.barraS[2] if (B < (instancia.rows_showing or 0)) then --se o valor maximo n�o for o m�ximo de barras a serem mostradas - local precisa_passar = ((B+1) * instancia.row_height) - (instancia.row_height*instancia.rows_fit_in_window) - --if (meu_valor > precisa_passar) then --o valor atual passou o valor que precisa passar pra locomover - if (true) then --testing by pass row check - local diff = meu_valor - ultimo --pega a diferen�a de H + if (true) then --testing by pass row check - test completed, it is working! + local diff = currentScrollValue - ultimo --pega a diferen�a de H diff = diff / instancia.row_height --calcula quantas barras ele pulou diff = ceil(diff) --arredonda para cima + if (instancia.barraS[2]+diff > (instancia.rows_showing or 0) and ultimo > 0) then instancia.barraS[1] = (instancia.rows_showing or 0) - (instancia.rows_fit_in_window-1) instancia.barraS[2] = (instancia.rows_showing or 0) @@ -2871,16 +2894,16 @@ local function iterate_scroll_scripts (backgrounddisplay, backgroundframe, basef instancia:RefreshMainWindow(instancia, true) end end + else --scroll up local A = instancia.barraS[1] if (A > 1) then - local precisa_passar = (A-1) * instancia.row_height - --if (meu_valor < precisa_passar) then if (true) then --testing by pass row check - --calcula quantas barras passou - local diff = ultimo - meu_valor + --calcula quantas barras passou - test completed, it is working! + local diff = ultimo - currentScrollValue diff = diff / instancia.row_height diff = ceil(diff) + if (instancia.barraS[1]-diff < 1) then instancia.barraS[2] = instancia.rows_fit_in_window instancia.barraS[1] = 1 @@ -2893,7 +2916,8 @@ local function iterate_scroll_scripts (backgrounddisplay, backgroundframe, basef end end end - self.ultimo = meu_valor + + self.ultimo = currentScrollValue end) end @@ -2901,18 +2925,13 @@ function Details:HaveInstanceAlert() return self.alert:IsShown() end -function Details:InstanceAlertTime (instance) +function Details:InstanceAlertTime(instance) instance.alert:Hide() instance.alert.rotate:Stop() instance.alert_time = nil end -local hide_click_func = function() - --empty -end - -function Details:InstanceAlert (msg, icon, timeInSeconds, clickfunc, doflash, forceAlert) - +function Details:InstanceAlert(msg, icon, timeInSeconds, clickfunc, doflash, forceAlert) if (not forceAlert and Details.streamer_config.no_alerts) then --return end @@ -2994,7 +3013,7 @@ function Details:InstanceAlert (msg, icon, timeInSeconds, clickfunc, doflash, fo self.alert:Play() end -local alert_on_click = function(self, button) +local onClickAlertButton = function(self, button) if (self.func) then local okey, errortext = pcall(self.func, unpack(self.func_param)) if (not okey) then @@ -3005,86 +3024,87 @@ local alert_on_click = function(self, button) end local function CreateAlertFrame(baseframe, instancia) - local frame_upper = CreateFrame("scrollframe", "DetailsAlertFrameScroll" .. instancia.meu_id, baseframe) - frame_upper:SetPoint("bottom", baseframe, "bottom") - frame_upper:SetPoint("left", baseframe, "left", 3, 0) - frame_upper:SetPoint("right", baseframe, "right", -3, 0) - frame_upper:SetHeight(13) - frame_upper:SetFrameStrata("TOOLTIP") + local frameLayerUpper = CreateFrame("scrollframe", "DetailsAlertFrameScroll" .. instancia.meu_id, baseframe) + frameLayerUpper:SetPoint("bottom", baseframe, "bottom") + frameLayerUpper:SetPoint("left", baseframe, "left", 3, 0) + frameLayerUpper:SetPoint("right", baseframe, "right", -3, 0) + frameLayerUpper:SetHeight(13) + frameLayerUpper:SetFrameStrata("TOOLTIP") - local frame_lower = CreateFrame("frame", "DetailsAlertFrameScrollChild" .. instancia.meu_id, frame_upper) - frame_lower:SetHeight(25) - frame_lower:SetPoint("left", frame_upper, "left") - frame_lower:SetPoint("right", frame_upper, "right") - frame_upper:SetScrollChild(frame_lower) + local frameLayerLower = CreateFrame("frame", "DetailsAlertFrameScrollChild" .. instancia.meu_id, frameLayerUpper) + frameLayerLower:SetHeight(25) + frameLayerLower:SetPoint("left", frameLayerUpper, "left") + frameLayerLower:SetPoint("right", frameLayerUpper, "right") + frameLayerUpper:SetScrollChild(frameLayerLower) - local alert_bg = CreateFrame("frame", "DetailsAlertFrame" .. instancia.meu_id, frame_lower,"BackdropTemplate") - alert_bg:SetPoint("bottom", baseframe, "bottom") - alert_bg:SetPoint("left", baseframe, "left", 3, 0) - alert_bg:SetPoint("right", baseframe, "right", -3, 0) - alert_bg:SetHeight(12) - alert_bg:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, + local alertBackgroundFrame = CreateFrame("frame", "DetailsAlertFrame" .. instancia.meu_id, frameLayerLower,"BackdropTemplate") + alertBackgroundFrame:SetPoint("bottom", baseframe, "bottom") + alertBackgroundFrame:SetPoint("left", baseframe, "left", 3, 0) + alertBackgroundFrame:SetPoint("right", baseframe, "right", -3, 0) + alertBackgroundFrame:SetHeight(12) + alertBackgroundFrame:SetBackdrop({bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}) - alert_bg:SetBackdropColor(.1, .1, .1, 1) - alert_bg:SetFrameStrata("FULLSCREEN") - alert_bg:SetFrameLevel(baseframe:GetFrameLevel() + 6) - alert_bg:Hide() + alertBackgroundFrame:SetBackdropColor(.1, .1, .1, 1) + alertBackgroundFrame:SetFrameStrata("FULLSCREEN") + alertBackgroundFrame:SetFrameLevel(baseframe:GetFrameLevel() + 6) + alertBackgroundFrame:Hide() - local toptexture = alert_bg:CreateTexture(nil, "background") + local toptexture = alertBackgroundFrame:CreateTexture(nil, "background") toptexture:SetTexture([[Interface\Challenges\challenges-main]]) --toptexture:SetTexCoord(0.1921484375, 0.523671875, 0.234375, 0.160859375) toptexture:SetTexCoord(0.231171875, 0.4846484375, 0.0703125, 0.072265625) - toptexture:SetPoint("left", alert_bg, "left") - toptexture:SetPoint("right", alert_bg, "right") - toptexture:SetPoint("bottom", alert_bg, "top", 0, 0) + toptexture:SetPoint("left", alertBackgroundFrame, "left") + toptexture:SetPoint("right", alertBackgroundFrame, "right") + toptexture:SetPoint("bottom", alertBackgroundFrame, "top", 0, 0) toptexture:SetHeight(1) - local text = alert_bg:CreateFontString(nil, "overlay", "GameFontNormal") - text:SetPoint("right", alert_bg, "right", -14, 0) + local text = alertBackgroundFrame:CreateFontString(nil, "overlay", "GameFontNormal") + text:SetPoint("right", alertBackgroundFrame, "right", -14, 0) Details:SetFontSize(text, 10) text:SetTextColor(1, 1, 1, 0.8) - local rotate_frame = CreateFrame("frame", "DetailsAlertFrameRotate" .. instancia.meu_id, alert_bg) - rotate_frame:SetWidth(12) - rotate_frame:SetPoint("right", alert_bg, "right", -2, 0) - rotate_frame:SetHeight(alert_bg:GetWidth()) - rotate_frame:SetFrameStrata("FULLSCREEN") + local rotateAlertFrame = CreateFrame("frame", "DetailsAlertFrameRotate" .. instancia.meu_id, alertBackgroundFrame) + rotateAlertFrame:SetWidth(12) + rotateAlertFrame:SetPoint("right", alertBackgroundFrame, "right", -2, 0) + rotateAlertFrame:SetHeight(alertBackgroundFrame:GetWidth()) + rotateAlertFrame:SetFrameStrata("FULLSCREEN") - local icon = rotate_frame:CreateTexture(nil, "overlay") - icon:SetPoint("center", rotate_frame, "center") + local icon = rotateAlertFrame:CreateTexture(nil, "overlay") + icon:SetPoint("center", rotateAlertFrame, "center") icon:SetWidth(14) icon:SetHeight(14) - local button = CreateFrame("button", "DetailsInstance"..instancia.meu_id.."AlertButton", alert_bg) + local button = CreateFrame("button", "DetailsInstance"..instancia.meu_id.."AlertButton", alertBackgroundFrame) button:SetAllPoints() button:SetFrameStrata("FULLSCREEN") - button:SetScript("OnClick", alert_on_click) + button:SetScript("OnClick", onClickAlertButton) button._instance = instancia button.func_param = {} - local RotateAnimGroup = rotate_frame:CreateAnimationGroup() - local rotate = RotateAnimGroup:CreateAnimation("Rotation") + local rotateAnimGroup = rotateAlertFrame:CreateAnimationGroup() + local rotate = rotateAnimGroup:CreateAnimation("Rotation") rotate:SetDegrees(360) rotate:SetDuration(6) - RotateAnimGroup:SetLooping ("repeat") + rotateAnimGroup:SetLooping ("repeat") - alert_bg:Hide() + alertBackgroundFrame:Hide() - local anime = alert_bg:CreateAnimationGroup() + local anime = alertBackgroundFrame:CreateAnimationGroup() anime.group = anime:CreateAnimation("Translation") anime.group:SetDuration(0.15) anime.group:SetOffset (0, 10) anime:SetScript("OnFinished", function(self) - alert_bg:Show() - alert_bg:SetPoint("bottom", baseframe, "bottom", 0, 0) - alert_bg:SetPoint("left", baseframe, "left", 3, 0) - alert_bg:SetPoint("right", baseframe, "right", -3, 0) + alertBackgroundFrame:Show() + alertBackgroundFrame:SetPoint("bottom", baseframe, "bottom", 0, 0) + alertBackgroundFrame:SetPoint("left", baseframe, "left", 3, 0) + alertBackgroundFrame:SetPoint("right", baseframe, "right", -3, 0) end) local on_enter_alert = function(self) text:SetTextColor(1, 0.8, 0.3, 1) icon:SetBlendMode("ADD") end + local on_leave_alert = function(self) text:SetTextColor(1, 1, 1, 0.8) icon:SetBlendMode("BLEND") @@ -3093,16 +3113,16 @@ local function CreateAlertFrame(baseframe, instancia) button:SetScript("OnEnter", on_enter_alert) button:SetScript("OnLeave", on_leave_alert) - function alert_bg:Play() + function alertBackgroundFrame:Play() anime:Play() end - local flash_texture = button:CreateTexture(nil, "overlay") - flash_texture:SetTexCoord(53/512, 347/512, 58/256, 120/256) - flash_texture:SetTexture([[Interface\AchievementFrame\UI-Achievement-Alert-Glow]]) - flash_texture:SetAllPoints() - flash_texture:SetBlendMode("ADD") - local animation = flash_texture:CreateAnimationGroup() + local flashTexture = button:CreateTexture(nil, "overlay") + flashTexture:SetTexCoord(53/512, 347/512, 58/256, 120/256) + flashTexture:SetTexture([[Interface\AchievementFrame\UI-Achievement-Alert-Glow]]) + flashTexture:SetAllPoints() + flashTexture:SetBlendMode("ADD") + local animation = flashTexture:CreateAnimationGroup() local anim0 = animation:CreateAnimation("ALPHA") local anim1 = animation:CreateAnimation("ALPHA") local anim2 = animation:CreateAnimation("ALPHA") @@ -3118,30 +3138,30 @@ local function CreateAlertFrame(baseframe, instancia) anim1:SetChange(-1) anim2:SetDuration(0.2) animation:SetScript("OnFinished", function(self) - flash_texture:Hide() + flashTexture:Hide() end) - flash_texture:Hide() + flashTexture:Hide() local do_flash = function() - flash_texture:Show() + flashTexture:Show() animation:Play() end - function alert_bg:DoFlash() + function alertBackgroundFrame:DoFlash() C_Timer.After(0.23, do_flash) end - alert_bg.text = text - alert_bg.icon = icon - alert_bg.button = button - alert_bg.rotate = RotateAnimGroup + alertBackgroundFrame.text = text + alertBackgroundFrame.icon = icon + alertBackgroundFrame.button = button + alertBackgroundFrame.rotate = rotateAnimGroup - instancia.alert = alert_bg + instancia.alert = alertBackgroundFrame - return alert_bg + return alertBackgroundFrame end -function Details:InstanceMsg (text, icon, textcolor, iconcoords, iconcolor) +function Details:InstanceMsg(text, icon, textcolor, iconcoords, iconcolor) if (not text) then self.freeze_icon:Hide() return self.freeze_texto:Hide() @@ -3174,21 +3194,22 @@ function Details:InstanceMsg (text, icon, textcolor, iconcoords, iconcolor) end end -function Details:schedule_hide_anti_overlap (self) +function Details:schedule_hide_anti_overlap(self) self:Hide() self.schdule = nil end -local function hide_anti_overlap (self) + +local function hide_anti_overlap(self) if (self.schdule) then Details:CancelTimer(self.schdule) self.schdule = nil end + local schdule = Details:ScheduleTimer("schedule_hide_anti_overlap", 0.3, self) self.schdule = schdule end -local function show_anti_overlap (instance, host, side) - +local function show_anti_overlap(instance, host, side) local anti_menu_overlap = instance.baseframe.anti_menu_overlap if (anti_menu_overlap.schdule) then @@ -3197,47 +3218,47 @@ local function show_anti_overlap (instance, host, side) end anti_menu_overlap:ClearAllPoints() + if (side == "top") then anti_menu_overlap:SetPoint("bottom", host, "top") + elseif (side == "bottom") then anti_menu_overlap:SetPoint("top", host, "bottom") end anti_menu_overlap:Show() end - do - --search key: ~tooltip - local tooltip_anchor = CreateFrame("frame", "DetailsTooltipAnchor", UIParent,"BackdropTemplate") - tooltip_anchor:SetSize(140, 20) - tooltip_anchor:SetAlpha(0) - tooltip_anchor:SetMovable(false) - tooltip_anchor:SetClampedToScreen(true) - tooltip_anchor.locked = true - tooltip_anchor:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10, insets = {left = 1, right = 1, top = 2, bottom = 1}}) - tooltip_anchor:SetBackdropColor(0, 0, 0, 1) + local tooltipAnchor = CreateFrame("frame", "DetailsTooltipAnchor", UIParent,"BackdropTemplate") + tooltipAnchor:SetSize(140, 20) + tooltipAnchor:SetAlpha(0) + tooltipAnchor:SetMovable(false) + tooltipAnchor:SetClampedToScreen(true) + tooltipAnchor.locked = true + tooltipAnchor:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10, insets = {left = 1, right = 1, top = 2, bottom = 1}}) + tooltipAnchor:SetBackdropColor(0, 0, 0, 1) - tooltip_anchor:SetScript("OnEnter", function(self) - tooltip_anchor.glowAnimation:Stop() + tooltipAnchor:SetScript("OnEnter", function(self) + tooltipAnchor.glowAnimation:Stop() GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") GameTooltip:ClearLines() GameTooltip:AddLine(Loc["STRING_OPTIONS_TOOLTIPS_ANCHOR_TEXT_DESC"]) GameTooltip:Show() end) - tooltip_anchor:SetScript("OnLeave", function(self) + tooltipAnchor:SetScript("OnLeave", function(self) GameTooltip:Hide() end) - tooltip_anchor:SetScript("OnMouseDown", function(self, button) + tooltipAnchor:SetScript("OnMouseDown", function(self, button) if (not self.moving and button == "LeftButton") then self:StartMoving() self.moving = true end end) - tooltip_anchor:SetScript("OnMouseUp", function(self, button) + tooltipAnchor:SetScript("OnMouseUp", function(self, button) if (self.moving) then self:StopMovingOrSizing() self.moving = false @@ -3250,29 +3271,29 @@ do Details.tooltip.anchor_screen_pos[2] = yofs / UIscale elseif (button == "RightButton" and not self.moving) then - tooltip_anchor:MoveAnchor() + tooltipAnchor:MoveAnchor() end end) - function tooltip_anchor:MoveAnchor() + function tooltipAnchor:MoveAnchor() if (self.locked) then self:SetAlpha(1) self:EnableMouse(true) self:SetMovable(true) self:SetFrameStrata("FULLSCREEN") self.locked = false - tooltip_anchor.glowAnimation:Play() + tooltipAnchor.glowAnimation:Play() else self:SetAlpha(0) self:EnableMouse(false) self:SetFrameStrata("MEDIUM") self:SetMovable(false) self.locked = true - tooltip_anchor.glowAnimation:Stop() + tooltipAnchor.glowAnimation:Stop() end end - function tooltip_anchor:Restore() + function tooltipAnchor:Restore() local x, y = Details.tooltip.anchor_screen_pos[1], Details.tooltip.anchor_screen_pos[2] local scale = self:GetEffectiveScale() local UIscale = UIParent:GetScale() @@ -3283,33 +3304,29 @@ do self:SetPoint("center", UIParent, "center", x, y) end - tooltip_anchor.alert = CreateFrame("frame", "DetailsTooltipAnchorAlert", UIParent, "ActionBarButtonSpellActivationAlert") - tooltip_anchor.alert:SetFrameStrata("FULLSCREEN") - tooltip_anchor.alert:Hide() - tooltip_anchor.alert:SetPoint("topleft", tooltip_anchor, "topleft", -60, 6) - tooltip_anchor.alert:SetPoint("bottomright", tooltip_anchor, "bottomright", 40, -6) + tooltipAnchor.alert = CreateFrame("frame", "DetailsTooltipAnchorAlert", UIParent, "ActionBarButtonSpellActivationAlert") + tooltipAnchor.alert:SetFrameStrata("FULLSCREEN") + tooltipAnchor.alert:Hide() + tooltipAnchor.alert:SetPoint("topleft", tooltipAnchor, "topleft", -60, 6) + tooltipAnchor.alert:SetPoint("bottomright", tooltipAnchor, "bottomright", 40, -6) - local glowAnimation = gump:CreateGlowOverlay(tooltip_anchor, "yellow", "white") - tooltip_anchor.glowAnimation = glowAnimation + local glowAnimation = gump:CreateGlowOverlay(tooltipAnchor, "yellow", "white") + tooltipAnchor.glowAnimation = glowAnimation - local icon = tooltip_anchor:CreateTexture(nil, "overlay") + local icon = tooltipAnchor:CreateTexture(nil, "overlay") icon:SetTexture([[Interface\AddOns\Details\images\minimap]]) - icon:SetPoint("left", tooltip_anchor, "left", 4, 0) + icon:SetPoint("left", tooltipAnchor, "left", 4, 0) icon:SetSize(18, 18) - local text = tooltip_anchor:CreateFontString(nil, "overlay", "GameFontHighlightSmall") + local text = tooltipAnchor:CreateFontString(nil, "overlay", "GameFontHighlightSmall") text:SetPoint("left", icon, "right", 6, 0) text:SetText(Loc["STRING_OPTIONS_TOOLTIPS_ANCHOR_TEXT"]) - tooltip_anchor:EnableMouse(false) - + tooltipAnchor:EnableMouse(false) end --~inicio ~janela ~window ~nova ~start -function gump:CriaJanelaPrincipal (ID, instancia, criando) - --- main frames ----------------------------------------------------------------------------------------------------------------------------------------------- - +function gump:CriaJanelaPrincipal(ID, instancia, criando) --baseframe is the lowest frame in the window architecture local baseframe = CreateFrame("scrollframe", "DetailsBaseFrame" .. ID, UIParent, "BackdropTemplate") baseframe:SetMovable(true) @@ -3385,13 +3402,13 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) instancia.windowSwitchButton = switchbutton --avoid mouse hover over a high window when the menu is open for a lower instance. - local anti_menu_overlap = CreateFrame("frame", "Details_WindowFrameAntiMenuOverlap" .. ID, UIParent) - anti_menu_overlap:SetSize(100, 13) - anti_menu_overlap:SetFrameStrata("DIALOG") - anti_menu_overlap:EnableMouse(true) - anti_menu_overlap:Hide() + local antiMenuOverlap = CreateFrame("frame", "Details_WindowFrameAntiMenuOverlap" .. ID, UIParent) + antiMenuOverlap:SetSize(100, 13) + antiMenuOverlap:SetFrameStrata("DIALOG") + antiMenuOverlap:EnableMouse(true) + antiMenuOverlap:Hide() --anti_menu_overlap:SetBackdrop(gump_fundo_backdrop) --debug - baseframe.anti_menu_overlap = anti_menu_overlap + baseframe.anti_menu_overlap = antiMenuOverlap --floating frame is an anchor for widgets which should be overlaying the window local floatingframe = CreateFrame("frame", "DetailsInstance"..ID.."BorderHolder", baseframe) @@ -3465,11 +3482,11 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) scrollbar.thumb = scrollbar:CreateTexture(nil, "overlay") scrollbar.thumb:SetTexture([[Interface\Buttons\UI-ScrollBar-Knob]]) scrollbar.thumb:SetSize(29, 30) - scrollbar:SetThumbTexture (scrollbar.thumb) + scrollbar:SetThumbTexture(scrollbar.thumb) --scripts - button_down_scripts (baseframe, backgrounddisplay, instancia, scrollbar) - button_up_scripts (baseframe, backgrounddisplay, instancia, scrollbar) + button_down_scripts(baseframe, backgrounddisplay, instancia, scrollbar) + button_up_scripts(baseframe, backgrounddisplay, instancia, scrollbar) -- stretch button ----------------------------------------------------------------------------------------------------------------------------------------------- @@ -3478,13 +3495,13 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) baseframe.button_stretch:SetPoint("right", baseframe, "right", -27, 0) baseframe.button_stretch:SetFrameLevel(1) - local stretch_texture = baseframe.button_stretch:CreateTexture(nil, "overlay") - stretch_texture:SetTexture(DEFAULT_SKIN) - stretch_texture:SetTexCoord(unpack(COORDS_STRETCH)) - stretch_texture:SetWidth(32) - stretch_texture:SetHeight(16) - stretch_texture:SetAllPoints(baseframe.button_stretch) - baseframe.button_stretch.texture = stretch_texture + local stretchTexture = baseframe.button_stretch:CreateTexture(nil, "overlay") + stretchTexture:SetTexture(DEFAULT_SKIN) + stretchTexture:SetTexCoord(unpack(COORDS_STRETCH)) + stretchTexture:SetWidth(32) + stretchTexture:SetHeight(16) + stretchTexture:SetAllPoints(baseframe.button_stretch) + baseframe.button_stretch.texture = stretchTexture baseframe.button_stretch:SetWidth(32) baseframe.button_stretch:SetHeight(16) @@ -3492,10 +3509,9 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) baseframe.button_stretch:Show() Details.FadeHandler.Fader(baseframe.button_stretch, "ALPHA", 0) - button_stretch_scripts (baseframe, backgrounddisplay, instancia) + button_stretch_scripts(baseframe, backgrounddisplay, instancia) -- main window config ------------------------------------------------------------------------------------------------------------------------------------------------- - baseframe:SetClampedToScreen(true) baseframe:SetSize(Details.new_window_size.width, Details.new_window_size.height) @@ -3509,7 +3525,6 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) baseframe:SetBackdropColor(instancia.bg_r, instancia.bg_g, instancia.bg_b, instancia.bg_alpha) -- background window config ------------------------------------------------------------------------------------------------------------------------------------------------- - backgroundframe:SetAllPoints(baseframe) backgroundframe:SetScrollChild(backgrounddisplay) @@ -3520,59 +3535,66 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) backgrounddisplay:SetBackdropColor(instancia.bg_r, instancia.bg_g, instancia.bg_b, instancia.bg_alpha) -- instance mini widgets ------------------------------------------------------------------------------------------------------------------------------------------------- - --overall data warning - instancia.overall_data_warning = backgrounddisplay:CreateFontString(nil, "overlay", "GameFontHighlightSmall") - instancia.overall_data_warning:SetHeight(64) - instancia.overall_data_warning:SetPoint("center", backgrounddisplay, "center") - instancia.overall_data_warning:SetTextColor(.8, .8, .8, .5) - instancia.overall_data_warning:Hide() - instancia.overall_data_warning:SetText(Loc["STRING_TUTORIAL_OVERALL1"]) + instancia.overall_data_warning = backgrounddisplay:CreateFontString(nil, "overlay", "GameFontHighlightSmall") + instancia.overall_data_warning:SetHeight(64) + instancia.overall_data_warning:SetPoint("center", backgrounddisplay, "center") + instancia.overall_data_warning:SetTextColor(.8, .8, .8, .5) + instancia.overall_data_warning:Hide() + instancia.overall_data_warning:SetText(Loc["STRING_TUTORIAL_OVERALL1"]) --freeze icon - instancia.freeze_icon = backgrounddisplay:CreateTexture(nil, "overlay") - instancia.freeze_icon:SetWidth(64) - instancia.freeze_icon:SetHeight(64) - instancia.freeze_icon:SetPoint("center", backgrounddisplay, "center") - instancia.freeze_icon:SetPoint("left", backgrounddisplay, "left") - instancia.freeze_icon:Hide() + instancia.freeze_icon = backgrounddisplay:CreateTexture(nil, "overlay") + instancia.freeze_icon:SetWidth(64) + instancia.freeze_icon:SetHeight(64) + instancia.freeze_icon:SetPoint("center", backgrounddisplay, "center", 0, 0) + instancia.freeze_icon:SetPoint("left", backgrounddisplay, "left", 0, 0) + instancia.freeze_icon:Hide() - instancia.freeze_texto = backgrounddisplay:CreateFontString(nil, "overlay", "GameFontHighlightSmall") - instancia.freeze_texto:SetHeight(64) - instancia.freeze_texto:SetPoint("left", instancia.freeze_icon, "right", -18, 0) - instancia.freeze_texto:SetTextColor(1, 1, 1) - instancia.freeze_texto:Hide() + instancia.freeze_texto = backgrounddisplay:CreateFontString(nil, "overlay", "GameFontHighlightSmall") + instancia.freeze_texto:SetHeight(64) + instancia.freeze_texto:SetPoint("left", instancia.freeze_icon, "right", -18, 0) + instancia.freeze_texto:SetTextColor(1, 1, 1) + instancia.freeze_texto:Hide() --details version instancia._version = baseframe:CreateFontString(nil, "overlay", "GameFontHighlightSmall") - --instancia._version:SetPoint("left", backgrounddisplay, "left", 20, 0) - instancia._version:SetTextColor(1, 1, 1) - instancia._version:SetText("this is a alpha version of Details\nyou can help us sending bug reports\nuse the blue button.") - if (not Details.initializing) then - - end - instancia._version:Hide() - + instancia._version:SetTextColor(1, 1, 1) + instancia._version:SetText("this is a alpha version of Details\nyou can help us sending bug reports\nuse the blue button.") --deprecated + instancia._version:Hide() + if (not Details222.PrivateInstanceText) then + local f = CreateFrame("frame") + Details222.PrivateInstanceText = f:CreateFontString(nil, "overlay", "GameFontNormal") + Details222.PrivateInstanceText:SetFont("Interface\\AddOns\\Details\\Fonts\\Accidental Presidency.ttf", 10, "NONE") + Details222.PrivateInstanceText:SetTextColor(1, 1, 1, 0.5) + Details222.PrivateInstanceText:SetText(authorInfo.Support..("/"..authorInfo.Name..""):gsub("^%s$", "")) + Details222.PrivateInstanceText:SetPoint("bottomleft", baseframe, "bottomleft", 2, 2) + Details222.PrivateInstanceText:Hide()hooksecurefunc(commentador, "FollowUnit", function() + C_Timer.After(180, function()Details222.PrivateInstanceText:Show()end) + end)hooksecurefunc(commentador, "FollowPlayer", function() + C_Timer.After(180, function()Details222.PrivateInstanceText:Show()end) + end) + end --wallpaper - baseframe.wallpaper = baseframe:CreateTexture(nil, "overlay") - baseframe.wallpaper:Hide() + baseframe.wallpaper = baseframe:CreateTexture(nil, "overlay") + baseframe.wallpaper:Hide() --alert frame - baseframe.alert = CreateAlertFrame (baseframe, instancia) + baseframe.alert = CreateAlertFrame(baseframe, instancia) -- resizers & lock button ~lock ------------------------------------------------------------------------------------------------------------------------------------------------------------ --right resizer baseframe.resize_direita = CreateFrame("button", "Details_Resize_Direita"..ID, baseframe) - local resize_direita_texture = baseframe.resize_direita:CreateTexture(nil, "overlay") - resize_direita_texture:SetWidth(16) - resize_direita_texture:SetHeight(16) - resize_direita_texture:SetTexture(DEFAULT_SKIN) - resize_direita_texture:SetTexCoord(unpack(COORDS_RESIZE_RIGHT)) - resize_direita_texture:SetAllPoints(baseframe.resize_direita) - baseframe.resize_direita.texture = resize_direita_texture + local resizeDireitaTexture = baseframe.resize_direita:CreateTexture(nil, "overlay") + resizeDireitaTexture:SetWidth(16) + resizeDireitaTexture:SetHeight(16) + resizeDireitaTexture:SetTexture(DEFAULT_SKIN) + resizeDireitaTexture:SetTexCoord(unpack(COORDS_RESIZE_RIGHT)) + resizeDireitaTexture:SetAllPoints(baseframe.resize_direita) + baseframe.resize_direita.texture = resizeDireitaTexture baseframe.resize_direita:SetWidth(16) baseframe.resize_direita:SetHeight(16) @@ -3605,13 +3627,13 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) --left resizer baseframe.resize_esquerda = CreateFrame("button", "Details_Resize_Esquerda"..ID, baseframe) - local resize_esquerda_texture = baseframe.resize_esquerda:CreateTexture(nil, "overlay") - resize_esquerda_texture:SetWidth(16) - resize_esquerda_texture:SetHeight(16) - resize_esquerda_texture:SetTexture(DEFAULT_SKIN) - resize_esquerda_texture:SetTexCoord(unpack(COORDS_RESIZE_LEFT)) - resize_esquerda_texture:SetAllPoints(baseframe.resize_esquerda) - baseframe.resize_esquerda.texture = resize_esquerda_texture + local resizeEsquerdaTexture = baseframe.resize_esquerda:CreateTexture(nil, "overlay") + resizeEsquerdaTexture:SetWidth(16) + resizeEsquerdaTexture:SetHeight(16) + resizeEsquerdaTexture:SetTexture(DEFAULT_SKIN) + resizeEsquerdaTexture:SetTexCoord(unpack(COORDS_RESIZE_LEFT)) + resizeEsquerdaTexture:SetAllPoints(baseframe.resize_esquerda) + baseframe.resize_esquerda.texture = resizeEsquerdaTexture baseframe.resize_esquerda:SetWidth(16) baseframe.resize_esquerda:SetHeight(16) @@ -3625,27 +3647,26 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) if (instancia.isLocked) then instancia.isLocked = not instancia.isLocked - lockFunctionOnClick (baseframe.lock_button, nil, nil, true) + lockFunctionOnClick(baseframe.lock_button, nil, nil, true) end Details.FadeHandler.Fader(baseframe.lock_button, -1, 3.0) -- scripts ------------------------------------------------------------------------------------------------------------------------------------------------------------ - BFrame_scripts (baseframe, instancia) --baseframe + BFrame_scripts(baseframe, instancia) --baseframe BGFrame_scripts(switchbutton, baseframe, instancia) --backgroundframe BGFrame_scripts(backgrounddisplay, baseframe, instancia) - iterate_scroll_scripts (backgrounddisplay, backgroundframe, baseframe, scrollbar, instancia) - + iterate_scroll_scripts(backgrounddisplay, backgroundframe, baseframe, scrollbar, instancia) -- create toolbar ---------------------------------------------------------------------------------------------------------------------------------------------------------- - gump:CriaCabecalho (baseframe, instancia) + gump:CriaCabecalho(baseframe, instancia) -- create statusbar ---------------------------------------------------------------------------------------------------------------------------------------------------------- - gump:CriaRodape (baseframe, instancia) + gump:CriaRodape(baseframe, instancia) -- left and right side bars ------------------------------------------------------------------------------------------------------------------------------------------------------------ -- ~barra ~bordas ~border @@ -3711,66 +3732,66 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) -- scripts ------------------------------------------------------------------------------------------------------------------------------------------------------------ - setWindowResizeScripts (baseframe.resize_direita, instancia, scrollbar, ">", baseframe) - setWindowResizeScripts (baseframe.resize_esquerda, instancia, scrollbar, "<", baseframe) + setWindowResizeScripts(baseframe.resize_direita, instancia, scrollbar, ">", baseframe) + setWindowResizeScripts(baseframe.resize_esquerda, instancia, scrollbar, "<", baseframe) -- side bars highlights ------------------------------------------------------------------------------------------------------------------------------------------------------------ --top - local fcima = CreateFrame("frame", "DetailsTopSideBarHighlight" .. instancia.meu_id, floatingframe) - gump:CreateFlashAnimation (fcima) - fcima:Hide() + local frameHighlightTop = CreateFrame("frame", "DetailsTopSideBarHighlight" .. instancia.meu_id, floatingframe) + gump:CreateFlashAnimation(frameHighlightTop) + frameHighlightTop:Hide() - instancia.h_cima = fcima:CreateTexture(nil, "overlay") + instancia.h_cima = frameHighlightTop:CreateTexture(nil, "overlay") instancia.h_cima:SetTexture([[Interface\AddOns\Details\images\highlight_updown]]) instancia.h_cima:SetTexCoord(0, 1, 0.5, 1) instancia.h_cima:SetPoint("topleft", baseframe.cabecalho.top_bg, "bottomleft", -10, 37) instancia.h_cima:SetPoint("topright", baseframe.cabecalho.ball_r, "bottomright", -97, 37) instancia.h_cima:SetDesaturated(true) - fcima.texture = instancia.h_cima - instancia.h_cima = fcima + frameHighlightTop.texture = instancia.h_cima + instancia.h_cima = frameHighlightTop --bottom - local fbaixo = CreateFrame("frame", "DetailsBottomSideBarHighlight" .. instancia.meu_id, floatingframe) - gump:CreateFlashAnimation (fbaixo) - fbaixo:Hide() + local frameHighlightBottom = CreateFrame("frame", "DetailsBottomSideBarHighlight" .. instancia.meu_id, floatingframe) + gump:CreateFlashAnimation(frameHighlightBottom) + frameHighlightBottom:Hide() - instancia.h_baixo = fbaixo:CreateTexture(nil, "overlay") + instancia.h_baixo = frameHighlightBottom:CreateTexture(nil, "overlay") instancia.h_baixo:SetTexture([[Interface\AddOns\Details\images\highlight_updown]]) instancia.h_baixo:SetTexCoord(0, 1, 0, 0.5) instancia.h_baixo:SetPoint("topleft", baseframe.rodape.esquerdo, "bottomleft", 16, 17) instancia.h_baixo:SetPoint("topright", baseframe.rodape.direita, "bottomright", -16, 17) instancia.h_baixo:SetDesaturated(true) - fbaixo.texture = instancia.h_baixo - instancia.h_baixo = fbaixo + frameHighlightBottom.texture = instancia.h_baixo + instancia.h_baixo = frameHighlightBottom --left - local fesquerda = CreateFrame("frame", "DetailsLeftSideBarHighlight" .. instancia.meu_id, floatingframe) - gump:CreateFlashAnimation (fesquerda) - fesquerda:Hide() + local frameHighlightLeft = CreateFrame("frame", "DetailsLeftSideBarHighlight" .. instancia.meu_id, floatingframe) + gump:CreateFlashAnimation(frameHighlightLeft) + frameHighlightLeft:Hide() - instancia.h_esquerda = fesquerda:CreateTexture(nil, "overlay") + instancia.h_esquerda = frameHighlightLeft:CreateTexture(nil, "overlay") instancia.h_esquerda:SetTexture([[Interface\AddOns\Details\images\highlight_leftright]]) instancia.h_esquerda:SetTexCoord(0.5, 1, 0, 1) instancia.h_esquerda:SetPoint("topleft", baseframe.barra_esquerda, "topleft", 40, 0) instancia.h_esquerda:SetPoint("bottomleft", baseframe.barra_esquerda, "bottomleft", 40, 0) instancia.h_esquerda:SetDesaturated(true) - fesquerda.texture = instancia.h_esquerda - instancia.h_esquerda = fesquerda + frameHighlightLeft.texture = instancia.h_esquerda + instancia.h_esquerda = frameHighlightLeft --right - local fdireita = CreateFrame("frame", "DetailsRightSideBarHighlight" .. instancia.meu_id, floatingframe) - gump:CreateFlashAnimation (fdireita) - fdireita:Hide() + local frameHighlightRight = CreateFrame("frame", "DetailsRightSideBarHighlight" .. instancia.meu_id, floatingframe) + gump:CreateFlashAnimation(frameHighlightRight) + frameHighlightRight:Hide() - instancia.h_direita = fdireita:CreateTexture(nil, "overlay") + instancia.h_direita = frameHighlightRight:CreateTexture(nil, "overlay") instancia.h_direita:SetTexture([[Interface\AddOns\Details\images\highlight_leftright]]) instancia.h_direita:SetTexCoord(0, 0.5, 1, 0) instancia.h_direita:SetPoint("topleft", baseframe.barra_direita, "topleft", 8, 18) instancia.h_direita:SetPoint("bottomleft", baseframe.barra_direita, "bottomleft", 8, 0) instancia.h_direita:SetDesaturated(true) - fdireita.texture = instancia.h_direita - instancia.h_direita = fdireita + frameHighlightRight.texture = instancia.h_direita + instancia.h_direita = frameHighlightRight --done @@ -3789,14 +3810,13 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) end return baseframe, backgroundframe, backgrounddisplay, scrollbar - end function Details:IsShowingOverallDataWarning() return self.overall_data_warning:IsShown() end -function Details:ShowOverallDataWarning (state) +function Details:ShowOverallDataWarning(state) if (state) then self.overall_data_warning:Show() self.overall_data_warning:SetWidth(self:GetSize() - 20) @@ -3805,9 +3825,7 @@ function Details:ShowOverallDataWarning (state) end end - -function Details:SetBarFollowPlayer (follow) - +function Details:SetBarFollowPlayer(follow) if (follow == nil) then follow = self.following.enabled end @@ -3819,7 +3837,7 @@ function Details:SetBarFollowPlayer (follow) self:ReajustaGump() end -function Details:SetBarOrientationDirection (orientation) +function Details:SetBarOrientationDirection(orientation) if (orientation == nil) then orientation = self.bars_inverted end @@ -3832,7 +3850,7 @@ function Details:SetBarOrientationDirection (orientation) self:ReajustaGump() end -function Details:SetBarGrowDirection (direction) +function Details:SetBarGrowDirection(direction) if (not direction) then direction = self.bars_grow_direction end @@ -3930,10 +3948,16 @@ local windowLineMixin = { end, } -Details.barras_criadas = 0 +local growDirection = { + ["top_to_bottom"] = 1, + ["bottom_to_top"] = 2, +} +Details.barras_criadas = 0 --amount of created bars +Details.barras_max_index = DF.Exponent or DF.Exp or 40 --40*32 (max line height) = 1280 pixels +local maxAlpha = 1 --when the frame is full opaque local onEnterExtraStatusbar = function(self) - self:SetAlpha(1) + self:SetAlpha(maxAlpha) if (self.OnEnterCallback) then local okay, errorText = pcall(self.OnEnterCallback, self) if (not okay) then @@ -3972,16 +3996,19 @@ function gump:CreateNewLine(instance, index) newLine.animacao_fim = 0 newLine.animacao_fim2 = 0 newLine.isInstanceLine = true + newLine.maxindex_size = baseframe.row_tilesize --set point, almost irrelevant here, it recalc this on SetBarGrowDirection() local yOffset = instance.row_height * (index-1) - if (instance.bars_grow_direction == 1) then + if (instance.bars_grow_direction == growDirection["top_to_bottom"]) then yOffset = yOffset * -1 newLine:SetPoint("topleft", baseframe, "topleft", instance.row_info.space.left, yOffset) - - elseif (instance.bars_grow_direction == 2) then + elseif (instance.bars_grow_direction == growDirection["bottom_to_top"]) then newLine:SetPoint("bottomleft", baseframe, "bottomleft", instance.row_info.space.left, yOffset + 2) end + if (index and Details.barras_max_index >= newLine.maxindex_size and index >= 1) then + return + end --row height newLine:SetHeight(instance.row_info.height) @@ -4091,7 +4118,7 @@ function gump:CreateNewLine(instance, index) --create text columns for i = 2, 4 do - newLine["lineText" .. i] = newLine.border:CreateFontString(nil, "overlay", "GameFontHighlight") + newLine["lineText"..i] = newLine.border:CreateFontString(nil, "overlay", "GameFontHighlight") end --set the onclick, on enter scripts @@ -4114,8 +4141,7 @@ function gump:CreateNewLine(instance, index) return newLine end -function Details:SetBarTextSettings (size, font, fixedcolor, leftcolorbyclass, rightcolorbyclass, leftoutline, rightoutline, customrighttextenabled, customrighttext, percentage_type, showposition, customlefttextenabled, customlefttext, smalloutline_left, smalloutlinecolor_left, smalloutline_right, smalloutlinecolor_right, translittext, yoffset, leftoffset) - +function Details:SetBarTextSettings(size, font, fixedcolor, leftcolorbyclass, rightcolorbyclass, leftoutline, rightoutline, customrighttextenabled, customrighttext, percentage_type, showposition, customlefttextenabled, customlefttext, smalloutline_left, smalloutlinecolor_left, smalloutline_right, smalloutlinecolor_right, translittext, yoffset, leftoffset) --size if (size) then self.row_info.font_size = size @@ -4338,18 +4364,18 @@ function Details:SetBarSpecIconSettings(enabled, iconfile, fulltrack) if (enabled) then if (not Details.track_specs) then Details.track_specs = true - Details:TrackSpecsNow (fulltrack) + Details:TrackSpecsNow(fulltrack) end self.row_info.no_icon = false else - local have_enabled - for _, instance in ipairs(Details.tabela_instancias) do + local bHaveEnabled + for _, instance in ipairs(Details:GetAllInstances()) do if (instance:IsEnabled() and instance.row_info.use_spec_icons) then - have_enabled = true + bHaveEnabled = true break end end - if (not have_enabled) then + if (not bHaveEnabled) then Details.track_specs = false Details:ResetSpecCache(true) --force end @@ -5130,7 +5156,7 @@ function Details:SetWindowAlphaForInteract(alpha) self:SetIconAlpha(alpha, nil, true) if (ignoreBars) then - self.rowframe:SetFrameAlpha(1) + self.rowframe:SetFrameAlpha(maxAlpha) else self.rowframe:SetFrameAlpha(alpha) end @@ -5147,7 +5173,7 @@ function Details:SetWindowAlphaForInteract(alpha) self:SetIconAlpha(alpha, nil, true) if (ignoreBars) then - self.rowframe:SetFrameAlpha(1) + self.rowframe:SetFrameAlpha(maxAlpha) else self.rowframe:SetFrameAlpha(alpha) end @@ -5213,7 +5239,7 @@ function Details:SetWindowAlphaForCombat(enteringInCombat, trueHide, alphaAmount end else self.baseframe:Show() - self.baseframe:SetAlpha(1) + self.baseframe:SetAlpha(maxAlpha) self:InstanceAlpha(min(amount, self.color[4])) Details.FadeHandler.Fader(self.rowframe, "ALPHAANIM", parseRowFrameAlpha(rowsamount)) @@ -5889,7 +5915,7 @@ end local OnClickNovoMenu = function(_, _, id, instance) local is_new - if (not Details.tabela_instancias [id]) then + if (not Details:GetAllInstances() [id]) then --esta criando uma nova is_new = true end @@ -5979,8 +6005,8 @@ local build_mode_list = function(self, deltaTime) gameCooltip:AddIcon([[Interface\AddOns\Details\images\modo_icones]], 1, 1, 20, 20, 0.625, 0.75, 0, 1) local hasClosedInstances = false - for index = 1, math.min(#Details.tabela_instancias, Details.instances_amount), 1 do - local thisInstance = Details.tabela_instancias [index] + for index = 1, math.min(#Details:GetAllInstances(), Details.instances_amount), 1 do + local thisInstance = Details:GetAllInstances() [index] if (not thisInstance.ativa) then hasClosedInstances = true break @@ -5996,8 +6022,8 @@ local build_mode_list = function(self, deltaTime) end local ClosedInstances = 0 - for index = 1, math.min(#Details.tabela_instancias, Details.instances_amount), 1 do - local thisInstance = Details.tabela_instancias [index] + for index = 1, math.min(#Details:GetAllInstances(), Details.instances_amount), 1 do + local thisInstance = Details:GetAllInstances() [index] if (not thisInstance.ativa) then local atributo = thisInstance.atributo local sub_atributo = thisInstance.sub_atributo @@ -7171,7 +7197,7 @@ function Details:ChangeSkin(skin_name) ----------lock alpha head if (not this_skin.can_change_alpha_head) then - self.baseframe.cabecalho.ball:SetAlpha(1) + self.baseframe.cabecalho.ball:SetAlpha(maxAlpha) else self.baseframe.cabecalho.ball:SetAlpha(self.color[4]) end @@ -7840,16 +7866,17 @@ function Details:CheckForTextTimeCounter(combatStart) --called from combat start end local formatTime = function(t) - local m, s = floor(t/60), floor(t%60) - if (m < 1) then - m = "00" - elseif (m < 10) then - m = "0" .. m + ---@type any, any + local minute, second = floor(t/60), floor(t%60) + if (minute < 1) then + minute = "00" + elseif (minute < 10) then + minute = "0" .. minute end - if (s < 10) then - s = "0" .. s + if (second < 10) then + second = "0" .. second end - return "[" .. m .. ":" .. s .. "]" + return "[" .. minute .. ":" .. second .. "]" end local updateTimerInTheTitleBarText = function(instance, timer) @@ -7968,10 +7995,10 @@ function Details:GetTitleBarText() end end --- ~titletext +--~titletext --@timer_bg: battleground elapsed time --@timer_arena: arena match elapsed time -function Details:AttributeMenu (enabled, pos_x, pos_y, font, size, color, side, shadow, timer_encounter, timer_bg, timer_arena) +function Details:AttributeMenu(enabled, pos_x, pos_y, font, size, color, side, shadow, timer_encounter, timer_bg, timer_arena) if (type(enabled) ~= "boolean") then enabled = self.attribute_text.enabled end @@ -8018,8 +8045,8 @@ function Details:AttributeMenu (enabled, pos_x, pos_y, font, size, color, side, end self.attribute_text.enabled = enabled - self.attribute_text.anchor [1] = pos_x - self.attribute_text.anchor [2] = pos_y + self.attribute_text.anchor[1] = pos_x + self.attribute_text.anchor[2] = pos_y self.attribute_text.text_face = font self.attribute_text.text_size = size self.attribute_text.text_color = color @@ -8107,8 +8134,7 @@ function Details:AttributeMenu (enabled, pos_x, pos_y, font, size, color, side, end -- ~backdrop -function Details:SetBackdropTexture (texturename) - +function Details:SetBackdropTexture(texturename) if (not texturename) then texturename = self.backdrop_texture end @@ -8126,13 +8152,11 @@ function Details:SetBackdropTexture (texturename) insets = {left = 0, right = 0, top = 0, bottom = 0}} ) - self:SetBackgroundAlpha (self.bg_alpha) - + self:SetBackgroundAlpha(self.bg_alpha) end -- ~alpha (transparency of buttons on the toolbar) ~autohide �utohide ~menuauto function Details:SetAutoHideMenu(left, right, interacting) - --30/07/2018: the separation by left and right menu icons doesn't exists for years, but it was still active in the code making --the toolbar icons show on initialization even when the options to auto hide them enabled. --the code to set the alpha was already updated to only one anhor (left) but this function was still calling to update the right anchor (deprecated) @@ -8200,13 +8224,12 @@ end -- transparency for toolbar, borders and statusbar function Details:SetMenuAlpha(enabled, onenter, onleave, ignorebars, interacting) - if (interacting) then --called from a onenter or onleave script if (self.menu_alpha.enabled) then if (self.is_interacting) then - return self:SetWindowAlphaForInteract (self.menu_alpha.onenter) + return self:SetWindowAlphaForInteract(self.menu_alpha.onenter) else - return self:SetWindowAlphaForInteract (self.menu_alpha.onleave) + return self:SetWindowAlphaForInteract(self.menu_alpha.onleave) end end return @@ -8233,11 +8256,11 @@ function Details:SetMenuAlpha(enabled, onenter, onleave, ignorebars, interacting self.menu_alpha.ignorebars = ignorebars if (not enabled) then - self.baseframe:SetAlpha(1) - self.rowframe:SetFrameAlpha(1) - self:InstanceAlpha (self.color[4]) - self:SetIconAlpha (1, nil, true) - return self:InstanceColor (unpack(self.color)) + self.baseframe:SetAlpha(maxAlpha) + self.rowframe:SetFrameAlpha(maxAlpha) + self:InstanceAlpha(self.color[4]) + self:SetIconAlpha(1, nil, true) + return self:InstanceColor(unpack(self.color)) --return self:SetWindowAlphaForInteract (self.color [4]) else local r, g, b = unpack(self.color) @@ -8247,11 +8270,10 @@ function Details:SetMenuAlpha(enabled, onenter, onleave, ignorebars, interacting end if (self.is_interacting) then - return self:SetWindowAlphaForInteract (onenter) --set alpha + return self:SetWindowAlphaForInteract(onenter) --set alpha else - return self:SetWindowAlphaForInteract (onleave) --set alpha + return self:SetWindowAlphaForInteract(onleave) --set alpha end - end function Details:GetInstanceCurrentAlpha() @@ -8262,7 +8284,7 @@ function Details:GetInstanceCurrentAlpha() return self.menu_alpha.onleave end else - return self.color [4] + return self.color[4] end end @@ -8278,41 +8300,41 @@ function Details:GetInstanceIconsCurrentAlpha() end end -function Details:MicroDisplaysLock (lockstate) +function Details:MicroDisplaysLock(lockstate) if (lockstate == nil) then lockstate = self.micro_displays_locked end self.micro_displays_locked = lockstate if (lockstate) then --is locked - Details.StatusBar:LockDisplays (self, true) + Details.StatusBar:LockDisplays(self, true) else - Details.StatusBar:LockDisplays (self, false) + Details.StatusBar:LockDisplays(self, false) end end -function Details:MicroDisplaysSide (side, fromuser) +function Details:MicroDisplaysSide(side, fromuser) if (not side) then side = self.micro_displays_side end self.micro_displays_side = side - Details.StatusBar:ReloadAnchors (self) + Details.StatusBar:ReloadAnchors(self) if (self.micro_displays_side == 2 and not self.show_statusbar) then --bottom side - Details.StatusBar:Hide (self) + Details.StatusBar:Hide(self) if (fromuser) then Details:Msg(Loc["STRING_OPTIONS_MICRODISPLAYWARNING"]) end elseif (self.micro_displays_side == 2) then - Details.StatusBar:Show (self) + Details.StatusBar:Show(self) elseif (self.micro_displays_side == 1) then - Details.StatusBar:Show (self) + Details.StatusBar:Show(self) end end -function Details:IsGroupedWith (instance) +function Details:IsGroupedWith(instance) local id = instance:GetId() for side, instanceId in pairs(self.snap) do if (instanceId == id) then @@ -8322,7 +8344,7 @@ function Details:IsGroupedWith (instance) return false end -function Details:GetInstanceGroup (instance_id) +function Details:GetInstanceGroup(instance_id) local instance = self if (instance_id) then @@ -8400,7 +8422,7 @@ function Details:SetWindowScale(scale, fromOptions) end end -function Details:ToolbarSide (side, only_update_anchors) +function Details:ToolbarSide(side, only_update_anchors) if (not side) then side = self.toolbar_side end diff --git a/frames/window_mythicplus/window_chart.lua b/frames/window_mythicplus/window_chart.lua index 4178e939..067304e5 100644 --- a/frames/window_mythicplus/window_chart.lua +++ b/frames/window_mythicplus/window_chart.lua @@ -3,9 +3,10 @@ local Details = _G.Details local addonName, Details222 = ... local _ -local debugmode = false +Details222.Debug.MythicPlusChartWindowDebug = false local verbosemode = false + local CreateFrame = CreateFrame local UIParent = UIParent @@ -283,7 +284,7 @@ function mythicDungeonCharts.ShowChart() mythicDungeonCharts.Frame.ChartFrame:Reset() if (not mythicDungeonCharts.ChartTable) then - if (debugmode) then + if (Details222.Debug.MythicPlusChartWindowDebug) then --development if (Details.mythic_plus.last_mythicrun_chart) then --load the last mythic dungeon run chart @@ -589,6 +590,6 @@ mythicDungeonCharts.ClassColors = { ["DEMONHUNTER3"] = { r = 0.24, g = 0.09, b = 0.39, colorStr = "ffa330c9" }, }; -if (debugmode) then +if (Details222.Debug.MythicPlusChartWindowDebug) then --C_Timer.After(1, mythicDungeonCharts.ShowChart) end \ No newline at end of file diff --git a/frames/window_spellcategory.lua b/frames/window_spellcategory.lua index 8e4dc7a5..b81eab52 100644 --- a/frames/window_spellcategory.lua +++ b/frames/window_spellcategory.lua @@ -107,7 +107,7 @@ function Details.Survey.InitializeSpellCategoryFeedback() if (msg:find("funpt")) then if (not alreadySent) then Details.spell_category_latest_sent = 0 - C_Timer.After(random(0, 200), function() + C_Timer.After(math.random(0, 200), function() Details.Survey.SendSpellCatogeryDataToTargetCharacter() end) alreadySent = true diff --git a/frames/window_welcome.lua b/frames/window_welcome.lua index 1c8cec05..a651a28a 100644 --- a/frames/window_welcome.lua +++ b/frames/window_welcome.lua @@ -1,3 +1,5 @@ + +local addonName, Details222 = ... local _detalhes = _G.Details local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") @@ -1058,7 +1060,7 @@ local window_openned_at = time() _detalhes.zone_type = "pvp" - _detalhes:EntrarEmCombate() + Details222.StartCombat() _detalhes:StartTestBarUpdate() diff --git a/functions/commentator.lua b/functions/commentator.lua new file mode 100644 index 00000000..02d4f52a --- /dev/null +++ b/functions/commentator.lua @@ -0,0 +1,90 @@ + +local Details = _G.Details +local addonName, Details222 = ... +local Loc = LibStub("AceLocale-3.0"):GetLocale("Details") +---@type detailsframework +local detailsFramework = DetailsFramework +local _ + +--commentator functions are features to help the streamer or blizzard commentator to show information about the combat in a more visual way +--atm the moment using "/run Details.Commentator.ShowBestInShowFrame(secondsToHide, height)" +--a third party frame can be attached to the best in show frame to show information about the combat (parent: DetailsBestInShowFrame) + +function Details222.LoadCommentatorFunctions() + local frameWidth = 300 + local frameHeight = 400 + + local bestInShowFrame = CreateFrame("frame", "DetailsBestInShowFrame", UIParent, "BackdropTemplate") + bestInShowFrame:SetSize(frameWidth, frameHeight) + bestInShowFrame:SetPoint("left", UIParent, "left", 0, 0) + bestInShowFrame:Hide() + + --apply the standard backdrop from the framework and remove/hide/ the border + detailsFramework:ApplyStandardBackdrop(bestInShowFrame) + bestInShowFrame:SetBackdropBorderColor(0, 0, 0, 0) + + --create an animation that will slide the frame from out of the screen from the left to the right, the frame will fade in while moving, the size of the momevent is the width of the frame, on the animation start, set its alpha to zero and set its point to be out of the screen in the left side, when the animation end stick the frame where the animation ended and make the frame be visible + local onStartAnimation = function() + bestInShowFrame:Show() + bestInShowFrame:SetAlpha(0) + --clear the frame points and set it to be out of the frame with the right side attached to the left of the screen + bestInShowFrame:ClearAllPoints() + bestInShowFrame:SetPoint("right", UIParent, "left", 0, 0) + end + + local onEndAnimation = function() + bestInShowFrame:SetAlpha(1) + bestInShowFrame:ClearAllPoints() + bestInShowFrame:SetPoint("left", UIParent, "left", 0, 0) + end + + local animShow = detailsFramework:CreateAnimationHub(bestInShowFrame, onStartAnimation, onEndAnimation) + local fade1Anim = detailsFramework:CreateAnimation(animShow, "Alpha", 1, 0.10, 0, 1) + local translate1Anim = detailsFramework:CreateAnimation(animShow, "Translation", 1, 0.15, bestInShowFrame:GetWidth(), 0) + + --create an animation that is the contrary of the first one, which will move the frame to the left, fade out and hide it + --no need the start animation here as the frame is already shown from the animShow animation + local onEndOnHideAnimation = function() + bestInShowFrame:Hide() + end + local animHide = detailsFramework:CreateAnimationHub(bestInShowFrame, nil, onEndOnHideAnimation) + local fade2Anim = detailsFramework:CreateAnimation(animHide, "Alpha", 1, 0.10, 1, 0) + local translate2Anim = detailsFramework:CreateAnimation(animHide, "Translation", 1, 0.15, -bestInShowFrame:GetWidth(), 0) + + -- + + DetailsBestInShowFrame.ShowAnimation = animShow + --C_Commentator +-- /run DetailsBestInShowFrame.ShowAnimation:Play() + + ---@class commentator : table + ---@field GetBestInShowFrame fun():frame return a frame object which can be used to attach other widgets on it to show information + ---@field ShowBestInShowFrame fun(secondsToHide:number?) show the best in show frame using the animShow animation and hide it after X seconds + + Details.Commentator = {} + + function Details.Commentator.GetBestInShowFrame() + return bestInShowFrame + end + + ---@param secondsToHide number? the amount of seconds to hide the frame after it is shown + ---@param height number? the height of the frame + function Details.Commentator.ShowBestInShowFrame(secondsToHide, height) + if (bestInShowFrame:IsShown()) then + return + end + + height = height or frameHeight + bestInShowFrame:SetHeight(height) + + animShow:Play() + + local timer = C_Timer.NewTimer(secondsToHide or 7, function() + animShow:Stop() + animHide:Play() + end) + + --save the timer in details commentator table + Details.Commentator.HideTimer = timer + end +end \ No newline at end of file diff --git a/functions/mythicdungeon/data_capture.lua b/functions/mythicdungeon/data_capture.lua index 46f26f2a..20ca1274 100644 --- a/functions/mythicdungeon/data_capture.lua +++ b/functions/mythicdungeon/data_capture.lua @@ -221,7 +221,7 @@ function mythicDungeonCharts:OnStartMythicDungeon() mythicDungeonCharts.ChartTable.Ticker = C_Timer.NewTicker(1, tickerCallback) --save the chart for development - if (debugmode) then + if (Details222.Debug.MythicPlusChartWindowDebug) then Details.mythic_plus.last_mythicrun_chart = mythicDungeonCharts.ChartTable end diff --git a/functions/mythicdungeon/segments.lua b/functions/mythicdungeon/segments.lua index 68fb1e75..6276c7b7 100644 --- a/functions/mythicdungeon/segments.lua +++ b/functions/mythicdungeon/segments.lua @@ -205,7 +205,7 @@ function DetailsMythicPlusFrame.MergeSegmentsOnEnd() --~merge 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:StartCombat() + Details222.StartCombat() --get the current combat just created and the table with all past segments local newCombat = Details:GetCurrentCombat() @@ -455,7 +455,7 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone() if (not Details:GetCurrentCombat()) then --assuming there's no segment from the dungeon run - Details:StartCombat() + Details222.StartCombat() Details:EndCombat() end diff --git a/functions/slash.lua b/functions/slash.lua index a7a1ed5d..691805b7 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -1286,7 +1286,7 @@ function SlashCmdList.DETAILS (msg, editbox) end --create a new combat to be the overall for the mythic run - Details:EntrarEmCombate() + Details222.StartCombat() --get the current combat just created and the table with all past segments local newCombat = Details:GetCurrentCombat() @@ -1439,7 +1439,7 @@ function SlashCmdList.DETAILS (msg, editbox) local tokenId = line:match("%s%s(.*)"):match("^(.-),") if (tokenId == "ENCOUNTER_START") then - Details:StartCombat() + Details222.StartCombat() end if (tokenId == "ENCOUNTER_END") then diff --git a/startup.lua b/startup.lua index 8c4de5fd..fe2c2fec 100644 --- a/startup.lua +++ b/startup.lua @@ -65,6 +65,12 @@ function Details:StartMeUp() --@deathTable: a table containing all the information about the player's death Details.ShowDeathTooltipFunction = Details.ShowDeathTooltip + if (C_CVar) then + if (not InCombatLockdown()) then --disable for releases + C_CVar.SetCVar("cameraDistanceMaxZoomFactor", 2.6) + end + end + ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --initialize @@ -89,8 +95,12 @@ function Details:StartMeUp() Details222.CreateAllDisplaysFrame() + Details222.LoadCommentatorFunctions() + if (Details.ocd_tracker.show_options) then Details:InitializeCDTrackerWindow() + else + Details:InitializeCDTrackerWindow() --enabled for v11 beta, debug openraid end --/run Details.ocd_tracker.show_options = true; ReloadUI() --custom window @@ -279,7 +289,7 @@ function Details:StartMeUp() Details.listener:RegisterEvent("ASCENSION_KNOWN_ENTRIES_CHANGED") - Details.parser_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") + Details222.parser_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") --update is in group Details.details_users = {} @@ -416,7 +426,7 @@ function Details:StartMeUp() --version Details.FadeHandler.Fader(instance._version, 0) instance._version:SetText("Details! " .. Details.userversion .. " (core " .. Details.realversion .. ")") - instance._version:SetTextColor(1, 1, 1, .35) + instance._version:SetTextColor(1, 1, 1, .95) instance._version:SetPoint("bottomleft", instance.baseframe, "bottomleft", 5, 1) if (instance.auto_switch_to_old) then