Mercurial > wow > reaction
comparison modules/ConfigUI.lua @ 184:1ee86bbb05a0
more options rearranging
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Fri, 22 Oct 2010 16:03:04 +0000 |
| parents | 55c2fc0c8d55 |
| children |
comparison
equal
deleted
inserted
replaced
| 183:1696ff2c80cc | 184:1ee86bbb05a0 |
|---|---|
| 10 local L = ReAction.L | 10 local L = ReAction.L |
| 11 local _G = _G | 11 local _G = _G |
| 12 local AceConfigReg = LibStub("AceConfigRegistry-3.0") | 12 local AceConfigReg = LibStub("AceConfigRegistry-3.0") |
| 13 local AceConfigDialog = LibStub("AceConfigDialog-3.0") | 13 local AceConfigDialog = LibStub("AceConfigDialog-3.0") |
| 14 | 14 |
| 15 -- some constants | |
| 16 local configName = "ReAction" | |
| 17 | |
| 18 -- module declaration | 15 -- module declaration |
| 19 local moduleID = "ConfigUI" | 16 local moduleID = "ConfigUI" |
| 20 local module = ReAction:NewModule( moduleID, | 17 local module = ReAction:NewModule( moduleID, |
| 21 "AceEvent-3.0" | 18 "AceEvent-3.0" |
| 22 ) | 19 ) |
| 24 -- module methods | 21 -- module methods |
| 25 function module:OnInitialize() | 22 function module:OnInitialize() |
| 26 self.db = ReAction.db:RegisterNamespace( moduleID, | 23 self.db = ReAction.db:RegisterNamespace( moduleID, |
| 27 { | 24 { |
| 28 profile = { | 25 profile = { |
| 29 closeOnLaunch = true, | |
| 30 editorCloseOnLaunch = true, | 26 editorCloseOnLaunch = true, |
| 31 } | 27 } |
| 32 } | 28 } |
| 33 ) | 29 ) |
| 34 | 30 |
| 45 if self.editor then | 41 if self.editor then |
| 46 self.editor:Hide() | 42 self.editor:Hide() |
| 47 end | 43 end |
| 48 end | 44 end |
| 49 | 45 |
| 50 function module:OptionShowEditor() | |
| 51 self:LaunchBarEditor() | |
| 52 -- you can't close a dialog in response to an options click, because the end of the | |
| 53 -- handler for all the button events calls lib:Open() | |
| 54 -- So, schedule a close on the next OnUpdate | |
| 55 if self.db.profile.closeOnLaunch then | |
| 56 self.editor.closePending = true | |
| 57 end | |
| 58 end | |
| 59 | |
| 60 function module:OptionGetCloseThis() | |
| 61 return self.db.profile.closeOnLaunch | |
| 62 end | |
| 63 | |
| 64 function module:OptionSetCloseThis(info,val) | |
| 65 self.db.profile.closeOnLaunch = val | |
| 66 end | |
| 67 | 46 |
| 68 | 47 |
| 69 | 48 |
| 70 | 49 |
| 71 | 50 |
| 86 BOTTOMLEFT = L["Bottom Left"], | 65 BOTTOMLEFT = L["Bottom Left"], |
| 87 BOTTOMRIGHT = L["Bottom Right"], | 66 BOTTOMRIGHT = L["Bottom Right"], |
| 88 } | 67 } |
| 89 | 68 |
| 90 | 69 |
| 91 -- use a local GUI container to work around AceConfigDialog closing | |
| 92 -- both the bar editor and the global options when interface options is closed | |
| 93 local editor = LibStub("AceGUI-3.0"):Create("Frame") | 70 local editor = LibStub("AceGUI-3.0"):Create("Frame") |
| 94 local frame = editor.frame | 71 local frame = editor.frame |
| 95 frame:SetClampedToScreen(true) | 72 frame:SetClampedToScreen(true) |
| 96 frame:Hide() | 73 frame:Hide() |
| 97 local old_OnUpdate = frame:GetScript("OnUpdate") | 74 local old_OnUpdate = frame:GetScript("OnUpdate") |
| 98 frame:SetScript("OnUpdate", function(dt) | 75 frame:SetScript("OnUpdate", function(dt) |
| 99 if old_OnUpdate then | 76 if old_OnUpdate then |
| 100 old_OnUpdate(dt) | 77 old_OnUpdate(dt) |
| 101 end | 78 end |
| 102 if editor.closePending then | |
| 103 InterfaceOptionsFrame:Hide() | |
| 104 editor.closePending = false | |
| 105 end | |
| 106 if editor.selfClosePending then | 79 if editor.selfClosePending then |
| 107 editor:Hide() | 80 editor:Hide() |
| 108 AceConfigReg:NotifyChange(configName) | |
| 109 editor.selfClosePending = false | 81 editor.selfClosePending = false |
| 110 end | 82 end |
| 111 end ) | 83 end ) |
| 112 editor:SetCallback("OnClose", | 84 editor:SetCallback("OnClose", |
| 113 function() | 85 function() |
