WoWInterface SVN mRunes

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

mRunes/accid.ttf Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
mRunes/HalD.tga Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes : Added: svn:mime-type + application/octet-stream
mRunes/Modules/Runes.lua New file
0,0 → 1,480
local _, class = UnitClass("player")
if class ~= "DEATHKNIGHT" then
return
end
 
local plugin = mRunes:NewModule("Runes", "AceEvent-3.0")
plugin.mRunesPlugin = true
 
local AceGUI = LibStub("AceGUI-3.0")
local LSM = LibStub("LibSharedMedia-3.0")
local BD = LibStub("LibBackdrop-1.0")
local FA = LibStub("LibFrameAnchorRegistry-1.0")
local UIF
local db
 
-- Rune Types
local RUNETYPE_BLOOD = 1;
local RUNETYPE_UNHOLY = 2;
local RUNETYPE_FROST = 3;
local RUNETYPE_DEATH = 4;
 
local NrRunes = 6
local InCombat = false
local RuneOnCD = true
local ConfigMode = false
 
local backdrop = {
tile = true,
tileSize = 16,
insets = {},
}
 
plugin.DisplayName = "Runes"
plugin.DisplayIcon = [[Interface\Icons\INV_Glyph_MajorDeathKnight]]
plugin.DisplayOrder = 1
 
function plugin:OnInitialize()
local defaults = {
profile = {
Enabled = true,
HideBlizz = true,
 
Attached = {
f = "mRunesCenter",
x = 0,
y = 0,
Point = "CENTER",
RelPoint = "CENTER",
},
 
 
InternalSpacing = 2,
FrameColor = {0, 0, 0, 0.5},
 
RuneSpacing = 1.12,
Width = 330,
Height = 22,
 
RuneTexture = "HalD",
 
RuneAlphaInCombat = 1,
RuneAlphaOutCombat = 0.2,
RuneAlphaActive = 0.5,
 
RuneCooldownInset = 2,
RuneCooldownAlwaysShow = false,
RuneCooldownShow = true,
RuneCooldownHorAlign = "LEFT",
 
Font = "accid",
FontSize = 16,
FontFlags = "OUTLINE",
FontColor = {1, 1, 1, 1},
 
BorderTexture = "None",
BorderWidth = 5,
BorderInsets = 0,
BorderPadding = 2,
BorderColor = {0, 0, 0, 1},
 
RuneColors = {
[RUNETYPE_BLOOD] = {1.0, 0.0, 0.0, 1},
[RUNETYPE_UNHOLY] ={0.0, 0.8, 0.0, 1},
[RUNETYPE_FROST] = {0.0, 1.0, 1.0, 1},
[RUNETYPE_DEATH] = {0.8, 0.1, 1.0, 1},
}
}
}
 
self.db = mRunes.db:RegisterNamespace(self:GetName(), defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "ProfileChanged")
db = self.db.profile
 
self:SetEnabledState(db.Enabled)
 
UIF = LibStub("LibGUIFactory-1.0"):GetFactory("mRunes")
 
if not mRuneFrame then
self:CreateFuneFrame()
end
end
 
function plugin:OnEnable()
self:ApplySettings()
self.Frame:Show()
 
self:RegisterEvent("RUNE_TYPE_UPDATE", "RuneTypeUpdate")
self:RegisterEvent("RUNE_POWER_UPDATE", "RuneStateChange")
self:RegisterEvent("PLAYER_ENTERING_WORLD", "EnterWorld")
 
mRunes.RegisterCallback(self, "EnteringCombat")
mRunes.RegisterCallback(self, "LeavingCombat")
mRunes.RegisterCallback(self, "ToggleConfigMode")
 
FA.RegisterCallback(self, "FrameRegistered", "ApplySettings")
 
if UnitAffectingCombat("player") then
self:EnteringCombat("EnteringCombat")
else
self:LeavingCombat("LeavingCombat")
end
 
end
 
function plugin:OnDisable()
self.Frame:Hide()
end
 
function plugin:ProfileChanged()
db = self.db.profile
self:ApplySettings()
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Callbacks ~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:EnteringCombat(event)
mRunes.FadeIn(self.Frame, false, db.RuneAlphaInCombat)
InCombat = true
RuneOnCD = false
end
 
function plugin:LeavingCombat(event)
mRunes.FadeOut(self.Frame, db.RuneAlphaOutCombat)
InCombat = false
end
 
function plugin:EnterWorld(...)
if self.Runes then
for i, rune in pairs(self.Runes) do
rune.Update = true
self:RuneTypeUpdate("RUNE_TYPE_UPDATE", i)
end
end
end
 
function plugin:ToggleConfigMode(event, enable)
if enable then
self.Frame.ConfigText:Show()
mRunes.FadeIn(self.Frame, false, 1)
else
self.Frame.ConfigText:Hide()
if InCombat then
mRunes.FadeIn(self.Frame, true, db.RuneAlphaInCombat)
elseif RuneOnCD then
mRunes.FadeIn(self.Frame, true, db.RuneAlphaActive)
else
mRunes.FadeIn(self.Frame, true, db.RuneAlphaOutCombat)
end
end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Events ~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
 
local Update
 
-- Rune type changed (unholy runes)
function plugin:RuneTypeUpdate(event, runeID)
self.Runes[runeID]:SetStatusBarColor(unpack(db.RuneColors[GetRuneType(runeID)]))
end
 
-- Rune Ready/Not Ready event
function plugin:RuneStateChange(event, runeID, ready)
if runeID == 8 or runeID == 7 then return end
 
if ready then
self.Runes[runeID]:SetValue(1)
self.Runes[runeID].Update = nil
self.Runes[runeID].CDText:SetText(("%.1f"):format(0))
if not db.RuneCooldownAlwaysShow then
self.Runes[runeID].CDText:Hide()
end
else
self.Runes[runeID].Update = not ready
mRunes:RegisterOnUpdate(self, Update)
end
end
 
Update = function(self, elapsed)
self = plugin
local haveCD = false
local oldHaveCD = RuneOnCD
for i, rune in pairs(self.Runes) do
if rune.Update then
local StartTime, CooldownTime, Ready = GetRuneCooldown(i)
local diff = GetTime() - StartTime
local remaining = CooldownTime - diff
local t = diff / CooldownTime
rune:SetValue(t)
if remaining < 0 and not db.RuneCooldownAlwaysShow then
rune.CDText:Hide()
elseif db.RuneCooldownShow then
rune.CDText:Show()
rune.CDText:SetText(("%.1f"):format(Ready and 0 or (remaining < 0 and 0 or remaining)))
end
 
if Ready then rune.Update = nil else haveCD = true end
end
end
 
if not InCombat then
RuneOnCD = haveCD
if RuneOnCD and (RuneOnCD ~= oldHaveCD) then
local currAlpha = self.Frame:GetAlpha()
if currAlpha < db.RuneAlphaActive then
mRunes.FadeIn(self.Frame, false, db.RuneAlphaActive)
else
mRunes.FadeOut(self.Frame, db.RuneAlphaActive)
end
elseif not RuneOnCD and (RuneOnCD ~= oldHaveCD) then
mRunes:UnregisterOnUpdate(self, Update)
mRunes.FadeOut(self.Frame, db.RuneAlphaOutCombat)
end
end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Settings ~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:ApplySettings()
if self.Frame then
local anchor = FA:GetAnchor(db.Attached.f)
self.Frame:ClearAllPoints()
self.Frame:SetPoint(db.Attached.Point, anchor, db.Attached.RelPoint, db.Attached.x, db.Attached.y)
 
self.Frame:SetWidth(db.Width)
self.Frame:SetHeight(db.Height)
 
self.Frame:SetAlpha(InCombat and db.RuneAlphaInCombat or db.RuneAlphaOutCombat)
 
backdrop.insets.left = db.BorderInsets
backdrop.insets.right = db.BorderInsets
backdrop.insets.top = db.BorderInsets
backdrop.insets.bottom = db.BorderInsets
backdrop.edgeFile = LSM:Fetch("border", db.BorderTexture)
backdrop.edgeSize = db.BorderWidth
backdrop.bgFile = LSM:Fetch("background", "Solid")
self.Frame:SetBackdrop(backdrop)
self.Frame:SetBackdropColor(unpack(db.FrameColor))
self.Frame:SetBackdropBorderColor(unpack(db.BorderColor))
 
local RuneWidth = db.Width / 6
for i, rune in pairs(self.Runes) do
rune:ClearAllPoints()
if i == 1 then
rune:SetPoint("LEFT", db.BorderPadding + db.RuneSpacing / 2, 0)
rune:SetWidth(RuneWidth - db.RuneSpacing - db.BorderPadding / 3)
else
rune:SetPoint("LEFT", self.Runes[i-1], "RIGHT", db.RuneSpacing, 0)
rune:SetWidth(RuneWidth - db.RuneSpacing - db.BorderPadding / 3)
end
rune:SetHeight(db.Height - db.BorderPadding * 2)
rune:SetStatusBarTexture(LSM:Fetch("statusbar", db.RuneTexture))
rune:GetStatusBarTexture():SetHorizTile(false)
rune:SetStatusBarColor(unpack(db.RuneColors[GetRuneType(i)]))
 
local leftinset, rightinset = 0, 0
if db.RuneCooldownHorAlign == "LEFT" then
leftinset = db.RuneCooldownInset
elseif db.RuneCooldownHorAlign == "RIGHT" then
rightinset = -db.RuneCooldownInset
end
 
rune.CDText:ClearAllPoints()
rune.CDText:SetPoint("TOPLEFT", leftinset, 0)
rune.CDText:SetPoint("BOTTOMRIGHT", rightinset, 0)
rune.CDText:SetFont(LSM:Fetch("font", db.Font), db.FontSize, db.FontFlags)
rune.CDText:SetTextColor(unpack(db.FontColor))
rune.CDText:SetJustifyH(db.RuneCooldownHorAlign)
rune.CDText:SetJustifyV("MIDDLE")
 
if db.RuneCooldownAlwaysShow and db.RuneCooldownShow then
rune.CDText:Show()
else
rune.CDText:Hide()
end
rune.Update = true
end
 
self.Frame:SetAlpha(InCombat and db.RuneAlphaInCombat or (RuneOnCD and db.RuneAlphaActive or db.RuneAlphaOutCombat))
if self.Frame:GetAlpha() > 0 then self.Frame:Show() else self.Frame:Hide() end
end
 
if db.HideBlizz then RuneFrame:Hide()
else RuneFrame:Show() end
 
if not db.Enabled and self:IsEnabled() then self:Disable()
elseif db.Enabled and not self:IsEnabled() then self:Enable() end
 
FA:FrameModified("mRunes", "Runes")
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Create Frames ~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:CreateFuneFrame()
local frame = CreateFrame("Frame", "mRunesRuneFrame", UIParent)
 
BD:EnhanceBackdrop(frame)
FA:RegisterAnchor("mRunes", "Runes", "mRunesRunes", frame)
 
self.Runes = {}
for i = 1, NrRunes do
self.Runes[i] = self:CreateRune(i, frame)
end
 
local configFrame = CreateFrame("Frame", nil, frame)
configFrame:SetAllPoints()
configFrame:SetFrameLevel(self.Runes[1]:GetFrameLevel() + 10)
local configText = configFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
configText:SetAllPoints()
configText:SetText("Runes")
configText:Hide()
frame.ConfigText = configText
 
frame:Show()
 
self.Frame = frame
end
 
function plugin:CreateRune(runeID, parent)
local rune = CreateFrame("StatusBar", "mRunesRune"..runeID, parent)
rune:SetMinMaxValues(0,1)
rune:SetValue(1)
 
local runeCooldown = rune:CreateFontString(nil, nil, "GameFontNormal")
rune.CDText = runeCooldown
 
rune.Update = true
rune:Show()
 
return rune
end
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Options ~~~~~~~~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function plugin:GetOptions()
return plugin.GetGUI
end
 
do
local function Callback()
plugin:ApplySettings()
end
 
local FontFlagList = {
["NONE"] = "None",
["OUTLINE"] = "Outline",
["THICKOUTLINE"] = "Thick Outline",
["MONOCHROME"] = "Monochrome",
}
 
local HorizontalAlignList = {
["LEFT"] = "Left",
["CENTER"] = "Center",
["RIGHT"] = "Right",
}
 
local TabSelected
local LastSelectedTab
 
function plugin:GetGUI()
self = plugin
 
local returnGroup = AceGUI:Create("SimpleGroup")
returnGroup:SetFullWidth(true)
returnGroup:SetLayout("Flow")
 
returnGroup:AddChild(UIF:NewLine(10))
 
returnGroup:AddChild(UIF:CheckBox("Enabled", db, "Enabled", Callback, nil, 0.2))
returnGroup:AddChild(UIF:CheckBox("Hide default rune frame", db, "HideBlizz", Callback, "Hides the blizzard build in rune frame", 0.8))
 
local tgroup = UIF:TabGroup()
returnGroup:AddChild(tgroup)
tgroup:SetTabs({
{text = "Position & Size", value = "PaS"},
{text = "Colors & Alpha", value = "CaA"},
{text = "Font", value = "Font"},
})
 
tgroup:SetCallback("OnGroupSelected", TabSelected)
tgroup:SelectTab(LastSelectedTab or "PaS")
 
return returnGroup
end
 
TabSelected = function(self, event, tab)
self:ReleaseChildren()
LastSelectedTab = tab
 
if tab == "PaS" then
self:AddChild(UIF:Text1("Select a frame to attach to. You can then adjust the relative positioning to that frame via X and Y as well as the anchor points."))
local t = AceGUI:Create("FrameAnchorDropdown")
t:SetRelativeWidth(0.5)
t:SetList(FA:GetAnchors(plugin.Frame))
t:SetLabel("Anchor")
t:SetValue(db.Attached.f)
t:SetCallback("OnValueChanged", function(self, event, cat, name, frame)
db.Attached.f = cat
Callback()
end)
self:AddChild(t)
self:AddChild(UIF:Spacer(10))
self:AddChild(UIF:Text2("Avoid creating circle references!", nil, nil, nil, nil, nil, 0.4))
self:AddChild(UIF:NewLine())
self:AddChild(UIF:Dropdown("Point", db.Attached, "Point", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Dropdown("Relative Point", db.Attached, "RelPoint", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Slider("X", db.Attached, "x", -300, 300, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Y", db.Attached, "y", -300, 300, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Width", db, "Width", 5, 1000, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Height", db, "Height", 5, 200, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Space between Runes", db, "RuneSpacing", 0, 100, 0.1, Callback, 0.5))
 
elseif tab == "CaA" then
local group = UIF:InlineGroup2("Rune Colors")
self:AddChild(group)
group:AddChild(UIF:ColorSelect("Blood", db.RuneColors, 1, Callback, true, 0.25))
group:AddChild(UIF:ColorSelect("Unholy", db.RuneColors, 2, Callback, true, 0.25))
group:AddChild(UIF:ColorSelect("Frost", db.RuneColors, 3, Callback, true, 0.25))
group:AddChild(UIF:ColorSelect("Death", db.RuneColors, 4, Callback, true, 0.25))
 
group = UIF:InlineGroup2("Alpha")
self:AddChild(group)
group:AddChild(UIF:Slider("Combat", db, "RuneAlphaInCombat", 0, 1, 0.01, Callback, 0.33))
group:AddChild(UIF:Slider("OOC (Runes on cooldown)", db, "RuneAlphaActive", 0, 1, 0.01, Callback, 0.33))
group:AddChild(UIF:Slider("OOC (No runes on cooldown)", db, "RuneAlphaOutCombat", 0, 1, 0.01, Callback, 0.33))
 
group = UIF:InlineGroup2("Border and Background")
self:AddChild(group)
group:AddChild(UIF:LSMDropdown("border", "Border texture", db, "BorderTexture", Callback, 0.5))
group:AddChild(UIF:LSMDropdown("statusbar", "Bar Texture", db, "RuneTexture", Callback, 0.5))
 
group:AddChild(UIF:ColorSelect("Background Color", db, "FrameColor", Callback, true, 0.5))
group:AddChild(UIF:ColorSelect("Border color", db, "BorderColor", Callback, true, 0.5))
group:AddChild(UIF:Slider("Border Width", db, "BorderWidth", 0, 50, 1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Padding", db, "BorderPadding", 0, 100, 0.1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Insets", db, "BorderInsets", 0, 50, 1, Callback, 0.33))
 
elseif tab == "Font" then
self:AddChild(UIF:Text1("These settings are for the cooldown text on each rune"))
self:AddChild(UIF:CheckBox("Show", db, "RuneCooldownShow", Callback, "Toggle if the cooldown text should shown", 0.5))
self:AddChild(UIF:CheckBox("Always Show", db, "RuneCooldownAlwaysShow", Callback, "Toggle if the cooldown text should always be shown, even when it is not on cooldown", 0.5))
self:AddChild(UIF:LSMDropdown("font", "Font", db, "Font", Callback, 0.5))
self:AddChild(UIF:Dropdown("Font Flags", db, "FontFlags", Callback, FontFlagList, 0.5))
self:AddChild(UIF:ColorSelect("Color", db, "FontColor", Callback, false, 0.2))
self:AddChild(UIF:Slider("Size", db, "FontSize", 2, 50, 1, Callback, 0.4))
self:AddChild(UIF:Slider("Margin", db, "RuneCooldownInset", 0, 50, 0.1, Callback, 0.4))
self:AddChild(UIF:Dropdown("Horizontal Alignment", db, "RuneCooldownHorAlign", Callback, HorizontalAlignList, 0.5))
end
 
self:DoLayout()
self.parent:DoLayout()
end
end
\ No newline at end of file
mRunes/Modules/RunicPower.lua New file
0,0 → 1,414
local _, class = UnitClass("player")
if class ~= "DEATHKNIGHT" then
return
end
 
local plugin = mRunes:NewModule("Runic Power", "AceEvent-3.0")
plugin.mRunesPlugin = true
 
local AceGUI = LibStub("AceGUI-3.0")
local LSM = LibStub("LibSharedMedia-3.0")
local BD = LibStub("LibBackdrop-1.0")
local FA = LibStub("LibFrameAnchorRegistry-1.0")
local UIF
local db
 
local InCombat = false
local HaveRP = false
local ConfigMode = false
 
local backdrop = {
tile = true,
tileSize = 16,
insets = {},
}
 
plugin.DisplayName = "Runic Power"
plugin.DisplayIcon = [[Interface\Icons\Spell_DeathKnight_DarkConviction]]
plugin.DisplayOrder = 2
 
function plugin:OnInitialize()
local defaults = {
profile = {
Enabled = true,
 
Attached = {
f = "mRunesRunes",
x = 0,
y = 0,
Point = "TOP",
RelPoint = "BOTTOM",
},
 
Width = 330,
Height = 20,
InternalSpacing = 1,
AlphaIncCombat = 1,
AlphaOutCombat = 0.2,
AlphaActive = 0.5,
 
HorAlign = "LEFT",
AlwaysShowText = false,
ShowText = true,
 
Font = "accid",
FontSize = 16,
FontFlags = "OUTLINE",
FontColor = {1, 1, 1, 1},
 
Texture = "HalD",
PowerColor = {0, 0.82, 1, 1},
 
BorderTexture = "None",
BorderWidth = 5,
BorderInsets = 0,
BorderColor = {0, 0, 0, 1},
BorderPadding = 2,
BackgroundColor = {0, 0, 0, 0.5},
}
}
 
self.db = mRunes.db:RegisterNamespace(self:GetName(), defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "ProfileChanged")
db = self.db.profile
 
self:SetEnabledState(db.Enabled)
 
UIF = LibStub("LibGUIFactory-1.0"):GetFactory("mRunes")
 
if not self.PowerFrame then
self:CreatePowerFrame()
end
end
 
function plugin:OnEnable()
self:ApplySettings()
 
self:RegisterEvent("UNIT_MAXRUNIC_POWER", "RunicPowerChange")
self:RegisterEvent("UNIT_RUNIC_POWER", "RunicPowerChange")
self:RegisterEvent("UNIT_POWER", "RunicPowerChange")
self:RegisterEvent("UNIT_MAXPOWER", "RunicPowerChange")
 
mRunes.RegisterCallback(self, "EnteringCombat")
mRunes.RegisterCallback(self, "LeavingCombat")
mRunes.RegisterCallback(self, "ToggleConfigMode")
 
if UnitAffectingCombat("player") then
self:EnteringCombat("EnteringCombat")
else
self:LeavingCombat("LeavingCombat")
end
 
mRunes:RegisterOnUpdate(self.PowerFrame, self.RunicPowerChange, 0.1)
end
 
function plugin:OnDisable()
mRunes:UnregisterOnUpdate(self.PowerFrame, self.RunicPowerChange)
if self.PowerFrame then mRunes.FadeOut(self.PowerFrame) end
end
 
function plugin:ProfileChanged()
db = self.db.profile
self:ApplySettings()
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Callbacks ~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:EnteringCombat(event)
mRunes.FadeIn(self.PowerFrame, false, db.AlphaIncCombat)
InCombat = true
HaveRP = false
end
 
function plugin:LeavingCombat(event)
if UnitPower("player") <= 0 then mRunes.FadeOut(self.PowerFrame, db.AlphaOutCombat) end
InCombat = false
end
 
function plugin:EnterWorld(...)
end
 
function plugin:ToggleConfigMode(event, enable)
ConfigMode = enable
if enable then
self.PowerFrame.text:Show()
self.PowerFrame.ConfigText:Show()
mRunes.FadeIn(self.PowerFrame, false, 1)
self.PowerFrame.bar:SetValue(0.7)
self.PowerFrame.text:SetText(75)
else
self.PowerFrame.text:Hide()
self.PowerFrame.ConfigText:Hide()
self.PowerFrame.bar:SetValue(0)
self.PowerFrame.text:SetText()
if InCombat then
mRunes.FadeIn(self.PowerFrame, true, db.AlphaIncCombat)
elseif HaveRP then
mRunes.FadeIn(self.PowerFrame, true, db.AlphaActive)
else
mRunes.FadeIn(self.PowerFrame, true, db.AlphaOutCombat)
end
end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Events ~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:RunicPowerChange(event, unit)
self = plugin
if unit and unit ~= "player" then return end
local power = UnitPower("player")
local maxPower = UnitPowerMax("player")
local p = power / maxPower
local haveRP = false
local oldHaveRP = HaveRP
if power > 0 then
haveRP = true
self.PowerFrame.bar:SetValue(p)
self.PowerFrame.text:SetFormattedText("%d", power)
if db.ShowText and not self.PowerFrame.text:IsShown() then self.PowerFrame.text:Show() end
else
mRunes:UnregisterOnUpdate(self.PowerFrame, self.RunicPowerChange)
self.PowerFrame.bar:SetValue(0)
self.PowerFrame.text:SetFormattedText("%d", 0)
if not db.AlwaysShowText and not ConfigMode then
if self.PowerFrame.text:IsShown() then self.PowerFrame.text:Hide() end
elseif db.ShowText then
if not self.PowerFrame.text:IsShown() then self.PowerFrame.text:Show() end
else
if self.PowerFrame.text:IsShown() then self.PowerFrame.text:Hide() end
end
end
 
if not InCombat then
HaveRP = haveRP
if HaveRP and (HaveRP ~= oldHaveRP) then
local currAlpha = self.PowerFrame:GetAlpha()
if currAlpha < db.AlphaActive then
mRunes.FadeIn(self.PowerFrame, false, db.AlphaActive)
else
mRunes.FadeOut(self.PowerFrame, db.AlphaActive)
local t = 2
end
elseif not HaveRP and (HaveRP ~= oldHaveRP) then
mRunes.FadeOut(self.PowerFrame, db.AlphaOutCombat)
end
end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Settings ~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:ApplySettings()
local PowerFrame = self.PowerFrame
if PowerFrame then
local anchor = FA:GetAnchor(db.Attached.f)
PowerFrame:ClearAllPoints()
PowerFrame:SetPoint(db.Attached.Point, anchor, db.Attached.RelPoint, db.Attached.x, db.Attached.y)
PowerFrame:SetWidth(db.Width)
PowerFrame:SetHeight(db.Height)
 
backdrop.insets.left = db.BorderInsets
backdrop.insets.right = db.BorderInsets
backdrop.insets.top = db.BorderInsets
backdrop.insets.bottom = db.BorderInsets
backdrop.edgeFile = LSM:Fetch("border", db.BorderTexture)
backdrop.edgeSize = db.BorderWidth
backdrop.bgFile = LSM:Fetch("background", "Solid")
PowerFrame:SetBackdrop(backdrop)
PowerFrame:SetBackdropColor(unpack(db.BackgroundColor))
PowerFrame:SetBackdropBorderColor(unpack(db.BorderColor))
 
local leftinset, rightinset = 0, 0
if db.HorAlign == "LEFT" then
leftinset = db.InternalSpacing
elseif db.HorAlign == "RIGHT" then
rightinset = -db.InternalSpacing
end
 
PowerFrame.text:SetPoint("TOPLEFT", leftinset, 0)
PowerFrame.text:SetPoint("BOTTOMRIGHT", rightinset, 0)
PowerFrame.text:SetFont(LSM:Fetch("font", db.Font), db.FontSize, db.FontFlags)
PowerFrame.text:SetTextColor(unpack(db.FontColor))
PowerFrame.text:SetJustifyH(db.HorAlign)
PowerFrame.text:SetJustifyV("MIDDLE")
 
local bar = PowerFrame.bar
bar:ClearAllPoints()
bar:SetPoint("TOPLEFT", db.BorderPadding, -db.BorderPadding)
bar:SetPoint("BOTTOMRIGHT", -db.BorderPadding, db.BorderPadding)
 
bar:SetStatusBarTexture(LSM:Fetch("statusbar", db.Texture))
bar:GetStatusBarTexture():SetHorizTile(false)
bar:SetStatusBarColor(unpack(db.PowerColor))
 
PowerFrame:SetAlpha(InCombat and db.AlphaIncCombat or (HaveRP and db.AlphaActive or db.AlphaOutCombat))
if PowerFrame:GetAlpha() > 0 then PowerFrame:Show() else PowerFrame:Hide() end
if db.AlwaysShowText and db.ShowText then
PowerFrame.text:Show()
else
PowerFrame.text:Hide()
end
 
self:RunicPowerChange("UNIT_RUNIC_POWER", "player")
end
 
if not db.Enabled and self:IsEnabled() then self:Disable()
elseif db.Enabled and not self:IsEnabled() then self:Enable() end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Create Frames ~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:CreatePowerFrame()
local frame = CreateFrame("Frame", nil, UIParent)
 
BD:EnhanceBackdrop(frame)
FA:RegisterAnchor("mRunes", "Runic Power", "mRunesRunicPower", frame)
 
local bar = CreateFrame("StatusBar", nil, frame)
bar:SetMinMaxValues(0,1)
frame.bar = bar
 
local text = bar:CreateFontString(nil, nil, "GameFontNormal")
frame.text = text
 
local configFrame = CreateFrame("Frame", nil, frame)
configFrame:SetAllPoints()
configFrame:SetFrameLevel(bar:GetFrameLevel() + 10)
local configText = configFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
configText:SetAllPoints()
configText:SetText("Runes")
configText:Hide()
frame.ConfigText = configText
 
self.PowerFrame = frame
end
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Options ~~~~~~~~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function plugin:GetOptions()
return plugin.GetGUI
end
 
do
local function Callback()
plugin:ApplySettings()
end
 
local FontFlagList = {
["NONE"] = "None",
["OUTLINE"] = "Outline",
["THICKOUTLINE"] = "Thick Outline",
["MONOCHROME"] = "Monochrome",
}
 
local VerticalAlignList = {
["TOP"] = "Top",
["MIDDLE"] = "Middle",
["BOTTOM"] = "Bottom",
}
 
local HorizontalAlignList = {
["LEFT"] = "Left",
["CENTER"] = "Center",
["RIGHT"] = "Right",
}
 
local TabSelected
local LastTablSelected
 
 
function plugin:GetGUI()
self = plugin
 
local returnGroup = AceGUI:Create("SimpleGroup")
returnGroup:SetFullWidth(true)
returnGroup:SetLayout("Flow")
 
returnGroup:AddChild(UIF:NewLine(10))
 
returnGroup:AddChild(UIF:CheckBox("Enabled", db, "Enabled", Callback, nil, 0.33))
 
local tgroup = UIF:TabGroup()
returnGroup:AddChild(tgroup)
tgroup:SetTabs({
{text = "Position & Size", value = "PaS"},
{text = "Colors & Alpha", value = "CaA"},
{text = "Font", value = "Font"},
})
tgroup:SetCallback("OnGroupSelected", TabSelected)
tgroup:SelectTab(LastTablSelected or "PaS")
 
return returnGroup
end
 
TabSelected = function(self, event, tab)
self:ReleaseChildren()
LastTablSelected = tab
 
if tab == "PaS" then
 
self:AddChild(UIF:Text1("Select a frame to attach to. You can then adjust the relative positioning to that frame via X and Y as well as the anchor points."))
local t = AceGUI:Create("FrameAnchorDropdown")
t:SetRelativeWidth(0.5)
t:SetList(FA:GetAnchors(plugin.PowerFrame))
t:SetLabel("Anchor")
t:SetValue(db.Attached.f)
t:SetCallback("OnValueChanged", function(self, event, cat, name, frame)
db.Attached.f = cat
Callback()
end)
self:AddChild(t)
self:AddChild(UIF:Spacer(10))
self:AddChild(UIF:Text2("Avoid creating circle references!", nil, nil, nil, nil, nil, 0.4))
self:AddChild(UIF:NewLine())
self:AddChild(UIF:Dropdown("Point", db.Attached, "Point", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Dropdown("Relative Point", db.Attached, "RelPoint", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Slider("X", db.Attached, "x", -300, 300, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Y", db.Attached, "y", -300, 300, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Width", db, "Width", 5, 1000, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Height", db, "Height", 5, 200, 0.1, Callback, 0.5))
 
elseif tab == "CaA" then
local group = UIF:InlineGroup2("Bar Color")
self:AddChild(group)
group:AddChild(UIF:ColorSelect("Runic Power color", db, "PowerColor", Callback, true, 1.0))
 
group = UIF:InlineGroup2("Alpha")
self:AddChild(group)
group:AddChild(UIF:Slider("In combat", db, "AlphaIncCombat", 0, 1, 0.01, Callback, 0.33))
group:AddChild(UIF:Slider("OOC (RP > 0)", db, "AlphaActive", 0, 1, 0.01, Callback, 0.33))
group:AddChild(UIF:Slider("OOC (RP = 0)", db, "AlphaOutCombat", 0, 1, 0.01, Callback, 0.33))
 
group = UIF:InlineGroup2("Border and Background")
self:AddChild(group)
group:AddChild(UIF:LSMDropdown("border", "Border texture", db, "BorderTexture", Callback, 0.5))
group:AddChild(UIF:LSMDropdown("statusbar", "Bar Texture", db, "Texture", Callback, 0.5))
 
group:AddChild(UIF:ColorSelect("Background Color", db, "BackgroundColor", Callback, true, 0.5))
group:AddChild(UIF:ColorSelect("Border color", db, "BorderColor", Callback, true, 0.5))
group:AddChild(UIF:Slider("Border Width", db, "BorderWidth", 0, 50, 1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Padding", db, "BorderPadding", 0, 100, 0.1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Insets", db, "BorderInsets", 0, 50, 1, Callback, 0.33))
 
elseif tab == "Font" then
self:AddChild(UIF:Text1("These settings are for the text display of current runic power."))
self:AddChild(UIF:CheckBox("Show", db, "ShowText", Callback, "Toggle if the runic power text should be shown.", 0.5))
self:AddChild(UIF:CheckBox("Always Show", db, "AlwaysShowText", Callback, "Toggle if the runic power text should always be shown. If not it will be hidden when the runc power is at 0", 0.5))
self:AddChild(UIF:LSMDropdown("font", "Font", db, "Font", Callback, 0.5))
self:AddChild(UIF:Dropdown("Font Flags", db, "FontFlags", Callback, FontFlagList, 0.5))
self:AddChild(UIF:ColorSelect("Color", db, "FontColor", Callback, false, 0.2))
self:AddChild(UIF:Slider("Size", db, "FontSize", 2, 50, 1, Callback, 0.4))
self:AddChild(UIF:Slider("Margin", db, "InternalSpacing", 0, 50, 0.1, Callback, 0.4))
self:AddChild(UIF:Dropdown("Horizontal Align", db, "HorAlign", Callback, HorizontalAlignList, 0.5))
end
 
self:DoLayout()
self.parent:DoLayout()
end
end
\ No newline at end of file
mRunes/Modules/Timers.lua New file
0,0 → 1,694
local _, class = UnitClass("player")
if class ~= "DEATHKNIGHT" then
return
end
 
local plugin = mRunes:NewModule("Timers", "AceEvent-3.0")
plugin.mRunesPlugin = true
 
local AceGUI = LibStub("AceGUI-3.0")
local LSM = LibStub("LibSharedMedia-3.0")
local BD = LibStub("LibBackdrop-1.0")
local FA = LibStub("LibFrameAnchorRegistry-1.0")
local UIF
local db
 
local LUnitDebuff = UnitDebuff
local LUnitBuff = UnitBuff
 
local InCombat = false
local ConfigMode = false
 
local Bars = {
}
 
local Spells = {
{
id = "FrostFever",
spell = 59921
},
{
id = "BloodPlague",
spell = 59879
},
{
id = "ScarletFever",
spell = 81130,
talent = {
tab = 1,
index = 6,
},
},
{
id = "UnholyBlight",
spell = 50536,
talent = {
tab = 3,
index = 13,
},
},
{
id = "EbonPlague",
spell = 65142,
talent = {
tab = 3,
index = 17,
}
},
{
id = "ShadowInfustion",
spell = 91342,
talent = {
tab = 3,
index = 10,
},
unit = "pet",
type = "buff",
showStacks = true,
},
{
id = "DarkTransformation",
spell = 93426,
talent = {
tab = 3,
index = 16,
},
unit = "pet",
type = "buff",
},
{
id = "FreezingFog",
spell = 59052,
talent = {
tab = 2,
index = 11,
},
type = "buff",
unit = "player",
},
{
id = "KillingMachine",
spell = 51124,
talent = {
tab = 2,
index = 10,
},
type = "buff",
unit = "player",
}
}
 
-- local name, icon, tier, column, currentRank, maxRank = GetTalentInfo(tab, i, isnotplayer)
 
local backdrop = {
tile = true,
tileSize = 16,
insets = {},
}
 
plugin.DisplayName = "Timers"
plugin.DisplayIcon = [[Interface\Icons\spell_deathknight_bloodplague]]
plugin.DisplayOrder = 3
 
function plugin:OnInitialize()
local defaults = {
profile = {
Enabled = true,
 
Bar = {
["**"] = {
Attached = {
f = nil,
x = 0,
y = -1,
Point = "TOP",
RelPoint = "BOTTOM",
},
 
Enabled = true,
DisableOnMissingTalent = true,
NotCountMissing = true,
RelativeHeight = 1,
Color = {1, 1, 1, 1},
Order = 1,
ShowName = true,
ShowTime = true,
 
Width = 330,
Height = 25,
BarSpacing = 2,
 
AlphaIncCombat = 1,
AlphaOutCombat = 0.0,
 
ShowIcon = true,
 
Texture = "HalD",
 
BorderTexture = "None",
BorderWidth = 5,
BorderInsets = 0,
BorderPadding = 0,
BorderColor = {0, 0, 0, 1},
BackgroundColor = {0, 0, 0, 0.5},
 
Font = "accid",
FontSize = 16,
FontFlags = "OUTLINE",
FontColor = {1, 1, 1, 1},
HorAlign = "LEFT",
InternalSpacing = 2,
},
["FrostFever"] = {
Color = {12/255, 146/255, 237/255, 1},
},
["BloodPlague"] = {
Color = {255/255, 0/255, 228/255, 1},
},
["ScarletFever"] = {
Color = {208/255, 77/255, 0/255, 1},
},
["EbonPlague"] = {
Color = {169/255, 0/255, 255/255, 1},
},
["ShadowInfustion"] = {
Color = {8/255, 153/255, 32/255, 1},
},
["DarkTransformation"] = {
Color = {8/255, 153/255, 32/255, 1},
},
},
}
}
 
for i, data in pairs(Spells) do
defaults.profile.Bar[data.id] = defaults.profile.Bar[data.id] or {}
defaults.profile.Bar[data.id].NotCountMissing = data.NotCountMissing
end
 
self.db = mRunes.db:RegisterNamespace(self:GetName(), defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "ProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "ProfileChanged")
db = self.db.profile
 
self:SetEnabledState(db.Enabled)
 
UIF = LibStub("LibGUIFactory-1.0"):GetFactory("mRunes")
 
if not self.DiseaseFrame then
self:CreateDiseaseFrame()
end
end
 
function plugin:OnEnable()
self:RegisterEvent("UNIT_AURA")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:RegisterEvent("PLAYER_TALENT_UPDATE", "ApplySettings")
 
mRunes.RegisterCallback(self, "EnteringCombat")
mRunes.RegisterCallback(self, "LeavingCombat")
mRunes.RegisterCallback(self, "ToggleConfigMode")
 
self:ApplySettings()
 
mRunes:RegisterOnUpdate(self, self.Update)
self:UNIT_AURA("UNIT_AURA", "target")
self:UNIT_AURA("UNIT_AURA", "pet")
end
 
function plugin:OnDisable()
mRunes:UnregisterOnUpdate(self, self.Update)
mRunes.UnregisterAllCallbacks(self)
end
 
function plugin:ProfileChanged(event)
db = self.db.profile
for i, bar in pairs(Bars) do
bar.db = db.Bar[bar.id]
end
self:ApplySettings()
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Callbacks ~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:EnteringCombat(event)
if UnitExists("target") and UnitReaction("player", "target") < 5 then
end
InCombat = true
end
 
function plugin:LeavingCombat(event)
InCombat = false
end
 
function plugin:ToggleConfigMode(event, enable)
ConfigMode = enable
if enable then
for _, bar in pairs(Bars) do
local min, max = bar:GetMinMaxValues()
bar.background:SetHeight(bar.db.Height)
bar.background:Show()
bar:SetValue(max / 10 * 7)
bar.text:SetFormattedText("%s %.1f", bar.SpellName, math.random(10, 40 * 100) / 100)
end
else
for _, bar in pairs(Bars) do
bar:SetValue(0)
end
self:ApplySettings()
end
self:ApplySettings()
end
 
function plugin:Update()
local t = GetTime()
 
for name, bar in pairs(Bars) do
local bdb = bar.db
if bdb.Enabled then
if bar.duration then
local dur = bar.expires - t
if dur < 0 then
bar.expires = nil
bar.duration = nil
bar.stacks = nil
bar:SetValue(0)
bar.text:SetText()
 
if not self:ShouldShow(bar) and bar.background:IsShown() then
bar.background:Hide()
bar.background:SetHeight(0.01)
plugin:ReAnchor()
end
else
bar:SetValue(dur / bar.duration)
if bdb.ShowTime and bdb.ShowName then
bar.text:SetFormattedText("%s %s: %.1f", bar.SpellName, bar.ShowStacks and ("(%d)"):format(bar.stacks) or "", dur)
elseif bdb.ShowTime then
bar.text:SetFormattedText("%s %.1f ", bar.ShowStacks and ("(%d)"):format(bar.stacks) or "", dur)
elseif bdb.ShowName then
bar.text:SetFormattedText("%s %s", bar.SpellName, bar.ShowStacks and ("(%d)"):format(bar.stacks) or "")
else
bar.text:SetText()
end
end
end
end
end
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Events ~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:UNIT_AURA(event, unit)
if unit == "target" or unit == "pet" or unit == "player" then
for i, bar in pairs(Bars) do
if unit == bar.Unit then
local bdb = bar.db
local BuffFunc = bar.Type == "debuff" and LUnitDebuff or LUnitBuff
local name, rank, icon, count, atype, duration, expires, caster, stealable, shouldConsolidate, spellId = BuffFunc(unit, bar.SpellName)
 
if name and caster == "player" then
bar.expires = expires
bar.duration = duration
bar.stacks = count
if self:ShouldShow(bar) and not bar.background:IsShown() then
bar.background:Show()
bar.background:SetHeight(bdb.Height)
self:ReAnchor()
end
else
bar.expires = nil
bar.duration = nil
bar.stacks = nil
bar:SetValue(0)
bar.text:SetText()
 
if not self:ShouldShow(bar) and bar.background:IsShown() then
bar.background:Hide()
bar.background:SetHeight(0.01)
self:ReAnchor()
end
end
end
end
end
end
 
function plugin:PLAYER_TARGET_CHANGED(event)
self:UNIT_AURA("UNIT_AURA", "target")
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Settings ~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
local SortedBars = {}
local function SortBars(a, b)
return a.db.Order < b.db.Order
end
 
function plugin:ApplySettings()
self:ReAnchor()
for i, b in pairs(Spells) do
local bar = Bars[i]
local bdb = bar.db
 
local anchor
if bdb.Attached.f then
anchor = FA:GetAnchor(bdb.Attached.f)
end
if not anchor then
anchor = i == 1 and FA:GetAnchor("mRunesRunicPower") or Bars[i-1].background
end
local frame = bar.background
 
 
backdrop.insets.left = bdb.BorderInsets
backdrop.insets.right = bdb.BorderInsets
backdrop.insets.top = bdb.BorderInsets
backdrop.insets.bottom = bdb.BorderInsets
backdrop.edgeFile = LSM:Fetch("border", bdb.BorderTexture)
backdrop.edgeSize = bdb.BorderWidth
backdrop.bgFile = LSM:Fetch("background", "Solid")
frame:SetBackdrop(backdrop)
frame:SetBackdropColor(unpack(bdb.BackgroundColor))
frame:SetBackdropBorderColor(unpack(bdb.BorderColor))
 
bar:SetStatusBarTexture(LSM:Fetch("statusbar", bdb.Texture))
bar:SetStatusBarColor(unpack(bdb.Color))
 
local leftinset, rightinset = 0, 0
if bdb.HorAlign == "LEFT" then
leftinset = bdb.InternalSpacing
elseif bdb.HorAlign == "RIGHT" then
rightinset = -bdb.InternalSpacing
end
 
bar.text:SetPoint("TOPLEFT", leftinset, 0)
bar.text:SetPoint("BOTTOMRIGHT", rightinset, 0)
bar.text:SetFont(LSM:Fetch("font", bdb.Font), bdb.FontSize, bdb.FontFlags)
bar.text:SetTextColor(unpack(bdb.FontColor))
bar.text:SetJustifyH(bdb.HorAlign)
bar.text:SetJustifyV("MIDDLE")
end
 
if not db.Enabled and self:IsEnabled() then self:Disable()
elseif db.Enabled and not self:IsEnabled() then self:Enable() end
end
 
function plugin:ReAnchor()
for i, b in pairs(Spells) do
local bar = Bars[i]
local bdb = bar.db
 
local anchor
if bdb.Attached.f then
anchor = FA:GetAnchor(bdb.Attached.f)
end
if not anchor then
anchor = i == 1 and FA:GetAnchor("mRunesRunicPower") or Bars[i-1].background
end
local frame = bar.background
 
frame:ClearAllPoints()
frame:SetPoint(bdb.Attached.Point, anchor, bdb.Attached.RelPoint, bdb.Attached.x, bdb.Attached.y)
frame:SetWidth(bdb.Width)
 
if self:ShouldShow(bar) and not bar.background:IsShown() then
frame:Show()
frame:SetHeight(bdb.Height)
elseif not self:ShouldShow(bar) and bar.background:IsShown() then
frame:Hide()
frame:SetHeight(0.01)
elseif self:ShouldShow(bar) then
frame:SetHeight(bdb.Height)
end
 
bar:ClearAllPoints()
if bdb.ShowIcon then
bar.icon:ClearAllPoints()
bar.icon:SetPoint("TOPLEFT", frame, "TOPLEFT", bdb.BorderPadding, -bdb.BorderPadding)
bar.icon:SetHeight(frame:GetHeight() - bdb.BorderPadding * 2)
bar.icon:SetWidth(frame:GetHeight() - bdb.BorderPadding * 2)
bar.icon:SetTexture(bar.SpellIcon)
bar.icon:Show()
 
bar:SetPoint("TOPLEFT", bar.icon, "TOPRIGHT", 2, 0)
bar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -bdb.BorderPadding, bdb.BorderPadding)
else
bar.icon:Hide()
bar:SetPoint("TOPLEFT", frame, bdb.BorderPadding, -bdb.BorderPadding)
bar:SetPoint("BOTTOMRIGHT", frame, -bdb.BorderPadding, bdb.BorderPadding)
end
bar:SetMinMaxValues(0, 1)
end
end
 
function plugin:ShouldShow(bar)
local bdb = bar.db
if not bdb.Enabled then return false end
if ConfigMode then return true end
if bar.Restriction and bdb.DisableOnMissingTalent then
if bar.Restriction.type == "TALENT" then
local name, icon, tier, column, currentRank, maxRank = GetTalentInfo(bar.Restriction.tab, bar.Restriction.index, false)
if not name or currentRank == 0 then
return false
end
end
end
 
if bdb.NotCountMissing and not bar.duration then
return false
end
 
return true
end
 
-- ~~~~~~~~~~~~~~~~~~~~
-- Create Frames ~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~
function plugin:CreateDiseaseFrame()
for s, data in pairs(Spells) do
local spellID = (type(data.spell) == "table") and data.spell[1] or data.spell
local spellName, _, spellIcon = GetSpellInfo(spellID)
if spellName then
local bar = self:CreateBar(UIParent, data.id, spellName)
 
bar.Spell = spellID
bar.SpellName = spellName
bar.SpellIcon = spellIcon
bar.Unit = data.unit or "target"
bar.Type = data.type or "debuff"
bar.ShowStacks = data.showStacks
bar.NotCountMissing = data.NotCountMissing
bar.db = db.Bar[data.id]
bar.id = data.id
 
if data.talent then
bar.Restriction = {
type = "TALENT",
tab = data.talent.tab,
index = data.talent.index,
}
end
 
Bars[s] = bar
end
end
end
 
function plugin:CreateBar(parent, BarName, SpellName)
local frame = CreateFrame("Frame", "mRunes"..BarName.."Background", parent)
local bar = CreateFrame("StatusBar", "mRunes"..BarName.."Bar", frame)
 
BD:EnhanceBackdrop(frame)
bar.background = frame
 
FA:RegisterAnchor("mRunes\001Timers", SpellName, "mRunesTimer"..BarName, frame)
 
local text = bar:CreateFontString(nil, nil, "GameFontNormal")
bar.text = text
 
local icon = frame:CreateTexture(nil, "ARTOWORK")
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
bar.icon = icon
 
bar:SetFrameLevel(bar.background:GetFrameLevel() + 1)
 
return bar
end
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Options ~~~~~~~~~~~~~~~~~~~~
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function plugin:GetOptions()
return plugin.GetGUI
end
 
do
local function Callback()
plugin:ApplySettings()
end
 
local FontFlagList = {
["NONE"] = "None",
["OUTLINE"] = "Outline",
["THICKOUTLINE"] = "Thick Outline",
["MONOCHROME"] = "Monochrome",
}
 
local VerticalAlignList = {
["TOP"] = "Top",
["MIDDLE"] = "Middle",
["BOTTOM"] = "Bottom",
}
 
local HorizontalAlignList = {
["LEFT"] = "Left",
["CENTER"] = "Center",
["RIGHT"] = "Right",
}
 
local TabSelected
local LastTabSelected
local BarSelected
local LastBarSelected
local BarTabs = {}
 
function plugin:GetGUI()
self = plugin
 
local returnGroup = AceGUI:Create("SimpleGroup")
returnGroup:SetFullWidth(true)
returnGroup:SetLayout("Flow")
 
returnGroup:AddChild(UIF:NewLine(10))
 
returnGroup:AddChild(UIF:CheckBox("Enabled", db, "Enabled", Callback, nil, 0.33))
 
wipe(BarTabs)
for name, bar in pairs(Bars) do
BarTabs[bar.id] = {text = bar.SpellName, value = bar.id, icon = bar.SpellIcon}
end
 
table.sort(BarTabs, function(a, b) return a.text < b.text end)
 
local tgroup = UIF:DropdownGroup("Spells")
tgroup:SetLayout("Flow")
returnGroup:AddChild(tgroup)
tgroup:SetGroupList(BarTabs)
tgroup:SetCallback("OnGroupSelected", BarSelected)
tgroup:SetGroup(LastBarSelected or Bars[1].id)
 
return returnGroup
end
 
BarSelected = function(self, event, tab)
self:ReleaseChildren()
LastBarSelected = tab
 
local bar
for _, b in pairs(Bars) do
if b.id == tab then
bar = b
break
end
end
 
self:AddChild(UIF:CheckBox("Enabled", bar.db, "Enabled", Callback, nil, 0.3))
 
local tgroup = UIF:TabGroup()
tgroup:SetTabs(
{
{text = "Anchoring and Size", value = "anchor"},
{text = "Font", value = "font"},
{text = "Texture and Colors", value = "tex"},
}
)
self:AddChild(tgroup)
tgroup.userdata.bar = bar
tgroup:SetCallback("OnGroupSelected", TabSelected)
tgroup:SelectTab(LastSelectedTab or "anchor")
 
end
 
TabSelected = function(self, event, tab)
self:ReleaseChildren()
LastSelectedTab = tab
 
local bar = self.userdata.bar
local bdb = self.userdata.bar.db
 
local title = UIF:Title2(bar.SpellName)
title:SetImage(bar.SpellIcon)
self:AddChild(title)
 
if tab == "anchor" then
self:AddChild(UIF:Text1("Select a frame to attach to. You can then adjust the relative positioning to that frame via X and Y as well as the anchor points."))
 
self:AddChild(UIF:CheckBox("Show spell icon", bdb, "ShowIcon", Callback, nil, 0.5))
 
local t = AceGUI:Create("FrameAnchorDropdown")
t:SetRelativeWidth(0.5)
t:SetList(FA:GetAnchors(bar.background))
t:SetLabel("Anchor")
t:SetValue(bdb.Attached.f)
t:SetCallback("OnValueChanged", function(self, event, cat, name, frame)
bdb.Attached.f = cat
Callback()
end)
self:AddChild(t)
self:AddChild(UIF:NewLine())
self:AddChild(UIF:Dropdown("Point", bdb.Attached, "Point", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Dropdown("Relative Point", bdb.Attached, "RelPoint", Callback, mRunes:GetAnchorList(), 0.5, true))
self:AddChild(UIF:Slider("X", bdb.Attached, "x", -1500, 1500, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Y", bdb.Attached, "y", -1500, 1500, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Width", bdb, "Width", 5, 1000, 0.1, Callback, 0.5))
self:AddChild(UIF:Slider("Height", bdb, "Height", 5, 200, 0.1, Callback, 0.5))
 
self:AddChild(UIF:CheckBox("Show Name", bdb, "ShowName", Callback, "Toggle display of spellname on the bar", 0.5))
self:AddChild(UIF:CheckBox("Show Time", bdb, "ShowTime", Callback, "Toggle display of remaining time", 0.5))
self:AddChild(UIF:CheckBox("Collapse when missing", bdb, "NotCountMissing", Callback, "Toggle if the bars should collapse and take up no space when the the spell is missing", 0.5))
if bar.Restriction then
if bar.Restriction.type == "TALENT" then
self:AddChild(UIF:CheckBox("Disable when missing talent", bdb, "DisableOnMissingTalent", Callback, "This will disable this bar if the talent for it is missing", 0.8))
end
self:AddChild(UIF:NewLine())
end
 
elseif tab == "font" then
self:AddChild(UIF:LSMDropdown("font", "Font", bdb, "Font", Callback, 0.5))
self:AddChild(UIF:Dropdown("Font Flags", bdb, "FontFlags", Callback, FontFlagList, 0.5))
self:AddChild(UIF:ColorSelect("Color", bdb, "FontColor", Callback, false, 0.2))
self:AddChild(UIF:Slider("Size", bdb, "FontSize", 2, 50, 1, Callback, 0.4))
self:AddChild(UIF:Slider("Margin", bdb, "InternalSpacing", 0, 50, 0.1, Callback, 0.4))
self:AddChild(UIF:Dropdown("Horizontal Align", bdb, "HorAlign", Callback, HorizontalAlignList, 0.5))
 
 
 
elseif tab == "tex" then
self:AddChild(UIF:ColorSelect("Color", bdb, "Color", Callback, true, 0.5))
 
local group = UIF:InlineGroup2("Alpha")
self:AddChild(group)
group:AddChild(UIF:Slider("In combat", bdb, "AlphaIncCombat", 0, 1, 0.01, Callback, 0.33))
group:AddChild(UIF:Slider("OOC or No target", bdb, "AlphaOutCombat", 0, 1, 0.01, Callback, 0.33))
 
group = UIF:InlineGroup2("Border and Background")
self:AddChild(group)
group:AddChild(UIF:LSMDropdown("border", "Border texture", bdb, "BorderTexture", Callback, 0.5))
group:AddChild(UIF:LSMDropdown("statusbar", "Bar Texture", bdb, "Texture", Callback, 0.5))
 
group:AddChild(UIF:ColorSelect("Background Color", bdb, "BackgroundColor", Callback, true, 0.5))
group:AddChild(UIF:ColorSelect("Border color", bdb, "BorderColor", Callback, true, 0.5))
group:AddChild(UIF:Slider("Border Width", bdb, "BorderWidth", 1, 50, 1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Padding", bdb, "BorderPadding", 0, 100, 0.1, Callback, 0.33))
group:AddChild(UIF:Slider("Border Insets", bdb, "BorderInsets", 0, 50, 1, Callback, 0.33))
end
 
self:DoLayout()
self.parent:DoLayout()
end
end
\ No newline at end of file
mRunes/Modules/Procs.lua --- mRunes/Libs/modules.xml (revision 0) +++ mRunes/Libs/modules.xml (revision 6) @@ -0,0 +1,16 @@ + +