Quantcast

* Added support for raid targets

James Whitehead II [12-24-06 - 00:30]
* Added support for raid targets
* Registration of slash commands using Dongle, they do nothing at the moment
* Added support for group numbers
* Added support for group leader icons
* Added support for master looter icons
* children will now hide their header's title depending on how many children are visible
* Added a leftbox and a rightbox for bounding
Filename
PerfectRaid.lua
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 9cb768b..4086789 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -72,6 +72,7 @@ function PerfectRaid:Enable()
 	self:RegisterEvent("UNIT_MAXENERGY", "UNIT_MAXMANA")
 	self:RegisterEvent("UNIT_MAXFOCUS", "UNIT_MAXMANA")
 	self:RegisterEvent("UNIT_AURA")
+	self:RegisterEvent("RAID_TARGET_UPDATE")

 	local mode = self.db.profile.mode
 	if mode == "singleclass" then
@@ -83,6 +84,12 @@ function PerfectRaid:Enable()
 	elseif mode == "advanced" then
 		self:CreateRaidHeaders()
 	end
+
+	-- Register slash command
+	self.cmd = self:InitializeSlashCommand("PerfectRaid Options", "PERFECTRAID", "praid", "perfectraid")
+
+	-- Force a roster update
+	self:RAID_ROSTER_UPDATE()
 end

 function PerfectRaid:CreateSingleColumn(sort)
@@ -267,6 +274,7 @@ function PerfectRaid:CreateRaidFrame(name, title, filter, strict, dragparent)
 	frame.title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
 	frame.title:SetPoint("BOTTOM", frame, "TOP", 0, 3)
 	frame.title:SetText(title or "")
+	frame.count = 0
 	frame:SetAttribute("point", "TOP")
 	frame:SetAttribute("groupFilter", filter)
 	frame:SetAttribute("template", "SecureUnitButtonTemplate")
@@ -416,6 +424,12 @@ local function OnShow(frame)
 	frame.name:SetText(self:GetColoredName(unit))
 --	frame.name:SetText(UnitName(unit))

+	local idx = tonumber(string.match(unit, "^raid(%d+)$"))
+	if idx then
+		local group = select(3, GetRaidRosterInfo(idx))
+		frame.group:SetText(group)
+	end
+
 	local class = select(2, UnitClass(unit)) or "WARRIOR"
 	frame.class = class
 	frame.classcolor = RAID_CLASS_COLORS[class]
@@ -440,6 +454,7 @@ local function OnShow(frame)
 	self:UNIT_HEALTH(nil, unit)
 	self:UNIT_MANA(nil, unit)
 	self:UNIT_AURA(nil, unit)
+	self:RAID_TARGET_UPDATE(nil, unit)
 end

 local function OnHide(frame)
@@ -455,10 +470,25 @@ local function OnAttributeChanged(frame, name, value)
 			tbl[frame] = nil
 		end
 	end
+
+	local parent = frame:GetParent()
+	if value == nil then
+		local num = parent:GetNumChildren()
+		local visible = nil
+		for i=1,num do
+			local button = parent:GetAttribute("child"..i)
+			if button:IsShown() then visible = true end
+		end
+		if not visible then
+			parent.title:Hide()
+		else
+			parent.title:Show()
+		end
+	end
 end

 function PerfectRaid.ConfigureButton(button)
-	button:SetWidth(160)
+	button:SetWidth(200)
 	button:SetHeight(14)
 --	button:SetBackdrop(GameTooltip:GetBackdrop())
 	button:SetBackdropColor(0.3, 0.3, 0.3)
@@ -470,9 +500,17 @@ function PerfectRaid.ConfigureButton(button)
 	local parent = button:GetParent()
 	button:SetAttribute("dragparent", parent:GetAttribute("dragparent"))

+	local leftbox = CreateFrame("Frame", nil, button)
+	leftbox:SetPoint("TOPLEFT", 0, 0)
+	leftbox:SetPoint("BOTTOMRIGHT", button, "BOTTOMLEFT", 70, 0)
+
+	local rightbox = CreateFrame("Frame", nil, button)
+	rightbox:SetPoint("TOPRIGHT", 0, 0)
+	rightbox:SetPoint("BOTTOMLEFT", button, "BOTTOMRIGHT", -40, 0)
+
 	local bar = CreateFrame("StatusBar", nil, button)
-	bar:SetPoint("TOPLEFT", 70, 0)
-	bar:SetPoint("BOTTOMRIGHT", 0, 0)
+	bar:SetPoint("TOPLEFT", leftbox, "TOPRIGHT", 0, 0)
+	bar:SetPoint("BOTTOMRIGHT", rightbox, "BOTTOMLEFT", 0, 0)
 	bar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth")
 	button.healthbar = bar

@@ -484,11 +522,40 @@ function PerfectRaid.ConfigureButton(button)
 	button.manabar = bar
 	bar:Hide()

+	local group = leftbox:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+	group:SetPoint("LEFT", 0, 0)
+	group:SetHeight(14)
+	group:SetJustifyH("LEFT")
+	button.group = group
+	button.group:SetWidth(0.1)
+	button.group:Hide()
+
 	local font = button.healthbar:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
-	font:SetPoint("RIGHT", button.healthbar, "LEFT", -2, 0)
-	font:SetPoint("LEFT", button, "LEFT", 0, 0)
+	font:SetPoint("RIGHT", leftbox, "RIGHT", -2, 0)
+	font:SetPoint("LEFT", group, "RIGHT", 0, 0)
 	font:SetJustifyH("RIGHT")
-	button.name = font
+	button.name = font
+
+	local raidicon = button:CreateTexture(nil, "ARTWORK")
+	raidicon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons")
+	raidicon:SetHeight(16)
+	raidicon:SetWidth(0.1)
+	raidicon:SetPoint("RIGHT", leftbox, "LEFT", 0, 0)
+	button.raidicon = raidicon
+
+	local leadericon = button:CreateTexture(nil, "ARTWORK")
+	leadericon:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon")
+	leadericon:SetHeight(16)
+	leadericon:SetWidth(0.1)
+	leadericon:SetPoint("RIGHT", raidicon, "LEFT", 0, 0)
+	button.leadericon = leadericon
+
+	local looticon = button:CreateTexture(nil, "ARTWORK")
+	looticon:SetTexture("Interface\\GroupFrame\\UI-Group-MasterLooter")
+	looticon:SetHeight(16)
+	looticon:SetWidth(0.1)
+	looticon:SetPoint("RIGHT", leadericon, "LEFT", 0, 0)
+	button.looticon = looticon

 	local font = button.healthbar:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
 	font:SetPoint("RIGHT", -2, 2)
@@ -508,71 +575,31 @@ function PerfectRaid.ConfigureButton(button)
 end

 function PerfectRaid:RAID_ROSTER_UPDATE()
-	if GetNumRaidMembers() > 0 then
-		--PRaidPartyHeader:Hide()
-		if self.moving then
-			self.moving:StopMovingOrSizing()
-		end
-		self:ShowHideTitles()
-	else
-		if PRaidPartyHeader then
-			PRaidPartyHeader:Show()
-		end
-		for unit,tbl in pairs(frames) do
-			for k,v in pairs(tbl) do
-				tbl[k] = nil
-			end
-		end
-		if self.headers then
-			for k,v in pairs(self.headers) do
-				v.title:Hide()
-			end
-		end
-		if self.column then
-			for k,v in pairs(self.column) do
-				v.title:Hide()
-			end
-		end
-	end
-end
-
-function PerfectRaid:ShowHideTitles()
-	if self.column then
-		for i,frame in pairs(self.column) do
-			local active
-			for i=1,frame:GetNumChildren() do
-				local button = frame:GetAttribute("Child"..i)
-				if button:IsShown() then
-					active = true
-				end
-			end
-			if not active then
-				frame.title:Hide()
-			else
-				frame.title:Show()
-			end
-		end
+	if self.moving then
+		self.moving:StopMovingOrSizing()
 	end

-	if self.headers then
-		for i,frame in pairs(self.headers) do
-			local active
-			for i=1,frame:GetNumChildren() do
-				local button = frame:GetAttribute("Child"..i)
-				if button:IsShown() then
-					active = true
-				end
-			end
-			if not active then
-				frame.title:Hide()
+	-- Lets check for party leader
+	for unit in pairs(frames) do
+		local leader = UnitIsPartyLeader(unit)
+		local looter = select(2, GetLootMethod()) == unit
+		if leader and looter then looter = false end
+
+		for frame in pairs(frames[unit]) do
+			if leader then
+				frame.leadericon:SetWidth(16)
 			else
-				frame.title:Show()
+				frame.leadericon:SetWidth(0.1)
 			end
+			if looter then
+				frame.looticon:SetWidth(16)
+			else
+				frame.looticon:SetWidth(0.1)
+			end
 		end
-	end
+	end
 end

-
 local class = select(2, UnitClass("player"))
 local spells = {
 	DRUID = "Healing Touch",
@@ -648,24 +675,18 @@ function PerfectRaid:UNIT_AURA(event, unit)
 		frame.aura:SetText(status)
 	end
 end
-
---seterrorhandler(function(msg) PerfectRaid:Print(msg .. debugstack()) end)
-
-SLASH_PERFECTRAID1 = "/praid"
-SLASH_PERFECTRAID2 = "/perfectraid"

-SlashCmdList["PERFECTRAID"] = function(msg)
-	-- Slash Command Handler
-	if InCombatLockdown() then
-		PerfectRaid:Print("You cannot change option when in combat")
-		return
-	end
-
-	if not PROptions then
-		PerfectRaid:CreateOptions()
-		PROptions:Show()
+function PerfectRaid:RAID_TARGET_UPDATE(event, unit)
+	if not frames[unit] then return end
+	local index = GetRaidTargetIndex(unit)
+	if not index then
+		for frame in pairs(frames[unit]) do
+			frame.raidicon:SetWidth(0.1)
+		end
 	else
-		PROptions:Show()
-	end
+		for frame in pairs(frames[unit]) do
+			SetRaidTargetIconTexture(frame.raidicon, index)
+			frame.raidicon:SetWidth(16)
+		end
+	end
 end
-