/keys now only show the player name, before was showing the player name and the realm name

This commit is contained in:
Tercio Jose
2023-01-02 16:02:48 -03:00
parent e98638cd83
commit 1e83cac1f2
9 changed files with 520 additions and 157 deletions
+67 -9
View File
@@ -293,7 +293,11 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--methods
--functions
---change the function which will be called when the button is pressed
---@param func function
---@param param1 any
---@param param2 any
---@param clickType string|nil
function ButtonMetaFunctions:SetClickFunction(func, param1, param2, clickType)
if (not clickType or string.find(string.lower(clickType), "left")) then
if (func) then
@@ -318,29 +322,37 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
end
end
--text
---set the text shown on the button
---@param text string
function ButtonMetaFunctions:SetText(text)
self.button.text:SetText(text)
end
--text color
---set the color of the button text
---@param ... any
function ButtonMetaFunctions:SetTextColor(...)
local red, green, blue, alpha = DF:ParseColors(...)
self.button.text:SetTextColor(red, green, blue, alpha)
end
ButtonMetaFunctions.SetFontColor = ButtonMetaFunctions.SetTextColor --alias
--text size
---set the size of the button text
---@param ... number
function ButtonMetaFunctions:SetFontSize(...)
DF:SetFontSize(self.button.text, ...)
end
--text font
---set the font into the button text
---@param font string
function ButtonMetaFunctions:SetFontFace(font)
DF:SetFontFace(self.button.text, font)
end
--textures
---comment
---@param normalTexture any
---@param highlightTexture any
---@param pressedTexture any
---@param disabledTexture any
function ButtonMetaFunctions:SetTexture(normalTexture, highlightTexture, pressedTexture, disabledTexture)
if (normalTexture) then
self.button:SetNormalTexture(normalTexture)
@@ -379,13 +391,25 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
end
end
--icon
---return the texture set into the icon with SetIcon()
---@return number|nil texture
function ButtonMetaFunctions:GetIconTexture()
if (self.icon) then
return self.icon:GetTexture()
end
end
---add an icon to the left of the button text
---@param texture any
---@param width number|nil
---@param height number|nil
---@param layout "background|border|overlay|artwork"|nil
---@param texcoord table|nil
---@param overlay any
---@param textDistance number|nil
---@param leftPadding number|nil
---@param textHeight number|nil
---@param shortMethod any
function ButtonMetaFunctions:SetIcon(texture, width, height, layout, texcoord, overlay, textDistance, leftPadding, textHeight, shortMethod)
if (not self.icon) then
self.icon = self:CreateTexture(nil, "artwork")
@@ -461,30 +485,37 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
end
end
--enabled
---query if the button is enabled or not
---@return boolean
function ButtonMetaFunctions:IsEnabled()
return self.button:IsEnabled()
end
---enable the button making it clickable and not grayed out
---@return unknown
function ButtonMetaFunctions:Enable()
return self.button:Enable()
end
---disable the button making it unclickable and grayed out
---@return unknown
function ButtonMetaFunctions:Disable()
return self.button:Disable()
end
--exec
---simulate a click on the button
function ButtonMetaFunctions:Exec()
local frameWidget = self.widget
DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":Exec()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
end
---simulate a click on the button, but this function is called with a different name
function ButtonMetaFunctions:Click()
local frameWidget = self.widget
DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":Click()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
end
---simulate a right click on the button
function ButtonMetaFunctions:RightClick()
local frameWidget = self.widget
DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2)
@@ -712,6 +743,10 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
---receives a table where the keys are settings and the values are the values to set
---this is the list of keys the table support:
---width, height, icon|table, textcolor, textsize, textfont, textalign, backdrop, backdropcolor, backdropbordercolor, onentercolor, onleavecolor, onenterbordercolor, onleavebordercolor
---@param template table
function ButtonMetaFunctions:SetTemplate(template)
if (type(template) == "string") then
template = DF:GetTemplate("button", template)
@@ -818,6 +853,21 @@ end
self:SetScript("OnEnable", onEnableFunc)
end
---create a Details Framework button
---@param parent table
---@param func function
---@param width number
---@param height number
---@param text string
---@param param1 any|nil
---@param param2 any|nil
---@param texture any|nil
---@param member string|nil
---@param name string|nil
---@param shortMethod boolean|nil
---@param buttonTemplate table|nil
---@param textTemplate table|nil
---@return table|nil
function DF:CreateButton(parent, func, width, height, text, param1, param2, texture, member, name, shortMethod, buttonTemplate, textTemplate)
return DF:NewButton(parent, parent, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate)
end
@@ -994,6 +1044,14 @@ end
return self.color_texture:GetVertexColor()
end
---create a button which opens a color picker when clicked
---@param parent table
---@param name string|nil
---@param member string|nil
---@param callback function
---@param alpha number|nil
---@param buttonTemplate table|nil
---@return table|nil
function DF:CreateColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
return DF:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
end
+208 -18
View File
@@ -57,63 +57,91 @@ if (not PixelUtil) then
end
end
---return r, g, b, a for the default backdrop color used in addons
---@return number
---@return number
---@return number
---@return number
function DF:GetDefaultBackdropColor()
return 0.1215, 0.1176, 0.1294, 0.8
end
---return if the wow version the player is playing is dragonflight or an expansion after it
---@return boolean
function DF.IsDragonflightAndBeyond()
return select(4, GetBuildInfo()) >= 100000
end
---return if the wow version the player is playing is dragonflight
---@return boolean
function DF.IsDragonflight()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 110000 and buildInfo >= 100000) then
return true
end
return false
end
---return if the wow version the player is playing is a classic version of wow
---@return boolean
function DF.IsTimewalkWoW()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 40000) then
return true
end
return false
end
---return if the wow version the player is playing is the vanilla version of wow
---@return boolean
function DF.IsClassicWow()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 20000) then
return true
end
return false
end
---return true if the player is playing in the TBC version of wow
---@return boolean
function DF.IsTBCWow()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 30000 and buildInfo >= 20000) then
return true
end
return false
end
---return true if the player is playing in the WotLK version of wow
---@return boolean
function DF.IsWotLKWow()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 40000 and buildInfo >= 30000) then
return true
end
return false
end
---return true if the player is playing in the WotLK version of wow with the retail api
---@return boolean
function DF.IsWotLKWowWithRetailAPI()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 40000 and buildInfo >= 30401) then
return true
end
return false
end
---return true if the version of wow the player is playing is the shadowlands
function DF.IsShadowlandsWow()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 100000 and buildInfo >= 90000) then
return true
end
return false
end
---for classic wow, get the role using the texture from the talents frame
local roleBySpecTextureName = {
DruidBalance = "DAMAGER",
DruidFeralCombat = "DAMAGER",
@@ -157,7 +185,8 @@ local roleBySpecTextureName = {
DeathKnightUnholy = "DAMAGER",
}
--classic, tbc and wotlk role guesser based on the weights of each talent tree
---classic, tbc and wotlk role guesser based on the weights of each talent tree
---@return string
function DF:GetRoleByClassicTalentTree()
if (not DF.IsTimewalkWoW()) then
return "NONE"
@@ -197,6 +226,9 @@ function DF:GetRoleByClassicTalentTree()
return "DAMAGER"
end
---return the role of the unit, this is safe to use for all versions of wow
---@param unitId string
---@return string
function DF.UnitGroupRolesAssigned(unitId)
if (not DF.IsTimewalkWoW()) then --Was function exist check. TBC has function, returns NONE. -Flamanis 5/16/2022
local role = UnitGroupRolesAssigned(unitId)
@@ -231,7 +263,8 @@ function DF.UnitGroupRolesAssigned(unitId)
end
end
--return the specialization of the player it self
---return the specialization of the player it self
---@return number|nil
function DF.GetSpecialization()
if (GetSpecialization) then
return GetSpecialization()
@@ -239,9 +272,11 @@ function DF.GetSpecialization()
return nil
end
function DF.GetSpecializationInfoByID(...)
---return the specialization using the specId
---@param specId unknown
function DF.GetSpecializationInfoByID(specId)
if (GetSpecializationInfoByID) then
return GetSpecializationInfoByID(...)
return GetSpecializationInfoByID(specId)
end
return nil
end
@@ -430,6 +465,10 @@ end
DF.table = {}
---find a value inside a table and return the index
---@param t table
---@param value any
---@return integer|nil
function DF.table.find(t, value)
for i = 1, #t do
if (t[i] == value) then
@@ -438,6 +477,11 @@ function DF.table.find(t, value)
end
end
---find the value inside the table, and it it's not found, add it
---@param t table
---@param index integer|any
---@param value any
---@return boolean
function DF.table.addunique(t, index, value)
if (not value) then
value = index
@@ -454,6 +498,9 @@ function DF.table.addunique(t, index, value)
return true
end
---get the table 't' and reverse the order of the values within it
---@param t table
---@return table
function DF.table.reverse(t)
local new = {}
local index = 1
@@ -464,6 +511,10 @@ function DF.table.reverse(t)
return new
end
---copy the values from table2 to table1, ignore the metatable and UIObjects
---@param t1 table
---@param t2 table
---@return table
function DF.table.duplicate(t1, t2)
for key, value in pairs(t2) do
if (key ~= "__index" and key ~= "__newindex") then
@@ -484,7 +535,10 @@ function DF.table.duplicate(t1, t2)
return t1
end
--copy from table2 to table1 overwriting values
---copy from the table 't2' to table 't1' ignoring the metatable and overwriting values, does copy UIObjects
---@param t1 table
---@param t2 table
---@return table
function DF.table.copy(t1, t2)
for key, value in pairs(t2) do
if (key ~= "__index" and key ~= "__newindex") then
@@ -499,7 +553,10 @@ function DF.table.copy(t1, t2)
return t1
end
--copy from table2 to table1 overwriting values but do not copy data that cannot be compressed
---copy from table2 to table1 overwriting values but do not copy data that cannot be compressed
---@param t1 table
---@param t2 table
---@return table
function DF.table.copytocompress(t1, t2)
for key, value in pairs(t2) do
if (key ~= "__index" and type(value) ~= "function") then
@@ -516,7 +573,10 @@ function DF.table.copytocompress(t1, t2)
return t1
end
--add the indexes of table2 into table1
---add the indexes of table2 into the end of the table table1
---@param t1 table
---@param t2 table
---@return table
function DF.table.append(t1, t2)
for i = 1, #t2 do
t1[#t1+1] = t2[i]
@@ -524,7 +584,10 @@ function DF.table.append(t1, t2)
return t1
end
--copy values that does exist on table2 but not on table1
---copy values that does exist on table2 but not on table1
---@param t1 table
---@param t2 table
---@return table
function DF.table.deploy(t1, t2)
for key, value in pairs(t2) do
if (type(value) == "table") then
@@ -537,6 +600,11 @@ function DF.table.deploy(t1, t2)
return t1
end
---get the contends of table 't' and return it as a string
---@param t table
---@param resultString string
---@param deep integer
---@return string
function DF.table.dump(t, resultString, deep)
resultString = resultString or ""
deep = deep or 0
@@ -584,7 +652,9 @@ function DF.table.dump(t, resultString, deep)
return resultString
end
--grab a text and split it into lines adding each line to a indexed table
---grab a text and split it into lines adding each line to an array table
---@param text string
---@return table
function DF:SplitTextInLines(text)
local lines = {}
local position = 1
@@ -624,6 +694,10 @@ elseif (GetLocale() == "zhTW") then
symbol_1K, symbol_10K, symbol_1B = "", "", ""
end
---get the game localization and return which symbol need to be used after formatting numbers, this is for asian languages
---@return string
---@return string
---@return string
function DF:GetAsianNumberSymbols()
if (GetLocale() == "koKR") then
return "", "", ""
@@ -640,6 +714,9 @@ function DF:GetAsianNumberSymbols()
end
if (symbol_1K) then
---if symbol_1K is valid, the game has an Asian localization, 'DF.FormatNumber' will use Asian symbols to format numbers
---@param number number
---@return string
function DF.FormatNumber(number)
if (number > 99999999) then
return format("%.2f", number/100000000) .. symbol_1B
@@ -655,7 +732,10 @@ if (symbol_1K) then
return format("%.1f", number)
end
else
function DF.FormatNumber (number)
---if symbol_1K isn't valid, 'DF.FormatNumber' will use western symbols to format numbers
---@param number number
---@return string|number
function DF.FormatNumber(number)
if (number > 999999999) then
return format("%.2f", number/1000000000) .. "B"
elseif (number > 999999) then
@@ -669,6 +749,9 @@ else
end
end
---format a number with commas
---@param value number
---@return string
function DF:CommaValue(value)
if (not value) then
return "0"
@@ -684,6 +767,9 @@ function DF:CommaValue(value)
return left .. (num:reverse():gsub('(%d%d%d)','%1,'):reverse()) .. right
end
---call the function 'callback' for each group member passing the unitID and the extra arguments
---@param callback function
---@vararg any
function DF:GroupIterator(callback, ...)
if (IsInRaid()) then
for i = 1, GetNumGroupMembers() do
@@ -701,23 +787,39 @@ function DF:GroupIterator(callback, ...)
end
end
---get an integer an format it as string with the time format 16:45
---@param value number
---@return string
function DF:IntegerToTimer(value) --~formattime
return "" .. floor(value/60) .. ":" .. format("%02.f", value%60)
end
---remove the realm name from a name
---@param name string
---@return string
function DF:RemoveRealmName(name)
return name:gsub(("%-.*"), "")
end
---remove the realm name from a name
---@param name string
---@return string
function DF:RemoveRealName(name)
return name:gsub(("%-.*"), "")
end
---get the UIObject of type 'FontString' named fontString and set the font size to the maximum value of the arguments
---@param fontString FontString
---@vararg number
function DF:SetFontSize(fontString, ...)
local font, _, flags = fontString:GetFont()
fontString:SetFont(font, max(...), flags)
end
---get the UIObject of type 'FontString' named fontString and set the font to the argument fontface
---@param fontString FontString
---@param fontface string
---@return nil
function DF:SetFontFace(fontString, fontface)
local font = SharedMedia:Fetch("font", fontface, true)
if (font) then
@@ -727,11 +829,28 @@ function DF:SetFontFace(fontString, fontface)
local _, size, flags = fontString:GetFont()
fontString:SetFont(fontface, size, flags)
end
---get the FontString passed and set the font color
---@param fontString FontString
---@param r any
---@param g number|nil
---@param b number|nil
---@param a number|nil
---@return nil
function DF:SetFontColor(fontString, r, g, b, a)
r, g, b, a = DF:ParseColors(r, g, b, a)
fontString:SetTextColor(r, g, b, a)
end
---get the FontString passed and set the font shadow color and offset
---@param fontString FontString
---@param r number
---@param g number
---@param b number
---@param a number
---@param x number
---@param y number
---@return nil
function DF:SetFontShadow(fontString, r, g, b, a, x, y)
r, g, b, a = DF:ParseColors(r, g, b, a)
fontString:SetShadowColor(r, g, b, a)
@@ -743,6 +862,10 @@ function DF:SetFontShadow(fontString, r, g, b, a, x, y)
fontString:SetShadowOffset(x, y)
end
---get the FontString object passed and set the rotation of the text shown
---@param fontString FontString
---@param degrees number
---@return nil
function DF:SetFontRotation(fontString, degrees)
if (type(degrees) == "number") then
if (not fontString.__rotationAnimation) then
@@ -757,6 +880,10 @@ function DF:SetFontRotation(fontString, degrees)
end
end
---receives a string and a color and return the string wrapped with the color using |c and |r scape codes
---@param text string
---@param color any
---@return string
function DF:AddColorToText(text, color) --wrap text with a color
local r, g, b = DF:ParseColors(color)
if (not r) then
@@ -770,6 +897,10 @@ function DF:AddColorToText(text, color) --wrap text with a color
return text
end
---receives a string 'text' and a class name and return the string wrapped with the class color using |c and |r scape codes
---@param text string
---@param className string
---@return string
function DF:AddClassColorToText(text, className)
if (type(className) ~= "string") then
return DF:RemoveRealName(text)
@@ -788,19 +919,33 @@ function DF:AddClassColorToText(text, className)
return text
end
---create a string with the spell icon and the spell name using |T|t scape codes to add the icon inside the string
---@param spellId any
---@return string
function DF:MakeStringFromSpellId(spellId)
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
return "|T" .. spellIcon .. ":16:16:0:0:64:64:4:60:4:60|t " .. spellName
end
return ""
end
---returns the class icon texture coordinates and texture file path
---@param class string
---@return number, number, number, number, string
function DF:GetClassTCoordsAndTexture(class)
local l, r, t, b = unpack(CLASS_ICON_TCOORDS[class])
return l, r, t, b, [[Interface\WORLDSTATEFRAME\Icons-Classes]]
end
function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
---wrap 'text' with the class icon of 'playerName' using |T|t scape codes
---@param text string
---@param playerName string
---@param englishClassName string this is the english class name, not the localized one, english class name is upper case
---@param useSpec boolean|nil
---@param iconSize number|nil
---@return string
function DF:AddClassIconToText(text, playerName, englishClassName, useSpec, iconSize)
local size = iconSize or 16
local spec
@@ -825,9 +970,10 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
end
end
if (class) then
if (englishClassName) then
local classString = ""
local L, R, T, B = unpack(Details.class_coords[class])
--Details.class_coords uses english class names as keys and the values are tables containing texture coordinates
local L, R, T, B = unpack(Details.class_coords[englishClassName])
if (L) then
local imageSize = 128
classString = "|TInterface\\AddOns\\Details\\images\\classes_small:" .. size .. ":" .. size .. ":0:0:" .. imageSize .. ":" .. imageSize .. ":" .. (L * imageSize) .. ":" .. (R * imageSize) .. ":" .. (T * imageSize) .. ":" .. (B * imageSize) .. "|t"
@@ -838,11 +984,17 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
return text
end
---return the size of a fontstring
---@param fontString table
---@return number
function DF:GetFontSize(fontString)
local _, size = fontString:GetFont()
return size
end
---return the font of a fontstring
---@param fontString table
---@return string
function DF:GetFontFace(fontString)
local fontface = fontString:GetFont()
return fontface
@@ -855,6 +1007,9 @@ local ValidOutlines = {
["THICKOUTLINE"] = true,
}
---set the outline of a fontstring, outline is a black border around the text, can be "NONE", "MONOCHROME", "OUTLINE" or "THICKOUTLINE"
---@param fontString table
---@param outline any
function DF:SetFontOutline(fontString, outline)
local font, fontSize = fontString:GetFont()
if (outline) then
@@ -882,6 +1037,9 @@ function DF:SetFontOutline(fontString, outline)
fontString:SetFont(font, fontSize, outline)
end
---remove spaces from the start and end of the string
---@param string string
---@return string
function DF:Trim(string)
return DF:trim(string)
end
@@ -947,7 +1105,10 @@ function DF:CleanTruncateUTF8String(text)
return text
end
--DF:TruncateNumber(number, fractionDigits): truncate the amount of numbers used to show fraction.
---truncate the amount of numbers used to show the fraction part of a number
---@param number number
---@param fractionDigits number
---@return number
function DF:TruncateNumber(number, fractionDigits)
fractionDigits = fractionDigits or 2
local truncatedNumber = number
@@ -964,10 +1125,14 @@ function DF:TruncateNumber(number, fractionDigits)
return truncatedNumber
end
---attempt to get the ID of an npc from a GUID
---@param GUID string
---@return number
function DF:GetNpcIdFromGuid(GUID)
local npcId = select(6, strsplit("-", GUID ))
if (npcId) then
return tonumber(npcId)
npcId = tonumber(npcId)
return npcId or 0
end
return 0
end
@@ -1257,7 +1422,17 @@ end
IsColorTable = true,
}
--convert a any format of color to any other format of color
---convert a any format of color to any other format of color
---@param newFormat string
---@param r number|string
---@param g number|nil
---@param b number|nil
---@param a number|nil
---@param decimalsAmount number|nil
---@return string|table|number|nil
---@return number|nil
---@return number|nil
---@return number|nil
function DF:FormatColor(newFormat, r, g, b, a, decimalsAmount)
a = a or 1
r, g, b, a = DF:ParseColors(r, g, b, a)
@@ -1299,10 +1474,24 @@ end
return t
end
function DF:IsHtmlColor(color)
return DF.alias_text_colors[color]
---return true if DF.alias_text_colors has the colorName as a key
---DF.alias_text_colors is a table where key is a color name and value is an indexed table with the r g b values
---@param colorName any
---@return unknown
function DF:IsHtmlColor(colorName)
return DF.alias_text_colors[colorName]
end
---get the values passed and return r g b a color values
---the function accept color name, tables with r g b a members, indexed tables with r g b a values, numbers, html hex color
---@param red any
---@param green any
---@param blue any
---@param alpha any
---@return number
---@return number
---@return number
---@return number
function DF:ParseColors(red, green, blue, alpha)
local firstParameter = red
@@ -1365,6 +1554,7 @@ end
alpha = 1
end
--saturate the values before returning to make sure they are on the 0 to 1 range
return Saturate(red), Saturate(green), Saturate(blue), Saturate(alpha)
end
+69 -7
View File
@@ -343,6 +343,9 @@ detailsFramework.PayloadMixin = {
end,
}
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.ScriptHookMixin)
---
---@class DetailsFramework.ScriptHookMixin
detailsFramework.ScriptHookMixin = {
RunHooksForWidget = function(self, event, ...)
local hooks = self.HookList[event]
@@ -412,7 +415,13 @@ detailsFramework.ScriptHookMixin = {
end,
}
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.SortFunctions)
---add methods to be used on scrollframes
---@class DetailsFramework.ScrollBoxFunctions
detailsFramework.ScrollBoxFunctions = {
---refresh the scrollbox by resetting all lines created with :CreateLine(), then calling the refresh_func which was set at :CreateScrollBox()
---@param self table
---@return table
Refresh = function(self)
--hide all frames and tag as not in use
self._LinesInUse = 0
@@ -427,8 +436,10 @@ detailsFramework.ScrollBoxFunctions = {
offset = self:GetOffsetFaux()
end
--call the refresh function
detailsFramework:CoreDispatch((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
--hide all frames that are not in use
for index, frame in ipairs(self.Frames) do
if (not frame._InUse) then
frame:Hide()
@@ -468,10 +479,15 @@ detailsFramework.ScrollBoxFunctions = {
return true
end,
---create a line within the scrollbox
---@param self table is the scrollbox
---@param func function|nil function to create the line object, this function will receive the line index as argument and return a table with the line object
---@return table line object (table)
CreateLine = function(self, func)
if (not func) then
func = self.CreateLineFunc
end
local okay, newLine = pcall(func, self, #self.Frames+1)
if (okay) then
if (not newLine) then
@@ -676,18 +692,31 @@ local SortByMemberReverse = function(t1, t2)
return t1[SortMember] < t2[SortMember]
end
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.SortFunctions)
---adds the method Sort() to a table, this method can be used to sort another table by a member, can't sort itself
---@class DetailsFramework.SortFunctions
detailsFramework.SortFunctions = {
Sort = function(self, thisTable, memberName, isReverse)
SortMember = memberName
if (not isReverse) then
table.sort(thisTable, SortByMember)
---sort a table by a member
---@param self table
---@param tThisTable table
---@param sMemberName string
---@param bIsReverse boolean
Sort = function(self, tThisTable, sMemberName, bIsReverse)
SortMember = sMemberName
if (not bIsReverse) then
table.sort(tThisTable, SortByMember)
else
table.sort(thisTable, SortByMemberReverse)
table.sort(tThisTable, SortByMemberReverse)
end
end
}
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.DataMixin)
---add 'data' to a table, this table can be used to store data for the object
---@class DetailsFramework.DataMixin
detailsFramework.DataMixin = {
---initialize the data table
---@param self table
DataConstructor = function(self)
self._dataInfo = {
data = {},
@@ -696,18 +725,28 @@ detailsFramework.DataMixin = {
}
end,
---when data is changed, functions registered with this function will be called
---@param self table
---@param func function
---@param ... unknown
AddDataChangeCallback = function(self, func, ...)
assert(type(func) == "function", "invalid function for AddDataChangeCallback.")
local allCallbacks = self._dataInfo.callbacks
allCallbacks[func] = {...}
end,
---remove a previous registered callback function
---@param self table
---@param func function
RemoveDataChangeCallback = function(self, func)
assert(type(func) == "function", "invalid function for RemoveDataChangeCallback.")
local allCallbacks = self._dataInfo.callbacks
allCallbacks[func] = nil
end,
---set the data table
---@param self table
---@param data table
SetData = function(self, data)
assert(type(data) == "table", "invalid table for SetData.")
self._dataInfo.data = data
@@ -719,10 +758,15 @@ detailsFramework.DataMixin = {
end
end,
---get the data table
---@param self table
GetData = function(self)
return self._dataInfo.data
end,
---get the next value from the data table
---@param self table
---@return any
GetDataNextValue = function(self)
local currentValue = self._dataInfo.dataCurrentIndex
local value = self:GetData()[currentValue]
@@ -730,24 +774,36 @@ detailsFramework.DataMixin = {
return value
end,
---reset the data index, making GetDataNextValue() return the first value again
ResetDataIndex = function(self)
self._dataInfo.dataCurrentIndex = 1
end,
---get the size of the data table
---@param self table
---@return number
GetDataSize = function(self)
return #self:GetData()
end,
---get the first value from the data table
---@param self table
---@return any
GetDataFirstValue = function(self)
return self:GetData()[1]
end,
---get the last value from the data table
---@param self table
---@return any
GetDataLastValue = function(self)
local data = self:GetData()
return data[#data]
end,
--if the value stored is number, return the min and max values
---get the min and max values from the data table, if the value stored is number, return the min and max values
---@param self table
---@return number, number
GetDataMinMaxValues = function(self)
local minDataValue = 0
local maxDataValue = 0
@@ -766,7 +822,10 @@ detailsFramework.DataMixin = {
return minDataValue, maxDataValue
end,
--when data uses sub tables, get the min max values from a specific index or key
---when data uses sub tables, get the min max values from a specific index or key, if the value stored is number, return the min and max values
---@param self table
---@param key string
---@return number, number
GetDataMinMaxValueFromSubTable = function(self, key)
local minDataValue = 0
local maxDataValue = 0
@@ -786,6 +845,9 @@ detailsFramework.DataMixin = {
end,
}
---mixin to use with DetailsFramework:Mixin(table, detailsFramework.ValueMixin)
---add support to min value and max value into a table or object
---@class DetailsFramework.ValueMixin
detailsFramework.ValueMixin = {
ValueConstructor = function(self)
self.minValue = 0
+45 -30
View File
@@ -3780,62 +3780,77 @@ local simple_list_box_SetData = function(self, t)
self.list_table = t
end
function detailsFramework:CreateSimpleListBox (parent, name, title, empty_text, list_table, onclick, options)
local f = CreateFrame("frame", name, parent, "BackdropTemplate")
function detailsFramework:CreateSimpleListBox(parent, name, title, emptyText, listTable, onClick, options)
local scroll = CreateFrame("frame", name, parent, "BackdropTemplate")
f.ResetWidgets = simple_list_box_ResetWidgets
f.GetOrCreateWidget = simple_list_box_GetOrCreateWidget
f.Refresh = simple_list_box_RefreshWidgets
f.SetData = simple_list_box_SetData
f.nextWidget = 1
f.list_table = list_table
f.func = function(self, button, value)
--onclick (value)
detailsFramework:QuickDispatch(onclick, value)
f:Refresh()
scroll.ResetWidgets = simple_list_box_ResetWidgets
scroll.GetOrCreateWidget = simple_list_box_GetOrCreateWidget
scroll.Refresh = simple_list_box_RefreshWidgets
scroll.SetData = simple_list_box_SetData
scroll.nextWidget = 1
scroll.list_table = listTable
scroll.func = function(self, button, value)
detailsFramework:QuickDispatch(onClick, value)
scroll:Refresh()
end
f.widgets = {}
scroll.widgets = {}
detailsFramework:ApplyStandardBackdrop(f)
detailsFramework:ApplyStandardBackdrop(scroll)
f.options = options or {}
self.table.deploy(f.options, default_options)
scroll.options = options or {}
self.table.deploy(scroll.options, default_options)
if (f.options.x_button_func) then
local original_X_function = f.options.x_button_func
f.options.x_button_func = function(self, button, value)
if (scroll.options.x_button_func) then
local original_X_function = scroll.options.x_button_func
scroll.options.x_button_func = function(self, button, value)
detailsFramework:QuickDispatch(original_X_function, value)
f:Refresh()
scroll:Refresh()
end
end
f:SetBackdropBorderColor(unpack(f.options.panel_border_color))
scroll:SetBackdropBorderColor(unpack(scroll.options.panel_border_color))
f:SetSize(f.options.width + 2, f.options.height)
scroll:SetSize(scroll.options.width + 2, scroll.options.height)
local name = detailsFramework:CreateLabel(f, title, 12, "silver")
local name = detailsFramework:CreateLabel(scroll, title, 12, "silver")
name:SetTemplate(detailsFramework:GetTemplate("font", "OPTIONS_FONT_TEMPLATE"))
name:SetPoint("bottomleft", f, "topleft", 0, 2)
f.Title = name
name:SetPoint("bottomleft", scroll, "topleft", 0, 2)
scroll.Title = name
local emptyLabel = detailsFramework:CreateLabel(f, empty_text, 12, "gray")
local emptyLabel = detailsFramework:CreateLabel(scroll, emptyText, 12, "gray")
emptyLabel:SetAlpha(.6)
emptyLabel:SetSize(f.options.width-10, f.options.height)
emptyLabel:SetSize(scroll.options.width-10, scroll.options.height)
emptyLabel:SetPoint("center", 0, 0)
emptyLabel:Hide()
emptyLabel.align = "center"
f.EmptyLabel = emptyLabel
scroll.EmptyLabel = emptyLabel
return f
return scroll
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ~scrollbox
function detailsFramework:CreateScrollBox (parent, name, refreshFunc, data, width, height, lineAmount, lineHeight, createLineFunc, autoAmount, noScroll)
---create a scrollbox with the methods :Refresh() :SetData() :CreateLine()
---@param parent table
---@param name string
---@param refreshFunc function
---@param data table
---@param width number
---@param height number
---@param lineAmount number
---@param lineHeight number
---@param createLineFunc function|nil
---@param autoAmount boolean|nil
---@param noScroll boolean|nil
---@return table
function detailsFramework:CreateScrollBox(parent, name, refreshFunc, data, width, height, lineAmount, lineHeight, createLineFunc, autoAmount, noScroll)
--create the scrollframe, it is the base of the scrollbox
local scroll = CreateFrame("scrollframe", name, parent, "FauxScrollFrameTemplate, BackdropTemplate")
--apply the standard background color
detailsFramework:ApplyStandardBackdrop(scroll)
scroll:SetSize(width, height)
+11 -1
View File
@@ -172,15 +172,21 @@ function Details:ContainerSort (container, amount, keyName2) --[[exported]]
end
end
---return true if the actor is or was in the player group
---@param self table
---@return boolean|nil
function Details:IsGroupPlayer() --[[exported]]
return self.grupo
end
---return true if the player is a pet or guardian
---@return boolean
function Details:IsPetOrGuardian() --[[exported]]
return self.owner and true or false
end
---return true if the actor is a player
---@return boolean
function Details:IsPlayer() --[[exported]]
if (self.flag_original) then
if (bitBand(self.flag_original, OBJECT_TYPE_PLAYER) ~= 0) then
@@ -190,6 +196,8 @@ function Details:IsPlayer() --[[exported]]
return false
end
---return true if the actor is an enemy of neutral npc
---@return boolean
function Details:IsNeutralOrEnemy() --[[exported]]
if (self.flag_original) then
if (bitBand(self.flag_original, 0x00000060) ~= 0) then
@@ -203,6 +211,8 @@ function Details:IsNeutralOrEnemy() --[[exported]]
return false
end
---return true if the actor is a friendly npc
---@return boolean
function Details:IsFriendlyNpc() --[[exported]]
local flag = self.flag_original
if (flag) then
+69 -45
View File
@@ -36,8 +36,8 @@
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local combatente = _detalhes.combatente
local container_combatentes = _detalhes.container_combatentes
local actorContainer = _detalhes.container_combatentes
local alvo_da_habilidade = _detalhes.alvo_da_habilidade
local atributo_damage = _detalhes.atributo_damage
local atributo_heal = _detalhes.atributo_heal
@@ -103,8 +103,12 @@
["None"] = 0,
--]=]
--attempt to get the owner of rogue's Akaari's Soul from Secrect Technique
function Details222.Pets.AkaarisSoulOwner(petGUID, petName)
---attempt to get the owner of rogue's Akaari's Soul from Secrect Technique
---@param petGUID string
---@return string|any
---@return string|any
---@return number|any
function Details222.Pets.AkaarisSoulOwner(petGUID)
local tooltipData = C_TooltipInfo.GetHyperlink("unit:" .. petGUID)
local args = tooltipData.args
@@ -232,79 +236,94 @@ end
end
end
function container_combatentes:GetActor(actorName)
---return the actor object for a given actor name
---@param actorName string
---@return table|nil
function actorContainer:GetActor(actorName)
local index = self._NameIndexTable [actorName]
if (index) then
return self._ActorTable [index]
end
end
function container_combatentes:GetSpellSource (spellid)
---return an actor name which used the spell passed 'spellId'
---@param spellId number
---@return string|nil
function actorContainer:GetSpellSource(spellId)
local t = self._ActorTable
--print("getting the source", spellid, #t)
for i = 1, #t do
if (t[i].spells._ActorTable [spellid]) then
if (t[i].spells._ActorTable[spellId]) then
return t[i].nome
end
end
end
function container_combatentes:GetAmount (actorName, key)
---return the value stored in the 'key' for an actor, the key can be any value stored in the actor table such like 'total', 'damage_taken', 'heal', 'interrupt', etc
---@param actorName string
---@param key string
---@return number
function actorContainer:GetAmount(actorName, key)
key = key or "total"
local index = self._NameIndexTable [actorName]
local index = self._NameIndexTable[actorName]
if (index) then
return self._ActorTable [index] [key] or 0
return self._ActorTable[index][key] or 0
else
return 0
end
end
function container_combatentes:GetTotal (key)
---return the total value stored in the 'key' for all actors, the key can be any value stored in the actor table such like 'total', 'damage_taken', 'heal', 'interrupt', etc
---@param key string
---@return number
function actorContainer:GetTotal(key)
local total = 0
key = key or "total"
for _, actor in ipairs(self._ActorTable) do
total = total + (actor [key] or 0)
total = total + (actor[key] or 0)
end
return total
end
function container_combatentes:GetTotalOnRaid (key, combat)
function actorContainer:GetTotalOnRaid(key, combat)
local total = 0
key = key or "total"
local roster = combat.raid_roster
for _, actor in ipairs(self._ActorTable) do
if (roster [actor.nome]) then
total = total + (actor [key] or 0)
total = total + (actor[key] or 0)
end
end
return total
end
function container_combatentes:ListActors()
---return an ipairs iterator for all actors stored in this Container
---usage: for index, actorObject in container:ListActors() do
---@return function
function actorContainer:ListActors()
return ipairs(self._ActorTable)
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--internals
--build a new actor container
function container_combatentes:NovoContainer (tipo_do_container, combat_table, combat_id)
local _newContainer = {
funcao_de_criacao = container_combatentes:FuncaoDeCriacao (tipo_do_container),
tipo = tipo_do_container,
combatId = combat_id,
---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
---actors can be retrieved using the same function above
---@param containerType number
---@param combatObject table
---@param combatId number
---@return table
function actorContainer:NovoContainer(containerType, combatObject, combatId)
local newContainer = {
funcao_de_criacao = actorContainer:FuncaoDeCriacao(containerType),
tipo = containerType,
combatId = combatId,
_ActorTable = {},
_NameIndexTable = {}
}
setmetatable(_newContainer, container_combatentes)
return _newContainer
setmetatable(newContainer, actorContainer)
return newContainer
end
--try to get the actor class from name
@@ -709,12 +728,17 @@ end
end
end
--english alias
function container_combatentes:GetOrCreateActor (serial, nome, flag, criar)
return self:PegarCombatente (serial, nome, flag, criar)
---get an actor from the container, if the actor doesn't exists, and the bShouldCreate is true, create a new actor
---@param serial string
---@param actorName string
---@param actorFlags number
---@param bShouldCreate boolean
---@return table
function actorContainer:GetOrCreateActor (serial, actorName, actorFlags, bShouldCreate)
return self:PegarCombatente(serial, actorName, actorFlags, criar)
end
function container_combatentes:PegarCombatente (serial, nome, flag, criar)
function actorContainer:PegarCombatente (serial, nome, flag, criar)
--[[statistics]]-- _detalhes.statistics.container_calls = _detalhes.statistics.container_calls + 1
--if (flag and nome:find("Kastfall") and bit.band(flag, 0x2000) ~= 0) then
@@ -986,7 +1010,7 @@ end
table.wipe(petBlackList)
end
function container_combatentes:FuncaoDeCriacao (tipo)
function actorContainer:FuncaoDeCriacao (tipo)
if (tipo == container_damage_target) then
return alvo_da_habilidade.NovaTabela
@@ -1018,7 +1042,7 @@ end
end
--chama a funo para ser executada em todos os atores
function container_combatentes:ActorCallFunction (funcao, ...)
function actorContainer:ActorCallFunction (funcao, ...)
for index, actor in ipairs(self._ActorTable) do
funcao (nil, actor, ...)
end
@@ -1029,18 +1053,18 @@ end
return (t1 [bykey] or 0) > (t2 [bykey] or 0)
end
function container_combatentes:SortByKey (key)
function actorContainer:SortByKey (key)
assert(type(key) == "string", "Container:SortByKey() expects a keyname on parameter 1.")
bykey = key
_table_sort (self._ActorTable, sort)
self:remapear()
end
function container_combatentes:Remap()
function actorContainer:Remap()
return self:remapear()
end
function container_combatentes:remapear()
function actorContainer:remapear()
local mapa = self._NameIndexTable
local conteudo = self._ActorTable
for i = 1, #conteudo do
@@ -1052,7 +1076,7 @@ end
--reconstri meta e indexes
setmetatable(container, _detalhes.container_combatentes)
container.__index = _detalhes.container_combatentes
container.funcao_de_criacao = container_combatentes:FuncaoDeCriacao (container.tipo)
container.funcao_de_criacao = actorContainer:FuncaoDeCriacao (container.tipo)
--repara mapa
local mapa = {}
+30 -28
View File
@@ -11,56 +11,58 @@ local addonName, Details222 = ...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local container_playernpc = _detalhes.container_type.CONTAINER_PLAYERNPC
local container_damage = _detalhes.container_type.CONTAINER_DAMAGE_CLASS
local container_heal = _detalhes.container_type.CONTAINER_HEAL_CLASS
local container_heal_target = _detalhes.container_type.CONTAINER_HEALTARGET_CLASS
local container_friendlyfire = _detalhes.container_type.CONTAINER_FRIENDLYFIRE
local container_damage_target = _detalhes.container_type.CONTAINER_DAMAGETARGET_CLASS
local container_energy = _detalhes.container_type.CONTAINER_ENERGY_CLASS
local container_energy_target = _detalhes.container_type.CONTAINER_ENERGYTARGET_CLASS
local container_misc = _detalhes.container_type.CONTAINER_MISC_CLASS
local container_misc_target = _detalhes.container_type.CONTAINER_MISCTARGET_CLASS
local habilidade_dano = _detalhes.habilidade_dano
local habilidade_cura = _detalhes.habilidade_cura
local habilidade_e_energy = _detalhes.habilidade_e_energy
local habilidade_misc = _detalhes.habilidade_misc
local container_habilidades = _detalhes.container_habilidades
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--internals
function container_habilidades:NovoContainer (tipo_do_container)
local _newContainer = {
funcao_de_criacao = container_habilidades:FuncaoDeCriacao (tipo_do_container),
tipo = tipo_do_container,
_ActorTable = {}
}
setmetatable(_newContainer, container_habilidades)
return _newContainer
end
function container_habilidades:GetSpell (id)
return self._ActorTable [id]
---get the spellTable for the passed spellId
---@param spellId number
---@return table
function container_habilidades:GetSpell (spellId)
return self._ActorTable[spellId]
end
function container_habilidades:GetAmount (id, key)
local spell = self._ActorTable [id]
---return the value of the spellTable[key] for the passed spellId
---@param spellId number
---@param key string
---@return any
function container_habilidades:GetAmount(spellId, key)
local spell = self._ActorTable[spellId]
if (spell) then
return spell [key]
return spell[key]
end
end
---return an iterator for all spellTables in this container
---@return fun(table: table<<K>, <V>>, index?: <K>):<K>, <V>
function container_habilidades:ListActors()
return pairs(self._ActorTable)
end
function container_habilidades:ListActors()
--same as the function above, just an alias
function container_habilidades:ListSpells()
return pairs(self._ActorTable)
end
@@ -69,18 +71,18 @@ local addonName, Details222 = ...
end
function container_habilidades:PegaHabilidade (id, criar, token)
local esta_habilidade = self._ActorTable [id]
if (esta_habilidade) then
return esta_habilidade
else
if (criar) then
local novo_objeto = self.funcao_de_criacao (nil, id, nil, token)
self._ActorTable [id] = novo_objeto
return novo_objeto
else
return nil
@@ -91,16 +93,16 @@ local addonName, Details222 = ...
function container_habilidades:FuncaoDeCriacao (tipo)
if (tipo == container_damage) then
return habilidade_dano.NovaTabela
elseif (tipo == container_heal) then
return habilidade_cura.NovaTabela
elseif (tipo == container_energy) then
return habilidade_e_energy.NovaTabela
elseif (tipo == container_misc) then
return habilidade_misc.NovaTabela
end
end
+18 -18
View File
@@ -6707,36 +6707,36 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--details api functions
--number of combat
function _detalhes:GetCombatId()
return _detalhes.combat_id
function Details:GetCombatId()
return Details.combat_id
end
--if in combat
function _detalhes:IsInCombat()
function Details:IsInCombat()
return _in_combat
end
function _detalhes:IsInEncounter()
return _detalhes.encounter_table.id and true or false
function Details:IsInEncounter()
return Details.encounter_table.id and true or false
end
--get combat
function _detalhes:GetCombat(combat)
function Details:GetCombat(combat)
if (not combat) then
return _current_combat
elseif (type(combat) == "number") then
if (combat == -1) then --overall
return _detalhes.tabela_overall
return Details.tabela_overall
elseif (combat == 0) then --current
return _current_combat
else
return _detalhes.tabela_historico.tabelas [combat]
return Details.tabela_historico.tabelas [combat]
end
elseif (type(combat) == "string") then
if (combat == "overall") then
return _detalhes.tabela_overall
return Details.tabela_overall
elseif (combat == "current") then
return _current_combat
end
@@ -6745,17 +6745,17 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
return nil
end
function _detalhes:GetAllActors(_combat, _actorname)
return _detalhes:GetActor(_combat, 1, _actorname), _detalhes:GetActor(_combat, 2, _actorname), _detalhes:GetActor(_combat, 3, _actorname), _detalhes:GetActor(_combat, 4, _actorname)
function Details:GetAllActors(_combat, _actorname)
return Details:GetActor(_combat, 1, _actorname), Details:GetActor(_combat, 2, _actorname), Details:GetActor(_combat, 3, _actorname), Details:GetActor(_combat, 4, _actorname)
end
--get player
function _detalhes:GetPlayer(_actorname, _combat, _attribute)
return _detalhes:GetActor(_combat, _attribute, _actorname)
function Details:GetPlayer(_actorname, _combat, _attribute)
return Details:GetActor(_combat, _attribute, _actorname)
end
--get an actor
function _detalhes:GetActor(combat, attribute, actorName)
function Details:GetActor(combat, attribute, actorName)
if (not combat) then
combat = "current" --current combat
end
@@ -6765,11 +6765,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
if (not actorName) then
actorName = _detalhes.playername
actorName = Details.playername
end
if (combat == 0 or combat == "current") then
local actor = _detalhes.tabela_vigente(attribute, actorName)
local actor = Details.tabela_vigente(attribute, actorName)
if (actor) then
return actor
else
@@ -6777,7 +6777,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
elseif (combat == -1 or combat == "overall") then
local actor = _detalhes.tabela_overall(attribute, actorName)
local actor = Details.tabela_overall(attribute, actorName)
if (actor) then
return actor
else
@@ -6785,7 +6785,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
elseif (type(combat) == "number") then
local combatTables = _detalhes.tabela_historico.tabelas[combat]
local combatTables = Details.tabela_historico.tabelas[combat]
if (combatTables) then
local actor = combatTables(attribute, actorName)
if (actor) then
+3 -1
View File
@@ -2152,7 +2152,9 @@ if (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) then
local L, R, T, B = unpack(iconTexCoords)
line.icon:SetTexCoord(L+0.02, R-0.02, T+0.02, B-0.02)
line.playerNameText.text = unitName
--remove the realm name from the player name (if any)
local unitNameNoRealm = DetailsFramework:RemoveRealmName(unitName)
line.playerNameText.text = unitNameNoRealm
line.keystoneLevelText.text = level
line.dungeonNameText.text = mapName
DetailsFramework:TruncateText(line.dungeonNameText, 240)