Added Search into the options panel

This commit is contained in:
Tercio Jose
2021-09-24 22:07:13 -03:00
parent e607f32edb
commit 1c20f166cb
14 changed files with 503 additions and 335 deletions
+9 -9
View File
@@ -2,7 +2,7 @@
local Details = _G.Details
local DF = _G.DetailsFramework
local raidStatusLib = LibStub:GetLibrary("LibRaidStatus-1.0")
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
local width = 170
local height = 300
@@ -42,9 +42,9 @@ function Details.CooldownTracking.EnableTracker()
Details.ocd_tracker.enabled = true
--register callbacks
raidStatusLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownListUpdateFunc")
raidStatusLib.RegisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownListWipedFunc")
raidStatusLib.RegisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownListUpdateFunc")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownListWipedFunc")
openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
--Details.CooldownTracking.RefreshCooldownFrames()
end
@@ -58,9 +58,9 @@ function Details.CooldownTracking.DisableTracker()
end
--unregister callbacks
raidStatusLib.UnregisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownUpdateFunc")
raidStatusLib.UnregisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownUpdateFunc")
raidStatusLib.UnregisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListUpdate", "CooldownUpdateFunc")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownListWiped", "CooldownUpdateFunc")
openRaidLib.UnregisterCallback(Details.CooldownTracking, "CooldownUpdate", "CooldownUpdateFunc")
end
function Details.CooldownTracking.CooldownUpdateFunc()
Details.CooldownTracking.RefreshCooldowns()
@@ -116,7 +116,7 @@ function Details.CooldownTracking.ProcessUnitCooldowns(unitId, statusBarFrameId,
return
end
local allPlayersInfo = raidStatusLib.playerInfoManager.GetAllPlayersInfo()
local allPlayersInfo = openRaidLib.playerInfoManager.GetAllPlayersInfo()
local allCooldownsFromLib = LIB_RAID_STATUS_COOLDOWNS_BY_SPEC
local cooldownsEnabled = Details.ocd_tracker.cooldowns
@@ -249,7 +249,7 @@ function Details.CooldownTracking.RefreshCooldowns()
--local cache saved with the character savedVariables
local cooldownCache = screenPanel.cooldownCache
local cooldownStatus = raidStatusLib.cooldownManager.GetAllPlayersCooldown()
local cooldownStatus = openRaidLib.cooldownManager.GetAllPlayersCooldown()
local cooldownIndex = 1
for unitName, allPlayerCooldowns in pairs(cooldownStatus) do
+92 -2
View File
@@ -190,6 +190,88 @@ function Details.options.InitializeOptionsWindow(instance)
changelog:SetTemplate (options_button_template)
changelog:SetIcon ("Interface\\AddOns\\Details\\images\\icons", nil, nil, nil, {367/512, 399/512, 43/512, 76/512}, {1, 1, 1, 0.8}, 4, 2)
--search field
local searchBox = DF:CreateTextEntry(f, function()end, 150, 20, _, _, _, options_dropdown_template)
searchBox:SetHook ("OnChar", f.OnSearchBoxTextChanged)
searchBox:SetHook ("OnTextChanged", f.OnSearchBoxTextChanged)
searchBox:SetPoint ("topright", f, "topright", -5, -30)
local searchLabel = DF:CreateLabel(f, "Search:", DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
searchLabel:SetPoint ("right", searchBox, "left", -2, 0)
searchBox:SetHook("OnChar", function()
if (searchBox.text ~= "") then
local searchSection = f.sectionFramesContainer[19]
searchSection.sectionButton:Enable()
searchSection.sectionButton:Click()
local searchingFor = searchBox.text
local allSectionFrames = f.sectionFramesContainer
local allSectionNames = {}
local allSectionOptions = {}
for i = 1, #allSectionFrames do
local sectionFrame = allSectionFrames[i]
local sectionOptionsTable = sectionFrame.sectionOptions
allSectionNames[#allSectionNames+1] = sectionFrame.name
allSectionOptions[#allSectionOptions+1] = sectionOptionsTable
end
--this table will hold all options
local allOptions = {}
--start the fill process filling 'allOptions' with each individual option from each tab
for i = 1, #allSectionOptions do
local sectionOptions = allSectionOptions[i]
local lastLabel = nil
for k, setting in pairs(sectionOptions) do
if (setting.type == "label") then
lastLabel = setting
end
if (setting.name) then
allOptions[#allOptions+1] = {setting = setting, label = lastLabel, header = allSectionNames[i]}
end
end
end
local searchingText = string.lower(searchingFor)
searchBox:SetFocus()
local options = {}
local lastTab = nil
local lastLabel = nil
for i = 1, #allOptions do
local optionData = allOptions[i]
local optionName = string.lower(optionData.setting.name)
if (optionName:find(searchingText)) then
if optionData.header ~= lastTab then
if lastTab ~= nil then
options[#options+1] = {type = "label", get = function() return "" end, text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")} -- blank
end
options[#options+1] = {type = "label", get = function() return optionData.header end, text_template = {color = "silver", size = 14, font = DF:GetBestFontForLanguage()}}
lastTab = optionData.header
lastLabel = nil
end
if optionData.label ~= lastLabel then
options[#options+1] = optionData.label
lastLabel = optionData.label
end
options[#options+1] = optionData.setting
end
end
local startX = 200
local startY = -40
DF:BuildMenuVolatile(searchSection, options, startX, startY, 500, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template, globalCallback)
else
f.sectionFramesContainer[19].sectionButton:Disable()
end
end)
local sectionsName = { --section names
[1] = Loc ["STRING_OPTIONSMENU_DISPLAY"],
[3] = Loc ["STRING_OPTIONSMENU_ROWSETTINGS"],
@@ -214,12 +296,15 @@ function Details.options.InitializeOptionsWindow(instance)
[18] = "Mythic Dungeon",
[19] = "Search Results",
}
local optionsSectionsOrder = {
1, "", 3, 4, "", 5, 6, 7, 12, 13, "", 9, 2, 8, 10, 11, 18, "", 14, 15, 16, 17--, 18, 19
1, "", 3, 4, "", 5, 6, 7, 12, 13, "", 9, 2, 8, 10, 11, 18, "", 14, 15, 16, 17, "", 19
}
local maxSectionIds = 18
local maxSectionIds = 19
Details.options.maxSectionIds = maxSectionIds
local buttonYPosition = -40
@@ -248,6 +333,7 @@ function Details.options.InitializeOptionsWindow(instance)
local sectionFrame = CreateFrame("frame", "$parentTab" .. sectionId, f, "BackdropTemplate")
sectionFrame:SetAllPoints()
sectionFrame:EnableMouse(false)
sectionFrame.name = sectionsName[sectionId]
--tinsert(f.sectionFramesContainer, sectionFrame)
f.sectionFramesContainer[sectionId] = sectionFrame
@@ -261,6 +347,10 @@ function Details.options.InitializeOptionsWindow(instance)
sectionButton:SetPoint("topleft", f, "topleft", 10, buttonYPosition)
buttonYPosition = buttonYPosition - (section_menu_button_height + 1)
sectionFrame.sectionButton = sectionButton
if (sectionId == 19) then --search results
sectionButton:Disable()
end
end
else
buttonYPosition = buttonYPosition - 15
+35
View File
@@ -23,6 +23,7 @@ end
~16 - custom spells
~17 - charts data
~18 - mythic dungeon
~19 - search results
--]]
@@ -657,6 +658,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize+20, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -1010,6 +1012,7 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -1564,6 +1567,7 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize+20, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -1921,6 +1925,7 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -2378,6 +2383,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -2675,6 +2681,7 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -2787,6 +2794,8 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
do --> micro displays
@@ -3419,6 +3428,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -3657,6 +3667,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -4032,6 +4043,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
refreshToggleAnchor()
end
@@ -4179,6 +4191,7 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -4582,6 +4595,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
sectionFrame:SetScript("OnShow", function()
@@ -4912,6 +4926,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(autoSwitchFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
@@ -5491,6 +5506,7 @@ do --raid tools
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -5729,6 +5745,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX + 350, startY - 20 - 200, heightSize + 300, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -5889,6 +5906,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -6308,6 +6326,7 @@ do
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
@@ -6391,6 +6410,21 @@ do
},
}
sectionFrame.sectionOptions = sectionOptions
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
tinsert(Details.optionsSection, buildSection)
end
-- ~19 - search results
do
local buildSection = function(sectionFrame)
local sectionOptions = {
}
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
@@ -6414,3 +6448,4 @@ do
tinsert(Details.optionsSection, buildSection)
end
--]]