Skip to content

Commit

Permalink
Another round of polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Mar 5, 2024
1 parent b1a7c5e commit a155ec5
Show file tree
Hide file tree
Showing 27 changed files with 677 additions and 270 deletions.
6 changes: 6 additions & 0 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
---@field container_type table<containertype, string> [containertype] = "damage" or "heal" or "energy" or "utility"
---@field TextureAtlas table<atlasname, df_atlasinfo>
---@field playername string
---@field breakdown_general profile_breakdown_settings
---@field
---@field GetDisplayClassByDisplayId fun(self: details, displayId: number) : table -return the class object for the given displayId (attributeId)
---@field GetTextureAtlas fun(self: details, atlasName: atlasname) : df_atlasinfo return the texture atlas data
Expand Down Expand Up @@ -787,3 +788,8 @@
---@class details222 : table
---@field TimeMachine timemachine

---@class profile_breakdown_settings : table
---@field font_size number
---@field font_color color
---@field font_outline outline
---@field font_face string
5 changes: 3 additions & 2 deletions Libs/DF/buildmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local _
---@field desc string
---@field descPhraseId string
---@field hooks table
---@field include_default boolean

---@class df_menu_toggle : df_menu_table
---@field set function
Expand Down Expand Up @@ -962,7 +963,7 @@ function detailsFramework:BuildMenuVolatile(parent, menuOptions, xOffset, yOffse

do
if (widgetTable.type == "selectfont") then
local func = detailsFramework:CreateFontListGenerator(widgetTable.set)
local func = detailsFramework:CreateFontListGenerator(widgetTable.set, widgetTable.include_default)
dropdown:SetFunction(func)

elseif (widgetTable.type == "selectcolor") then
Expand Down Expand Up @@ -1202,7 +1203,7 @@ function detailsFramework:BuildMenu(parent, menuOptions, xOffset, yOffset, heigh
local dropdown
do
if (widgetTable.type == "selectfont") then
dropdown = detailsFramework:CreateFontDropDown(parent, widgetTable.set, widgetTable.get(), widgetWidth or 140, widgetHeight or defaultHeight, nil, "$parentWidget" .. index, dropdownTemplate)
dropdown = detailsFramework:CreateFontDropDown(parent, widgetTable.set, widgetTable.get(), widgetWidth or 140, widgetHeight or defaultHeight, nil, "$parentWidget" .. index, dropdownTemplate, widgetTable.include_default)

elseif (widgetTable.type == "selectcolor") then
dropdown = detailsFramework:CreateColorDropDown(parent, widgetTable.set, widgetTable.get(), widgetWidth or 140, widgetHeight or defaultHeight, nil, "$parentWidget" .. index, dropdownTemplate)
Expand Down
6 changes: 2 additions & 4 deletions Libs/DF/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,7 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
---width, height, icon|table, textcolor, textsize, textfont, textalign, backdrop, backdropcolor, backdropbordercolor, onentercolor, onleavecolor, onenterbordercolor, onleavebordercolor
---@param template table|string
function ButtonMetaFunctions:SetTemplate(template)
if (type(template) == "string") then
template = detailsFramework:GetTemplate("button", template)
end
template = detailsFramework:ParseTemplate(self.type, template)

if (not template) then
detailsFramework:Error("template not found")
Expand Down Expand Up @@ -859,7 +857,7 @@ end
self:SetScript("OnEnable", onEnableFunc)
end

---@class df_button : button, df_scripthookmixin
---@class df_button : button, df_scripthookmixin, df_widgets
---@field widget button
---@field tooltip string
---@field shown boolean
Expand Down
72 changes: 69 additions & 3 deletions Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,57 @@
---@field nativeHeight number?
---@field desaturated boolean?
---@field desaturation number?
---@field atlas string?

---@alias templatetype
---@alias df_templatename string

---@class df_template : table
---@field width any
---@field height any
---@field backdrop any
---@field backdropcolor any
---@field backdropbordercolor any
---@field onentercolor any
---@field onleavecolor any
---@field onenterbordercolor any
---@field onleavebordercolor any
---@field icon any
---@field size any
---@field textsize any
---@field font any
---@field textfont any
---@field color any
---@field textcolor any
---@field textalign any
---@field rounded_corner any
---@field thumbtexture any
---@field slider_left any
---@field slider_right any
---@field slider_middle any
---@field thumbwidth any
---@field thumbheight any
---@field thumbcolor any
---@field amount_color any
---@field amount_outline any
---@field amount_size any
---@field enabled_backdropcolor any
---@field disabled_backdropcolor any
---@field is_checkbox any
---@field checked_texture any
---@field checked_xoffset any
---@field checked_yoffset any
---@field checked_size_percent any
---@field checked_color any



---@class df_widgets : table
---@field type string
---@field dframework boolean
---@field container frame
---@field widget frame

---@alias templatecategory
---| "font"
---| "dropdown"
---| "button"
Expand Down Expand Up @@ -75,6 +124,12 @@
---@field AnchorPoints string[]
---@field alias_text_colors table<string, number[]>
---@field ClassFileNameToIndex table<string, number> engClass -> classIndex
---@field ClientLanguage string
---@field dropdown_templates table<df_templatename, df_template>
---@field switch_templates table<df_templatename, df_template>
---@field button_templates table<df_templatename, df_template>
---@field slider_templates table<df_templatename, df_template>
---@field font_templates table<df_templatename, df_template>
---@field LoadSpellCache fun(self:table, hashMap:table, indexTable:table, allSpellsSameName:table) : hashMap:table, indexTable:table, allSpellsSameName:table load all spells in the game and add them into the passed tables
---@field UnloadSpellCache fun(self:table) wipe the table contents filled with LoadSpellCache()
---@field GetCurrentClassName fun(self:table) : string return the name of the class the player is playing
Expand Down Expand Up @@ -106,9 +161,10 @@
---@field GetFontSize fun(self:table, fontstring:fontstring) : number return the font size of the fontstring
---@field SetFontColor fun(self:table, fontstring:fontstring, red:any, green:number?, blue:number?, alpha:number?)
---@field SetFontFace fun(self:table, fontstring:fontstring, font:string)
---@field SetFontDefault fun(self:table, fontstring:fontstring)
---@field GetFontFace fun(self:table, fontstring:fontstring) : string return the font face of the fontstring
---@field SetFontShadow fun(self:table, fontstring:fontstring, red:any, green:number?, blue:number?, alpha:number?, offsetX:number?, offsetY:number?)
---@field SetFontOutline fun(self:table, fontstring:fontstring, outline:fontflags)
---@field SetFontOutline fun(self:table, fontstring:fontstring, outline:outline)
---@field RemoveRealmName fun(self:table, name:string) : string, number remove the realm name from the player name, must be in the format of "name-realm"
---@field RemoveOwnerName fun(self:table, name:string) : string, number removes the owner name from a name string, the owner name must be between < and >
---@field CleanUpName fun(self:table, name:string) : string removes the realm name and owner name from a name string
Expand All @@ -135,7 +191,7 @@
---@field NewColor fun(self:table, colorName:string, red:number, green:number, blue:number, alpha:number?) : table
---@field CreateKeybindFrame fun(self:table, parent:frame, name:string?, options:table?, setKeybindCallback:function?, keybindData:table?) : df_keybindframe
---@field CreateStatusBar fun(self:table, parent:frame, options:table?) : frame
---@field GetTemplate fun(self:table, templateType:templatetype, templateName:string) : table
---@field GetTemplate fun(self:table, templatecategory:templatecategory, templateName:string) : table
---@field UpdateLoadConditionsTable fun(self:table, loadConditionsTable:table)
---@field IconPick fun(self:table, callback:function, bCloseWhenSelect:boolean?, param1:any?, param2:any?)
---@field OpenLoadConditionsPanel fun(self:table, optionsTable:table, callback:function, frameOptions:table?)
Expand Down Expand Up @@ -193,7 +249,17 @@
---@field IsTexture fun(self:table, texture:any, bCheckTextureObject: boolean?) : boolean
---@field CreateAtlasString fun(self:table, atlas:atlasinfo|atlasname, textureHeight:number?, textureWidth:number?) : string
---@field SetMask fun(self:table, texture:texture, maskTexture:atlasname|texturepath|textureid) : nil
---@field GetClientRegion fun(self:table) : string
---@field GetBestFontPathForLanguage fun(self:table, languageId:string) : string
---@field SetTemplate fun(self:table, frame:uiobject, template:string)
---@field ParseTemplate fun(self:table, templateCategory:string, template:string|table) : table
---@field GetParentName fun(self:table, frame:uiobject) : string
---@field IsLatinLanguage fun(self:table, languageId:string) : boolean
---@field
---@field
---@field




--[=[
Expand Down
27 changes: 13 additions & 14 deletions Libs/DF/dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ function DetailsFrameworkDropDownOnHide(self)
end

local iconSizeTable = {16, 16}
function DF:BuildDropDownFontList(onClick, icon, iconTexcoord, iconSize)
function DF:BuildDropDownFontList(onClick, icon, iconTexcoord, iconSize, bIncludeDefault)
local fontTable = {}

local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
Expand All @@ -1006,20 +1006,18 @@ function DF:BuildDropDownFontList(onClick, icon, iconTexcoord, iconSize)

table.sort(fontTable, function(t1, t2) return t1.label < t2.label end)

if (bIncludeDefault) then
table.insert(fontTable, 1, {value = "DEFAULT", label = "DEFAULT", onclick = onClick, icon = icon, iconsize = iconSizeTable, texcoord = iconTexcoord, font = "", descfont = "abcdefg ABCDEFG"})
end

return fontTable
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
template = DF:ParseTemplate(self.type, template)

self.template = template

Expand Down Expand Up @@ -1101,7 +1099,7 @@ end
------------------------------------------------------------------------------------------------------------
--object constructor

---@class df_dropdown : table, frame
---@class df_dropdown : table, frame, df_widgets
---@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 SetFunction fun(self:df_dropdown, func:function)
Expand All @@ -1119,8 +1117,8 @@ end
---return a function which when called returns a table filled with all fonts available and ready to be used on dropdowns
---@param callback function
---@return function
function DF:CreateFontListGenerator(callback)
return function() return DF:BuildDropDownFontList(callback, [[Interface\AnimCreate\AnimCreateIcons]], {0, 32/128, 64/128, 96/128}, 16) end
function DF:CreateFontListGenerator(callback, bIncludeDefault)
return function() return DF:BuildDropDownFontList(callback, [[Interface\AnimCreate\AnimCreateIcons]], {0, 32/128, 64/128, 96/128}, 16, bIncludeDefault) end
end

local colorGeneratorStatusBarTexture = [[Interface\Tooltips\UI-Tooltip-Background]]
Expand Down Expand Up @@ -1204,8 +1202,9 @@ end
---@param member string?
---@param name string?
---@param template table?
function DF:CreateFontDropDown(parent, callback, default, width, height, member, name, template)
local func = DF:CreateFontListGenerator(callback)
---@param bIncludeDefault boolean?
function DF:CreateFontDropDown(parent, callback, default, width, height, member, name, template, bIncludeDefault)
local func = DF:CreateFontListGenerator(callback, bIncludeDefault)
local dropDownObject = DF:NewDropDown(parent, parent, name, member, width, height, func, default, template)
return dropDownObject
end
Expand Down Expand Up @@ -1256,7 +1255,7 @@ function DF:NewDropDown(parent, container, name, member, width, height, func, de
end

if (name:find("$parent")) then
local parentName = DF.GetParentName(parent)
local parentName = DF:GetParentName(parent)
name = name:gsub("$parent", parentName)
end

Expand Down
80 changes: 0 additions & 80 deletions Libs/DF/frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,86 +14,6 @@ local defaultBorderColorTable = {0.1, 0.1, 0.1, 1}
---@type edgenames[]
local cornerNames = {"TopLeft", "TopRight", "BottomLeft", "BottomRight"}

---@class blz_backdrop : table
---@field TopLeftCorner texture
---@field TopRightCorner texture
---@field BottomLeftCorner texture
---@field BottomRightCorner texture
---@field TopEdge texture
---@field BottomEdge texture
---@field LeftEdge texture
---@field RightEdge texture
---@field Center texture

---@class cornertextures : table
---@field TopLeft texture
---@field TopRight texture
---@field BottomLeft texture
---@field BottomRight texture

---@class edgetextures : table
---@field Top texture
---@field Bottom texture
---@field Left texture
---@field Right texture

---@class df_roundedpanel_options : table
---@field width number
---@field height number
---@field use_titlebar boolean
---@field use_scalebar boolean
---@field title string
---@field scale number
---@field roundness number
---@field color any
---@field border_color any
---@field corner_texture texturepath|textureid
---@field horizontal_border_size_offset number?

---@class df_roundedpanel_preset : table, df_roundedpanel_options
---@field border_color any
---@field color any
---@field roundness number

---@class df_roundedcornermixin : table
---@field RoundedCornerConstructor fun(self:df_roundedpanel) --called from CreateRoundedPanel
---@field SetColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@field SetBorderCornerColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@field SetRoundness fun(self:df_roundedpanel, slope: number)
---@field GetCornerSize fun(self:df_roundedpanel) : width, height
---@field OnSizeChanged fun(self:df_roundedpanel) --called when the frame size changes
---@field CreateBorder fun(self:df_roundedpanel) --called from SetBorderCornerColor if the border is not created yet
---@field CalculateBorderEdgeSize fun(self:df_roundedpanel, alignment: "vertical"|"horizontal"): number --calculate the size of the border edge texture
---@field SetTitleBarColor fun(self:df_roundedpanel, red: any, green: number|nil, blue: number|nil, alpha: number|nil)
---@field GetMaxFrameLevel fun(self:df_roundedpanel) : number --return the max frame level of the frame and its children

---@class df_roundedpanel : frame, df_roundedcornermixin, df_optionsmixin, df_titlebar
---@field bHasBorder boolean
---@field bHasTitleBar boolean
---@field options df_roundedpanel_options
---@field cornerRoundness number
---@field CornerTextures cornertextures
---@field CenterTextures texture[]
---@field BorderCornerTextures cornertextures
---@field BorderEdgeTextures edgetextures
---@field TitleBar df_roundedpanel
---@field bIsTitleBar boolean
---@field TopLeft texture corner texture
---@field TopRight texture corner texture
---@field BottomLeft texture corner texture
---@field BottomRight texture corner texture
---@field TopEdgeBorder texture border edge
---@field BottomEdgeBorder texture border edge
---@field LeftEdgeBorder texture border edge
---@field RightEdgeBorder texture border edge
---@field TopLeftBorder texture border corner
---@field TopRightBorder texture border corner
---@field BottomLeftBorder texture border corner
---@field BottomRightBorder texture border corner
---@field TopHorizontalEdge texture texture connecting the top corners
---@field BottomHorizontalEdge texture texture connecting the bottom corners
---@field CenterBlock texture texture connecting the bottom left of the topleft corner with the top right of the bottom right corner

---@param self df_roundedpanel
---@param textures cornertextures
---@param width number|nil
Expand Down
Loading

0 comments on commit a155ec5

Please sign in to comment.