Quantcast

* Initial framework for modular design, ConfigureButton and ShowButton() are run at the correct times.

James Whitehead II [12-31-06 - 20:03]
* Initial framework for modular design, ConfigureButton and ShowButton() are run at the correct times.
* Buff frameowork in place, properly showing SoR and Perception =)
Filename
PerfectRaid.lua
PerfectRaid.toc
PerfectRaidOptions.lua
PerfectRaid_Buffs.lua
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index b52db5d..3d9ac4c 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -37,6 +37,7 @@ local utils = DongleStub("DongleUtils")
 PerfectRaid = DongleStub("Dongle"):New("PerfectRaid")

 function PerfectRaid:Initialize()
+	self.frames = frames
 	self.defaults = {
 		profile = {
 			headers = {},
@@ -311,6 +312,12 @@ local function OnShow(frame)
 	frames[unit] = frames[unit] or {}
 	frames[unit][frame] = true

+	for name,module in self:IterateModules() do
+		if type(module.ShowButton) == "function" then
+			module:ShowButton(frame)
+		end
+	end
+
 	self:UNIT_HEALTH(nil, unit)
 	self:UNIT_MANA(nil, unit)
 end
@@ -350,6 +357,8 @@ local function OnAttributeChanged(frame, name, value)
 end

 function PerfectRaid.ConfigureButton(button)
+	local self = PerfectRaid
+
 	button:SetWidth(200)
 	button:SetHeight(14)
 --	button:SetBackdrop(GameTooltip:GetBackdrop())
@@ -367,10 +376,12 @@ function PerfectRaid.ConfigureButton(button)
 	local leftbox = CreateFrame("Frame", nil, button)
 	leftbox:SetPoint("TOPLEFT", 0, 0)
 	leftbox:SetPoint("BOTTOMRIGHT", button, "BOTTOMLEFT", 70, 0)
+	button.leftbox = leftbox

 	local rightbox = CreateFrame("Frame", nil, button)
 	rightbox:SetPoint("TOPRIGHT", 0, 0)
 	rightbox:SetPoint("BOTTOMLEFT", button, "BOTTOMRIGHT", -40, 0)
+	button.rightbox = rightbox

 	local bar = CreateFrame("StatusBar", nil, button)
 	bar:SetPoint("TOPLEFT", leftbox, "TOPRIGHT", 0, 0)
@@ -425,13 +436,15 @@ function PerfectRaid.ConfigureButton(button)
 	font:SetPoint("RIGHT", -2, 2)
 	button.status = font

-	local font = button.healthbar:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
-	font:SetPoint("LEFT", button.healthbar, "RIGHT", 3, 0)
-	button.aura = font
-
 	button:SetClampedToScreen(true)
 	button:RegisterForDrag("LeftButton")

+	for name,module in self:IterateModules() do
+		if type(module.ConfigureButton) == "function" then
+			module:ConfigureButton(button)
+		end
+	end
+
 	button:SetScript("OnShow", OnShow)
 	button:SetScript("OnDragStart", OnDragStart)
 	button:SetScript("OnDragStop", OnDragStop)
diff --git a/PerfectRaid.toc b/PerfectRaid.toc
index 81a1190..7b73cc1 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -4,10 +4,13 @@
 ## Notes: Simply powerful raid and party frames
 ## SavedVariables: PerfectRaidDB
 ## OptionalDeps: Dongle
+
 Dongle.lua
 DongleUtils.lua
 Localization.enUS.lua
 PerfectRaid.xml
 PerfectRaid.lua

+PerfectRaid_Buffs.lua
+

diff --git a/PerfectRaidOptions.lua b/PerfectRaidOptions.lua
new file mode 100644
index 0000000..41c9b84
--- /dev/null
+++ b/PerfectRaidOptions.lua
@@ -0,0 +1,28 @@
+--[[
+foo = CreateFrame("Frame", "PRTestOptions", UIParent, "PROptionsTemplate")
+foo:SetHeight(300) foo:SetWidth(450)
+foo:SetPoint("CENTER", 0, 0)
+foo:Show()
+
+local tab1 = CreateFrame("Button", "PRTab1", foo, "PRTabTemplate")
+tab1:SetPoint("TOPLEFT", foo, "BOTTOMLEFT", 10, 12)
+tab1:Show()
+
+local tab2 = CreateFrame("Button", "PRTab2", foo, "PRTabTemplate")
+tab2:SetPoint("TOPLEFT", tab1, "TOPRIGHT", 3, 0)
+tab2:Show()
+
+local tab3 = CreateFrame("Button", "PRTab3", foo, "PRTabTemplate")
+tab3:SetPoint("TOPLEFT", tab2, "TOPRIGHT", 3, 0)
+tab3:SetWidth(150)
+tab3:Show()
+
+local check1 = CreateFrame("CheckButton", "PRCheck1", foo, "PRCheckTemplate")
+check1:SetHeight(16) check1:SetWidth(16)
+check1:SetPoint("TOPLEFT", 20, -30)
+check1:Show()
+
+local button1 = CreateFrame("Button", "PRButton1", foo, "PRButtonTemplate")
+button1:SetPoint("BOTTOMRIGHT", foo, -15, 17)
+button1:Show()
+--]]
\ No newline at end of file
diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua
index 24112f3..3354d1d 100644
--- a/PerfectRaid_Buffs.lua
+++ b/PerfectRaid_Buffs.lua
@@ -29,10 +29,46 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------]]

+local Buffs = PerfectRaid:NewModule("PerfectRaid-Buffs")
+local frames
+
+function Buffs:Initialize()
+	frames = PerfectRaid.frames
+end
+
+function Buffs:Enable()
+	self:RegisterEvent("UNIT_AURA")
+end
+
+function Buffs:ConfigureButton(button)
+	local font = button:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+	font:SetPoint("LEFT", button.rightbox, "LEFT", 3, 0)
+	button.aura = font
+end
+
+function Buffs:ShowButton(button)
+	local unit = button:GetAttribute("unit")
+	self:UNIT_AURA(nil, unit)
+end
+
+local buffs = {
+	{
+		buffname = "Seal of Righteousness",
+		colortext = "|cFF339911SoR|r",
+		cond = {"ALL"},
+	},
+	{
+		buffname = "Perception",
+		colortext = "|cFFFF1111Perc|r",
+		cond = {"ALL"},
+	},
+}
+
 local buffcache = {}
 local work = {}
-function PerfectRaid:UNIT_AURA(event, unit)
+function Buffs:UNIT_AURA(event, unit)
 	if not frames[unit] then return end
+
 	for k,v in pairs(buffcache) do buffcache[k] = nil end

 	for i=1,40 do
@@ -49,7 +85,6 @@ function PerfectRaid:UNIT_AURA(event, unit)

 	for k,v in pairs(work) do work[k] = nil end

-	local buffs = self.db.profile.buffs
 	for i,entry in ipairs(buffs) do
 		local checkcond = false
 		local num = buffcache[entry.buffname]
@@ -82,3 +117,7 @@ function PerfectRaid:UNIT_AURA(event, unit)
 		frame.aura:SetText(status)
 	end
 end
+
+Buffs.conditions = {
+	["ALL"] = function() return true end,
+}
\ No newline at end of file