Commit 6873aceb authored by Blazeflack's avatar Blazeflack

Copied files from CastBarPowerOverlay, which will be used as a base

parents
package-as: ElvUI_CastBarPowerOverlay
ignore:
- Changelog_Curse.txt
move-folders:
ElvUI_CastBarPowerOverlay/ElvUI_CastBarPowerOverlay: ElvUI_CastBarPowerOverlay
manual-changelog:
filename: Changelog_Curse.txt
markup-type: creole
\ No newline at end of file
**2.37, September 4th 2015**
* [NEW] Added options to overlay the Pet Castbar.
* [NEW] Added option which allows you to overlay on Health instead of Power.
\\ \\
**2.36, July 14th 2015**
* Update ToC for patch 6.2
\\ \\
**2.35, February 25th 2015**
* Update ToC for patch 6.1
\\ \\
**2.34, October 14th 2014**
* Bump toc for patch 6.0.2
\\ \\
**2.33, October 30th 2013**
* [FIX] Fix frame level issues introduced with recent ElvUI changes.
\\ \\
**2.32, September 10th 2013**
* Bump toc for 5.4
\\ \\
**2.31, June 2nd 2013**
* [CHG] Remove plugin header with information about me and my plugins.
\\ \\
**Older Versions**
2.30: Fix error when toggling overlay for Arena or Boss frames. Move all unit code into core and reduce the amount of code by 193 lines (~10KB).
2.29: Update info about other plugins, bump TOC for patch 5.3.
2.28: Information update, locales updated, bump TOC.
2.27: Information update, bump TOC.
2.26: Fix a FrameStrata issue causing the castbar to appear on top of other UI elements.
2.25: Remove LibElvUIPlugin-1.0 library which is now included with ElvUI. Update recommended!
2.24: Update LibElvUIPlugin-1.0 library. Fixes a bug. Updating is recommended!
2.23: Update LibElvUIPlugin-1.0 library.
2.22: Fix compatibility issue with ElvUI_CastBarSnap.
2.21: Config has been rewritten to make use of the new LibElvUIPlugin-1.0 library. Additionally, options to hide or offset castbar text have been added.
2.19: Change post hooks to secure hooks. This change should not be noticeable in any way.
2.18: Small position tweaks, toc bump for 5.1.
2.17: Pixel Perfect tweaks. Try to minimize risk of setting incorrect size or position under some circumstances.
2.16: Fix: Don't touch position or size unless the option is enabled.
2.15: Fix (I think) a bug which causes the castbar to use incorrect sizes when changing spec or going through loading screens.
2.14: Preparation for the new PixelPerfect mode in ElvUI.
2.13: Locale update.
2.12: Disable option to overlay on power bar, if power bar is disabled.
2.11: License included with download.
2.1: Allow CastBarSnap and CastBarPowerOverlay to coexist by disabling CastBarPowerOverlay for the player castbar if both addons are loaded.
2.01: Fix arena config.
2.0: Version to be used with the World of Warcraft Mists of Pandaria Beta.
\ No newline at end of file
## Interface: 60200
## Author: Blazeflack
## Version: 2.37
## Title: |cff1784d1ElvUI|r CastBarPowerOverlay
## Notes: Adds a toggle option to overlay the castbar on the power bar for the respective unit frame.
## RequiredDeps: ElvUI
## OptionalDeps: ElvUI_CastBarSnap
locales.lua
config.lua
core.lua
## X-Tukui-ProjectID: 62
## X-Tukui-ProjectFolders: ElvUI_CastBarPowerOverlay
\ No newline at end of file
ElvUI_CastBarPowerOverlay License
Copyright ©2012-2015
The contents of this addon, excluding third-party resources, are
copyrighted to their authors with all rights reserved.
The author of this addon hereby grants you the following rights:
1. You may make modifications to this addon for private use only, you
must have the authors express written consent to publicize any portion
of this addon.
2. Do not modify the name of this addon, including the addon folders.
3. This copyright notice shall be included in all copies or substantial
portions of the Software.
All rights not explicitly addressed in this license are reserved by
the copyright holders.
\ No newline at end of file
local E, L, V, P, G, _ = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local CBPO = E:NewModule('CastBarPowerOverlay', 'AceTimer-3.0', 'AceEvent-3.0')
local UF = E:GetModule('UnitFrames');
-- Defaults
V['CBPO'] = {
['warned'] = false,
}
P['CBPO'] = {
['player'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
['target'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
['focus'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
['pet'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
['boss'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
['arena'] = {
['overlay'] = true,
["overlayOnFrame"] = "POWER",
['hidetext'] = false,
['xOffsetText'] = 4,
['yOffsetText'] = 0,
['xOffsetTime'] = -4,
['yOffsetTime'] = 0,
},
}
function CBPO:InsertOptions()
if not E.Options.args.blazeplugins then
E.Options.args.blazeplugins = {
order = -2,
type = 'group',
name = 'Plugins (by Blazeflack)',
args = {},
}
end
local function CreateOptionsGroup(order, name, unit, updateFunc)
local group = {
order = order,
type = "group",
name = name,
args = {
info = {
order = 1,
type = 'header',
name = name,
},
overlay = {
order = 2,
type = 'toggle',
name = L['Enable Overlay'],
desc = L['Overlay the castbar on the chosen panel.'],
get = function(info) return E.db.CBPO[unit].overlay end,
set = function(info, value) E.db.CBPO[unit].overlay = value; updateFunc(CBPO, unit) end,
},
overlayOnFrame = {
order = 3,
type = 'select',
name = L['Overlay Panel'],
desc = L['Choose which panel to overlay the castbar on.'],
disabled = function() return not E.db.CBPO[unit].overlay end,
values = {
["POWER"] = L["Power"],
["HEALTH"] = L["Health"],
},
get = function(info) return E.db.CBPO[unit].overlayOnFrame end,
set = function(info, value)
if value == "POWER" and not E.db.unitframe.units[unit].power.enable then
E:StaticPopup_Show('CBPO_PowerDisabled')
value = "HEALTH"
end
E.db.CBPO[unit].overlayOnFrame = value;
updateFunc(CBPO, unit);
end,
},
hidetext = {
order = 4,
type = 'toggle',
name = L['Hide Text'],
desc = L['Hide Castbar text. Useful if your power height is very low or if you use power offset.'],
get = function(info) return E.db.CBPO[unit].hidetext end,
set = function(info, value) E.db.CBPO[unit].hidetext = value; updateFunc(CBPO, unit); end,
disabled = function() return not E.db.CBPO[unit].overlay end,
},
spacer1 = {
order = 5,
type = 'description',
name ='',
},
xOffsetText = {
order = 6,
type = 'range',
name = L['Text xOffset'],
desc = L['Move castbar text to the left or to the right. Default is 4'],
get = function(info) return E.db.CBPO[unit].xOffsetText end,
set = function(info, value) E.db.CBPO[unit].xOffsetText = value; updateFunc(CBPO, unit); end,
min = -100, max = 100, step = 1,
disabled = function() return (not E.db.CBPO[unit].overlay or E.db.CBPO[unit].hidetext) end,
},
yOffsetText = {
order = 7,
type = 'range',
name = L['Text yOffset'],
desc = L['Move castbar text up or down. Default is 0'],
get = function(info) return E.db.CBPO[unit].yOffsetText end,
set = function(info, value) E.db.CBPO[unit].yOffsetText = value; updateFunc(CBPO, unit); end,
min = -50, max = 50, step = 1,
disabled = function() return (not E.db.CBPO[unit].overlay or E.db.CBPO[unit].hidetext) end,
},
spacer2 = {
order = 8,
type = 'description',
name ='',
},
xOffsetTime = {
order = 9,
type = 'range',
name = L['Time xOffset'],
desc = L['Move castbar time to the left or to the right. Default is -4'],
get = function(info) return E.db.CBPO[unit].xOffsetTime end,
set = function(info, value) E.db.CBPO[unit].xOffsetTime = value; updateFunc(CBPO, unit); end,
min = -100, max = 100, step = 1,
disabled = function() return (not E.db.CBPO[unit].overlay or E.db.CBPO[unit].hidetext) end,
},
yOffsetTime = {
order = 10,
type = 'range',
name = L['Time yOffset'],
desc = L['Move castbar time up or down. Default is 0'],
get = function(info) return E.db.CBPO[unit].yOffsetTime end,
set = function(info, value) E.db.CBPO[unit].yOffsetTime = value; updateFunc(CBPO, unit); end,
min = -50, max = 50, step = 1,
disabled = function() return (not E.db.CBPO[unit].overlay or E.db.CBPO[unit].hidetext) end,
},
},
}
return group
end
E.Options.args.blazeplugins.args.CBPO = {
order = 10,
type = 'group',
name = 'CastBarPowerOverlay',
childGroups = 'tab',
disabled = function() return not E.private.unitframe.enable end,
args = {},
}
local options = E.Options.args.blazeplugins.args.CBPO.args
options.player = CreateOptionsGroup(1, L["Player"], "player", CBPO.UpdateSettings)
options.target = CreateOptionsGroup(2, L["Target"], "target", CBPO.UpdateSettings)
options.focus = CreateOptionsGroup(3, L["Focus"], "focus", CBPO.UpdateSettings)
options.pet = CreateOptionsGroup(4, L["Pet"], "pet", CBPO.UpdateSettings)
options.arena = CreateOptionsGroup(5, L["Arena"], "arena", CBPO.UpdateSettings)
options.boss = CreateOptionsGroup(6, L["Boss"], "boss", CBPO.UpdateSettings)
--Disable player overlay if CastBarSnap is enabled
E.Options.args.blazeplugins.args.CBPO.args.player.args.overlay.disabled = function() return IsAddOnLoaded('ElvUI_CastBarSnap') end
end
E:RegisterModule(CBPO:GetName())
\ No newline at end of file
local E, L, V, P, G, _ = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local CBPO = E:GetModule('CastBarPowerOverlay')
local UF = E:GetModule('UnitFrames');
local EP = LibStub('LibElvUIPlugin-1.0')
local addon, ns = ...
local CBS_Enabled = false
-- Create compatibility warning popup
E.PopupDialogs['CBPOCompatibility'] = {
text = L['CBPO_CONFLICT_WARNING'],
button1 = L['I understand'],
OnAccept = function() E.private.CBPO.warned = true end,
timeout = 0,
whileDead = 1,
preferredIndex = 3,
}
-- Warn about trying to overlay on disabled power bar
E.PopupDialogs['CBPO_PowerDisabled'] = {
text = L['CBPO_POWER_DISABLED'],
button1 = L['I understand'],
timeout = 0,
whileDead = 1,
preferredIndex = 3,
}
--Set size of castbar and position on chosen frame
local function SetCastbarSizeAndPosition(unit, unitframe, overlayFrame)
local db = E.db.CBPO[unit];
local cdb = E.db.unitframe.units[unit].castbar;
local castbar = unitframe.Castbar
local frameStrata = db.overlayOnFrame == "HEALTH" and unitframe.RaisedElementParent:GetFrameStrata() or overlayFrame:GetFrameStrata()
local frameLevel = (db.overlayOnFrame == "HEALTH" and unitframe.RaisedElementParent:GetFrameLevel() or overlayFrame:GetFrameLevel()) + 2
--Store original frame strata and level
castbar.origFrameStrata = castbar.origFrameStrata or castbar:GetFrameStrata()
castbar.origFrameLevel = castbar.origFrameLevel or castbar:GetFrameLevel()
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()
-- Set castbar height and width according to chosen overlay panel
cdb.width, cdb.height = overlayWidth, overlayHeight
-- Update internal settings
UF:Configure_Castbar(unitframe, true) --2nd argument is to prevent loop
-- Raise FrameStrata and FrameLevel so castbar stays on top of power bar
-- If offset is used, the castbar will still stay on top of power bar while staying below health bar.
castbar:SetFrameStrata(frameStrata)
castbar:SetFrameLevel(frameLevel)
-- 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)
else
castbar.Holder:ClearAllPoints()
castbar.Holder:SetPoint("TOPLEFT", overlayFrame.backdrop or overlayFrame, "TOPLEFT", -unitframe.SPACING, unitframe.SPACING)
end
castbar.isOverlayed = true
end
--Reset castbar size and position
local function ResetCastbarSizeAndPosition(unit, unitframe)
local cdb = E.db.unitframe.units[unit].castbar;
local castbar = unitframe.Castbar
local mover = castbar.Holder.mover
--Reset size back to default
cdb.width, cdb.height = E.db.unitframe.units[unit].width, P.unitframe.units[unit].castbar.height
-- Reset frame strata and level
castbar:SetFrameStrata(castbar.origFrameStrata)
castbar:SetFrameLevel(castbar.origFrameLevel)
-- Update internal settings
UF:Configure_Castbar(unitframe, true) --2nd argument is to prevent loop
-- Revert castbar position to default
if mover then
local moverName = mover and mover.textString
if moverName ~= "" and moverName ~= nil then
E:ResetMovers(moverName)
end
else
--Boss/Arena frame castbars don't have movers
castbar.Holder:ClearAllPoints()
castbar.Holder:Point("TOPLEFT", unitframe, "BOTTOMLEFT", 0, -(E.Border * 3))
end
castbar.isOverlayed = false
end
--Configure castbar text position and alpha
local function ConfigureText(unit, castbar)
local db = E.db.CBPO[unit]
if db.hidetext then -- Hide
castbar.Text:SetAlpha(0)
castbar.Time:SetAlpha(0)
else -- Show
castbar.Text:SetAlpha(1)
castbar.Time:SetAlpha(1)
end
-- Set position of castbar text according to chosen offsets
castbar.Text:ClearAllPoints()
castbar.Text:SetPoint("LEFT", castbar, "LEFT", db.xOffsetText, db.yOffsetText)
castbar.Time:ClearAllPoints()
castbar.Time:SetPoint("RIGHT", castbar, "RIGHT", db.xOffsetTime, db.yOffsetTime)
end
--Reset castbar text position and alpha
local function ResetText(castbar)
castbar.Text:ClearAllPoints()
castbar.Text:SetPoint("LEFT", castbar, "LEFT", 4, 0)
castbar.Time:ClearAllPoints()
castbar.Time:SetPoint("RIGHT", castbar, "RIGHT", -4, 0)
castbar.Text:SetAlpha(1)
castbar.Time:SetAlpha(1)
end
--Initiate update/reset of castbar
local function ConfigureCastbar(unit, unitframe)
local db = E.db.CBPO[unit];
local cdb = E.db.unitframe.units[unit].castbar;
local castbar = unitframe.Castbar
if db.overlay then
local OverlayFrame = db.overlayOnFrame == "HEALTH" and unitframe.Health or unitframe.Power
SetCastbarSizeAndPosition(unit, unitframe, OverlayFrame)
ConfigureText(unit, castbar)
elseif castbar.isOverlayed then
ResetCastbarSizeAndPosition(unit, unitframe)
ResetText(castbar)
end
end
--Initiate update of unit
function CBPO:UpdateSettings(unit)
local db = E.db.CBPO[unit];
local cdb = E.db.unitframe.units[unit].castbar;
--Check if power is disabled and overlay is set to POWER
if not E.db.unitframe.units[unit].power.enable and (E.db.CBPO[unit].overlay and E.db.CBPO[unit].overlayOnFrame == "POWER") then
E:StaticPopup_Show('CBPO_PowerDisabled', unit)
E.db.CBPO[unit].overlayOnFrame = "HEALTH"
end
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
for i = 1, 5 do
local unitframe = _G["ElvUF_Arena"..i]
ConfigureCastbar(unit, unitframe)
end
elseif unit == 'boss' then
for i = 1, 5 do
local unitframe = _G["ElvUF_Boss"..i]
ConfigureCastbar(unit, unitframe)
end
end
end
-- Function to be called when registered events fire
function CBPO:UpdateAllCastbars()
CBPO:UpdateSettings("player")
CBPO:UpdateSettings("target")
CBPO:UpdateSettings("focus")
CBPO:UpdateSettings("pet")
CBPO:UpdateSettings("arena")
CBPO:UpdateSettings("boss")
end
function CBPO:Initialize()
-- Register callback with LibElvUIPlugin
EP:RegisterPlugin(addon, CBPO.InsertOptions)
--ElvUI UnitFrames are not enabled, stop right here!
if E.private.unitframe.enable ~= true then return end
if IsAddOnLoaded('ElvUI_CastBarSnap') then
CBS_Enabled = true
if not E.private.CBPO.warned then
-- Warn user about CastBarPowerOverlay being disabled for Player CastBar
E:StaticPopup_Show('CBPOCompatibility')
end
E.db.CBPO.player.overlay = false
else
E.private.CBPO.warned = false
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)
end)
--Castbar was modified, re-apply settings
hooksecurefunc(UF, "Configure_Castbar", function(self, frame, preventLoop)
if preventLoop then return; end --I call Configure_Castbar with "true" as 2nd argument
local unit = frame.unitframeType
if unit and E.db.CBPO[unit] and E.db.CBPO[unit].overlay then
CBPO:UpdateSettings(unit)
end
end)
--Health may have changed size, update castbar overlay settings
hooksecurefunc(UF,'Configure_HealthBar', function(self, frame)
local unit = frame.unitframeType
if unit and E.db.CBPO[unit] and E.db.CBPO[unit].overlay and E.db.CBPO[unit].overlayOnFrame == "HEALTH" then
CBPO:UpdateSettings(unit)
end
end)
--Power may have changed size, update castbar overlay settings
hooksecurefunc(UF,'Configure_Power',function(self, frame)
local unit = frame.unitframeType
if unit and E.db.CBPO[unit] and E.db.CBPO[unit].overlay and E.db.CBPO[unit].overlayOnFrame == "POWER" then
CBPO:UpdateSettings(unit)
end
end)
end
\ No newline at end of file
-- English localization file for enUS and enGB.
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "enUS", true);
if not L then return end
L["CBPO_CONFLICT_WARNING"] = "It would appear you have ElvUI_CastBarSnap loaded. CastBarPowerOverlay has been disabled for the Player CastBar."
L["CBPO_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
--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',
end
--Spanish (Spain) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "esES")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
end
--Spanish (Mexico) Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "esMX")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
end
--French Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "frFR")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
end
--Italian Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "itIT")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
end
--Korean Localizations
local L = LibStub("AceLocale-3.0"):NewLocale("ElvUI", "koKR")
if L then
--Add translations here, eg.
-- L[' Alert'] = ' Alert',
end