Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
fixed issue when some addons caused issue with xp and reputation bar offset.
added method for update position.
added vehicle bar check for buttons.
removed offset axis from API.
  • Loading branch information
s0h2x committed Oct 30, 2022
1 parent 2959fbd commit a654756
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 103 deletions.
89 changes: 59 additions & 30 deletions modules/mainbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local pairs = pairs;
local ipairs = ipairs;
local format = string.format;
local UIParent = UIParent;
local hooksecurefunc = hooksecurefunc;
local UnitFactionGroup = UnitFactionGroup;
local _G = getfenv(0);

Expand All @@ -26,8 +27,8 @@ local pUiMainBarArt = CreateFrame(
'pUiMainBarArt',
pUiMainBar
);
pUiMainBar:SetScale(config.mainbars.scale_actionbar)
pUiMainBarArt:SetFrameStrata('DIALOG');
pUiMainBar:SetScale(config.mainbars.scale_actionbar);
pUiMainBarArt:SetFrameStrata('HIGH');
pUiMainBarArt:SetFrameLevel(pUiMainBar:GetFrameLevel() + 4);
pUiMainBarArt:SetAllPoints(pUiMainBar);

Expand Down Expand Up @@ -117,7 +118,7 @@ function MainMenuBarMixin:actionbar_setup()
end
MultiBarBottomLeft:SetParent(pUiMainBar)
MultiBarBottomRight:SetParent(pUiMainBar)
MultiBarBottomRight:EnableMouse(false) -- top middle
MultiBarBottomRight:EnableMouse(false)
MultiBarBottomRight:SetClearPoint('BOTTOMLEFT', MultiBarBottomLeftButton1, 'TOPLEFT', 0, 8)
MultiBarRight:SetClearPoint('TOPRIGHT', UIParent, 'RIGHT', -6, (Minimap:GetHeight() * 1.3))
MultiBarRight:SetScale(config.mainbars.scale_rightbar)
Expand Down Expand Up @@ -205,38 +206,66 @@ end,
'UPDATE_EXHAUSTION'
);

do
local both = config.xprepbar.bothbar_offset;
local single = config.xprepbar.singlebar_offset;
local nobar = config.xprepbar.nobar_offset;
local abovexp = config.xprepbar.repbar_abovexp_offset;
local default = config.xprepbar.repbar_offset;
local offset_axis_update = {
ReputationWatchBar, MainMenuExpBar,_,both,_,single,_,single,_,nobar
};
local both = config.xprepbar.bothbar_offset;
local single = config.xprepbar.singlebar_offset;
local nobar = config.xprepbar.nobar_offset;
local abovexp = config.xprepbar.repbar_abovexp_offset;
local default = config.xprepbar.repbar_offset;

hooksecurefunc('ReputationWatchBar_Update',function()
local name = GetWatchedFactionInfo();
if name then
ReputationWatchBar:SetClearPoint('BOTTOM', UIParent, 0, MainMenuExpBar:IsShown() and abovexp or default);
ReputationWatchBarOverlayFrame:SetClearPoint('BOTTOM', UIParent, 0, MainMenuExpBar:IsShown() and abovexp or default);
ReputationWatchStatusBar:SetHeight(10)
ReputationWatchStatusBar:SetClearPoint('TOPLEFT', ReputationWatchBar, 0, 3)
ReputationWatchStatusBarText:SetClearPoint('CENTER', ReputationWatchStatusBar, 'CENTER', 0, old and 0 or 1);
ReputationWatchStatusBarBackground:SetAllPoints(ReputationWatchStatusBar)
end
end)
hooksecurefunc('ReputationWatchBar_Update',function()
local name = GetWatchedFactionInfo();
if name then
ReputationWatchBar:SetClearPoint('BOTTOM', UIParent, 0, MainMenuExpBar:IsShown() and abovexp or default);
ReputationWatchBarOverlayFrame:SetClearPoint('BOTTOM', UIParent, 0, MainMenuExpBar:IsShown() and abovexp or default);
ReputationWatchStatusBar:SetHeight(10)
ReputationWatchStatusBar:SetClearPoint('TOPLEFT', ReputationWatchBar, 0, 3)
ReputationWatchStatusBarText:SetClearPoint('CENTER', ReputationWatchStatusBar, 'CENTER', 0, old and 0 or 1);
ReputationWatchStatusBarBackground:SetAllPoints(ReputationWatchStatusBar)
end
end)

for _,bar in pairs({ReputationWatchBar,MainMenuExpBar}) do
bar:HookScript('OnShow',function()
pUiMainBar:set_offset_axis(unpack(offset_axis_update))
end)
bar:HookScript('OnHide',function()
pUiMainBar:set_offset_axis(unpack(offset_axis_update))
end)
-- method update position
function pUiMainBar:actionbar_update()
local xpbar = MainMenuExpBar:IsShown();
local repbar = ReputationWatchBar:IsShown();
if not InCombatLockdown() and not UnitAffectingCombat('player') then
if xpbar and repbar then
self:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, both);
elseif xpbar then
self:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, single);
elseif repbar then
self:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, single);
else
self:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, nobar);
end
end
end

event:RegisterEvents(function()
pUiMainBar:actionbar_update();
end,
'PLAYER_LOGIN','ADDON_LOADED'
);

for _,bar in pairs({MainMenuExpBar,ReputationWatchBar}) do
if notRequired then return; end
if InCombatLockdown() and UnitAffectingCombat('player') then return; end

local yOffset = select(5, pUiMainBar:GetPoint());
if (yOffset == nobar) then notRequired = true; end

bar:HookScript('OnShow',function()
if (yOffset ~= nobar) then
pUiMainBar:actionbar_update();
end
end);
bar:HookScript('OnHide',function()
if (yOffset ~= nobar) then
pUiMainBar:actionbar_update();
end
end);
end;

function MainMenuBarMixin:initialize()
self:actionbutton_setup();
self:actionbar_setup();
Expand Down
62 changes: 42 additions & 20 deletions modules/petbar.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local addon = select(2,...);
local config = addon.config;
local event = addon.package;
local class = addon._class;
local pUiMainBar = addon.pUiMainBar;
local unpack = unpack;
Expand All @@ -16,35 +17,56 @@ local hooksecurefunc = hooksecurefunc;

-- @param: config number
local offsetX = config.additional.pet.x_position;
local offsetY = config.additional.y_position;
local nobar = config.additional.y_position;
local exOffs = config.additional.leftbar_offset;
local exOffs2 = config.additional.rightbar_offset;
local leftOffset, rightOffset = offsetY + exOffs, offsetY + exOffs2;
local offset_axis_update = {
MultiBarBottomLeft,
MultiBarBottomRight,
offsetX,
leftOffset,
offsetX,
rightOffset,
offsetX,
leftOffset,
offsetX,
offsetY
};
local leftOffset, rightOffset = nobar + exOffs, nobar + exOffs2;

local anchor = CreateFrame('Frame', 'pUiPetBarHolder', UIParent)
anchor:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, offsetY)
anchor:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, nobar)
anchor:SetSize(37, 37)

-- method update position
function anchor:petbar_update()
local leftbar = MultiBarBottomLeft:IsShown();
local rightbar = MultiBarBottomRight:IsShown();
if not InCombatLockdown() and not UnitAffectingCombat('player') then
if leftbar and rightbar then
self:SetPoint('TOPLEFT', pUiMainBar,'TOPLEFT', offsetX, leftOffset);
elseif leftbar then
self:SetPoint("TOPLEFT", pUiMainBar,'TOPLEFT', offsetX, rightOffset);
elseif rightbar then
self:SetPoint("TOPLEFT", pUiMainBar,'TOPLEFT', offsetX, leftOffset);
else
self:SetPoint("TOPLEFT", pUiMainBar,'TOPLEFT', offsetX, nobar);
end
end
end

event:RegisterEvents(function()
anchor:petbar_update();
end,
'PLAYER_LOGIN','ADDON_LOADED'
);

for _,bar in pairs({MultiBarBottomLeft,MultiBarBottomRight}) do
if notRequired then return; end
if InCombatLockdown() and UnitAffectingCombat('player') then return; end

local yOffset = select(5, anchor:GetPoint());
if (yOffset == nobar) then notRequired = true end

bar:HookScript('OnShow',function()
anchor:set_offset_axis(unpack(offset_axis_update))
end)
if (yOffset ~= nobar) then
anchor:petbar_update();
end
end);
bar:HookScript('OnHide',function()
anchor:set_offset_axis(unpack(offset_axis_update))
end)
end
if (yOffset ~= nobar) then
anchor:petbar_update();
end
end);
end;

local petbar = CreateFrame('Frame', 'pUiPetBar', UIParent, 'SecureHandlerStateTemplate')
petbar:SetAllPoints(anchor)
Expand Down
68 changes: 46 additions & 22 deletions modules/stance.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local addon = select(2,...);
local config = addon.config;
local event = addon.package;
local class = addon._class;
local pUiMainBar = addon.pUiMainBar;
local unpack = unpack;
Expand All @@ -15,6 +16,8 @@ local GetShapeshiftFormCooldown = GetShapeshiftFormCooldown;
local CreateFrame = CreateFrame;
local UIParent = UIParent;
local hooksecurefunc = hooksecurefunc;
local UnitAffectingCombat = UnitAffectingCombat;

local stance = {
['DEATHKNIGHT'] = 'show',
['DRUID'] = 'show',
Expand All @@ -27,35 +30,56 @@ local stance = {

-- @param: config number
local offsetX = config.additional.stance.x_position;
local offsetY = config.additional.y_position;
local nobar = config.additional.y_position;
local exOffs = config.additional.leftbar_offset;
local exOffs2 = config.additional.rightbar_offset;
local leftOffset, rightOffset = offsetY + exOffs, offsetY + exOffs2;
local offset_axis_update = {
MultiBarBottomLeft,
MultiBarBottomRight,
offsetX,
leftOffset,
offsetX,
rightOffset,
offsetX,
leftOffset,
offsetX,
offsetY
};
local leftOffset, rightOffset = nobar + exOffs, nobar + exOffs2;

local anchor = CreateFrame('Frame', 'pUiStanceHolder', pUiMainBar)
anchor:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, offsetY)
anchor:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, nobar)
anchor:SetSize(37, 37)

-- method update position
function anchor:stancebar_update()
local leftbar = MultiBarBottomLeft:IsShown();
local rightbar = MultiBarBottomRight:IsShown();
if not InCombatLockdown() and not UnitAffectingCombat('player') then
if leftbar and rightbar then
self:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, leftOffset);
elseif leftbar then
self:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, rightOffset);
elseif rightbar then
self:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, leftOffset);
else
self:SetPoint('TOPLEFT', pUiMainBar, 'TOPLEFT', offsetX, nobar);
end
end
end

event:RegisterEvents(function()
anchor:stancebar_update();
end,
'PLAYER_LOGIN','ADDON_LOADED'
);

for _,bar in pairs({MultiBarBottomLeft,MultiBarBottomRight}) do
if notRequired then return; end
if InCombatLockdown() and UnitAffectingCombat('player') then return; end

local yOffset = select(5, anchor:GetPoint());
if (yOffset == nobar) then notRequired = true end

bar:HookScript('OnShow',function()
anchor:set_offset_axis(unpack(offset_axis_update))
end)
if (yOffset ~= nobar) then
anchor:stancebar_update();
end
end);
bar:HookScript('OnHide',function()
anchor:set_offset_axis(unpack(offset_axis_update))
end)
end
if (yOffset ~= nobar) then
anchor:stancebar_update();
end
end);
end;

local stancebar = CreateFrame('Frame', 'pUiStanceBar', anchor, 'SecureHandlerStateTemplate')
stancebar:SetAllPoints(anchor)
Expand Down Expand Up @@ -153,8 +177,8 @@ local function OnEvent(self,event,...)
end
end

stancebar:RegisterEvent('PLAYER_LOGIN')
stancebar:RegisterEvent('PLAYER_ENTERING_WORLD')
stancebar:RegisterEvent('PLAYER_LOGIN');
stancebar:RegisterEvent('PLAYER_ENTERING_WORLD');
stancebar:RegisterEvent('UPDATE_SHAPESHIFT_FORMS');
stancebar:RegisterEvent('UPDATE_SHAPESHIFT_USABLE');
stancebar:RegisterEvent('UPDATE_SHAPESHIFT_COOLDOWN');
Expand Down
23 changes: 13 additions & 10 deletions modules/vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,19 @@ end

local function vehiclebutton_position()
local button
for index=1, VEHICLE_MAX_ACTIONBUTTONS do
button = _G['VehicleMenuBarActionButton'..index]
button:ClearAllPoints()
button:SetParent(pUiVehicleBar)
button:SetSize(52, 52)
if index == 1 then
button:SetPoint('BOTTOMLEFT', pUiVehicleBar, 'BOTTOMRIGHT', -594, 21)
else
local previous = _G['VehicleMenuBarActionButton'..index-1]
button:SetPoint('LEFT', previous, 'RIGHT', 6, 0)
if pUiVehicleBar:IsShown() or mixin2template:IsShown() then
for index=1, VEHICLE_MAX_ACTIONBUTTONS do
button = _G['VehicleMenuBarActionButton'..index]
button:ClearAllPoints()
button:SetParent(pUiVehicleBar)
button:SetSize(52, 52)
button:Show()
if index == 1 then
button:SetPoint('BOTTOMLEFT', pUiVehicleBar, 'BOTTOMRIGHT', -594, 21)
else
local previous = _G['VehicleMenuBarActionButton'..index-1]
button:SetPoint('LEFT', previous, 'RIGHT', 6, 0)
end
end
end
end
Expand Down
21 changes: 0 additions & 21 deletions utils/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,6 @@ addon.functions.SetNumPagesButton = function(self, parent, direct, yOffset)
self:GetHighlightTexture():set_atlas('ui-hud-actionbar-'..direct..'-highlight', true)
end

addon.functions.get_offset = function(self, xOffset, yOffset)
local point, relto, relpoint, x, y = self:GetPoint()
xOffset = xOffset or x
yOffset = yOffset or y
self:SetClearPoint(point, relto, relpoint, xOffset, yOffset)
end

addon.api.set_offset_axis = function(self, frame1, frame2, x, y, x1, y1, x2, y2, x3, y3)
local offset = addon.functions.get_offset
if InCombatLockdown() and UnitAffectingCombat('player') then return end
if frame1:IsShown() and frame2:IsShown() then
offset(self, x, y)
elseif frame1:IsShown() then
offset(self, x1, y1)
elseif frame2:IsShown() then
offset(self, x2, y2)
else
offset(self, x3, y3)
end
end

addon.functions.inject_api = function(object)
local mt = getmetatable(object).__index
for API,FUNCTIONS in pairs(addon.api) do
Expand Down

0 comments on commit a654756

Please sign in to comment.