From d6420d190240d40a91e8cf4fc22f16435cc2fae8 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Wed, 31 Aug 2022 11:36:15 -0300 Subject: [PATCH] Attempt to fix Encounter Time not showing for some users --- Libs/DF/dropdown.lua | 2 +- Libs/DF/fw.lua | 2 +- Libs/DF/panel.lua | 20 +++---- frames/window_main.lua | 122 +++++++++++++++++++++++------------------ functions/profiles.lua | 1 + 5 files changed, 83 insertions(+), 64 deletions(-) diff --git a/Libs/DF/dropdown.lua b/Libs/DF/dropdown.lua index 218546c63..5062db4cf 100644 --- a/Libs/DF/dropdown.lua +++ b/Libs/DF/dropdown.lua @@ -1271,7 +1271,7 @@ function DF:CreateNewDropdownFrame(parent, name) scroll:SetScrollChild(child) tinsert(UISpecialFrames, f.dropdownborder:GetName()) - tinsert(UISpecialFrames, f.dropdownframe:GetName()) + --tinsert(UISpecialFrames, f.dropdownframe:GetName()) --not adding this solves an issue with ConsolePort addon and stackoverflows on Hide... return f end diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 61fc48b2f..c2ca227dc 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 332 +local dversion = 334 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index 034ccb04b..84d792379 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -6542,8 +6542,8 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) pvptalent = {x2StartAt, -70}, group = {x2StartAt, -210}, affix = {x2StartAt, -270}, - encounter_ids = {x2StartAt, -400}, - map_ids = {x2StartAt, -440}, + encounter_ids = {x2StartAt, -420}, + map_ids = {x2StartAt, -460}, } local editingLabel = DF:CreateLabel (f, "Load Conditions For:") @@ -6592,7 +6592,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) }) end - local classGroup = DF:CreateRadionGroup (f, classes, name, {width = 200, height = 200, title = "Character Class"}, {offset_x = 130, amount_per_line = 3}) + local classGroup = DF:CreateCheckboxGroup (f, classes, name, {width = 200, height = 200, title = "Character Class"}, {offset_x = 130, amount_per_line = 3}) classGroup:SetPoint ("topleft", f, "topleft", anchorPositions.class [1], anchorPositions.class [2]) classGroup.DBKey = "class" tinsert (f.AllRadioGroups, classGroup) @@ -6610,7 +6610,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) texture = specIcon, }) end - local specGroup = DF:CreateRadionGroup (f, specs, name, {width = 200, height = 200, title = "Character Spec"}, {offset_x = 130, amount_per_line = 4}) + local specGroup = DF:CreateCheckboxGroup (f, specs, name, {width = 200, height = 200, title = "Character Spec"}, {offset_x = 130, amount_per_line = 4}) specGroup:SetPoint ("topleft", f, "topleft", anchorPositions.spec [1], anchorPositions.spec [2]) specGroup.DBKey = "spec" tinsert (f.AllRadioGroups, specGroup) @@ -6626,7 +6626,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) get = function() return f.OptionsTable.race [raceTable.FileString] end, }) end - local raceGroup = DF:CreateRadionGroup (f, raceList, name, {width = 200, height = 200, title = "Character Race"}) + local raceGroup = DF:CreateCheckboxGroup (f, raceList, name, {width = 200, height = 200, title = "Character Race"}) raceGroup:SetPoint ("topleft", f, "topleft", anchorPositions.race [1], anchorPositions.race [2]) raceGroup.DBKey = "race" tinsert (f.AllRadioGroups, raceGroup) @@ -6643,7 +6643,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) texture = talentTable.Texture, }) end - local talentGroup = DF:CreateRadionGroup (f, talentList, name, {width = 200, height = 200, title = "Characer Talents"}, {offset_x = 150, amount_per_line = 3}) + local talentGroup = DF:CreateCheckboxGroup (f, talentList, name, {width = 200, height = 200, title = "Characer Talents"}, {offset_x = 150, amount_per_line = 3}) talentGroup:SetPoint ("topleft", f, "topleft", anchorPositions.talent [1], anchorPositions.talent [2]) talentGroup.DBKey = "talent" tinsert (f.AllRadioGroups, talentGroup) @@ -6743,7 +6743,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) texture = talentTable.Texture, }) end - local pvpTalentGroup = DF:CreateRadionGroup (f, pvpTalentList, name, {width = 200, height = 200, title = "Characer PvP Talents"}, {offset_x = 150, amount_per_line = 3}) + local pvpTalentGroup = DF:CreateCheckboxGroup (f, pvpTalentList, name, {width = 200, height = 200, title = "Characer PvP Talents"}, {offset_x = 150, amount_per_line = 3}) pvpTalentGroup:SetPoint ("topleft", f, "topleft", anchorPositions.pvptalent [1], anchorPositions.pvptalent [2]) pvpTalentGroup.DBKey = "pvptalent" tinsert (f.AllRadioGroups, pvpTalentGroup) @@ -6841,7 +6841,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) get = function() return f.OptionsTable.group [groupTable.ID] or f.OptionsTable.group [groupTable.ID .. ""] end, }) end - local groupTypesGroup = DF:CreateRadionGroup (f, groupTypes, name, {width = 200, height = 200, title = "Group Types"}) + local groupTypesGroup = DF:CreateCheckboxGroup (f, groupTypes, name, {width = 200, height = 200, title = "Group Types"}) groupTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.group [1], anchorPositions.group [2]) groupTypesGroup.DBKey = "group" tinsert (f.AllRadioGroups, groupTypesGroup) @@ -6856,7 +6856,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) get = function() return f.OptionsTable.role [roleTable.ID] or f.OptionsTable.role [roleTable.ID .. ""] end, }) end - local roleTypesGroup = DF:CreateRadionGroup (f, roleTypes, name, {width = 200, height = 200, title = "Role Types"}) + local roleTypesGroup = DF:CreateCheckboxGroup (f, roleTypes, name, {width = 200, height = 200, title = "Role Types"}) roleTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.role [1], anchorPositions.role [2]) roleTypesGroup.DBKey = "role" tinsert (f.AllRadioGroups, roleTypesGroup) @@ -6876,7 +6876,7 @@ function DF:OpenLoadConditionsPanel (optionsTable, callback, frameOptions) }) end end - local affixTypesGroup = DF:CreateRadionGroup (f, affixes, name, {width = 200, height = 200, title = "M+ Affixes"}) + local affixTypesGroup = DF:CreateCheckboxGroup (f, affixes, name, {width = 200, height = 200, title = "M+ Affixes"}) affixTypesGroup:SetPoint ("topleft", f, "topleft", anchorPositions.affix [1], anchorPositions.affix [2]) affixTypesGroup.DBKey = "affix" tinsert (f.AllRadioGroups, affixTypesGroup) diff --git a/frames/window_main.lua b/frames/window_main.lua index bdf2ad7d8..bba1a5efe 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -7916,41 +7916,42 @@ function _detalhes:RefreshAttributeTextSize() end -- ~encounter ~timer -function _detalhes:CheckForTextTimeCounter (combat_start) - if (combat_start) then - if (_detalhes.tabela_vigente.is_boss) then - local lower = _detalhes:GetLowerInstanceNumber() - if (lower) then - local instance = _detalhes:GetInstance (lower) +function Details:CheckForTextTimeCounter(combatStart) --called from combat start function + if (combatStart) then + --if (Details.tabela_vigente.is_boss) then --is an encounter + local instanceId = Details:GetLowerInstanceNumber() + if (instanceId) then + local instance = Details:GetInstance(instanceId) if (instance.baseframe and instance:IsEnabled()) then - if (instance.attribute_text.show_timer) then - if (_detalhes.instance_title_text_timer [instance:GetId()]) then - Details.Schedules.Cancel(_detalhes.instance_title_text_timer [instance:GetId()]) + if (instance.attribute_text.show_timer) then --can show the timer + --start a new ticker of 1 second + if (Details.instance_title_text_timer[instance:GetId()]) then + Details.Schedules.Cancel(Details.instance_title_text_timer[instance:GetId()]) end - _detalhes.instance_title_text_timer[instance:GetId()] = Details.Schedules.NewTicker(1, Details.TitleTextTickTimer, Details, instance) + Details.instance_title_text_timer[instance:GetId()] = Details.Schedules.NewTicker(1, Details.TitleTextTickTimer, Details, instance) end end else - return - end - else - if (_detalhes.in_combat and _detalhes.zone_type == "raid") then - Details.Schedules.NewTimer(3, Details.CheckForTextTimeCounter, Details, true) + return --there's no open window end - end + --else --boss encounter not found + -- if (Details.in_combat and Details.zone_type == "raid") then + -- Details.Schedules.NewTimer(3, Details.CheckForTextTimeCounter, Details, true) + -- end + --end else - for _, instance in ipairs (_detalhes.tabela_instancias) do - if (_detalhes.instance_title_text_timer [instance:GetId()] and instance.baseframe and instance:IsEnabled() and instance.menu_attribute_string) then - Details.Schedules.Cancel(_detalhes.instance_title_text_timer[instance:GetId()]) - local current_text = instance:GetTitleBarText() - current_text = current_text:gsub ("%[.*%] ", "") - instance:SetTitleBarText(current_text) + for instanceId, instance in Details:ListInstances() do + if (Details.instance_title_text_timer[instance:GetId()] and instance.baseframe and instance:IsEnabled() and instance.menu_attribute_string) then --check if the instance is initialized + Details.Schedules.Cancel(Details.instance_title_text_timer[instance:GetId()]) + local currentText = instance:GetTitleBarText() + currentText = currentText:gsub("%[.*%] ", "") + instance:SetTitleBarText(currentText) end end end end -local format_timer = function (t) +local formatTime = function (t) local m, s = _math_floor (t/60), _math_floor (t%60) if (m < 1) then m = "00" @@ -7963,32 +7964,67 @@ local format_timer = function (t) return "[" .. m .. ":" .. s .. "]" end -function _detalhes:TitleTextTickTimer (instance) +function _detalhes:TitleTextTickTimer (instance) --called on each 1 second tick if (instance.attribute_text.enabled) then + --tick only during encounter + if (not Details.titletext_showtimer_always) then + if (IsEncounterInProgress) then + if (not IsEncounterInProgress()) then + return + end + else + if (not Details.tabela_vigente.is_boss) then + return + end + end + end + local currentText = instance.menu_attribute_string.originalText if (currentText) then - local timer = format_timer (_detalhes.tabela_vigente:GetCombatTime()) + local timer = formatTime(_detalhes.tabela_vigente:GetCombatTime()) instance:SetTitleBarText(timer .. " " .. currentText) else local current_text = instance:GetTitleBarText() - if (not current_text:find ("%[.*%]")) then + if (not current_text:find("%[.*%]")) then instance:SetTitleBarText("[00:01] " .. current_text) else - local timer = format_timer (_detalhes.tabela_vigente:GetCombatTime()) - current_text = current_text:gsub ("%[.*%]", timer) + local timer = formatTime(_detalhes.tabela_vigente:GetCombatTime()) + current_text = current_text:gsub("%[.*%]", timer) instance:SetTitleBarText(current_text) end end end end -function _detalhes:SetTitleBarText(text) - if (self.attribute_text.enabled and self.menu_attribute_string) then +function Details:RefreshTitleBarText() + local titleBarText = self.menu_attribute_string + + if (titleBarText and self == titleBarText.owner_instance) then + local sName = self:GetInstanceAttributeText() + local instanceMode = self:GetMode() + + if (instanceMode == DETAILS_MODE_GROUP or instanceMode == DETAILS_MODE_ALL) then + local segment = self:GetSegment() + if (segment == DETAILS_SEGMENTID_OVERALL) then + sName = sName .. " " .. Loc ["STRING_OVERALL"] + + elseif (segment >= 2) then + sName = sName .. " [" .. segment .. "]" + end + end + + titleBarText:SetText(sName) + titleBarText.originalText = sName + end +end + +function Details:SetTitleBarText(text) + if (self.menu_attribute_string) then self.menu_attribute_string:SetText(text) end end -function _detalhes:GetTitleBarText() +function Details:GetTitleBarText() if (self.menu_attribute_string) then return self.menu_attribute_string:GetText() end @@ -8058,34 +8094,16 @@ function _detalhes:AttributeMenu (enabled, pos_x, pos_y, font, size, color, side end if (not self.menu_attribute_string) then - --local label = gump:NewLabel (self.floatingframe, nil, "DetailsAttributeStringInstance" .. self.meu_id, nil, "", "GameFontHighlightSmall") local label = gump:NewLabel (self.baseframe, nil, "DetailsAttributeStringInstance" .. self.meu_id, nil, "", "GameFontHighlightSmall") self.menu_attribute_string = label - self.menu_attribute_string.text = _detalhes:GetSubAttributeName (self.atributo, self.sub_atributo) + self:RefreshTitleBarText() self.menu_attribute_string.owner_instance = self - self.menu_attribute_string.Enabled = true self.menu_attribute_string.__enabled = true - function self.menu_attribute_string:OnEvent (instance, attribute, subAttribute) - if (instance == label.owner_instance) then - local sName = instance:GetInstanceAttributeText() - local instanceMode = instance:GetMode() - - if (instanceMode == DETAILS_MODE_GROUP or instanceMode == DETAILS_MODE_ALL) then - local segment = instance:GetSegment() - if (segment == DETAILS_SEGMENTID_OVERALL) then - sName = sName .. " " .. Loc ["STRING_OVERALL"] - - elseif (segment >= 2) then - sName = sName .. " [" .. segment .. "]" - end - end - - label.text = sName - label.originalText = sName - end + function self.menu_attribute_string:OnEvent(instance, attribute, subAttribute) + instance:RefreshTitleBarText() end _detalhes:RegisterEvent (self.menu_attribute_string, "DETAILS_INSTANCE_CHANGEATTRIBUTE", self.menu_attribute_string.OnEvent) diff --git a/functions/profiles.lua b/functions/profiles.lua index 8cb744ada..02b14c69a 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1284,6 +1284,7 @@ local default_global_data = { }, current_exp_raid_encounters = {}, installed_skins_cache = {}, + titletext_showtimer_always = false, --> keystone cache keystone_cache = {},