X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/8f4bc830f37b66724627f90628b8e3179ad98440..2ddc77e690e99f5db2d01706ae25e54fc45eba86:/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua diff --git a/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua index 1c28821..f2d5266 100644 --- a/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua +++ b/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua @@ -1,10 +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 1089 2013-09-13 14:32:35Z nevcairiel $ +-- @release $Id: AceConfigDialog-3.0.lua 1163 2017-08-14 14:04:39Z nevcairiel $ local LibStub = LibStub -local MAJOR, MINOR = "AceConfigDialog-3.0", 58 +local gui = LibStub("AceGUI-3.0") +local reg = LibStub("AceConfigRegistry-3.0") + +local MAJOR, MINOR = "AceConfigDialog-3.0", 64 local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not AceConfigDialog then return end @@ -17,9 +20,6 @@ AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {} AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {} AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {} -local gui = LibStub("AceGUI-3.0") -local reg = LibStub("AceConfigRegistry-3.0") - -- Lua APIs local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort local strmatch, format = string.match, string.format @@ -542,16 +542,16 @@ local function OptionOnMouseOver(widget, event) if descStyle and descStyle ~= "tooltip" then return end - GameTooltip:SetText(name, 1, .82, 0, 1) + GameTooltip:SetText(name, 1, .82, 0, true) if opt.type == "multiselect" then - GameTooltip:AddLine(user.text,0.5, 0.5, 0.8, 1) + GameTooltip:AddLine(user.text, 0.5, 0.5, 0.8, true) end if type(desc) == "string" then - GameTooltip:AddLine(desc, 1, 1, 1, 1) + GameTooltip:AddLine(desc, 1, 1, 1, true) end if type(usage) == "string" then - GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1) + GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true) end GameTooltip:Show() @@ -611,6 +611,31 @@ local function confirmPopup(appName, rootframe, basepath, info, message, func, . end end +local function validationErrorPopup(message) + if not StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] then + StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] = {} + end + local t = StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] + t.text = message + t.button1 = OKAY + t.preferredIndex = STATICPOPUP_NUMDIALOGS + local dialog, oldstrata + t.OnAccept = function() + if dialog and oldstrata then + dialog:SetFrameStrata(oldstrata) + end + end + t.timeout = 0 + t.whileDead = 1 + t.hideOnEscape = 1 + + dialog = StaticPopup_Show("ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG") + if dialog then + oldstrata = dialog:GetFrameStrata() + dialog:SetFrameStrata("TOOLTIP") + end +end + local function ActivateControl(widget, event, ...) --This function will call the set / execute handler for the widget --widget:GetUserDataTable() contains the needed info @@ -696,32 +721,26 @@ local function ActivateControl(widget, event, ...) end local rootframe = user.rootframe - if type(validated) == "string" then - --validate function returned a message to display - if rootframe.SetStatusText then - rootframe:SetStatusText(validated) - else - -- TODO: do something else. - end - PlaySound("igPlayerInviteDecline") - del(info) - return true - elseif not validated then - --validate returned false - if rootframe.SetStatusText then + if not validated or type(validated) == "string" then + if not validated then if usage then - rootframe:SetStatusText(name..": "..usage) + validated = name..": "..usage else if pattern then - rootframe:SetStatusText(name..": Expected "..pattern) + validated = name..": Expected "..pattern else - rootframe:SetStatusText(name..": Invalid Value") + validated = name..": Invalid Value" end end + end + + -- show validate message + if rootframe.SetStatusText then + rootframe:SetStatusText(validated) else - -- TODO: do something else + validationErrorPopup(validated) end - PlaySound("igPlayerInviteDecline") + PlaySound(PlaySoundKitID and "igPlayerInviteDecline" or 882) -- SOUNDKIT.IG_PLAYER_INVITE_DECLINE || XXX _DECLINE is actually missing from the table del(info) return true else @@ -1092,7 +1111,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) - if type(image) == "string" then + if type(image) == "string" or type(image) == "number" then control = gui:Create("Icon") if not width then width = GetOptionsMemberValue("imageWidth",v, options, path, appName) @@ -1154,7 +1173,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin local image = GetOptionsMemberValue("image", v, options, path, appName) local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName) - if type(image) == "string" then + if type(image) == "string" or type(image) == "number" then if type(imageCoords) == "table" then control:SetImage(image, unpack(imageCoords)) else @@ -1354,7 +1373,7 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) - if type(image) == "string" then + if type(image) == "string" or type(image) == "number" then if not width then width = GetOptionsMemberValue("imageWidth",v, options, path, appName) end @@ -1448,10 +1467,10 @@ local function TreeOnButtonEnter(widget, event, uniquevalue, button) GameTooltip:SetPoint("LEFT",button,"RIGHT") end - GameTooltip:SetText(name, 1, .82, 0, 1) + GameTooltip:SetText(name, 1, .82, 0, true) if type(desc) == "string" then - GameTooltip:AddLine(desc, 1, 1, 1, 1) + GameTooltip:AddLine(desc, 1, 1, 1, true) end GameTooltip:Show() @@ -1817,6 +1836,14 @@ function AceConfigDialog:Open(appName, container, ...) tinsert(path, (select(n, ...))) end + local option = options + if type(container) == "table" and container.type == "BlizOptionsGroup" and #path > 0 then + for i = 1, #path do + option = options.args[path[i]] + end + name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName)) + end + --if a container is given feed into that if container then f = container