General development and bug fixes (see commit description).

- Fixed the deaths display, where the windows wasn't usig custom text scripts.
- Fixed an issue with custom displays, where it was unable to use class colors in their texts.
- More development and bug fixes on the new Mythic+ Run Completion panel.
- Framework Update.
This commit is contained in:
Tercio Jose
2024-02-13 13:24:28 -03:00
parent 18e7464cef
commit 2fd02eebb1
19 changed files with 5685 additions and 1758 deletions
+49 -12
View File
@@ -481,12 +481,16 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
---enable the button making it clickable and not grayed out
---@return unknown
function ButtonMetaFunctions:Enable()
return self.button:Enable()
end
---disable the button making it unclickable and grayed out
---@return unknown
function ButtonMetaFunctions:Disable()
if (self.color_texture) then
self.color_texture:SetVertexColor(0.14, 0.14, 0.14)
end
return self.button:Disable()
end
@@ -733,7 +737,7 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
---receives a table where the keys are settings and the values are the values to set
---this is the list of keys the table support:
---width, height, icon|table, textcolor, textsize, textfont, textalign, backdrop, backdropcolor, backdropbordercolor, onentercolor, onleavecolor, onenterbordercolor, onleavebordercolor
---@param template table
---@param template table|string
function ButtonMetaFunctions:SetTemplate(template)
if (type(template) == "string") then
template = detailsFramework:GetTemplate("button", template)
@@ -808,6 +812,25 @@ function ButtonMetaFunctions:SetTemplate(template)
if (template.textalign) then
self.textalign = template.textalign
end
if (template.rounded_corner) then
self:SetBackdrop(nil)
detailsFramework:AddRoundedCornersToFrame(self.widget or self, template.rounded_corner)
--check if this is a color picker button
if (self.__iscolorpicker) then
self.color_texture:SetTexture([[Interface\CHARACTERFRAME\TempPortraitAlphaMaskSmall]], "CLAMP", "CLAMP", "TRILINEAR")
self.color_texture:SetDrawLayer("overlay", 7)
self.color_texture:SetPoint("topleft", self.widget, "topleft", 2, -2)
self.color_texture:SetPoint("bottomright", self.widget, "bottomright", -2, 2)
self.background_texture:SetDrawLayer("overlay", 6)
self.background_texture:SetPoint("topleft", self.color_texture, "topleft", 2, -2)
self.background_texture:SetPoint("bottomright", self.color_texture, "bottomright", -2, 2)
self.widget.texture_disabled:SetTexture([[Interface\CHARACTERFRAME\TempPortraitAlphaMaskSmall]], "CLAMP", "CLAMP", "TRILINEAR")
end
end
end
------------------------------------------------------------------------------------------------------------
@@ -857,7 +880,7 @@ end
---@field textfont string
---@field textsize number
---@field icon texture created after calling SetIcon()
---@field SetTemplate fun(self: df_button, template: table) set the button visual by a template
---@field SetTemplate fun(self: df_button, template: table|string) 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
@@ -1064,6 +1087,15 @@ end
return self.color_texture:GetVertexColor()
end
---@class df_colorpickbutton : df_button
---@field color_callback function
---@field Cancel function
---@field SetColor function
---@field GetColor function
---@field __iscolorpicker boolean
---@field color_texture texture
---@field background_texture texture
---create a button which opens a color picker when clicked
---@param parent table
---@param name string|nil
@@ -1077,33 +1109,38 @@ end
end
function detailsFramework:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate)
--button
local colorPickButton = detailsFramework: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")
---@cast colorPickButton df_colorpickbutton
colorPickButton.color_callback = callback
colorPickButton.Cancel = colorpickCancel
colorPickButton.SetColor = setColorPickColor
colorPickButton.GetColor = getColorPickColor
colorPickButton.__iscolorpicker = true
colorPickButton.HookList.OnColorChanged = {}
if (not buttonTemplate) then
colorPickButton:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
end
--background showing a grid to indicate the transparency
local background = colorPickButton:CreateTexture(nil, "background", nil, 2)
local background = colorPickButton:CreateTexture("$parentBackgroupTransparency", "background", nil, 2)
background:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0)
background:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0)
background:SetTexture([[Interface\ITEMSOCKETINGFRAME\UI-EMPTYSOCKET]])
background:SetTexCoord(3/16, 13/16, 3/16, 13/16)
background:SetAtlas("AnimCreate_Icon_Texture")
background:SetAlpha(0.3)
colorPickButton.background_texture = background
--texture which shows the texture color
local colorTexture = detailsFramework:NewImage(colorPickButton, nil, 16, 16, nil, nil, "color_texture", "$parentTex")
local colorTexture = colorPickButton:CreateTexture("$parentTex", "overlay")
colorTexture:SetColorTexture(1, 1, 1)
colorTexture:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0)
colorTexture:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0)
colorTexture:SetDrawLayer("background", 3)
colorPickButton.color_texture = colorTexture
if (not buttonTemplate) then
colorPickButton:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"))
else
colorPickButton:SetTemplate(buttonTemplate)
end
return colorPickButton
end
+8 -2
View File
@@ -103,7 +103,7 @@
---@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 UnitGroupRolesAssigned fun(unitId: unit, bUseSupport:boolean?, specId: specializationid?) : string there's no self here
---@field SetAnchor fun(self:table, widget:uiobject, anchorTable:df_anchor, anchorTo:uiobject?) only adjust the anchors of a widget, does not save values
---@field AddTextureToText fun(text:string, textureInfo:table, bAddSpace:boolean?, bAddAfterText:boolean) : string textureInfo is a table with .texture .width .height .coords{left, right, top, bottom}
---@field CreateTextureInfo fun(texture:atlasname|texturepath|textureid, width:number?, height:number?, left:number?, right:number?, top:number?, bottom:number?, imageWidthnumber?, imageHeightnumber?) : table
@@ -112,6 +112,8 @@
---@field CreateDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateFontDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateColorDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateOutlineDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateAnchorPointDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateFontListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all fonts available and ready to be used on dropdowns
---@field CreateTextEntry fun(self:table, parent:frame, textChangedCallback:function, width:number, height:number, member:string?, name:string?, labelText:string?, textentryTemplate:table?, labelTemplate:table?) : df_textentry
---@field ReskinSlider fun(self:table, slider:frame)
@@ -146,5 +148,9 @@
---@field CreateEditor fun(self:table, parent:frame, name:string?, options:df_editor_defaultoptions?) : df_editor
---@field RandomBool fun(self:table, odds: number?) : boolean return a random boolean
---@field CreateHighlightTexture fun(self:table, parent:frame, parentKey:string?, alpha:number?, name:string?) : texture
---@field CreateIconRowGeneric fun(self:table, parent:frame, name:string?, options:table?)
---@field CreateColorPickButton fun(self:table, parent:frame, name:string?, member:string?, callback:function, alpha:number?, buttonTemplate:table?) : df_button
---@field CreateSlider fun(self:table, parent:frame, width:number?, height:number?, minValue:number?, maxValue:number?, step:number?, defaultv:number?, isDecemal:boolean?, member:string?, name:string?, label:string?, sliderTemplate:string|table?, labelTemplate:string|table?) : df_slider, df_label?
---@field
---@field
---@field
+32 -11
View File
@@ -303,7 +303,7 @@ function DropDownMetaFunctions:GetFrameForOption(optionsTable, value) --not test
end
function DropDownMetaFunctions:Refresh()
local optionsTable = DF:Dispatch(self.func, self)
local state, optionsTable = xpcall(self.func, geterrorhandler(), self)
if (#optionsTable == 0) then
self:NoOption(true)
@@ -558,9 +558,11 @@ function DropDownMetaFunctions:Selected(thisOption)
self.statusbar:SetTexture(thisOption.statusbar)
if (thisOption.statusbarcolor) then
self.statusbar:SetVertexColor(unpack(thisOption.statusbarcolor))
else
self.statusbar:SetVertexColor(1, 1, 1, 1)
end
else
self.statusbar:SetTexture([[Interface\Tooltips\CHATBUBBLE-BACKGROUND]])
self.statusbar:SetVertexColor(0, 0, 0, 0)
end
if (self.widget.__rcorners) then
@@ -774,9 +776,11 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype)
thisOptionFrame.statusbar:SetTexture(thisOption.statusbar)
if (thisOption.statusbarcolor) then
thisOptionFrame.statusbar:SetVertexColor(unpack(thisOption.statusbarcolor))
else
thisOptionFrame.statusbar:SetVertexColor(1, 1, 1, 1)
end
else
thisOptionFrame.statusbar:SetTexture([[Interface\Tooltips\CHATBUBBLE-BACKGROUND]])
thisOptionFrame.statusbar:SetVertexColor(0, 0, 0, 0)
end
--an extra button in the right side of the row
@@ -824,7 +828,7 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype)
end
selectedTexture:Show()
selectedTexture:SetVertexColor(1, 1, 1, .3)
selectedTexture:SetVertexColor(1, 1, 0, .5)
selectedTexture:SetTexCoord(0, 29/32, 5/32, 27/32)
currentIndex = tindex
@@ -1009,13 +1013,21 @@ end
--template
function DropDownMetaFunctions:SetTemplate(template)
if (type(template) == "string") then
local templateName = template
template = DF:GetTemplate("dropdown", templateName)
if (not template) then
print("no template found", templateName)
end
end
self.template = template
if (template.width) then
PixelUtil.SetWidth(self.dropdown, template.width)
end
if (template.height) then
PixelUtil.SetWidth(self.dropdown, template.height)
PixelUtil.SetHeight(self.dropdown, template.height)
end
if (template.backdrop) then
@@ -1090,13 +1102,19 @@ end
--object constructor
---@class df_dropdown : table, frame
---@field SetTemplate fun(self:df_dropdown, template:table)
---@field SetTemplate fun(self:df_dropdown, template:table|string)
---@field BuildDropDownFontList fun(self:df_dropdown, onClick:function, icon:any, iconTexcoord:table?, iconSize:table?):table make a dropdown list with all fonts available, on select a font, call the function onClick
---@field
---@field
---@field
---@field
---@field
---@field SetFunction fun(self:df_dropdown, func:function)
---@field SetEmptyTextAndIcon fun(self:df_dropdown, text:string, icon:any)
---@field Select fun(self:df_dropdown, optionName:string|number, byOptionNumber:boolean?, bOnlyShown:boolean?, runCallback:boolean?):boolean
---@field Open fun(self:df_dropdown)
---@field Close fun(self:df_dropdown)
---@field Refresh fun(self:df_dropdown)
---@field GetFunction fun(self:df_dropdown):function
---@field GetMenuSize fun(self:df_dropdown):number, number
---@field SetMenuSize fun(self:df_dropdown, width:number, height:number)
---@field Disable fun(self:df_dropdown)
---@field Enable fun(self:df_dropdown)
---return a function which when called returns a table filled with all fonts available and ready to be used on dropdowns
---@param callback function
@@ -1259,6 +1277,9 @@ function DF:NewDropDown(parent, container, name, member, width, height, func, de
default = 1
end
width = width or 160
height = height or 20
dropDownObject.dropdown = DF:CreateNewDropdownFrame(parent, name)
PixelUtil.SetSize(dropDownObject.dropdown, width, height)
+50 -18
View File
@@ -1,6 +1,6 @@
local dversion = 510
local dversion = 511
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -2522,6 +2522,28 @@ DF.dropdown_templates["OPTIONS_DROPDOWNDARK_TEMPLATE"] = {
dropiconpoints = {-2, -3},
}
DF.dropdown_templates["OLD_DROPDOWN_TEMPLATE"] = {
height = 24,
backdrop = {
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
edgeSize = 8,
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
tileSize = 64,
tile = true,
insets = {left = 4, right = 4, top = 4, bottom = 4}
},
backdropcolor = {0.1215, 0.1176, 0.1294, 0.4000},
backdropbordercolor = {1, 1, 1, 1},
onentercolor = {.5, .5, .5, .9},
onenterbordercolor = {1, 1, 1, 1},
dropicon = "Interface\\BUTTONS\\arrow-Down-Down",
dropiconsize = {16, 16},
dropiconpoints = {-2, -3},
}
--switches
DF.switch_templates = DF.switch_templates or {}
DF.switch_templates["OPTIONS_CHECKBOX_TEMPLATE"] = {
@@ -2534,6 +2556,23 @@ DF.switch_templates["OPTIONS_CHECKBOX_TEMPLATE"] = {
disabled_backdropcolor = {1, 1, 1, .2},
onenterbordercolor = {1, 1, 1, 1},
}
DF.switch_templates["OPTIONS_CIRCLECHECKBOX_TEMPLATE"] = {
width = 18,
height = 18,
is_checkbox = true, --will call SetAsCheckBox()
checked_texture = [[Interface\CHARACTERFRAME\TempPortraitAlphaMaskSmall]],
checked_size_percent = 0.7,
checked_xoffset = 0,
checked_yoffset = 0,
checked_color = "dark3",
rounded_corner = {
color = {.075, .075, .075, 1},
border_color = {.2, .2, .2, 1},
roundness = 8,
},
}
DF.switch_templates["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
@@ -2553,6 +2592,14 @@ DF.button_templates["OPTIONS_BUTTON_TEMPLATE"] = {
backdropbordercolor = {0, 0, 0, 1},
}
DF.button_templates["OPTIONS_CIRCLEBUTTON_TEMPLATE"] = {
rounded_corner = {
color = {.075, .075, .075, 1},
border_color = {.2, .2, .2, 1},
roundness = 8,
},
}
DF.button_templates["OPTIONS_BUTTON_GOLDENBORDER_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
@@ -3905,7 +3952,7 @@ function DF:GetClassSpecIds(engClass) --naming conventions
end
local dispatch_error = function(context, errortext)
DF:Msg( (context or "<no context>") .. " |cFFFF9900error|r: " .. (errortext or "<no error given>"))
error((context or "") .. (errortext or ""))
end
--call a function with payload, if the callback doesn't exists, quit silently
@@ -3930,23 +3977,8 @@ end
---@param ... any
---@return any
function DF:Dispatch(func, ...)
if (type(func) ~= "function") then
return dispatch_error(_, "DetailsFramework:Dispatch(func) expect a function as parameter 1.")
end
assert(type(func) == "function", "DetailsFramework:Dispatch(func) expect a function as parameter 1. Received: " .. type(func) .. " instead.")
return select(2, xpcall(func, geterrorhandler(), ...))
--[=[
local dispatchResult = {xpcall(func, geterrorhandler(), ...)}
local okay = dispatchResult[1]
if (not okay) then
return false
end
tremove(dispatchResult, 1)
return unpack(dispatchResult)
--]=]
end
--[=[
+359 -142
View File
@@ -14,14 +14,94 @@ end
---@field options table
---@field NextIcon number
---@field IconPool table<number, df_icongeneric> table which store the icons created for this iconrow
---@field SetAuraWithIconTemplate fun(self:df_icongeneric, aI:aurainfo, iconTemplateTable:table)
---@field ClearIcons fun(self:df_icongeneric, resetBuffs:boolean?, resetDebuffs:boolean?)
---@field AlignAuraIcons fun(self:df_icongeneric)
---@class df_iconrow_generic_options : table
---@field icon_width number? @The width of the icon.
---@field icon_height number? @The height of the icon.
---@field texcoord table? @The texture coordinates of the icon.
---@field show_text boolean? @Whether to show text on the icon.
---@field text_color table? @The color of the text.
---@field text_size number? @The size of the text.
---@field text_font string? @The font of the text.
---@field text_outline string? @The outline style of the text.
---@field text_anchor df_anchor? @The anchor point of the text.
---@field text_alpha_by_percent boolean? @Whether to change the alpha of the text by the percentage of the cooldown.
---@field desc_text boolean? @Whether to show description text.
---@field desc_text_color table? @The color of the description text.
---@field desc_text_size number? @The size of the description text.
---@field desc_text_font string? @The font of the description text.
---@field desc_text_outline string? @The outline style of the description text.
---@field desc_text_anchor string? @The anchor point of the description text.
---@field desc_text_rel_anchor string? @The relative anchor point of the description text.
---@field desc_text_x_offset number? @The x offset of the description text.
---@field desc_text_y_offset number? @The y offset of the description text.
---@field stack_text boolean? @Whether to show stack text.
---@field stack_text_color table? @The color of the stack text.
---@field stack_text_size number? @The size of the stack text.
---@field stack_text_font string? @The font of the stack text.
---@field stack_text_outline string? @The outline style of the stack text.
---@field stack_text_anchor string? @The anchor point of the stack text.
---@field stack_text_rel_anchor string? @The relative anchor point of the stack text.
---@field stack_text_x_offset number? @The x offset of the stack text.
---@field stack_text_y_offset number? @The y offset of the stack text.
---@field left_padding number? @The distance between the right and left sides.
---@field top_padding number? @The distance between the top and bottom sides.
---@field icon_padding number? @The distance between each icon.
---@field backdrop table? @The backdrop options.
---@field backdrop_color table? @The color of the backdrop.
---@field backdrop_border_color table? @The color of the backdrop border.
---@field anchor table? @The anchor options.
---@field grow_direction number? @The direction in which the icons grow.
---@field center_alignment boolean? @Whether to align the icons in the center.
---@field surpress_blizzard_cd_timer boolean? @Whether to suppress the Blizzard cooldown timer.
---@field surpress_tulla_omni_cc boolean? @Whether to suppress the Tulla OmniCC cooldown count.
---@field on_tick_cooldown_update boolean? @Whether to update cooldowns on every tick.
---@field cooldown_max_brightness number? @The maximum brightness of the cooldown, it is adjusted by the percent.
---@field decimal_timer boolean? @Whether to display the timer in decimal format.
---@field show_cooldown boolean? @Whether to show blizzard cooldown animation.
---@field cooldown_reverse boolean? @Whether to reverse the cooldown animation.
---@field cooldown_swipe_enabled boolean? @Whether to enable the cooldown swipe animation.
---@field cooldown_edge_texture string? @The texture for the cooldown edge.
---@field show_horizontal_swipe boolean? @Whether to show the horizontal swipe animation.
---@field swipe_alpha number? @The alpha value for the swipe animation.
---@field swipe_brightness number? @The brightness value for the swipe animation.
---@field swipe_progressive_color boolean? @Whether to use progressive color for the swipe animation. Start on Green and goes to Red, follows percent amount.
---@field swipe_color table? @When the color isn't progressive, this is the color of the swipe
---@field swipe_color_start number[]? @Whether to use yellow color for the swipe animation.
---@field swipe_color_end number[]? @Whether to use red color for the swipe animation.
---@field remove_on_finish boolean? @Whether to remove the icon when the cooldown finishes. Only usable if the icon has a identifier (from setting specific).
---@field first_icon_use_anchor boolean? @The anchor point for the first ico will use the anchor set in options.anchor.
---@class df_iconrow_generic : df_iconrow
---@field SetCooldown fun(self:df_iconrow_generic, iconFrame:df_icongeneric)
---@field OnIconTick fun(iconFrame:df_icongeneric)
---@field FormatCooldownTime fun(thisTime:number)
---@field FormatCooldownTimeDecimal fun(formattedTime:number)
---@field GetIconGrowDirection fun(self:df_iconrow_generic):number
---@field OnOptionChanged fun(self:df_iconrow_generic, optionName:string)
---@field CreateIcon fun(self:df_iconrow_generic, iconName:string)
---@field GetIcon fun(self:df_iconrow_generic)
---@field SetStacks fun(self:df_iconrow_generic, iconFrame:df_icongeneric, bIsShown:boolean, stacksAmount:number?)
---@field AddSpecificIcon fun(self:df_iconrow_generic, identifierKey:any, spellId:number, borderColor:table, startTime:number, duration:number, forceTexture:string, descText:string, count:number, debuffType:string, caster:string, canStealOrPurge:boolean, spellName:string, isBuff:boolean, modRate:number, iconSettings:table)
---@field AddSpecificIconWithTemplate fun(self:df_iconrow_generic, iconTemplateTable:table)
---@field IsIconShown fun(self:df_iconrow_generic, identifierKey:any)
---@field SetIcon fun(self:df_iconrow_generic, spellId:number, borderColor:table, startTime:number, duration:number, iconTexture:string, descText:string, count:number, debuffType:string, caster:string, canStealOrPurge:boolean, spellName:string, isBuff:boolean, modRate:number, iconSettings:table, expirationTime:number?)
---@field RemoveSpecificIcon fun(self:df_iconrow_generic, identifierKey:any)
---@field ClearIcons fun(self:df_iconrow_generic, resetBuffs:boolean?, resetDebuffs:boolean?)
---@field AlignAuraIcons fun(self:df_iconrow_generic)
---@field SetAuraWithIconTemplate fun(self:df_iconrow_generic, auraInfo:aurainfo, iconTemplateTable:table)
---@field IconPool table<number, df_icongeneric>
---@field NextIcon number
---@field AuraCache table<any, boolean>
---@field shownAmount number
---@field options table
---@field SetSpecificAuraWithIconTemplate fun(self:df_iconrow_generic, identifierKey:any, auraInfo:aurainfo, iconTemplateTable:table)
local unpack = unpack
local CreateFrame = CreateFrame
local PixelUtil = PixelUtil
local GetTime = GetTime
local Clamp = detailsFramework.Math.Clamp
local spellIconCache = {}
local spellNameCache = {}
@@ -38,9 +118,16 @@ local iconFrameOnHideScript = function(self)
end
end
local checkPointCallback = function(iconFrame)
if (iconFrame.timeRemaining < 3) then
end
return true
end
detailsFramework.IconGenericMixin = {
---create a new icon frame
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
---@param iconName string the name of the icon frame
---@return df_icongeneric
CreateIcon = function(self, iconName)
@@ -55,9 +142,8 @@ detailsFramework.IconGenericMixin = {
---@type texture
newIcon.CooldownBrightnessTexture = newIcon:CreateTexture(nil, "artwork", nil, 2)
newIcon.CooldownBrightnessTexture:SetBlendMode("ADD")
newIcon.CooldownBrightnessTexture:SetAlpha(1)
PixelUtil.SetPoint(newIcon.CooldownBrightnessTexture, "topleft", newIcon, "topleft", 0, 0)
PixelUtil.SetPoint(newIcon.CooldownBrightnessTexture, "bottomright", newIcon, "bottomright", 0, 0)
PixelUtil.SetPoint(newIcon.CooldownBrightnessTexture, "topleft", newIcon.Texture, "topleft", 0, 0)
PixelUtil.SetPoint(newIcon.CooldownBrightnessTexture, "bottomright", newIcon.Texture, "bottomright", 0, 0)
---@type texture
newIcon.Border = newIcon:CreateTexture(nil, "background")
@@ -80,10 +166,10 @@ detailsFramework.IconGenericMixin = {
--create a overlay texture which will indicate the cooldown time
newIcon.CooldownTexture = newIcon:CreateTexture(self:GetName() .. "CooldownTexture", "overlay", nil, 6)
newIcon.CooldownTexture:SetColorTexture(1, 1, 1, 1)
newIcon.CooldownTexture:SetTexture("Interface\\BUTTONS\\GreyscaleRamp64", "CLAMP", "CLAMP", "TRILINEAR")
newIcon.CooldownTexture:SetHeight(2)
newIcon.CooldownTexture:SetPoint("bottomleft", newIcon.Texture, "bottomleft", 0, 0)
newIcon.CooldownTexture:SetPoint("bottomright", newIcon.Texture, "bottomright", 0, 0)
newIcon.CooldownTexture:SetHeight(1)
newIcon.CooldownTexture:Hide()
newIcon.CooldownEdge = newIcon:CreateTexture(self:GetName() .. "CooldownEdge", "overlay", nil, 7)
@@ -95,11 +181,18 @@ detailsFramework.IconGenericMixin = {
newIcon.stacks = 0
newIcon:SetScript("OnHide", iconFrameOnHideScript)
local cooldownFrame = CreateFrame("cooldown", "$parentCooldownFrame", newIcon, "CooldownFrameTemplate, BackdropTemplate")
cooldownFrame:SetAllPoints()
cooldownFrame:EnableMouse(false)
cooldownFrame:SetFrameLevel(newIcon:GetFrameLevel()+1)
cooldownFrame.CountdownText = ({cooldownFrame:GetRegions()})[1]
newIcon.Cooldown = cooldownFrame
return newIcon
end,
---get an icon frame from the pool
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
---@return df_icongeneric
GetIcon = function(self)
---@type df_icongeneric
@@ -152,7 +245,7 @@ detailsFramework.IconGenericMixin = {
end,
---adds only if not existing already in the cache
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
AddSpecificIcon = function(self, identifierKey, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff, modRate, iconSettings)
if (not identifierKey or identifierKey == "") then
return
@@ -179,18 +272,32 @@ detailsFramework.IconGenericMixin = {
end
end,
---set an icon frame with a template
---@param self df_iconrow the parent frame
---@param aI aurainfo
---@param iconTemplateTable df_icontemplate
SetAuraWithIconTemplate = function(self, aI, iconTemplateTable)
local startTime = aI.expirationTime - aI.duration
---@type df_icongeneric
self:SetIcon(aI.spellId, nil, startTime, aI.duration, aI.icon, nil, aI.applications, aI.dispelName, aI.sourceUnit, aI.isStealable, aI.name, aI.isHelpful, aI.timeMod, iconTemplateTable, aI.expirationTime)
SetSpecificAuraWithIconTemplate = function(self, identifierKey, auraInfo, iconTemplateTable)
if (not identifierKey or identifierKey == "") then
return
end
if (not self.AuraCache[identifierKey]) then
---@type df_icongeneric
local iconFrame = self:SetAuraWithIconTemplate(auraInfo, iconTemplateTable)
iconFrame.identifierKey = identifierKey
self.AuraCache[identifierKey] = true
end
end,
---set an icon frame with a template
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
---@param auraInfo aurainfo
---@param iconTemplateTable df_icontemplate
SetAuraWithIconTemplate = function(self, auraInfo, iconTemplateTable)
local startTime = auraInfo.expirationTime - auraInfo.duration
---@type df_icongeneric
return self:SetIcon(auraInfo.spellId, nil, startTime, auraInfo.duration, auraInfo.icon, nil, auraInfo.applications, auraInfo.dispelName, auraInfo.sourceUnit, auraInfo.isStealable, auraInfo.name, auraInfo.isHelpful, auraInfo.timeMod, iconTemplateTable, auraInfo.expirationTime)
end,
---set an icon frame with a template
---@param self df_iconrow_generic the parent frame
---@return df_icongeneric?
SetIcon = function(self, spellId, borderColor, startTime, duration, iconTexture, descText, count, debuffType, caster, canStealOrPurge, spellName, isBuff, modRate, iconSettings, expirationTime)
local actualSpellName, spellIcon = spellNameCache[spellId], spellIconCache[spellId]
@@ -213,6 +320,10 @@ detailsFramework.IconGenericMixin = {
end
end
if (iconSettings.overrideTexture) then
spellIcon = iconSettings.overrideTexture
end
if (spellIcon) then
spellName = spellName or actualSpellName or "unknown_aura"
modRate = modRate or 1
@@ -223,8 +334,29 @@ detailsFramework.IconGenericMixin = {
iconFrame.expirationTime = expirationTime
local widthFromTexture
local heightFromTexture
local width = iconSettings.width or self.options.icon_width
local height = iconSettings.height or self.options.icon_height or width
--adjust the width and height by scale
local scale = iconSettings.scale or 1
width = width * scale
height = height * scale
PixelUtil.SetSize(iconFrame, width, height)
--set the texture points to be all points minus one
iconFrame.Texture:ClearAllPoints()
PixelUtil.SetPoint(iconFrame.Texture, "topleft", iconFrame, "topleft", 1, -1)
PixelUtil.SetPoint(iconFrame.Texture, "bottomright", iconFrame, "bottomright", -1, 1)
iconFrame.textureWidth = math.max(iconFrame.Texture:GetWidth(), width)
iconFrame.textureHeight = math.max(iconFrame.Texture:GetHeight(), height) --for some reason, GetHeight() was returning 0 on the first call
--cache size
iconFrame.width = width
iconFrame.height = height
iconFrame:Show()
if (iconFrame.Texture.texture ~= spellIcon or (iconSettings.coords and iconSettings.coords ~= iconFrame.currentCoords)) then
iconFrame.Texture:SetTexture(spellIcon, "CLAMP", "CLAMP", iconSettings.textureFilter or "LINEAR") --"TRILINEAR"
@@ -240,38 +372,13 @@ detailsFramework.IconGenericMixin = {
iconFrame.Texture:SetTexCoord(0, 1, 0, 1)
end
iconFrame.Texture:ClearAllPoints()
if (iconSettings.points) then
iconFrame.Texture:ClearAllPoints()
for i = 1, #iconSettings.points do
local point = iconSettings.points[i]
iconFrame.Texture:SetPoint(point[1], iconFrame, point[2], point[3], point[4])
end
if (iconSettings.width) then
iconFrame.Texture:SetWidth(iconSettings.width)
widthFromTexture = iconSettings.width
else
iconFrame.Texture:SetWidth(self.options.icon_width)
end
if (iconSettings.height or iconSettings.width) then
iconFrame.Texture:SetHeight(iconSettings.height or iconSettings.width)
heightFromTexture = iconSettings.height or iconSettings.width
else
iconFrame.Texture:SetHeight(self.options.icon_height)
end
else
if (iconSettings.width) then
iconFrame.Texture:SetWidth(iconSettings.width)
iconFrame.Texture:SetHeight(iconSettings.height or iconSettings.width)
widthFromTexture = iconSettings.width
heightFromTexture = iconSettings.height or iconSettings.width
PixelUtil.SetPoint(iconFrame.Texture, "center", iconFrame, "center", 0, 0)
else
PixelUtil.SetPoint(iconFrame.Texture, "topleft", iconFrame, "topleft", 1, -1)
PixelUtil.SetPoint(iconFrame.Texture, "bottomright", iconFrame, "bottomright", -1, 1)
end
iconFrame.Texture:SetSize(width, height)
end
iconFrame.Texture.texture = spellIcon
@@ -285,6 +392,17 @@ detailsFramework.IconGenericMixin = {
end
end
iconFrame:SetIgnoreParentAlpha(false)
if (iconSettings.color) then
local r, g, b, a = detailsFramework:ParseColors(iconSettings.color)
iconFrame.Texture:SetVertexColor(r, g, b, a)
--ignore the param alpha has the settings might have an alpha for it
iconFrame:SetIgnoreParentAlpha(true)
else
iconFrame.Texture:SetVertexColor(1, 1, 1, 1)
end
if (borderColor) then
iconFrame.Border:Show()
iconFrame.Border:SetVertexColor(unpack(borderColor))
@@ -306,44 +424,33 @@ detailsFramework.IconGenericMixin = {
iconFrame.stacks = count or 0
if (iconSettings.scale) then
iconFrame.Texture:SetScale(iconSettings.scale)
if (widthFromTexture) then
widthFromTexture = widthFromTexture * iconSettings.scale
end
if (heightFromTexture) then
heightFromTexture = heightFromTexture * iconSettings.scale
end
else
iconFrame.Texture:SetScale(1)
end
if (iconSettings.alpha) then
iconFrame.Texture:SetAlpha(iconSettings.alpha)
else
iconFrame.Texture:SetAlpha(1)
end
iconFrame:Show()
iconFrame.textureWidth = iconFrame.Texture:GetWidth()
iconFrame.textureHeight = iconFrame.Texture:GetHeight()
PixelUtil.SetSize(iconFrame, iconFrame.textureWidth, iconFrame.textureHeight)
--cache size
iconFrame.width = iconFrame.textureWidth
iconFrame.height = iconFrame.textureHeight
--iconFrame.Texture:SetBlendMode("ADD")
iconFrame.CooldownBrightnessTexture:SetTexture(iconFrame.Texture:GetTexture())
do
local left, top, c, bottom, right = iconFrame.Texture:GetTexCoord()
iconFrame.CooldownBrightnessTexture:SetTexCoord(left, right, top, bottom)
iconFrame.CooldownBrightnessTexture.cords = {left, right, top, bottom}
local coords = iconFrame.CooldownBrightnessTexture.cords
if (coords) then
coords[1] = left
coords[2] = right
coords[3] = top
coords[4] = bottom
else
iconFrame.CooldownBrightnessTexture.cords = {left, right, top, bottom}
end
iconFrame.CooldownBrightnessTexture.top = top
iconFrame.CooldownBrightnessTexture.bottom = bottom
end
PixelUtil.SetPoint(iconFrame.CooldownBrightnessTexture, "bottomright", iconFrame, "bottomright", -1, 1)
PixelUtil.SetPoint(iconFrame.CooldownBrightnessTexture, "bottomright", iconFrame.Texture, "bottomright", 0, 0)
end
--make information available
iconFrame.spellId = spellId
@@ -388,7 +495,7 @@ detailsFramework.IconGenericMixin = {
end
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
---@param iconFrame df_icongeneric
SetCooldown = function(self, iconFrame)
if (iconFrame.cooldownLooper) then
@@ -399,69 +506,166 @@ detailsFramework.IconGenericMixin = {
--iconFrame:SetScale(3) --debug
iconFrame.CooldownEdge:Hide()
iconFrame.CooldownEdge.texture = nil
if (options.show_horizontal_swipe) then
iconFrame.CooldownEdge:Show()
iconFrame.CooldownTexture:Show()
iconFrame.CooldownBrightnessTexture:Show()
detailsFramework:SetFontColor(iconFrame.CountdownText, self.options.text_color)
iconFrame.CooldownEdge.texture = nil
iconFrame.CooldownEdge:SetAlpha(0.834)
PixelUtil.SetSize(iconFrame.CooldownEdge, iconFrame.CooldownTexture:GetWidth(), 2)
PixelUtil.SetPoint(iconFrame.CooldownEdge, "topleft", iconFrame.CooldownTexture, "topleft", 0, 0)
PixelUtil.SetPoint(iconFrame.CooldownEdge, "topright", iconFrame.CooldownTexture, "topright", 0, 0)
PixelUtil.SetHeight(iconFrame.CooldownEdge, 2)
PixelUtil.SetSize(iconFrame.CooldownEdge, iconFrame.CooldownTexture:GetWidth(), 2)
PixelUtil.SetPoint(iconFrame.CooldownEdge, "topleft", iconFrame.CooldownTexture, "topleft", 0, 0)
PixelUtil.SetPoint(iconFrame.CooldownEdge, "topright", iconFrame.CooldownTexture, "topright", 0, 0)
PixelUtil.SetHeight(iconFrame.CooldownEdge, 8)
local swipe_brightness = options.swipe_brightness
iconFrame.CooldownBrightnessTexture:SetAlpha(swipe_brightness)
iconFrame.CooldownEdge:SetTexture(options.swipe_white, "CLAMP", "CLAMP", "TRILINEAR")
iconFrame.CooldownEdge.texture = options.swipe_white
local swipe_darkness = options.swipe_alpha
iconFrame.CooldownTexture:SetAlpha(swipe_darkness)
iconFrame.CooldownTexture:SetVertexColor(unpack(options.swipe_color))
local swipe_brightness = options.swipe_brightness
iconFrame.CooldownBrightnessTexture:SetAlpha(swipe_brightness)
iconFrame.CooldownEdge:SetAlpha(0.834)
local swipe_darkness = options.swipe_alpha
iconFrame.CooldownTexture:SetAlpha(swipe_darkness)
iconFrame.CooldownTexture:SetVertexColor(unpack(options.swipe_color))
else
iconFrame.CooldownEdge:Hide()
iconFrame.CooldownBrightnessTexture:Hide()
iconFrame.CooldownTexture:Hide()
end
if (options.show_text) then
detailsFramework:SetFontColor(iconFrame.CountdownText, self.options.text_color)
detailsFramework:SetFontSize(iconFrame.CountdownText, self.options.text_size)
detailsFramework:SetFontFace(iconFrame.CountdownText, self.options.text_font)
detailsFramework:SetFontOutline(iconFrame.CountdownText, self.options.text_outline)
detailsFramework:SetAnchor(iconFrame.CountdownText, self.options.text_anchor, iconFrame)
iconFrame.CountdownText:Show()
iconFrame.CountdownText:SetAlpha(1)
else
iconFrame.CountdownText:Hide()
end
if (options.show_cooldown) then
iconFrame.Cooldown:Show()
iconFrame.Cooldown:SetReverse(options.cooldown_reverse)
iconFrame.Cooldown:SetDrawSwipe(options.cooldown_swipe_enabled)
iconFrame.Cooldown:SetEdgeTexture(options.cooldown_edge_texture) --the yellow edge that follows the cooldown animation
iconFrame.Cooldown:SetHideCountdownNumbers(options.surpress_blizzard_cd_timer)
iconFrame.Cooldown:SetSwipeTexture([[Interface\Masks\SquareMask]], 0, 0, 0, 0.3)
--iconFrame.Cooldown:SetSwipeColor(1, 1, 1, 1)
--iconFrame.Cooldown:SetSwipeColor(0, 0, 0, 0.1)
--iconFrame.Cooldown:SetDrawEdge(true) --the same shit as above
--iconFrame.Cooldown:SetDrawSwipe(true)
--iconFrame.Cooldown:SetDrawBling(true) --edge of the animation, a thin horizontal texture
--iconFrame.Cooldown:SetEdgeScale(4) --edge of the animation, a thin horizontal texture
if (not options.surpress_blizzard_cd_timer) then
detailsFramework:SetFontColor(iconFrame.Cooldown.CountdownText, self.options.text_color)
detailsFramework:SetFontSize(iconFrame.Cooldown.CountdownText, self.options.text_size)
detailsFramework:SetFontFace(iconFrame.Cooldown.CountdownText, self.options.text_font)
detailsFramework:SetFontOutline(iconFrame.Cooldown.CountdownText, self.options.text_outline)
end
iconFrame.Cooldown.noCooldownCount = options.surpress_tulla_omni_cc
CooldownFrame_Set(iconFrame.Cooldown, iconFrame.startTime, iconFrame.duration, true, true, iconFrame.modRate)
iconFrame.CooldownBrightnessTexture:Show()
else
iconFrame.Cooldown:Hide()
end
self.OnIconTick(iconFrame)
local amountOfLoops = math.floor(iconFrame.duration / 0.5)
local amountOfLoops = math.floor(iconFrame.duration / 0.25)
local loopEndCallback = nil
local checkPointCallback = nil
local newLooper = detailsFramework.Schedules.NewLooper(0.5, self.OnIconTick, amountOfLoops, loopEndCallback, checkPointCallback, iconFrame)
iconFrame.cooldownLooper = newLooper
if (iconFrame.options.remove_on_finish) then
--increase the amount of loops in one, so the last loop will remove the icon
--otherwise it might finish
amountOfLoops = amountOfLoops + 1
local newLooper = detailsFramework.Schedules.NewLooper(0.25, self.OnIconTick, amountOfLoops, loopEndCallback, checkPointCallback, iconFrame)
iconFrame.cooldownLooper = newLooper
else
local newLooper = detailsFramework.Schedules.NewLooper(0.25, self.OnIconTick, amountOfLoops, loopEndCallback, checkPointCallback, iconFrame)
iconFrame.cooldownLooper = newLooper
end
end,
---@param iconFrame df_icongeneric
OnIconTick = function(iconFrame)
local now = GetTime()
--local percent = (now - iconFrame.startTime) / iconFrame.duration --no mod rate
local percent = ((now - iconFrame.startTime) / (iconFrame.modRate or 1)) / (iconFrame.duration / (iconFrame.modRate or 1))
local percent = (((now - iconFrame.startTime) / (iconFrame.modRate or 1)) / (iconFrame.duration / (iconFrame.modRate or 1))) or 0
local options = iconFrame.options
percent = Saturate(percent)
--percent = abs(percent - 1)
local newHeight = math.min(iconFrame.textureHeight * percent, iconFrame.textureHeight)
iconFrame.CooldownTexture:SetHeight(newHeight)
iconFrame.timeRemaining = iconFrame.duration - (now - iconFrame.startTime)
PixelUtil.SetPoint(iconFrame.CooldownBrightnessTexture, "bottomright", iconFrame, "bottomright", 0, newHeight) --iconFrame.textureHeight -
local left, right, top, bottom = unpack(iconFrame.CooldownBrightnessTexture.cords)
local newBottomCord = Lerp(iconFrame.CooldownBrightnessTexture.top, iconFrame.CooldownBrightnessTexture.bottom, abs(percent - 1))
iconFrame.CooldownBrightnessTexture:SetTexCoord(left, right, top, newBottomCord)
if (percent > options.swipe_percent2) then
if (options.swipe_red and iconFrame.CooldownEdge.texture ~= options.swipe_red) then
iconFrame.CooldownEdge:Show()
iconFrame.CooldownEdge:SetTexture(options.swipe_red)
iconFrame.CooldownEdge.texture = options.swipe_red
end
elseif (percent > options.swipe_percent1) then
if (options.swipe_yellow and iconFrame.CooldownEdge.texture ~= options.swipe_yellow) then
iconFrame.CooldownEdge:Show()
iconFrame.CooldownEdge:SetTexture(options.swipe_yellow)
iconFrame.CooldownEdge.texture = options.swipe_yellow
if (percent >= 1) then
--time expired
if (options.remove_on_finish) then
iconFrame:GetParent():RemoveSpecificIcon(iconFrame.identifierKey)
return
else
percent = 1
end
end
--iconFrame.CountdownText:SetText(iconFrame.parentIconRow.FormatCooldownTime(iconFrame.duration - (now - iconFrame.startTime))) --no mod rate
iconFrame.CountdownText:SetText(iconFrame.parentIconRow.FormatCooldownTime((iconFrame.duration - (now - iconFrame.startTime)) / (iconFrame.modRate or 1)))
--self.CountdownText:Show()
if (options.show_horizontal_swipe) then
local newHeight = math.min(iconFrame.textureHeight * percent, iconFrame.textureHeight)
iconFrame.CooldownTexture:SetHeight(newHeight)
PixelUtil.SetPoint(iconFrame.CooldownBrightnessTexture, "bottomright", iconFrame.Texture, "bottomright", 0, newHeight) --iconFrame.textureHeight -
local left, right, top, bottom = unpack(iconFrame.CooldownBrightnessTexture.cords)
local newBottomCord = Lerp(iconFrame.CooldownBrightnessTexture.top, iconFrame.CooldownBrightnessTexture.bottom, abs(percent - 1))
iconFrame.CooldownBrightnessTexture:SetTexCoord(left, right, top, newBottomCord)
--local newBrightness = Lerp(Saturate(options.cooldown_max_brightness-0.6), options.cooldown_max_brightness, percent)
--iconFrame.CooldownBrightnessTexture:SetAlpha(newBrightness)
if (options.swipe_progressive_color) then
--interpolate from green to red
--percent goes from 0 to 1, where zero is the start of the cooldown and 1 is the end
if (options.swipe_color_start and options.swipe_color_end) then
--use the first and second color
local r1, g1, b1 = unpack(options.swipe_color_start)
local r2, g2, b2 = unpack(options.swipe_color_end)
local r, g, b = detailsFramework.Math.LerpLinearColor(percent, 1, r1, g1, b1, r2, g2, b2)
iconFrame.CooldownEdge:SetVertexColor(r, g, b, 0.834)
else
--use a solid color
iconFrame.CooldownEdge:SetVertexColor(unpack(options.swipe_color))
end
--iconFrame.CooldownEdge:SetVertexColor(percent, math.abs(percent-1), 0, 0.834)
local alpha = Saturate(0.2 + percent)
iconFrame.CooldownEdge:SetAlpha(alpha)
else
--use a solid color
iconFrame.CooldownEdge:SetVertexColor(unpack(options.swipe_color))
end
end
if (options.show_cooldown) then
if (options.cooldown_max_brightness) then
iconFrame.CooldownBrightnessTexture:SetAlpha(Lerp(0, options.cooldown_max_brightness, percent))
local swipeAlpha = Saturate(Lerp(0, 1, percent))
local exponentialCurve = 0.1 * math.exp(3.5 * swipeAlpha)
exponentialCurve = Saturate(exponentialCurve)
iconFrame.Cooldown:SetSwipeColor(0, 0, 0, exponentialCurve)
end
end
--show the countdown text
if (options.show_text) then
iconFrame.CountdownText:SetText(iconFrame.parentIconRow.FormatCooldownTime((iconFrame.duration - (now - iconFrame.startTime)) / (iconFrame.modRate or 1)))
if (options.text_alpha_by_percent) then
iconFrame.CountdownText:SetAlpha(percent)
end
end
end,
FormatCooldownTime = function(thisTime)
@@ -495,7 +699,7 @@ detailsFramework.IconGenericMixin = {
end
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
---@param identifierKey any
RemoveSpecificIcon = function(self, identifierKey)
if (not identifierKey or identifierKey == "") then
@@ -527,7 +731,7 @@ detailsFramework.IconGenericMixin = {
self:AlignAuraIcons()
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
ClearIcons = function(self, resetBuffs, resetDebuffs)
resetBuffs = resetBuffs ~= false
resetDebuffs = resetDebuffs ~= false
@@ -560,7 +764,7 @@ detailsFramework.IconGenericMixin = {
self:AlignAuraIcons()
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
AlignAuraIcons = function(self)
local iconPool = self.IconPool
local iconAmount = #iconPool
@@ -604,22 +808,30 @@ detailsFramework.IconGenericMixin = {
if (growDirection == 1) then --grow to right
if (bIsFirstIcon) then
local attachSide = (bIsCenterAligned and "center") or (nWhichSide and not detailsFramework.SideIsCorner[nWhichSide] and "left") or "bottomleft"
PixelUtil.SetPoint(iconFrame, attachSide, anchorTo, attachSide, 0, 0)
if (self.options.first_icon_use_anchor) then
detailsFramework:SetAnchor(iconFrame, self.options.anchor, self)
else
local attachSide = (bIsCenterAligned and "center") or (nWhichSide and not detailsFramework.SideIsCorner[nWhichSide] and "left") or "bottomleft"
PixelUtil.SetPoint(iconFrame, attachSide, anchorTo, attachSide, 0, 0)
end
else
PixelUtil.SetPoint(iconFrame, "left", anchorTo, "right", xPadding, 0)
end
elseif (growDirection == 2) then --grow to left
if (bIsFirstIcon) then
local attachSide = (bIsCenterAligned and "center") or (nWhichSide and not detailsFramework.SideIsCorner[nWhichSide] and "right") or "bottomright"
PixelUtil.SetPoint(iconFrame, attachSide, anchorTo, attachSide, 0, 0)
if (self.options.first_icon_use_anchor) then
detailsFramework:SetAnchor(iconFrame, self.options.anchor, self)
else
local attachSide = (bIsCenterAligned and "center") or (nWhichSide and not detailsFramework.SideIsCorner[nWhichSide] and "right") or "bottomright"
PixelUtil.SetPoint(iconFrame, attachSide, anchorTo, attachSide, 0, 0)
end
else
PixelUtil.SetPoint(iconFrame, "right", anchorTo, "left", xPadding, 0)
end
end
width = width + ((iconFrame.width or iconFrame:GetWidth()) * iconFrame:GetScale()) + 1
width = width + ((iconFrame.width or iconFrame:GetWidth())) + 1 --* iconFrame:GetScale() removed the getscale as now the scale are applied to the width and height
end
if (bIsCenterAligned) then
@@ -636,13 +848,13 @@ detailsFramework.IconGenericMixin = {
end
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
GetIconGrowDirection = function(self)
local side = self.options.anchor.side
return detailsFramework.GrowDirectionBySide[side]
end,
---@param self df_iconrow the parent frame
---@param self df_iconrow_generic the parent frame
OnOptionChanged = function(self, optionName)
if (self.SetBackdropColor) then
self:SetBackdropColor(unpack(self.options.backdrop_color))
@@ -651,19 +863,18 @@ detailsFramework.IconGenericMixin = {
end,
}
local default_icon_row_options = {
---@type df_iconrow_generic_options
local default_iconrow_generic_options = {
icon_width = 20,
icon_height = 20,
texcoord = {.1, .9, .1, .9},
show_text = true,
show_text = false,
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,
text_anchor = {side = 9, x = 0, y = 0},
text_alpha_by_percent = false,
desc_text = true,
desc_text_color = {1, 1, 1, 1},
desc_text_size = 7,
@@ -691,29 +902,35 @@ local default_icon_row_options = {
anchor = {side = 6, x = 2, y = 0},
grow_direction = 1, --1 = to right 2 = to left
center_alignment = false, --if true if will align the icons with grow_direction and then set the iconRow width to match the length used by all icons
surpress_blizzard_cd_timer = false,
show_cooldown = false,
surpress_tulla_omni_cc = false,
on_tick_cooldown_update = true,
decimal_timer = false,
decimal_timer = false, --nop, not in use
cooldown_reverse = false,
cooldown_swipe_enabled = true,
cooldown_edge_texture = "Interface\\Cooldown\\edge",
cooldown_max_brightness = 0.7,
surpress_blizzard_cd_timer = false,
on_tick_cooldown_update = true, --nop, not in use
show_horizontal_swipe = true,
swipe_progressive_color = true,
swipe_alpha = 0.5,
swipe_brightness = 0.5,
swipe_color = {0, 0, 0},
swipe_yellow = false,
swipe_red = false,
swipe_percent1 = 0.75,
swipe_percent2 = 0.90,
swipe_color = {0, 0, 0}, --this variable is having conflicts because it's in use by other things
swipe_color_start = {0, 1, 0},
swipe_color_end = {1, 0, 0},
--first_icon_anchor = "auto",
remove_on_finish = false,
first_icon_use_anchor = false,
}
---@param parent frame
---@param name string?
---@param options table?
---@return df_iconrow
---@return df_iconrow_generic
function detailsFramework:CreateIconRowGeneric(parent, name, options)
local newIconRowFrame = CreateFrame("frame", name, parent, "BackdropTemplate")
newIconRowFrame.IconPool = {}
@@ -724,7 +941,7 @@ function detailsFramework:CreateIconRowGeneric(parent, name, options)
detailsFramework:Mixin(newIconRowFrame, detailsFramework.IconGenericMixin)
detailsFramework:Mixin(newIconRowFrame, detailsFramework.OptionsFunctions)
newIconRowFrame:BuildOptionsTable(default_icon_row_options, options)
newIconRowFrame:BuildOptionsTable(default_iconrow_generic_options, options)
newIconRowFrame:SetSize(1, 1)
+8 -3
View File
@@ -111,14 +111,14 @@ local cornerNames = {"TopLeft", "TopRight", "BottomLeft", "BottomRight"}
local setCornerPoints = function(self, textures, width, height, xOffset, yOffset, bIsBorder)
for cornerName, thisTexture in pairs(textures) do
PixelUtil.SetSize(thisTexture, width or 16, height or 16)
thisTexture:SetTexture(self.options.corner_texture)
thisTexture:SetTexture(self.options.corner_texture, "CLAMP", "CLAMP", "TRILINEAR")
--set the mask
if (not thisTexture.MaskTexture and bIsBorder) then
thisTexture.MaskTexture = self:CreateMaskTexture(nil, "background")
thisTexture.MaskTexture:SetSize(74, 64)
thisTexture:AddMaskTexture(thisTexture.MaskTexture)
thisTexture.MaskTexture:SetTexture([[Interface\Azerite\AzeriteGoldRingRank2]]) --1940690
thisTexture.MaskTexture:SetTexture([[Interface\Azerite\AzeriteGoldRingRank2]], "CLAMP", "CLAMP", "TRILINEAR") --1940690
--thisTexture.MaskTexture:Hide()
end
@@ -300,7 +300,7 @@ detailsFramework.RoundedCornerPanelMixin = {
---@type height
local frameHeight = self:GetHeight()
if (frameHeight < 32) then
if (false and frameHeight < 32) then
local newCornerSize = frameHeight / 2
--set the new size of the corners on all corner textures
@@ -419,6 +419,11 @@ detailsFramework.RoundedCornerPanelMixin = {
return self:GetHeight() - (borderTexture:GetHeight() * 2) + 2
elseif (alignment == "horizontal") then
if (self.tabSide) then
if (self.tabSide == "left" or self.tabSide == "right") then
return self:GetWidth() - (borderTexture:GetHeight() * 2) + 2 - borderTexture:GetHeight()
end
end
return self:GetWidth() - (borderTexture:GetHeight() * 2) + 2
end
+100 -8
View File
@@ -334,11 +334,11 @@ local grid_scrollbox_options = {
---create a scrollbox with a grid layout
---@param parent frame
---@param name string
---@param refreshFunc function
---@param refreshFunc fun(button:frame, data:table)
---@param data table
---@param createColumnFrameFunc function
---@param createColumnFrameFunc fun(line:frame, lineIndex:number, columnIndex:number)
---@param options df_gridscrollbox_options?
---@return unknown
---@return df_gridscrollbox
function detailsFramework:CreateGridScrollBox(parent, name, refreshFunc, data, createColumnFrameFunc, options)
options = options or {}
@@ -428,25 +428,117 @@ function detailsFramework:CreateGridScrollBox(parent, name, refreshFunc, data, c
scrollBox.OnSetData = onSetData
onSetData(scrollBox, data)
---@cast scrollBox df_gridscrollbox
return scrollBox
end
function detailsFramework.CreateRoundedOptionsScrollBox(parent, name, onRefreshButton, onSelectOption, tbdData, createSelectorButton, gridScrollBoxOptions)
---create a scrollbox with a grid layout to be used as a menu
---@param parent frame
---@param name string?
---@param refreshMeFunc fun(gridScrollBox:df_gridscrollbox, searchText:string)
---@param refreshButtonFunc fun(button:button, data:table)
---@param clickFunc fun(button:button, data:table)
---@param onCreateButton fun(button:button, lineIndex:number, columnIndex:number)
---@param gridScrollBoxOptions df_gridscrollbox_options
---@return df_gridscrollbox
function detailsFramework:CreateMenuWithGridScrollBox(parent, name, refreshMeFunc, refreshButtonFunc, clickFunc, onCreateButton, gridScrollBoxOptions)
local dataSelected = nil
local gridScrollBox
local onClickButtonSelectorButton = function(blizzButton, buttonDown, dfButton, data)
dataSelected = data
gridScrollBox:Refresh()
xpcall(clickFunc, geterrorhandler(), dfButton, data)
end
--create a search bar to filter the auras
local searchText = ""
local onSearchTextChangedCallback = function(self, ...)
local text = self:GetText()
searchText = string.lower(text)
dataSelected = nil
gridScrollBox:RefreshMe()
end
local searchBox = detailsFramework:CreateSearchBox(parent, onSearchTextChangedCallback)
---when the scroll is refreshing the line, the line will call this function for each selection button on it
---@param button df_button
---@param data table
local refreshAuraSelectorFrame = function(button, data)
local refreshLine = function(button, data)
button.data = data
if (data.tooltip) then
button.tooltip = data.tooltip
end
xpcall(onRefreshButton, geterrorhandler(), button, data)
--set what happen when the user clicks the button
button:SetClickFunction(onSelectOption, button, data)
button:SetClickFunction(onClickButtonSelectorButton, button, data)
if (button.data == dataSelected) then
button.widget:SetBorderCornerColor(.9, .9, .9)
else
button.widget:SetBorderCornerColor(unpack(gridScrollBoxOptions.roundedFramePreset.border_color))
end
xpcall(refreshButtonFunc, geterrorhandler(), button, data)
end
--create a line
local createButton = function(line, lineIndex, columnIndex)
local width = gridScrollBoxOptions.width / gridScrollBoxOptions.columns_per_line - 5
local height = gridScrollBoxOptions.line_height
if (not height) then
height = 30
end
local button = detailsFramework:CreateButton(line, onClickButtonSelectorButton, width, height)
detailsFramework:AddRoundedCornersToFrame(button.widget, gridScrollBoxOptions.roundedFramePreset)
button.textsize = 11
button:SetHook("OnEnter", function(self)
local dfButton = self:GetObject()
GameCooltip:Reset()
if (dfButton.spellId) then
GameCooltip:SetSpellByID(dfButton.spellId)
GameCooltip:SetOwner(self)
GameCooltip:Show()
end
self:SetBorderCornerColor(.9, .9, .9)
end)
button:SetHook("OnLeave", function(self)
GameCooltip:Hide()
local dfButton = self:GetObject()
if (dfButton.data == dataSelected) then
self:SetBorderCornerColor(.9, .9, .9)
else
self:SetBorderCornerColor(unpack(gridScrollBoxOptions.roundedFramePreset.border_color))
end
end)
xpcall(onCreateButton, geterrorhandler(), button, lineIndex, columnIndex)
return button
end
gridScrollBox = detailsFramework:CreateGridScrollBox(parent, name, refreshLine, {}, createButton, gridScrollBoxOptions)
gridScrollBox:SetBackdrop({})
gridScrollBox:SetBackdropColor(0, 0, 0, 0)
gridScrollBox:SetBackdropBorderColor(0, 0, 0, 0)
gridScrollBox.__background:Hide()
gridScrollBox:Show()
gridScrollBox.searchBox = searchBox
searchBox:SetPoint("bottomleft", gridScrollBox, "topleft", 0, 2)
searchBox:SetWidth(gridScrollBoxOptions.width)
function gridScrollBox:RefreshMe()
xpcall(refreshMeFunc, geterrorhandler(), gridScrollBox, searchBox:GetText())
end
return gridScrollBox
end
--Need to test this and check the "same_name_spells_add(value)" on the OnEnter function
+71 -8
View File
@@ -885,13 +885,26 @@ local get_switch_func = function(self)
return self.OnSwitch
end
local setCheckedTexture = function(self, texture, xOffSet, yOffSet)
self.checked_texture:SetTexture(texture)
local setCheckedTexture = function(self, texture, xOffSet, yOffSet, sizePercent, color)
if (texture) then
self.checked_texture:SetTexture(texture, "CLAMP", "CLAMP", "TRILINEAR")
end
if (xOffSet or yOffSet) then
self.checked_texture:SetPoint("center", self.button, "center", xOffSet or -1, yOffSet or -1)
else
self.checked_texture:SetPoint("center", self.button, "center", -1, -1)
end
if (sizePercent and type(sizePercent) == "number") then
local width = self:GetWidth() * sizePercent
self.checked_texture:SetSize(width, width)
end
if (color) then
local r, g, b, a = DF:ParseColors(color)
self.checked_texture:SetVertexColor(r, g, b, a)
end
end
local set_as_checkbok = function(self)
@@ -904,6 +917,7 @@ local set_as_checkbok = function(self)
self.checked_texture = checked
self.SetCheckedTexture = setCheckedTexture
self.SetChecked = switch_set_value
self._thumb:Hide()
self._text:Hide()
@@ -1041,6 +1055,14 @@ function DF:NewSwitch(parent, container, name, member, width, height, leftText,
end
function DFSliderMetaFunctions:SetTemplate(template)
if (type(template) == "string") then
local templateName = template
template = DF:GetTemplate("switch", templateName)
if (not template) then
print("no template found", templateName)
end
end
--slider e switch
if (template.width) then
PixelUtil.SetWidth(self.widget, template.width)
@@ -1103,13 +1125,54 @@ function DFSliderMetaFunctions:SetTemplate(template)
local r, g, b, a = DF:ParseColors(template.disabled_backdropcolor)
self.backdrop_disabledcolor = {r, g, b, a}
end
if (template.is_checkbox) then
self:SetAsCheckBox()
self:SetCheckedTexture(template.checked_texture, template.checked_xoffset or 0, template.checked_yoffset or 0, template.checked_size_percent or 0.7, template.checked_color)
end
if (template.rounded_corner) then
self:SetBackdrop(nil)
DF:AddRoundedCornersToFrame(self.widget or self, template.rounded_corner)
end
end
function DF:CreateSlider (parent, w, h, min, max, step, defaultv, isDecemal, member, name, with_label, slider_template, label_template)
local slider, label = DF:NewSlider (parent, parent, name, member, w, h, min, max, step, defaultv, isDecemal, false, with_label, slider_template, label_template)
return slider, label
--DF:Mixin(DFSliderMetaFunctions, DF.SetPointMixin)
--DF:Mixin(DFSliderMetaFunctions, DF.FrameMixin)
--DF:Mixin(DFSliderMetaFunctions, DF.TooltipHandlerMixin)
---@class df_slider : slider, df_scripthookmixin
---@field widget slider
---@field slider slider
---@field type string
---@field dframework boolean
---@field SetTemplate fun(self:df_slider, template: table|string)
---@field SetFixedParameter fun(value: any)
---@field GetFixedParameter fun()
---@field SetValueNoCallback fun(value: number)
---@field SetThumbSize fun(width:number, height:number)
---@field ClearFocus fun()
---@param parent frame
---@param width number? default 150
---@param height number? default 20
---@param minValue number? default 1
---@param maxValue number? default 2
---@param step number? default 1
---@param defaultv number? default to minValue
---@param isDecemal boolean? default false
---@param member string?
---@param name string?
---@param label string?
---@param sliderTemplate string|table|nil
---@param labelTemplate string|table|nil
---@return df_slider, df_label?
function DF:CreateSlider (parent, width, height, minValue, maxValue, step, defaultv, isDecemal, member, name, label, sliderTemplate, labelTemplate)
local slider, labelText = DF:NewSlider(parent, parent, name, member, width, height, minValue, maxValue, step, defaultv, isDecemal, false, label, sliderTemplate, labelTemplate)
return slider, labelText
end
---@return df_slider, df_label?
function DF:NewSlider (parent, container, name, member, width, height, minValue, maxValue, step, defaultValue, isDecemal, isSwitch, with_label, slider_template, label_template)
if (not name) then
name = "DetailsFrameworkSlider" .. DF.SliderCounter
@@ -1117,7 +1180,7 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
end
if (not parent) then
return error("Details! FrameWork: parent not found.", 2)
error("Details! FrameWork: parent not found.", 2)
end
if (not container) then
@@ -1148,8 +1211,8 @@ function DF:NewSlider (parent, container, name, member, width, height, minValue,
step = step or 1
defaultValue = defaultValue or minValue
width = width or 130
height = height or 19
width = width or 160
height = height or 20
--default members
SliderObject.lockdown = false
+45
View File
@@ -722,6 +722,51 @@ function detailsFramework:NewTextEntry(parent, container, name, member, width, h
return newTextEntryObject, withLabel
end
---create a search box with no backdrop, a magnifying glass icon and a clear search button
---@param parent frame
---@param callback any
---@return df_textentry
function detailsFramework:CreateSearchBox(parent, callback)
local onSearchPressEnterCallback = function(_, _, text, self)
callback(self)
end
local searchBox = detailsFramework:CreateTextEntry(parent, onSearchPressEnterCallback, 220, 26)
searchBox:SetAsSearchBox()
searchBox:SetTextInsets(25, 5, 0, 0)
searchBox:SetBackdrop(nil)
searchBox:SetHook("OnTextChanged", callback)
local file, size, flags = searchBox:GetFont()
searchBox:SetFont(file, 12, flags)
searchBox.ClearSearchButton:SetAlpha(0)
searchBox.BottomLineTexture = searchBox:CreateTexture(nil, "border")
searchBox.BottomLineTexture:SetPoint("bottomleft", searchBox.widget, "bottomleft", -15, 0)
searchBox.BottomLineTexture:SetPoint("bottomright", searchBox.widget, "bottomright", 0, 0)
local bUseAtlasSize = false
searchBox.BottomLineTexture:SetAtlas("common-slider-track")
searchBox.BottomLineTexture:SetHeight(8)
--create the button to clear the search box
searchBox.ClearSearchButton = CreateFrame("button", nil, searchBox.widget, "UIPanelCloseButton")
searchBox.ClearSearchButton:SetPoint("right", searchBox.widget, "right", -3, 0)
searchBox.ClearSearchButton:SetSize(10, 10)
searchBox.ClearSearchButton:SetAlpha(0.3)
searchBox.ClearSearchButton:GetNormalTexture():SetAtlas("common-search-clearbutton")
searchBox.ClearSearchButton:GetHighlightTexture():SetAtlas("common-search-clearbutton")
searchBox.ClearSearchButton:GetPushedTexture():SetAtlas("common-search-clearbutton")
searchBox.ClearSearchButton:SetScript("OnClick", function()
searchBox:SetText("")
searchBox:PressEnter()
searchBox:ClearFocus()
end)
return searchBox
end
function detailsFramework:NewSpellEntry(parent, func, width, height, param1, param2, member, name)
local editbox = detailsFramework:NewTextEntry(parent, parent, name, member, width, height, func, param1, param2)
return editbox
File diff suppressed because it is too large Load Diff