Skip to content

Commit

Permalink
Bug fixes, Framework update, General changes to accommodate new systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Feb 26, 2024
1 parent 483d9c6 commit 32adc61
Show file tree
Hide file tree
Showing 34 changed files with 1,804 additions and 527 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

otherplugins/
Blizzard_APIDocumentationGenerated/
.tmp.driveupload/
core/parser - FF.lua
core/parser_original.lua
core/windows - Copy.lua
Expand Down
2 changes: 1 addition & 1 deletion API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ table members: name, mapid, zone@
time = combat:GetCombatTime()
@COMMENTreturns the length of the combat in seconds, if the combat is in progress, returns the current elapsed time.@
minutes, seconds = GetFormatedCombatTime()
minutes, seconds = GetMSTime()
@COMMENTreturns the combat time formated with minutes and seconds.@
startDate, endDate = combat:GetDate()
Expand Down
2 changes: 1 addition & 1 deletion API.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ table members: name, mapid, zone
time = combat:GetCombatTime()
returns the length of the combat in seconds, if the combat is in progress, returns the current elapsed time.

minutes, seconds = GetFormatedCombatTime()
minutes, seconds = GetMSTime()
returns the combat time formated with minutes and seconds.

startDate, endDate = combat:GetDate()
Expand Down
165 changes: 154 additions & 11 deletions Definitions.lua

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Details.toc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ indent.lua
core\util.lua
functions\mixin.lua
API.lua
textures.lua

functions\ej_cache.lua
functions\events.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ indent.lua
core\util.lua
functions\mixin.lua
API.lua
textures.lua

functions\ej_cache.lua
functions\private.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ indent.lua
core\util.lua
functions\mixin.lua
API.lua
textures.lua

functions\ej_cache.lua
functions\private.lua
Expand Down
34 changes: 15 additions & 19 deletions Libs/DF/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
end
end

local noColor = {1, 1, 1, 1}

---add an icon to the left of the button text
---short method truncates the text: false = do nothing, nil = increate the button width, 1 = decrease the font size, 2 = truncate the text
---@param texture any
Expand All @@ -403,6 +405,16 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
self.widget.text:SetPoint("left", self.icon, "right", textDistance or 2, 0 + (textHeight or 0))
end

overlay = overlay or noColor
local red, green, blue, alpha = detailsFramework:ParseColors(overlay or noColor)

local left, right, top, bottom = texcoord and texcoord[1], texcoord and texcoord[2], texcoord and texcoord[3], texcoord and texcoord[4]
texture, width, height, left, right, top, bottom, red, green, blue, alpha = detailsFramework:ParseTexture(texture, width, height, left, right, top, bottom, red, green, blue, alpha)

if (red == nil) then
red, green, blue, alpha = 1, 1, 1, 1
end

if (type(texture) == "string") then
local isAtlas = C_Texture.GetAtlasInfo(texture)
if (isAtlas) then
Expand All @@ -414,33 +426,17 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin)
else
self.icon:SetTexture(texture)
end

elseif (type(texture) == "table") then
local r, g, b, a = detailsFramework:ParseColors(texture)
self.icon:SetColorTexture(r, g, b, a)
else
self.icon:SetTexture(texture)
end

self.icon:SetSize(width or self.height * 0.8, height or self.height * 0.8)

self.icon:SetDrawLayer(layout or "artwork")

if (texcoord) then
self.icon:SetTexCoord(unpack(texcoord))
else
self.icon:SetTexCoord(0, 1, 0, 1)
end
self.icon:SetTexCoord(left, right, top, bottom)

if (overlay) then
if (type(overlay) == "string") then
local r, g, b, a = detailsFramework:ParseColors(overlay)
self.icon:SetVertexColor(r, g, b, a)
else
self.icon:SetVertexColor(unpack(overlay))
end
else
self.icon:SetVertexColor(1, 1, 1, 1)
end
self.icon:SetVertexColor(red, green, blue, alpha)

local buttonWidth = self.button:GetWidth()
local iconWidth = self.icon:GetWidth()
Expand Down
18 changes: 15 additions & 3 deletions Libs/DF/cooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ if (not DF or not DetailsFrameworkCanLoad) then
return
end

local detailsFramework = DF

local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
local _

Expand All @@ -15,7 +17,7 @@ local max = math.max

--api locals
local PixelUtil = PixelUtil or DFPixelUtil
local version = 20
local version = 21

local CONST_MENU_TYPE_MAINMENU = "main"
local CONST_MENU_TYPE_SUBMENU = "sub"
Expand Down Expand Up @@ -3178,9 +3180,19 @@ function DF:CreateCoolTip()
if (gameCooltip.Indexes == 0) then
return gameCooltip:PrintDebug("AddIcon() requires an already added line (Cooltip:AddLine()).")
end

--check data integrity
if ((type(iconTexture) ~= "string" and type(iconTexture) ~= "number") and (type(iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture")) then
return gameCooltip:PrintDebug("AddIcon() invalid parameters.")
local bCheckTextureObject = true
if (not detailsFramework:IsTexture(iconTexture, bCheckTextureObject)) then
return gameCooltip:PrintDebug("AddIcon() invalid texture.")
end

--parse the texure
local red, green, blue, alpha
iconTexture, iconWidth, iconHeight, leftCoord, rightCoord, topCoord, bottomCoord, red, green, blue, alpha = detailsFramework:ParseTexture(iconTexture, iconWidth, iconHeight, leftCoord, rightCoord, topCoord, bottomCoord, overlayColor)

if (not overlayColor and red) then
overlayColor = {red, green, blue, alpha}
end

side = side or 1
Expand Down
58 changes: 55 additions & 3 deletions Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
---@field RegisterTableKeyWithLocTable fun(table:table, key:any, locTable:table, silence:boolean?)
---@field RegisterObjectWithLocTable fun(object:uiobject, locTable:table, silence:boolean?)

---@class df_atlasinfo : atlasinfo
---@field vertexRed number?
---@field vertexGreen number?
---@field vertexBlue number?
---@field vertexAlpha number?
---@field colorName string?
---@field nativeWidth number?
---@field nativeHeight number?

---@alias templatetype
---| "font"
---| "dropdown"
Expand All @@ -56,11 +65,13 @@
---@field KeybindMixin df_keybindmixin
---@field ScriptHookMixin df_scripthookmixin
---@field EditorMixin df_editormixin
---@field ScrollBoxFunctions df_scrollboxmixin
---@field ClassCache {ID:number, Name:string, FileString:string, Texture:string, TexCoord:number[]}[] only available after calling GetClassList()
---@field Math df_math
---@field FontOutlineFlags table<outline, boolean>
---@field table df_table_functions
---@field AnchorPoints string[]
---@field alias_text_colors table<string, number[]>
---@field ClassFileNameToIndex table<string, number> engClass -> classIndex
---@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()
Expand Down Expand Up @@ -108,7 +119,8 @@
---@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
---@field ApplyStandardBackdrop fun(self:table, frame:frame, bUseSolidColor:boolean?, alphaScale:number?)
---@field CreateLabel fun(self:table, parent:frame, text:string, size:number?, color:any?, font:string?, member:string?, name:string?, layer:drawlayer?) : df_label
---@field NewLabel fun(self:table, parent:frame, container:frame, name:string?, member:string?, text:string|table, font:string?, size:any?, color:any?, layer:drawlayer?) : df_label
---@field CreateLabel fun(self:table, parent:frame, text:string, size:any?, color:any?, font:string?, member:string?, name:string?, layer:drawlayer?) : df_label
---@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
Expand All @@ -118,7 +130,7 @@
---@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)
---@field GetAvailableSpells fun(self:table) : table<spellid, boolean>
---@field NewColor fun(self:table, colorName:string, red:number, green:number, blue:number, alpha:number)
---@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
Expand Down Expand Up @@ -153,9 +165,49 @@
---@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 CreateFrameContainer fun(self:table, parent:frame, options:table?, frameName:string?) : df_framecontainer create a frame container, which is a frame that envelops another frame, and can be moved, resized, etc.
---@field CreateAnimation fun(self:table, animationGroup:animationgroup, animationType:animationtype, order:number, duration:number, arg1:any, arg2:any, arg3:any, arg4:any, arg5:any, arg6:any, arg7:any, arg8:any) : animation
---@field NewImage fun(self:table, parent:frame, texture:atlasname|texturepath|textureid|df_gradienttable|nil, width:number?, height:number?, layer:drawlayer?, texCoord:table?, member:string?, name:string?) : df_image
---@field CreateTexture fun(self:table, parent:frame, texture:atlasname|texturepath|textureid|nil, width:number?, height:number?, layer:drawlayer?, coords:table?, member:string?, name:string?) : df_image
---@field CreateImage fun(self:table, parent:frame, texture:atlasname|texturepath|textureid|nil, width:number?, height:number?, layer:drawlayer?, coords:table?, member:string?, name:string?) : df_image
---@field CreateFrameShake fun(self:table, parent:uiobject, duration:number?, amplitude:number?, frequency:number?, absoluteSineX:boolean?, absoluteSineY:boolean?, scaleX:number?, scaleY:number?, fadeInTime:number?, fadeOutTime:number?, anchorPoints:table?) : df_frameshake
---@field SetTexCoordFromAtlasInfo fun(self:table, texture:texture, atlasInfo:atlasinfo) : nil
---@field
---@field TruncateNumber fun(self:table, number:number, fractionDigits:number) : number
---@field GetNpcIdFromGuid fun(self:table, GUID:string) : number
---@field SortOrder1 fun(t1:table, t2:table) : boolean
---@field SortOrder2 fun(t1:table, t2:table) : boolean
---@field SortOrder3 fun(t1:table, t2:table) : boolean
---@field SortOrder1R fun(t1:table, t2:table) : boolean
---@field SortOrder2R fun(t1:table, t2:table) : boolean
---@field SortOrder3R fun(t1:table, t2:table) : boolean
---@field Trim fun(self:table, string:string) : string
---@field trim fun(self:table, string:string) : string
---@field TruncateTextSafe fun(self:table, fontString:fontstring, maxWidth:number) : nil
---@field TruncateText fun(self:table, fontString:fontstring, maxWidth:number) : nil
---@field CleanTruncateUTF8String fun(self:table, text:string) : string
---@field GetSpellBookSpells fun(self:table) : table<string, boolean>, spellid[] return a list of spells from the player spellbook
---@field PreviewTexture fun(self:table, texture:atlasname|texturepath|textureid, left:number?, right:number?, top:number?, bottom:number?) : nil
---@field SetAtlas fun(self:table, textureObject:texture, atlas:atlasinfo|atlasname, useAtlasSize:boolean?, filterMode:texturefilter?, resetTexCoords:boolean?) : nil
---@field CreateAtlas fun(self:table, file:texturepath|textureid, width:number?, height:number?, leftTexCoord:number?, rightTexCoord:number?, topTexCoord:number?, bottomTexCoord:number?, tilesHorizontally:boolean?, tilesVertically:boolean?, vertexRed:any, vertexGreen:number?, vertexBlue:number?, vertexAlpha:number?) : atlasinfo
---@field ParseTexture fun(self:table, texture:texturepath|textureid|atlasname|atlasinfo, width: number?, height: number?, leftTexCoord: number?, rightTexCoord: number?, topTexCoord: number?, bottomTexCoord: number?, vertexRed:number|string?, vertexGreenvertexRed:number?, vertexBluevertexRed:number?, vertexAlphavertexRed:number?) : any, number?, number?, number?, number?, number?, number?, number?, number?, number?, number?, number?
---@field IsTexture fun(self:table, texture:any, bCheckTextureObject: boolean?) : boolean
---@field CreateAtlasString fun(self:table, atlas:atlasinfo|atlasname, textureHeight:number?, textureWidth:number?) : string
---@field

--[=[
Wrapped objects: when using the following functions, the object will be wrapped in a table, e.g. detailsFramework:CreateButton() will return a table with the button, the button will be accessible through the "button" key.
The wrapper table will have the same metatable as the wrapped object, so you can call methods on the wrapper table as if it was the wrapped object.
Example: local myButton = detailsFramework:CreateButton(); myButton:SetSize(100, 100) => will call SetSize(100, 100) on the button wrapped.
The wrapped object will be accessible through the "widget" key, e.g. local myButton = detailsFramework:CreateButton(); local actualButtonUIObject = myButton.widget.
Wrapped objects can give errors when used in some situations, like when passing them to the game API, in this case, you can use the "widget" key to access the actual object. This is very common on SetPoint calls where the game API expects a frame, not a table. Error exammple with SetPoints: "SetPoint(): Wrong object type for function".
The following functions will return a wrapped object:
- CreateButton, NewButton
- CreateColorPickButton
- CreateTexture, CreateImage, NewImage
- CreateSearchBox, NewSpellEntry, NewTextEntry, CreateTextEntry
- NewDropDown, CreateDropDown, CreateFontDropDown, CreateColorDropDown, CreateOutlineDropDown, CreateAnchorPointDropDown
- NewPanel, CreatePanel
- CreateSwitch, NewSwitch, NewSlider, CreateSlider
- NewLabel, CreateLabel
- NewSplitBar, CreateSplitBar
- CreateTimeBar
--]=]
38 changes: 34 additions & 4 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down Expand Up @@ -1166,6 +1166,8 @@ function DF:CleanUpName(name)
name = DF:RemoveRealmName(name)
name = DF:RemoveOwnerName(name)
name = name:gsub("%[%*%]%s", "")
--remove texture escape sequence
name = name:gsub("|T.-|t", "")
return name
end

Expand Down Expand Up @@ -1599,7 +1601,9 @@ function DF.SortOrder3R(t1, t2)
return t1[3] < t2[3]
end

--return a list of spells from the player spellbook
---return a list of spells from the player spellbook
---@return table<string, boolean> spellNamesInSpellBook
---@return spellid[] spellIdsInSpellBook
function DF:GetSpellBookSpells()
local spellNamesInSpellBook = {}
local spellIdsInSpellBook = {}
Expand Down Expand Up @@ -2036,10 +2040,15 @@ end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--colors

--add a new color name, the color can be query using DetailsFramework:ParseColors(colorName)
---add a new color name, the color can be query using DetailsFramework:ParseColors(colorName)
---@param colorName string
---@param red number
---@param green number
---@param blue number
---@param alpha number?
---@return table
function DF:NewColor(colorName, red, green, blue, alpha)
assert(type(colorName) == "string", "DetailsFramework:NewColor(): colorName must be a string.")
--assert(not DF.alias_text_colors[colorName], "DetailsFramework:NewColor(): colorName already exists.")

red, green, blue, alpha = DetailsFramework:ParseColors(red, green, blue, alpha)
local colorTable = DetailsFramework:FormatColor("table", red, green, blue, alpha)
Expand Down Expand Up @@ -5075,3 +5084,24 @@ function _G.__benchmark(bNotPrintResult)
end
end

function DF:PreviewTexture(texture, left, right, top, bottom)
local preview = DetailsFrameworkTexturePreview or CreateFrame("frame", "DetailsFrameworkTexturePreview", UIParent)
preview:SetSize(200, 200)
preview:SetPoint("center")
preview.texture = DetailsFrameworkTexturePreviewTexture or preview:CreateTexture("DetailsFrameworkTexturePreviewTexture", "artwork")
preview.texture:SetAllPoints()

--check if the texture passed is an atlas
if (type(texture) == "string" and C_Texture.GetAtlasInfo(texture)) then
preview.texture:SetAtlas(texture)

elseif (type(texture) == "table") then
preview.texture:SetTexture(texture.file or texture.filename)
preview.texture:SetTexCoord(texture.leftTexCoord, texture.rightTexCoord, texture.topTexCoord, texture.bottomTexCoord)
else
preview.texture:SetTexture(texture)
preview.texture:SetTexCoord(left or 0, right or 1, top or 0, bottom or 1)
end

preview:Show()
end
Loading

0 comments on commit 32adc61

Please sign in to comment.