Framework update

This commit is contained in:
Tercio Jose
2023-08-25 11:16:09 -03:00
parent 4ae7c24268
commit 5cef044c5c
10 changed files with 574 additions and 162 deletions
+34 -2
View File
@@ -1,8 +1,24 @@
---@class df_table_functions
---@field find fun(tbl:table, value:any) : number? find the index of a value in a array
---@field addunique fun(tbl:table, value:any) : boolean add a value to an array if it doesn't exist yet
---@field reverse fun(tbl:table) reverse the order of an array
---@field append fun(tbl1:table, tbl2:table) append the array of table2 to table1
---@field duplicate fun(tblReceiving:table, tblGiving:table) copy the values from table2 to table1 overwriting existing values, ignores __index and __newindex, keys pointing to a UIObject are preserved
---@field copy fun(tblReceiving:table, tblGiving:table) copy the values from table2 to table1 overwriting existing values, ignores __index and __newindex, threat UIObjects as regular tables
---@field deploy fun(tblReceiving:table, tblGiving:table) copy keys/values that does exist on tblGiving but not in tblReceiving
---@field copytocompress fun(tblReceiving:table, tblGiving:table) copy the values from table2 to table1 overwriting existing values, ignores __index, functions and tables with a 'GetObjectType' key
---@field removeduplicate fun(tbl1:table, tbl2:table) remove the keys from table1 which also exists in table2 with the same value
---@field dump fun(tbl:table) : string dump a table to a string
---@class detailsframework
---@field OptionsFunctions df_optionsmixin
---@field RoundedCornerPanelMixin df_roundedcornermixin
---@field GetDefaultBackdropColor fun(self:table) : red, green, blue, alpha return a standard backdrop color
---@field Schedules df_schedule
---@field Math df_math
---@field table df_table_functions
---@field Dispatch fun(self:table, callback:function, ...) : any dispatch a function call using xpcall
---@field GetDefaultBackdropColor fun(self:table) : red, green, blue, alpha return the standard backdrop color used by blizzard on their own frames
---@field Msg fun(self:table, message:string, ...) show a message in the chat frame
---@field MsgWarning fun(self:table, message:string, ...) show a warning message in the chat frame
---@field CreateCloseButton fun(self:table, parent:frame, frameName:string?) : df_closebutton
@@ -14,4 +30,20 @@
---@field Mixin fun(self:table, target:table, ...) : table
---@field SetButtonTexture fun(self:table, button:button|df_button, texture:atlasname|texturepath|textureid)
---@field CreateFadeAnimation fun(self:table, UIObject:uiobject, fadeInTime:number?, fadeOutTime:number?, fadeInAlpha:number?, fadeOutAlpha:number?)
---@field UnitGroupRolesAssigned fun(self:table, unitId: unit, specId: specializationid) : string
---@field SetFontSize fun(self:table, fontstring:fontstring, size:number)
---@field SetFontColor fun(self:table, fontstring:fontstring, red:any, green:number?, blue:number?, alpha:number?)
---@field SetFontFace fun(self:table, fontstring:fontstring, font:string)
---@field SetFontShadow fun(self:table, fontstring:fontstring, red:any, green:number?, blue:number?, alpha:number?, offsetX:number?, offsetY:number?)
---@field SetFontOutline fun(self:table, fontstring:fontstring, outline:fontflags)
---@field RemoveRealmName fun(self:table, name:string) : string, number remove the realm name from the player name, must be in the format of "name-realm"
---@field RemoveOwnerName fun(self:table, name:string) : string, number removes the owner name from a name string, the owner name must be between < and >
---@field CleanUpName fun(self:table, name:string) : string removes the realm name and owner name from a name string
---@field IntegerToTimer fun(self:table, time:number) : string convert a number to a timer string, e.g. 150 -> 2:30
---@field GroupIterator fun(self:table, callback:function, ...) iterate over the group, calling the callback function for each group member
---@field CommaValue fun(self:table, value:number) : string convert a number to a string with commas, e.g. 1000000 -> 1,000,000
---@field SplitTextInLines fun(self:table, text:string) : string[] split a text into lines
---@field UnitGroupRolesAssigned fun(unitId: unit, bUseSupport:boolean, specId: specializationid) : string there's no self here
---@field
---@field
---@field
---@field
+89 -15
View File
@@ -1,6 +1,6 @@
local dversion = 457
local dversion = 460
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -233,8 +233,8 @@ end
---return the role of the unit, this is safe to use for all versions of wow
---@param unitId string
---@param specId number
---@param bUseSupport boolean
---@param specId number
---@return string
function DF.UnitGroupRolesAssigned(unitId, bUseSupport, specId)
if (not DF.IsTimewalkWoW()) then --Was function exist check. TBC has function, returns NONE. -Flamanis 5/16/2022
@@ -525,7 +525,7 @@ function DF.table.reverse(t)
return new
end
---copy the values from table2 to table1, ignore the metatable and UIObjects
---copy the values from table2 to table1 overwriting existing values, ignores __index and __newindex, keys pointing to a UIObject are preserved
---@param t1 table
---@param t2 table
---@return table
@@ -549,7 +549,7 @@ function DF.table.duplicate(t1, t2)
return t1
end
---copy from the table 't2' to table 't1' ignoring the metatable and overwriting values, does copy UIObjects
---copy the values from table2 to table1 overwriting existing values, ignores __index and __newindex, threat UIObjects as regular tables
---@param t1 table
---@param t2 table
---@return table
@@ -640,12 +640,83 @@ function DF.table.deploy(t1, t2)
return t1
end
local function tableToString(t, resultString, deep, seenTables)
resultString = resultString or ""
deep = deep or 0
seenTables = seenTables or {}
if seenTables[t] then
resultString = resultString .. "--CIRCULAR REFERENCE\n"
return resultString
end
local space = string.rep(" ", deep)
seenTables[t] = true
for key, value in pairs(t) do
local valueType = type(value)
if (type(key) == "function") then
key = "#function#"
elseif (type(key) == "table") then
key = "#table#"
end
if (type(key) ~= "string" and type(key) ~= "number") then
key = "unknown?"
end
if (valueType == "table") then
local sUIObjectType = value.GetObjectType and value:GetObjectType()
if (sUIObjectType) then
if (type(key) == "number") then
resultString = resultString .. space .. "[" .. key .. "] = |cFFa9ffa9 " .. sUIObjectType .. " {|r\n"
else
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9 " .. sUIObjectType .. " {|r\n"
end
else
if (type(key) == "number") then
resultString = resultString .. space .. "[" .. key .. "] = |cFFa9ffa9 {|r\n"
else
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9 {|r\n"
end
end
resultString = resultString .. tableToString(value, nil, deep + 1, seenTables)
resultString = resultString .. space .. "|cFFa9ffa9},|r\n"
elseif (valueType == "string") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = \"|cFFfff1c1" .. value .. "|r\",\n"
elseif (valueType == "number") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFFffc1f4" .. value .. "|r,\n"
elseif (valueType == "function") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = function()end,\n"
elseif (valueType == "boolean") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFF99d0ff" .. (value and "true" or "false") .. "|r,\n"
end
end
return resultString
end
local function tableToStringSafe(t)
local seenTables = {}
return tableToString(t, nil, 0, seenTables)
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)
if true then return tableToStringSafe(t) end
resultString = resultString or ""
deep = deep or 0
local space = ""
@@ -967,7 +1038,7 @@ end
---@param self table
---@param fontString fontstring
---@param degrees number
function DF:SetFontRotation(fontString, degrees)
function DF:SetFontRotation(fontString, degrees) --deprecated, use fontString:SetRotation(degrees)
if (type(degrees) == "number") then
if (not fontString.__rotationAnimation) then
fontString.__rotationAnimation = DF:CreateAnimationHub(fontString)
@@ -3927,7 +3998,7 @@ function DF:CreateGlowOverlay (parent, antsColor, glowColor)
glowFrame.SetColor = glow_overlay_setcolor
glowFrame:SetColor(antsColor, glowColor)
glowFrame:Hide()
parent.overlay = glowFrame
@@ -3950,7 +4021,7 @@ function DF:CreateGlowOverlay (parent, antsColor, glowColor)
--glowFrame.ProcStartFlipbook:SetSize(frameWidth * scale, frameHeight * scale)
glowFrame.ProcStartFlipbook:SetPoint("TOPLEFT", glowFrame, "TOPLEFT", -frameWidth * scale, frameHeight * scale)
glowFrame.ProcStartFlipbook:SetPoint("BOTTOMRIGHT", glowFrame, "BOTTOMRIGHT", frameWidth * scale, -frameHeight * scale)
end
end
glowFrame:EnableMouse(false)
return glowFrame
end
@@ -4557,19 +4628,22 @@ end
---@return any
function DF:Dispatch(func, ...)
if (type(func) ~= "function") then
return dispatch_error (_, "DF:Dispatch expect a function as parameter 1.")
return dispatch_error(_, "DetailsFramework:Dispatch(func) expect a function as parameter 1.")
end
return select(2, xpcall(func, geterrorhandler(), ...))
local dispatchResult = {xpcall(func, geterrorhandler(), ...)}
local okay = dispatchResult[1]
--[=[
local dispatchResult = {xpcall(func, geterrorhandler(), ...)}
local okay = dispatchResult[1]
if (not okay) then
return false
end
if (not okay) then
return false
end
tremove(dispatchResult, 1)
tremove(dispatchResult, 1)
return unpack(dispatchResult)
return unpack(dispatchResult)
--]=]
end
--[=[
+157 -29
View File
@@ -9,25 +9,41 @@ local unpack = unpack
local CreateFrame = CreateFrame
local PixelUtil = PixelUtil
local spellIconCache = {}
local spellNameCache = {}
detailsFramework.IconMixin = {
---create a new icon frame
---@param self frame the parent frame
---@param iconName string the name of the icon frame
---@return frame
CreateIcon = function(self, iconName)
local iconFrame = CreateFrame("frame", iconName, self, "BackdropTemplate")
CreateIcon = function(self, iconName, bIsSimple)
---@type frame
local iconFrame = CreateFrame("frame", iconName, self, not bIsSimple and "BackdropTemplate")
---@type texture
iconFrame.Texture = iconFrame:CreateTexture(nil, "artwork")
PixelUtil.SetPoint(iconFrame.Texture, "topleft", iconFrame, "topleft", 1, -1)
PixelUtil.SetPoint(iconFrame.Texture, "bottomright", iconFrame, "bottomright", -1, 1)
---@type texture
iconFrame.Border = iconFrame:CreateTexture(nil, "background")
iconFrame.Border:SetAllPoints()
iconFrame.Border:SetColorTexture(0, 0, 0)
iconFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
iconFrame:SetBackdropBorderColor(0, 0, 0, 0)
iconFrame:EnableMouse(false)
---@type fontstring
iconFrame.StackText = iconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
iconFrame.StackText:SetPoint("bottomright", iconFrame, "bottomright", 0, 0)
iconFrame.StackText:Hide()
iconFrame.StackTextShadow = iconFrame:CreateFontString(nil, "artwork", "GameFontNormal")
iconFrame.StackTextShadow:SetPoint("center", iconFrame.StackText, "center", 0, 0)
iconFrame.StackTextShadow:SetTextColor(0, 0, 0)
iconFrame.StackTextShadow:Hide()
---@type fontstring
iconFrame.Desc = iconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
iconFrame.Desc:SetPoint("bottom", iconFrame, "top", 0, 2)
iconFrame.Desc:Hide()
local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", iconFrame, "CooldownFrameTemplate, BackdropTemplate")
cooldownFrame:SetAllPoints()
@@ -35,39 +51,57 @@ detailsFramework.IconMixin = {
cooldownFrame:SetFrameLevel(iconFrame:GetFrameLevel()+1)
iconFrame.Cooldown = cooldownFrame
---@type fontstring
iconFrame.CountdownText = cooldownFrame:CreateFontString(nil, "overlay", "GameFontNormal")
iconFrame.CountdownText:SetPoint("center", iconFrame, "center", 0, 0)
iconFrame.CountdownText:Hide()
iconFrame.StackText = iconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
iconFrame.StackText:SetPoint("center", iconFrame, "bottomright", 0, 0)
iconFrame.StackText:Hide()
iconFrame.Desc = iconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
iconFrame.Desc:SetPoint("bottom", iconFrame, "top", 0, 2)
iconFrame.Desc:Hide()
return iconFrame
end,
GetIcon = function(self)
GetIcon = function(self, bIsSimple)
local iconFrame = self.IconPool[self.NextIcon]
if (not iconFrame) then
local newIconFrame = self:CreateIcon("$parentIcon" .. self.NextIcon)
newIconFrame.parentIconRow = self
newIconFrame.Cooldown:SetHideCountdownNumbers(self.options.surpress_blizzard_cd_timer)
newIconFrame.Cooldown.noCooldownCount = self.options.surpress_tulla_omni_cc
iconFrame = self:CreateIcon("$parentIcon" .. self.NextIcon, bIsSimple)
iconFrame.parentIconRow = self
newIconFrame.CountdownText:ClearAllPoints()
newIconFrame.CountdownText:SetPoint(self.options.text_anchor or "center", iconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0)
newIconFrame.StackText:ClearAllPoints()
newIconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
newIconFrame.Desc:ClearAllPoints()
newIconFrame.Desc:SetPoint(self.options.desc_text_anchor or "bottom", iconFrame, self.options.desc_text_rel_anchor or "top", self.options.desc_text_x_offset or 0, self.options.desc_text_y_offset or 2)
if (bIsSimple) then
iconFrame.Cooldown:Hide()
iconFrame.Desc:Hide()
iconFrame.Texture:SetTexCoord(0.1, 0.9, 0.1, 0.9)
--newIconFrame:SetBackdropBorderColor(0, 0, 0, 0)
iconFrame.Border:ClearAllPoints()
iconFrame.Border:SetPoint("topleft", iconFrame, "topleft", -1, 1)
iconFrame.Border:SetPoint("bottomright", iconFrame, "bottomright", 1, -1)
iconFrame.Border:SetTexture(130759)
iconFrame.Border:SetTexCoord(0.296875, 0.5703125, 0, 0.515625)
iconFrame.Border:SetDrawLayer("overlay", 7)
self.IconPool[self.NextIcon] = newIconFrame
iconFrame = newIconFrame
iconFrame.StackText:SetTextColor(detailsFramework:ParseColors(self.options.stack_text_color))
iconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "center", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
detailsFramework:SetFontSize(iconFrame.StackText, self.options.stack_text_size)
detailsFramework:SetFontFace(iconFrame.StackText, self.options.stack_text_font)
detailsFramework:SetFontOutline(iconFrame.StackText, self.options.stack_text_outline)
detailsFramework:SetFontFace(iconFrame.StackTextShadow, self.options.stack_text_font)
detailsFramework:SetFontSize(iconFrame.StackTextShadow, self.options.stack_text_size+1)
else
iconFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
iconFrame:SetBackdropBorderColor(0, 0, 0, 0)
iconFrame:EnableMouse(false)
iconFrame.Cooldown:SetHideCountdownNumbers(self.options.surpress_blizzard_cd_timer)
iconFrame.Cooldown.noCooldownCount = self.options.surpress_tulla_omni_cc
iconFrame.CountdownText:ClearAllPoints()
iconFrame.CountdownText:SetPoint(self.options.text_anchor or "center", iconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0)
iconFrame.Desc:ClearAllPoints()
iconFrame.Desc:SetPoint(self.options.desc_text_anchor or "bottom", iconFrame, self.options.desc_text_rel_anchor or "top", self.options.desc_text_x_offset or 0, self.options.desc_text_y_offset or 2)
end
iconFrame.StackText:ClearAllPoints()
iconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "center", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
self.IconPool[self.NextIcon] = iconFrame
iconFrame = iconFrame
end
iconFrame:ClearAllPoints()
@@ -133,6 +167,8 @@ detailsFramework.IconMixin = {
iconFrame:SetBackdropBorderColor(0, 0, 0 ,0)
end
--iconFrame.Border:SetColorTexture(0, 0, 0, 1)
if (startTime) then
CooldownFrame_Set(iconFrame.Cooldown, startTime, duration, true, true, modRate)
@@ -168,11 +204,13 @@ detailsFramework.IconMixin = {
iconFrame.Cooldown:SetDrawSwipe(self.options.cooldown_swipe_enabled)
iconFrame.Cooldown:SetEdgeTexture(self.options.cooldown_edge_texture)
iconFrame.Cooldown:SetHideCountdownNumbers(self.options.surpress_blizzard_cd_timer)
iconFrame.Cooldown:Show()
else
iconFrame.timeRemaining = nil
iconFrame.expirationTime = nil
iconFrame:SetScript("OnUpdate", nil)
iconFrame.CountdownText:Hide()
iconFrame.Cooldown:Hide()
end
if (descText and self.options.desc_text) then
@@ -191,7 +229,7 @@ detailsFramework.IconMixin = {
iconFrame.StackText:Show()
iconFrame.StackText:SetText(count)
iconFrame.StackText:SetTextColor(detailsFramework:ParseColors(self.options.stack_text_color))
iconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
iconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "center", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0)
detailsFramework:SetFontSize(iconFrame.StackText, self.options.stack_text_size)
detailsFramework:SetFontFace(iconFrame.StackText, self.options.stack_text_font)
detailsFramework:SetFontOutline(iconFrame.StackText, self.options.stack_text_outline)
@@ -232,6 +270,89 @@ detailsFramework.IconMixin = {
end
end,
SetStacks = function(self, iconFrame, bIsShown, stacksAmount)
if (bIsShown) then
iconFrame.StackText:Show()
iconFrame.StackTextShadow:Show()
iconFrame.StackText:SetText(stacksAmount)
iconFrame.StackTextShadow:SetText(stacksAmount)
else
iconFrame.StackText:Hide()
iconFrame.StackTextShadow:Hide()
end
end,
SetIconSimple = function(self, spellId, borderColor, startTime, duration, iconTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff, modRate)
local actualSpellName, spellIcon = spellNameCache[spellId], spellIconCache[spellId]
if (not actualSpellName) then
actualSpellName, _, spellIcon = GetSpellInfo(spellId)
spellIconCache[spellId] = spellIcon
spellNameCache[spellId] = actualSpellName
end
if iconTexture then
spellIcon = iconTexture
end
if (spellIcon) then
spellName = spellName or actualSpellName or "unknown_aura"
modRate = modRate or 1
local bIsSimple = true
local iconFrame = self:GetIcon(bIsSimple, bIsSimple)
if (iconFrame.Texture.texture ~= spellIcon) then
iconFrame.Texture:SetTexture(spellIcon, "clamp", "clamp", "nearest")
iconFrame.Texture.texture = spellIcon
end
if (borderColor) then
iconFrame.Border:Show()
iconFrame.Border:SetVertexColor(unpack(borderColor))
else
iconFrame.Border:Hide()
end
if (count and count > 1 and self.options.stack_text) then
self:SetStacks(iconFrame, true, count)
else
self:SetStacks(iconFrame, false)
end
PixelUtil.SetSize(iconFrame, self.options.icon_width, self.options.icon_height)
iconFrame:Show()
--update the size of the frame
self:SetWidth((self.options.left_padding * 2) + (self.options.icon_padding * (self.NextIcon-2)) + (self.options.icon_width * (self.NextIcon - 1)))
self:SetHeight(self.options.icon_height + (self.options.top_padding * 2))
--make information available
iconFrame.spellId = spellId
iconFrame.startTime = startTime
iconFrame.duration = duration
iconFrame.count = count
iconFrame.debuffType = debuffType
iconFrame.caster = caster
iconFrame.canStealOrPurge = canStealOrPurge
iconFrame.isBuff = isBuff
iconFrame.spellName = spellName
iconFrame.identifierKey = nil -- only used for "specific" add/remove
--add the spell into the cache
self.AuraCache[spellId or -1] = true
self.AuraCache[spellName] = true
self.AuraCache.canStealOrPurge = self.AuraCache.canStealOrPurge or canStealOrPurge
self.AuraCache.hasEnrage = self.AuraCache.hasEnrage or debuffType == "" --yes, enrages are empty-string...
--show the frame
self:Show()
return iconFrame
end
end,
OnIconTick = function(self, deltaTime)
local now = GetTime()
if (self.lastUpdateCooldown + 0.05) <= now then
@@ -413,8 +534,10 @@ detailsFramework.IconMixin = {
end,
OnOptionChanged = function(self, optionName)
self:SetBackdropColor(unpack(self.options.backdrop_color))
self:SetBackdropBorderColor(unpack(self.options.backdrop_border_color))
if (self.SetBackdropColor) then
self:SetBackdropColor(unpack(self.options.backdrop_color))
self:SetBackdropBorderColor(unpack(self.options.backdrop_border_color))
end
end,
}
@@ -466,6 +589,11 @@ local default_icon_row_options = {
cooldown_edge_texture = "Interface\\Cooldown\\edge",
}
---comment
---@param parent frame
---@param name string?
---@param options table?
---@return frame
function detailsFramework:CreateIconRow(parent, name, options)
local newIconRowFrame = CreateFrame("frame", name, parent, "BackdropTemplate")
newIconRowFrame.IconPool = {}
+128 -34
View File
@@ -8,14 +8,44 @@ local UnitExists = UnitExists
local atan2 = math.atan2
local pi = math.pi
local abs = math.abs
local UnitPosition = UnitPosition
local Clamp = Clamp
local max = max
local Lerp = Lerp
SMALL_FLOAT = 0.000001
--find distance between two players
function DF:GetDistance_Unit(unit1, unit2)
if (UnitExists(unit1) and UnitExists(unit2)) then
local u1X, u1Y = UnitPosition(unit1)
local u2X, u2Y = UnitPosition(unit2)
--namespace
DF.Math = {}
---@class df_math : table
---@field GetUnitDistance fun(unitId1: unit, unitId2: unit) : number find distance between two units
---@field GetPointDistance fun(x1: number, y1: number, x2: number, y2: number) : number find distance between two points
---@field FindLookAtRotation fun(x1: number, y1: number, x2: number, y2: number) : number find a rotation for an object from a point to another point
---@field MapRangeClamped fun(inputX: number, inputY: number, outputX: number, outputY: number, value: number) : number find the value scale between two given values. e.g: value of 500 in a range 0-100 result in 10 in a scale for 0-10
---@field MapRangeUnclamped fun(inputX: number, inputY: number, outputX: number, outputY: number, value: number) : number find the value scale between two given values. e.g: value of 75 in a range 0-100 result in 7.5 in a scale for 0-10
---@field GetRangePercent fun(minValue: number, maxValue: number, value: number) : number find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
---@field GetRangeValue fun(minValue: number, maxValue: number, percent: number) : number find the value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
---@field GetColorRangeValue fun(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, value: number) : number, number, number find the color value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
---@field GetDotProduct fun(value1: table, value2: table) : number dot product of two 2D Vectors
---@field GetBezierPoint fun(value: number, point1: table, point2: table, point3: table) : number find a point in a bezier curve
---@field LerpNorm fun(minValue: number, maxValue: number, value: number) : number normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
---@field LerpLinearColor fun(deltaTime: number, interpSpeed: number, r1: number, g1: number, b1: number, r2: number, g2: number, b2: number) : number, number, number change the color by the deltaTime
---@field IsNearlyEqual fun(value1: number, value2: number, tolerance: number) : boolean check if a number is near another number by a tolerance
---@field IsNearlyZero fun(value: number, tolerance: number) : boolean check if a number is near zero
---@field IsWithin fun(minValue: number, maxValue: number, value: number, isInclusive: boolean) : boolean check if a number is within a two other numbers, if isInclusive is true, it'll include the max value
---@field Clamp fun(minValue: number, maxValue: number, value: number) : number dont allow a number ot be lower or bigger than a certain range
---@field Round fun(num: number, numDecimalPlaces: number) : number cut fractions on a float
---@field GetObjectCoordinates fun(object: uiobject) : objectcoordinates return the coordinates of the four corners of an object
---find distance between two units
---@param unitId1 string
---@param unitId2 string
function DF.Math.GetUnitDistance(unitId1, unitId2)
if (UnitExists(unitId1) and UnitExists(unitId2)) then
local u1X, u1Y = UnitPosition(unitId1)
local u2X, u2Y = UnitPosition(unitId2)
local dX = u2X - u1X
local dY = u2Y - u1Y
@@ -25,63 +55,54 @@ function DF:GetDistance_Unit(unit1, unit2)
return 0
end
--find distance between two points
function DF:GetDistance_Point(x1, y1, x2, y2)
local dx = x2 - x1
local dy = y2 - y1
return ((dx * dx) + (dy * dy)) ^ .5
function DF.Math.GetPointDistance(x1, y1, x2, y2)
local dX = x2 - x1
local dY = y2 - y1
return ((dX * dX) + (dY * dY)) ^ .5
end
--find a rotation for an object from a point to another point
function DF:FindLookAtRotation(x1, y1, x2, y2)
return atan2 (y2 - y1, x2 - x1) + pi
function DF.Math.FindLookAtRotation(x1, y1, x2, y2)
return atan2(y2 - y1, x2 - x1) + pi
end
--find the value scale between two given values. e.g: value of 500 in a range 0-100 result in 10 in a scale for 0-10
function DF:MapRangeClamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue(outputX, outputY, Clamp(DF:GetRangePercent(inputX, inputY, value), 0, 1))
function DF.Math.MapRangeClamped(inputX, inputY, outputX, outputY, value)
return DF.Math.GetRangeValue(outputX, outputY, Clamp(DF.Math.GetRangePercent(inputX, inputY, value), 0, 1))
end
--find the value scale between two given values. e.g: value of 75 in a range 0-100 result in 7.5 in a scale for 0-10
function DF:MapRangeUnclamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue(outputX, outputY, DF:GetRangePercent(inputX, inputY, value))
function DF.Math.MapRangeUnclamped(inputX, inputY, outputX, outputY, value)
return DF.Math.GetRangeValue(outputX, outputY, DF.Math.GetRangePercent(inputX, inputY, value))
end
--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
function DF:GetRangePercent(minValue, maxValue, value)
function DF.Math.GetRangePercent(minValue, maxValue, value)
return (value - minValue) / max((maxValue - minValue), SMALL_FLOAT)
end
--find the value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
function DF:GetRangeValue(minValue, maxValue, percent)
function DF.Math.GetRangeValue(minValue, maxValue, percent)
return Lerp(minValue, maxValue, percent)
end
function DF:GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
local newR = DF:LerpNorm(r1, r2, value)
local newG = DF:LerpNorm(g1, g2, value)
local newB = DF:LerpNorm(b1, b2, value)
function DF.Math.GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
local newR = DF.Math.LerpNorm(r1, r2, value)
local newG = DF.Math.LerpNorm(g1, g2, value)
local newB = DF.Math.LerpNorm(b1, b2, value)
return newR, newG, newB
end
--dot product of two 2D Vectors
function DF:GetDotProduct(value1, value2)
function DF.Math.GetDotProduct(value1, value2)
return (value1.x * value2.x) + (value1.y * value2.y)
end
function DF:GetBezierPoint(value, point1, point2, point3)
function DF.Math.GetBezierPoint(value, point1, point2, point3)
local bP1 = Lerp(point1, point2, value)
local bP2 = Lerp(point2, point3, value)
return Lerp(bP1, bP2, value)
end
--normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
function DF:LerpNorm(minValue, maxValue, value)
function DF.Math.LerpNorm(minValue, maxValue, value)
return (minValue + value * (maxValue - minValue))
end
--change the color by the deltaTime
function DF:LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
function DF.Math.LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
deltaTime = deltaTime * interpSpeed
local r = r1 + (r2 - r1) * deltaTime
local g = g1 + (g2 - g1) * deltaTime
@@ -89,6 +110,79 @@ function DF:LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
return r, g, b
end
function DF.Math.IsNearlyEqual(value1, value2, tolerance)
tolerance = tolerance or SMALL_FLOAT
return abs(value1 - value2) <= tolerance
end
function DF.Math.IsNearlyZero(value, tolerance)
tolerance = tolerance or SMALL_FLOAT
return abs(value) <= tolerance
end
function DF.Math.IsWithin(minValue, maxValue, value, isInclusive)
if (isInclusive) then
return ((value >= minValue) and (value <= maxValue))
else
return ((value >= minValue) and (value < maxValue))
end
end
function DF.Math.Clamp(minValue, maxValue, value)
return value < minValue and minValue or value < maxValue and value or maxValue
end
function DF.Math.Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
--old calls, keeping for compatibility
function DF:GetDistance_Unit(unit1, unit2)
return DF.Math.GetUnitDistance(unit1, unit2)
end
function DF:GetDistance_Point(x1, y1, x2, y2)
return DF.Math.GetPointDistance(x1, y1, x2, y2)
end
--find a rotation for an object from a point to another point
function DF:FindLookAtRotation(x1, y1, x2, y2)
return DF.Math.FindLookAtRotation(x1, y1, x2, y2)
end
--find the value scale between two given values. e.g: value of 500 in a range 0-100 result in 10 in a scale for 0-10
function DF:MapRangeClamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue(outputX, outputY, Clamp(DF:GetRangePercent(inputX, inputY, value), 0, 1))
end
--find the value scale between two given values. e.g: value of 75 in a range 0-100 result in 7.5 in a scale for 0-10
function DF:MapRangeUnclamped(inputX, inputY, outputX, outputY, value)
return DF:GetRangeValue(outputX, outputY, DF:GetRangePercent(inputX, inputY, value))
end
--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
function DF:GetRangePercent(minValue, maxValue, value)
return (value - minValue) / max((maxValue - minValue), SMALL_FLOAT)
end
--find the value in the range given from a normalized percent. e.g range of 200-400 and a percent of 0.8 result in 360
function DF:GetRangeValue(minValue, maxValue, percent)
return Lerp(minValue, maxValue, percent)
end
function DF:GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
return DF.Math.GetColorRangeValue(r1, g1, b1, r2, g2, b2, value)
end
--dot product of two 2D Vectors
function DF:GetDotProduct(value1, value2)
return (value1.x * value2.x) + (value1.y * value2.y)
end
function DF:GetBezierPoint(value, point1, point2, point3)
return DF.Math.GetBezierPoint(value, point1, point2, point3)
end
--normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
function DF:LerpNorm(minValue, maxValue, value)
return (minValue + value * (maxValue - minValue))
end
--change the color by the deltaTime
function DF:LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
return DF.Math.LerpLinearColor(deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
end
--check if a number is near another number by a tolerance
function DF:IsNearlyEqual(value1, value2, tolerance)
tolerance = tolerance or SMALL_FLOAT
+26 -1
View File
@@ -1018,7 +1018,10 @@ detailsFramework.ValueMixin = {
---@field GetBorderTexture fun(self: table) : string
---@field SetBorderColor fun(self: table, ...)
---@field GetBorderColor fun(self: table) : number, number, number, number
---@field SetDesaturated fun(self: table, bIsDesaturated: boolean)
---@field IsDesaturated fun(self: table) : boolean
---@field SetVertexColor fun(self: table, red: any, green: number?, blue: number?, alpha: number?)
---@field GetVertexColor fun(self: table) : number, number, number, number
detailsFramework.StatusBarFunctions = {
SetTexture = function(self, texture, isTemporary)
@@ -1036,6 +1039,27 @@ detailsFramework.StatusBarFunctions = {
return self.barTexture:GetTexture()
end,
SetDesaturated = function(self, bIsDesaturated)
self.barTexture:SetDesaturated(bIsDesaturated)
end,
SetDesaturation = function(self, desaturationAmount)
self.barTexture:SetDesaturation(desaturationAmount)
end,
IsDesaturated = function(self)
return self.barTexture:IsDesaturated()
end,
SetVertexColor = function(self, red, green, blue, alpha)
red, green, blue, alpha = detailsFramework:ParseColors(red, green, blue, alpha)
self.barTexture:SetVertexColor(red, green, blue, alpha)
end,
GetVertexColor = function(self)
return self.barTexture:GetVertexColor()
end,
SetAtlas = function(self, atlasName)
self.barTexture:SetAtlas(atlasName)
end,
@@ -1045,6 +1069,7 @@ detailsFramework.StatusBarFunctions = {
end,
SetTexCoord = function(self, ...)
local left, right, top, bottom = ...
return self.barTexture:SetTexCoord(...)
end,
+9 -1
View File
@@ -10,6 +10,14 @@ local unpack = table.unpack or _G.unpack
--make a namespace for schedules
DF.Schedules = DF.Schedules or {}
---@class df_schedule : table
---@field NewTicker fun(time: number, callback: function, ...: any): timer
---@field NewTimer fun(time: number, callback: function, ...: any): timer
---@field Cancel fun(ticker: timer)
---@field After fun(time: number, callback: function)
---@field SetName fun(object: timer, name: string)
---@field RunNextTick fun(callback: function)
--run a scheduled function with its payload
local triggerScheduledTick = function(tickerObject)
local payload = tickerObject.payload
@@ -51,7 +59,7 @@ function DF.Schedules.NewTimer(time, callback, ...)
return newTimer
end
--cancel an ongoing ticker
--cancel an ongoing ticker, the native call tickerObject:Cancel() also works with no problem
function DF.Schedules.Cancel(tickerObject)
--ignore if there's no ticker object
if (tickerObject) then
+53 -31
View File
@@ -70,12 +70,14 @@ local cleanfunction = function() end
---@field ShieldIndicatorTexture texturepath|textureid|atlasname
---@field ShieldGlowTexture texturepath|textureid|atlasname
---@field ShieldGlowWidth number
---@field DontSetStatusBarTexture boolean
---@field Width number
---@field Height number
---@class df_healthbar : statusbar, df_scripthookmixin, df_statusbarmixin
---@field unit unit
---@field displayedUnit unit
---@field oldHealth number
---@field currentHealth number
---@field currentHealthMax number
---@field WidgetType string
@@ -86,7 +88,7 @@ local cleanfunction = function() end
---@field healAbsorbIndicator texture
---@field shieldAbsorbGlow texture
---@field barTexture texture
---@field SetUnit fun(self:df_healthbar, unit:unit, displayedUnit:unit)
---@field SetUnit fun(self:df_healthbar, unit:unit?, displayedUnit:unit)
---@field GetTexture fun(self:df_healthbar) : texture
---@field SetTexture fun(self:df_healthbar, texture:texturepath|textureid|atlasname)
---@field SetColor fun(self:df_healthbar, red:number, green:number, blue:number, alpha:number)
@@ -140,6 +142,7 @@ local cleanfunction = function() end
CanTick = false, --if true calls the method 'OnTick' every tick, the function needs to be overloaded, it receives self and deltaTime as parameters
ShowHealingPrediction = true, --when casting a healing pass, show the amount of health that spell will heal
ShowShields = true, --indicator of the amount of damage absortion the unit has
DontSetStatusBarTexture = false,
--appearance
BackgroundColor = detailsFramework:CreateColorTable (.2, .2, .2, .8),
@@ -251,6 +254,9 @@ local cleanfunction = function() end
self.shieldAbsorbGlow:Hide()
self:SetUnit(nil)
self.currentHealth = 1
self.currentHealthMax = 2
end
--call every tick
@@ -258,25 +264,29 @@ local cleanfunction = function() end
--when an event happen for this unit, send it to the apropriate function
healthBarMetaFunctions.OnEvent = function(self, event, ...)
local eventFunc = self [event]
local eventFunc = self[event]
if (eventFunc) then
--the function doesn't receive which event was, only 'self' and the parameters
eventFunc (self, ...)
eventFunc(self, ...)
end
end
--when the unit max health is changed
healthBarMetaFunctions.UpdateMaxHealth = function(self)
local maxHealth = UnitHealthMax (self.displayedUnit)
local maxHealth = UnitHealthMax(self.displayedUnit)
self:SetMinMaxValues(0, maxHealth)
self.currentHealthMax = maxHealth
self:RunHooksForWidget("OnHealthMaxChange", self, self.displayedUnit)
if (self.OnHealthMaxChange) then --direct call
self.OnHealthMaxChange(self, self.displayedUnit)
else
self:RunHooksForWidget("OnHealthMaxChange", self, self.displayedUnit)
end
end
healthBarMetaFunctions.UpdateHealth = function(self)
-- update max health regardless to avoid weird wrong values on UpdateMaxHealth sometimes
-- local maxHealth = UnitHealthMax (self.displayedUnit)
-- local maxHealth = UnitHealthMax(self.displayedUnit)
-- self:SetMinMaxValues(0, maxHealth)
-- self.currentHealthMax = maxHealth
@@ -285,7 +295,11 @@ local cleanfunction = function() end
self.currentHealth = health
PixelUtil.SetStatusBarValue(self, health)
self:RunHooksForWidget("OnHealthChange", self, self.displayedUnit)
if (self.OnHealthChange) then --direct call
self.OnHealthChange(self, self.displayedUnit)
else
self:RunHooksForWidget("OnHealthChange", self, self.displayedUnit)
end
end
--health and absorbs prediction
@@ -365,7 +379,13 @@ local cleanfunction = function() end
self:UpdateHealPrediction()
end
healthBarMetaFunctions.UNIT_HEALTH = function(self, ...)
healthBarMetaFunctions.UNIT_HEALTH = function(self, unitId)
self:UpdateHealth()
self:UpdateHealPrediction()
end
healthBarMetaFunctions.UNIT_MAXHEALTH = function(self, unitId)
self:UpdateMaxHealth()
self:UpdateHealth()
self:UpdateHealPrediction()
end
@@ -375,12 +395,6 @@ local cleanfunction = function() end
self:UpdateHealPrediction()
end
healthBarMetaFunctions.UNIT_MAXHEALTH = function(self, ...)
self:UpdateMaxHealth()
self:UpdateHealth()
self:UpdateHealPrediction()
end
healthBarMetaFunctions.UNIT_HEAL_PREDICTION = function(self, ...)
self:UpdateMaxHealth()
self:UpdateHealth()
@@ -430,7 +444,6 @@ function detailsFramework:CreateHealthBar(parent, name, settingsOverride)
healthBar.shieldAbsorbGlow:SetDrawLayer("artwork", 7)
--statusbar texture
healthBar.barTexture = healthBar:CreateTexture(nil, "artwork")
healthBar:SetStatusBarTexture(healthBar.barTexture)
end
--mixins
@@ -447,6 +460,12 @@ function detailsFramework:CreateHealthBar(parent, name, settingsOverride)
end
healthBar.Settings = settings
if (healthBar.Settings.DontSetStatusBarTexture) then
healthBar.barTexture:SetAllPoints()
else
healthBar:SetStatusBarTexture(healthBar.barTexture)
end
--hook list
healthBar.HookList = detailsFramework.table.copy({}, healthBarMetaFunctions.HookList)
@@ -488,6 +507,7 @@ end
---@field Settings df_powerbarsettings
---@field background texture
---@field percentText fontstring
---@field SetUnit fun(self:df_healthbar, unit:unit?, displayedUnit:unit?)
detailsFramework.PowerFrameFunctions = {
WidgetType = "powerBar",
@@ -617,9 +637,10 @@ detailsFramework.PowerFrameFunctions = {
self:Hide()
end
end,
UpdatePower = function(self)
self.currentPower = UnitPower(self.displayedUnit, self.powerType)
PixelUtil.SetStatusBarValue (self, self.currentPower)
PixelUtil.SetStatusBarValue(self, self.currentPower)
if (self.Settings.ShowPercentText) then
self.percentText:SetText(floor(self.currentPower / self.currentPowerMax * 100) .. "%")
@@ -845,7 +866,7 @@ end
---@field fadeOutAnimation animationgroup
---@field fadeInAnimation animationgroup
---@field flashAnimation animationgroup
---@field SetUnit fun(self:df_castbar, unit:string)
---@field SetUnit fun(self:df_castbar, unit:string?)
---@field SetDefaultColor fun(self:df_castbar, colorType: caststage_color, red:any, green:number?, blue:number?, alpha:number?)
---@field UpdateCastColor fun(self:df_castbar) after setting a new color, call this function to update the bar color (while casting or channeling)
---@field GetCastColor fun(self:df_castbar) return a table with the color values for the current state of the casting process
@@ -1942,17 +1963,17 @@ end
end
---@class df_unitframesettings : table
---@field ClearUnitOnHide boolean
---@field ShowCastBar boolean
---@field ShowPowerBar boolean
---@field ShowUnitName boolean
---@field ShowBorder boolean
---@field CanModifyHealhBarColor boolean
---@field ColorByAggro boolean
---@field FixedHealthColor boolean
---@field UseFriendlyClassColor boolean
---@field UseEnemyClassColor boolean
---@field ShowTargetOverlay boolean
---@field ClearUnitOnHide boolean true
---@field ShowCastBar boolean true
---@field ShowPowerBar boolean true
---@field ShowUnitName boolean true
---@field ShowBorder boolean true
---@field CanModifyHealhBarColor boolean true
---@field ColorByAggro boolean false
---@field FixedHealthColor boolean false
---@field UseFriendlyClassColor boolean true
---@field UseEnemyClassColor boolean true
---@field ShowTargetOverlay boolean true
---@field BorderColor table
---@field CanTick boolean
---@field Width number
@@ -1964,7 +1985,7 @@ end
---@field WidgetType string
---@field Settings df_unitframesettings
---@field SetHealthBarColor fun(self:df_unitframe, r:number, g:number?, b:number?, a:number?)
---@field SetUnit fun(self:df_unitframe, unit:string) sets the unit to be shown in the unit frame
---@field SetUnit fun(self:df_unitframe, unit:string?) sets the unit to be shown in the unit frame
---@field OnTick fun(self:df_unitframe, deltaTime:number?) if CanTick is true, this function will be called every frame
detailsFramework.UnitFrameFunctions = {
@@ -1987,7 +2008,7 @@ end
--misc
ShowTargetOverlay = true, --shows a highlighht for the player current target
BorderColor = detailsFramework:CreateColorTable (0, 0, 0, 1), --border color, set to alpha zero for no border
BorderColor = detailsFramework:CreateColorTable(0, 0, 0, 1), --border color, set to alpha zero for no border
CanTick = false, --if true it'll run the OnTick event
--size
@@ -2384,8 +2405,9 @@ end
self:UpdateUnitFrame()
end
end,
PARTY_MEMBER_ENABLE = function(self, ...)
if (UnitIsConnected (self.unit)) then
if (UnitIsConnected(self.unit)) then
self:UpdateName()
end
end,
+54 -25
View File
@@ -181,6 +181,29 @@
---| "Minimap"
---| "GameTooltip"
---@class aurainfo : table
---@field applications number
---@field auraInstanceID number
---@field canApplyAura boolean
---@field dispelName string if not dispellable, doesn't have this key
---@field duration number
---@field expirationTime number based on GetTime, if zero, it's a permanent aura (usually weekly buffs)
---@field icon number
---@field isBossAura boolean
---@field isFromPlayerOrPlayerPet boolean
---@field isHelpful boolean true for buffs, false for debuffs
---@field isHarmful boolean true for debuffs, false for buffs
---@field isNameplateOnly boolean
---@field isRaid boolean player can cast this aura or the player can dispel this aura
---@field isStealable boolean
---@field nameplateShowPersonal boolean
---@field nameplateShowAll boolean
---@field points table
---@field spellId number
---@field timeMod number
---@field name string aura name
---@field sourceUnit string unitid
---@alias width number property that represents the horizontal size of a UI element, such as a frame or a texture. Gotten from the first result of GetWidth() or from the first result of GetSize(). It is expected a GetWidth() or GetSize() when the type 'height' is used.
---@alias height number property that represents the vertical size of a UI element, such as a frame or a texture. Gotten from the first result of GetHeight() or from the second result of GetSize(). It is expected a GetHeight() or GetSize() when the type 'height' is used.
---@alias framelevel number represent how high a frame is placed within its strata. The higher the frame level, the more likely it is to appear in front of other frames. The frame level is a number between 0 and 65535. The default frame level is 0. The frame level is set with the SetFrameLevel() function.
@@ -194,6 +217,8 @@
---@alias encounterejid number encounter ID number used by the encounter journal
---@alias encountername string encounter name received by the event ENCOUNTER_START and ENCOUNTER_END also used by the encounter journal
---@alias spellid number each spell in the game has a unique spell id, this id can be used to identify a spell.
---@alias unitname string name of a unit
---@alias unitguid string unique id of a unit (GUID)
---@alias actorname string name of a unit
---@alias petname string refers to a pet's name
---@alias ownername string refers to the pet's owner name
@@ -204,7 +229,7 @@
---@alias guid string unique id of a unit (GUID)
---@alias specializationid number the ID of a class specialization
---@alias controlflags number flags telling what unit type the is (player, npc, pet, etc); it's relatiotionship to the player (friendly, hostile, etc); who controls the unit (controlled by the player, controlled by the server, etc)
---@alias color table, string @table(r: red|number, g: green|number, b: blue|number, a: alpha|number) @string(color name) @hex (000000-ffffff) value representing a color, the value must be a table with the following fields: r, g, b, a. r, g, b are numbers between 0 and 1, a is a number between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@alias color table @table(r: red|number, g: green|number, b: blue|number, a: alpha|number) @table(number, number, number, number) @string(color name) @hex (000000-ffffff) value representing a color, the value must be a table with the following fields: r, g, b, a. r, g, b are numbers between 0 and 1, a is a number between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color)
---@alias scale number @number(0.65-2.40) value representing the scale factor of the UIObject, the value must be between 0.65 and 2.40, the width and height of the UIObject will be multiplied by this value.
---@alias script string, function is a piece of code that is executed in response to a specific event, such as a button click or a frame update. Scripts can be used to implement behavior and logic for UI elements.
---@alias event string is a notification that is sent to a frame when something happens, such as a button click or a frame update. Events can be used to trigger scripts.
@@ -259,6 +284,7 @@
---@field Show fun(self: uiobject) make the object be shown on the user screen
---@field Hide fun(self: uiobject) make the object be hidden from the user screen
---@field SetShown fun(self: uiobject, state: boolean) show or hide the object
---@field IsVisible fun(self: uiobject) : boolean return if the object is visible or not, visibility accounts for the object parent's be not shown
---@field IsShown fun(self: uiobject) : boolean return if the object is shown or not
---@field SetAllPoints fun(self: uiobject, target: uiobject|nil) set the object to be the same size as its parent or the target object
---@field SetParent fun(self: uiobject, parent: frame) set the parent object of the object
@@ -316,7 +342,7 @@
---@field SetDuration fun(self: animation, duration: number)
---@field SetEndDelay fun(self: animation, delay: number)
---@field SetOrder fun(self: animation, order: number)
---@field SetScript fun(self: animation, event: string, handler: function|nil)
---@field SetScript fun(self: animation, event: string, handler: function?)
---@field SetSmoothing fun(self: animation, smoothing: string)
---@field Stop fun(self: animation)
@@ -324,16 +350,16 @@
---@field GetEndPoint fun(self: line) : relativePoint: anchorpoint, relativeTo: anchorpoint, offsetX: number, offsetY: number
---@field GetStartPoint fun(self: line) : relativePoint: anchorpoint, relativeTo: anchorpoint, offsetX: number, offsetY: number
---@field GetThickness fun(self: line) : number
---@field SetStartPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject|number, relativePoint: anchorpoint|number, xOffset: number|nil, yOffset: number|nil)
---@field SetEndPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject|number, relativePoint: anchorpoint|number, xOffset: number|nil, yOffset: number|nil)
---@field SetColorTexture fun(self: line, red: number, green: number, blue: number, alpha: number)
---@field SetStartPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject|number, relativePoint: anchorpoint|number, xOffset: number?, yOffset: number?)
---@field SetEndPoint fun(self: line, point: anchorpoint, relativeFrame: uiobject|number, relativePoint: anchorpoint|number, xOffset: number?, yOffset: number?)
---@field SetColorTexture fun(self: line, red: number, green: number, blue: number, alpha: number?)
---@field SetThickness fun(self: line, thickness: number)
---@class frame : uiobject
---@field CreateLine fun(self: frame, name: string|nil, drawLayer: drawlayer, templateName: string|nil, subLevel: number|nil) : line
---@field CreateLine fun(self: frame, name: string?, drawLayer: drawlayer, templateName: string?, subLevel: number?) : line
---@field SetID fun(self: frame, id: number) set an ID for the frame
---@field SetAttribute fun(self: frame, name: string, value: any)
---@field SetScript fun(self: frame, event: string, handler: function|nil)
---@field SetScript fun(self: frame, event: string, handler: function?)
---@field GetScript fun(self: frame, event: string) : function
---@field SetFrameStrata fun(self: frame, strata: framestrata)
---@field SetFrameLevel fun(self: frame, level: number)
@@ -342,8 +368,8 @@
---@field SetMovable fun(self: frame, movable: boolean)
---@field SetUserPlaced fun(self: frame, userPlaced: boolean)
---@field SetBackdrop fun(self: frame, backdrop: backdrop|table)
---@field SetBackdropColor fun(self: frame, red: red|number, green: green|number, blue: blue|number, alpha: alpha|number)
---@field SetBackdropBorderColor fun(self: frame, red: red|number, green: green|number, blue: blue|number, alpha: alpha|number)
---@field SetBackdropColor fun(self: frame, red: red|number, green: green|number, blue: blue|number, alpha: alpha|number?)
---@field SetBackdropBorderColor fun(self: frame, red: red|number, green: green|number, blue: blue|number, alpha: alpha|number?)
---@field GetBackdrop fun(self: frame) : backdrop
---@field GetBackdropColor fun(self: frame) : red|number, green|number, blue|number, alpha|number
---@field GetBackdropBorderColor fun(self: frame) : red|number, green|number, blue|number, alpha|number
@@ -353,7 +379,7 @@
---@field SetPropagateGamepadInput fun(self: frame, propagate: boolean)
---@field StartMoving fun(self: frame)
---@field IsMovable fun(self: frame) : boolean
---@field StartSizing fun(self: frame, sizingpoint: sizingpoint|nil)
---@field StartSizing fun(self: frame, sizingpoint: sizingpoint?)
---@field StopMovingOrSizing fun(self: frame)
---@field GetAttribute fun(self: frame, name: string) : any
---@field GetFrameLevel fun(self: frame) : number
@@ -364,15 +390,17 @@
---@field GetName fun(self: frame) : string
---@field GetChildren fun(self: frame) : frame[]
---@field GetRegions fun(self: frame) : region[]
---@field CreateTexture fun(self: frame, name: string|nil, layer: drawlayer, inherits: string|nil, subLayer: number|nil) : texture
---@field CreateMaskTexture fun(self: frame, name: string|nil, layer: drawlayer, inherits: string|nil, subLayer: number|nil) : texture
---@field CreateFontString fun(self: frame, name: string|nil, layer: drawlayer, inherits: string|nil, subLayer: number|nil) : fontstring
---@field CreateTexture fun(self: frame, name: string?, layer: drawlayer, inherits: string?, subLayer: number?) : texture
---@field CreateMaskTexture fun(self: frame, name: string?, layer: drawlayer, inherits: string?, subLayer: number?) : texture
---@field CreateFontString fun(self: frame, name: string?, layer: drawlayer, inherits: string?, subLayer: number?) : fontstring
---@field EnableMouse fun(self: frame, enable: boolean) enable mouse interaction
---@field SetResizable fun(self: frame, enable: boolean) enable resizing of the frame
---@field EnableMouseWheel fun(self: frame, enable: boolean) enable mouse wheel scrolling
---@field RegisterForDrag fun(self: frame, button: string) register the frame for drag events, allowing it to be dragged by the mouse
---@field SetResizeBounds fun(self: frame, minWidth: number, minHeight: number, maxWidth: number, maxHeight: number) set the minimum and maximum size of the frame
---@field RegisterEvent fun(self: frame, event: string) register for an event, trigers "OnEvent" script when the event is fired
---@field RegisterUnitEvent fun(self: frame, event: string, unitId: unit) register for an event, trigers "OnEvent" only if the event occurred for the registered unit
---@field UnregisterEvent fun(self: frame, event: string) unregister for an event
---@field HookScript fun(self: frame, event: string, handler: function) run a function after the frame's script has been executed, carrying the same arguments
---@class button : frame
@@ -389,20 +417,20 @@
---@field GetText fun(self: button) : string
---@field SetTextInsets fun(self: button, left: number, right: number, top: number, bottom: number)
---@field GetTextInsets fun(self: button) : number, number, number, number
---@field SetDisabledTextColor fun(self: button, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetDisabledTextColor fun(self: button, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field GetDisabledTextColor fun(self: button) : number, number, number, number
---@field SetFontString fun(self: button, fontString: fontstring)
---@field GetFontString fun(self: button) : fontstring
---@field SetButtonState fun(self: button, state: string, enable: boolean)
---@field GetButtonState fun(self: button, state: string) : boolean
---@field RegisterForClicks fun(self: button, button1: nil|buttontype, button2: nil|buttontype, button3: nil|buttontype, button4: nil|buttontype)
---@field RegisterForClicks fun(self: button, button1: buttontype?, button2: buttontype?, button3: buttontype?, button4: buttontype?)
---@field GetNormalTexture fun(self: button) : texture
---@field GetPushedTexture fun(self: button) : texture
---@field GetHighlightTexture fun(self: button) : texture
---@field GetDisabledTexture fun(self: button) : texture
---@class statusbar : frame
---@field SetStatusBarColor fun(self: statusbar, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetStatusBarColor fun(self: statusbar, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field SetStatusBarTexture fun(self: statusbar, path: string|texture)
---@field GetStatusBarTexture fun(self: statusbar) : texture
---@field SetMinMaxValues fun(self: statusbar, minValue: number, maxValue: number)
@@ -429,17 +457,17 @@
---@class region : uiobject
---@class fontstring : region
---@field SetDrawLayer fun(self: fontstring, layer: drawlayer, subLayer: number|nil)
---@field SetDrawLayer fun(self: fontstring, layer: drawlayer, subLayer: number?)
---@field SetFont fun(self: fontstring, font: string, size: number, flags: string)
---@field SetText fun(self: fontstring, text: string|number)
---@field GetText fun(self: fontstring) : string
---@field GetFont fun(self: fontstring) : string, number, string
---@field GetStringWidth fun(self: fontstring) : number return the width of the string in pixels
---@field SetShadowColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetShadowColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field GetShadowColor fun(self: fontstring) : number, number, number, number
---@field SetShadowOffset fun(self: fontstring, offsetX: number, offsetY: number)
---@field GetShadowOffset fun(self: fontstring) : number, number
---@field SetTextColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetTextColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field GetTextColor fun(self: fontstring) : number, number, number, number
---@field SetJustifyH fun(self: fontstring, justifyH: justifyh)
---@field GetJustifyH fun(self: fontstring) : string
@@ -463,11 +491,11 @@
---@field GetTextInsets fun(self: fontstring) : number, number, number, number
---@field SetTextJustification fun(self: fontstring, justifyH: string, justifyV: string)
---@field GetTextJustification fun(self: fontstring) : string, string
---@field SetTextShadowColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetTextShadowColor fun(self: fontstring, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field GetTextShadowColor fun(self: fontstring) : number, number, number, number
---@field SetTextShadowOffset fun(self: fontstring, offsetX: number, offsetY: number)
---@field GetTextShadowOffset fun(self: fontstring) : number, number
---@field SetTextShadow fun(self: fontstring, offsetX: number, offsetY: number, r: red|number, g: green|number, b: blue|number, a: alpha|number)
---@field SetTextShadow fun(self: fontstring, offsetX: number, offsetY: number, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field SetTextTruncate fun(self: fontstring, truncate: string)
---@field GetTextTruncate fun(self: fontstring) : string
---@field SetTextTruncateWidth fun(self: fontstring, width: number)
@@ -476,13 +504,14 @@
---@field GetTextTruncateLines fun(self: fontstring) : number
---@class texture : region
---@field SetDrawLayer fun(self: texture, layer: drawlayer, subLayer: number|nil)
---@field SetTexture fun(self: texture, path: textureid|texturepath, horizontalWrap: texturewrap|nil, verticalWrap: texturewrap|nil, filter: texturefilter|nil)
---@field SetDrawLayer fun(self: texture, layer: drawlayer, subLayer: number?)
---@field SetTexture fun(self: texture, path: textureid|texturepath, horizontalWrap: texturewrap?, verticalWrap: texturewrap?, filter: texturefilter?)
---@field SetAtlas fun(self: texture, atlas: string)
---@field SetColorTexture fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number|nil)
---@field SetColorTexture fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field SetDesaturated fun(self: texture, desaturate: boolean)
---@field SetDesaturation fun(self: texture, desaturation: number)
---@field SetBlendMode fun(self: texture, mode: blendmode)
---@field SetVertexColor fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number|nil)
---@field SetVertexColor fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field GetPoint fun(self: texture, index: number) : string, table, string, number, number
---@field SetShown fun(self: texture, state: boolean)
---@field IsShown fun(self: texture) : boolean
+2 -2
View File
@@ -13,8 +13,8 @@
local addonName, Details222 = ...
local version, build, date, tocversion = GetBuildInfo()
Details.build_counter = 11856
Details.alpha_build_counter = 11856 --if this is higher than the regular counter, use it instead
Details.build_counter = 11857
Details.alpha_build_counter = 11857 --if this is higher than the regular counter, use it instead
Details.dont_open_news = true
Details.game_version = version
Details.userversion = version .. " " .. Details.build_counter
+22 -22
View File
@@ -20,31 +20,31 @@ end
function Details:Dump (...)
if (not DetailsDumpFrame) then
DetailsDumpFrame = DetailsFramework:CreateSimplePanel(_G.UIParent)
DetailsDumpFrame:SetSize(700, 600)
DetailsDumpFrame:SetSize(700, 800)
DetailsDumpFrame:SetTitle("Details! Dump Table [|cFFFF3333Ready Only|r]")
local text_editor = DetailsFramework:NewSpecialLuaEditorEntry(DetailsDumpFrame, 680, 560, "Editbox", "$parentEntry", true)
local text_editor = DetailsFramework:NewSpecialLuaEditorEntry(DetailsDumpFrame, 680, 760, "Editbox", "$parentEntry", true)
text_editor:SetPoint("topleft", DetailsDumpFrame, "topleft", 10, -30)
text_editor.scroll:SetBackdrop(nil)
text_editor.editbox:SetBackdrop(nil)
text_editor:SetBackdrop(nil)
DetailsFramework:ReskinSlider(text_editor.scroll)
if (not text_editor.__background) then
text_editor.__background = text_editor:CreateTexture(nil, "background")
end
text_editor:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
text_editor:SetBackdropBorderColor(0, 0, 0, 1)
text_editor.__background:SetColorTexture(0.2317647, 0.2317647, 0.2317647)
text_editor.__background:SetVertexColor(0.27, 0.27, 0.27)
text_editor.__background:SetAlpha(0.8)
text_editor.__background:SetVertTile(true)
text_editor.__background:SetHorizTile(true)
text_editor.__background:SetAllPoints()
text_editor.__background:SetAllPoints()
end
local t = select(1, ...)
@@ -83,33 +83,33 @@ function Details:ShowImportWindow (defaultText, confirmFunc, titleText)
importWindow:SetFrameStrata("FULLSCREEN")
importWindow:SetPoint("center")
DetailsFramework:ApplyStandardBackdrop(importWindow, false, 1.2)
local importTextEditor = DetailsFramework:NewSpecialLuaEditorEntry(importWindow, 780, 540, "ImportEditor", "$parentEditor", true)
importTextEditor:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
importTextEditor:SetBackdropColor(.2, .2, .2, .5)
importTextEditor:SetBackdropBorderColor(0, 0, 0, 1)
importTextEditor:SetPoint("topleft", importWindow, "topleft", 10, -30)
importTextEditor.scroll:SetBackdrop(nil)
importTextEditor.editbox:SetBackdrop(nil)
importTextEditor:SetBackdrop(nil)
DetailsFramework:ReskinSlider(importTextEditor.scroll)
if (not importTextEditor.__background) then
importTextEditor.__background = importTextEditor:CreateTexture(nil, "background")
end
importTextEditor:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
importTextEditor:SetBackdropBorderColor(0, 0, 0, 1)
importTextEditor.__background:SetColorTexture(0.2317647, 0.2317647, 0.2317647)
importTextEditor.__background:SetVertexColor(0.27, 0.27, 0.27)
importTextEditor.__background:SetAlpha(0.8)
importTextEditor.__background:SetVertTile(true)
importTextEditor.__background:SetHorizTile(true)
importTextEditor.__background:SetAllPoints()
importTextEditor.__background:SetAllPoints()
--import button
local onClickImportButton = function()
if (_G.DetailsExportWindow.ConfirmFunction) then
@@ -120,23 +120,23 @@ function Details:ShowImportWindow (defaultText, confirmFunc, titleText)
local okayButton = DetailsFramework:CreateButton(importTextEditor, onClickImportButton, 120, 20, "Okay", -1, nil, nil, nil, nil, nil, Details.gump:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), Details.gump:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) --localize-me
okayButton:SetIcon ([[Interface\BUTTONS\UI-Panel-BiggerButton-Up]], 20, 20, "overlay", {0.1, .9, 0.1, .9})
importTextEditor.OkayButton = okayButton
--cancel button
local cancelButton = DetailsFramework:CreateButton(importTextEditor, function() importWindow:Hide() end, 120, 20, "Cancel", -1, nil, nil, nil, nil, nil, Details.gump:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), Details.gump:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) --localize-me
cancelButton:SetIcon ([[Interface\BUTTONS\UI-Panel-MinimizeButton-Up]], 20, 20, "overlay", {0.1, .9, 0.1, .9})
okayButton:SetPoint("topright", importTextEditor, "bottomright", 0, -10)
cancelButton:SetPoint("right", okayButton, "left", -20, 0)
end
_G.DetailsExportWindow.ConfirmFunction = confirmFunc
_G.DetailsExportWindow.ImportEditor:SetText(defaultText or "")
_G.DetailsExportWindow:Show()
titleText = titleText or "Details! Dump String"
_G.DetailsExportWindow.Title:SetText(titleText)
C_Timer.After(.2, function()
_G.DetailsExportWindow.ImportEditor:SetFocus(true)
_G.DetailsExportWindow.ImportEditor.editbox:HighlightText (0)