Framework Update and Code improvements
This commit is contained in:
+288
-75
@@ -1,26 +1,27 @@
|
||||
|
||||
local DF = _G["DetailsFramework"]
|
||||
local detailsFramework = _G["DetailsFramework"]
|
||||
|
||||
if (not DF or not DetailsFrameworkCanLoad) then
|
||||
if (not detailsFramework or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
local _
|
||||
local unpack = unpack
|
||||
local emptyFunction = function() end
|
||||
local APIButtonFunctions = false
|
||||
|
||||
do
|
||||
local metaPrototype = {
|
||||
WidgetType = "button",
|
||||
dversion = DF.dversion
|
||||
dversion = detailsFramework.dversion
|
||||
}
|
||||
|
||||
--check if there's a metaPrototype already existing
|
||||
if (_G[DF.GlobalWidgetControlNames["button"]]) then
|
||||
if (_G[detailsFramework.GlobalWidgetControlNames["button"]]) then
|
||||
--get the already existing metaPrototype
|
||||
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["button"]]
|
||||
local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames["button"]]
|
||||
--check if is older
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
|
||||
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then
|
||||
--the version is older them the currently loading one
|
||||
--copy the new values into the old metatable
|
||||
for funcName, _ in pairs(metaPrototype) do
|
||||
@@ -29,23 +30,23 @@ do
|
||||
end
|
||||
else
|
||||
--first time loading the framework
|
||||
_G[DF.GlobalWidgetControlNames["button"]] = metaPrototype
|
||||
_G[detailsFramework.GlobalWidgetControlNames["button"]] = metaPrototype
|
||||
end
|
||||
end
|
||||
|
||||
local ButtonMetaFunctions = _G[DF.GlobalWidgetControlNames["button"]]
|
||||
local ButtonMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames["button"]]
|
||||
|
||||
DF:Mixin(ButtonMetaFunctions, DF.SetPointMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.FrameMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.TooltipHandlerMixin)
|
||||
DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.SetPointMixin)
|
||||
detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.FrameMixin)
|
||||
detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.TooltipHandlerMixin)
|
||||
detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--metatables
|
||||
|
||||
ButtonMetaFunctions.__call = function(self)
|
||||
local frameWidget = self.widget
|
||||
DF:CoreDispatch((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
|
||||
detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
@@ -194,18 +195,18 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
--text color
|
||||
local smember_textcolor = function(object, value)
|
||||
local value1, value2, value3, value4 = DF:ParseColors(value)
|
||||
local value1, value2, value3, value4 = detailsFramework:ParseColors(value)
|
||||
return object.button.text:SetTextColor(value1, value2, value3, value4)
|
||||
end
|
||||
|
||||
--text font
|
||||
local smember_textfont = function(object, value)
|
||||
return DF:SetFontFace (object.button.text, value)
|
||||
return detailsFramework:SetFontFace (object.button.text, value)
|
||||
end
|
||||
|
||||
--text size
|
||||
local smember_textsize = function(object, value)
|
||||
return DF:SetFontSize(object.button.text, value)
|
||||
return detailsFramework:SetFontSize(object.button.text, value)
|
||||
end
|
||||
|
||||
--texture
|
||||
@@ -331,7 +332,7 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
---set the color of the button text
|
||||
---@param ... any
|
||||
function ButtonMetaFunctions:SetTextColor(...)
|
||||
local red, green, blue, alpha = DF:ParseColors(...)
|
||||
local red, green, blue, alpha = detailsFramework:ParseColors(...)
|
||||
self.button.text:SetTextColor(red, green, blue, alpha)
|
||||
end
|
||||
ButtonMetaFunctions.SetFontColor = ButtonMetaFunctions.SetTextColor --alias
|
||||
@@ -339,13 +340,13 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
---set the size of the button text
|
||||
---@param ... number
|
||||
function ButtonMetaFunctions:SetFontSize(...)
|
||||
DF:SetFontSize(self.button.text, ...)
|
||||
detailsFramework:SetFontSize(self.button.text, ...)
|
||||
end
|
||||
|
||||
---set the font into the button text
|
||||
---@param font string
|
||||
function ButtonMetaFunctions:SetFontFace(font)
|
||||
DF:SetFontFace(self.button.text, font)
|
||||
detailsFramework:SetFontFace(self.button.text, font)
|
||||
end
|
||||
|
||||
---comment
|
||||
@@ -425,14 +426,14 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
if (isAtlas) then
|
||||
self.icon:SetAtlas(texture)
|
||||
|
||||
elseif (DF:IsHtmlColor(texture)) then
|
||||
local r, g, b, a = DF:ParseColors(texture)
|
||||
elseif (detailsFramework:IsHtmlColor(texture)) then
|
||||
local r, g, b, a = detailsFramework:ParseColors(texture)
|
||||
self.icon:SetColorTexture(r, g, b, a)
|
||||
else
|
||||
self.icon:SetTexture(texture)
|
||||
end
|
||||
elseif (type(texture) == "table") then
|
||||
local r, g, b, a = DF:ParseColors(texture)
|
||||
local r, g, b, a = detailsFramework:ParseColors(texture)
|
||||
self.icon:SetColorTexture(r, g, b, a)
|
||||
else
|
||||
self.icon:SetTexture(texture)
|
||||
@@ -449,7 +450,7 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
if (overlay) then
|
||||
if (type(overlay) == "string") then
|
||||
local r, g, b, a = DF:ParseColors(overlay)
|
||||
local r, g, b, a = detailsFramework:ParseColors(overlay)
|
||||
self.icon:SetVertexColor(r, g, b, a)
|
||||
else
|
||||
self.icon:SetVertexColor(unpack(overlay))
|
||||
@@ -476,7 +477,7 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
loop = false
|
||||
break
|
||||
else
|
||||
DF:SetFontSize(self.button.text, textSize)
|
||||
detailsFramework:SetFontSize(self.button.text, textSize)
|
||||
textWidth = self.button.text:GetStringWidth()
|
||||
textSize = textSize - 1
|
||||
end
|
||||
@@ -506,25 +507,25 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
---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)
|
||||
detailsFramework: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)
|
||||
detailsFramework: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)
|
||||
detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2)
|
||||
end
|
||||
|
||||
--custom textures
|
||||
function ButtonMetaFunctions:InstallCustomTexture()
|
||||
--function deprecated, now just set a the standard template
|
||||
self:SetTemplate(DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
self:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
@@ -649,8 +650,8 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
|
||||
button.mouse_down = GetTime()
|
||||
local x, y = GetCursorPosition()
|
||||
button.x = floor(x)
|
||||
button.y = floor(y)
|
||||
button.x = math.floor(x)
|
||||
button.y = math.floor(y)
|
||||
|
||||
if (not object.container.isLocked and object.container:IsMovable()) then
|
||||
if (not button.isLocked and button:IsMovable()) then
|
||||
@@ -662,9 +663,9 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
if (object.options.OnGrab) then
|
||||
if (type(object.options.OnGrab) == "string" and object.options.OnGrab == "PassClick") then
|
||||
if (buttontype == "LeftButton") then
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.func, button, buttontype, object.param1, object.param2)
|
||||
detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.func, button, buttontype, object.param1, object.param2)
|
||||
else
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.funcright, button, buttontype, object.param1, object.param2)
|
||||
detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.funcright, button, buttontype, object.param1, object.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -727,16 +728,16 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
end
|
||||
|
||||
local x, y = GetCursorPosition()
|
||||
x = floor(x)
|
||||
y = floor(y)
|
||||
x = math.floor(x)
|
||||
y = math.floor(y)
|
||||
|
||||
button.mouse_down = button.mouse_down or 0 --avoid issues when the button was pressed while disabled and release when enabled
|
||||
|
||||
if ((x == button.x and y == button.y) or (button.mouse_down + 0.5 > GetTime() and button:IsMouseOver())) then
|
||||
if (buttonType == "LeftButton") then
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.func, button, buttonType, object.param1, object.param2)
|
||||
detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.func, button, buttonType, object.param1, object.param2)
|
||||
else
|
||||
DF:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.funcright, button, buttonType, object.param1, object.param2)
|
||||
detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.funcright, button, buttonType, object.param1, object.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -749,11 +750,11 @@ DF:Mixin(ButtonMetaFunctions, DF.ScriptHookMixin)
|
||||
---@param template table
|
||||
function ButtonMetaFunctions:SetTemplate(template)
|
||||
if (type(template) == "string") then
|
||||
template = DF:GetTemplate("button", template)
|
||||
template = detailsFramework:GetTemplate("button", template)
|
||||
end
|
||||
|
||||
if (not template) then
|
||||
DF:Error("template not found")
|
||||
detailsFramework:Error("template not found")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -770,34 +771,34 @@ function ButtonMetaFunctions:SetTemplate(template)
|
||||
end
|
||||
|
||||
if (template.backdropcolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.backdropcolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.backdropcolor)
|
||||
self:SetBackdropColor(r, g, b, a)
|
||||
self.onleave_backdrop = {r, g, b, a}
|
||||
end
|
||||
|
||||
if (template.backdropbordercolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.backdropbordercolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.backdropbordercolor)
|
||||
self:SetBackdropBorderColor(r, g, b, a)
|
||||
self.onleave_backdrop_border_color = {r, g, b, a}
|
||||
end
|
||||
|
||||
if (template.onentercolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.onentercolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.onentercolor)
|
||||
self.onenter_backdrop = {r, g, b, a}
|
||||
end
|
||||
|
||||
if (template.onleavecolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.onleavecolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.onleavecolor)
|
||||
self.onleave_backdrop = {r, g, b, a}
|
||||
end
|
||||
|
||||
if (template.onenterbordercolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.onenterbordercolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.onenterbordercolor)
|
||||
self.onenter_backdrop_border_color = {r, g, b, a}
|
||||
end
|
||||
|
||||
if (template.onleavebordercolor) then
|
||||
local r, g, b, a = DF:ParseColors(template.onleavebordercolor)
|
||||
local r, g, b, a = detailsFramework:ParseColors(template.onleavebordercolor)
|
||||
self.onleave_backdrop_border_color = {r, g, b, a}
|
||||
end
|
||||
|
||||
@@ -842,7 +843,7 @@ end
|
||||
self.text:SetJustifyH("CENTER")
|
||||
self.text:SetPoint("CENTER", self, "CENTER", 0, 0)
|
||||
self:SetFontString(self.text)
|
||||
DF:SetFontSize(self.text, 10)
|
||||
detailsFramework:SetFontSize(self.text, 10)
|
||||
|
||||
self.texture_disabled = self:CreateTexture("$parent_TextureDisabled", "OVERLAY")
|
||||
self.texture_disabled:SetAllPoints()
|
||||
@@ -853,6 +854,36 @@ end
|
||||
self:SetScript("OnEnable", onEnableFunc)
|
||||
end
|
||||
|
||||
---@class df_button : button
|
||||
---@field tooltip string
|
||||
---@field shown boolean
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field text string
|
||||
---@field clickfunction function
|
||||
---@field texture string
|
||||
---@field locked boolean
|
||||
---@field fontcolor any
|
||||
---@field fontface string
|
||||
---@field fontsize number
|
||||
---@field textcolor any
|
||||
---@field textfont string
|
||||
---@field textsize number
|
||||
---@field SetTemplate fun(self: df_button, template: table) set the button visual by a template
|
||||
---@field RightClick fun(self: df_button) right click the button executing its right click function
|
||||
---@field Exec fun(self: df_button) execute the button function for the left button
|
||||
---@field Disable fun(self: df_button) disable the button
|
||||
---@field Enable fun(self: df_button) enable the button
|
||||
---@field IsEnabled fun(self: df_button) : boolean returns true if the button is enabled
|
||||
---@field SetIcon fun(self: df_button,texture: string, width: number|nil, height: number|nil, layout: string|nil, texcoord: table|nil, overlay: table|nil, textDistance: number|nil, leftPadding: number|nil, textHeight: number|nil, shortMethod: any|nil)
|
||||
---@field GetIconTexture fun(self: df_button) : string returns the texture path of the button icon
|
||||
---@field SetTexture fun(self: df_button, normalTexture: string, highlightTexture: string, pressedTexture: string, disabledTexture: string) set the regular button textures
|
||||
---@field SetFontFace fun(self: df_button, font: string) set the button font
|
||||
---@field SetFontSize fun(self: df_button, size: number) set the button font size
|
||||
---@field SetTextColor fun(self: df_button, color: any) set the button text color
|
||||
---@field SetText fun(self: df_button, text: string) set the button text
|
||||
---@field SetClickFunction fun(self: df_button, func: function, param1: any, param2: any, clickType: "left"|"right"|nil)
|
||||
|
||||
---create a Details Framework button
|
||||
---@param parent table
|
||||
---@param func function
|
||||
@@ -867,22 +898,23 @@ end
|
||||
---@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)
|
||||
---@return df_button
|
||||
function detailsFramework:CreateButton(parent, func, width, height, text, param1, param2, texture, member, name, shortMethod, buttonTemplate, textTemplate)
|
||||
return detailsFramework:NewButton(parent, parent, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate)
|
||||
end
|
||||
|
||||
function DF:NewButton(parent, container, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate)
|
||||
---@return df_button
|
||||
function detailsFramework:NewButton(parent, container, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate)
|
||||
if (not name) then
|
||||
name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter
|
||||
DF.ButtonCounter = DF.ButtonCounter + 1
|
||||
name = "DetailsFrameworkButtonNumber" .. detailsFramework.ButtonCounter
|
||||
detailsFramework.ButtonCounter = detailsFramework.ButtonCounter + 1
|
||||
|
||||
elseif (not parent) then
|
||||
return error("Details! FrameWork: parent not found.", 2)
|
||||
error("Details! FrameWork: parent not found.", 2)
|
||||
end
|
||||
|
||||
if (name:find("$parent")) then
|
||||
local parentName = DF.GetParentName(parent)
|
||||
local parentName = detailsFramework.GetParentName(parent)
|
||||
name = name:gsub("$parent", parentName)
|
||||
end
|
||||
|
||||
@@ -904,7 +936,7 @@ end
|
||||
buttonObject.options = {OnGrab = false}
|
||||
|
||||
buttonObject.button = CreateFrame("button", name, parent, "BackdropTemplate")
|
||||
DF:Mixin(buttonObject.button, DF.WidgetFunctions)
|
||||
detailsFramework:Mixin(buttonObject.button, detailsFramework.WidgetFunctions)
|
||||
|
||||
createButtonWidgets(buttonObject.button)
|
||||
buttonObject.button:SetSize(width or 100, height or 20)
|
||||
@@ -934,7 +966,7 @@ end
|
||||
buttonObject.button:SetHighlightTexture(texture, "ADD")
|
||||
|
||||
local locTable = text
|
||||
DF.Language.SetTextWithLocTableWithDefault(buttonObject.button.text, locTable, text)
|
||||
detailsFramework.Language.SetTextWithLocTableWithDefault(buttonObject.button.text, locTable, text)
|
||||
|
||||
buttonObject.button.text:SetPoint("center", buttonObject.button, "center")
|
||||
|
||||
@@ -954,7 +986,7 @@ end
|
||||
loop = false
|
||||
break
|
||||
else
|
||||
DF:SetFontSize(buttonObject.button.text, textsize)
|
||||
detailsFramework:SetFontSize(buttonObject.button.text, textsize)
|
||||
textWidth = buttonObject.button.text:GetStringWidth()
|
||||
textsize = textsize - 1
|
||||
end
|
||||
@@ -972,18 +1004,18 @@ end
|
||||
|
||||
if (textTemplate) then
|
||||
if (textTemplate.size) then
|
||||
DF:SetFontSize(buttonObject.button.text, textTemplate.size)
|
||||
detailsFramework:SetFontSize(buttonObject.button.text, textTemplate.size)
|
||||
end
|
||||
|
||||
if (textTemplate.color) then
|
||||
local r, g, b, a = DF:ParseColors(textTemplate.color)
|
||||
local r, g, b, a = detailsFramework:ParseColors(textTemplate.color)
|
||||
buttonObject.button.text:SetTextColor(r, g, b, a)
|
||||
end
|
||||
|
||||
if (textTemplate.font) then
|
||||
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
||||
local font = SharedMedia:Fetch("font", textTemplate.font)
|
||||
DF:SetFontFace(buttonObject.button.text, font)
|
||||
detailsFramework:SetFontFace(buttonObject.button.text, font)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1015,24 +1047,23 @@ end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--color picker button
|
||||
|
||||
local pickcolorCallback = function(self, red, green, blue, alpha, button)
|
||||
alpha = abs(alpha - 1)
|
||||
alpha = math.abs(alpha - 1)
|
||||
button.MyObject.color_texture:SetVertexColor(red, green, blue, alpha)
|
||||
|
||||
--safecall
|
||||
DF:CoreDispatch((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, red, green, blue, alpha)
|
||||
detailsFramework:CoreDispatch((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, red, green, blue, alpha)
|
||||
button.MyObject:RunHooksForWidget("OnColorChanged", button.MyObject, red, green, blue, alpha)
|
||||
end
|
||||
|
||||
local pickcolor = function(self)
|
||||
local red, green, blue, alpha = self.MyObject.color_texture:GetVertexColor()
|
||||
alpha = abs(alpha - 1)
|
||||
DF:ColorPick(self, red, green, blue, alpha, pickcolorCallback)
|
||||
alpha = math.abs(alpha - 1)
|
||||
detailsFramework:ColorPick(self, red, green, blue, alpha, pickcolorCallback)
|
||||
end
|
||||
|
||||
local setColorPickColor = function(button, ...)
|
||||
local red, green, blue, alpha = DF:ParseColors(...)
|
||||
local red, green, blue, alpha = detailsFramework:ParseColors(...)
|
||||
button.color_texture:SetVertexColor(red, green, blue, alpha)
|
||||
end
|
||||
|
||||
@@ -1052,13 +1083,13 @@ end
|
||||
---@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)
|
||||
function detailsFramework:CreateColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
|
||||
return detailsFramework:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
|
||||
end
|
||||
|
||||
function DF:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
|
||||
function detailsFramework:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
|
||||
--button
|
||||
local colorPickButton = DF:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate)
|
||||
local colorPickButton = detailsFramework:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate)
|
||||
colorPickButton.color_callback = callback
|
||||
colorPickButton.Cancel = colorpickCancel
|
||||
colorPickButton.SetColor = setColorPickColor
|
||||
@@ -1067,7 +1098,7 @@ end
|
||||
colorPickButton.HookList.OnColorChanged = {}
|
||||
|
||||
if (not buttonTemplate) then
|
||||
colorPickButton:SetTemplate(DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
colorPickButton:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
|
||||
end
|
||||
|
||||
--background showing a grid to indicate the transparency
|
||||
@@ -1079,7 +1110,7 @@ end
|
||||
background:SetAlpha(0.3)
|
||||
|
||||
--texture which shows the texture color
|
||||
local colorTexture = DF:NewImage(colorPickButton, nil, 16, 16, nil, nil, "color_texture", "$parentTex")
|
||||
local colorTexture = detailsFramework:NewImage(colorPickButton, nil, 16, 16, nil, nil, "color_texture", "$parentTex")
|
||||
colorTexture:SetColorTexture(1, 1, 1)
|
||||
colorTexture:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0)
|
||||
colorTexture:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0)
|
||||
@@ -1088,7 +1119,7 @@ end
|
||||
return colorPickButton
|
||||
end
|
||||
|
||||
function DF:SetRegularButtonTexture(button, texture, left, right, top, bottom)
|
||||
function detailsFramework:SetRegularButtonTexture(button, texture, left, right, top, bottom)
|
||||
if (type(left) == "table") then
|
||||
left, right, top, bottom = unpack(left)
|
||||
end
|
||||
@@ -1124,8 +1155,8 @@ end
|
||||
end
|
||||
end
|
||||
|
||||
function DF:SetRegularButtonVertexColor(button, ...)
|
||||
local r, g, b, a = DF:ParseColor(...)
|
||||
function detailsFramework:SetRegularButtonVertexColor(button, ...)
|
||||
local r, g, b, a = detailsFramework:ParseColor(...)
|
||||
local normalTexture = button:GetNormalTexture()
|
||||
local pushedTexture = button:GetPushedTexture()
|
||||
local highlightTexture = button:GetHightlightTexture()
|
||||
@@ -1135,4 +1166,186 @@ end
|
||||
pushedTexture:SetVertexColor(r, g, b, a)
|
||||
highlightTexture:SetVertexColor(r, g, b, a)
|
||||
disabledTexture:SetVertexColor(r, g, b, a)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--tab button
|
||||
|
||||
---@class df_tabbutton : button
|
||||
---@field LeftTexture texture
|
||||
---@field RightTexture texture
|
||||
---@field MiddleTexture texture
|
||||
---@field SelectedTexture texture
|
||||
---@field Text fontstring
|
||||
---@field CloseButton df_closebutton
|
||||
---@field leftTextureName string
|
||||
---@field rightTextureName string
|
||||
---@field middleTextureName string
|
||||
---@field leftTextureSelectedName string
|
||||
---@field rightTextureSelectedName string
|
||||
---@field middleTextureSelectedName string
|
||||
---@field bIsSelected boolean
|
||||
---@field SetText fun(self: df_tabbutton, text: string)
|
||||
---@field SetSelected fun(self: df_tabbutton, selected: boolean)
|
||||
---@field IsSelected fun(self: df_tabbutton): boolean
|
||||
---@field Reset fun(self: df_tabbutton)
|
||||
|
||||
detailsFramework.TabButtonMixin = {
|
||||
---set the text of the tab button
|
||||
---@param self df_tabbutton
|
||||
---@param text string
|
||||
SetText = function(self, text)
|
||||
self.Text:SetText(text)
|
||||
--adjust the width of the tab button to fit the text
|
||||
local fontStringLength = self.Text:GetStringWidth()
|
||||
self:SetWidth(fontStringLength + 20)
|
||||
end,
|
||||
|
||||
---highlight the tab textures to indicate the tab is selected
|
||||
---@param self df_tabbutton
|
||||
---@param selected boolean
|
||||
SetSelected = function(self, selected)
|
||||
self.LeftTexture:SetAtlas(selected and self.leftTextureSelectedName or self.leftTextureName)
|
||||
self.RightTexture:SetAtlas(selected and self.rightTextureSelectedName or self.rightTextureName)
|
||||
self.MiddleTexture:SetAtlas(selected and self.middleTextureSelectedName or self.middleTextureName)
|
||||
self.SelectedTexture:SetShown(selected)
|
||||
self.bIsSelected = selected
|
||||
end,
|
||||
|
||||
---get a boolean representing if the tab is selected
|
||||
---@param self df_tabbutton
|
||||
---@return boolean
|
||||
IsSelected = function(self)
|
||||
return self.bIsSelected
|
||||
end,
|
||||
|
||||
---set all textures to their default values, set the text to an empty string, set the selected state to false
|
||||
---@param self df_tabbutton
|
||||
Reset = function(self)
|
||||
self.LeftTexture:SetAtlas(self.leftTextureName)
|
||||
self.RightTexture:SetAtlas(self.rightTextureName)
|
||||
self.MiddleTexture:SetAtlas(self.middleTextureName)
|
||||
self.Text:SetText("")
|
||||
self.bIsSelected = false
|
||||
self.SelectedTexture:Hide()
|
||||
end,
|
||||
|
||||
}
|
||||
|
||||
---create a button which can be used as a tab button, has textures for left, right, middle and a text
|
||||
---@param parent frame
|
||||
---@param frameName string|nil
|
||||
---@return df_tabbutton
|
||||
function detailsFramework:CreateTabButton(parent, frameName)
|
||||
---@type df_tabbutton
|
||||
local tabButton = CreateFrame("button", frameName, parent)
|
||||
tabButton:SetSize(50, 20)
|
||||
tabButton.bIsSelected = false
|
||||
|
||||
detailsFramework:Mixin(tabButton, detailsFramework.TabButtonMixin)
|
||||
|
||||
tabButton.LeftTexture = tabButton:CreateTexture(nil, "artwork")
|
||||
tabButton.RightTexture = tabButton:CreateTexture(nil, "artwork")
|
||||
tabButton.MiddleTexture = tabButton:CreateTexture(nil, "artwork")
|
||||
tabButton.SelectedTexture = tabButton:CreateTexture(nil, "overlay")
|
||||
tabButton.SelectedTexture:SetBlendMode("ADD")
|
||||
tabButton.SelectedTexture:SetAlpha(0.5)
|
||||
tabButton.SelectedTexture:Hide()
|
||||
tabButton.Text = tabButton:CreateFontString(nil, "overlay", "GameFontNormal")
|
||||
tabButton.CloseButton = detailsFramework:CreateCloseButton(tabButton, "$parentCloseButton")
|
||||
|
||||
tabButton.Text:SetPoint("center", tabButton, "center", 0, 0)
|
||||
tabButton.CloseButton:SetPoint("topright", tabButton, "topright", 0, 0)
|
||||
|
||||
tabButton.LeftTexture:SetPoint("bottomleft", tabButton, "bottomleft", 0, 0)
|
||||
tabButton.LeftTexture:SetPoint("topleft", tabButton, "topleft", 0, 0)
|
||||
|
||||
tabButton.RightTexture:SetPoint("bottomright", tabButton, "bottomright", 0, 0)
|
||||
tabButton.RightTexture:SetPoint("topright", tabButton, "topright", 0, 0)
|
||||
|
||||
tabButton.MiddleTexture:SetPoint("topleft", tabButton.LeftTexture, "topright", 0, 0)
|
||||
tabButton.MiddleTexture:SetPoint("topright", tabButton.RightTexture, "topleft", 0, 0)
|
||||
|
||||
tabButton.SelectedTexture:SetAllPoints(tabButton.MiddleTexture)
|
||||
|
||||
tabButton.leftTextureName = "Options_Tab_Left"
|
||||
tabButton.rightTextureName = "Options_Tab_Right"
|
||||
tabButton.middleTextureName = "Options_Tab_Middle"
|
||||
|
||||
tabButton.leftTextureSelectedName = "Options_Tab_Active_Left"
|
||||
tabButton.rightTextureSelectedName = "Options_Tab_Active_Right"
|
||||
tabButton.middleTextureSelectedName = "Options_Tab_Active_Middle"
|
||||
|
||||
tabButton.LeftTexture:SetAtlas(tabButton.leftTextureName)
|
||||
tabButton.LeftTexture:SetWidth(2)
|
||||
|
||||
tabButton.RightTexture:SetAtlas(tabButton.rightTextureName)
|
||||
tabButton.RightTexture:SetWidth(2)
|
||||
|
||||
tabButton.MiddleTexture:SetAtlas(tabButton.middleTextureName)
|
||||
tabButton.MiddleTexture:SetHeight(20)
|
||||
|
||||
tabButton.SelectedTexture:SetTexture([[Interface\PaperDollInfoFrame\UI-Character-Tab-Highlight-yellow]])
|
||||
|
||||
tabButton.Text:SetText("")
|
||||
|
||||
return tabButton
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--close button
|
||||
|
||||
detailsFramework.CloseButtonMixin = {
|
||||
OnClick = function(self)
|
||||
self:GetParent():Hide()
|
||||
end,
|
||||
OnEnter = function(self)
|
||||
self:GetNormalTexture():SetVertexColor(1, 0, 0)
|
||||
end,
|
||||
OnLeave = function(self)
|
||||
self:GetNormalTexture():SetVertexColor(1, 1, 1)
|
||||
end,
|
||||
}
|
||||
|
||||
---@class df_closebutton : button
|
||||
---@field OnClick fun(self: df_closebutton)
|
||||
---@field OnEnter fun(self: df_closebutton)
|
||||
---@field OnLeave fun(self: df_closebutton)
|
||||
|
||||
---create a close button which when clicked will hide the parent frame
|
||||
---@param parent frame
|
||||
---@param frameName string|nil
|
||||
---@return df_closebutton
|
||||
function detailsFramework:CreateCloseButton(parent, frameName)
|
||||
---@type df_closebutton
|
||||
local closeButton = CreateFrame("button", frameName, parent)
|
||||
closeButton:SetFrameLevel(parent:GetFrameLevel() + 1)
|
||||
closeButton:SetSize(16, 16)
|
||||
|
||||
detailsFramework:Mixin(closeButton, detailsFramework.CloseButtonMixin)
|
||||
|
||||
closeButton:SetNormalTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
|
||||
closeButton:SetHighlightTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
|
||||
closeButton:SetPushedTexture([[Interface\GLUES\LOGIN\Glues-CheckBox-Check]])
|
||||
closeButton:GetNormalTexture():SetDesaturated(true)
|
||||
closeButton:GetHighlightTexture():SetDesaturated(true)
|
||||
closeButton:GetPushedTexture():SetDesaturated(true)
|
||||
|
||||
closeButton:SetAlpha(0.7)
|
||||
closeButton:SetScript("OnClick", closeButton.OnClick)
|
||||
closeButton:SetScript("OnEnter", closeButton.OnEnter)
|
||||
closeButton:SetScript("OnLeave", closeButton.OnLeave)
|
||||
|
||||
return closeButton
|
||||
end
|
||||
|
||||
--[=[
|
||||
--example:
|
||||
local frame = CreateFrame("frame", "MyTestFrameForCloseButton", UIParent)
|
||||
frame:SetSize(200, 200)
|
||||
frame:SetPoint("center", UIParent, "center", 0, 0)
|
||||
|
||||
local closeButton = detailsFramework:CreateCloseButton(frame, "$parentCloseButton")
|
||||
closeButton:SetPoint("topright", frame, "topright", 0, 0)
|
||||
--]=]
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 430
|
||||
local dversion = 436
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary(major, minor)
|
||||
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
|
||||
local detailsFramework = DetailsFramework
|
||||
|
||||
if (not detailsFramework or not DetailsFrameworkCanLoad) then
|
||||
return
|
||||
end
|
||||
|
||||
local unpack = unpack
|
||||
local CreateFrame = CreateFrame
|
||||
local PixelUtil = PixelUtil
|
||||
|
||||
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")
|
||||
|
||||
iconFrame.Texture = iconFrame:CreateTexture(nil, "artwork")
|
||||
PixelUtil.SetPoint(iconFrame.Texture, "topleft", iconFrame, "topleft", 1, -1)
|
||||
PixelUtil.SetPoint(iconFrame.Texture, "bottomright", iconFrame, "bottomright", -1, 1)
|
||||
|
||||
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)
|
||||
|
||||
local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", iconFrame, "CooldownFrameTemplate, BackdropTemplate")
|
||||
cooldownFrame:SetAllPoints()
|
||||
cooldownFrame:EnableMouse(false)
|
||||
cooldownFrame:SetFrameLevel(iconFrame:GetFrameLevel()+1)
|
||||
iconFrame.Cooldown = cooldownFrame
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
self.IconPool[self.NextIcon] = newIconFrame
|
||||
iconFrame = newIconFrame
|
||||
end
|
||||
|
||||
iconFrame:ClearAllPoints()
|
||||
|
||||
local anchor = self.options.anchor
|
||||
local anchorTo = self.NextIcon == 1 and self or self.IconPool[self.NextIcon - 1]
|
||||
local xPadding = self.NextIcon == 1 and self.options.left_padding or self.options.icon_padding or 1
|
||||
local growDirection = self.options.grow_direction
|
||||
|
||||
if (growDirection == 1) then --grow to right
|
||||
if (self.NextIcon == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "left", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "right", xPadding, 0)
|
||||
end
|
||||
|
||||
elseif (growDirection == 2) then --grow to left
|
||||
if (self.NextIcon == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "right", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "left", xPadding, 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
detailsFramework:SetFontColor(iconFrame.CountdownText, self.options.text_color)
|
||||
|
||||
self.NextIcon = self.NextIcon + 1
|
||||
return iconFrame
|
||||
end,
|
||||
|
||||
--adds only if not existing already in the cache
|
||||
AddSpecificIcon = function(self, identifierKey, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff)
|
||||
if (not identifierKey or identifierKey == "") then
|
||||
return
|
||||
end
|
||||
|
||||
if (not self.AuraCache[identifierKey]) then
|
||||
local icon = self:SetIcon(spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff or false)
|
||||
icon.identifierKey = identifierKey
|
||||
self.AuraCache[identifierKey] = true
|
||||
end
|
||||
end,
|
||||
|
||||
SetIcon = function(self, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff, modRate)
|
||||
local actualSpellName, _, spellIcon = GetSpellInfo(spellId)
|
||||
|
||||
if forceTexture then
|
||||
spellIcon = forceTexture
|
||||
end
|
||||
|
||||
spellName = spellName or actualSpellName or "unknown_aura"
|
||||
modRate = modRate or 1
|
||||
|
||||
if (spellIcon) then
|
||||
local iconFrame = self:GetIcon()
|
||||
iconFrame.Texture:SetTexture(spellIcon)
|
||||
iconFrame.Texture:SetTexCoord(unpack(self.options.texcoord))
|
||||
|
||||
if (borderColor) then
|
||||
iconFrame:SetBackdropBorderColor(detailsFramework:ParseColors(borderColor))
|
||||
else
|
||||
iconFrame:SetBackdropBorderColor(0, 0, 0 ,0)
|
||||
end
|
||||
|
||||
if (startTime) then
|
||||
CooldownFrame_Set(iconFrame.Cooldown, startTime, duration, true, true, modRate)
|
||||
|
||||
if (self.options.show_text) then
|
||||
iconFrame.CountdownText:Show()
|
||||
|
||||
local now = GetTime()
|
||||
|
||||
iconFrame.timeRemaining = (startTime + duration - now) / modRate
|
||||
iconFrame.expirationTime = startTime + duration
|
||||
|
||||
local formattedTime = (iconFrame.timeRemaining > 0) and self.options.decimal_timer and iconFrame.parentIconRow.FormatCooldownTimeDecimal(iconFrame.timeRemaining) or iconFrame.parentIconRow.FormatCooldownTime(iconFrame.timeRemaining) or ""
|
||||
iconFrame.CountdownText:SetText(formattedTime)
|
||||
|
||||
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)
|
||||
detailsFramework:SetFontSize(iconFrame.CountdownText, self.options.text_size)
|
||||
detailsFramework:SetFontFace (iconFrame.CountdownText, self.options.text_font)
|
||||
detailsFramework:SetFontOutline (iconFrame.CountdownText, self.options.text_outline)
|
||||
|
||||
if self.options.on_tick_cooldown_update then
|
||||
iconFrame.lastUpdateCooldown = now
|
||||
iconFrame:SetScript("OnUpdate", self.OnIconTick)
|
||||
else
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
else
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
iconFrame.CountdownText:Hide()
|
||||
end
|
||||
|
||||
iconFrame.Cooldown:SetReverse(self.options.cooldown_reverse)
|
||||
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)
|
||||
else
|
||||
iconFrame.timeRemaining = nil
|
||||
iconFrame.expirationTime = nil
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
iconFrame.CountdownText:Hide()
|
||||
end
|
||||
|
||||
if (descText and self.options.desc_text) then
|
||||
iconFrame.Desc:Show()
|
||||
iconFrame.Desc:SetText(descText.text)
|
||||
iconFrame.Desc:SetTextColor(detailsFramework:ParseColors(descText.text_color or self.options.desc_text_color))
|
||||
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)
|
||||
detailsFramework:SetFontSize(iconFrame.Desc, descText.text_size or self.options.desc_text_size)
|
||||
detailsFramework:SetFontFace(iconFrame.Desc, self.options.desc_text_font)
|
||||
detailsFramework:SetFontOutline(iconFrame.Desc, self.options.desc_text_outline)
|
||||
else
|
||||
iconFrame.Desc:Hide()
|
||||
end
|
||||
|
||||
if (count and count > 1 and self.options.stack_text) then
|
||||
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)
|
||||
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)
|
||||
else
|
||||
iconFrame.StackText:Hide()
|
||||
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
|
||||
self.timeRemaining = self.expirationTime - now
|
||||
if self.timeRemaining > 0 then
|
||||
if self.parentIconRow.options.decimal_timer then
|
||||
self.CountdownText:SetText(self.parentIconRow.FormatCooldownTimeDecimal(self.timeRemaining))
|
||||
else
|
||||
self.CountdownText:SetText(self.parentIconRow.FormatCooldownTime(self.timeRemaining))
|
||||
end
|
||||
else
|
||||
self.CountdownText:SetText("")
|
||||
end
|
||||
self.lastUpdateCooldown = now
|
||||
end
|
||||
end,
|
||||
|
||||
FormatCooldownTime = function(formattedTime)
|
||||
if (formattedTime >= 3600) then
|
||||
formattedTime = math.floor(formattedTime / 3600) .. "h"
|
||||
|
||||
elseif (formattedTime >= 60) then
|
||||
formattedTime = math.floor(formattedTime / 60) .. "m"
|
||||
|
||||
else
|
||||
formattedTime = math.floor(formattedTime)
|
||||
end
|
||||
return formattedTime
|
||||
end,
|
||||
|
||||
FormatCooldownTimeDecimal = function(formattedTime)
|
||||
if formattedTime < 10 then
|
||||
return ("%.1f"):format(formattedTime)
|
||||
|
||||
elseif formattedTime < 60 then
|
||||
return ("%d"):format(formattedTime)
|
||||
|
||||
elseif formattedTime < 3600 then
|
||||
return ("%d:%02d"):format(formattedTime/60%60, formattedTime%60)
|
||||
|
||||
elseif formattedTime < 86400 then
|
||||
return ("%dh %02dm"):format(formattedTime/(3600), formattedTime/60%60)
|
||||
|
||||
else
|
||||
return ("%dd %02dh"):format(formattedTime/86400, (formattedTime/3600) - (math.floor(formattedTime/86400) * 24))
|
||||
end
|
||||
end,
|
||||
|
||||
RemoveSpecificIcon = function(self, identifierKey)
|
||||
if (not identifierKey or identifierKey == "") then
|
||||
return
|
||||
end
|
||||
|
||||
table.wipe(self.AuraCache)
|
||||
|
||||
local iconPool = self.IconPool
|
||||
local countStillShown = 0
|
||||
|
||||
for i = 1, self.NextIcon -1 do
|
||||
local iconFrame = iconPool[i]
|
||||
if (iconFrame.identifierKey and iconFrame.identifierKey == identifierKey) then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
iconFrame.identifierKey = nil
|
||||
else
|
||||
self.AuraCache[iconFrame.spellId] = true
|
||||
self.AuraCache[iconFrame.spellName] = true
|
||||
self.AuraCache.canStealOrPurge = self.AuraCache.canStealOrPurge or iconFrame.canStealOrPurge
|
||||
self.AuraCache.hasEnrage = self.AuraCache.hasEnrage or iconFrame.debuffType == "" --yes, enrages are empty-string...
|
||||
countStillShown = countStillShown + 1
|
||||
end
|
||||
end
|
||||
|
||||
self:AlignAuraIcons()
|
||||
end,
|
||||
|
||||
ClearIcons = function(self, resetBuffs, resetDebuffs)
|
||||
resetBuffs = resetBuffs ~= false
|
||||
resetDebuffs = resetDebuffs ~= false
|
||||
table.wipe(self.AuraCache)
|
||||
|
||||
local iconPool = self.IconPool
|
||||
|
||||
for i = 1, self.NextIcon -1 do
|
||||
local iconFrame = iconPool[i]
|
||||
if (iconFrame.isBuff == nil) then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
|
||||
elseif (resetBuffs and iconFrame.isBuff) then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
|
||||
elseif (resetDebuffs and not iconFrame.isBuff) then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
|
||||
else
|
||||
self.AuraCache[iconFrame.spellId] = true
|
||||
self.AuraCache[iconFrame.spellName] = true
|
||||
self.AuraCache.canStealOrPurge = self.AuraCache.canStealOrPurge or iconFrame.canStealOrPurge
|
||||
self.AuraCache.hasEnrage = self.AuraCache.hasEnrage or iconFrame.debuffType == "" --yes, enrages are empty-string...
|
||||
end
|
||||
end
|
||||
|
||||
self:AlignAuraIcons()
|
||||
end,
|
||||
|
||||
AlignAuraIcons = function(self)
|
||||
local iconPool = self.IconPool
|
||||
local iconAmount = #iconPool
|
||||
local countStillShown = 0
|
||||
|
||||
table.sort(iconPool, function(i1, i2) return i1:IsShown() and not i2:IsShown() end)
|
||||
|
||||
if iconAmount == 0 then
|
||||
self:Hide()
|
||||
else
|
||||
--re-anchor not hidden
|
||||
for i = 1, iconAmount do
|
||||
local iconFrame = iconPool[i]
|
||||
local anchor = self.options.anchor
|
||||
local anchorTo = i == 1 and self or self.IconPool[i - 1]
|
||||
local xPadding = i == 1 and self.options.left_padding or self.options.icon_padding or 1
|
||||
local growDirection = self.options.grow_direction
|
||||
|
||||
countStillShown = countStillShown + (iconFrame:IsShown() and 1 or 0)
|
||||
|
||||
iconFrame:ClearAllPoints()
|
||||
if (growDirection == 1) then --grow to right
|
||||
if (i == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "left", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "right", xPadding, 0)
|
||||
end
|
||||
elseif (growDirection == 2) then --grow to left
|
||||
if (i == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "right", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "left", xPadding, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.NextIcon = countStillShown + 1
|
||||
end,
|
||||
|
||||
GetIconGrowDirection = function(self)
|
||||
local side = self.options.anchor.side
|
||||
|
||||
if (side == 1) then
|
||||
return 1
|
||||
elseif (side == 2) then
|
||||
return 2
|
||||
elseif (side == 3) then
|
||||
return 1
|
||||
elseif (side == 4) then
|
||||
return 1
|
||||
elseif (side == 5) then
|
||||
return 2
|
||||
elseif (side == 6) then
|
||||
return 1
|
||||
elseif (side == 7) then
|
||||
return 2
|
||||
elseif (side == 8) then
|
||||
return 1
|
||||
elseif (side == 9) then
|
||||
return 1
|
||||
elseif (side == 10) then
|
||||
return 1
|
||||
elseif (side == 11) then
|
||||
return 2
|
||||
elseif (side == 12) then
|
||||
return 1
|
||||
elseif (side == 13) then
|
||||
return 1
|
||||
end
|
||||
end,
|
||||
|
||||
OnOptionChanged = function(self, optionName)
|
||||
self:SetBackdropColor(unpack(self.options.backdrop_color))
|
||||
self:SetBackdropBorderColor(unpack(self.options.backdrop_border_color))
|
||||
end,
|
||||
}
|
||||
|
||||
local default_icon_row_options = {
|
||||
icon_width = 20,
|
||||
icon_height = 20,
|
||||
texcoord = {.1, .9, .1, .9},
|
||||
show_text = true,
|
||||
text_color = {1, 1, 1, 1},
|
||||
text_size = 12,
|
||||
text_font = "Arial Narrow",
|
||||
text_outline = "NONE",
|
||||
text_anchor = "center",
|
||||
text_rel_anchor = "center",
|
||||
text_x_offset = 0,
|
||||
text_y_offset = 0,
|
||||
desc_text = true,
|
||||
desc_text_color = {1, 1, 1, 1},
|
||||
desc_text_size = 7,
|
||||
desc_text_font = "Arial Narrow",
|
||||
desc_text_outline = "NONE",
|
||||
desc_text_anchor = "bottom",
|
||||
desc_text_rel_anchor = "top",
|
||||
desc_text_x_offset = 0,
|
||||
desc_text_y_offset = 2,
|
||||
stack_text = true,
|
||||
stack_text_color = {1, 1, 1, 1},
|
||||
stack_text_size = 10,
|
||||
stack_text_font = "Arial Narrow",
|
||||
stack_text_outline = "NONE",
|
||||
stack_text_anchor = "center",
|
||||
stack_text_rel_anchor = "bottomright",
|
||||
stack_text_x_offset = 0,
|
||||
stack_text_y_offset = 0,
|
||||
left_padding = 1, --distance between right and left
|
||||
top_padding = 1, --distance between top and bottom
|
||||
icon_padding = 1, --distance between each icon
|
||||
backdrop = {},
|
||||
backdrop_color = {0, 0, 0, 0.5},
|
||||
backdrop_border_color = {0, 0, 0, 1},
|
||||
anchor = {side = 6, x = 2, y = 0},
|
||||
grow_direction = 1, --1 = to right 2 = to left
|
||||
surpress_blizzard_cd_timer = false,
|
||||
surpress_tulla_omni_cc = false,
|
||||
on_tick_cooldown_update = true,
|
||||
decimal_timer = false,
|
||||
cooldown_reverse = false,
|
||||
cooldown_swipe_enabled = true,
|
||||
cooldown_edge_texture = "Interface\\Cooldown\\edge",
|
||||
}
|
||||
|
||||
function detailsFramework:CreateIconRow(parent, name, options)
|
||||
local newIconRowFrame = CreateFrame("frame", name, parent, "BackdropTemplate")
|
||||
newIconRowFrame.IconPool = {}
|
||||
newIconRowFrame.NextIcon = 1
|
||||
newIconRowFrame.AuraCache = {}
|
||||
|
||||
detailsFramework:Mixin(newIconRowFrame, detailsFramework.IconMixin)
|
||||
detailsFramework:Mixin(newIconRowFrame, detailsFramework.OptionsFunctions)
|
||||
|
||||
newIconRowFrame:BuildOptionsTable(default_icon_row_options, options)
|
||||
|
||||
newIconRowFrame:SetSize(newIconRowFrame.options.icon_width, newIconRowFrame.options.icon_height + (newIconRowFrame.options.top_padding * 2))
|
||||
|
||||
newIconRowFrame:SetBackdrop(newIconRowFrame.options.backdrop)
|
||||
newIconRowFrame:SetBackdropColor(unpack(newIconRowFrame.options.backdrop_color))
|
||||
newIconRowFrame:SetBackdropBorderColor(unpack(newIconRowFrame.options.backdrop_border_color))
|
||||
|
||||
return newIconRowFrame
|
||||
end
|
||||
@@ -32,6 +32,7 @@
|
||||
<Include file="normal_bar.xml"/>
|
||||
<Include file="panel.xml"/>
|
||||
|
||||
<Script file="icon.lua"/>
|
||||
<Script file="pictureedit.lua"/>
|
||||
<Script file="auras.lua"/>
|
||||
<Script file="tabcontainer.lua"/>
|
||||
|
||||
+25
-470
@@ -2286,15 +2286,35 @@ end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ~prompt
|
||||
--@dontOverride: won't show another prompt if theres already a shown prompt
|
||||
function detailsFramework:ShowPromptPanel(message, trueCallback, falseCallback, dontOverride, width)
|
||||
function detailsFramework:HidePromptPanel(promptName)
|
||||
if (detailsFramework.promtp_panel) then
|
||||
if (promptName) then
|
||||
if (detailsFramework.promtp_panel.promptName == promptName) then
|
||||
detailsFramework.promtp_panel:Hide()
|
||||
detailsFramework.promtp_panel.promptName = nil
|
||||
end
|
||||
else
|
||||
detailsFramework.promtp_panel:Hide()
|
||||
detailsFramework.promtp_panel.promptName = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---show a prompt to the player with a question (message) and two buttons "yes" and "no"
|
||||
---@param message string the question to show to the player
|
||||
---@param trueCallback function if the player clicks on "yes"
|
||||
---@param falseCallback function if the player clicks on "no"
|
||||
---@param dontOverride boolean|nil if true, won't show another prompt if theres already a shown prompt
|
||||
---@param width number|nil width of the prompt frame, if ommited, will use the default width 400
|
||||
---@param promptName string|nil set a name to the prompt, used on HidePromptPanel(promptName)
|
||||
function detailsFramework:ShowPromptPanel(message, trueCallback, falseCallback, dontOverride, width, promptName)
|
||||
if (not DetailsFrameworkPromptSimple) then
|
||||
local promptFrame = CreateFrame("frame", "DetailsFrameworkPromptSimple", UIParent, "BackdropTemplate")
|
||||
promptFrame:SetSize(400, 80)
|
||||
promptFrame:SetFrameStrata("DIALOG")
|
||||
promptFrame:SetPoint("center", UIParent, "center", 0, 300)
|
||||
detailsFramework:ApplyStandardBackdrop(promptFrame)
|
||||
tinsert(UISpecialFrames, "DetailsFrameworkPromptSimple")
|
||||
table.insert(UISpecialFrames, "DetailsFrameworkPromptSimple")
|
||||
|
||||
detailsFramework:CreateTitleBar(promptFrame, "Prompt!")
|
||||
detailsFramework:ApplyStandardBackdrop(promptFrame)
|
||||
@@ -2375,6 +2395,8 @@ function detailsFramework:ShowPromptPanel(message, trueCallback, falseCallback,
|
||||
detailsFramework.promtp_panel:SetWidth(400)
|
||||
end
|
||||
|
||||
detailsFramework.promtp_panel.promptName = promptName
|
||||
|
||||
detailsFramework.promtp_panel.prompt:SetText(message)
|
||||
detailsFramework.promtp_panel.button_true.true_function = trueCallback
|
||||
detailsFramework.promtp_panel.button_false.false_function = falseCallback
|
||||
@@ -4413,473 +4435,6 @@ function detailsFramework:CreateTitleBar (f, titleText)
|
||||
return titleBar
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ~icon row
|
||||
|
||||
detailsFramework.IconRowFunctions = {
|
||||
|
||||
GetIcon = function(self)
|
||||
local iconFrame = self.IconPool [self.NextIcon]
|
||||
|
||||
if (not iconFrame) then
|
||||
local newIconFrame = CreateFrame("frame", "$parentIcon" .. self.NextIcon, self, "BackdropTemplate")
|
||||
newIconFrame.parentIconRow = self
|
||||
|
||||
newIconFrame.Texture = newIconFrame:CreateTexture(nil, "artwork")
|
||||
PixelUtil.SetPoint(newIconFrame.Texture, "topleft", newIconFrame, "topleft", 1, -1)
|
||||
PixelUtil.SetPoint(newIconFrame.Texture, "bottomright", newIconFrame, "bottomright", -1, 1)
|
||||
|
||||
newIconFrame.Border = newIconFrame:CreateTexture(nil, "background")
|
||||
newIconFrame.Border:SetAllPoints()
|
||||
newIconFrame.Border:SetColorTexture(0, 0, 0)
|
||||
|
||||
newIconFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
|
||||
newIconFrame:SetBackdropBorderColor(0, 0, 0, 0)
|
||||
newIconFrame:EnableMouse(false)
|
||||
|
||||
local cooldownFrame = CreateFrame("cooldown", "$parentIconCooldown" .. self.NextIcon, newIconFrame, "CooldownFrameTemplate, BackdropTemplate")
|
||||
cooldownFrame:SetAllPoints()
|
||||
cooldownFrame:EnableMouse(false)
|
||||
cooldownFrame:SetFrameLevel(newIconFrame:GetFrameLevel()+1)
|
||||
cooldownFrame:SetHideCountdownNumbers (self.options.surpress_blizzard_cd_timer)
|
||||
cooldownFrame.noCooldownCount = self.options.surpress_tulla_omni_cc
|
||||
|
||||
newIconFrame.CountdownText = cooldownFrame:CreateFontString(nil, "overlay", "GameFontNormal")
|
||||
--newIconFrame.CountdownText:SetPoint("center")
|
||||
newIconFrame.CountdownText:SetPoint(self.options.text_anchor or "center", newIconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0)
|
||||
newIconFrame.CountdownText:Hide()
|
||||
|
||||
newIconFrame.StackText = newIconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
|
||||
--newIconFrame.StackText:SetPoint("bottomright")
|
||||
newIconFrame.StackText:SetPoint(self.options.stack_text_anchor or "center", newIconFrame, 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.StackText:Hide()
|
||||
|
||||
newIconFrame.Desc = newIconFrame:CreateFontString(nil, "overlay", "GameFontNormal")
|
||||
--newIconFrame.Desc:SetPoint("bottom", newIconFrame, "top", 0, 2)
|
||||
newIconFrame.Desc:SetPoint(self.options.desc_text_anchor or "bottom", newIconFrame, self.options.desc_text_rel_anchor or "top", self.options.desc_text_x_offset or 0, self.options.desc_text_y_offset or 2)
|
||||
newIconFrame.Desc:Hide()
|
||||
|
||||
newIconFrame.Cooldown = cooldownFrame
|
||||
|
||||
self.IconPool [self.NextIcon] = newIconFrame
|
||||
iconFrame = newIconFrame
|
||||
end
|
||||
|
||||
iconFrame:ClearAllPoints()
|
||||
|
||||
local anchor = self.options.anchor
|
||||
local anchorTo = self.NextIcon == 1 and self or self.IconPool [self.NextIcon - 1]
|
||||
local xPadding = self.NextIcon == 1 and self.options.left_padding or self.options.icon_padding or 1
|
||||
local growDirection = self.options.grow_direction
|
||||
|
||||
if (growDirection == 1) then --grow to right
|
||||
if (self.NextIcon == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "left", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "right", xPadding, 0)
|
||||
end
|
||||
|
||||
elseif (growDirection == 2) then --grow to left
|
||||
if (self.NextIcon == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "right", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "left", xPadding, 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
detailsFramework:SetFontColor(iconFrame.CountdownText, self.options.text_color)
|
||||
|
||||
self.NextIcon = self.NextIcon + 1
|
||||
return iconFrame
|
||||
end,
|
||||
|
||||
--adds only if not existing already in the cache
|
||||
AddSpecificIcon = function(self, identifierKey, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff)
|
||||
if not identifierKey or identifierKey == "" then
|
||||
return
|
||||
end
|
||||
|
||||
if not self.AuraCache[identifierKey] then
|
||||
local icon = self:SetIcon (spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff or false)
|
||||
icon.identifierKey = identifierKey
|
||||
self.AuraCache[identifierKey] = true
|
||||
end
|
||||
end,
|
||||
|
||||
SetIcon = function(self, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff, modRate)
|
||||
|
||||
local actualSpellName, _, spellIcon = GetSpellInfo(spellId)
|
||||
|
||||
if forceTexture then
|
||||
spellIcon = forceTexture
|
||||
end
|
||||
|
||||
spellName = spellName or actualSpellName or "unknown_aura"
|
||||
modRate = modRate or 1
|
||||
|
||||
if (spellIcon) then
|
||||
local iconFrame = self:GetIcon()
|
||||
iconFrame.Texture:SetTexture(spellIcon)
|
||||
iconFrame.Texture:SetTexCoord(unpack(self.options.texcoord))
|
||||
|
||||
if (borderColor) then
|
||||
iconFrame:SetBackdropBorderColor(Plater:ParseColors(borderColor))
|
||||
else
|
||||
iconFrame:SetBackdropBorderColor(0, 0, 0 ,0)
|
||||
end
|
||||
|
||||
if (startTime) then
|
||||
CooldownFrame_Set (iconFrame.Cooldown, startTime, duration, true, true, modRate)
|
||||
|
||||
if (self.options.show_text) then
|
||||
iconFrame.CountdownText:Show()
|
||||
|
||||
local now = GetTime()
|
||||
|
||||
iconFrame.timeRemaining = (startTime + duration - now) / modRate
|
||||
iconFrame.expirationTime = startTime + duration
|
||||
|
||||
local formattedTime = (iconFrame.timeRemaining > 0) and self.options.decimal_timer and iconFrame.parentIconRow.FormatCooldownTimeDecimal(iconFrame.timeRemaining) or iconFrame.parentIconRow.FormatCooldownTime(iconFrame.timeRemaining) or ""
|
||||
iconFrame.CountdownText:SetText(formattedTime)
|
||||
|
||||
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)
|
||||
detailsFramework:SetFontSize(iconFrame.CountdownText, self.options.text_size)
|
||||
detailsFramework:SetFontFace (iconFrame.CountdownText, self.options.text_font)
|
||||
detailsFramework:SetFontOutline (iconFrame.CountdownText, self.options.text_outline)
|
||||
|
||||
if self.options.on_tick_cooldown_update then
|
||||
iconFrame.lastUpdateCooldown = now
|
||||
iconFrame:SetScript("OnUpdate", self.OnIconTick)
|
||||
else
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
else
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
iconFrame.CountdownText:Hide()
|
||||
end
|
||||
|
||||
iconFrame.Cooldown:SetReverse (self.options.cooldown_reverse)
|
||||
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)
|
||||
else
|
||||
iconFrame.timeRemaining = nil
|
||||
iconFrame.expirationTime = nil
|
||||
iconFrame:SetScript("OnUpdate", nil)
|
||||
iconFrame.CountdownText:Hide()
|
||||
end
|
||||
|
||||
if (descText and self.options.desc_text) then
|
||||
iconFrame.Desc:Show()
|
||||
iconFrame.Desc:SetText(descText.text)
|
||||
iconFrame.Desc:SetTextColor(detailsFramework:ParseColors(descText.text_color or self.options.desc_text_color))
|
||||
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)
|
||||
detailsFramework:SetFontSize(iconFrame.Desc, descText.text_size or self.options.desc_text_size)
|
||||
detailsFramework:SetFontFace (iconFrame.Desc, self.options.desc_text_font)
|
||||
detailsFramework:SetFontOutline (iconFrame.Desc, self.options.desc_text_outline)
|
||||
else
|
||||
iconFrame.Desc:Hide()
|
||||
end
|
||||
|
||||
if (count and count > 1 and self.options.stack_text) then
|
||||
iconFrame.StackText:Show()
|
||||
iconFrame.StackText:SetText(count)
|
||||
iconFrame.StackText:SetTextColor(detailsFramework:ParseColors(self.options.desc_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)
|
||||
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)
|
||||
else
|
||||
iconFrame.StackText:Hide()
|
||||
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
|
||||
self.timeRemaining = self.expirationTime - now
|
||||
if self.timeRemaining > 0 then
|
||||
if self.parentIconRow.options.decimal_timer then
|
||||
self.CountdownText:SetText(self.parentIconRow.FormatCooldownTimeDecimal(self.timeRemaining))
|
||||
else
|
||||
self.CountdownText:SetText(self.parentIconRow.FormatCooldownTime(self.timeRemaining))
|
||||
end
|
||||
else
|
||||
self.CountdownText:SetText("")
|
||||
end
|
||||
self.lastUpdateCooldown = now
|
||||
end
|
||||
end,
|
||||
|
||||
FormatCooldownTime = function(formattedTime)
|
||||
if (formattedTime >= 3600) then
|
||||
formattedTime = floor(formattedTime / 3600) .. "h"
|
||||
|
||||
elseif (formattedTime >= 60) then
|
||||
formattedTime = floor(formattedTime / 60) .. "m"
|
||||
|
||||
else
|
||||
formattedTime = floor(formattedTime)
|
||||
end
|
||||
return formattedTime
|
||||
end,
|
||||
|
||||
FormatCooldownTimeDecimal = function(formattedTime)
|
||||
if formattedTime < 10 then
|
||||
return ("%.1f"):format(formattedTime)
|
||||
elseif formattedTime < 60 then
|
||||
return ("%d"):format(formattedTime)
|
||||
elseif formattedTime < 3600 then
|
||||
return ("%d:%02d"):format(formattedTime/60%60, formattedTime%60)
|
||||
elseif formattedTime < 86400 then
|
||||
return ("%dh %02dm"):format(formattedTime/(3600), formattedTime/60%60)
|
||||
else
|
||||
return ("%dd %02dh"):format(formattedTime/86400, (formattedTime/3600) - (floor(formattedTime/86400) * 24))
|
||||
end
|
||||
end,
|
||||
|
||||
RemoveSpecificIcon = function(self, identifierKey)
|
||||
if not identifierKey or identifierKey == "" then
|
||||
return
|
||||
end
|
||||
|
||||
table.wipe(self.AuraCache)
|
||||
|
||||
local iconPool = self.IconPool
|
||||
local countStillShown = 0
|
||||
for i = 1, self.NextIcon -1 do
|
||||
local iconFrame = iconPool[i]
|
||||
if iconFrame.identifierKey and iconFrame.identifierKey == identifierKey then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
iconFrame.identifierKey = nil
|
||||
else
|
||||
self.AuraCache [iconFrame.spellId] = true
|
||||
self.AuraCache [iconFrame.spellName] = true
|
||||
self.AuraCache.canStealOrPurge = self.AuraCache.canStealOrPurge or iconFrame.canStealOrPurge
|
||||
self.AuraCache.hasEnrage = self.AuraCache.hasEnrage or iconFrame.debuffType == "" --yes, enrages are empty-string...
|
||||
countStillShown = countStillShown + 1
|
||||
end
|
||||
end
|
||||
|
||||
self:AlignAuraIcons()
|
||||
|
||||
end,
|
||||
|
||||
ClearIcons = function(self, resetBuffs, resetDebuffs)
|
||||
resetBuffs = resetBuffs ~= false
|
||||
resetDebuffs = resetDebuffs ~= false
|
||||
table.wipe(self.AuraCache)
|
||||
|
||||
local iconPool = self.IconPool
|
||||
for i = 1, self.NextIcon -1 do
|
||||
local iconFrame = iconPool[i]
|
||||
if iconFrame.isBuff == nil then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
elseif resetBuffs and iconFrame.isBuff then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
elseif resetDebuffs and not iconFrame.isBuff then
|
||||
iconFrame:Hide()
|
||||
iconFrame:ClearAllPoints()
|
||||
else
|
||||
self.AuraCache [iconFrame.spellId] = true
|
||||
self.AuraCache [iconFrame.spellName] = true
|
||||
self.AuraCache.canStealOrPurge = self.AuraCache.canStealOrPurge or iconFrame.canStealOrPurge
|
||||
self.AuraCache.hasEnrage = self.AuraCache.hasEnrage or iconFrame.debuffType == "" --yes, enrages are empty-string...
|
||||
end
|
||||
end
|
||||
|
||||
self:AlignAuraIcons()
|
||||
|
||||
end,
|
||||
|
||||
AlignAuraIcons = function(self)
|
||||
|
||||
local iconPool = self.IconPool
|
||||
local iconAmount = #iconPool
|
||||
local countStillShown = 0
|
||||
|
||||
table.sort (iconPool, function(i1, i2) return i1:IsShown() and not i2:IsShown() end)
|
||||
|
||||
if iconAmount == 0 then
|
||||
self:Hide()
|
||||
else
|
||||
-- re-anchor not hidden
|
||||
for i = 1, iconAmount do
|
||||
local iconFrame = iconPool[i]
|
||||
local anchor = self.options.anchor
|
||||
local anchorTo = i == 1 and self or self.IconPool [i - 1]
|
||||
local xPadding = i == 1 and self.options.left_padding or self.options.icon_padding or 1
|
||||
local growDirection = self.options.grow_direction
|
||||
|
||||
countStillShown = countStillShown + (iconFrame:IsShown() and 1 or 0)
|
||||
|
||||
iconFrame:ClearAllPoints()
|
||||
if (growDirection == 1) then --grow to right
|
||||
if (i == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "left", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "right", xPadding, 0)
|
||||
end
|
||||
|
||||
elseif (growDirection == 2) then --grow to left
|
||||
if (i == 1) then
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "right", xPadding, 0)
|
||||
else
|
||||
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "left", xPadding, 0)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.NextIcon = countStillShown + 1
|
||||
|
||||
end,
|
||||
|
||||
GetIconGrowDirection = function(self)
|
||||
local side = self.options.anchor.side
|
||||
|
||||
if (side == 1) then
|
||||
return 1
|
||||
elseif (side == 2) then
|
||||
return 2
|
||||
elseif (side == 3) then
|
||||
return 1
|
||||
elseif (side == 4) then
|
||||
return 1
|
||||
elseif (side == 5) then
|
||||
return 2
|
||||
elseif (side == 6) then
|
||||
return 1
|
||||
elseif (side == 7) then
|
||||
return 2
|
||||
elseif (side == 8) then
|
||||
return 1
|
||||
elseif (side == 9) then
|
||||
return 1
|
||||
elseif (side == 10) then
|
||||
return 1
|
||||
elseif (side == 11) then
|
||||
return 2
|
||||
elseif (side == 12) then
|
||||
return 1
|
||||
elseif (side == 13) then
|
||||
return 1
|
||||
end
|
||||
end,
|
||||
|
||||
OnOptionChanged = function(self, optionName)
|
||||
self:SetBackdropColor(unpack(self.options.backdrop_color))
|
||||
self:SetBackdropBorderColor(unpack(self.options.backdrop_border_color))
|
||||
end,
|
||||
}
|
||||
|
||||
local default_icon_row_options = {
|
||||
icon_width = 20,
|
||||
icon_height = 20,
|
||||
texcoord = {.1, .9, .1, .9},
|
||||
show_text = true,
|
||||
text_color = {1, 1, 1, 1},
|
||||
text_size = 12,
|
||||
text_font = "Arial Narrow",
|
||||
text_outline = "NONE",
|
||||
text_anchor = "center",
|
||||
text_rel_anchor = "center",
|
||||
text_x_offset = 0,
|
||||
text_y_offset = 0,
|
||||
desc_text = true,
|
||||
desc_text_color = {1, 1, 1, 1},
|
||||
desc_text_size = 7,
|
||||
desc_text_font = "Arial Narrow",
|
||||
desc_text_outline = "NONE",
|
||||
desc_text_anchor = "bottom",
|
||||
desc_text_rel_anchor = "top",
|
||||
desc_text_x_offset = 0,
|
||||
desc_text_y_offset = 2,
|
||||
stack_text = true,
|
||||
stack_text_color = {1, 1, 1, 1},
|
||||
stack_text_size = 10,
|
||||
stack_text_font = "Arial Narrow",
|
||||
stack_text_outline = "NONE",
|
||||
stack_text_anchor = "center",
|
||||
stack_text_rel_anchor = "bottomright",
|
||||
stack_text_x_offset = 0,
|
||||
stack_text_y_offset = 0,
|
||||
left_padding = 1, --distance between right and left
|
||||
top_padding = 1, --distance between top and bottom
|
||||
icon_padding = 1, --distance between each icon
|
||||
backdrop = {},
|
||||
backdrop_color = {0, 0, 0, 0.5},
|
||||
backdrop_border_color = {0, 0, 0, 1},
|
||||
anchor = {side = 6, x = 2, y = 0},
|
||||
grow_direction = 1, --1 = to right 2 = to left
|
||||
surpress_blizzard_cd_timer = false,
|
||||
surpress_tulla_omni_cc = false,
|
||||
on_tick_cooldown_update = true,
|
||||
decimal_timer = false,
|
||||
cooldown_reverse = false,
|
||||
cooldown_swipe_enabled = true,
|
||||
cooldown_edge_texture = "Interface\\Cooldown\\edge",
|
||||
}
|
||||
|
||||
function detailsFramework:CreateIconRow (parent, name, options)
|
||||
local f = _G.CreateFrame("frame", name, parent, "BackdropTemplate")
|
||||
f.IconPool = {}
|
||||
f.NextIcon = 1
|
||||
f.AuraCache = {}
|
||||
|
||||
detailsFramework:Mixin(f, detailsFramework.IconRowFunctions)
|
||||
detailsFramework:Mixin(f, detailsFramework.OptionsFunctions)
|
||||
|
||||
f:BuildOptionsTable (default_icon_row_options, options)
|
||||
|
||||
f:SetSize(f.options.icon_width, f.options.icon_height + (f.options.top_padding * 2))
|
||||
|
||||
f:SetBackdrop(f.options.backdrop)
|
||||
f:SetBackdropColor(unpack(f.options.backdrop_color))
|
||||
f:SetBackdropBorderColor(unpack(f.options.backdrop_border_color))
|
||||
|
||||
return f
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--radio group
|
||||
|
||||
|
||||
@@ -969,6 +969,7 @@ DF.CrowdControlSpells = {
|
||||
[105421] = "PALADIN", --Blinding Light (talent)
|
||||
[31935] = "PALADIN", --Avengers Shield
|
||||
[217824] = "PALADIN", --Shield of Virtue
|
||||
[10326] = "PALADIN", --Turn Evil
|
||||
|
||||
[221562] = "DEATHKNIGHT", --Asphyxiate
|
||||
[108194] = "DEATHKNIGHT", --Asphyxiate (talent)
|
||||
@@ -1002,6 +1003,7 @@ DF.CrowdControlSpells = {
|
||||
[24394] = "HUNTER", --Intimidation
|
||||
[117405] = "HUNTER", --Binding Shot (trigger)
|
||||
[117526] = "HUNTER", --Binding Shot (triggered)
|
||||
[1513] = "HUNTER", --Scare Beast
|
||||
|
||||
[119381] = "MONK", --Leg Sweep
|
||||
[115078] = "MONK", --Paralysis
|
||||
@@ -1034,6 +1036,7 @@ DF.CrowdControlSpells = {
|
||||
[331866] = "COVENANT|VENTHYR", --Agent of Chaos (Nadia soulbind)
|
||||
|
||||
[372245] = "EVOKER", --Terror of the Skies
|
||||
[360806] = "EVOKER", --Sleep Walk
|
||||
}
|
||||
|
||||
-- additionals for classic
|
||||
|
||||
Reference in New Issue
Block a user