Mercurial > wow > reaction
comparison modules/ReAction_Action/ReAction_Action.lua @ 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 |
comparison
equal
deleted
inserted
replaced
| 91:c2504a8b996c | 92:5f1d7a81317c |
|---|---|
| 12 local ReAction = ReAction | 12 local ReAction = ReAction |
| 13 local L = ReAction.L | 13 local L = ReAction.L |
| 14 local _G = _G | 14 local _G = _G |
| 15 local CreateFrame = CreateFrame | 15 local CreateFrame = CreateFrame |
| 16 local format = string.format | 16 local format = string.format |
| 17 local wipe = wipe | |
| 17 | 18 |
| 18 ReAction:UpdateRevision("$Revision$") | 19 ReAction:UpdateRevision("$Revision$") |
| 19 | 20 |
| 20 -- libraries | 21 -- libraries |
| 21 local KB = LibStub("LibKeyBound-1.0") | 22 local KB = LibStub("LibKeyBound-1.0") |
| 257 | 258 |
| 258 if self.config.buttons == nil then | 259 if self.config.buttons == nil then |
| 259 self.config.buttons = { } | 260 self.config.buttons = { } |
| 260 end | 261 end |
| 261 self:Refresh() | 262 self:Refresh() |
| 263 self:SetKeybindMode(ReAction:GetKeybindMode()) | |
| 262 return self | 264 return self |
| 263 end | 265 end |
| 264 | 266 |
| 265 function Handle:Refresh() | 267 function Handle:Refresh() |
| 266 local r, c = self.bar:GetButtonGrid() | 268 local r, c = self.bar:GetButtonGrid() |
| 322 | 324 |
| 323 function Handle:SetKeybindMode(mode) | 325 function Handle:SetKeybindMode(mode) |
| 324 for _, b in pairs(self.btns) do | 326 for _, b in pairs(self.btns) do |
| 325 if mode then | 327 if mode then |
| 326 -- set the border for all buttons to the keybind-enable color | 328 -- set the border for all buttons to the keybind-enable color |
| 327 local r,g,b,a = KB:GetColorKeyBoundMode() | 329 b.border:SetVertexColor(KB:GetColorKeyBoundMode()) |
| 328 b.border:SetVertexColor(r,g,b,a) | |
| 329 b.border:Show() | 330 b.border:Show() |
| 331 elseif IsEquippedAction(b:GetActionID()) then | |
| 332 b.border:SetVertexColor(0, 1.0, 0, 0.35) -- from ActionButton.lua | |
| 330 else | 333 else |
| 331 b.border:Hide() | 334 b.border:Hide() |
| 332 end | 335 end |
| 333 end | 336 end |
| 334 end | 337 end |
| 561 | 564 |
| 562 ------ State property options ------ | 565 ------ State property options ------ |
| 563 do | 566 do |
| 564 local pageOptions = { | 567 local pageOptions = { |
| 565 page = { | 568 page = { |
| 566 name = L["Show Page #"], | 569 name = L["Show Page #"], |
| 567 order = 11, | 570 order = 11, |
| 568 type = "select", | 571 type = "select", |
| 569 width = "half", | 572 width = "half", |
| 570 disabled = "IsPageDisabled", | 573 disabled = "IsPageDisabled", |
| 571 hidden = "IsPageHidden", | 574 hidden = "IsPageHidden", |
| 572 values = "GetPageValues", | 575 values = "GetPageValues", |
| 573 set = "SetProp", | 576 set = "SetProp", |
| 574 get = "GetPage", | 577 get = "GetPage", |
| 592 function PropHandler:IsPageHidden() | 595 function PropHandler:IsPageHidden() |
| 593 return not GetBarConfig(self.bar) | 596 return not GetBarConfig(self.bar) |
| 594 end | 597 end |
| 595 | 598 |
| 596 function PropHandler:GetPageValues() | 599 function PropHandler:GetPageValues() |
| 600 if not self._pagevalues then | |
| 601 self._pagevalues = { } | |
| 602 end | |
| 597 local c = GetBarConfig(self.bar) | 603 local c = GetBarConfig(self.bar) |
| 598 if c then | 604 if c then |
| 599 local n = c.nPages | 605 local n = c.nPages |
| 606 -- cache the results | |
| 600 if self._npages ~= n then | 607 if self._npages ~= n then |
| 601 self._pagevalues = { } | |
| 602 self._npages = n | 608 self._npages = n |
| 603 -- cache the results | 609 wipe(self._pagevalues) |
| 604 for i = 1, n do | 610 for i = 1, n do |
| 605 self._pagevalues["page"..i] = i | 611 self._pagevalues["page"..i] = i |
| 606 end | 612 end |
| 607 end | 613 end |
| 608 return self._pagevalues | 614 end |
| 609 end | 615 return self._pagevalues |
| 610 end | 616 end |
| 611 | 617 |
| 612 function PropHandler:GetPage(info) | 618 function PropHandler:GetPage(info) |
| 613 return self:GetProp(info) or 1 | 619 return self:GetProp(info) or 1 |
| 614 end | 620 end |
| 807 f.ClearBindings = ClearBindings | 813 f.ClearBindings = ClearBindings |
| 808 f.GetBindings = GetBindings | 814 f.GetBindings = GetBindings |
| 809 buttonLookup[f] = button | 815 buttonLookup[f] = button |
| 810 f:SetKey(button:GetConfig().hotkey) | 816 f:SetKey(button:GetConfig().hotkey) |
| 811 ReAction:RegisterKeybindFrame(f) | 817 ReAction:RegisterKeybindFrame(f) |
| 818 if ReAction:GetKeybindMode() then | |
| 819 button.border:SetVertexColor(KB:GetColorKeyBoundMode()) | |
| 820 button.border:Show() | |
| 821 end | |
| 812 end | 822 end |
| 813 end | 823 end |
| 814 | 824 |
| 815 local meta = {__index = Button} | 825 local meta = {__index = Button} |
| 816 | 826 |
| 864 -- install mind control actions for all buttons just for simplicity | 874 -- install mind control actions for all buttons just for simplicity |
| 865 if self.idx <= 12 then | 875 if self.idx <= 12 then |
| 866 f:SetAttribute("*action-mc", 120 + self.idx) | 876 f:SetAttribute("*action-mc", 120 + self.idx) |
| 867 end | 877 end |
| 868 | 878 |
| 869 -- wrap the OnClick handler to use a pagemap from the header's context | |
| 870 parent:WrapScript(f, "OnClick", | |
| 871 -- function OnClick(self, button, down) | |
| 872 [[ | |
| 873 if doMindControl and GetBonusBarOffset() == 5 then | |
| 874 return "mc" | |
| 875 else | |
| 876 return state and page and page[state] or button | |
| 877 end | |
| 878 ]]) | |
| 879 | |
| 880 -- set a _childupdate handler, called within the header's context | 879 -- set a _childupdate handler, called within the header's context |
| 881 -- SetAttribute() is a brute-force way to trigger ActionButton_UpdateAction(). Setting "*action1" | |
| 882 -- will, in the absence of a useful replacement for SecureButton_GetEffectiveButton(), force | |
| 883 -- ActionButton_CalculateAction() to use the new action-id for display purposes. It also | |
| 884 -- sort of obviates the OnClick handler, but hopefully this is only temporary until | |
| 885 -- SecureButton_GetEffectiveButton() gets fixed. | |
| 886 f:SetAttribute("_childupdate", | 880 f:SetAttribute("_childupdate", |
| 887 -- function _childupdate(self, snippetid, message) | 881 -- function _childupdate(self, snippetid, message) |
| 888 [[ | 882 [[ |
| 889 local action = "action" | 883 local action = "action" |
| 890 if doMindControl and GetBonusBarOffset() == 5 then | 884 if doMindControl and GetBonusBarOffset() == 5 then |
| 891 action = "*action-mc" | 885 action = "*action-mc" |
| 892 elseif page and state and page[state] then | 886 elseif page and state and page[state] then |
| 893 action = "*action-"..page[state] | 887 action = "*action-"..page[state] |
| 894 end | 888 end |
| 895 local value = self:GetAttribute(action) | 889 local value = self:GetAttribute(action) |
| 896 self:SetAttribute("*action1",value) | 890 self:SetAttribute("action",value) |
| 897 ]]) | 891 ]]) |
| 898 | 892 |
| 899 self.frame = f | 893 self.frame = f |
| 900 self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) | 894 self.normalTexture = getglobal(format("%sNormalTexture",f:GetName())) |
| 901 | 895 |
