Skip to content

Commit

Permalink
framework update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jul 9, 2024
1 parent 8031500 commit f6e5ca9
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 32 deletions.
10 changes: 10 additions & 0 deletions Libs/DF/buildmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,16 @@ end
---classes used by the menu builder on the menuOptions table on both functions BuildMenu and BuildMenuVolatile
---the menuOptions consists of a table with several tables inside in array, each table is a widget to be created
---class df_menu_label is used when the sub table of menuOptions has a key named "type" with the value "label" or "text"

--[=[
function detailsFramework:BuildMenu(parent, menuOptions, xOffset, yOffset, height, useColon, textTemplate, dropdownTemplate, switchTemplate, switchIsCheckbox, sliderTemplate, buttonTemplate, valueChangeHook)
local tNow = debugprofilestop()
detailsFramework:BuildMenu22(parent, menuOptions, xOffset, yOffset, height, useColon, textTemplate, dropdownTemplate, switchTemplate, switchIsCheckbox, sliderTemplate, buttonTemplate, valueChangeHook)
local tEnd = debugprofilestop()
print("BuildMenu for", (menuOptions.Name or "--"), floor(tEnd - tNow), "ms")
end
--]=]

function detailsFramework:BuildMenu(parent, menuOptions, xOffset, yOffset, height, useColon, textTemplate, dropdownTemplate, switchTemplate, switchIsCheckbox, sliderTemplate, buttonTemplate, valueChangeHook)
--how many widgets has been created on this line loop pass
local amountLineWidgetAdded = 0
Expand Down
4 changes: 3 additions & 1 deletion Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
---@field CreateColorPickButton fun(self:table, parent:frame, name:string?, member:string?, callback:function, alpha:number?, buttonTemplate:table?) : df_colorpickbutton
---@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 CreateAnimationHub fun(self:table, parent:uiobject, onPlay:function?, onFinished:function?) : animationgroup
---@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
Expand Down Expand Up @@ -321,8 +322,9 @@
---@field CreateMenuWithGridScrollBox fun(self:table, parent:frame, name:string?, refreshMeFunc:function, refreshButtonFunc:function, clickFunc:function, onCreateButton:function, gridScrollBoxOptions:df_gridscrollbox_options) : df_gridscrollbox create a scrollbox with a grid layout to be used as a menu
---@field CreateSearchBox fun(self:table, parent:frame, callback:function) : df_searchbox
---@field ConvertAnchorPointToInside fun(self:table, anchorPoint:anchorid) : anchorid
---@field CreateHeader fun(self:table, parent:frame, headerTable:df_headercolumndata[], options:table?, frameName:string?) : df_headerframe
---@field
---@field




Expand Down
11 changes: 10 additions & 1 deletion Libs/DF/dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,16 @@ end
function DetailsFrameworkDropDownOptionOnEnter(self)
if (self.table.desc) then
GameCooltip2:Preset(2)
GameCooltip2:AddLine(self.table.desc)

local addonId = self.table.addonId
if (addonId) then
local phraseId = self.table.desc
local text = DF.Language.GetText(addonId, phraseId)
GameCooltip2:AddLine(text or phraseId)
else
GameCooltip2:AddLine(self.table.desc)
end

if (self.table.descfont) then
GameCooltip2:SetOption("TextFont", self.table.descfont)
end
Expand Down
55 changes: 37 additions & 18 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down Expand Up @@ -44,13 +44,24 @@ local HasPetSpells = HasPetSpells or C_SpellBook.HasPetSpells
SMALL_NUMBER = 0.000001
ALPHA_BLEND_AMOUNT = 0.8400251

local _, _, _, buildInfo = GetBuildInfo()
--cache this stuff
local g, b, d, t = GetBuildInfo()
DF.BuildYear = tonumber(d:match("%d+$") or 0)
DF.GamePatch = g --string "10.2.7"
DF.BuildId = b --string "55000"
DF.Toc = t --number 100000
DF.Exp = floor(DF.Toc/10000)

local buildInfo = DF.Toc

DF.dversion = dversion

DF.AuthorInfo = {
Name = "Terciob",
Author = "",
Name = "Terciob", --terciob
Discord = "https://discord.gg/AGSzAZX",
Support = "www.patreon.com",
SearchVideos = "www.youtube.com",
}

function DF:Msg(msg, ...)
Expand Down Expand Up @@ -3320,6 +3331,8 @@ end
--animations

---create an animation 'hub' which is an animationGroup but with some extra functions
--tags: create, animation, hub, group, animationgroup, createanimationhub
--prompt example: create an animation group for the object 'variable name' with the start animation function doing 'what to do' and the finish animation function doing 'what to do'
---@param parent uiobject
---@param onPlay function?
---@param onFinished function?
Expand All @@ -3333,30 +3346,35 @@ function DF:CreateAnimationHub(parent, onPlay, onFinished)
return newAnimation
end

---* Create a new animation for an animation hub or group.
---animation descriptions:
--tags: animation, create, alpha, scale, translation, rotation, path, vertexcolor, color, animation type, animation duration, animation order, animation object, return variable
--prompt example: create a new animation of type 'alpha' for the animation group 'variable name', with an order of 'number', a duration of 'number', from alpha 'number' to alpha 'number'
---* Create a new animation for an animation hub created with CreateAnimationHub().
---* Alpha: CreateAnimation(animGroup, "Alpha", order, duration, fromAlpha, toAlpha).
---* Scale: CreateAnimation(animGroup, "Scale", order, duration, fromScaleX, fromScaleY, toScaleX, toScaleY, originPoint, x, y).
---* Translation: CreateAnimation(animGroup, "Translation", order, duration, xOffset, yOffset).
---* Rotation: CreateAnimation(animGroup, "Rotation", order, duration, degrees, originPoint, x, y).
---* Path: CreateAnimation(animGroup, "Path", order, duration, xOffset, yOffset, curveType).
---* VertexColor: CreateAnimation(animGroup, "VertexColor", order, duration, r1, g1, b1, a1, r2, g2, b2, a2).
---@param animationGroup animationgroup
---@param animationType animationtype
---@param order number
---@param duration number
---@param arg1 any
---@param arg2 any
---@param arg3 any
---@param arg4 any
---@param arg5 any
---@param arg6 any
---@param arg7 any
---@param arg8 any
---@param animationGroup animationgroup the animation group created with CreateAnimationHub()
---@param animationType animationtype "Alpha", "Scale", "Translation", "Rotation", "Path", "VertexColor"
---@param order number the order of the animation, the lower the number, the earlier the animation will play
---@param duration number the duration of the animation in seconds
---@param arg1 any for Alpha: fromAlpha, for Scale: fromScaleX, for Translation: xOffset, for Rotation: degrees, for Path: xOffset, for VertexColor: r1
---@param arg2 any for Alpha: toAlpha, for Scale: fromScaleY, for Translation: yOffset, for Rotation: originPoint, for Path: yOffset, for VertexColor: g1
---@param arg3 any for Scale: toScaleX, for VertexColor: blue1, for Rotation: originXOffset, for Path: curveType, for VertexColor: b1
---@param arg4 any for Scale: toScaleY, for VertexColor: a1, for Rotation: originYOffset, for VertexColor: a1
---@param arg5 any for Scale: originPoint, for VertexColor: r2
---@param arg6 any for Scale: originXOffset, for VertexColor: g2
---@param arg7 any for Scale: originYOffset, for VertexColor: b2
---@param arg8 any for VertexColor: a2
---@return animation
function DF:CreateAnimation(animationGroup, animationType, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
---@type animation
local anim = animationGroup:CreateAnimation(animationType)
--set the order of the animation, the 'order' parameter isn't passed, it will use the NextAnimation property of the animationGroup
anim:SetOrder(order or animationGroup.NextAnimation)
--set the duration of the animation
anim:SetDuration(duration)

animationType = string.upper(animationType)
Expand All @@ -3373,11 +3391,11 @@ function DF:CreateAnimation(animationGroup, animationType, order, duration, arg1
anim:SetFromScale(arg1, arg2)
anim:SetToScale(arg3, arg4)
end
anim:SetOrigin(arg5 or "center", arg6 or 0, arg7 or 0) --point, x, y
anim:SetOrigin(arg5 or "center", arg6 or 0, arg7 or 0) --point, originXOffset, originYOffset

elseif (animationType == "ROTATION") then
anim:SetDegrees(arg1) --degree
anim:SetOrigin(arg2 or "center", arg3 or 0, arg4 or 0) --point, x, y
anim:SetOrigin(arg2 or "center", arg3 or 0, arg4 or 0) --originPoint, originXOffset, originYOffset

elseif (animationType == "TRANSLATION") then
anim:SetOffset(arg1, arg2)
Expand All @@ -3403,6 +3421,7 @@ function DF:CreateAnimation(animationGroup, animationType, order, duration, arg1
r2, g2, b2, a2 = DF:ParseColors(r2)
end

--CreateColor is a function declared in the game api that return a table with the color values in keys r, g, b, a
anim:SetStartColor(CreateColor(r1, g1, b1, a1))
anim:SetEndColor(CreateColor(r2, g2, b2, a2))
end
Expand Down
15 changes: 13 additions & 2 deletions Libs/DF/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ local wipe = wipe

--definitions

---@class df_headercolumndata : {key: string, name: string, icon: string, texcoord: table, text: string, canSort: boolean, selected: boolean, width: number, height: number, align: string, offset: number}
---@class df_headercolumndata : table
---@field key string
---@field name string
---@field icon string
---@field texcoord table
---@field text string
---@field canSort boolean
---@field selected boolean
---@field width number
---@field height number
---@field align string
---@field offset number

---@class df_headerchild : uiobject
---@field FramesToAlign table
Expand Down Expand Up @@ -637,7 +648,7 @@ local default_header_options = {
---a header is used to organize columns giving them a name/title, a way to sort and align them.
---each column is placed on the right side of the previous column.
---@param parent frame
---@param headerTable table
---@param headerTable df_headercolumndata[]
---@param options table?
---@param frameName string?
---@return df_headerframe
Expand Down
28 changes: 20 additions & 8 deletions Libs/DF/schedules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ function detailsFramework.Schedules.NewTicker(time, callback, ...)
return newTicker
end

--schedule a task with an interval of @time
--schedule a function/callback/ to run after 'time' with a payload passed in the varargs
--return an object that can be used to cancel the scheduled task
--difference from Schedules.After is that this function returns an object that can be used to cancel the scheduled task and also pass a payload to the callback
--prompt example: schedule 'function variable name' to run after 'time' amount of seconds with payload 'variable name, variable name...'
--prompt example: run 'function name' after 'time' leaving an object as reference
function detailsFramework.Schedules.NewTimer(time, callback, ...)
local payload = {...}
local newTimer = C_Timer.NewTimer(time, triggerScheduledTick)
Expand All @@ -165,7 +169,9 @@ function detailsFramework.Schedules.NewTimer(time, callback, ...)
return newTimer
end

--cancel an ongoing ticker, the native call tickerObject:Cancel() also works with no problem
--cancel an ongoing ticker or timer, the native call tickerObject:Cancel() also works
---prompt example: cancel schedule 'variable name'
---@param tickerObject timer
function detailsFramework.Schedules.Cancel(tickerObject)
--ignore if there's no ticker object
if (tickerObject) then
Expand Down Expand Up @@ -262,16 +268,22 @@ function detailsFramework.Schedules.AfterById(time, callback, id, ...)
return newTimer
end


--schedule a task with an interval of @time without payload
--schedule a function to be called after 'time'
--prompt example: create a schedule that runs the function 'variable name' after 'time' amount of seconds
function detailsFramework.Schedules.After(time, callback)
C_Timer.After(time, callback)
end

function detailsFramework.Schedules.SetName(object, name)
object.name = name
end

--schedule a function to be called on the next frame
--prompt example: run 'function name' on next tick
---@param callback function
function detailsFramework.Schedules.RunNextTick(callback)
return detailsFramework.Schedules.After(0, callback)
end

--set a name to a scheduled object
---@param object timer
---@param name string
function detailsFramework.Schedules.SetName(object, name)
object.name = name
end
5 changes: 4 additions & 1 deletion Libs/DF/tabcontainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ local unpack = unpack
local CreateFrame = CreateFrame
local PixelUtil = PixelUtil

---@class df_tabinfotable : {name: string, text: string, createOnDemandFunc:function?}
---@class df_tabinfotable : table
---@field name string
---@field text string
---@field createOnDemandFunc function?

---@class df_tabcontainer : frame
---@field AllFrames df_tabcontainerframe[]
Expand Down
3 changes: 3 additions & 0 deletions Libs/DF/textentry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ function detailsFramework:NewTextEntry(parent, container, name, member, width, h
newTextEntryObject.editbox:SetAutoFocus(false)
newTextEntryObject.editbox:SetFontObject("GameFontHighlightSmall")

newTextEntryObject.editbox:SetJustifyH("left")
newTextEntryObject.editbox:SetTextInsets(5, 3, 0, 0)

--editbox label
newTextEntryObject.editbox.label = newTextEntryObject.editbox:CreateFontString("$parent_Desc", "OVERLAY", "GameFontHighlightSmall")
newTextEntryObject.editbox.label:SetJustifyH("left")
Expand Down
3 changes: 2 additions & 1 deletion Libs/LibLuaServer/LibLuaServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5291,8 +5291,9 @@ ToggleSpellAutocast = function() end
---@return string, string, number, number, boolean, string
UnitCastingInfo = function() return "", "", 0, 0, false, "" end

---@param unit string
---@return string, string, number, number, boolean, string
UnitChannelInfo = function() return "", "", 0, 0, false, "" end
UnitChannelInfo = function(unit) return "", "", 0, 0, false, "" end

---@param command string
ConsoleExec = function(command) end
Expand Down
4 changes: 4 additions & 0 deletions Libs/LibOpenRaid/GetPlayerInformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ local getSpellListAsHashTableFromSpellBook = function()
--get racials from the general tab
local generalIndex = Enum.SpellBookSkillLineIndex and Enum.SpellBookSkillLineIndex.General or CONST_SPELLBOOK_GENERAL_TABID
local tabName, tabTexture, offset, numSpells, isGuild, offspecId = GetSpellTabInfo(generalIndex) --CONST_SPELLBOOK_GENERAL_TABID
if (not offset) then
return completeListOfSpells
end

offset = offset + 1
local tabEnd = offset + numSpells
for entryOffset = offset, tabEnd - 1 do
Expand Down

0 comments on commit f6e5ca9

Please sign in to comment.