/
config = { |
type = "execute", |
name = "Configure", |
order = 0, |
desc = "Open the Configuration Dialog", |
func = function() RuneWatch:ShowConfig() end, |
guiHidden = true |
frame = { |
type = "group", |
name = "Frame", |
order = 1, |
desc = "UI-Frame Options", |
args = { |
dsc = { |
type = "description", |
order = 0, |
cmdHidden = true, |
dropdownHidden = true, |
name = "This section of the configuration allows you to change the appearance/location of the main ui-frame." |
}, |
locked = { |
type = "toggle", |
name = "Locked", |
width = "full", |
desc = "Toggles the ui's locked state, preventing it from being moved.", |
get = function(info) return RuneWatch.db.locked end, |
set = function(info, v) RuneWatch.db.locked = v; RuneWatch:GuiUpdate(); end |
type = "group", |
name = "Behaviour", |
desc = "Mod-Behaviour Options", |
order = 2, |
args = { |
dsc = { |
type = "description", |
order = 0, |
cmdHidden = true, |
dropdownHidden = true, |
name = "This section of the configuration deals with behavioural changes to RuneWatch. The options in this section govern how RuneWatch acts and responds to various events." |
}, |
fadeout = { |
type = "group", |
order = 1, |
name = "Fade-Out", |
desc = "Out of combat Fade-Out", |
args = { |
dsc = { |
type = "description", |
order = 0, |
cmdHidden = true, |
dropdownHidden = true, |
guiHidden = true, |
name = "The Fade-Out behavior allows the RuneWatch Gui to fade-out after combat has ended, this allows the user to have an un-obstructed view when they aren't in combat since RuneWatch is primarily an in-combat mod." |
}, |
enabled = { |
local AceAddon = LibStub("AceAddon-3.0") |
local AceDB = LibStub("AceDB-3.0") |
local AceTimer = LibStub("AceTimer-3.0") |
RuneWatch = AceAddon:NewAddon("RuneWatch", "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0") |
local barWidth = 300; |
local rpBarCol = { r = 0.1, g = 0.1, b = 0.3 } |
local rpBarColMax = { r = 0.2, g = 0.2, b = 0.6 } |
local rpBarCol = { r = 0.2, g = 0.2, b = 0.6 } |
local rpBarColMax = { r = 0.4, g = 0.4, b = 0.9 } |
local artTextures = { |
Frame = "Interface\\AddOns\\RuneWatch\\Artwork\\UI-RuneWatch-Frame", |
Bar = "Interface\\AddOns\\RuneWatch\\Artwork\\UI-RuneWatch-Bar", |
Border = "Interface\\AddOns\\RuneWatch\\Artwork\\UI-RuneWatch-BarBorder" |
Bar = "Interface\\AddOns\\RuneWatch\\Artwork\\UI-RuneWatch-Bar" |
}; |
function RuneWatch:OnInitialize() |
self:RegisterEvent("RUNE_TYPE_UPDATE") |
self:RegisterEvent("UNIT_RUNIC_POWER") |
-- In/Out of Combat Events |
self:RegisterEvent("PLAYER_REGEN_DISABLED"); |
self:RegisterEvent("PLAYER_REGEN_ENABLED"); |
self:GuiUpdate(); |
--end |
self.LastUpdate = 0; |
-- Self-States |
self.State = { |
LastUpdate = 0, |
FadeOut = { |
active = false, |
elapsed = 0 |
} |
} |
end |
function RuneWatch:OnEnable() |
end |
function RuneWatch:OnUpdate(self, elapsed) |
local State = RuneWatch.State; |
State.LastUpdate = State.LastUpdate + elapsed; |
RuneWatch.LastUpdate = RuneWatch.LastUpdate + elapsed; |
if (State.FadeOut.active == true) then |
local tarOpacity = RuneWatch.db.behaviour.fadeout.opacity; |
if (RuneWatch.LastUpdate > 0.5) then |
RuneWatch.LastUpdate = 0; |
State.FadeOut.elapsed = State.FadeOut.elapsed + elapsed; |
if (State.FadeOut.elapsed >= RuneWatch.db.behaviour.fadeout.length) then |
State.FadeOut.active = false; |
RuneWatch.Gui.Anchor:SetAlpha(tarOpacity); |
else |
local perc = 1 - (State.FadeOut.elapsed / RuneWatch.db.behaviour.fadeout.length); |
local curOpacity = ((1-tarOpacity) * perc) + tarOpacity; |
RuneWatch.Gui.Anchor:SetAlpha(curOpacity); |
end |
end |
-- Update the Runic Power Every 1/2 second. |
if (State.LastUpdate > 0.5) then |
State.LastUpdate = 0; |
-- Update the GUI |
RuneWatch:UNIT_RUNIC_POWER("UNIT_RUNIC_POWER", "player"); |
end |
end |
-- Occurs when player enters 'combat' |
function RuneWatch:PLAYER_REGEN_DISABLED(event, ...) |
-- Always make sure our opacity is at full when we enter combat. |
self.Gui.Anchor:SetAlpha(1); |
end |
-- Occurs when player exits 'combat' |
function RuneWatch:PLAYER_REGEN_ENABLED(event, ...) |
-- If Fade-Out Is Turned on |
if (self.db.behaviour.fadeout.enabled == true) then |
-- Schedule a timer |
AceTimer:ScheduleTimer(function() self.State.FadeOut.elapsed = 0; self.State.FadeOut.active = true; end, self.db.behaviour.fadeout.wait); |
end |
end |
function RuneWatch:RUNE_POWER_UPDATE(event, ...) |
local rune, usable = ...; |
if not usable then |
bar:SetHeight(150); |
bar:Show(); |
local bord = frame:CreateTexture("$parent_BarBorder", "ARTWORK"); |
bord:SetTexture(artTextures.Border); |
bar:SetPoint("LEFT", self.Gui.Art.Base, "LEFT", 0, 0); |
bar:SetWidth(300); |
bar:SetHeight(150); |
bar:Show(); |
self.Gui.Art.Bar = bar; |
self.Gui.Art.BarBorder = bord; |
end |
function RuneWatch:InitBackBlocks() |