Skip to content

Commit

Permalink
Framework Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Oct 13, 2023
1 parent da1e12c commit 597371a
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 441 deletions.
672 changes: 273 additions & 399 deletions Libs/DF/auras.lua

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/label.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
81 changes: 43 additions & 38 deletions Libs/DF/scrollbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ 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'")
end
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)
Expand Down Expand Up @@ -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,
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand All @@ -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

if (spellsWithSameName) 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 .. ")")
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 (sameNameSpells) then
GameCooltip:Preset(2)
GameCooltip:SetOwner(line, "left", "right", 2, 0)
GameCooltip:SetOption("TextSize", 10)

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

Expand All @@ -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 = {}
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Libs/DF/textentry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Libs/LibLuaServer/LibLuaServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 597371a

Please sign in to comment.