diff --git a/Definitions.lua b/Definitions.lua index 8a122757..a3413dee 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -415,6 +415,7 @@ ---@field texture texture ---@class breakdownspellscrollframe : frame +---@field Header frame ---@class breakdownspellbar : button ---@field index number diff --git a/classes/class_instance.lua b/classes/class_instance.lua index 197923ce..55f61942 100644 --- a/classes/class_instance.lua +++ b/classes/class_instance.lua @@ -270,10 +270,9 @@ local instanceMixins = { end, ---call a refresh in the data shown in the instance - ---@param instance instance ---@param bForceRefresh boolean|nil RefreshData = function(instance, bForceRefresh) --deprecates Details:RefreshAllMainWindows() - local combatObject = instance.showing + local combatObject = instance:GetCombat() --check if the combat object exists, if not, freeze the window if (not combatObject) then @@ -283,24 +282,26 @@ local instanceMixins = { return end - local needRefresh = combatObject[instance.atributo].need_refresh + local mainAttribute, subAttribute = instance:GetDisplay() + + local needRefresh = combatObject:GetContainer(mainAttribute).need_refresh if (not needRefresh and not bForceRefresh) then return end - if (instance.atributo == 1) then --damage + if (mainAttribute == 1) then --damage Details.atributo_damage:RefreshWindow(instance, combatObject, bForceRefresh, nil, needRefresh) - elseif (instance.atributo == 2) then --heal + elseif (mainAttribute == 2) then --heal Details.atributo_heal:RefreshWindow(instance, combatObject, bForceRefresh, nil, needRefresh) - elseif (instance.atributo == 3) then --energy + elseif (mainAttribute == 3) then --energy Details.atributo_energy:RefreshWindow(instance, combatObject, bForceRefresh, nil, needRefresh) - elseif (instance.atributo == 4) then --utility + elseif (mainAttribute == 4) then --utility Details.atributo_misc:RefreshWindow(instance, combatObject, bForceRefresh, nil, needRefresh) - elseif (instance.atributo == 5) then --custom + elseif (mainAttribute == 5) then --custom Details.atributo_custom:RefreshWindow(instance, combatObject, bForceRefresh, nil, needRefresh) end end, @@ -330,11 +331,11 @@ local instanceMixins = { end --update player breakdown window if opened - if (not bForceRefresh) then + --if (not bForceRefresh) then if (Details:IsBreakdownWindowOpen()) then return Details:GetActorObjectFromBreakdownWindow():MontaInfo() end - end + --end end end, diff --git a/core/control.lua b/core/control.lua index 823a1d66..73cd9a30 100644 --- a/core/control.lua +++ b/core/control.lua @@ -1848,17 +1848,17 @@ self:RefreshMainWindow(true) end - function Details:RefreshMainWindow(instance, bForceRefresh) - if (not instance or type(instance) == "boolean") then - bForceRefresh = instance - instance = self + function Details:RefreshMainWindow(instanceObject, bForceRefresh) + if (not instanceObject or type(instanceObject) == "boolean") then + bForceRefresh = instanceObject + instanceObject = self end if (not bForceRefresh) then Details.LastUpdateTick = Details._tempo end - if (instance == -1) then + if (instanceObject == -1) then --update for index, thisInstance in ipairs(Details.tabela_instancias) do if (thisInstance.ativa) then @@ -1884,19 +1884,16 @@ return info.jogador:MontaInfo() end end - return - else - if (not instance.ativa) then - --print("instance not actived", instance.RefreshMainWindow, 1+nil) + if (not instanceObject.ativa) then return end end - if (instance.modo == modo_ALL or instance.modo == modo_GROUP) then - --print("updating all instances...") - return instance:RefreshAllMainWindows(bForceRefresh) + local currentMode = instanceObject:GetMode() + if (currentMode == DETAILS_MODE_ALL or currentMode == DETAILS_MODE_GROUP) then + return instanceObject:RefreshAllMainWindows(bForceRefresh) end end diff --git a/frames/window_playerbreakdown.lua b/frames/window_playerbreakdown.lua index f4b35708..82078549 100644 --- a/frames/window_playerbreakdown.lua +++ b/frames/window_playerbreakdown.lua @@ -84,19 +84,22 @@ end ---@param bIsShiftKeyDown boolean|nil ---@param bIsControlKeyDown boolean|nil function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttributeChange, bIsRefresh, bIsShiftKeyDown, bIsControlKeyDown) + ---@type number, number + local mainAttribute, subAttribute = instanceObject:GetDisplay() + --create the player list frame in the left side of the window Details.PlayerBreakdown.CreatePlayerListFrame() - if (not Details.row_singleclick_overwrite[instanceObject.atributo] or not Details.row_singleclick_overwrite[instanceObject.atributo][instanceObject.sub_atributo]) then + if (not Details.row_singleclick_overwrite[mainAttribute] or not Details.row_singleclick_overwrite[mainAttribute][subAttribute]) then Details:CloseBreakdownWindow() return - elseif (type(Details.row_singleclick_overwrite[instanceObject.atributo][instanceObject.sub_atributo]) == "function") then + elseif (type(Details.row_singleclick_overwrite[mainAttribute][subAttribute]) == "function") then if (bFromAttributeChange) then Details:CloseBreakdownWindow() return end - return Details.row_singleclick_overwrite[instanceObject.atributo][instanceObject.sub_atributo](_, actorObject, instanceObject, bIsShiftKeyDown, bIsControlKeyDown) + return Details.row_singleclick_overwrite[mainAttribute][subAttribute](_, actorObject, instanceObject, bIsShiftKeyDown, bIsControlKeyDown) end if (instanceObject:GetMode() == DETAILS_MODE_RAID) then @@ -105,7 +108,7 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute end --Details.info_jogador armazena o jogador que esta sendo mostrado na janela de detalhes - if (breakdownWindow.jogador and breakdownWindow.jogador == actorObject and instanceObject and breakdownWindow.atributo and instanceObject.atributo == breakdownWindow.atributo and instanceObject.sub_atributo == breakdownWindow.sub_atributo and not bIsRefresh) then + if (breakdownWindow.jogador and breakdownWindow.jogador == actorObject and instanceObject and breakdownWindow.atributo and mainAttribute == breakdownWindow.atributo and subAttribute == breakdownWindow.sub_atributo and not bIsRefresh) then Details:CloseBreakdownWindow() --se clicou na mesma barra ent�o fecha a janela de detalhes return @@ -142,15 +145,16 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute breakdownWindow:CreateRightSideBar() end + --todo: all portuguese keys to english + breakdownWindow.ativo = true --sinaliza o addon que a janela esta aberta - breakdownWindow.atributo = instanceObject.atributo --instancia.atributo -> grava o atributo (damage, heal, etc) - breakdownWindow.sub_atributo = instanceObject.sub_atributo --instancia.sub_atributo -> grava o sub atributo (damage done, dps, damage taken, etc) + breakdownWindow.atributo = mainAttribute --instancia.atributo -> grava o atributo (damage, heal, etc) + breakdownWindow.sub_atributo = subAttribute --instancia.sub_atributo -> grava o sub atributo (damage done, dps, damage taken, etc) breakdownWindow.jogador = actorObject --de qual jogador (objeto classe_damage) breakdownWindow.instancia = instanceObject --salva a refer�ncia da inst�ncia que pediu o breakdownWindow breakdownWindow.target_text = Loc ["STRING_TARGETS"] .. ":" breakdownWindow.target_member = "total" breakdownWindow.target_persecond = false - breakdownWindow.mostrando = nil local nome = breakdownWindow.jogador.nome --nome do jogador @@ -299,6 +303,8 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute tabButton:DoClick() tabButton:OnShowFunc() shownTab = tabButton + + actorObject:MontaInfo() --old api to update the breakdown window end end end @@ -644,41 +650,33 @@ function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFun tabName = "unnamed" end - --create a button for the tab - --tabOnClickFunc - local newTabButton = gump:CreateButton(breakdownWindow, function()end, 20, 20, nil, nil, nil, nil, nil, breakdownWindow:GetName() .. "TabButton" .. tabName .. math.random(1, 1000)) - newTabButton:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") + --create a button to select the tab + local tabButton = DetailsFramework:CreateButton(breakdownWindow, function()end, 20, 20, locName, nil, nil, nil, nil, breakdownWindow:GetName() .. "TabButton" .. tabName .. math.random(1, 1000), nil, "DETAILS_TAB_BUTTON_TEMPLATE") + tabButton:SetFrameLevel(breakdownWindow:GetFrameLevel()+1) + tabButton:Hide() + if (tabName == "Summary") then - newTabButton:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") + tabButton:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") end - newTabButton.IsDefaultTab = bIsDefaultTab - - newTabButton:SetText(locName) - newTabButton:SetFrameStrata("HIGH") - newTabButton:SetFrameLevel(breakdownWindow:GetFrameLevel()+1) - newTabButton:Hide() - - newTabButton.condition = conditionFunc - newTabButton.tabname = tabName - newTabButton.localized_name = locName - newTabButton.onclick = tabOnClickFunc - newTabButton.fillfunction = fillFunc - newTabButton.last_actor = {} + tabButton.IsDefaultTab = bIsDefaultTab + tabButton.condition = conditionFunc + tabButton.tabname = tabName + tabButton.localized_name = locName + tabButton.onclick = tabOnClickFunc + tabButton.fillfunction = fillFunc + tabButton.last_actor = {} ---@type tabframe - local tabFrame = CreateFrame("frame", breakdownWindow:GetName() .. "TabFrame" .. tabName .. math.random(1, 1000), UIParent, "BackdropTemplate") - newTabButton.tabFrame = tabFrame - newTabButton.frame = tabFrame - - tabFrame:SetParent(breakdownWindow) - tabFrame:SetFrameStrata("HIGH") - tabFrame:SetFrameLevel(breakdownWindow:GetFrameLevel()+5) - tabFrame:EnableMouse(true) + local tabFrame = CreateFrame("frame", breakdownWindow:GetName() .. "TabFrame" .. tabName .. math.random(1, 10000), breakdownWindow, "BackdropTemplate") + tabFrame:SetFrameLevel(breakdownWindow:GetFrameLevel()+1) tabFrame:SetPoint("topleft", breakdownWindow, "topleft", 0, -70) tabFrame:SetPoint("bottomright", breakdownWindow, "bottomright", 0, 20) tabFrame:Hide() + tabButton.tabFrame = tabFrame + tabButton.frame = tabFrame + if (iconSettings) then local texture = iconSettings.texture local coords = iconSettings.coords @@ -687,35 +685,43 @@ function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFun local overlay, textdistance, leftpadding, textheight, short_method --nil - newTabButton:SetIcon (texture, width, height, "overlay", coords, overlay, textdistance, leftpadding, textheight, short_method) + tabButton:SetIcon(texture, width, height, "overlay", coords, overlay, textdistance, leftpadding, textheight, short_method) if (iconSettings.desaturated) then - newTabButton.icon:SetDesaturated(true) + tabButton.icon:SetDesaturated(true) end end - if (newTabButton.fillfunction) then + if (tabButton.fillfunction) then tabFrame:SetScript("OnShow", function() - if (newTabButton.last_actor == breakdownWindow.jogador) then + ---@type actor + local actorObject = Details:GetActorObjectFromBreakdownWindow() + ---@type instance + local instanceObject = Details:GetActiveWindowFromBreakdownWindow() + ---@type combat + local combatObject = instanceObject:GetCombat() + + if (tabButton.last_actor == actorObject) then return end - newTabButton.last_actor = breakdownWindow.jogador - newTabButton:fillfunction(breakdownWindow.jogador, breakdownWindow.instancia.showing) + + tabButton.last_actor = actorObject + tabButton:fillfunction(actorObject, combatObject) end) end if (onCreateFunc) then - onCreateFunc(newTabButton, tabFrame) + onCreateFunc(tabButton, tabFrame) end - newTabButton.replaces = replace - Details.player_details_tabs[#Details.player_details_tabs+1] = newTabButton + tabButton.replaces = replace + Details.player_details_tabs[#Details.player_details_tabs+1] = tabButton - local onTabClickCallback = function(self) - self = self.MyObject or self + local onTabClickCallback = function(self) --self = tabButton + self = self.MyObject or self --framework button - for _, tab in ipairs(Details:GetBreakdownTabsInUse()) do - tab.frame:Hide() - tab:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") + for _, thisTabButton in ipairs(Details:GetBreakdownTabsInUse()) do + thisTabButton.frame:Hide() + thisTabButton:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE") end self:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE") @@ -723,35 +729,35 @@ function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFun end if (not tabOnClickFunc) then - newTabButton.OnShowFunc = function(self) + tabButton.OnShowFunc = function(self) --hide all tab frames, reset the template on all tabs --then set the template on this tab and set as selected tab onTabClickCallback(self) --show the tab frame tabFrame:Show() end - newTabButton:SetScript("OnClick", newTabButton.OnShowFunc) + tabButton:SetScript("OnClick", tabButton.OnShowFunc) else --custom - newTabButton.OnShowFunc = function(self) + tabButton.OnShowFunc = function(self) --hide all tab frames, reset the template on all tabs --then set the template on this tab and set as selected tab onTabClickCallback(self) --run onclick func - local result, errorText = pcall(tabOnClickFunc, newTabButton, tabFrame) + local result, errorText = pcall(tabOnClickFunc, tabButton, tabFrame) if (not result) then print("error on running tabOnClick function:", errorText) end end - newTabButton:SetScript("OnClick", newTabButton.OnShowFunc) + tabButton:SetScript("OnClick", tabButton.OnShowFunc) end - function newTabButton:DoClick() + function tabButton:DoClick() self:GetScript("OnClick")(self) end - newTabButton:SetScript("PostClick", function(self) + tabButton:SetScript("PostClick", function(self) CurrentTab = self.tabname or self.MyObject.tabname if (CurrentTab ~= "Summary") then @@ -765,5 +771,5 @@ function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFun end end) - return newTabButton, tabFrame + return tabButton, tabFrame end \ No newline at end of file diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua index 12995095..0c793e9a 100644 --- a/frames/window_playerbreakdown_spells.lua +++ b/frames/window_playerbreakdown_spells.lua @@ -211,6 +211,17 @@ function spellsTab.OnCreateTabCallback(tabButton, tabFrame) tabFrame.barras3 = {} --deprecated spellsTab.TabFrame = tabFrame + + --open the breakdown window at startup + --[=[ + C_Timer.After(1, function() + Details:OpenPlayerDetails(1) + C_Timer.After(1, function() + Details:OpenPlayerDetails(1) + Details:OpenPlayerDetails(1) + end) + end) + --]=] end function spellsTab.TrocaBackgroundInfo(tabFrame) --> spells tab | to be refactored | called fom OpenJanelaInfo function @@ -359,40 +370,6 @@ do --hide bars functions - to be refactored end end ---bar scripts -local onMouseDownCallback = function(self, button) - local hostFrame = breakdownWindow - - if (button == "LeftButton") then - hostFrame:StartMoving() - hostFrame.isMoving = true - - elseif (button == "RightButton" and not self.isMoving) then - Details:CloseBreakdownWindow() - end -end - -local onMouseUpCallback = function(self, button) - local hostFrame = breakdownWindow - - if (hostFrame.isMoving) then - hostFrame:StopMovingOrSizing() - hostFrame.isMoving = false - end -end - -function spellsTab.ApplyScripts() - local hostFrame = breakdownWindow --cannot be breakdown window, it should be the frame of the tab - hostFrame.SpellScrollFrame.gump:SetScript("OnMouseDown", onMouseDownCallback) - hostFrame.SpellScrollFrame.gump:SetScript("OnMouseUp", onMouseUpCallback) - - hostFrame.container_detalhes:SetScript("OnMouseDown", onMouseDownCallback) - hostFrame.container_detalhes:SetScript("OnMouseUp", onMouseUpCallback) - - hostFrame.container_alvos.gump:SetScript("OnMouseDown", onMouseDownCallback) - hostFrame.container_alvos.gump:SetScript("OnMouseUp", onMouseUpCallback) -end - function spellsTab.CreateReportButtons(tabFrame) --spell list report button tabFrame.report_esquerda = Details.gump:NewDetailsButton(tabFrame, tabFrame, nil, _detalhes.Reportar, tabFrame, 1, 16, 16, "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport2") @@ -439,7 +416,6 @@ end ---@param spellBar breakdownspellbar local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por nomes nas funções e formatar as linhas das funcções --all values from spellBar are cached values - --check if there's a spellbar selected, if there's one, ignore the mouseover if (spellsTab.HasSelectedSpellBar()) then return @@ -707,44 +683,29 @@ end ---@param spellBar breakdownspellbar ---@param button string local onMouseDownBreakdownSpellBar = function(spellBar, button) - print(1, spellBar:GetName()) - if false then - local x, y = _G.GetCursorPosition() - spellBar.cursorPosX = math.floor(x) - spellBar.cursorPosY = math.floor(y) - Details222.PlayerBreakdown.OnMouseDown(spellBar, button) - end + local x, y = _G.GetCursorPosition() + spellBar.cursorPosX = math.floor(x) + spellBar.cursorPosY = math.floor(y) end ---on mouse up a breakdownspellbar in the breakdown window ---@param spellBar breakdownspellbar ---@param button string local onMouseUpBreakdownSpellBar = function(spellBar, button) - print(2, spellBar:GetName()) - if false then - if (spellBar.onMouseUpTime == GetTime()) then - return - end + spellBar.onMouseUpTime = GetTime() - spellBar.onMouseUpTime = GetTime() + ---@type number, number + local x, y = _G.GetCursorPosition() + x = math.floor(x) + y = math.floor(y) - ---@type number, number - local x, y = _G.GetCursorPosition() - x = math.floor(x) - y = math.floor(y) + ---@type boolean + local bIsMouseInTheSamePosition = (x == spellBar.cursorPosX) and (y == spellBar.cursorPosY) - ---@type boolean - local bIsMouseInTheSamePosition = (x == spellBar.cursorPosX) and (y == spellBar.cursorPosY) - - --if the mouse is in the same position, then the user clicked the bar - --clicking the bar activate the lock mechanism - if (bIsMouseInTheSamePosition) then - spellsTab.SelectSpellBar(spellBar) - end + --if the mouse is in the same position, then the user clicked the bar + if (bIsMouseInTheSamePosition) then + spellsTab.SelectSpellBar(spellBar) end - - --print("selecting spell bar") - --spellsTab.SelectSpellBar(spellBar) end @@ -1229,7 +1190,7 @@ end ---@param scrollData breakdownscrolldata ---@param offset number ---@param totalLines number -local refreshFunc = function(scrollFrame, scrollData, offset, totalLines) --~refresh spells +local refreshFunc = function(scrollFrame, scrollData, offset, totalLines) --~refreshspells ~refresh ---@type number local maxValue = scrollData[1] and scrollData[1].total ---@type number @@ -1336,7 +1297,7 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) local headerTable = {} scrollFrame.Header = DetailsFramework:CreateHeader(tabFrame, headerTable, headerOptions) - scrollFrame.Header:SetPoint("topleft", scrollFrame, "topleft", 0, 0) + scrollFrame.Header:SetPoint("topleft", scrollFrame, "topleft", 0, 1) --create the scroll lines for i = 1, CONST_SPELLSCROLL_AMTLINES do @@ -1544,29 +1505,6 @@ end ---@param index number ---@return breakdownspellbar function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~create ~createline - - if (index == 1) then - --on this debug the onmousedown and onmouseup are working properly because is parented to the breakdownWindow - --but not on the spellbar which is parented to the spellscrollframe - local b = CreateFrame("button", nil, breakdownWindow, "BackdropTemplate") - b:SetSize(64, 64) - b:EnableMouse(true) - b:RegisterForClicks("AnyUp", "AnyDown") - b:SetPoint("topleft", breakdownWindow, "topleft", 50, -30) - b:SetScript("OnMouseDown", function() print("hi") end) - b:SetScript("OnMouseUp", function() print("bye") end) - DF:ApplyStandardBackdrop(b) - end - - local buttonTest = CreateFrame("button", self:GetName() .. "SpellBarTest" .. index, self, "BackdropTemplate") - buttonTest:SetSize(64, 64) - buttonTest:EnableMouse(true) - buttonTest:RegisterForClicks("AnyUp", "AnyDown") - buttonTest:SetFrameStrata("TOOLTIP") - buttonTest:SetScript("OnMouseDown", function() print("hi") end) - buttonTest:SetScript("OnMouseUp", function() print("bye") end) - DF:ApplyStandardBackdrop(buttonTest) - ---@type breakdownspellbar local spellBar = CreateFrame("button", self:GetName() .. "SpellBar" .. index, self, "BackdropTemplate") spellBar.index = index @@ -1577,8 +1515,6 @@ function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~cr spellBar:SetPoint("topleft", self, "topleft", 0, y) spellBar:SetPoint("topright", self, "topright", 0, y) - buttonTest:SetPoint("topleft", self, "topleft", 0, y) - spellBar:EnableMouse(true) spellBar:RegisterForClicks("AnyUp", "AnyDown") spellBar:SetAlpha(0.9) @@ -1591,7 +1527,6 @@ function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~cr spellBar.ExpandedChildren = {} DF:Mixin(spellBar, DF.HeaderFunctions) - DF:Mixin(buttonTest, DF.HeaderFunctions) ---@type statusbar local statusBar = CreateFrame("StatusBar", "$parentStatusBar", spellBar, "BackdropTemplate")