From be0b1a965e59642f5fc84a202cccae83e78cea6b Mon Sep 17 00:00:00 2001 From: BloodDragon2580 Date: Sun, 4 Dec 2022 10:57:48 +0100 Subject: [PATCH] Update to v5.7 Update Libs --- .../AceConfigCmd-3.0/AceConfigCmd-3.0.lua | 35 +- .../AceConfigDialog-3.0.lua | 138 +++--- .../Libs/AceConsole-3.0/AceConsole-3.0.lua | 8 +- MythicPlusDrop/Libs/AceDB-3.0/AceDB-3.0.lua | 14 +- .../AceDBOptions-3.0/AceDBOptions-3.0.lua | 456 ++++++++++++++++++ .../AceDBOptions-3.0/AceDBOptions-3.0.xml | 4 + .../BackgroundWidget.lua | 235 +++++++++ .../BorderWidget.lua | 230 +++++++++ .../FontWidget.lua | 216 +++++++++ .../SoundWidget.lua | 264 ++++++++++ .../StatusbarWidget.lua | 233 +++++++++ .../prototypes.lua | 266 ++++++++++ .../AceGUI-3.0-SharedMediaWidgets/widget.xml | 9 + MythicPlusDrop/Libs/AceGUI-3.0/AceGUI-3.0.lua | 94 ++-- .../AceGUIContainer-BlizOptionsGroup.lua | 9 +- .../widgets/AceGUIContainer-DropDownGroup.lua | 2 +- .../widgets/AceGUIContainer-Frame.lua | 20 +- .../widgets/AceGUIContainer-InlineGroup.lua | 2 +- .../widgets/AceGUIContainer-TabGroup.lua | 204 +++++++- .../widgets/AceGUIContainer-TreeGroup.lua | 28 +- .../widgets/AceGUIContainer-Window.lua | 14 +- .../widgets/AceGUIWidget-CheckBox.lua | 20 +- .../widgets/AceGUIWidget-ColorPicker.lua | 4 - .../widgets/AceGUIWidget-DropDown-Items.lua | 8 +- .../widgets/AceGUIWidget-DropDown.lua | 22 +- .../widgets/AceGUIWidget-EditBox.lua | 4 - .../widgets/AceGUIWidget-Keybinding.lua | 6 +- .../AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 16 +- .../widgets/AceGUIWidget-MultiLineEditBox.lua | 19 +- .../widgets/AceGUIWidget-Slider.lua | 26 +- .../CallbackHandler-1.0.lua | 67 +-- .../CallbackHandler-1.0.xml | 2 +- .../Libs/LibDBIcon-1.0/LibDBIcon-1.0.lua | 62 ++- .../LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 301 ++++++++++++ .../Libs/LibSharedMedia-3.0/lib.xml | 4 + MythicPlusDrop/Libs/LibStub/LibStub.lua | 10 +- MythicPlusDrop/MythicPlusDrop.toc | 2 +- 37 files changed, 2706 insertions(+), 348 deletions(-) create mode 100644 MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.lua create mode 100644 MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.xml create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/prototypes.lua create mode 100644 MythicPlusDrop/Libs/AceGUI-3.0-SharedMediaWidgets/widget.xml create mode 100644 MythicPlusDrop/Libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua create mode 100644 MythicPlusDrop/Libs/LibSharedMedia-3.0/lib.xml diff --git a/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua b/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua index 5113875..6dd6438 100644 --- a/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua +++ b/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua @@ -1,7 +1,7 @@ --- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames. -- @class file -- @name AceConfigCmd-3.0 --- @release $Id: AceConfigCmd-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ +-- @release $Id: AceConfigCmd-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ --[[ AceConfigCmd-3.0 @@ -37,17 +37,10 @@ local error, assert = error, assert -- WoW APIs local _G = _G --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME - - local L = setmetatable({}, { -- TODO: replace with proper locale __index = function(self,k) return k end }) - - local function print(msg) (SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME):AddMessage(msg) end @@ -401,7 +394,7 @@ local function handle(info, inputpos, tab, depth, retfalse) return end - local str = strsub(info.input,inputpos); + local strInput = strsub(info.input,inputpos); if tab.type=="execute" then ------------ execute -------------------------------------------- @@ -414,21 +407,21 @@ local function handle(info, inputpos, tab, depth, retfalse) local res = true if tab.pattern then - if not(type(tab.pattern)=="string") then err(info, inputpos, "'pattern' - expected a string") end - if not strmatch(str, tab.pattern) then - usererr(info, inputpos, "'"..str.."' - " .. L["invalid input"]) + if type(tab.pattern)~="string" then err(info, inputpos, "'pattern' - expected a string") end + if not strmatch(strInput, tab.pattern) then + usererr(info, inputpos, "'"..strInput.."' - " .. L["invalid input"]) return end end - do_final(info, inputpos, tab, "set", str) + do_final(info, inputpos, tab, "set", strInput) elseif tab.type=="toggle" then ------------ toggle -------------------------------------------- local b - local str = strtrim(strlower(str)) + local str = strtrim(strlower(strInput)) if str=="" then b = callmethod(info, inputpos, tab, "get") @@ -465,9 +458,9 @@ local function handle(info, inputpos, tab, depth, retfalse) elseif tab.type=="range" then ------------ range -------------------------------------------- - local val = tonumber(str) + local val = tonumber(strInput) if not val then - usererr(info, inputpos, "'"..str.."' - "..L["expected number"]) + usererr(info, inputpos, "'"..strInput.."' - "..L["expected number"]) return end if type(info.step)=="number" then @@ -487,7 +480,7 @@ local function handle(info, inputpos, tab, depth, retfalse) elseif tab.type=="select" then ------------ select ------------------------------------ - local str = strtrim(strlower(str)) + local str = strtrim(strlower(strInput)) local values = tab.values if type(values) == "function" or type(values) == "string" then @@ -528,7 +521,7 @@ local function handle(info, inputpos, tab, depth, retfalse) elseif tab.type=="multiselect" then ------------ multiselect ------------------------------------------- - local str = strtrim(strlower(str)) + local str = strtrim(strlower(strInput)) local values = tab.values if type(values) == "function" or type(values) == "string" then @@ -565,7 +558,7 @@ local function handle(info, inputpos, tab, depth, retfalse) --check that the opt is valid local ok - for k,v in pairs(values) do + for k in pairs(values) do if strlower(k)==opt then opt = k -- overwrite with key (in case of case mismatches) ok = true @@ -634,7 +627,7 @@ local function handle(info, inputpos, tab, depth, retfalse) elseif tab.type=="color" then ------------ color -------------------------------------------- - local str = strtrim(strlower(str)) + local str = strtrim(strlower(strInput)) if str == "" then --TODO: Show current value return @@ -706,7 +699,7 @@ local function handle(info, inputpos, tab, depth, retfalse) elseif tab.type=="keybinding" then ------------ keybinding -------------------------------------------- - local str = strtrim(strlower(str)) + local str = strtrim(strlower(strInput)) if str == "" then --TODO: Show current value return diff --git a/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua b/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua index a14e07d..4649c73 100644 --- a/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua +++ b/MythicPlusDrop/Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua @@ -1,13 +1,13 @@ --- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. -- @class file -- @name AceConfigDialog-3.0 --- @release $Id: AceConfigDialog-3.0.lua 1232 2020-04-14 22:21:22Z nevcairiel $ +-- @release $Id: AceConfigDialog-3.0.lua 1292 2022-09-29 08:00:11Z nevcairiel $ local LibStub = LibStub local gui = LibStub("AceGUI-3.0") local reg = LibStub("AceConfigRegistry-3.0") -local MAJOR, MINOR = "AceConfigDialog-3.0", 79 +local MAJOR, MINOR = "AceConfigDialog-3.0", 85 local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not AceConfigDialog then return end @@ -22,19 +22,13 @@ AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {} AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {} -- Lua APIs -local tinsert, tsort, tremove = table.insert, table.sort, table.remove +local tinsert, tsort, tremove, wipe = table.insert, table.sort, table.remove, table.wipe local strmatch, format = string.match, string.format local error = error -local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs +local pairs, next, select, type, unpack, ipairs = pairs, next, select, type, unpack, ipairs local tostring, tonumber = tostring, tonumber local math_min, math_max, math_floor = math.min, math.max, math.floor --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: NORMAL_FONT_COLOR, ACCEPT, CANCEL --- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge --- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory, geterrorhandler - local emptyTbl = {} --[[ @@ -194,9 +188,8 @@ local function GetOptionsMemberValue(membername, option, options, path, appName, --We have a function to call local info = new() --traverse the options table, picking up the handler and filling the info with the path - local handler local group = options - handler = group.handler or handler + local handler = group.handler for i = 1, #path do group = GetSubOption(group, path[i]) @@ -535,8 +528,7 @@ local function OptionOnMouseLeave(widget, event) end local function GetFuncName(option) - local type = option.type - if type == "execute" then + if option.type == "execute" then return "func" else return "set" @@ -544,13 +536,15 @@ local function GetFuncName(option) end do local frame = AceConfigDialog.popup - if not frame then + if not frame or oldminor < 81 then frame = CreateFrame("Frame", nil, UIParent) AceConfigDialog.popup = frame frame:Hide() frame:SetPoint("CENTER", UIParent, "CENTER") frame:SetSize(320, 72) + frame:EnableMouse(true) -- Do not allow click-through on the frame frame:SetFrameStrata("TOOLTIP") + frame:SetFrameLevel(100) -- Lots of room to draw under it frame:SetScript("OnKeyDown", function(self, key) if key == "ESCAPE" then self:SetPropagateKeyboardInput(false) @@ -564,26 +558,17 @@ do end end) - if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then - frame:SetBackdrop({ - bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], - edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], - tile = true, - tileSize = 32, - edgeSize = 32, - insets = { left = 11, right = 11, top = 11, bottom = 11 }, - }) - else - local border = CreateFrame("Frame", nil, frame, "DialogBorderDarkTemplate") - border:SetAllPoints(frame) - end + local border = CreateFrame("Frame", nil, frame, "DialogBorderOpaqueTemplate") + border:SetAllPoints(frame) + frame:SetFixedFrameStrata(true) + frame:SetFixedFrameLevel(true) local text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight") text:SetSize(290, 0) text:SetPoint("TOP", 0, -16) frame.text = text - local function newButton(text) + local function newButton(newText) local button = CreateFrame("Button", nil, frame) button:SetSize(128, 21) button:SetNormalFontObject(GameFontNormal) @@ -594,7 +579,7 @@ do button:GetPushedTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875) button:SetHighlightTexture(130762) -- "Interface\\Buttons\\UI-DialogBox-Button-Highlight" button:GetHighlightTexture():SetTexCoord(0.0, 1.0, 0.0, 0.71875) - button:SetText(text) + button:SetText(newText) return button end @@ -681,7 +666,7 @@ local function ActivateControl(widget, event, ...) if group[funcname] ~= nil then func = group[funcname] end - handler = group.handler or handler + handler = group.handler confirm = group.confirm validate = group.validate for i = 1, #path do @@ -745,7 +730,6 @@ local function ActivateControl(widget, event, ...) end end - local rootframe = user.rootframe if not validated or type(validated) == "string" then if not validated then if usage then @@ -760,8 +744,8 @@ local function ActivateControl(widget, event, ...) end -- show validate message - if rootframe.SetStatusText then - rootframe:SetStatusText(validated) + if user.rootframe.SetStatusText then + user.rootframe:SetStatusText(validated) else validationErrorPopup(validated) end @@ -798,14 +782,14 @@ local function ActivateControl(widget, event, ...) if type(confirm) == "boolean" then if confirm then if not confirmText then - local name, desc = option.name, option.desc - if type(name) == "function" then - name = name(info) + local option_name, desc = option.name, option.desc + if type(option_name) == "function" then + option_name = option_name(info) end if type(desc) == "function" then desc = desc(info) end - confirmText = name + confirmText = option_name if desc then confirmText = confirmText.." - "..desc end @@ -1147,8 +1131,6 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin --Control to feed local control - local name = GetOptionsMemberValue("name", v, options, path, appName) - if v.type == "execute" then local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) @@ -1251,7 +1233,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin end tsort(sorting, sortTblAsStrings) end - for k, value in ipairs(sorting) do + for _, value in ipairs(sorting) do local text = values[value] local radio = gui:Create("CheckBox") radio:SetLabel(text) @@ -1333,8 +1315,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin control:SetWidth(width_multiplier) end --check:SetTriState(v.tristate) - for i = 1, #valuesort do - local key = valuesort[i] + for s = 1, #valuesort do + local key = valuesort[s] local value = GetOptionsMemberValue("get",v, options, path, appName, key) control:SetItemValue(key,value) end @@ -1346,8 +1328,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin control:PauseLayout() local width = GetOptionsMemberValue("width",v,options,path,appName) - for i = 1, #valuesort do - local value = valuesort[i] + for s = 1, #valuesort do + local value = valuesort[s] local text = values[value] local check = gui:Create("CheckBox") check:SetLabel(text) @@ -1364,7 +1346,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin elseif width == "half" then check:SetWidth(width_multiplier / 2) elseif (type(width) == "number") then - control:SetWidth(width_multiplier * width) + check:SetWidth(width_multiplier * width) elseif width == "full" then check.width = "fill" else @@ -1434,8 +1416,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin end control:SetImageSize(width, height) end - local width = GetOptionsMemberValue("width",v,options,path,appName) - control.width = not width and "fill" + local controlWidth = GetOptionsMemberValue("width",v,options,path,appName) + control.width = not controlWidth and "fill" end --Common Init @@ -1690,29 +1672,29 @@ function AceConfigDialog:FeedGroup(appName,options,container,rootframe,path, isR elseif grouptype == "select" then - local select = gui:Create("DropdownGroup") - select:SetTitle(name) - InjectInfo(select, options, group, path, rootframe, appName) - select:SetCallback("OnGroupSelected", GroupSelected) + local selectGroup = gui:Create("DropdownGroup") + selectGroup:SetTitle(name) + InjectInfo(selectGroup, options, group, path, rootframe, appName) + selectGroup:SetCallback("OnGroupSelected", GroupSelected) local status = AceConfigDialog:GetStatusTable(appName, path) if not status.groups then status.groups = {} end - select:SetStatusTable(status.groups) + selectGroup:SetStatusTable(status.groups) local grouplist, orderlist = BuildSelect(group, options, path, appName) - select:SetGroupList(grouplist, orderlist) - select:SetUserData("grouplist", grouplist) - select:SetUserData("orderlist", orderlist) + selectGroup:SetGroupList(grouplist, orderlist) + selectGroup:SetUserData("grouplist", grouplist) + selectGroup:SetUserData("orderlist", orderlist) local firstgroup = orderlist[1] if firstgroup then - select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) + selectGroup:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) end - select.width = "fill" - select.height = "fill" + selectGroup.width = "fill" + selectGroup.height = "fill" - container:AddChild(select) + container:AddChild(selectGroup) --assume tree group by default --if parenttype is tree then this group is already a node on that tree @@ -1940,13 +1922,13 @@ end -- convert pre-39 BlizOptions structure to the new format if oldminor and oldminor < 39 and AceConfigDialog.BlizOptions then local old = AceConfigDialog.BlizOptions - local new = {} + local newOpt = {} for key, widget in pairs(old) do local appName = widget:GetUserData("appName") - if not new[appName] then new[appName] = {} end - new[appName][key] = widget + if not newOpt[appName] then newOpt[appName] = {} end + newOpt[appName][key] = widget end - AceConfigDialog.BlizOptions = new + AceConfigDialog.BlizOptions = newOpt else AceConfigDialog.BlizOptions = AceConfigDialog.BlizOptions or {} end @@ -1979,6 +1961,7 @@ end -- @param parent The parent to use in the interface options tree. -- @param ... The path in the options table to feed into the interface options panel. -- @return The reference to the frame registered into the Interface Options. +-- @return The category ID to pass to Settings.OpenToCategory (or InterfaceOptionsFrame_OpenToCategory) function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...) local BlizOptions = AceConfigDialog.BlizOptions @@ -1994,7 +1977,6 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...) if not BlizOptions[appName][key] then local group = gui:Create("BlizOptionsGroup") BlizOptions[appName][key] = group - group:SetName(name or appName, parent) group:SetTitle(name or appName) group:SetUserData("appName", appName) @@ -2007,8 +1989,30 @@ function AceConfigDialog:AddToBlizOptions(appName, name, parent, ...) end group:SetCallback("OnShow", FeedToBlizPanel) group:SetCallback("OnHide", ClearBlizPanel) - InterfaceOptions_AddCategory(group.frame) - return group.frame + if Settings and Settings.RegisterCanvasLayoutCategory then + local categoryName = name or appName + if parent then + local category = Settings.GetCategory(parent) + if not category then + error(("The parent category '%s' was not found"):format(parent), 2) + end + local subcategory = Settings.RegisterCanvasLayoutSubcategory(category, group.frame, categoryName) + + -- force the generated ID to be used for subcategories, as these can have very simple names like "Profiles" + group:SetName(subcategory.ID, parent) + else + local category = Settings.RegisterCanvasLayoutCategory(group.frame, categoryName) + -- using appName here would be cleaner, but would not be 100% compatible + -- but for top-level categories it should be fine, as these are typically addon names + category.ID = categoryName + group:SetName(categoryName, parent) + Settings.RegisterAddOnCategory(category) + end + else + group:SetName(name or appName, parent) + InterfaceOptions_AddCategory(group.frame) + end + return group.frame, group.frame.name else error(("%s has already been added to the Blizzard Options Window with the given path"):format(appName), 2) end diff --git a/MythicPlusDrop/Libs/AceConsole-3.0/AceConsole-3.0.lua b/MythicPlusDrop/Libs/AceConsole-3.0/AceConsole-3.0.lua index 678fa95..2361a3b 100644 --- a/MythicPlusDrop/Libs/AceConsole-3.0/AceConsole-3.0.lua +++ b/MythicPlusDrop/Libs/AceConsole-3.0/AceConsole-3.0.lua @@ -9,7 +9,7 @@ -- make into AceConsole. -- @class file -- @name AceConsole-3.0 --- @release $Id: AceConsole-3.0.lua 1202 2019-05-15 23:11:22Z nevcairiel $ +-- @release $Id: AceConsole-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ local MAJOR,MINOR = "AceConsole-3.0", 7 local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR) @@ -29,10 +29,6 @@ local max = math.max -- WoW APIs local _G = _G --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList - local tmp={} local function Print(self,frame,...) local n=0 @@ -174,7 +170,7 @@ function AceConsole:GetArgs(str, numargs, startpos) while true do -- find delimiter or hyperlink - local ch,_ + local _ pos,_,ch = strfind(str, delim_or_pipe, pos) if not pos then break end diff --git a/MythicPlusDrop/Libs/AceDB-3.0/AceDB-3.0.lua b/MythicPlusDrop/Libs/AceDB-3.0/AceDB-3.0.lua index 440330f..804cf2b 100644 --- a/MythicPlusDrop/Libs/AceDB-3.0/AceDB-3.0.lua +++ b/MythicPlusDrop/Libs/AceDB-3.0/AceDB-3.0.lua @@ -40,7 +40,7 @@ -- end -- @class file -- @name AceDB-3.0.lua --- @release $Id: AceDB-3.0.lua 1217 2019-07-11 03:06:18Z funkydude $ +-- @release $Id: AceDB-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 27 local AceDB = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) @@ -53,10 +53,6 @@ local setmetatable, rawset, rawget = setmetatable, rawset, rawget -- WoW APIs local _G = _G --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: LibStub - AceDB.db_registry = AceDB.db_registry or {} AceDB.frame = AceDB.frame or CreateFrame("Frame") @@ -98,11 +94,11 @@ local function copyDefaults(dest, src) -- This is a metatable used for table defaults local mt = { -- This handles the lookup and creation of new subtables - __index = function(t,k) - if k == nil then return nil end + __index = function(t,k2) + if k2 == nil then return nil end local tbl = {} copyDefaults(tbl, v) - rawset(t, k, tbl) + rawset(t, k2, tbl) return tbl end, } @@ -115,7 +111,7 @@ local function copyDefaults(dest, src) end else -- Values are not tables, so this is just a simple return - local mt = {__index = function(t,k) return k~=nil and v or nil end} + local mt = {__index = function(t,k2) return k2~=nil and v or nil end} setmetatable(dest, mt) end elseif type(v) == "table" then diff --git a/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.lua b/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.lua new file mode 100644 index 0000000..9029c66 --- /dev/null +++ b/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.lua @@ -0,0 +1,456 @@ +--- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles. +-- @class file +-- @name AceDBOptions-3.0 +-- @release $Id: AceDBOptions-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ +local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 15 +local AceDBOptions = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR) + +if not AceDBOptions then return end -- No upgrade needed + +-- Lua APIs +local pairs, next = pairs, next + +-- WoW APIs +local UnitClass = UnitClass + +AceDBOptions.optionTables = AceDBOptions.optionTables or {} +AceDBOptions.handlers = AceDBOptions.handlers or {} + +--[[ + Localization of AceDBOptions-3.0 +]] + +local L = { + choose = "Existing Profiles", + choose_desc = "You can either create a new profile by entering a name in the editbox, or choose one of the already existing profiles.", + choose_sub = "Select one of your currently available profiles.", + copy = "Copy From", + copy_desc = "Copy the settings from one existing profile into the currently active profile.", + current = "Current Profile:", + default = "Default", + delete = "Delete a Profile", + delete_confirm = "Are you sure you want to delete the selected profile?", + delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.", + delete_sub = "Deletes a profile from the database.", + intro = "You can change the active database profile, so you can have different settings for every character.", + new = "New", + new_sub = "Create a new empty profile.", + profiles = "Profiles", + profiles_sub = "Manage Profiles", + reset = "Reset Profile", + reset_desc = "Reset the current profile back to its default values, in case your configuration is broken, or you simply want to start over.", + reset_sub = "Reset the current profile to the default", +} + +local LOCALE = GetLocale() +if LOCALE == "deDE" then + L["choose"] = "Vorhandene Profile" + L["choose_desc"] = "Du kannst ein neues Profil erstellen, indem du einen neuen Namen in der Eingabebox 'Neu' eingibst, oder wähle eines der vorhandenen Profile aus." + L["choose_sub"] = "Wählt ein bereits vorhandenes Profil aus." + L["copy"] = "Kopieren von..." + L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil." + L["current"] = "Aktuelles Profil:" + L["default"] = "Standard" + L["delete"] = "Profil löschen" + L["delete_confirm"] = "Willst du das ausgewählte Profil wirklich löschen?" + L["delete_desc"] = "Lösche vorhandene oder unbenutzte Profile aus der Datenbank, um Platz zu sparen und die SavedVariables-Datei 'sauber' zu halten." + L["delete_sub"] = "Löscht ein Profil aus der Datenbank." + L["intro"] = "Hier kannst du das aktive Datenbankprofil ändern, damit du verschiedene Einstellungen für jeden Charakter erstellen kannst, wodurch eine sehr flexible Konfiguration möglich wird." + L["new"] = "Neu" + L["new_sub"] = "Ein neues Profil erstellen." + L["profiles"] = "Profile" + L["profiles_sub"] = "Profile verwalten" + L["reset"] = "Profil zurücksetzen" + L["reset_desc"] = "Setzt das momentane Profil auf Standardwerte zurück, für den Fall, dass mit der Konfiguration etwas schief lief oder weil du einfach neu starten willst." + L["reset_sub"] = "Das aktuelle Profil auf Standard zurücksetzen." +elseif LOCALE == "frFR" then + L["choose"] = "Profils existants" + L["choose_desc"] = "Vous pouvez créer un nouveau profil en entrant un nouveau nom dans la boîte de saisie, ou en choississant un des profils déjà existants." + L["choose_sub"] = "Permet de choisir un des profils déjà disponibles." + L["copy"] = "Copier à partir de" + L["copy_desc"] = "Copie les paramètres d'un profil déjà existant dans le profil actuellement actif." + L["current"] = "Profil actuel :" + L["default"] = "Défaut" + L["delete"] = "Supprimer un profil" + L["delete_confirm"] = "Etes-vous sûr de vouloir supprimer le profil sélectionné ?" + L["delete_desc"] = "Supprime les profils existants inutilisés de la base de données afin de gagner de la place et de nettoyer le fichier SavedVariables." + L["delete_sub"] = "Supprime un profil de la base de données." + L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des paramètres différents pour chaque personnage, permettant ainsi d'avoir une configuration très flexible." + L["new"] = "Nouveau" + L["new_sub"] = "Créée un nouveau profil vierge." + L["profiles"] = "Profils" + L["profiles_sub"] = "Gestion des profils" + L["reset"] = "Réinitialiser le profil" + L["reset_desc"] = "Réinitialise le profil actuel au cas où votre configuration est corrompue ou si vous voulez tout simplement faire table rase." + L["reset_sub"] = "Réinitialise le profil actuel avec les paramètres par défaut." +elseif LOCALE == "koKR" then + L["choose"] = "저장 중인 프로필" + L["choose_desc"] = "입력창에 새로운 이름을 입력하거나 저장 중인 프로필 중 하나를 선택하여 새로운 프로필을 만들 수 있습니다." + L["choose_sub"] = "현재 이용할 수 있는 프로필 중 하나를 선택합니다." + L["copy"] = "복사해오기" + L["copy_desc"] = "현재 사용 중인 프로필에 선택한 프로필의 설정을 복사합니다." + L["current"] = "현재 프로필:" + L["default"] = "기본값" + L["delete"] = "프로필 삭제" + L["delete_confirm"] = "정말로 선택한 프로필을 삭제할까요?" + L["delete_desc"] = "저장 공간 절약과 SavedVariables 파일의 정리를 위해 데이터베이스에서 사용하지 않는 프로필을 삭제하세요." + L["delete_sub"] = "데이터베이스의 프로필을 삭제합니다." + L["intro"] = "활성 데이터베이스 프로필을 변경할 수 있고, 각 캐릭터 별로 다른 설정을 할 수 있습니다." + L["new"] = "새로운 프로필" + L["new_sub"] = "새로운 프로필을 만듭니다." + L["profiles"] = "프로필" + L["profiles_sub"] = "프로필 관리" + L["reset"] = "프로필 초기화" + L["reset_desc"] = "설정이 깨졌거나 처음부터 다시 설정을 원하는 경우, 현재 프로필을 기본값으로 초기화하세요." + L["reset_sub"] = "현재 프로필을 기본값으로 초기화합니다" +elseif LOCALE == "esES" or LOCALE == "esMX" then + L["choose"] = "Perfiles existentes" + L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes." + L["choose_sub"] = "Selecciona uno de los perfiles disponibles." + L["copy"] = "Copiar de" + L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual." + L["current"] = "Perfil actual:" + L["default"] = "Por defecto" + L["delete"] = "Borrar un Perfil" + L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?" + L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables." + L["delete_sub"] = "Borra un perfil de la base de datos." + L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones." + L["new"] = "Nuevo" + L["new_sub"] = "Crear un nuevo perfil vacio." + L["profiles"] = "Perfiles" + L["profiles_sub"] = "Manejar Perfiles" + L["reset"] = "Reiniciar Perfil" + L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo." + L["reset_sub"] = "Reinicar el perfil actual al de por defecto" +elseif LOCALE == "zhTW" then + L["choose"] = "現有的設定檔" + L["choose_desc"] = "您可以在文字方塊內輸入名字以建立新的設定檔,或是選擇一個現有的設定檔使用。" + L["choose_sub"] = "從當前可用的設定檔裡面選擇一個。" + L["copy"] = "複製自" + L["copy_desc"] = "從一個現有的設定檔,將設定複製到現在使用中的設定檔。" + L["current"] = "目前設定檔:" + L["default"] = "預設" + L["delete"] = "刪除一個設定檔" + L["delete_confirm"] = "確定要刪除所選擇的設定檔嗎?" + L["delete_desc"] = "從資料庫裡刪除不再使用的設定檔,以節省空間,並且清理 SavedVariables 檔案。" + L["delete_sub"] = "從資料庫裡刪除一個設定檔。" + L["intro"] = "您可以從資料庫中選擇一個設定檔來使用,如此就可以讓每個角色使用不同的設定。" + L["new"] = "新建" + L["new_sub"] = "新建一個空的設定檔。" + L["profiles"] = "設定檔" + L["profiles_sub"] = "管理設定檔" + L["reset"] = "重置設定檔" + L["reset_desc"] = "將現用的設定檔重置為預設值;用於設定檔損壞,或者單純想要重來的情況。" + L["reset_sub"] = "將目前的設定檔重置為預設值" +elseif LOCALE == "zhCN" then + L["choose"] = "现有的配置文件" + L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。" + L["choose_sub"] = "从当前可用的配置文件里面选择一个。" + L["copy"] = "复制自" + L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。" + L["current"] = "当前配置文件:" + L["default"] = "默认" + L["delete"] = "删除一个配置文件" + L["delete_confirm"] = "你确定要删除所选择的配置文件么?" + L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。" + L["delete_sub"] = "从数据库里删除一个配置文件。" + L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。" + L["new"] = "新建" + L["new_sub"] = "新建一个空的配置文件。" + L["profiles"] = "配置文件" + L["profiles_sub"] = "管理配置文件" + L["reset"] = "重置配置文件" + L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。" + L["reset_sub"] = "将当前的配置文件恢复为默认值" +elseif LOCALE == "ruRU" then + L["choose"] = "Существующие профили" + L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей." + L["choose_sub"] = "Выбор одиного из уже доступных профилей" + L["copy"] = "Скопировать из" + L["copy_desc"] = "Скопировать настройки из выбранного профиля в активный." + L["current"] = "Текущий профиль:" + L["default"] = "По умолчанию" + L["delete"] = "Удалить профиль" + L["delete_confirm"] = "Вы уверены, что вы хотите удалить выбранный профиль?" + L["delete_desc"] = "Удалить существующий и неиспользуемый профиль из БД для сохранения места, и очистить SavedVariables файл." + L["delete_sub"] = "Удаление профиля из БД" + L["intro"] = "Изменяя активный профиль, вы можете задать различные настройки модификаций для каждого персонажа." + L["new"] = "Новый" + L["new_sub"] = "Создать новый чистый профиль" + L["profiles"] = "Профили" + L["profiles_sub"] = "Управление профилями" + L["reset"] = "Сброс профиля" + L["reset_desc"] = "Сбросить текущий профиль к стандартным настройкам, если ваша конфигурация испорчена или вы хотите настроить всё заново." + L["reset_sub"] = "Сброс текущего профиля на стандартный" +elseif LOCALE == "itIT" then + L["choose"] = "Profili Esistenti" + L["choose_desc"] = "Puoi creare un nuovo profilo digitando il nome della casella di testo, oppure scegliendone uno tra i profili già esistenti." + L["choose_sub"] = "Seleziona uno dei profili attualmente disponibili." + L["copy"] = "Copia Da" + L["copy_desc"] = "Copia le impostazioni da un profilo esistente, nel profilo attivo in questo momento." + L["current"] = "Profilo Attivo:" + L["default"] = "Standard" + L["delete"] = "Cancella un Profilo" + L["delete_confirm"] = "Sei sicuro di voler cancellare il profilo selezionato?" + L["delete_desc"] = "Cancella i profili non utilizzati dal database per risparmiare spazio e mantenere puliti i file di configurazione SavedVariables." + L["delete_sub"] = "Cancella un profilo dal Database." + L["intro"] = "Puoi cambiare il profilo attivo, in modo da usare impostazioni diverse per ogni personaggio." + L["new"] = "Nuovo" + L["new_sub"] = "Crea un nuovo profilo vuoto." + L["profiles"] = "Profili" + L["profiles_sub"] = "Gestisci Profili" + L["reset"] = "Reimposta Profilo" + L["reset_desc"] = "Riporta il tuo profilo attivo alle sue impostazioni predefinite, nel caso in cui la tua configurazione si sia corrotta, o semplicemente tu voglia re-inizializzarla." + L["reset_sub"] = "Reimposta il profilo ai suoi valori predefiniti." +elseif LOCALE == "ptBR" then + L["choose"] = "Perfis Existentes" + L["choose_desc"] = "Você pode tanto criar um perfil novo tanto digitando um nome na caixa de texto, quanto escolher um dos perfis já existentes." + L["choose_sub"] = "Selecione um de seus perfis atualmente disponíveis." + L["copy"] = "Copiar De" + L["copy_desc"] = "Copia as definições de um perfil existente no perfil atualmente ativo." + L["current"] = "Perfil Autal:" + L["default"] = "Padrão" + L["delete"] = "Remover um Perfil" + L["delete_confirm"] = "Tem certeza que deseja remover o perfil selecionado?" + L["delete_desc"] = "Remove perfis existentes e inutilizados do banco de dados para economizar espaço, e limpar o arquivo SavedVariables." + L["delete_sub"] = "Remove um perfil do banco de dados." + L["intro"] = "Você pode alterar o perfil do banco de dados ativo, para que possa ter definições diferentes para cada personagem." + L["new"] = "Novo" + L["new_sub"] = "Cria um novo perfil vazio." + L["profiles"] = "Perfis" + L["profiles_sub"] = "Gerenciar Perfis" + L["reset"] = "Resetar Perfil" + L["reset_desc"] = "Reseta o perfil atual para os valores padrões, no caso de sua configuração estar quebrada, ou simplesmente se deseja começar novamente." + L["reset_sub"] = "Resetar o perfil atual ao padrão" +end + +local defaultProfiles +local tmpprofiles = {} + +-- Get a list of available profiles for the specified database. +-- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below. +-- @param db The db object to retrieve the profiles from +-- @param common If true, getProfileList will add the default profiles to the return list, even if they have not been created yet +-- @param nocurrent If true, then getProfileList will not display the current profile in the list +-- @return Hashtable of all profiles with the internal name as keys and the display name as value. +local function getProfileList(db, common, nocurrent) + local profiles = {} + + -- copy existing profiles into the table + local currentProfile = db:GetCurrentProfile() + for i,v in pairs(db:GetProfiles(tmpprofiles)) do + if not (nocurrent and v == currentProfile) then + profiles[v] = v + end + end + + -- add our default profiles to choose from ( or rename existing profiles) + for k,v in pairs(defaultProfiles) do + if (common or profiles[k]) and not (nocurrent and k == currentProfile) then + profiles[k] = v + end + end + + return profiles +end + +--[[ + OptionsHandlerPrototype + prototype class for handling the options in a sane way +]] +local OptionsHandlerPrototype = {} + +--[[ Reset the profile ]] +function OptionsHandlerPrototype:Reset() + self.db:ResetProfile() +end + +--[[ Set the profile to value ]] +function OptionsHandlerPrototype:SetProfile(info, value) + self.db:SetProfile(value) +end + +--[[ returns the currently active profile ]] +function OptionsHandlerPrototype:GetCurrentProfile() + return self.db:GetCurrentProfile() +end + +--[[ + List all active profiles + you can control the output with the .arg variable + currently four modes are supported + + (empty) - return all available profiles + "nocurrent" - returns all available profiles except the currently active profile + "common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default") + "both" - common except the active profile +]] +function OptionsHandlerPrototype:ListProfiles(info) + local arg = info.arg + local profiles + if arg == "common" and not self.noDefaultProfiles then + profiles = getProfileList(self.db, true, nil) + elseif arg == "nocurrent" then + profiles = getProfileList(self.db, nil, true) + elseif arg == "both" then -- currently not used + profiles = getProfileList(self.db, (not self.noDefaultProfiles) and true, true) + else + profiles = getProfileList(self.db) + end + + return profiles +end + +function OptionsHandlerPrototype:HasNoProfiles(info) + local profiles = self:ListProfiles(info) + return ((not next(profiles)) and true or false) +end + +--[[ Copy a profile ]] +function OptionsHandlerPrototype:CopyProfile(info, value) + self.db:CopyProfile(value) +end + +--[[ Delete a profile from the db ]] +function OptionsHandlerPrototype:DeleteProfile(info, value) + self.db:DeleteProfile(value) +end + +--[[ fill defaultProfiles with some generic values ]] +local function generateDefaultProfiles(db) + defaultProfiles = { + ["Default"] = L["default"], + [db.keys.char] = db.keys.char, + [db.keys.realm] = db.keys.realm, + [db.keys.class] = UnitClass("player") + } +end + +--[[ create and return a handler object for the db, or upgrade it if it already existed ]] +local function getOptionsHandler(db, noDefaultProfiles) + if not defaultProfiles then + generateDefaultProfiles(db) + end + + local handler = AceDBOptions.handlers[db] or { db = db, noDefaultProfiles = noDefaultProfiles } + + for k,v in pairs(OptionsHandlerPrototype) do + handler[k] = v + end + + AceDBOptions.handlers[db] = handler + return handler +end + +--[[ + the real options table +]] +local optionsTable = { + desc = { + order = 1, + type = "description", + name = L["intro"] .. "\n", + }, + descreset = { + order = 9, + type = "description", + name = L["reset_desc"], + }, + reset = { + order = 10, + type = "execute", + name = L["reset"], + desc = L["reset_sub"], + func = "Reset", + }, + current = { + order = 11, + type = "description", + name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end, + width = "default", + }, + choosedesc = { + order = 20, + type = "description", + name = "\n" .. L["choose_desc"], + }, + new = { + name = L["new"], + desc = L["new_sub"], + type = "input", + order = 30, + get = false, + set = "SetProfile", + }, + choose = { + name = L["choose"], + desc = L["choose_sub"], + type = "select", + order = 40, + get = "GetCurrentProfile", + set = "SetProfile", + values = "ListProfiles", + arg = "common", + }, + copydesc = { + order = 50, + type = "description", + name = "\n" .. L["copy_desc"], + }, + copyfrom = { + order = 60, + type = "select", + name = L["copy"], + desc = L["copy_desc"], + get = false, + set = "CopyProfile", + values = "ListProfiles", + disabled = "HasNoProfiles", + arg = "nocurrent", + }, + deldesc = { + order = 70, + type = "description", + name = "\n" .. L["delete_desc"], + }, + delete = { + order = 80, + type = "select", + name = L["delete"], + desc = L["delete_sub"], + get = false, + set = "DeleteProfile", + values = "ListProfiles", + disabled = "HasNoProfiles", + arg = "nocurrent", + confirm = true, + confirmText = L["delete_confirm"], + }, +} + +--- Get/Create a option table that you can use in your addon to control the profiles of AceDB-3.0. +-- @param db The database object to create the options table for. +-- @return The options table to be used in AceConfig-3.0 +-- @usage +-- -- Assuming `options` is your top-level options table and `self.db` is your database: +-- options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) +function AceDBOptions:GetOptionsTable(db, noDefaultProfiles) + local tbl = AceDBOptions.optionTables[db] or { + type = "group", + name = L["profiles"], + desc = L["profiles_sub"], + } + + tbl.handler = getOptionsHandler(db, noDefaultProfiles) + tbl.args = optionsTable + + AceDBOptions.optionTables[db] = tbl + return tbl +end + +-- upgrade existing tables +for db,tbl in pairs(AceDBOptions.optionTables) do + tbl.handler = getOptionsHandler(db) + tbl.args = optionsTable +end diff --git a/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.xml b/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.xml new file mode 100644 index 0000000..51305f9 --- /dev/null +++ b/MythicPlusDrop/Libs/AceDBOptions-3.0/AceDBOptions-3.0.xml @@ -0,0 +1,4 @@ + +