Framework Update

This commit is contained in:
Tercio Jose
2023-10-13 18:04:13 -03:00
parent da1e12c20f
commit 597371aba1
8 changed files with 324 additions and 434 deletions
+268 -394
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -19,13 +19,19 @@
---| "slider"
---@class detailsframework
---@field dversion number
---@field OptionsFunctions df_optionsmixin
---@field GlobalWidgetControlNames table
---@field RoundedCornerPanelMixin df_roundedcornermixin
---@field Schedules df_schedule
---@field HeaderFunctions df_headerfunctions
---@field KeybindMixin df_keybindmixin
---@field ScriptHookMixin df_scripthookmixin
---@field Math df_math
---@field table df_table_functions
---@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 GetSpellCaches fun(self:table) : table, table, table return the tables filled with LoadSpellCache()
---@field IsValidSpecId fun(self:table, specId:number):boolean check if the passed specId is valid for the player class, also return false for tutorial specs
---@field DebugVisibility fun(self:table, object:uiobject) print the reason why the frame isn't shown in the screen
---@field Dispatch fun(self:table, callback:function, ...) : any dispatch a function call using xpcall, print to chat if the function passed is invalid
@@ -81,5 +87,5 @@
---@field CreateSwitch fun(self:table, parent:frame, onSwitch:function, defaultValue:boolean, width:number?, height:number?, leftText:string?, rightText:string?, member:string?, name:string?, colorInverted:boolean?, switchFunc:function?, returnFunc:function?, withLabel:string?, switch_template:table?, label_template:table?) : df_checkbox, df_label?
---@field CreateCheckboxGroup fun(self:table, parent:frame, radioOptions:df_radiooptions[], name:string?, options:table?, anchorOptions:table?) : df_checkboxgroup
---@field CreateRadioGroup fun(self:table, parent:frame, radioOptions:df_radiooptions[], name:string?, options:table?, anchorOptions:table?) : df_radiogroup
---@field
---@field CreateAuraScrollBox fun(self:table, parent:frame, name:string?, data:table?, onRemoveCallback:function?, options:table?) : df_aurascrollbox
---@field
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 475
local dversion = 477
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
+1 -1
View File
@@ -256,7 +256,7 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--object constructor
---@class df_label: uiobject
---@class df_label: fontstring
---@field widget fontstring widget and label points to the same fontstring
---@field label fontstring widget and label points to the same fontstring
---@field align justifyh
+1 -1
View File
@@ -3738,7 +3738,7 @@ end
---@field ReajustNumFrames boolean?
---@field DontHideChildrenOnPreRefresh boolean
---@field refresh_func fun(self:df_scrollbox, data:table, offset:number, numlines:number)
---@field Refresh fun(self:df_scrollbox, data:table, offset:number, numlines:number)
---@field Refresh fun(self:df_scrollbox)
---@field CreateLineFunc fun(self:df_scrollbox, index:number)?
---@field CreateLine fun(self:df_scrollbox, func:function)
---@field SetData fun(self:df_scrollbox, data:table)
+41 -36
View File
@@ -95,7 +95,7 @@ detailsFramework.ScrollBoxFunctions = {
func = self.CreateLineFunc
end
local okay, newLine = pcall(func, self, #self.Frames+1)
local okay, newLine = xpcall(func, geterrorhandler(), self, #self.Frames+1)
if (okay) then
if (not newLine) then
error("ScrollFrame:CreateLine() function did not returned a line, use: 'return line'")
@@ -103,9 +103,8 @@ detailsFramework.ScrollBoxFunctions = {
table.insert(self.Frames, newLine)
newLine.Index = #self.Frames
return newLine
else
error("ScrollFrame:CreateLine() error on creating a line: " .. newLine)
end
return newLine
end,
CreateLines = function(self, callback, lineAmount)
@@ -431,6 +430,7 @@ end
---@field backdrop_onenter number[]?
---@field backdrop_onleave number[]?
---@field font_size number?
---@field title_text string?
local auraScrollDefaultSettings = {
line_height = 18,
@@ -442,18 +442,18 @@ local auraScrollDefaultSettings = {
remove_icon_border = true,
no_scroll = false,
no_backdrop = false,
backdrop_onenter = {.8, .8, .8, 0.2},
backdrop_onleave = {.8, .8, .8, 0.4},
backdrop_onenter = {.8, .8, .8, 0.4},
backdrop_onleave = {.8, .8, .8, 0.2},
font_size = 12,
title_text = "",
}
---@param parent frame
---@param name string?
---@param data table? --can be set later with :SetData()
---@param profile table? --can be set later with :SetProfile()
---@param onAuraRemoveCallback function?
---@param options df_aurascrollbox_options?
function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAuraRemoveCallback, options)
function detailsFramework:CreateAuraScrollBox(parent, name, data, onAuraRemoveCallback, options)
--hack the construction of the options table here, as the scrollbox is created much later
options = options or {}
local scrollOptions = {}
@@ -493,6 +493,7 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
local onLeaveAuraLine = function(self)
self:SetBackdropColor(unpack(options.backdrop_onleave))
GameTooltip:Hide()
GameCooltip:Hide()
end
local onEnterAuraLine = function(line)
@@ -504,36 +505,32 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
end
line:SetBackdropColor(unpack(options.backdrop_onenter))
local scrollBox = line:GetParent()
local bAddedBySpellName = line.Flag --the user entered the spell name to track the spell (and not a spellId)
local spellId = line.SpellID
if (bAddedBySpellName) then --the user entered the spell name to track the spell
local spellName = GetSpellInfo(spellId)
if (spellName) then
local spellsWithSameName = scrollBox.profile.aura_cache_by_name[string.lower(spellName)]
if (not spellsWithSameName) then
--same_name_spells_add(value)
--spellsWithSameName = scrollBox.profile.aura_cache_by_name[string.lower(spellName)]
end
local spellsHashMap, spellsIndexTable, spellsWithSameName = detailsFramework:GetSpellCaches()
if (spellsWithSameName) then
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
local spellNameLower = spellName:lower()
local sameNameSpells = spellsWithSameName[spellNameLower]
if (spellsWithSameName) then
GameCooltip:Preset(2)
GameCooltip:SetOwner(line, "left", "right", 2, 0)
GameCooltip:SetOption("TextSize", 10)
if (sameNameSpells) then
GameCooltip:Preset(2)
GameCooltip:SetOwner(line, "left", "right", 2, 0)
GameCooltip:SetOption("TextSize", 10)
for i, spellId in ipairs(spellsWithSameName) do
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
GameCooltip:AddLine(spellName .. "(" .. spellId .. ")")
for i, thisSpellId in ipairs(sameNameSpells) do
GameCooltip:AddLine(spellName .. " (" .. thisSpellId .. ")")
GameCooltip:AddIcon(spellIcon, 1, 1, 14, 14, .1, .9, .1, .9)
end
end
GameCooltip:Show()
GameCooltip:Show()
end
end
end
else --the user entered the spellId to track the spell
GameCooltip:Preset(2)
GameCooltip:SetOwner(line, "left", "right", 2, 0)
@@ -577,7 +574,7 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
line:SetScript("OnLeave", onLeaveAuraLine)
line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
line:SetBackdropColor(options.backdrop_onleave)
line:SetBackdropColor(unpack(options.backdrop_onleave))
local iconTexture = line:CreateTexture("$parentIcon", "overlay")
iconTexture:SetSize(lineHeight - 2, lineHeight - 2)
@@ -602,11 +599,9 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
end
---@class df_aurascrollbox : df_scrollbox
---@field RefreshMe fun(self:df_aurascrollbox)
---@field TransformAuraData fun(self:df_aurascrollbox)
---@field SetProfile fun(self:df_aurascrollbox, profile:table)
---@field data_original table
---@field profile table
---@field refresh_original function
data = data or {}
@@ -617,9 +612,16 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
local auraScrollBox = detailsFramework:CreateScrollBox(parent, name, refreshAuraLines, data, options.width, options.height, options.line_amount, options.line_height)
detailsFramework:ReskinSlider(auraScrollBox)
---@cast auraScrollBox df_aurascrollbox
auraScrollBox.data_original = data
auraScrollBox.profile = profile or {}
local titleLabel = detailsFramework:CreateLabel(auraScrollBox, options.title_text)
titleLabel.textcolor = "silver"
titleLabel.textsize = 10
titleLabel:SetPoint("bottomleft", auraScrollBox, "topleft", 0, 2)
for i = 1, options.line_amount do
auraScrollBox:CreateLine(createLineFunc)
end
function auraScrollBox:TransformAuraData()
local newData = {}
@@ -638,10 +640,6 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
self.data = newData
end
function auraScrollBox.SetProfile(self, profile)
self.profile = profile
end
auraScrollBox.SetData = function(self, data)
self.data_original = data
self.data = data
@@ -652,6 +650,13 @@ function detailsFramework:CreateAuraScrollBox(parent, name, data, profile, onAur
return self.data_original
end
auraScrollBox.refresh_original = auraScrollBox.Refresh
auraScrollBox.Refresh = function()
auraScrollBox:TransformAuraData()
auraScrollBox:refresh_original()
end
auraScrollBox:SetData(data)
return auraScrollBox
+2
View File
@@ -541,6 +541,7 @@ end
---@field text any
---@field multiline any
---@field align any
---@field ShouldOptimizeAutoComplete boolean?
---@field SetTemplate fun(self:df_textentry, template:table)
---@field Disable fun(self:df_textentry)
---@field Enable fun(self:df_textentry)
@@ -555,6 +556,7 @@ end
---@field SetEnterFunction fun(self:df_textentry, func:function, param1:any, param2:any)
---@field SetHook fun(self:df_textentry, hookName:string, func:function)
---@field SetAsSearchBox fun(self:df_textentry)
---@field SetAsAutoComplete fun(self:df_textentry, poolName:string, poolTable:table?, shouldOptimize:boolean?) poolName is the name of the member on textEntry that will be used to store the pool table, poolTable is an array with word to be used on the autocomplete, shouldOptimize is a boolean that will optimize the autocomplete by using a cache table, it's recommended to use it if the autocomplete array is too large.
---@param parent frame
---@param textChangedCallback function
+3
View File
@@ -607,3 +607,6 @@
---@field SetTextColor fun(self: editbox, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field SetJustifyH fun(self:editbox, alignment:string)
---@field SetTextInsets fun(self:editbox, left:number, right:number, top:number, bottom:number)
---@field SetFocus fun(self:editbox, focus:boolean)
---@field HasFocus fun(self:editbox) : boolean return true if the editbox has focus
---@field HighlightText fun(self:editbox, start:number?, finish:number?) select a portion of the text, passing zero will select the entire text