Framework update, added RaidTargets in the unitId cache, class_utility code cleanup

This commit is contained in:
Tercio Jose
2024-07-20 18:04:43 -03:00
committed by andrew6180
parent 2babe473ea
commit 1bf24647ec
6 changed files with 361 additions and 305 deletions
+47 -15
View File
@@ -141,11 +141,17 @@ local onLeaveHighlight = function(self)
end
end
local createOptionHighlightTexture = function(frame, label, widgetWidth)
---create a button and a texture to highlight the button when the mouse is over it
---the button has the dimentions of the label and the widget
---@param frame frame
---@param label fontstring
---@param widgetWidth nunmber
---@return unknown
local createOptionHighlightFrame = function(frame, label, widgetWidth)
frame = frame.widget or frame
label = label.widget or label
local highlightFrame = CreateFrame("frame", nil, frame)
local highlightFrame = CreateFrame("button", nil, frame)
highlightFrame:EnableMouse(true)
highlightFrame:SetFrameLevel(frame:GetFrameLevel()-1)
@@ -170,7 +176,7 @@ local createOptionHighlightTexture = function(frame, label, widgetWidth)
highlightFrame.highlightTexture = highlightTexture
highlightFrame.parent = frame
return highlightTexture
return highlightFrame
end
local setLabelProperties = function(parent, widget, widgetTable, currentXOffset, currentYOffset, template)
@@ -219,7 +225,7 @@ local setDropdownProperties = function(parent, widget, widgetTable, currentXOffs
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
else
@@ -253,8 +259,27 @@ local setDropdownProperties = function(parent, widget, widgetTable, currentXOffs
return maxColumnWidth, maxWidgetWidth
end
local highlightFrameOnClickToggle = function(highlightFrame, mouseButton)
local parent = highlightFrame:GetParent()
local widget = parent.MyObject
local bNewState = not widget._get()
widget.OnSwitch(widget, nil, bNewState) --widget.OnSwitch = widgetTable.set
if (bNewState) then
widget:SetValue(true)
else
widget:SetValue(false)
end
if (widget._valueChangeHook) then
widget._valueChangeHook()
end
end
local setToggleProperties = function(parent, widget, widgetTable, currentXOffset, currentYOffset, template, widgetWidth, widgetHeight, bAlignAsPairs, nAlignAsPairsLength, valueChangeHook, maxColumnWidth, switchIsCheckbox, bUseBoxFirstOnAllWidgets, menuOptions, index, maxWidgetWidth)
widget._get = widgetTable.get
widget._set = widgetTable.set
widget.widget_type = "toggle"
widget.OnSwitch = widgetTable.set
@@ -263,14 +288,17 @@ local setToggleProperties = function(parent, widget, widgetTable, currentXOffset
end
if (widgetTable.children_follow_enabled) then
widget.SetValueOriginal = widget.SetValue
widget.SetValueOriginal = widget.SetValue --perhaps widgetTable.set() --perhaps setscrip OnClick
widget._name = widgetTable.name
local newSetFunc = function(widget, value)
local newSetFunc = function(thisWidget, value)
--look for children ids
local childrenids = widgetTable.childrenids
--print(childrenids, type(childrenids))
if (type(childrenids) == "table") then
for i, childId in ipairs(childrenids) do
local childWidget = parent:GetWidgetById(childId)
--print("childWidget", childWidget)
if (childWidget) then
--if the children_follow_reverse is true, then the children will be enabled when the toogle is disabeld
--this is used when the main toggle is a kind of "Do This Automatically", if is not doing it automatically
@@ -292,7 +320,7 @@ local setToggleProperties = function(parent, widget, widgetTable, currentXOffset
end
end
widget.SetValueOriginal(widget, value)
thisWidget.SetValueOriginal(thisWidget, value)
return value
end
@@ -325,13 +353,15 @@ local setToggleProperties = function(parent, widget, widgetTable, currentXOffset
local extraPaddingY = 0
if (bAlignAsPairs) then
PixelUtil.SetPoint(label, "topleft", widget:GetParent(), "topleft", currentXOffset, currentYOffset)
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
widget._valueChangeHook = valueChangeHook
widget.highlightFrame:SetScript("OnClick", highlightFrameOnClickToggle)
PixelUtil.SetPoint(label, "topleft", widget:GetParent(), "topleft", currentXOffset, currentYOffset)
PixelUtil.SetPoint(widget.widget, "right", widget.highlightFrame, "right", -3, 0)
else
if (widgetTable.boxfirst or bUseBoxFirstOnAllWidgets) then
label:SetPoint("left", widget.widget or widget, "right", 2, 0)
@@ -434,9 +464,11 @@ local setRangeProperties = function(parent, widget, widgetTable, currentXOffset,
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
widget.bAttachButtonsToLeft = true
else
widget:SetPoint("left", label, "right", 2, 0)
label:SetPoint("topleft", parent, "topleft", currentXOffset, currentYOffset)
@@ -508,7 +540,7 @@ local setColorProperties = function(parent, widget, widgetTable, currentXOffset,
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
else
@@ -573,7 +605,7 @@ local setExecuteProperties = function(parent, widget, widgetTable, currentXOffse
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
else
@@ -652,7 +684,7 @@ local setTextEntryProperties = function(parent, widget, widgetTable, currentXOff
PixelUtil.SetPoint(widget.widget, "left", label, "left", nAlignAsPairsLength, 0)
if (not widget.highlightFrame) then
local highlightFrame = createOptionHighlightTexture(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
local highlightFrame = createOptionHighlightFrame(widget, label, (widgetWidth or 140) + nAlignAsPairsLength + 5)
widget.highlightFrame = highlightFrame
end
else
+6
View File
@@ -220,7 +220,13 @@
---@field CreateColorDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateOutlineDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateAnchorPointDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateAudioDropDown fun(self:table, parent:frame, func:function, default:any, width:number?, height:number?, member:string?, name:string?, template:table?) : df_dropdown
---@field CreateFontListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all fonts available and ready to be used on dropdowns
---@field CreateAnchorPointListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all anchor points available and ready to be used on dropdowns
---@field CreateColorListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all colors available and ready to be used on dropdowns
---@field CreateOutlineListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all outline options available and ready to be used on dropdowns
---@field CreateAudioListGenerator fun(self:table, callback:function) : function return a function which when called returns a table filled with all audio options available and ready to be used on dropdowns
---@field BuildDropDownFontList fun(self:table, onClick:function, icon:atlasname|texturepath|textureid|nil, iconTexcoord:table?, iconSize:number?, bIncludeDefault:boolean?) : table build a list of fonts to be used as optionsTable for a dropdown
---@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>
+8 -2
View File
@@ -1012,15 +1012,21 @@ local iconSizeTable = {16, 16}
function DF:BuildDropDownFontList(onClick, icon, iconTexcoord, iconSize, bIncludeDefault)
local fontTable = {}
if (not iconSize) then
iconSize = iconSizeTable
else
iconSize = {iconSize, iconSize}
end
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
for name, fontPath in pairs(SharedMedia:HashTable("font")) do
fontTable[#fontTable+1] = {value = name, label = name, onclick = onClick, icon = icon, iconsize = iconSizeTable, texcoord = iconTexcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
fontTable[#fontTable+1] = {value = name, label = name, onclick = onClick, icon = icon, iconsize = iconSize, texcoord = iconTexcoord, font = fontPath, descfont = "abcdefg ABCDEFG"}
end
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"})
table.insert(fontTable, 1, {value = "DEFAULT", label = "DEFAULT", onclick = onClick, icon = icon, iconsize = iconSize, texcoord = iconTexcoord, font = "", descfont = "abcdefg ABCDEFG"})
end
return fontTable
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 547
local dversion = 550
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
+3
View File
@@ -121,6 +121,7 @@
Details222.Debug = {
DebugPets = false,
DebugPlayerPets = false,
DebugBuff = false,
}
Details222.Tvs = tvs
@@ -1563,9 +1564,11 @@ end
Details222.UnitIdCache.Raid = {}
Details222.UnitIdCache.RaidPet = {}
Details222.UnitIdCache.RaidTargets = {}
for i = 1, 40 do
Details222.UnitIdCache.Raid[i] = "raid" .. i
Details222.UnitIdCache.RaidPet[i] = "raidpet" .. i
Details222.UnitIdCache.RaidTargets[i] = "raidtarget" .. i
end
Details222.UnitIdCache.Boss = {}
+296 -287
View File
File diff suppressed because it is too large Load Diff