Mercurial > wow > reaction
changeset 184:1ee86bbb05a0
more options rearranging
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 22 Oct 2010 16:03:04 +0000 |
parents | 1696ff2c80cc |
children | 2e7a322e0195 |
files | Options.lua ReAction.lua locale/enUS.lua modules/ConfigUI.lua |
diffstat | 4 files changed, 181 insertions(+), 174 deletions(-) [+] |
line wrap: on
line diff
--- a/Options.lua Fri Oct 22 15:56:08 2010 +0000 +++ b/Options.lua Fri Oct 22 16:03:04 2010 +0000 @@ -5,145 +5,139 @@ local configID = "ReAction" -local configProfileID = "ReAction_Profile" - -local function SlashHandler(option) - if option == "config" or option == "options" then - ReAction:ShowOptions() - elseif option == "edit" then - ReAction:ShowEditor() - elseif option == "unlock" then - ReAction:SetConfigMode(true) - elseif option == "lock" then - ReAction:SetConfigMode(false) - elseif option == "kb" then - ReAction:SetKeybindMode(true) - else - print(("%3.1f"):format(version)) - print("/rxn config") - print("/rxn edit") - print("/rxn lock") - print("/rxn unlock") - print("/rxn kb") - end -end - - -function ReAction:GetOptions() - if not self.options then - self.options = { - type = "group", - name = "ReAction", - args = { - _desc = { - type = "description", - name = L["Customizable replacement for Blizzard's Action Bars"], - order = 1, - }, - unlock = { - type = "toggle", - name = L["Unlock Bars"], - desc = L["Unlock bars for dragging and resizing with the mouse"], - handler = self, - get = "GetConfigMode", - set = function(info, value) self:SetConfigMode(value) end, - width = "full", - disabled = InCombatLockdown, - order = 2, - }, - hide = { - type = "toggle", - name = L["Hide Blizzard Action Bars"], - desc = L["Hide the default main bar and extra action bars"], - handler = self:GetModule("HideBlizzard"), - get = "IsHidden", - set = "SetHidden", - disabled = "OptionDisabled", - width = "full", - order = 3, - }, - hideVehicle = { - type = "toggle", - name = L["Hide Blizzard Vehicle Bar"], - desc = L["Hide the default vechicle action bar"], - handler = self:GetModule("HideBlizzard"), - get = "IsHidden", - set = "SetHidden", - disabled = "OptionDisabled", - width = "full", - order = 4, - }, - edit = { - type = "execute", - name = L["Edit Bars..."], - desc = L["Show the ReAction Bar Editor dialogue"], - handler = self:GetModule("ConfigUI"), - func = "OptionShowEditor", - order = 5, - }, - _closeThis = { - type = "toggle", - name = L["Close on Launch"], - desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], - handler = self:GetModule("ConfigUI"), - get = "OptionGetCloseThis", - set = "OptionSetCloseThis", - order = 6, - cmdHidden = true, - dropdownHidden = true, - }, - keybind = { - type = "execute", - name = L["Key Bindings"], - desc = L["Show the keybinding dialogue"], - func = function() self:SetKeybindMode(true) end, - order = 7, - }, - skipProfileWarning = { - type = "toggle", - name = L["Skip profile keybind warning"], - desc = L["Don't show a warning about updating keybinds when switching profiles"], - get = function() return ReAction.db.global.skipKeybindWarning end, - set = function(info, value) ReAction.db.global.skipKeybindWarning = value end, - width = "double", - order = 8, - }, - } - } - end - return self.options -end - - -function ReAction:GetProfileOptions() - if not self.profileOptions then - self.profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) - end - return self.profileOptions -end +local displayName = L["ReAction"] function ReAction:InitializeOptions() - local AceConfigReg = LibStub("AceConfigRegistry-3.0") + local AceConfigReg = LibStub("AceConfigRegistry-3.0") local AceConfigDialog = LibStub("AceConfigDialog-3.0") - AceConfigReg:RegisterOptionsTable(configID,ReAction:GetOptions()) - AceConfigReg:RegisterOptionsTable(configProfileID,ReAction:GetProfileOptions()) + local options = { + type = "group", + name = displayName, + handler = self, + args = { + general = { + type = "group", + name = displayName, + args = { + _desc = { + type = "description", + name = L["Customizable replacement for Blizzard's Action Bars"], + order = 1, + }, + unlock = { + type = "toggle", + name = L["Unlock Bars"], + desc = L["Unlock bars for dragging and resizing with the mouse"], + get = "GetConfigMode", + set = "OptionSetConfigMode", + width = "full", + disabled = InCombatLockdown, + order = 2, + }, + hide = { + type = "toggle", + name = L["Hide Blizzard Action Bars"], + desc = L["Hide the default main bar and extra action bars"], + handler = self:GetModule("HideBlizzard"), + get = "IsHidden", + set = "SetHidden", + disabled = "OptionDisabled", + width = "full", + order = 3, + }, + hideVehicle = { + type = "toggle", + name = L["Hide Blizzard Vehicle Bar"], + desc = L["Hide the default vechicle action bar"], + handler = self:GetModule("HideBlizzard"), + get = "IsHidden", + set = "SetHidden", + disabled = "OptionDisabled", + width = "full", + order = 4, + }, + edit = { + type = "execute", + name = L["Edit Bars..."], + desc = L["Show the ReAction Bar Editor dialogue"], + func = "OptionShowEditor", + order = 5, + }, + _closeThis = { + type = "toggle", + name = L["Close on Launch"], + desc = L["Close the Interface Options window when launching the ReAction Bar Editor"], + get = "OptionGetCloseThis", + set = "OptionSetCloseThis", + order = 6, + cmdHidden = true, + dropdownHidden = true, + }, + keybind = { + type = "execute", + name = L["Key Bindings"], + desc = L["Show the keybinding dialogue"], + func = "OptionLaunchKeybindMode", + order = 7, + }, + skipProfileWarning = { + type = "toggle", + name = L["Skip profile keybind warning"], + desc = L["Don't show a warning about updating keybinds when switching profiles"], + get = "OptionGetSkipKeybindWarning", + set = "OptionSetSkipKeybindWarning", + width = "double", + order = 8, + }, + } + }, + profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db), + } + } - self.configFrame = AceConfigDialog:AddToBlizOptions(configID, L["ReAction"]) - self.configProfileFrame = AceConfigDialog:AddToBlizOptions(configProfileID, L["Profiles"], configID) + AceConfigReg:RegisterOptionsTable(configID,options) - self.configFrame.obj:SetCallback("default", - function() - self.db:ResetProfile() - AceConfigReg:NotifyChange(configID) - end ) + local f = AceConfigDialog:AddToBlizOptions(configID, displayName, nil, "general") + + if f and f.obj then + f.obj:SetCallback("default", + function() + self.db:ResetProfile() + AceConfigReg:NotifyChange(configID) + end ) + end + + AceConfigDialog:AddToBlizOptions(configID, options.args.profiles.name, configID, "profiles") self.db.RegisterCallback(self,"OnProfileChanged") self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged") self.db.RegisterCallback(self,"OnProfileCopied","OnProfileChanged") - SlashCmdList["REACTION"] = SlashHandler + SlashCmdList["REACTION"] = function(option) + option = string.match(option or "", "^%s*(%S+)") + if option == "config" or option == "options" then + ReAction:ShowOptions() + elseif option == "edit" then + ReAction:ShowEditor() + elseif option == "unlock" then + ReAction:SetConfigMode(true) + elseif option == "lock" then + ReAction:SetConfigMode(false) + elseif option == "kb" then + ReAction:SetKeybindMode(true) + else + print(("ReAction %3.1f:"):format(ReAction.version)) + print("Usage:") + print("/rxn config") + print("/rxn edit") + print("/rxn lock") + print("/rxn unlock") + print("/rxn kb") + end + end + _G["SLASH_REACTION1"] = "/reaction" _G["SLASH_REACTION2"] = "/rxn" @@ -164,21 +158,56 @@ end -function ReAction:PopKeybindWarning() +function ReAction:OnProfileChanged() + self:RebuildAll() if not self.db.global.skipKeybindWarning then StaticPopup_Show("REACTION_KB_WARN") end end -function ReAction:OnProfileChanged() - self:Disable() - self:Enable() - self:PopKeybindWarning() + +function ReAction:OptionSetConfigMode(info, value) + self:SetConfigMode(value) end +function ReAction:OptionShowEditor() + self:ShowEditor() + if self.db.profile.closeOptionsOnEditorLaunch then + InterfaceOptionsFrame:Hide() + end +end + + +function ReAction:OptionGetCloseThis() + return self.db.profile.closeOptionsOnEditorLaunch +end + + +function ReAction:OptionSetCloseThis(info,val) + self.db.profile.closeOptionsOnEditorLaunch = val +end + + +function ReAction:OptionLaunchKeybindMode() + self:SetKeybindMode(true) +end + + +function ReAction:OptionGetSkipKeybindWarning() + return self.db.global.skipKeybindWarning +end + + +function ReAction:OptionSetSkipKeybindWarning(info, value) + self.db.global.skipKeybindWarning = value +end + + -- export to LDB -LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject( "ReAction", +local LDB = LibStub:GetLibrary("LibDataBroker-1.1") +if LDB then + LDB:NewDataObject( "ReAction", { type = "launcher", icon = "Interface\\Icons\\INV_Qiraj_JewelEncased", @@ -207,5 +236,5 @@ tooltip:AddLine(format("|cff00cccc%s|r %s",L["Alt-click"],L["for keybind mode"])) end, - } -) + }) +end
--- a/ReAction.lua Fri Oct 22 15:56:08 2010 +0000 +++ b/ReAction.lua Fri Oct 22 16:03:04 2010 +0000 @@ -25,20 +25,19 @@ ReAction is also an AceAddon-3.0 and contains an AceDB-3.0, which in turn publish more events. ]]-- - local addonName, addonTable = ... -local version = GetAddOnMetadata(addonName,"Version") local ReAction = LibStub("AceAddon-3.0"):NewAddon( addonName, "AceEvent-3.0" ) +ReAction.version = GetAddOnMetadata(addonName,"Version") addonTable.ReAction = ReAction ------ LIBRARIES ------ local callbacks = LibStub("CallbackHandler-1.0"):New(ReAction) -local KB = LibStub("LibKeyBound-1.0") +local LKB = LibStub("LibKeyBound-1.0") local L = LibStub("AceLocale-3.0"):GetLocale("ReAction") ReAction.L = L -ReAction.KB = KB +ReAction.LKB = LKB ReAction.callbacks = callbacks ------ PRIVATE ------ @@ -134,13 +133,14 @@ { profile = { bars = { }, - defaultBar = { } + defaultBar = { }, + closeOptionsOnEditorLaunch = true, } }, true -- use global 'Default' (locale-specific) ) - KB.RegisterCallback(self,"LIBKEYBOUND_ENABLED") - KB.RegisterCallback(self,"LIBKEYBOUND_DISABLED") + LKB.RegisterCallback(self,"LIBKEYBOUND_ENABLED") + LKB.RegisterCallback(self,"LIBKEYBOUND_DISABLED") self:RegisterEvent("PLAYER_REGEN_DISABLED") @@ -180,6 +180,12 @@ UIErrorsFrame:AddMessage(msg) end +function ReAction:RebuildAll() + TearDownBars() + InitializeBars() +end + + -- usage: -- (1) ReAction:CreateBar(name, [cfgTable]) -- (2) ReAction:CreateBar(name, "barType", [nRows], [nCols], [btnSize], [btnSpacing]) @@ -384,11 +390,11 @@ function ReAction:SetKeybindMode( mode ) if mode ~= private.kbMode then if mode then - KB:Activate() + LKB:Activate() else - KB:Deactivate() + LKB:Deactivate() end - private.kbMode = KB:IsShown() or false + private.kbMode = LKB:IsShown() or false end end
--- a/locale/enUS.lua Fri Oct 22 15:56:08 2010 +0000 +++ b/locale/enUS.lua Fri Oct 22 16:03:04 2010 +0000 @@ -9,6 +9,7 @@ "ReAction config mode disabled during combat.", -- Options.lua +"ReAction", "Customizable replacement for Blizzard's Action Bars", "Unlock Bars", "Unlock bars for dragging and resizing with the mouse", @@ -24,8 +25,6 @@ "Show the keybinding dialogue", "Skip profile keybind warning", "Don't show a warning about updating keybinds when switching profiles", -"ReAction", -"Profiles", "ReAction profile changed: check your keybinds, they may need to be updated.", "OK", "ReAction: can't configure in combat",
--- a/modules/ConfigUI.lua Fri Oct 22 15:56:08 2010 +0000 +++ b/modules/ConfigUI.lua Fri Oct 22 16:03:04 2010 +0000 @@ -12,9 +12,6 @@ local AceConfigReg = LibStub("AceConfigRegistry-3.0") local AceConfigDialog = LibStub("AceConfigDialog-3.0") --- some constants -local configName = "ReAction" - -- module declaration local moduleID = "ConfigUI" local module = ReAction:NewModule( moduleID, @@ -26,7 +23,6 @@ self.db = ReAction.db:RegisterNamespace( moduleID, { profile = { - closeOnLaunch = true, editorCloseOnLaunch = true, } } @@ -47,23 +43,6 @@ end end -function module:OptionShowEditor() - self:LaunchBarEditor() - -- you can't close a dialog in response to an options click, because the end of the - -- handler for all the button events calls lib:Open() - -- So, schedule a close on the next OnUpdate - if self.db.profile.closeOnLaunch then - self.editor.closePending = true - end -end - -function module:OptionGetCloseThis() - return self.db.profile.closeOnLaunch -end - -function module:OptionSetCloseThis(info,val) - self.db.profile.closeOnLaunch = val -end @@ -88,8 +67,6 @@ } - -- use a local GUI container to work around AceConfigDialog closing - -- both the bar editor and the global options when interface options is closed local editor = LibStub("AceGUI-3.0"):Create("Frame") local frame = editor.frame frame:SetClampedToScreen(true) @@ -99,13 +76,8 @@ if old_OnUpdate then old_OnUpdate(dt) end - if editor.closePending then - InterfaceOptionsFrame:Hide() - editor.closePending = false - end if editor.selfClosePending then editor:Hide() - AceConfigReg:NotifyChange(configName) editor.selfClosePending = false end end )