Framework update
This commit is contained in:
+6
-3
@@ -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
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|||||||
+97
-67
@@ -6066,60 +6066,45 @@ 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
|
||||||
@@ -6127,70 +6112,105 @@ DF.RadioGroupCoreFunctions = {
|
|||||||
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()}
|
||||||
|
end,
|
||||||
|
|
||||||
|
GetCheckbox = function(self, checkboxId)
|
||||||
|
local allCheckboxes = self:GetAllCheckboxes()
|
||||||
|
local checkbox = allCheckboxes[checkboxId]
|
||||||
|
if (not checkbox) then
|
||||||
|
checkbox = self:CreateCheckbox()
|
||||||
|
end
|
||||||
|
return checkbox
|
||||||
|
end,
|
||||||
|
|
||||||
|
CreateCheckbox = 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"))
|
||||||
checkbox:SetAsCheckBox()
|
checkbox:SetAsCheckBox()
|
||||||
checkbox.Icon = DF:CreateImage (checkbox, "", 16, 16)
|
checkbox.Icon = DF:CreateImage(checkbox, "", 16, 16)
|
||||||
checkbox.Label = DF:CreateLabel (checkbox, "")
|
checkbox.Label = DF:CreateLabel(checkbox, "")
|
||||||
|
|
||||||
return checkbox
|
return checkbox
|
||||||
end,
|
end,
|
||||||
|
|
||||||
RefreshCheckbox = function (self, checkbox, optionTable)
|
ResetAllCheckboxes = function(self)
|
||||||
|
local radioCheckboxes = self:GetAllCheckboxes()
|
||||||
|
for i = 1, #radioCheckboxes do
|
||||||
|
local checkBox = radioCheckboxes[i]
|
||||||
|
checkBox:Hide()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
--if the list of checkboxes are a radio group
|
||||||
|
RadioOnClick = function(checkbox, fixedParam, value)
|
||||||
|
--turn off all checkboxes
|
||||||
|
checkbox:GetParent():DeselectAll()
|
||||||
|
|
||||||
|
--turn on the clicked checkbox
|
||||||
|
checkbox:SetValue(true)
|
||||||
|
|
||||||
|
--callback
|
||||||
|
if (checkbox._callback) then
|
||||||
|
DF:QuickDispatch(checkbox._callback, fixedParam, checkbox._optionid)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
RefreshCheckbox = function(self, checkbox, optionTable, optionId)
|
||||||
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
|
checkbox = checkbox.GetCapsule and checkbox:GetCapsule() or checkbox
|
||||||
|
|
||||||
local setFunc = self.options.is_radio and self.RadioOnClick or optionTable.set
|
local setFunc = self.options.is_radio and self.RadioOnClick or optionTable.set
|
||||||
checkbox:SetSwitchFunction (setFunc)
|
checkbox:SetSwitchFunction(setFunc)
|
||||||
checkbox._set = setFunc
|
checkbox._callback = optionTable.callback
|
||||||
checkbox:SetFixedParameter (optionTable.param)
|
checkbox._set = self.options.is_radio and optionTable.callback or optionTable.set
|
||||||
|
checkbox._optionid = optionId
|
||||||
|
checkbox:SetFixedParameter(optionTable.param or optionId)
|
||||||
|
|
||||||
local isChecked = DF:Dispatch (optionTable.get)
|
local isChecked = type(optionTable.get) == "function" and DF:Dispatch(optionTable.get) or false
|
||||||
checkbox:SetValue (isChecked)
|
checkbox:SetValue(isChecked)
|
||||||
|
|
||||||
checkbox.Label:SetText (optionTable.name)
|
checkbox.Label:SetText(optionTable.name)
|
||||||
|
|
||||||
if (optionTable.texture) then
|
if (optionTable.texture) then
|
||||||
checkbox.Icon:SetTexture (optionTable.texture)
|
checkbox.Icon:SetTexture(optionTable.texture)
|
||||||
checkbox.Icon:SetPoint ("left", checkbox, "right", 2, 0)
|
checkbox.Icon:SetPoint("left", checkbox, "right", 2, 0)
|
||||||
checkbox.Label:SetPoint ("left", checkbox.Icon, "right", 2, 0)
|
checkbox.Label:SetPoint("left", checkbox.Icon, "right", 2, 0)
|
||||||
|
|
||||||
if (optionTable.texcoord) then
|
if (optionTable.texcoord) then
|
||||||
checkbox.Icon:SetTexCoord (unpack (optionTable.texcoord))
|
checkbox.Icon:SetTexCoord(unpack(optionTable.texcoord))
|
||||||
else
|
else
|
||||||
checkbox.Icon:SetTexCoord (0, 1, 0, 1)
|
checkbox.Icon:SetTexCoord(0, 1, 0, 1)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
checkbox.Icon:SetTexture ("")
|
checkbox.Icon:SetTexture("")
|
||||||
checkbox.Label:SetPoint ("left", checkbox, "right", 2, 0)
|
checkbox.Label:SetPoint("left", checkbox, "right", 2, 0)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Refresh = function (self)
|
Refresh = function(self)
|
||||||
local radioOptions = self.RadioOptionsTable
|
self:ResetAllCheckboxes()
|
||||||
local radioCheckboxes = {self:GetChildren()}
|
local radioOptions = self:GetOptions()
|
||||||
|
local radioCheckboxes = self:GetAllCheckboxes()
|
||||||
|
|
||||||
for _, checkbox in ipairs (radioCheckboxes) do
|
for optionId, optionsTable in ipairs(radioOptions) do
|
||||||
checkbox:Hide()
|
local checkbox = self:GetCheckbox(optionId)
|
||||||
end
|
checkbox.OptionID = optionId
|
||||||
|
|
||||||
for radioIndex, optionsTable in ipairs (radioOptions) do
|
|
||||||
local checkbox = radioCheckboxes [radioIndex]
|
|
||||||
if (not checkbox) then
|
|
||||||
checkbox = self:CreateCheckbox()
|
|
||||||
end
|
|
||||||
checkbox.OptionID = radioIndex
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user