Skip to content

Commit

Permalink
Added support for Tab replacement on the breakdown window
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Nov 10, 2021
1 parent 8539e3b commit 7adae64
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 36 deletions.
138 changes: 108 additions & 30 deletions frames/window_playerbreakdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,27 @@ local spellInfoSettings = {
amount = 6,
}

_detalhes.player_details_tabs = {}
info.currentTabsInUse = {}

------------------------------------------------------------------------------------------------------------------------------
--self = instancia
--jogador = classe_damage ou classe_heal

function Details:GetBreakdownTabsInUse()
return info.currentTabsInUse
end

function Details:GetBreakdownTabByName(tabName, tablePool)
tablePool = tablePool or _detalhes.player_details_tabs
for index = 1, #tablePool do
local tab = tablePool[index]
if (tab.tabname == tabName) then
return tab, index
end
end
end

--return the combat being used to show the data in the opened breakdown window
function Details:GetCombatFromBreakdownWindow()
return info.instancia and info.instancia.showing
Expand Down Expand Up @@ -214,13 +231,13 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo
gump:HidaAllDetalheInfo()

gump:JI_AtualizaContainerBarras (-1)

local classe = jogador.classe

if (not classe) then
classe = "monster"
end

--info.classe_icone:SetTexture ("Interface\\AddOns\\Details\\images\\"..classe:lower()) --> top left
info.classe_icone:SetTexture ("Interface\\AddOns\\Details\\images\\classes") --> top left
info.SetClassIcon (jogador, classe)
Expand All @@ -240,27 +257,88 @@ function _detalhes:AbreJanelaInfo (jogador, from_att_change, refresh, ShiftKeyDo
end
end
end

info:ShowTabs()
Details.FadeHandler.Fader (info, 0)

--info:ShowTabs()

Details.FadeHandler.Fader(info, 0)
Details:UpdateBreakdownPlayerList()

--check which tab was selected and reopen that tab
-- if (info.selectedTab == "Summary") then
-- return jogador:MontaInfo()
-- else

--open tab
local tabsShown = {}
local tabsReplaced = {}
local tabReplacedAmount = 0

table.wipe(info.currentTabsInUse)

for index = 1, #_detalhes.player_details_tabs do
local tab = _detalhes.player_details_tabs [index]
if (tab:condition (info.jogador, info.atributo, info.sub_atributo)) then
if (tab.tabname == info.selectedTab) then
--_detalhes.player_details_tabs [index]:Click()
--_detalhes.player_details_tabs [index].onclick()
_detalhes.player_details_tabs [index]:OnShowFunc()
local tab = _detalhes.player_details_tabs[index]
tab.replaced = nil
tabsShown[#tabsShown+1] = tab
end

for index = 1, #tabsShown do
--get the tab
local tab = tabsShown[index]

if (tab.replaces) then
local attributeList = tab.replaces.attributes
if (attributeList[info.atributo]) then
if (attributeList[info.atributo][info.sub_atributo]) then
local tabReplaced, tabIndex = Details:GetBreakdownTabByName(tab.replaces.tabNameToReplace, tabsShown)
if (tabReplaced and tabIndex < index) then

tabReplaced:Hide()
tabReplaced.frame:Hide()
tinsert(tabsReplaced, tabReplaced)

tremove(tabsShown, tabIndex)
tinsert(tabsShown, tabIndex, tab)

if (tabReplaced.tabname == info.selectedTab) then
info.selectedTab = tab.tabname
end

tabReplaced.replaced = true
tabReplacedAmount = tabReplacedAmount + 1
end
end
end
end
end

local newTabsShown = {}
local tabAlreadyInUse = {}

for index = 1, #tabsShown do
if (not tabAlreadyInUse[tabsShown[index].tabname]) then
tabAlreadyInUse[tabsShown[index].tabname] = true
tinsert(newTabsShown, tabsShown[index])
end
end

tabsShown = newTabsShown
info.currentTabsInUse = newTabsShown

info:ShowTabs()

local shownTab
for index = 1, #tabsShown do
local tab = tabsShown[index]
if (tab:condition(info.jogador, info.atributo, info.sub_atributo)) then
if (info.selectedTab == tab.tabname) then
tabsShown[index]:Click()
tabsShown[index]:OnShowFunc()
shownTab = tabsShown[index]
end
end
end

shownTab:Click()
end

-- for beta todo: info background need a major rewrite
Expand Down Expand Up @@ -1861,7 +1939,7 @@ function gump:CriaJanelaInfo()
end,
nil, --[4] fill function
function() --[5] onclick
for _, tab in _ipairs (_detalhes.player_details_tabs) do
for _, tab in _ipairs (Details:GetBreakdownTabsInUse()) do
tab.frame:Hide()
end
end,
Expand Down Expand Up @@ -4874,12 +4952,12 @@ function gump:CriaJanelaInfo()
local secondRowIndex = 1
local breakLine = 6 --th tab it'll start the second line

for index = 1, #_detalhes.player_details_tabs do

local tab = _detalhes.player_details_tabs [index]

if (tab:condition (info.jogador, info.atributo, info.sub_atributo)) then
local tablePool = Details:GetBreakdownTabsInUse()

for index = 1, #tablePool do
local tab = tablePool[index]

if (tab:condition(info.jogador, info.atributo, info.sub_atributo) and not tab.replaced) then
--test if can show the tutorial for the comparison tab
if (tab.tabname == "Compare") then
--_detalhes:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", false)
Expand Down Expand Up @@ -4931,14 +5009,14 @@ function gump:CriaJanelaInfo()
end

if (tabsShown < 2) then
_detalhes.player_details_tabs[1]:SetPoint ("BOTTOMLEFT", info.container_barras, "TOPLEFT", 490 - (94 * (1-0)), 1)
tablePool[1]:SetPoint ("BOTTOMLEFT", info.container_barras, "TOPLEFT", 490 - (94 * (1-0)), 1)
end

--selected by default
_detalhes.player_details_tabs[1]:Click()
tablePool[1]:Click()
end

este_gump:SetScript ("OnHide", function (self)
este_gump:SetScript ("OnHide", function(self)
_detalhes:FechaJanelaInfo()
for _, tab in _ipairs (_detalhes.player_details_tabs) do
tab:Hide()
Expand All @@ -4955,15 +5033,13 @@ end

info.selectedTab = "Summary"

_detalhes.player_details_tabs = {}

function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, fillfunction, onclick, oncreate, iconSettings)
function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, fillfunction, onclick, oncreate, iconSettings, replace)
if (not tabname) then
tabname = "unnamed"
end

--create a button for the tab
local newTabButton = gump:CreateButton (info, onclick, 20, 20)
local newTabButton = gump:CreateButton (info, onclick, 20, 20, nil, nil, nil, nil, nil, "DetailsPlayerBreakdownWindowTab" .. tabname)
newTabButton:SetTemplate ("DETAILS_TAB_BUTTON_TEMPLATE")
if (tabname == "Summary") then
newTabButton:SetTemplate ("DETAILS_TAB_BUTTONSELECTED_TEMPLATE")
Expand All @@ -4985,7 +5061,7 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f
newTabButton.frame:SetFrameStrata ("HIGH")
newTabButton.frame:SetFrameLevel (info:GetFrameLevel()+5)
newTabButton.frame:EnableMouse (true)

if (iconSettings) then
local texture = iconSettings.texture
local coords = iconSettings.coords
Expand Down Expand Up @@ -5032,14 +5108,15 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f

newTabButton.frame:Hide()

newTabButton.replaces = replace
_detalhes.player_details_tabs [#_detalhes.player_details_tabs+1] = newTabButton

if (not onclick) then
--> hide all tabs
newTabButton.OnShowFunc = function (self)
self = self.MyObject or self

for _, tab in _ipairs (_detalhes.player_details_tabs) do
for _, tab in _ipairs (Details:GetBreakdownTabsInUse()) do
tab.frame:Hide()
tab:SetTemplate ("DETAILS_TAB_BUTTON_TEMPLATE")
end
Expand All @@ -5055,7 +5132,7 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f
newTabButton.OnShowFunc = function (self)
self = self.MyObject or self

for _, tab in _ipairs (_detalhes.player_details_tabs) do
for _, tab in _ipairs (Details:GetBreakdownTabsInUse()) do
tab.frame:Hide()
tab:SetTemplate ("DETAILS_TAB_BUTTON_TEMPLATE")
end
Expand Down Expand Up @@ -5088,6 +5165,7 @@ function _detalhes:CreatePlayerDetailsTab (tabname, localized_name, condition, f
end
end)

return newTabButton, newTabButton.frame
end

function _detalhes.playerDetailWindow:monta_relatorio (botao)
Expand Down
2 changes: 1 addition & 1 deletion plugins/Details_Streamer/Details_Streamer-BCC.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 20501
## Interface: 20502
## Title: Details!: Streamer (plugin)
## Notes: Show which spells you are casting, viewers can see what are you doing and follow your steps.
## RequiredDeps: Details
Expand Down
2 changes: 1 addition & 1 deletion plugins/Details_TinyThreat/Details_TinyThreat-BCC.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 20501
## Interface: 20502
## Title: Details!: Tiny Threat (plugin)
## Notes: Threat meter plugin, show threat for group members in the window. Select it from the Plugin menu in the Orange Cogwheel.
## RequiredDeps: Details
Expand Down
14 changes: 14 additions & 0 deletions plugins/Details_TinyThreat/Details_TinyThreat-Classic.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Interface: 11401
## Title: Details!: Tiny Threat (plugin)
## Notes: Threat meter plugin, show threat for group members in the window. Select it from the Plugin menu in the Orange Cogwheel.
## RequiredDeps: Details
## OptionalDeps: Ace3

#@no-lib-strip@
embeds.xml
#@end-no-lib-strip@

enUS.lua
ptBR.lua

Details_TinyThreat.lua
8 changes: 4 additions & 4 deletions plugins/Details_TinyThreat/Details_TinyThreat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,14 @@ function ThreatMeter:OnEvent (_, event, ...)

elseif (event == "ADDON_LOADED") then
local AddonName = select (1, ...)

if (AddonName == "Details_TinyThreat") then

if (_G._detalhes) then

if (DetailsFramework.IsClassicWow()) then
return
--return
end

--> create widgets
CreatePluginFrames (data)

Expand Down

0 comments on commit 7adae64

Please sign in to comment.