You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

859 lines
33 KiB

4 years ago
local Details = _G.Details
local Loc = _G.LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local SharedMedia = _G.LibStub:GetLibrary("LibSharedMedia-3.0")
local UIParent = UIParent
local gump = Details.gump
4 years ago
local _
local addonName, Details222 = ...
--remove warnings in the code
3 years ago
local ipairs = ipairs
local tinsert = tinsert
local tremove = tremove
3 years ago
local type = type
local unpack = _G.unpack
local PixelUtil = PixelUtil
local UISpecialFrames = UISpecialFrames
local wipe = wipe
local CreateFrame = _G.CreateFrame
local detailsFramework = DetailsFramework
4 years ago
local subAttributes = Details.sub_atributos
local breakdownWindow = Details.playerDetailWindow
4 years ago
local SummaryWidgets = {}
local CurrentTab = "Summary"
local PLAYER_DETAILS_WINDOW_WIDTH = 890
local PLAYER_DETAILS_WINDOW_HEIGHT = 574
local PLAYER_DETAILS_STATUSBAR_HEIGHT = 20
local PLAYER_DETAILS_STATUSBAR_ALPHA = 1
Details.player_details_tabs = {}
breakdownWindow.currentTabsInUse = {}
4 years ago
Details222.BreakdownWindow.BackdropSettings = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {DetailsFramework:GetDefaultBackdropColor()},
backdropbordercolor = {0, 0, 0, 0.7},
4 years ago
}
------------------------------------------------------------------------------------------------------------------------------
--self = instancia
--jogador = classe_damage ou classe_heal
function Details:GetBreakdownTabsInUse()
return breakdownWindow.currentTabsInUse
4 years ago
end
function Details:GetBreakdownTabByName(tabName, tablePool)
tablePool = tablePool or Details.player_details_tabs
4 years ago
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 breakdownWindow.instancia and breakdownWindow.instancia.showing
4 years ago
end
---return the window that requested to open the player breakdown window
---@return instance
4 years ago
function Details:GetActiveWindowFromBreakdownWindow()
return breakdownWindow.instancia
4 years ago
end
--return if the breakdown window is showing damage or heal
function Details:GetDisplayTypeFromBreakdownWindow()
return breakdownWindow.atributo, breakdownWindow.sub_atributo
4 years ago
end
--return the actor object in use by the breakdown window
function Details:GetActorObjectFromBreakdownWindow()
return breakdownWindow.jogador
4 years ago
end
function Details:GetBreakdownWindow()
return Details.playerDetailWindow
end
function Details:IsBreakdownWindowOpen()
return breakdownWindow.ativo
end
---open the breakdown window
---@param self details
---@param instanceObject instance
---@param actorObject actor
---@param bFromAttributeChange boolean|nil
---@param bIsRefresh boolean|nil
---@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()
4 years ago
3 years ago
--create the player list frame in the left side of the window
Details.PlayerBreakdown.CreatePlayerListFrame()
Details.PlayerBreakdown.CreateDumpDataFrame()
4 years ago
if (not Details.row_singleclick_overwrite[mainAttribute] or not Details.row_singleclick_overwrite[mainAttribute][subAttribute]) then
Details:CloseBreakdownWindow()
4 years ago
return
3 years ago
elseif (type(Details.row_singleclick_overwrite[mainAttribute][subAttribute]) == "function") then
if (bFromAttributeChange) then
Details:CloseBreakdownWindow()
4 years ago
return
end
Details.row_singleclick_overwrite[mainAttribute][subAttribute](_, actorObject, instanceObject, bIsShiftKeyDown, bIsControlKeyDown)
4 years ago
return
end
if (instanceObject:GetMode() == DETAILS_MODE_RAID) then
Details:CloseBreakdownWindow()
4 years ago
return
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 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
3 years ago
elseif (not actorObject) then
Details:CloseBreakdownWindow()
return
4 years ago
end
3 years ago
if (not breakdownWindow.bHasInitialized) then
local infoNumPoints = breakdownWindow:GetNumPoints()
for i = 1, infoNumPoints do
local point1, anchorObject, point2, x, y = breakdownWindow:GetPoint(i)
if (not anchorObject) then
breakdownWindow:ClearAllPoints()
end
end
breakdownWindow:SetUserPlaced(false)
breakdownWindow:SetDontSavePosition(true)
local okay, errorText = pcall(function()
breakdownWindow:SetPoint("center", UIParent, "center", 0, 0)
end)
if (not okay) then
breakdownWindow:ClearAllPoints()
breakdownWindow:SetPoint("center", UIParent, "center", 0, 0)
end
breakdownWindow.bHasInitialized = true
end
if (not breakdownWindow.RightSideBar) then
--breakdownWindow:CreateRightSideBar()
end
--todo: all portuguese keys to english
3 years ago
breakdownWindow.ativo = true --sinaliza o addon que a janela esta aberta
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
3 years ago
local nome = breakdownWindow.jogador.nome --nome do jogador
local atributo_nome = subAttributes[breakdownWindow.atributo].lista [breakdownWindow.sub_atributo] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"] --// nome do atributo // precisa ser o sub atributo correto???
3 years ago
--removendo o nome da realm do jogador
if (nome:find("-")) then
nome = nome:gsub(("-.*"), "")
4 years ago
end
if (breakdownWindow.instancia.atributo == 1 and breakdownWindow.instancia.sub_atributo == 6) then --enemy
atributo_nome = subAttributes [breakdownWindow.atributo].lista [1] .. " " .. Loc ["STRING_ACTORFRAME_REPORTOF"]
4 years ago
end
breakdownWindow.actorName:SetText(nome) --found it
breakdownWindow.attributeName:SetText(atributo_nome)
4 years ago
local serial = actorObject.serial
4 years ago
local avatar
if (serial ~= "") then
avatar = NickTag:GetNicknameTable (serial)
end
3 years ago
4 years ago
if (avatar and avatar [1]) then
breakdownWindow.actorName:SetText((not Details.ignore_nicktag and avatar [1]) or nome)
4 years ago
end
3 years ago
4 years ago
if (avatar and avatar [2]) then
breakdownWindow.avatar:SetTexture(avatar [2])
breakdownWindow.avatar_bg:SetTexture(avatar [4])
4 years ago
if (avatar [5]) then
breakdownWindow.avatar_bg:SetTexCoord(unpack(avatar [5]))
4 years ago
end
if (avatar [6]) then
breakdownWindow.avatar_bg:SetVertexColor(unpack(avatar [6]))
4 years ago
end
3 years ago
breakdownWindow.avatar_nick:SetText(avatar [1] or nome)
breakdownWindow.avatar_attribute:SetText(atributo_nome)
3 years ago
breakdownWindow.avatar_attribute:SetPoint("CENTER", breakdownWindow.avatar_nick, "CENTER", 0, 14)
breakdownWindow.avatar:Show()
breakdownWindow.avatar_bg:Show()
breakdownWindow.avatar_bg:SetAlpha(.65)
breakdownWindow.avatar_nick:Show()
breakdownWindow.avatar_attribute:Show()
breakdownWindow.actorName:Hide()
breakdownWindow.attributeName:Hide()
4 years ago
else
breakdownWindow.avatar:Hide()
breakdownWindow.avatar_bg:Hide()
breakdownWindow.avatar_nick:Hide()
breakdownWindow.avatar_attribute:Hide()
3 years ago
breakdownWindow.actorName:Show()
breakdownWindow.attributeName:Show()
4 years ago
end
3 years ago
breakdownWindow.attributeName:SetPoint("bottomleft", breakdownWindow.actorName, "topleft", 0, 2)
3 years ago
---@type string
local actorClass = actorObject.classe --classe not registered because it should be renamed to english 'class'
4 years ago
if (not actorClass) then
actorClass = "monster"
4 years ago
end
breakdownWindow.classIcon:SetTexture("Interface\\AddOns\\Details\\images\\classes") --top left
breakdownWindow.SetClassIcon(actorObject, actorClass)
4 years ago
Details.FadeHandler.Fader(breakdownWindow, 0)
4 years ago
Details:UpdateBreakdownPlayerList()
Details:InitializeAurasTab()
Details:InitializeCompareTab()
4 years ago
--open tab
local tabsShown = {}
local tabsReplaced = {}
local tabReplacedAmount = 0
wipe(breakdownWindow.currentTabsInUse)
4 years ago
for index = 1, #Details.player_details_tabs do
local tab = Details.player_details_tabs[index]
4 years ago
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[breakdownWindow.atributo]) then
if (attributeList[breakdownWindow.atributo][breakdownWindow.sub_atributo]) then
4 years ago
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 == breakdownWindow.selectedTab) then
breakdownWindow.selectedTab = tab.tabname
4 years ago
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
breakdownWindow.currentTabsInUse = newTabsShown
4 years ago
breakdownWindow:ShowTabs()
Details222.BreakdownWindow.CurrentDefaultTab = nil
4 years ago
local shownTab
for index = 1, #tabsShown do
local tabButton = tabsShown[index]
if (tabButton:condition(breakdownWindow.jogador, breakdownWindow.atributo, breakdownWindow.sub_atributo)) then
if (tabButton.IsDefaultTab) then
Details222.BreakdownWindow.CurrentDefaultTab = tabButton
end
if (breakdownWindow.selectedTab == tabButton.tabname) then
tabButton:DoClick()
tabButton:OnShowFunc()
shownTab = tabButton
actorObject:MontaInfo() --old api to update the breakdown window
4 years ago
end
end
end
if (shownTab) then
shownTab:Click()
end
end
3 years ago
function Details:CloseBreakdownWindow()
if (breakdownWindow.ativo) then
Details.FadeHandler.Fader(breakdownWindow, 1)
3 years ago
breakdownWindow.ativo = false --sinaliza o addon que a janela esta agora fechada
breakdownWindow.jogador = nil
breakdownWindow.atributo = nil
breakdownWindow.sub_atributo = nil
breakdownWindow.instancia = nil
3 years ago
breakdownWindow.actorName:SetText("")
breakdownWindow.attributeName:SetText("")
3 years ago
--iterate all tabs and clear caches
local tabsInUse = Details:GetBreakdownTabsInUse()
for index = 1, #tabsInUse do
local tabButton = tabsInUse[index]
tabButton.last_actor = nil
4 years ago
end
end
end
3 years ago
function Details.PlayerBreakdown.CreateDumpDataFrame()
breakdownWindow.dumpDataFrame = CreateFrame("frame", "$parentDumpTableFrame", DetailsBreakdownWindowPlayerScrollBox, "BackdropTemplate")
breakdownWindow.dumpDataFrame:SetPoint("topleft", DetailsBreakdownWindowPlayerScrollBox, "topleft", 0, 0)
breakdownWindow.dumpDataFrame:SetPoint("bottomright", DetailsBreakdownWindowPlayerScrollBox, "bottomright", 0, 0)
breakdownWindow.dumpDataFrame:SetFrameLevel(DetailsBreakdownWindowPlayerScrollBox:GetFrameLevel() + 10)
detailsFramework:ApplyStandardBackdrop(breakdownWindow.dumpDataFrame, true)
breakdownWindow.dumpDataFrame:Hide()
3 years ago
--create a details framework special lua editor
breakdownWindow.dumpDataFrame.luaEditor = detailsFramework:NewSpecialLuaEditorEntry(breakdownWindow.dumpDataFrame, 1, 1, "text", "$parentCodeEditorWindow")
breakdownWindow.dumpDataFrame.luaEditor:SetPoint("topleft", breakdownWindow.dumpDataFrame, "topleft", 2, -2)
breakdownWindow.dumpDataFrame.luaEditor:SetPoint("bottomright", breakdownWindow.dumpDataFrame, "bottomright", -2, 2)
breakdownWindow.dumpDataFrame.luaEditor:SetFrameLevel(breakdownWindow.dumpDataFrame:GetFrameLevel()+1)
breakdownWindow.dumpDataFrame.luaEditor:SetBackdrop({})
4 years ago
--hide the scroll bar
DetailsBreakdownWindowPlayerScrollBoxDumpTableFrameCodeEditorWindowScrollBar:Hide()
end
3 years ago
function breakdownWindow:CreateRightSideBar() --not enabled
breakdownWindow.RightSideBar = CreateFrame("frame", nil, breakdownWindow, "BackdropTemplate")
breakdownWindow.RightSideBar:SetWidth(20)
breakdownWindow.RightSideBar:SetPoint("topleft", breakdownWindow, "topright", 1, 0)
breakdownWindow.RightSideBar:SetPoint("bottomleft", breakdownWindow, "bottomright", 1, 0)
local rightSideBarAlpha = 0.75
3 years ago
detailsFramework:ApplyStandardBackdrop(breakdownWindow.RightSideBar)
3 years ago
local toggleMergePlayerSpells = function()
Details.merge_player_abilities = not Details.merge_player_abilities
local playerObject = Details:GetActorObjectFromBreakdownWindow()
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
Details:OpenBreakdownWindow(instanceObject, playerObject) --toggle
Details:OpenBreakdownWindow(instanceObject, playerObject)
end
3 years ago
local mergePlayerSpellsCheckbox = detailsFramework:CreateSwitch(breakdownWindow, toggleMergePlayerSpells, Details.merge_player_abilities, _, _, _, _, _, _, _, _, _, _, detailsFramework:GetTemplate("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
mergePlayerSpellsCheckbox:SetAsCheckBox()
mergePlayerSpellsCheckbox:SetPoint("bottom", breakdownWindow.RightSideBar, "bottom", 0, 2)
4 years ago
local mergePlayerSpellsLabel = breakdownWindow.RightSideBar:CreateFontString(nil, "overlay", "GameFontNormal")
mergePlayerSpellsLabel:SetText("Merge Player Spells")
detailsFramework:SetFontRotation(mergePlayerSpellsLabel, 90)
mergePlayerSpellsLabel:SetPoint("center", mergePlayerSpellsCheckbox.widget, "center", -6, mergePlayerSpellsCheckbox:GetHeight()/2 + mergePlayerSpellsLabel:GetStringWidth() / 2)
4 years ago
--
local toggleMergePetSpells = function()
Details.merge_pet_abilities = not Details.merge_pet_abilities
local playerObject = Details:GetActorObjectFromBreakdownWindow()
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
Details:OpenBreakdownWindow(instanceObject, playerObject) --toggle
Details:OpenBreakdownWindow(instanceObject, playerObject)
end
local mergePetSpellsCheckbox = detailsFramework:CreateSwitch(breakdownWindow, toggleMergePetSpells, Details.merge_pet_abilities, _, _, _, _, _, _, _, _, _, _, detailsFramework:GetTemplate("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
mergePetSpellsCheckbox:SetAsCheckBox(true)
mergePetSpellsCheckbox:SetPoint("bottom", breakdownWindow.RightSideBar, "bottom", 0, 160)
3 years ago
local mergePetSpellsLabel = breakdownWindow.RightSideBar:CreateFontString(nil, "overlay", "GameFontNormal")
mergePetSpellsLabel:SetText("Merge Pet Spells")
detailsFramework:SetFontRotation(mergePetSpellsLabel, 90)
mergePetSpellsLabel:SetPoint("center", mergePetSpellsCheckbox.widget, "center", -6, mergePetSpellsCheckbox:GetHeight()/2 + mergePetSpellsLabel:GetStringWidth() / 2)
3 years ago
mergePlayerSpellsCheckbox:SetAlpha(rightSideBarAlpha)
mergePlayerSpellsLabel:SetAlpha(rightSideBarAlpha)
mergePetSpellsCheckbox:SetAlpha(rightSideBarAlpha)
mergePetSpellsLabel:SetAlpha(rightSideBarAlpha)
end
3 years ago
---@type {[number]: boolean}
Details222.BreakdownWindow.ExpandedSpells = {}
4 years ago
---set a spell as expanded or not in the breakdown window
---@param key any
---@param bIsExpanded boolean
function Details222.BreakdownWindow.SetSpellAsExpanded(key, bIsExpanded)
Details222.BreakdownWindow.ExpandedSpells[key] = bIsExpanded
4 years ago
end
---get the state of the expanded for a spell
---@param key any
---@return boolean
function Details222.BreakdownWindow.IsSpellExpanded(key)
return Details222.BreakdownWindow.ExpandedSpells[key]
end
4 years ago
---receives spell data to show in the summary tab
---@param data breakdownspelldatalist
---@param actorObject actor
---@param combatObject combat
---@param instance instance
function Details222.BreakdownWindow.SendSpellData(data, actorObject, combatObject, instance)
--need to get the tab showing the summary and transmit the data to it
local tabButton = Details222.BreakdownWindow.CurrentDefaultTab
if (tabButton) then
--tab is the tab button
if (tabButton.OnReceiveSpellData) then
tabButton.OnReceiveSpellData(data, actorObject, combatObject, instance)
end
4 years ago
end
end
4 years ago
function Details222.BreakdownWindow.SendTargetData(targetList, actorObject, combatObject, instance)
local tabButton = Details222.BreakdownWindow.CurrentDefaultTab
if (tabButton) then
if (tabButton.OnReceiveTargetData) then
tabButton.OnReceiveTargetData(targetList, actorObject, combatObject, instance)
end
4 years ago
end
end
4 years ago
function Details222.BreakdownWindow.SendGenericData(resultTable, actorObject, combatObject, instance)
local tabButton = Details222.BreakdownWindow.CurrentDefaultTab
if (tabButton) then
if (tabButton.OnReceiveGenericData) then
tabButton.OnReceiveGenericData(resultTable, actorObject, combatObject, instance)
end
4 years ago
end
end
---set the class or spec icon for the actor displayed
---@param actorObject actor
---@param class string
function breakdownWindow.SetClassIcon(actorObject, class)
if (actorObject.spellicon) then
breakdownWindow.classIcon:SetTexture(actorObject.spellicon)
breakdownWindow.classIcon:SetTexCoord(.1, .9, .1, .9)
4 years ago
elseif (actorObject.spec) then
breakdownWindow.classIcon:SetTexture([[Interface\AddOns\Details\images\spec_icons_normal_alpha]])
breakdownWindow.classIcon:SetTexCoord(unpack(_detalhes.class_specs_coords [actorObject.spec]))
else
local coords = CLASS_ICON_TCOORDS[class]
if (coords) then
breakdownWindow.classIcon:SetTexture([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
local l, r, t, b = unpack(coords)
breakdownWindow.classIcon:SetTexCoord(l+0.01953125, r-0.01953125, t+0.01953125, b-0.01953125)
else
local c = _detalhes.class_coords ["MONSTER"]
breakdownWindow.classIcon:SetTexture("Interface\\AddOns\\Details\\images\\classes")
breakdownWindow.classIcon:SetTexCoord(c[1], c[2], c[3], c[4])
end
end
end
function Details:SetBreakdownWindowBackgroundTexture(texture)
breakdownWindow.backgroundTexture:SetTexture(texture)
4 years ago
end
--search key: ~create ~inicio ~start
function Details:CreateBreakdownWindow()
table.insert(UISpecialFrames, breakdownWindow:GetName())
breakdownWindow.extra_frames = {}
breakdownWindow.Loaded = true
Details.playerDetailWindow = breakdownWindow
breakdownWindow:SetWidth(PLAYER_DETAILS_WINDOW_WIDTH)
breakdownWindow:SetHeight(PLAYER_DETAILS_WINDOW_HEIGHT)
breakdownWindow:SetFrameStrata("HIGH")
breakdownWindow:SetToplevel(true)
breakdownWindow:EnableMouse(true)
breakdownWindow:SetResizable(true)
breakdownWindow:SetMovable(true)
breakdownWindow:SetClampedToScreen(true)
--make the window movable
if (not breakdownWindow.registeredLibWindow) then
local LibWindow = LibStub("LibWindow-1.1")
breakdownWindow.registeredLibWindow = true
if (LibWindow) then
breakdownWindow.libWindowTable = breakdownWindow.libWindowTable or {}
LibWindow.RegisterConfig(breakdownWindow, breakdownWindow.libWindowTable)
LibWindow.RestorePosition(breakdownWindow)
LibWindow.MakeDraggable(breakdownWindow)
LibWindow.SavePosition(breakdownWindow)
breakdownWindow:SetScript("OnMouseDown", function(self, button)
if (button == "RightButton") then
Details:CloseBreakdownWindow()
end
end)
4 years ago
end
end
3 years ago
detailsFramework:ApplyStandardBackdrop(breakdownWindow)
3 years ago
--background
breakdownWindow.backgroundTexture = breakdownWindow:CreateTexture("$parent", "background", nil, -3)
breakdownWindow.backgroundTexture:SetAllPoints()
breakdownWindow.backgroundTexture:Hide()
3 years ago
--host the textures and fontstring of the default frame of the player breakdown window
--what is the summary window: is the frame where all the widgets for the summary tab are created
breakdownWindow.SummaryWindowWidgets = CreateFrame("frame", "DetailsBreakdownWindowSummaryWidgets", breakdownWindow, "BackdropTemplate")
local SWW = breakdownWindow.SummaryWindowWidgets
SWW:SetAllPoints()
table.insert(SummaryWidgets, SWW) --where SummaryWidgets is declared: at the header of the file, what is the purpose of this table?
breakdownWindow.SummaryWindowWidgets:Hide()
3 years ago
detailsFramework:CreateScaleBar(breakdownWindow, Details.player_details_window)
breakdownWindow:SetScale(Details.player_details_window.scale)
3 years ago
--class icon
breakdownWindow.classIcon = breakdownWindow:CreateTexture(nil, "overlay", nil, 1)
breakdownWindow.classIcon:SetPoint("topleft", breakdownWindow, "topleft", 2, -17)
breakdownWindow.classIcon:SetSize(54, 54)
breakdownWindow.classIcon:SetAlpha(0.7)
3 years ago
--close button
breakdownWindow.closeButton = CreateFrame("Button", nil, breakdownWindow, "UIPanelCloseButton")
breakdownWindow.closeButton:SetSize(20, 20)
breakdownWindow.closeButton:SetPoint("TOPRIGHT", breakdownWindow, "TOPRIGHT", -5, -4)
breakdownWindow.closeButton:SetFrameLevel(breakdownWindow:GetFrameLevel()+5)
breakdownWindow.closeButton:GetNormalTexture():SetDesaturated(true)
breakdownWindow.closeButton:GetNormalTexture():SetVertexColor(.6, .6, .6)
breakdownWindow.closeButton:SetScript("OnClick", function(self)
Details:CloseBreakdownWindow()
end)
3 years ago
--title
detailsFramework:NewLabel(breakdownWindow, breakdownWindow, nil, "titleText", Loc ["STRING_PLAYER_DETAILS"], "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
breakdownWindow.titleText:SetPoint("center", breakdownWindow, "center")
breakdownWindow.titleText:SetPoint("top", breakdownWindow, "top", 0, -6)
3 years ago
--create the texts shown on the window
do
breakdownWindow.actorName = breakdownWindow:CreateFontString(nil, "overlay", "QuestFont_Large")
breakdownWindow.actorName:SetPoint("left", breakdownWindow.classIcon, "right", 20, -7)
3 years ago
breakdownWindow.attributeName = breakdownWindow:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
3 years ago
breakdownWindow.avatar = breakdownWindow:CreateTexture(nil, "overlay")
breakdownWindow.avatar_bg = breakdownWindow:CreateTexture(nil, "overlay")
breakdownWindow.avatar_attribute = breakdownWindow:CreateFontString(nil, "overlay", "GameFontHighlightSmall")
breakdownWindow.avatar_nick = breakdownWindow:CreateFontString(nil, "overlay", "QuestFont_Large")
breakdownWindow.avatar:SetDrawLayer("overlay", 3)
breakdownWindow.avatar_bg:SetDrawLayer("overlay", 2)
breakdownWindow.avatar_nick:SetDrawLayer("overlay", 4)
3 years ago
breakdownWindow.avatar:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 60, -10)
breakdownWindow.avatar_bg:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 60, -12)
breakdownWindow.avatar_bg:SetSize(275, 60)
breakdownWindow.avatar_nick:SetPoint("TOPLEFT", breakdownWindow, "TOPLEFT", 195, -54)
3 years ago
breakdownWindow.avatar:Hide()
breakdownWindow.avatar_bg:Hide()
breakdownWindow.avatar_nick:Hide()
end
3 years ago
--statusbar
local statusBar = CreateFrame("frame", nil, breakdownWindow, "BackdropTemplate")
statusBar:SetPoint("bottomleft", breakdownWindow, "bottomleft")
statusBar:SetPoint("bottomright", breakdownWindow, "bottomright")
statusBar:SetHeight(PLAYER_DETAILS_STATUSBAR_HEIGHT)
detailsFramework:ApplyStandardBackdrop(statusBar)
statusBar:SetAlpha(PLAYER_DETAILS_STATUSBAR_ALPHA)
breakdownWindow.statusBar = statusBar
3 years ago
statusBar.Text = detailsFramework:CreateLabel(statusBar)
statusBar.Text:SetPoint("left", 2, 0)
3 years ago
--create the gradients in the top and bottom side of the breakdown window
local gradientStartColor = Details222.ColorScheme.GetColorFor("gradient-background")
local gradientUp = detailsFramework:CreateTexture(breakdownWindow, {gradient = "vertical", fromColor = gradientStartColor, toColor = {0, 0, 0, 0.2}}, 1, 68, "artwork", {0, 1, 0, 1})
gradientUp:SetPoint("tops", 1, 1)
4 years ago
local gradientHeight = 481
local gradientDown = detailsFramework:CreateTexture(breakdownWindow, {gradient = "vertical", fromColor = "transparent", toColor = {0, 0, 0, 0.7}}, 1, gradientHeight, "border", {0, 1, 0, 1})
gradientDown:SetPoint("bottomleft", breakdownWindow.statusBar, "topleft", 1, 1)
gradientDown:SetPoint("bottomright", breakdownWindow.statusBar, "topright", -1, 1)
3 years ago
function breakdownWindow:SetStatusbarText(text, fontSize, fontColor)
if (not text) then
breakdownWindow:SetStatusbarText("Details! Damage Meter | Use '/details stats' for statistics", 10, "gray")
return
4 years ago
end
statusBar.Text.text = text
statusBar.Text.fontsize = fontSize
statusBar.Text.fontcolor = fontColor
4 years ago
end
3 years ago
--set default text
breakdownWindow:SetStatusbarText()
3 years ago
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--tabs ~tabs
function breakdownWindow:ShowTabs()
local tabsShown = 0
local secondRowIndex = 1
local breakLine = 6 --the tab it'll start the second line
local tablePool = Details:GetBreakdownTabsInUse()
for index = 1, #tablePool do
local tabButton = tablePool[index]
if (tabButton:condition(breakdownWindow.jogador, breakdownWindow.atributo, breakdownWindow.sub_atributo) and not tabButton.replaced) then
--test if can show the tutorial for the comparison tab
if (tabButton.tabname == "Compare") then
--Details:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", false)
if (not Details:GetTutorialCVar("DETAILS_INFO_TUTORIAL1")) then
Details:SetTutorialCVar ("DETAILS_INFO_TUTORIAL1", true)
local alert = CreateFrame("frame", "DetailsInfoPopUp1", breakdownWindow, "DetailsHelpBoxTemplate")
alert.ArrowUP:Show()
alert.ArrowGlowUP:Show()
alert.Text:SetText(Loc ["STRING_INFO_TUTORIAL_COMPARISON1"])
alert:SetPoint("bottom", tabButton.widget or tabButton, "top", 5, 28)
alert:Show()
end
end
3 years ago
tabButton:Show()
tabsShown = tabsShown + 1
3 years ago
tabButton:ClearAllPoints()
3 years ago
--get the button width
local buttonTemplate = gump:GetTemplate("button", "DETAILS_TAB_BUTTON_TEMPLATE")
local buttonWidth = buttonTemplate.width + 1
3 years ago
--pixelutil might not be compatible with classic wow
if (PixelUtil) then
PixelUtil.SetSize(tabButton, buttonTemplate.width, buttonTemplate.height)
if (tabsShown >= breakLine) then --next row of icons
PixelUtil.SetPoint(tabButton, "bottomright", breakdownWindow, "topright", -514 + (buttonWidth * (secondRowIndex)), -50)
secondRowIndex = secondRowIndex + 1
else
PixelUtil.SetPoint(tabButton, "bottomright", breakdownWindow, "topright", -514 + (buttonWidth * tabsShown), -69)
end
else
tabButton:SetSize(buttonTemplate.width, buttonTemplate.height)
if (tabsShown >= breakLine) then --next row of icons
tabButton:SetPoint("bottomright", breakdownWindow, "topright", -514 + (buttonWidth * (secondRowIndex)), -50)
secondRowIndex = secondRowIndex + 1
else
tabButton:SetPoint("bottomright", breakdownWindow, "topright", -514 + (buttonWidth * tabsShown), -69)
end
end
3 years ago
tabButton:SetAlpha(0.8)
else
tabButton.frame:Hide()
tabButton:Hide()
end
end
3 years ago
if (tabsShown < 2) then
tablePool[1]:SetPoint("bottomleft", breakdownWindow.container_barras, "topleft", 490 - (94 * (1-0)), 1)
end
3 years ago
--selected by default
tablePool[1]:Click()
end
breakdownWindow:SetScript("OnHide", function(self)
Details:CloseBreakdownWindow()
for _, tab in ipairs(Details.player_details_tabs) do
tab:Hide()
tab.frame:Hide()
end
end)
4 years ago
breakdownWindow.tipo = 1 --tipo da janela // 1 = janela normal
return breakdownWindow
4 years ago
end
breakdownWindow.selectedTab = "Summary"
3 years ago
function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFunc, tabOnClickFunc, onCreateFunc, iconSettings, replace, bIsDefaultTab) --~tab
if (not tabName) then
tabName = "unnamed"
end
4 years ago
--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()
3 years ago
if (tabName == "Summary") then
tabButton:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE")
end
3 years ago
tabButton.IsDefaultTab = bIsDefaultTab
tabButton.condition = conditionFunc
tabButton.tabname = tabName
tabButton.localized_name = locName
tabButton.onclick = tabOnClickFunc
tabButton.fillfunction = fillFunc
tabButton.last_actor = {} --need to double check is this getting cleared
4 years ago
---@type tabframe
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", -1, 20)
tabFrame:Hide()
3 years ago
DetailsFramework:ApplyStandardBackdrop(tabFrame)
tabFrame:SetBackdropBorderColor(0, 0, 0, 0.3)
tabFrame.__background:SetAlpha(0.3)
tabFrame.RightEdge:Hide()
4 years ago
--create the gradients in the top and bottom side of the breakdown window
local gradientStartColor = Details222.ColorScheme.GetColorFor("gradient-background")
local red, green, blue = unpack(gradientStartColor)
3 years ago
local gradientUpDown = detailsFramework:CreateTexture(tabFrame, {gradient = "vertical", fromColor = {red, green, blue, 0}, toColor = {red, green, blue, 0.4}}, 1, 34*2, "artwork", {0, 1, 0, 1})
gradientUpDown:SetPoint("topleft", tabFrame, "topleft", 0, 0)
gradientUpDown:SetPoint("topright", tabFrame, "topright", 0, 0)
3 years ago
tabButton.tabFrame = tabFrame
tabButton.frame = tabFrame
4 years ago
if (iconSettings) then
local texture = iconSettings.texture
local coords = iconSettings.coords
local width = iconSettings.width
local height = iconSettings.height
3 years ago
local overlay, textdistance, leftpadding, textheight, short_method --nil
3 years ago
tabButton:SetIcon(texture, width, height, "overlay", coords, overlay, textdistance, leftpadding, textheight, short_method)
if (iconSettings.desaturated) then
tabButton.icon:SetDesaturated(true)
end
4 years ago
end
if (tabButton.fillfunction) then
tabFrame:SetScript("OnShow", function()
---@type actor
local actorObject = Details:GetActorObjectFromBreakdownWindow()
4 years ago
if (tabButton.last_actor == actorObject) then
return
end
3 years ago
---@type instance
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
---@type combat
local combatObject = instanceObject:GetCombat()
3 years ago
tabButton.last_actor = actorObject --it's caching the actor, on pre-reset need to clean up this variable (need to check this later)
tabButton:fillfunction(actorObject, combatObject)
end)
4 years ago
end
3 years ago
if (onCreateFunc) then
onCreateFunc(tabButton, tabFrame)
end
3 years ago
tabButton.replaces = replace
Details.player_details_tabs[#Details.player_details_tabs+1] = tabButton
3 years ago
local onTabClickCallback = function(self) --self = tabButton
self = self.MyObject or self --framework button
4 years ago
for _, thisTabButton in ipairs(Details:GetBreakdownTabsInUse()) do
thisTabButton.frame:Hide()
thisTabButton:SetTemplate("DETAILS_TAB_BUTTON_TEMPLATE")
4 years ago
end
self:SetTemplate("DETAILS_TAB_BUTTONSELECTED_TEMPLATE")
breakdownWindow.selectedTab = self.tabname
4 years ago
end
3 years ago
if (not tabOnClickFunc) then
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()
4 years ago
end
tabButton:SetScript("OnClick", tabButton.OnShowFunc)
else
--custom
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)
4 years ago
--run onclick func
local result, errorText = pcall(tabOnClickFunc, tabButton, tabFrame)
if (not result) then
print("error on running tabOnClick function:", errorText)
end
4 years ago
end
tabButton:SetScript("OnClick", tabButton.OnShowFunc)
4 years ago
end
function tabButton:DoClick()
self:GetScript("OnClick")(self)
4 years ago
end
3 years ago
tabButton:SetScript("PostClick", function(self)
CurrentTab = self.tabname or self.MyObject.tabname
if (CurrentTab ~= "Summary") then
for _, widget in ipairs(SummaryWidgets) do
widget:Hide()
end
4 years ago
else
for _, widget in ipairs(SummaryWidgets) do
widget:Show()
end
4 years ago
end
end)
3 years ago
return tabButton, tabFrame
end