comparison Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua @ 18:a0dcdcaec1ea v7.3.0.018

- toc update. - libs update.
author Tercio
date Tue, 17 Oct 2017 10:02:01 -0200
parents ce416064d8a1
children fedcd7c21db9
comparison
equal deleted inserted replaced
17:da84a5064a5a 18:a0dcdcaec1ea
1 --- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. 1 --- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables.
2 -- @class file 2 -- @class file
3 -- @name AceConfigDialog-3.0 3 -- @name AceConfigDialog-3.0
4 -- @release $Id: AceConfigDialog-3.0.lua 1089 2013-09-13 14:32:35Z nevcairiel $ 4 -- @release $Id: AceConfigDialog-3.0.lua 1167 2017-08-29 22:08:48Z funkydude $
5 5
6 local LibStub = LibStub 6 local LibStub = LibStub
7 local MAJOR, MINOR = "AceConfigDialog-3.0", 58 7 local gui = LibStub("AceGUI-3.0")
8 local reg = LibStub("AceConfigRegistry-3.0")
9
10 local MAJOR, MINOR = "AceConfigDialog-3.0", 64
8 local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) 11 local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
9 12
10 if not AceConfigDialog then return end 13 if not AceConfigDialog then return end
11 14
12 AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {} 15 AceConfigDialog.OpenFrames = AceConfigDialog.OpenFrames or {}
14 AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame") 17 AceConfigDialog.frame = AceConfigDialog.frame or CreateFrame("Frame")
15 18
16 AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {} 19 AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {}
17 AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {} 20 AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
18 AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {} 21 AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {}
19
20 local gui = LibStub("AceGUI-3.0")
21 local reg = LibStub("AceConfigRegistry-3.0")
22 22
23 -- Lua APIs 23 -- Lua APIs
24 local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort 24 local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort
25 local strmatch, format = string.match, string.format 25 local strmatch, format = string.match, string.format
26 local assert, loadstring, error = assert, loadstring, error 26 local assert, loadstring, error = assert, loadstring, error
540 local usage = GetOptionsMemberValue("usage", opt, options, path, appName) 540 local usage = GetOptionsMemberValue("usage", opt, options, path, appName)
541 local descStyle = opt.descStyle 541 local descStyle = opt.descStyle
542 542
543 if descStyle and descStyle ~= "tooltip" then return end 543 if descStyle and descStyle ~= "tooltip" then return end
544 544
545 GameTooltip:SetText(name, 1, .82, 0, 1) 545 GameTooltip:SetText(name, 1, .82, 0, true)
546 546
547 if opt.type == "multiselect" then 547 if opt.type == "multiselect" then
548 GameTooltip:AddLine(user.text,0.5, 0.5, 0.8, 1) 548 GameTooltip:AddLine(user.text, 0.5, 0.5, 0.8, true)
549 end 549 end
550 if type(desc) == "string" then 550 if type(desc) == "string" then
551 GameTooltip:AddLine(desc, 1, 1, 1, 1) 551 GameTooltip:AddLine(desc, 1, 1, 1, true)
552 end 552 end
553 if type(usage) == "string" then 553 if type(usage) == "string" then
554 GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1) 554 GameTooltip:AddLine("Usage: "..usage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
555 end 555 end
556 556
557 GameTooltip:Show() 557 GameTooltip:Show()
558 end 558 end
559 559
603 t.timeout = 0 603 t.timeout = 0
604 t.whileDead = 1 604 t.whileDead = 1
605 t.hideOnEscape = 1 605 t.hideOnEscape = 1
606 606
607 dialog = StaticPopup_Show("ACECONFIGDIALOG30_CONFIRM_DIALOG") 607 dialog = StaticPopup_Show("ACECONFIGDIALOG30_CONFIRM_DIALOG")
608 if dialog then
609 oldstrata = dialog:GetFrameStrata()
610 dialog:SetFrameStrata("TOOLTIP")
611 end
612 end
613
614 local function validationErrorPopup(message)
615 if not StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] then
616 StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"] = {}
617 end
618 local t = StaticPopupDialogs["ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG"]
619 t.text = message
620 t.button1 = OKAY
621 t.preferredIndex = STATICPOPUP_NUMDIALOGS
622 local dialog, oldstrata
623 t.OnAccept = function()
624 if dialog and oldstrata then
625 dialog:SetFrameStrata(oldstrata)
626 end
627 end
628 t.timeout = 0
629 t.whileDead = 1
630 t.hideOnEscape = 1
631
632 dialog = StaticPopup_Show("ACECONFIGDIALOG30_VALIDATION_ERROR_DIALOG")
608 if dialog then 633 if dialog then
609 oldstrata = dialog:GetFrameStrata() 634 oldstrata = dialog:GetFrameStrata()
610 dialog:SetFrameStrata("TOOLTIP") 635 dialog:SetFrameStrata("TOOLTIP")
611 end 636 end
612 end 637 end
694 if not success then validated = false end 719 if not success then validated = false end
695 end 720 end
696 end 721 end
697 722
698 local rootframe = user.rootframe 723 local rootframe = user.rootframe
699 if type(validated) == "string" then 724 if not validated or type(validated) == "string" then
700 --validate function returned a message to display 725 if not validated then
726 if usage then
727 validated = name..": "..usage
728 else
729 if pattern then
730 validated = name..": Expected "..pattern
731 else
732 validated = name..": Invalid Value"
733 end
734 end
735 end
736
737 -- show validate message
701 if rootframe.SetStatusText then 738 if rootframe.SetStatusText then
702 rootframe:SetStatusText(validated) 739 rootframe:SetStatusText(validated)
703 else 740 else
704 -- TODO: do something else. 741 validationErrorPopup(validated)
705 end 742 end
706 PlaySound("igPlayerInviteDecline") 743 PlaySound(882) -- SOUNDKIT.IG_PLAYER_INVITE_DECLINE || _DECLINE is actually missing from the table
707 del(info)
708 return true
709 elseif not validated then
710 --validate returned false
711 if rootframe.SetStatusText then
712 if usage then
713 rootframe:SetStatusText(name..": "..usage)
714 else
715 if pattern then
716 rootframe:SetStatusText(name..": Expected "..pattern)
717 else
718 rootframe:SetStatusText(name..": Invalid Value")
719 end
720 end
721 else
722 -- TODO: do something else
723 end
724 PlaySound("igPlayerInviteDecline")
725 del(info) 744 del(info)
726 return true 745 return true
727 else 746 else
728 747
729 local confirmText = option.confirmText 748 local confirmText = option.confirmText
1090 if v.type == "execute" then 1109 if v.type == "execute" then
1091 1110
1092 local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) 1111 local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
1093 local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) 1112 local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
1094 1113
1095 if type(image) == "string" then 1114 if type(image) == "string" or type(image) == "number" then
1096 control = gui:Create("Icon") 1115 control = gui:Create("Icon")
1097 if not width then 1116 if not width then
1098 width = GetOptionsMemberValue("imageWidth",v, options, path, appName) 1117 width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
1099 end 1118 end
1100 if not height then 1119 if not height then
1152 end 1171 end
1153 1172
1154 local image = GetOptionsMemberValue("image", v, options, path, appName) 1173 local image = GetOptionsMemberValue("image", v, options, path, appName)
1155 local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName) 1174 local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName)
1156 1175
1157 if type(image) == "string" then 1176 if type(image) == "string" or type(image) == "number" then
1158 if type(imageCoords) == "table" then 1177 if type(imageCoords) == "table" then
1159 control:SetImage(image, unpack(imageCoords)) 1178 control:SetImage(image, unpack(imageCoords))
1160 else 1179 else
1161 control:SetImage(image) 1180 control:SetImage(image)
1162 end 1181 end
1352 end 1371 end
1353 1372
1354 local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) 1373 local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName)
1355 local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) 1374 local image, width, height = GetOptionsMemberValue("image",v, options, path, appName)
1356 1375
1357 if type(image) == "string" then 1376 if type(image) == "string" or type(image) == "number" then
1358 if not width then 1377 if not width then
1359 width = GetOptionsMemberValue("imageWidth",v, options, path, appName) 1378 width = GetOptionsMemberValue("imageWidth",v, options, path, appName)
1360 end 1379 end
1361 if not height then 1380 if not height then
1362 height = GetOptionsMemberValue("imageHeight",v, options, path, appName) 1381 height = GetOptionsMemberValue("imageHeight",v, options, path, appName)
1446 GameTooltip:SetPoint("BOTTOM",button,"TOP") 1465 GameTooltip:SetPoint("BOTTOM",button,"TOP")
1447 else 1466 else
1448 GameTooltip:SetPoint("LEFT",button,"RIGHT") 1467 GameTooltip:SetPoint("LEFT",button,"RIGHT")
1449 end 1468 end
1450 1469
1451 GameTooltip:SetText(name, 1, .82, 0, 1) 1470 GameTooltip:SetText(name, 1, .82, 0, true)
1452 1471
1453 if type(desc) == "string" then 1472 if type(desc) == "string" then
1454 GameTooltip:AddLine(desc, 1, 1, 1, 1) 1473 GameTooltip:AddLine(desc, 1, 1, 1, true)
1455 end 1474 end
1456 1475
1457 GameTooltip:Show() 1476 GameTooltip:Show()
1458 end 1477 end
1459 1478
1813 tinsert(path, container) 1832 tinsert(path, container)
1814 container = nil 1833 container = nil
1815 end 1834 end
1816 for n = 1, select("#",...) do 1835 for n = 1, select("#",...) do
1817 tinsert(path, (select(n, ...))) 1836 tinsert(path, (select(n, ...)))
1837 end
1838
1839 local option = options
1840 if type(container) == "table" and container.type == "BlizOptionsGroup" and #path > 0 then
1841 for i = 1, #path do
1842 option = options.args[path[i]]
1843 end
1844 name = format("%s - %s", name, GetOptionsMemberValue("name", option, options, path, appName))
1818 end 1845 end
1819 1846
1820 --if a container is given feed into that 1847 --if a container is given feed into that
1821 if container then 1848 if container then
1822 f = container 1849 f = container