Mercurial > wow > reaction
comparison classes/Bar.lua @ 156:611e6ce08717
Use state-unitexists for unitwatch
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Mon, 18 May 2009 23:08:34 +0000 |
parents | 806a61b331a0 |
children | e77f716af1b7 |
comparison
equal
deleted
inserted
replaced
155:806a61b331a0 | 156:611e6ce08717 |
---|---|
16 anchorKeys = newtable("point","relPoint","x","y") | 16 anchorKeys = newtable("point","relPoint","x","y") |
17 | 17 |
18 state = nil | 18 state = nil |
19 set_state = nil | 19 set_state = nil |
20 state_override = nil | 20 state_override = nil |
21 unit_exists = nil | |
21 | 22 |
22 showAll = false | 23 showAll = false |
23 hidden = false | 24 hidden = false |
24 | 25 |
25 defaultAlpha = 1.0 | 26 defaultAlpha = 1.0 |
34 local _reaction_refresh = | 35 local _reaction_refresh = |
35 [[ | 36 [[ |
36 local oldState = state | 37 local oldState = state |
37 state = state_override or set_state or state | 38 state = state_override or set_state or state |
38 | 39 |
40 local hide = nil | |
39 if state then | 41 if state then |
40 local settings = settings[state] | 42 local settings = settings[state] |
41 if settings then | 43 if settings then |
42 -- show/hide | 44 -- show/hide |
43 local h = settings.hide and not showAll | 45 hide = settings.hide |
44 if h ~= hidden then | |
45 if h then | |
46 self:Hide() | |
47 else | |
48 self:Show() | |
49 end | |
50 hidden = h | |
51 end | |
52 -- re-anchor | 46 -- re-anchor |
53 local old_anchor = activeStates.anchor | 47 local old_anchor = activeStates.anchor |
54 activeStates.anchor = settings.anchorEnable and state | 48 activeStates.anchor = settings.anchorEnable and state |
55 if old_anchor ~= activeStates.anchor or not set_state then | 49 if old_anchor ~= activeStates.anchor or not set_state then |
56 if activeStates.anchor then | 50 if activeStates.anchor then |
80 self:SetAlpha(activeStates.alpha and settings.alpha or defaultAlpha) | 74 self:SetAlpha(activeStates.alpha and settings.alpha or defaultAlpha) |
81 end | 75 end |
82 end | 76 end |
83 end | 77 end |
84 | 78 |
79 -- hide if state or unit_exists says to | |
80 hide = not showAll and (hide or unithide) | |
81 if hide ~= hidden then | |
82 hidden = hide | |
83 if hide then | |
84 self:Hide() | |
85 else | |
86 self:Show() | |
87 end | |
88 end | |
89 | |
85 for _, attr in pairs(extensions) do | 90 for _, attr in pairs(extensions) do |
86 control:RunAttribute(attr) | 91 control:RunAttribute(attr) |
87 end | 92 end |
88 | 93 |
89 control:ChildUpdate() | 94 control:ChildUpdate() |
108 control:CallMethod("UpdateShowGrid") | 113 control:CallMethod("UpdateShowGrid") |
109 ]] | 114 ]] |
110 | 115 |
111 local _onstate_unitexists = -- function( self, stateid, newstate ) | 116 local _onstate_unitexists = -- function( self, stateid, newstate ) |
112 [[ | 117 [[ |
113 | 118 unithide = not newstate |
114 ]] .. _reaction_refresh | 119 ]] .. _reaction_refresh |
115 | 120 |
116 local _onclick = -- function( self, button, down ) | 121 local _onclick = -- function( self, button, down ) |
117 [[ | 122 [[ |
118 if state_override == button then | 123 if state_override == button then |
341 -- Methods | 346 -- Methods |
342 -- | 347 -- |
343 | 348 |
344 function Bar:SetConfigMode(mode) | 349 function Bar:SetConfigMode(mode) |
345 self:SetSecureData("showAll",mode) | 350 self:SetSecureData("showAll",mode) |
346 self:UpdateUnitWatch() | |
347 self:ShowControls(mode) | 351 self:ShowControls(mode) |
348 for b in self:IterateButtons() do | 352 for b in self:IterateButtons() do |
349 b:ShowGridTemp(mode) | 353 b:ShowGridTemp(mode) |
350 b:UpdateActionIDLabel(mode) | 354 b:UpdateActionIDLabel(mode) |
351 end | 355 end |
352 end | 356 end |
353 | 357 |
354 function Bar:SetKeybindMode(mode) | 358 function Bar:SetKeybindMode(mode) |
355 self:SetSecureData("showAll",mode) | 359 self:SetSecureData("showAll",mode) |
356 self:UpdateUnitWatch() | |
357 for b in self:IterateButtons() do | 360 for b in self:IterateButtons() do |
358 b:SetKeybindMode(mode) | 361 b:SetKeybindMode(mode) |
359 end | 362 end |
360 end | 363 end |
361 | 364 |
436 end | 439 end |
437 | 440 |
438 function Bar:UpdateShowGrid() | 441 function Bar:UpdateShowGrid() |
439 for button in self:IterateButtons() do | 442 for button in self:IterateButtons() do |
440 button:UpdateShowGrid() | 443 button:UpdateShowGrid() |
441 end | |
442 end | |
443 | |
444 function Bar:UpdateUnitWatch() | |
445 if self.unitwatch then | |
446 if self.unitwatchActive and (ReAction:GetConfigMode() or ReAction:GetKeybindMode()) then | |
447 UnregisterUnitWatch(self:GetFrame()) | |
448 self.unitwatchActive = false | |
449 elseif not self.unitwatchActive then | |
450 RegisterUnitWatch(self:GetFrame()) | |
451 self.unitwatchActive = true | |
452 end | |
453 self:RefreshSecureState() | |
454 end | 444 end |
455 end | 445 end |
456 | 446 |
457 function Bar:ShowControls(show) | 447 function Bar:ShowControls(show) |
458 if show then | 448 if show then |
588 function Bar:RegisterUnitWatch( unit, enable ) | 578 function Bar:RegisterUnitWatch( unit, enable ) |
589 local f = self:GetFrame() | 579 local f = self:GetFrame() |
590 if unit then | 580 if unit then |
591 f:SetAttribute("unit",unit) | 581 f:SetAttribute("unit",unit) |
592 end | 582 end |
583 if enable then | |
584 RegisterUnitWatch(self:GetFrame(),true) | |
585 elseif self.unitwatch then | |
586 UnregisterUnitWatch(self:GetFrame()) | |
587 end | |
593 self.unitwatch = enable | 588 self.unitwatch = enable |
594 self:UpdateUnitWatch() | 589 self:RefreshSecureState() |
595 end | 590 end |
596 | 591 |
597 -- set a keybind to push a value into "state-reaction" attribute | 592 -- set a keybind to push a value into "state-reaction" attribute |
598 function Bar:SetStateKeybind( key, state ) | 593 function Bar:SetStateKeybind( key, state ) |
599 local f = self:GetFrame() | 594 local f = self:GetFrame() |