Mercurial > wow > hotcorners
comparison Libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua @ 17:3000eccbf1a0 v7.3.0.017
- ToC Update.
| author | Tercio | 
|---|---|
| date | Sat, 02 Sep 2017 14:10:48 -0300 | 
| parents | 371e14cd2feb | 
| children | 9ad7f3c634f1 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 16:6c64dd7f16a2 | 17:3000eccbf1a0 | 
|---|---|
| 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 1139 2016-07-03 07:43:51Z 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", 61 | 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 | 
| 609 oldstrata = dialog:GetFrameStrata() | 609 oldstrata = dialog:GetFrameStrata() | 
| 610 dialog:SetFrameStrata("TOOLTIP") | 610 dialog:SetFrameStrata("TOOLTIP") | 
| 611 end | 611 end | 
| 612 end | 612 end | 
| 613 | 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") | |
| 633 if dialog then | |
| 634 oldstrata = dialog:GetFrameStrata() | |
| 635 dialog:SetFrameStrata("TOOLTIP") | |
| 636 end | |
| 637 end | |
| 638 | |
| 614 local function ActivateControl(widget, event, ...) | 639 local function ActivateControl(widget, event, ...) | 
| 615 --This function will call the set / execute handler for the widget | 640 --This function will call the set / execute handler for the widget | 
| 616 --widget:GetUserDataTable() contains the needed info | 641 --widget:GetUserDataTable() contains the needed info | 
| 617 local user = widget:GetUserDataTable() | 642 local user = widget:GetUserDataTable() | 
| 618 local option = user.option | 643 local option = user.option | 
| 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 | 
