File choir.lua changed (mode: 100644) (index 148f441..4a4413b) |
... |
... |
local function healthBarUpdateProcessor(self, elapsedDurationSec) |
300 |
300 |
self.idleDurationSec = idleDurationSec - elapsedDurationSec |
self.idleDurationSec = idleDurationSec - elapsedDurationSec |
301 |
301 |
else |
else |
302 |
302 |
self.idleDurationSec = math.abs(updateFrequencyPerSecond) |
self.idleDurationSec = math.abs(updateFrequencyPerSecond) |
|
303 |
|
|
303 |
304 |
healthBarUpdateOverlay(self, self.overlay, self:GetAttribute('unit')) |
healthBarUpdateOverlay(self, self.overlay, self:GetAttribute('unit')) |
304 |
305 |
end |
end |
305 |
306 |
end |
end |
|
... |
... |
local function createClearcastingSubset(unitButton, targetFilter) |
577 |
578 |
columnQuantity, rowQuantity) |
columnQuantity, rowQuantity) |
578 |
579 |
end |
end |
579 |
580 |
|
|
|
581 |
|
--[[-- |
|
582 |
|
Populate given menuFrame with menu buttons. |
|
583 |
|
|
|
584 |
|
The menu buttons that will be added to the given contextual menu |
|
585 |
|
are those that were defined by the baseline game client |
|
586 |
|
for the TargetFrameDropDown, PlayerFrameDropDown and others, |
|
587 |
|
declared in UnitPopupFrames global variable that is a table. |
|
588 |
|
|
|
589 |
|
There is an important implicit parameter menuFrame.unit. |
|
590 |
|
The property is set in contextualMenuOnShowCallback. |
|
591 |
|
|
|
592 |
|
It is done this way to avoid creating redundant menu frames |
|
593 |
|
for every unit button. Instead, this approach reuses the singleton |
|
594 |
|
menu frame for every of 9*5 menu buttons that the add-on creates. |
|
595 |
|
|
|
596 |
|
@function contenxtualMenuOnClickCallback |
|
597 |
|
@arg menuFrame given menu frame, likely ChoirContextualMenu |
|
598 |
|
]] |
|
599 |
|
local function contextualMenuOnClickCallback(menuFrame) |
|
600 |
|
assert (menuFrame ~= nil) |
|
601 |
|
--[[ See https://github.com/Ennie/wow-ui-source/blob/master/FrameXML/UnitPopup.lua ]]-- |
|
602 |
|
--[[ See https://www.townlong-yak.com/framexml/live/TargetFrame.lua ]]-- |
|
603 |
|
local unitDesignation = menuFrame.unit or 'target' |
|
604 |
|
local menuCategory |
|
605 |
|
local name, id |
|
606 |
|
if UnitIsUnit(unitDesignation, "player") then |
|
607 |
|
menuCategory = "SELF" |
|
608 |
|
elseif UnitIsUnit(unitDesignation, "vehicle") then |
|
609 |
|
menuCategory = "VEHICLE" |
|
610 |
|
elseif UnitIsUnit(unitDesignation, "pet") then |
|
611 |
|
menuCategory = "PET" |
|
612 |
|
elseif UnitIsPlayer(unitDesignation) then |
|
613 |
|
id = UnitInRaid(unitDesignation) |
|
614 |
|
if id then |
|
615 |
|
menuCategory = "RAID_PLAYER" |
|
616 |
|
elseif UnitInParty(unitDesignation) then |
|
617 |
|
menuCategory = "PARTY" |
|
618 |
|
else |
|
619 |
|
if not UnitIsMercenary("player") then |
|
620 |
|
if UnitCanCooperate("player", unitDesignation) then |
|
621 |
|
menuCategory = "PLAYER"; |
|
622 |
|
else |
|
623 |
|
menuCategory = "ENEMY_PLAYER" |
|
624 |
|
end |
|
625 |
|
else |
|
626 |
|
if UnitCanAttack("player", unitDesignation) then |
|
627 |
|
menuCategory = "ENEMY_PLAYER" |
|
628 |
|
else |
|
629 |
|
menuCategory = "PLAYER"; |
|
630 |
|
end |
|
631 |
|
end |
|
632 |
|
end |
|
633 |
|
else |
|
634 |
|
menuCategory = "TARGET" |
|
635 |
|
name = RAID_TARGET_ICON |
|
636 |
|
end |
|
637 |
|
assert (UnitPopupMenus[menuCategory] ~= nil) |
|
638 |
|
UnitPopup_ShowMenu(menuFrame, menuCategory, unitDesignation, name, id) |
|
639 |
|
end |
|
640 |
|
|
|
641 |
|
local function createContextualMenu() |
|
642 |
|
--[[ See https://wowwiki-archive.fandom.com/wiki/UI_Object_UIDropDownMenu ]]-- |
|
643 |
|
local menuFrame = CreateFrame('FRAME', 'ChoirContextualMenu', ChoirFrame, 'UIDropDownMenuTemplate') |
|
644 |
|
assert (menuFrame ~= nil) |
|
645 |
|
UIDropDownMenu_Initialize(menuFrame, contextualMenuOnClickCallback, 'MENU') |
|
646 |
|
|
|
647 |
|
return menuFrame |
|
648 |
|
end |
|
649 |
|
|
|
650 |
|
local function contextualMenuOnShowCallback(targetFrame, unitDesignation, mouseButtonDesignation) |
|
651 |
|
assert (targetFrame ~= nil) |
|
652 |
|
assert (unitDesignation ~= nil) |
|
653 |
|
if mouseButtonDesignation ~= 'RightButton' then |
|
654 |
|
return |
|
655 |
|
end |
|
656 |
|
local menuFrame = ChoirContextualMenu |
|
657 |
|
assert (menuFrame ~= nil) |
|
658 |
|
menuFrame.unit = unitDesignation |
|
659 |
|
ToggleDropDownMenu(1, nil, menuFrame, targetFrame:GetName(), 144, 12) |
|
660 |
|
end |
|
661 |
|
|
580 |
662 |
local function createUnitButton(parentFrame, frameName, unit, |
local function createUnitButton(parentFrame, frameName, unit, |
581 |
663 |
someFilterDescriptorFirst, someFilterDescriptorLast, width, height) |
someFilterDescriptorFirst, someFilterDescriptorLast, width, height) |
582 |
664 |
assert (parentFrame ~= nil) |
assert (parentFrame ~= nil) |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit, |
588 |
670 |
createBindingKeyHandler(u) |
createBindingKeyHandler(u) |
589 |
671 |
createInheritanceHandler(u) |
createInheritanceHandler(u) |
590 |
672 |
|
|
591 |
|
u:SetAttribute('type', 'target') |
|
|
673 |
|
u:SetAttribute('type1', 'target') |
592 |
674 |
|
|
593 |
675 |
local padding = 4 |
local padding = 4 |
594 |
676 |
if not width then |
if not width then |
|
... |
... |
local function createUnitButton(parentFrame, frameName, unit, |
608 |
690 |
|
|
609 |
691 |
u:SetAttribute('unit', unit) |
u:SetAttribute('unit', unit) |
610 |
692 |
|
|
|
693 |
|
u:RegisterForClicks('AnyUp') |
|
694 |
|
u:SetAttribute('*type2', 'menu') |
|
695 |
|
SecureUnitButton_OnLoad(u, unit, contextualMenuOnShowCallback); |
|
696 |
|
|
611 |
697 |
local roleWidget = createRoleWidget(u) |
local roleWidget = createRoleWidget(u) |
612 |
698 |
local headerFrame = createHeader(u, width, 24) |
local headerFrame = createHeader(u, width, 24) |
613 |
699 |
local healthBarFrame = createHealthBar(u, width, 24) |
local healthBarFrame = createHealthBar(u, width, 24) |
|
... |
... |
local function createGroup(rootFrame, groupNumber, unitTable) |
882 |
968 |
--[[ Assume that parent is the spoiler frame |
--[[ Assume that parent is the spoiler frame |
883 |
969 |
-- which was created with createSpoiler and |
-- which was created with createSpoiler and |
884 |
970 |
-- has required scripts hooked to it ]]-- |
-- has required scripts hooked to it ]]-- |
885 |
|
local spoilerFrame = self:GetParent() |
|
886 |
|
spoilerFrame:Hide() |
|
|
971 |
|
if 'LeftButton' == button then |
|
972 |
|
local spoilerFrame = self:GetParent() |
|
973 |
|
spoilerFrame:Hide() |
|
974 |
|
end |
887 |
975 |
]=]) |
]=]) |
888 |
976 |
b:Hide() |
b:Hide() |
889 |
977 |
|
|
|
... |
... |
local function initRangeSpellName(rootFrame) |
1282 |
1370 |
return s |
return s |
1283 |
1371 |
end |
end |
1284 |
1372 |
|
|
1285 |
|
local function initSpoiler(rootFrame) |
|
|
1373 |
|
local function initSpoiler(rootFrame, contextualMenu) |
1286 |
1374 |
assert (rootFrame ~= nil) |
assert (rootFrame ~= nil) |
|
1375 |
|
--[[ NOTE Unit buttons require unit contextual menu to be initialized ]]-- |
|
1376 |
|
assert (contextualMenu ~= nil) |
1287 |
1377 |
|
|
1288 |
1378 |
--[[ WARNING All mutually exclusive frames must be placed under the same parent, |
--[[ WARNING All mutually exclusive frames must be placed under the same parent, |
1289 |
1379 |
-- for the spoiler toggling to work correctly. |
-- for the spoiler toggling to work correctly. |
|
... |
... |
local function initSpoiler(rootFrame) |
1316 |
1406 |
return spoilerHolder |
return spoilerHolder |
1317 |
1407 |
end |
end |
1318 |
1408 |
|
|
1319 |
|
local function initRaidFrame(rootFrame, spoilerHolder) |
|
|
1409 |
|
local function initRaidFrame(rootFrame, spoilerHolder, contextualMenu) |
|
1410 |
|
--[[ NOTE Unit buttons require unit contextual menu to be initialized ]]-- |
|
1411 |
|
assert (contextualMenu ~= nil) |
1320 |
1412 |
return createRaidFrame(rootFrame, spoilerHolder) |
return createRaidFrame(rootFrame, spoilerHolder) |
1321 |
1413 |
end |
end |
1322 |
1414 |
|
|
|
... |
... |
local function initConf(rootFrame, raidFrame) |
1771 |
1863 |
return confFrame, bindingKeyFrame |
return confFrame, bindingKeyFrame |
1772 |
1864 |
end |
end |
1773 |
1865 |
|
|
|
1866 |
|
local function initContextualMenu() |
|
1867 |
|
return createContextualMenu() |
|
1868 |
|
end |
|
1869 |
|
|
1774 |
1870 |
local function init(rootFrame) |
local function init(rootFrame) |
1775 |
1871 |
assert (rootFrame ~= nil) |
assert (rootFrame ~= nil) |
1776 |
1872 |
|
|
|
... |
... |
local function init(rootFrame) |
1782 |
1878 |
rootFrame:SetAllPoints() |
rootFrame:SetAllPoints() |
1783 |
1879 |
|
|
1784 |
1880 |
initRangeSpellName(rootFrame) |
initRangeSpellName(rootFrame) |
1785 |
|
local spoilerHolder = initSpoiler(rootFrame) |
|
1786 |
|
local raidFrame = initRaidFrame(rootFrame, spoilerHolder) |
|
|
1881 |
|
local contextualMenu = initContextualMenu() |
|
1882 |
|
local spoilerHolder = initSpoiler(rootFrame, contextualMenu) |
|
1883 |
|
local raidFrame = initRaidFrame(rootFrame, spoilerHolder, contextualMenu) |
1787 |
1884 |
initConf(rootFrame, raidFrame) |
initConf(rootFrame, raidFrame) |
1788 |
1885 |
|
|
1789 |
1886 |
trace('init') |
trace('init') |