Mercurial > wow > reaction
changeset 92:5f1d7a81317c
- Various bugfixes
- Switched action bar paging/mc fully to the _childupdate method
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 17 Oct 2008 22:43:57 +0000 |
parents | c2504a8b996c |
children | 567a885cdfad |
files | Overlay.lua ReAction.lua State.lua modules/ReAction_Action/ReAction_Action.lua modules/ReAction_ConfigUI/ReAction_ConfigUI.lua |
diffstat | 5 files changed, 106 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/Overlay.lua Fri Oct 17 03:59:55 2008 +0000 +++ b/Overlay.lua Fri Oct 17 22:43:57 2008 +0000 @@ -16,6 +16,8 @@ local SetButtonGrid = Bar.SetButtonGrid local ApplyAnchor = Bar.ApplyAnchor +local KB = LibStub("LibKeyBound-1.0") + ReAction:UpdateRevision("$Revision$") -- @@ -29,7 +31,9 @@ local function StoreExtents(bar) local f = bar:GetFrame() - SetAnchor( bar, f:GetPoint(1) ) + local p, fr, rp, x, y = f:GetPoint(1) + fr = fr or UIParent + SetAnchor( bar, p, fr, rp, x, y ) SetSize( bar, f:GetWidth(), f:GetHeight() ) end @@ -267,6 +271,12 @@ local function GetClosestPointSnapped(f1, rx, ry, xOff, yOff) local o, p, rp, x, y = GetClosestVisiblePoint(f1) local s = false + + local insideOffsetFunc = p and insidePointOffsetFuncs[p] + local coordFunc = p and pointCoordFuncs[p] + if not insideOffsetFunc or not coordFunc then + return + end local sx, sy = insidePointOffsetFuncs[p](xOff or 0, yOff or 0) local xx, yy = pointCoordFuncs[p](f1) @@ -353,35 +363,33 @@ f:SetMovable(true) f:SetResizable(true) - f:SetClampedToScreen(true) - local control = CreateFrame("Button", nil, f) - control:EnableMouse(true) - control:SetToplevel(true) - control:SetPoint("TOPLEFT", -4, 4) - control:SetPoint("BOTTOMRIGHT", 4, -4) - control:SetBackdrop({ + local overlay = CreateFrame("Button", nil, f) + overlay:EnableMouse(true) + overlay:SetFrameLevel(3) -- set it above the buttons + overlay:SetPoint("TOPLEFT", -4, 4) + overlay:SetPoint("BOTTOMRIGHT", 4, -4) + overlay:SetBackdrop({ edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }, }) - control:SetClampedToScreen(true) -- textures - local bgTex = control:CreateTexture(nil,"BACKGROUND") + local bgTex = overlay:CreateTexture(nil,"BACKGROUND") bgTex:SetTexture(0.7,0.7,1.0,0.2) bgTex:SetPoint("TOPLEFT",4,-4) bgTex:SetPoint("BOTTOMRIGHT",-4,4) - local hTex = control:CreateTexture(nil,"HIGHLIGHT") + local hTex = overlay:CreateTexture(nil,"HIGHLIGHT") hTex:SetTexture(0.7,0.7,1.0,0.2) hTex:SetPoint("TOPLEFT",4,-4) hTex:SetPoint("BOTTOMRIGHT",-4,4) hTex:SetBlendMode("ADD") -- label - local label = control:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") + local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") label:SetAllPoints() label:SetJustifyH("CENTER") label:SetShadowColor(0,0,0,1) @@ -403,7 +411,7 @@ -- edge drag handles for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do - local edge = CreateFrame("Frame",nil,control) + local edge = CreateFrame("Frame",nil,overlay) edge:EnableMouse(true) edge:SetWidth(8) edge:SetHeight(8) @@ -445,7 +453,7 @@ end -- corner drag handles, nested in an anonymous frame so that they are on top - local foo = CreateFrame("Frame",nil,control) + local foo = CreateFrame("Frame",nil,overlay) foo:SetAllPoints(true) for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do local corner = CreateFrame("Frame",nil,foo) @@ -513,10 +521,10 @@ end - control:RegisterForDrag("LeftButton") - control:RegisterForClicks("RightButtonUp") + overlay:RegisterForDrag("LeftButton") + overlay:RegisterForClicks("RightButtonUp") - control:SetScript("OnDragStart", + overlay:SetScript("OnDragStart", function() f:StartMoving() f.isMoving = true @@ -545,7 +553,7 @@ GameTooltip:Show() end - control:SetScript("OnDragStop", + overlay:SetScript("OnDragStop", function() f:StopMovingOrSizing() f.isMoving = false @@ -567,7 +575,7 @@ end ) - control:SetScript("OnEnter", + overlay:SetScript("OnEnter", function() -- TODO: add bar type and status information to name --[[ @@ -584,36 +592,51 @@ end ) - control:SetScript("OnLeave", HideGameTooltip) + overlay:SetScript("OnLeave", HideGameTooltip) - control:SetScript("OnClick", + overlay:SetScript("OnClick", function() ReAction:ShowEditor(bar) end ) - control:Raise() + function overlay:LIBKEYBOUND_ENABLED(evt) + self:SetFrameLevel(1) + end - return control + function overlay:LIBKEYBOUND_DISABLED(evt) + self:SetFrameLevel(3) + end + + KB.RegisterCallback(overlay,"LIBKEYBOUND_ENABLED") + KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED") + + if ReAction:GetKeybindMode() then + self:SetFrameLevel(1) + end + + return overlay end -- export methods to the Bar prototype function Bar:ShowControls(show) + local f = self.controlFrame if show then - if not self.controlFrame then - self.controlFrame = CreateControls(self) + if not f then + f = CreateControls(self) + self.controlFrame = f end - self.controlFrame:Show() - self.controlFrame:Raise() - elseif self.controlFrame then - self.controlFrame:Hide() + f:Show() + elseif f then + f:Hide() end end function Bar:SetLabel(name) - if self.controlLabelString then - self.controlLabelString:SetText(self.name) + local label = self.controlLabelString + if label then + label:SetText(self.name) end end
--- a/ReAction.lua Fri Oct 17 03:59:55 2008 +0000 +++ b/ReAction.lua Fri Oct 17 22:43:57 2008 +0000 @@ -107,13 +107,19 @@ } ReAction.options = options -local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, CallModuleMethod, SlashHandler +local SelectBar, DestroyBar, InitializeBars, TearDownBars, DeepCopy, CallModuleMethod, SlashHandler, KBAttach do local pcall = pcall local geterrorhandler = geterrorhandler local self = ReAction local inited = false + local function kb_onEnter( self ) + if ReAction:GetKeybindMode() then + KB:Set(self) + end + end + function SelectBar(x) local bar, name if type(x) == "string" then @@ -214,6 +220,16 @@ self:Print("/rxn kb") end end + + function KBAttach( frame ) + if not private.kbHooked[frame] then + -- avoid taint, particularly with SecureAnchorEnterTemplate + -- don't hook scripts multiple times, there isn't any unhook! + frame:HookScript("OnEnter",kb_onEnter) + private.kbHooked[frame] = true + end + end + end @@ -487,26 +503,11 @@ CallModuleMethod("ConfigUI","LaunchBarEditor",bar, ...) end - -local kb_onEnter -do - function kb_onEnter( self ) - if ReAction:GetKeybindMode() then - KB:Set(self) - end - end -end - function ReAction:SetKeybindMode( mode ) if mode ~= private.kbMode then if mode then for f in pairs(private.allKB) do - if not private.kbHooked[f] then - -- avoid taint, particularly with SecureAnchorEnterTemplate - -- don't hook scripts multiple times, there isn't any unhook! - f:HookScript("OnEnter",kb_onEnter) - private.kbHooked[f] = true - end + KBAttach(f) end KB:Activate() else @@ -522,6 +523,9 @@ function ReAction:RegisterKeybindFrame( f ) private.allKB[f] = true + if private.kbMode then + KBAttach(f) + end end function ReAction:FreeOverrideHotkey( key )
--- a/State.lua Fri Oct 17 03:59:55 2008 +0000 +++ b/State.lua Fri Oct 17 22:43:57 2008 +0000 @@ -88,6 +88,9 @@ scale = true, } + local weak = { __mode = "k" } + local statedrivers = setmetatable( { }, weak ) + local keybinds = setmetatable( { }, weak ) -- -- Secure Handler Snippets @@ -144,10 +147,6 @@ end ]] .. onStateHandler - local weak = { __mode = "k" } - local statedrivers = setmetatable( { }, weak ) - local keybinds = setmetatable( { }, weak ) - -- Construct a lua assignment as a code string and execute it within the header -- frame's sandbox. 'value' must be a string, boolean, number, or nil. If called -- with four arguments, then it treats 'varname' as an existing global table and @@ -415,8 +414,10 @@ end function ShowAll( bar, show ) - SetHandlerData(bar, "showAll", show) - RefreshState(bar) + if statedrivers[bar] then + SetHandlerData(bar, "showAll", show) + RefreshState(bar) + end end end
--- a/modules/ReAction_Action/ReAction_Action.lua Fri Oct 17 03:59:55 2008 +0000 +++ b/modules/ReAction_Action/ReAction_Action.lua Fri Oct 17 22:43:57 2008 +0000 @@ -14,6 +14,7 @@ local _G = _G local CreateFrame = CreateFrame local format = string.format +local wipe = wipe ReAction:UpdateRevision("$Revision$") @@ -259,6 +260,7 @@ self.config.buttons = { } end self:Refresh() + self:SetKeybindMode(ReAction:GetKeybindMode()) return self end @@ -324,9 +326,10 @@ for _, b in pairs(self.btns) do if mode then -- set the border for all buttons to the keybind-enable color - local r,g,b,a = KB:GetColorKeyBoundMode() - b.border:SetVertexColor(r,g,b,a) + b.border:SetVertexColor(KB:GetColorKeyBoundMode()) b.border:Show() + elseif IsEquippedAction(b:GetActionID()) then + b.border:SetVertexColor(0, 1.0, 0, 0.35) -- from ActionButton.lua else b.border:Hide() end @@ -563,10 +566,10 @@ do local pageOptions = { page = { - name = L["Show Page #"], - order = 11, - type = "select", - width = "half", + name = L["Show Page #"], + order = 11, + type = "select", + width = "half", disabled = "IsPageDisabled", hidden = "IsPageHidden", values = "GetPageValues", @@ -594,19 +597,22 @@ end function PropHandler:GetPageValues() + if not self._pagevalues then + self._pagevalues = { } + end local c = GetBarConfig(self.bar) if c then local n = c.nPages + -- cache the results if self._npages ~= n then - self._pagevalues = { } self._npages = n - -- cache the results + wipe(self._pagevalues) for i = 1, n do self._pagevalues["page"..i] = i end end - return self._pagevalues end + return self._pagevalues end function PropHandler:GetPage(info) @@ -809,6 +815,10 @@ buttonLookup[f] = button f:SetKey(button:GetConfig().hotkey) ReAction:RegisterKeybindFrame(f) + if ReAction:GetKeybindMode() then + button.border:SetVertexColor(KB:GetColorKeyBoundMode()) + button.border:Show() + end end end @@ -866,23 +876,7 @@ f:SetAttribute("*action-mc", 120 + self.idx) end - -- wrap the OnClick handler to use a pagemap from the header's context - parent:WrapScript(f, "OnClick", - -- function OnClick(self, button, down) - [[ - if doMindControl and GetBonusBarOffset() == 5 then - return "mc" - else - return state and page and page[state] or button - end - ]]) - -- set a _childupdate handler, called within the header's context - -- SetAttribute() is a brute-force way to trigger ActionButton_UpdateAction(). Setting "*action1" - -- will, in the absence of a useful replacement for SecureButton_GetEffectiveButton(), force - -- ActionButton_CalculateAction() to use the new action-id for display purposes. It also - -- sort of obviates the OnClick handler, but hopefully this is only temporary until - -- SecureButton_GetEffectiveButton() gets fixed. f:SetAttribute("_childupdate", -- function _childupdate(self, snippetid, message) [[ @@ -893,7 +887,7 @@ action = "*action-"..page[state] end local value = self:GetAttribute(action) - self:SetAttribute("*action1",value) + self:SetAttribute("action",value) ]]) self.frame = f
--- a/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua Fri Oct 17 03:59:55 2008 +0000 +++ b/modules/ReAction_ConfigUI/ReAction_ConfigUI.lua Fri Oct 17 22:43:57 2008 +0000 @@ -128,6 +128,7 @@ local editor = LibStub("AceGUI-3.0"):Create("Frame") local frame = editor.frame frame:SetClampedToScreen(true) + frame:Hide() local old_OnUpdate = frame:GetScript("OnUpdate") frame:SetScript("OnUpdate", function(dt) if old_OnUpdate then @@ -295,10 +296,12 @@ AceConfigReg:RegisterOptionsTable(editorName, options) function editor:Open(bar, ...) + if not frame:IsVisible() then + AceConfigDialog:Open(editorName,self) + end if bar then AceConfigDialog:SelectGroup(editorName, barOptMap[bar:GetName()], ...) end - AceConfigDialog:Open(editorName,self) end function editor:Refresh()