Skip to content

Commit

Permalink
possess bar and maybe mouseover targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Feb 23, 2022
1 parent 87ba537 commit fa943fb
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Dominos/Dominos.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ end
function Addon:GetDatabaseDefaults()
return {
profile = {
possessBar = 1,
possessBar = self:IsBuild('retail') and 1 or "pet",
-- if true, applies a default dominos skin to buttons
-- when masque is not enabled
applyButtonTheme = true,
Expand All @@ -193,7 +193,7 @@ function Addon:GetDatabaseDefaults()
showEquippedItemBorders = true,
showTooltips = true,
showTooltipsCombat = true,
useOverrideUI = not self:IsBuild('classic'),
useOverrideUI = self:IsBuild('retail'),

minimap = {hide = false},

Expand Down Expand Up @@ -585,7 +585,7 @@ function Addon:SetUseOverrideUI(enable)
end

function Addon:UsingOverrideUI()
return self.db.profile.useOverrideUI and not self:IsBuild('classic')
return self.db.profile.useOverrideUI and self:IsBuild('retail')
end

function Addon:UpdateUseOverrideUI()
Expand Down
5 changes: 5 additions & 0 deletions Dominos/Dominos.toc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ core\frame.lua
core\buttonBar.lua
core\bindableButton.lua
core\fadeManager.lua
#@version-retail@
core\overrideController.lua
#@end-version-retail@
#@version-bcc@
core\overrideController.bcc.lua
#@end-version-bcc@
core\tooltipController.lua
# builtin bars
bars\actionButtonMixin.lua
Expand Down
36 changes: 31 additions & 5 deletions Dominos/bars/actionBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ end)
ActionBar:Extend('OnAcquire', function(self)
self:LoadStateController()
self:UpdateStateDriver()
self:SetRightClickUnit(Addon:GetRightClickUnit())
self:SetUnit(self:GetUnit())
self:SetRightClickUnit(self:GetRightClickUnit())
self:UpdateGrid()
self:UpdateTransparent(true)
self:UpdateFlyoutDirection()
Expand All @@ -87,7 +88,9 @@ function ActionBar:GetDefaults()
spacing = 4,
padW = 2,
padH = 2,
numButtons = self:MaxLength()
numButtons = self:MaxLength(),
unit = "none",
rightClickUnit = "none"
}
end

Expand Down Expand Up @@ -144,7 +147,6 @@ function ActionBar:GetOffset(stateId)
return self.pages[stateId]
end


function ActionBar:UpdateStateDriver()
local conditions

Expand Down Expand Up @@ -251,6 +253,22 @@ function ActionBar:KEYBOUND_DISABLED()
end

-- right click targeting support
function ActionBar:SetUnit(unit)
unit = unit or 'none'

if unit == 'none' then
self:SetAttribute('*unit*', nil)
else
self:SetAttribute('*unit*', unit)
end

self.sets.unit = unit
end

function ActionBar:GetUnit()
return self.sets.unit or 'none'
end

function ActionBar:SetRightClickUnit(unit)
unit = unit or 'none'

Expand All @@ -259,13 +277,21 @@ function ActionBar:SetRightClickUnit(unit)
else
self:SetAttribute('*unit2', unit)
end

self.sets.rightClickUnit = unit
end

function ActionBar:GetRightClickUnit()
return self:SetAttribute('*unit2') or 'none'
local unit = self.sets.rightClickUnit

if unit ~= "none" then
return unit
end

return Addon:GetRightClickUnit() or "none"
end

function ActionBar:OnSetAlpha(alpha)
function ActionBar:OnSetAlpha(_alpha)
self:UpdateTransparent()
end

Expand Down
15 changes: 14 additions & 1 deletion Dominos/bars/petBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ function PetBar:GetDisplayName()
return L.PetBarDisplayName
end

function PetBar:IsOverrideBar()
-- TODO: make overrideBar a property of the bar itself instead of a global
-- setting
return Addon.db.profile.possessBar == self.id
end

function PetBar:UpdateOverrideBar()
self:UpdateDisplayConditions()
end

if Addon:IsBuild('bcc', 'classic') then
function PetBar:GetDisplayConditions()
return '[pet]show;hide'
if self:IsOverrideBar() then
return '[@pet,exists][bonusbar:5]show;hide'
end
return '[@pet,exists,nobonusbar:5]show;hide'
end
else
function PetBar:GetDisplayConditions()
Expand Down
59 changes: 59 additions & 0 deletions Dominos/core/overrideController.bcc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
local _, Addon = ...
local OverrideController = Addon:CreateHiddenFrame('Frame', nil, UIParent, 'SecureHandlerStateTemplate')

function OverrideController:OnLoad()
self:SetAttribute('_onstate-possess', [[
self:RunAttribute('updateOverridePage')
]])

self:SetAttribute('updateOverridePage', [[
local newPage = GetBonusBarOffset() or 0
self:SetAttribute('state-overridepage', newPage)
]])

self:Execute([[ myFrames = table.new() ]])

RegisterStateDriver(self, 'possess', '[bonusbar:5]1;0')

self.OnLoad = nil
end

function OverrideController:Add(frame)
self:SetFrameRef('FrameToRegister', frame)

self:Execute([[
local frame = self:GetFrameRef('FrameToRegister')
table.insert(myFrames, frame)
]])

-- OnLoad states
frame:SetAttribute('state-overridepage', self:GetAttribute('state-overridepage') or 0)
end

function OverrideController:Remove(frame)
self:SetFrameRef('FrameToUnregister', frame)

self:Execute([[
local frameToUnregister = self:GetFrameRef('FrameToUnregister')
for i, frame in pairs(myFrames) do
if frame == frameToUnregister then
table.remove(myFrames, i)
break
end
end
]])
end

-- returns true if the player is in a state where they should be using actions
-- normally found on the override bar
function OverrideController:OverrideBarActive()
return (self:GetAttribute('state-overridepage') or 0) > 10
end

OverrideController:OnLoad()

-- exports
Addon.OverrideController = OverrideController
6 changes: 5 additions & 1 deletion Dominos_Config/options/general.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Addon:AddOptionsPanel(
player = L.RCUPlayer,
focus = L.RCUFocus,
targettarget = L.RCUToT,
none = L.None
none = DEFAULT
},
get = function()
return ParentAddon:GetRightClickUnit() or "none"
Expand Down Expand Up @@ -90,6 +90,10 @@ Addon:AddOptionsPanel(
tinsert(items, L.ActionBarNumber:format(i))
end

if ParentAddon:IsBuild("bcc", "classic") then
items.pet = ParentAddon.Frame:Get("pet"):GetDisplayName()
end

return items
end,
get = function()
Expand Down

0 comments on commit fa943fb

Please sign in to comment.