Framework update

This commit is contained in:
Tercio Jose
2022-08-18 10:11:27 -03:00
parent 145233f9c5
commit 0551c6ea62
2 changed files with 114 additions and 81 deletions
+6 -3
View File
@@ -1,6 +1,6 @@
local dversion = 328 local dversion = 329
local major, minor = "DetailsFramework-1.0", dversion local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor) local DF, oldminor = LibStub:NewLibrary (major, minor)
@@ -933,11 +933,12 @@ end
--return a list of spells from the player spellbook --return a list of spells from the player spellbook
function DF:GetSpellBookSpells() function DF:GetSpellBookSpells()
local spellNamesInSpellBook = {} local spellNamesInSpellBook = {}
local spellIdsInSpellBook = {}
for i = 1, GetNumSpellTabs() do for i = 1, GetNumSpellTabs() do
local tabName, tabTexture, offset, numSpells, isGuild, offspecId = GetSpellTabInfo(i) local tabName, tabTexture, offset, numSpells, isGuild, offspecId = GetSpellTabInfo(i)
if (offspecId == 0) then if (offspecId == 0 and tabTexture ~= 136830) then --don't add spells found in the General tab
offset = offset + 1 offset = offset + 1
local tabEnd = offset + numSpells local tabEnd = offset + numSpells
@@ -949,6 +950,7 @@ function DF:GetSpellBookSpells()
local spellName = GetSpellInfo(spellId) local spellName = GetSpellInfo(spellId)
if (spellName) then if (spellName) then
spellNamesInSpellBook[spellName] = true spellNamesInSpellBook[spellName] = true
spellIdsInSpellBook[#spellIdsInSpellBook+1] = spellId
end end
else else
local _, _, numSlots, isKnown = GetFlyoutInfo(spellId) local _, _, numSlots, isKnown = GetFlyoutInfo(spellId)
@@ -958,6 +960,7 @@ function DF:GetSpellBookSpells()
if (isKnown) then if (isKnown) then
local spellName = GetSpellInfo(spellID) local spellName = GetSpellInfo(spellID)
spellNamesInSpellBook[spellName] = true spellNamesInSpellBook[spellName] = true
spellIdsInSpellBook[#spellIdsInSpellBook+1] = spellID
end end
end end
end end
@@ -967,7 +970,7 @@ function DF:GetSpellBookSpells()
end end
end end
return spellNamesInSpellBook return spellNamesInSpellBook, spellIdsInSpellBook
end end
------------------------------ ------------------------------
+108 -78
View File
@@ -6066,131 +6066,151 @@ local default_radiogroup_options = {
} }
DF.RadioGroupCoreFunctions = { DF.RadioGroupCoreFunctions = {
RadioOnClick = function (self, fixedParam, value)
--turn off all checkboxes
local frameList = {self:GetParent():GetChildren()}
for _, checkbox in ipairs (frameList) do
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
checkbox:SetValue (false)
end
--turn on the clicked checkbox
self:SetValue (true)
--callback
DF:QuickDispatch (self._set, fixedParam)
end,
Disable = function (self) Disable = function (self)
local frameList = {self:GetChildren()} local frameList = self:GetAllCheckboxes()
for _, checkbox in ipairs (frameList) do for _, checkbox in ipairs(frameList) do
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
checkbox:Disable() checkbox:Disable()
end end
end, end,
Enable = function (self) Enable = function (self)
local frameList = {self:GetChildren()} local frameList = self:GetAllCheckboxes()
for _, checkbox in ipairs (frameList) do for _, checkbox in ipairs(frameList) do
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
checkbox:Enable() checkbox:Enable()
end end
end, end,
DeselectAll = function (self) DeselectAll = function(self)
local frameList = {self:GetChildren()} local frameList = self:GetAllCheckboxes()
for _, checkbox in ipairs (frameList) do for _, checkbox in ipairs(frameList) do
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
checkbox:SetValue (false) checkbox:SetValue(false)
end end
end, end,
FadeIn = function (self) FadeIn = function(self)
local frameList = {self:GetChildren()} local frameList = self:GetAllCheckboxes()
for _, checkbox in ipairs (frameList) do for _, checkbox in ipairs(frameList) do
checkbox:SetAlpha (1) checkbox:SetAlpha(1)
end end
end, end,
FadeOut = function (self) FadeOut = function(self)
local frameList = {self:GetChildren()} local frameList = self:GetAllCheckboxes()
for _, checkbox in ipairs (frameList) do for _, checkbox in ipairs(frameList) do
checkbox:SetAlpha (.7) checkbox:SetAlpha(.7)
end end
end, end,
SetFadeState = function (self, state) SetFadeState = function(self, state)
if (state) then if (state) then
self:FadeIn() self:FadeIn()
else else
self:FadeOut() self:FadeOut()
end end
end, end,
CreateCheckbox = function (self) GetAllCheckboxes = function(self)
local checkbox = DF:CreateSwitch (self, function()end, false, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE")) return {self:GetChildren()}
checkbox:SetAsCheckBox() end,
checkbox.Icon = DF:CreateImage (checkbox, "", 16, 16)
checkbox.Label = DF:CreateLabel (checkbox, "") GetCheckbox = function(self, checkboxId)
local allCheckboxes = self:GetAllCheckboxes()
local checkbox = allCheckboxes[checkboxId]
if (not checkbox) then
checkbox = self:CreateCheckbox()
end
return checkbox return checkbox
end, end,
RefreshCheckbox = function (self, checkbox, optionTable) CreateCheckbox = function(self)
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox local checkbox = DF:CreateSwitch(self, function()end, false, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"))
checkbox:SetAsCheckBox()
checkbox.Icon = DF:CreateImage(checkbox, "", 16, 16)
checkbox.Label = DF:CreateLabel(checkbox, "")
local setFunc = self.options.is_radio and self.RadioOnClick or optionTable.set return checkbox
checkbox:SetSwitchFunction (setFunc) end,
checkbox._set = setFunc
checkbox:SetFixedParameter (optionTable.param) ResetAllCheckboxes = function(self)
local radioCheckboxes = self:GetAllCheckboxes()
local isChecked = DF:Dispatch (optionTable.get) for i = 1, #radioCheckboxes do
checkbox:SetValue (isChecked) local checkBox = radioCheckboxes[i]
checkBox:Hide()
checkbox.Label:SetText (optionTable.name)
if (optionTable.texture) then
checkbox.Icon:SetTexture (optionTable.texture)
checkbox.Icon:SetPoint ("left", checkbox, "right", 2, 0)
checkbox.Label:SetPoint ("left", checkbox.Icon, "right", 2, 0)
if (optionTable.texcoord) then
checkbox.Icon:SetTexCoord (unpack (optionTable.texcoord))
else
checkbox.Icon:SetTexCoord (0, 1, 0, 1)
end
else
checkbox.Icon:SetTexture ("")
checkbox.Label:SetPoint ("left", checkbox, "right", 2, 0)
end end
end, end,
Refresh = function (self) --if the list of checkboxes are a radio group
local radioOptions = self.RadioOptionsTable RadioOnClick = function(checkbox, fixedParam, value)
local radioCheckboxes = {self:GetChildren()} --turn off all checkboxes
checkbox:GetParent():DeselectAll()
for _, checkbox in ipairs (radioCheckboxes) do --turn on the clicked checkbox
checkbox:Hide() checkbox:SetValue(true)
--callback
if (checkbox._callback) then
DF:QuickDispatch(checkbox._callback, fixedParam, checkbox._optionid)
end end
end,
RefreshCheckbox = function(self, checkbox, optionTable, optionId)
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
for radioIndex, optionsTable in ipairs (radioOptions) do local setFunc = self.options.is_radio and self.RadioOnClick or optionTable.set
local checkbox = radioCheckboxes [radioIndex] checkbox:SetSwitchFunction(setFunc)
if (not checkbox) then checkbox._callback = optionTable.callback
checkbox = self:CreateCheckbox() checkbox._set = self.options.is_radio and optionTable.callback or optionTable.set
checkbox._optionid = optionId
checkbox:SetFixedParameter(optionTable.param or optionId)
local isChecked = type(optionTable.get) == "function" and DF:Dispatch(optionTable.get) or false
checkbox:SetValue(isChecked)
checkbox.Label:SetText(optionTable.name)
if (optionTable.texture) then
checkbox.Icon:SetTexture(optionTable.texture)
checkbox.Icon:SetPoint("left", checkbox, "right", 2, 0)
checkbox.Label:SetPoint("left", checkbox.Icon, "right", 2, 0)
if (optionTable.texcoord) then
checkbox.Icon:SetTexCoord(unpack(optionTable.texcoord))
else
checkbox.Icon:SetTexCoord(0, 1, 0, 1)
end end
checkbox.OptionID = radioIndex else
checkbox.Icon:SetTexture("")
checkbox.Label:SetPoint("left", checkbox, "right", 2, 0)
end
end,
Refresh = function(self)
self:ResetAllCheckboxes()
local radioOptions = self:GetOptions()
local radioCheckboxes = self:GetAllCheckboxes()
for optionId, optionsTable in ipairs(radioOptions) do
local checkbox = self:GetCheckbox(optionId)
checkbox.OptionID = optionId
checkbox:Show() checkbox:Show()
self:RefreshCheckbox (checkbox, optionsTable) self:RefreshCheckbox(checkbox, optionsTable, optionId)
end end
--sending false to automatically use the radio group children --sending false to automatically use the radio group children
self:ArrangeFrames (false, self.AnchorOptions) self:ArrangeFrames(false, self.AnchorOptions)
end, end,
SetOptions = function (self, radioOptions) SetOptions = function(self, radioOptions)
self.RadioOptionsTable = radioOptions self.RadioOptionsTable = radioOptions
self:Refresh() self:Refresh()
end, end,
GetOptions = function(self)
return self.RadioOptionsTable
end,
} }
--[=[ --[=[
@@ -6201,7 +6221,7 @@ DF.RadioGroupCoreFunctions = {
options: override options for default_radiogroup_options table options: override options for default_radiogroup_options table
anchorOptions: override options for default_framelayout_options table anchorOptions: override options for default_framelayout_options table
--]=] --]=]
function DF:CreateRadionGroup (parent, radioOptions, name, options, anchorOptions) function DF:CreateCheckboxGroup(parent, radioOptions, name, options, anchorOptions)
local f = CreateFrame ("frame", name, parent, "BackdropTemplate") local f = CreateFrame ("frame", name, parent, "BackdropTemplate")
DF:Mixin (f, DF.OptionsFunctions) DF:Mixin (f, DF.OptionsFunctions)
@@ -6228,6 +6248,16 @@ function DF:CreateRadionGroup (parent, radioOptions, name, options, anchorOption
return f return f
end end
function DF:CreateRadionGroup(parent, radioOptions, name, options, anchorOptions) --alias for miss spelled old function
return DF:CreateRadioGroup(parent, radioOptions, name, options, anchorOptions)
end
function DF:CreateRadioGroup(parent, radioOptions, name, options, anchorOptions)
options = options or {}
options.is_radio = true
return DF:CreateCheckboxGroup(parent, radioOptions, name, options, anchorOptions)
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> load conditions panel --> load conditions panel