mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-21 20:00:48 +00:00
gui: always reinitialize profile dropdown menu
This commit is contained in:
+20
-8
@@ -1243,15 +1243,27 @@ pfUI:RegisterModule("gui", 20400, function ()
|
|||||||
local values = {}
|
local values = {}
|
||||||
for name, config in pairs(pfUI_profiles) do table.insert(values, name) end
|
for name, config in pairs(pfUI_profiles) do table.insert(values, name) end
|
||||||
|
|
||||||
local function pfUpdateProfiles()
|
local function ReloadProfiles()
|
||||||
|
local oldval = UIDropDownMenu_GetText(pfUIDropDownMenuProfile)
|
||||||
local values = {}
|
local values = {}
|
||||||
for name, config in pairs(pfUI_profiles) do table.insert(values, name) end
|
local exists
|
||||||
pfUIDropDownMenuProfile.values = values
|
|
||||||
UIDropDownMenu_SetSelectedID(pfUIDropDownMenuProfile, 0, 0)
|
for name, config in pairs(pfUI_profiles) do
|
||||||
UIDropDownMenu_SetText("", pfUIDropDownMenuProfile)
|
table.insert(values, name)
|
||||||
|
if name == oldval then
|
||||||
|
exists = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not exists then
|
||||||
|
UIDropDownMenu_SetText("", pfUIDropDownMenuProfile)
|
||||||
|
UIDropDownMenu_SetSelectedID(pfUIDropDownMenuProfile, 0, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
return values
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateConfig(nil, T["Select profile"], C.global, "profile", "dropdown", values, false, "Profile")
|
CreateConfig(function() return end, T["Select profile"], C.global, "profile", "dropdown", ReloadProfiles, false, "Profile")
|
||||||
|
|
||||||
-- load profile
|
-- load profile
|
||||||
CreateConfig(nil, T["Load profile"], C.global, "profile", "button", function()
|
CreateConfig(nil, T["Load profile"], C.global, "profile", "button", function()
|
||||||
@@ -1271,7 +1283,7 @@ pfUI:RegisterModule("gui", 20400, function ()
|
|||||||
if C.global.profile and pfUI_profiles[C.global.profile] then
|
if C.global.profile and pfUI_profiles[C.global.profile] then
|
||||||
CreateQuestionDialog(T["Delete profile"] .. " '|cff33ffcc" .. C.global.profile .. "|r'?", function()
|
CreateQuestionDialog(T["Delete profile"] .. " '|cff33ffcc" .. C.global.profile .. "|r'?", function()
|
||||||
pfUI_profiles[C.global.profile] = nil
|
pfUI_profiles[C.global.profile] = nil
|
||||||
pfUpdateProfiles()
|
ReloadProfiles()
|
||||||
this:GetParent():Hide()
|
this:GetParent():Hide()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -1301,8 +1313,8 @@ pfUI:RegisterModule("gui", 20400, function ()
|
|||||||
profile = (string.gsub(profile,"^%s*(.-)%s*$", "%1"))
|
profile = (string.gsub(profile,"^%s*(.-)%s*$", "%1"))
|
||||||
if profile and profile ~= "" then
|
if profile and profile ~= "" then
|
||||||
pfUI_profiles[profile] = CopyTable(C)
|
pfUI_profiles[profile] = CopyTable(C)
|
||||||
pfUpdateProfiles()
|
|
||||||
this:GetParent():Hide()
|
this:GetParent():Hide()
|
||||||
|
ReloadProfiles()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, false, true)
|
end, false, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user