Commit 19529f8e authored by Blazeflack's avatar Blazeflack

Fixed overlay when "Inside Information Panel" is enabled in ElvUI. Added warning about old CBPO.

parent e116ab63
local E, L, V, P, G, _ = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local CBO = E:GetModule('CastBarOverlay')
local UF = E:GetModule('UnitFrames');
local EP = LibStub('LibElvUIPlugin-1.0')
local CBO = E:GetModule("CastBarOverlay")
local UF = E:GetModule("UnitFrames");
local EP = LibStub("LibElvUIPlugin-1.0")
local addon, ns = ...
local CBS_Enabled = false
......@@ -10,19 +10,28 @@ local _G = _G
local C_Timer_After = C_Timer.After
-- Create compatibility warning popup
E.PopupDialogs['CBOCompatibility'] = {
text = L['CBO_CONFLICT_WARNING'],
button1 = L['I understand'],
E.PopupDialogs["CBOCompatibility"] = {
text = L["CBO_CONFLICT_WARNING"],
button1 = L["I understand"],
OnAccept = function() E.private.CBO.warned = true end,
timeout = 0,
whileDead = 1,
preferredIndex = 3,
}
E.PopupDialogs["CBO_CBPOWARNING"] = {
text = L["CBO_CBPOWARNING"],
button1 = L["I understand"],
OnAccept = function() DisableAddOn("ElvUI_CastBarPowerOverlay"); ReloadUI() end,
timeout = 0,
whileDead = 1,
preferredIndex = 3,
}
-- Warn about trying to overlay on disabled power bar
E.PopupDialogs['CBO_PowerDisabled'] = {
text = L['CBO_POWER_DISABLED'],
button1 = L['I understand'],
E.PopupDialogs["CBO_PowerDisabled"] = {
text = L["CBO_POWER_DISABLED"],
button1 = L["I understand"],
timeout = 0,
whileDead = 1,
preferredIndex = 3,
......@@ -41,9 +50,8 @@ local function SetCastbarSizeAndPosition(unit, unitframe, overlayFrame)
castbar.origFrameStrata = castbar.origFrameStrata or castbar:GetFrameStrata()
castbar.origFrameLevel = castbar.origFrameLevel or castbar:GetFrameLevel()
-- if unit == "player" then print(overlayFrame.backdrop:GetWidth()) end
local overlayWidth = overlayFrame.backdrop and (overlayFrame.backdrop:GetWidth() + (E.Spacing * 2)) or overlayFrame:GetWidth()
local overlayHeight = overlayFrame.backdrop and (overlayFrame.backdrop:GetHeight() + (E.Spacing * 2)) or overlayFrame:GetHeight()
local overlayWidth = overlayFrame:GetWidth()
local overlayHeight = overlayFrame:GetHeight()
-- Set castbar height and width according to chosen overlay panel
cdb.width, cdb.height = overlayWidth, overlayHeight
......@@ -56,13 +64,25 @@ local function SetCastbarSizeAndPosition(unit, unitframe, overlayFrame)
castbar:SetFrameStrata(frameStrata)
castbar:SetFrameLevel(frameLevel)
--Adjust size of castbar icon
castbar.Icon.bg:Size(overlayHeight + unitframe.BORDER*2)
-- Position the castbar on overLayFrame
if castbar.Holder.mover then
castbar.Holder.mover:ClearAllPoints()
castbar.Holder.mover:SetPoint("TOPLEFT", overlayFrame.backdrop or overlayFrame, "TOPLEFT", -unitframe.SPACING, unitframe.SPACING)
if (not cdb.iconAttached) then
castbar:SetInside(overlayFrame, 0, 0)
else
castbar.Holder:ClearAllPoints()
castbar.Holder:SetPoint("TOPLEFT", overlayFrame.backdrop or overlayFrame, "TOPLEFT", -unitframe.SPACING, unitframe.SPACING)
local iconWidth = cdb.icon and (castbar.Icon.bg:GetWidth() - unitframe.BORDER) or 0
if(unitframe.ORIENTATION == "LEFT") then
castbar:SetPoint("TOPLEFT", overlayFrame, "TOPLEFT", iconWidth + unitframe.SPACING*3, 0)
castbar:SetPoint("BOTTOMRIGHT", overlayFrame, "BOTTOMRIGHT")
else
castbar:SetPoint("TOPLEFT", overlayFrame, "TOPLEFT")
castbar:SetPoint("BOTTOMRIGHT", overlayFrame, "BOTTOMRIGHT", -iconWidth - unitframe.SPACING*3, 0)
end
end
if(castbar.Holder.mover) then
E:DisableMover(castbar.Holder.mover:GetName())
end
castbar.isOverlayed = true
......@@ -90,6 +110,7 @@ local function ResetCastbarSizeAndPosition(unit, unitframe)
if moverName ~= "" and moverName ~= nil then
E:ResetMovers(moverName)
end
E:EnableMover(mover:GetName())
else
--Boss/Arena frame castbars don't have movers
castbar.Holder:ClearAllPoints()
......@@ -151,20 +172,20 @@ function CBO:UpdateSettings(unit)
--Check if power is disabled and overlay is set to POWER
if not E.db.unitframe.units[unit].power.enable and (E.db.CBO[unit].overlay and E.db.CBO[unit].overlayOnFrame == "POWER") then
E:StaticPopup_Show('CBO_PowerDisabled', unit)
E:StaticPopup_Show("CBO_PowerDisabled", unit)
E.db.CBO[unit].overlayOnFrame = "HEALTH"
end
if (unit == 'player' and not CBS_Enabled) or unit == 'target' or unit == 'focus' or unit == "pet" then
if (unit == "player" and not CBS_Enabled) or unit == "target" or unit == "focus" or unit == "pet" then
local unitFrameName = "ElvUF_"..E:StringTitle(unit)
local unitframe = _G[unitFrameName]
ConfigureCastbar(unit, unitframe)
elseif unit == 'arena' then
elseif unit == "arena" then
for i = 1, 5 do
local unitframe = _G["ElvUF_Arena"..i]
ConfigureCastbar(unit, unitframe)
end
elseif unit == 'boss' then
elseif unit == "boss" then
for i = 1, 5 do
local unitframe = _G["ElvUF_Boss"..i]
ConfigureCastbar(unit, unitframe)
......@@ -189,21 +210,26 @@ function CBO:Initialize()
--ElvUI UnitFrames are not enabled, stop right here!
if E.private.unitframe.enable ~= true then return end
if IsAddOnLoaded('ElvUI_CastBarSnap') then
if IsAddOnLoaded("ElvUI_CastBarSnap") then
CBS_Enabled = true
if not E.private.CBO.warned then
-- Warn user about CastBarPowerOverlay being disabled for Player CastBar
E:StaticPopup_Show('CBOCompatibility')
E:StaticPopup_Show("CBOCompatibility")
end
E.db.CBO.player.overlay = false
else
E.private.CBO.warned = false
end
--Check if the old CastBarPowerOverlay is enabled
if IsAddOnLoaded("ElvUI_CastBarPowerOverlay") then
E:StaticPopup_Show("CBO_CBPOWARNING")
end
--Profile changed, update castbar overlay settings
hooksecurefunc(E, "UpdateAll", function()
--Delay it a bit to allow all db changes to take effect before we update
self:ScheduleTimer('UpdateAllCastbars', 0.5)
self:ScheduleTimer("UpdateAllCastbars", 0.5)
end)
--Castbar was modified, re-apply settings
......@@ -216,7 +242,7 @@ function CBO:Initialize()
end)
--Health may have changed size, update castbar overlay settings
hooksecurefunc(UF,'Configure_HealthBar', function(self, frame)
hooksecurefunc(UF,"Configure_HealthBar", function(self, frame)
local unit = frame.unitframeType
if unit and E.db.CBO[unit] and E.db.CBO[unit].overlay and E.db.CBO[unit].overlayOnFrame == "HEALTH" then
CBO:UpdateSettings(unit)
......@@ -224,7 +250,7 @@ function CBO:Initialize()
end)
--Power may have changed size, update castbar overlay settings
hooksecurefunc(UF,'Configure_Power',function(self, frame)
hooksecurefunc(UF,"Configure_Power",function(self, frame)
local unit = frame.unitframeType
if unit and E.db.CBO[unit] and E.db.CBO[unit].overlay and E.db.CBO[unit].overlayOnFrame == "POWER" then
CBO:UpdateSettings(unit)
......
......@@ -2,98 +2,89 @@
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "enUS", true);
if not L then return end
L["CBO_CBPOWARNING"] = "You still have the outdated addon 'CastBarPowerOverlay' enabled. It will now be disabled. You should uninstall it when possible."
L["CBO_CONFLICT_WARNING"] = "It would appear you have ElvUI_CastBarSnap loaded. CastBarPowerOverlay has been disabled for the Player CastBar."
L["CBO_POWER_DISABLED"] = "The %s power frame is disabled. Setting castbar overlay to health instead."
L["I understand"] = true
L['Arena'] = true
L['Boss'] = true
L['Choose which panel to overlay the castbar on.'] = true;
L['Enable Overlay'] = true;
L['Focus'] = true
L['Hide Castbar text. Useful if your power height is very low or if you use power offset.'] = true
L['Hide Text'] = true
L['Move castbar text to the left or to the right. Default is 4'] = true
L['Move castbar text up or down. Default is 0'] = true
L['Move castbar time to the left or to the right. Default is -4'] = true
L['Move castbar time up or down. Default is 0'] = true
L['Overlay Panel'] = true;
L['Overlay the castbar on the chosen panel.'] = true;
L['Player'] = true
L['Target'] = true
L['Text xOffset'] = true
L['Text yOffset'] = true
L['Time xOffset'] = true
L['Time yOffset'] = true
L["Arena"] = true
L["Boss"] = true
L["Choose which panel to overlay the castbar on."] = true;
L["Enable Overlay"] = true;
L["Focus"] = true
L["Hide Castbar text. Useful if your power height is very low or if you use power offset."] = true
L["Hide Text"] = true
L["Move castbar text to the left or to the right. Default is 4"] = true
L["Move castbar text up or down. Default is 0"] = true
L["Move castbar time to the left or to the right. Default is -4"] = true
L["Move castbar time up or down. Default is 0"] = true
L["Overlay Panel"] = true;
L["Overlay the castbar on the chosen panel."] = true;
L["Player"] = true
L["Target"] = true
L["Text xOffset"] = true
L["Text yOffset"] = true
L["Time xOffset"] = true
L["Time yOffset"] = true
--We don't need the rest if we're on enUS or enGB locale, so stop here.
--We don"t need the rest if we"re on enUS or enGB locale, so stop here.
if GetLocale() == "enUS" then return end
--German Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "deDE")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Spanish (Spain) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "esES")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Spanish (Mexico) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "esMX")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--French Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "frFR")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Italian Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "itIT")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Korean Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "koKR")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Portuguese Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "ptBR")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Russian Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "ruRU")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Chinese (China, simplified) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "zhCN")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
--Chinese (Taiwan, traditional) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "zhTW")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
--Add translations here
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment