Skip to content

Commit

Permalink
General development and bug fixes (see commit description).
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Tercioo committed Feb 13, 2024
1 parent 18e7464 commit 2fd02ee
Show file tree
Hide file tree
Showing 19 changed files with 5,679 additions and 1,752 deletions.
61 changes: 49 additions & 12 deletions Libs/DF/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

43 changes: 32 additions & 11 deletions Libs/DF/dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
68 changes: 50 additions & 18 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 510
local dversion = 511
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -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"] = {
Expand All @@ -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},
Expand All @@ -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},
Expand Down Expand Up @@ -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
Expand All @@ -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

--[=[
Expand Down
Loading

0 comments on commit 2fd02ee

Please sign in to comment.