Mercurial > wow > reaction
comparison MultiCastButton.lua @ 282:7a9e82c0df15
Show empty totem buttons in config mode when character doesn't have totems
| author | Flick |
|---|---|
| date | Wed, 11 May 2011 17:21:04 -0700 |
| parents | 4e325f1ea6e1 |
| children | 276165a0e860 |
comparison
equal
deleted
inserted
replaced
| 281:2098dba4baf5 | 282:7a9e82c0df15 |
|---|---|
| 323 | 323 |
| 324 ReAction.Button.MultiCast = MultiCast | 324 ReAction.Button.MultiCast = MultiCast |
| 325 ReAction:RegisterBarType(MultiCast) | 325 ReAction:RegisterBarType(MultiCast) |
| 326 | 326 |
| 327 function MultiCast:New( btnConfig, bar, idx ) | 327 function MultiCast:New( btnConfig, bar, idx ) |
| 328 local maxIndex = bar.nTotemSlots or 0 | 328 if idx < 1 or idx > NUM_MULTI_CAST_BUTTONS_PER_PAGE + 2 then |
| 329 if bar.summonSlot then | 329 ReAction:UserError(L["All %s buttons are in use for this bar, cannot create any more buttons"]:format(self.barType)) |
| 330 maxIndex = maxIndex + 1 | 330 error(nil) |
| 331 end | |
| 332 if bar.recallSlot then | |
| 333 maxIndex = maxIndex + 1 | |
| 334 end | |
| 335 | |
| 336 if not bar.hasMulticast or idx > maxIndex then | |
| 337 return false | |
| 338 end | |
| 339 | |
| 340 if idx < 1 then | |
| 341 error("invalid index") | |
| 342 end | 331 end |
| 343 | 332 |
| 344 self = Super.New(self, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) | 333 self = Super.New(self, btnConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) |
| 334 | |
| 335 if not bar.hasMulticast or idx > bar.maxIndex then | |
| 336 -- Not enough multicast capability to use this button | |
| 337 self:Refresh() | |
| 338 return self | |
| 339 end | |
| 345 | 340 |
| 346 local barFrame = bar:GetFrame() | 341 local barFrame = bar:GetFrame() |
| 347 local f = self:GetFrame() | 342 local f = self:GetFrame() |
| 348 | 343 |
| 349 -- attributes | 344 -- attributes |
| 447 end | 442 end |
| 448 | 443 |
| 449 function MultiCast:Refresh() | 444 function MultiCast:Refresh() |
| 450 Super.Refresh(self) | 445 Super.Refresh(self) |
| 451 self:UpdateAction() | 446 self:UpdateAction() |
| 447 | |
| 448 local bar = self.bar | |
| 449 if bar.hasMulticast == true and self.idx <= bar.maxIndex or ReAction:GetConfigMode() then | |
| 450 self:GetFrame():Show() | |
| 451 else | |
| 452 self:GetFrame():Hide() | |
| 453 end | |
| 452 end | 454 end |
| 453 | 455 |
| 454 function MultiCast:ShowGrid( show ) | 456 function MultiCast:ShowGrid( show ) |
| 455 end | 457 end |
| 456 | 458 |
| 609 frame.icon:SetTexCoord(0,1,0,1) | 611 frame.icon:SetTexCoord(0,1,0,1) |
| 610 end | 612 end |
| 611 end | 613 end |
| 612 | 614 |
| 613 function MultiCast:SetupBar( bar ) | 615 function MultiCast:SetupBar( bar ) |
| 614 Super.SetupBar(self,bar) | |
| 615 | |
| 616 local slot = 0 | 616 local slot = 0 |
| 617 local nTotemSlots = 0 | 617 local nTotemSlots = 0 |
| 618 local summonSlot = nil | 618 local summonSlot = nil |
| 619 local recallSlot = nil | 619 local recallSlot = nil |
| 620 | 620 |
| 639 if spell and IsSpellKnown(spell) then | 639 if spell and IsSpellKnown(spell) then |
| 640 recallSlot = slot | 640 recallSlot = slot |
| 641 end | 641 end |
| 642 end | 642 end |
| 643 | 643 |
| 644 if nTotemSlots == 0 then | 644 local maxIndex = nTotemSlots |
| 645 bar.hasMulticast = false -- no multicast capability | 645 if summonSlot then |
| 646 return | 646 maxIndex = maxIndex + 1 |
| 647 end | 647 end |
| 648 | 648 if recallSlot then |
| 649 bar.hasMulticast = true | 649 maxIndex = maxIndex + 1 |
| 650 end | |
| 651 | |
| 652 bar.hasMulticast = nTotemSlots > 0 | |
| 650 bar.summonSlot = summonSlot | 653 bar.summonSlot = summonSlot |
| 651 bar.recallSlot = recallSlot | 654 bar.recallSlot = recallSlot |
| 652 bar.nTotemSlots = nTotemSlots | 655 bar.nTotemSlots = nTotemSlots |
| 653 | 656 bar.maxIndex = maxIndex |
| 657 | |
| 658 if bar.hasMulticast == false then | |
| 659 Super.SetupBar(self,bar) | |
| 660 return -- no multicast capability | |
| 661 end | |
| 654 | 662 |
| 655 local f = bar:GetFrame() | 663 local f = bar:GetFrame() |
| 656 | 664 |
| 657 -- init bar secure environment | 665 -- init bar secure environment |
| 658 f:SetAttribute("lastSummon", bar:GetConfig().lastSummon) | 666 f:SetAttribute("lastSummon", bar:GetConfig().lastSummon) |
| 769 end | 777 end |
| 770 end) | 778 end) |
| 771 f.events_registered = true | 779 f.events_registered = true |
| 772 end | 780 end |
| 773 | 781 |
| 774 | |
| 775 f:Execute(_bar_init) | 782 f:Execute(_bar_init) |
| 776 end | 783 |
| 777 | 784 Super.SetupBar(self,bar) -- create buttons after this is done |
| 785 end | |
| 786 |
