Quantcast

Show dungeon roles in raid frames

F. Dekker [04-21-13 - 12:40]
Show dungeon roles in raid frames

- the dungeon role icon will appear infront of the username.
- in config you can select if and which roles you want to show.
- maintank and mainassist roles will appear as tank role.
Filename
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid.toc
PerfectRaid_Config.lua
PerfectRaid_Roles.lua
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index b5a18a7..f8b15b3 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -163,6 +163,8 @@ PerfectRaidLocals = {
 	["Save"] = "Save",
 	["Shadow Protection"] = "Shadow Protection",
 	["Shaman"] = "Shaman",
+	["Show damagers"] = "Show damagers",
+	["Show healers"] = "Show healers",
 	["Show HP deficit"] = "Show HP deficit",
 	["Show frame in raid"] = "Show frame in raid",
 	["Show frame when solo"] = "Show frame when solo",
@@ -171,6 +173,8 @@ PerfectRaidLocals = {
 	["Show options GUI"] = "Show options GUI",
 	["Show player in frame"] = "Show player in frame",
 	["Show raid icons"] = "Show raid icons",
+	["Show raid roles"] = "Show raid roles",
+	["Show tanks"] = "Show tanks",
 	["Show unit tooltip on mouseover"] = "Show unit tooltip on mouseover",
 	["Sort Frames By:"] = "Sort Frames By:",
 	["Soulstone Resurrection"] = "Soulstone Resurrection",
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 17d4359..e9b8541 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -63,7 +63,9 @@ function PerfectRaid:Initialize()
 			clickcast = true,
 			locked = false,
 			showraidicons = true,
-			raidiconposition = "LNAME",
+			raidiconposition = "MHBAR",
+			showroles = true,
+			showroletank = true,
 			highlight = {
 				mouseover = true,
 				tooltip = false,
diff --git a/PerfectRaid.toc b/PerfectRaid.toc
index 8ecd84b..ffe64c6 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -30,3 +30,4 @@ PerfectRaid_ReadyCheck.lua
 PerfectRaid_Config.lua
 PerfectRaid_RaidIcons.lua
 PerfectRaid_IncomingHeals.lua
+PerfectRaid_Roles.lua
diff --git a/PerfectRaid_Config.lua b/PerfectRaid_Config.lua
index 2e1a422..aea0116 100644
--- a/PerfectRaid_Config.lua
+++ b/PerfectRaid_Config.lua
@@ -67,10 +67,30 @@ function Config:CreateOptions(opt)
 	check.Label:SetText(L["Lock frames"])
 	table.insert(options.widgets, check)

+	local roles = CreateFrame("CheckButton", "PRConfig_RaidRole", options, "PRCheckTemplate")
+	roles.Label:SetText(L["Show raid roles"])
+	roles:Show();
+	roles:SetPoint( "TOPRIGHT", -160, 0 )
+
+	local role1 = CreateFrame("CheckButton", "PRConfig_RaidRoleTank", options, "PRCheckTemplate")
+	role1.Label:SetText(L["Show tanks"])
+	role1:Show();
+	role1:SetPoint( "TOPLEFT", roles, "BOTTOMLEFT", 25, 0)
+
+	local role2 = CreateFrame("CheckButton", "PRConfig_RaidRoleDamager", options, "PRCheckTemplate")
+	role2.Label:SetText(L["Show damagers"])
+	role2:Show();
+	role2:SetPoint( "TOPLEFT", role1, "BOTTOMLEFT", 0, 0)
+
+	local role3 = CreateFrame("CheckButton", "PRConfig_RaidRoleHealer", options, "PRCheckTemplate")
+	role3.Label:SetText(L["Show healers"])
+	role3:Show();
+	role3:SetPoint( "TOPLEFT", role2, "BOTTOMLEFT", 0, 0)
+
 	local check = CreateFrame("CheckButton", "PRConfig_RaidIcons", options, "PRCheckTemplate")
 	check.Label:SetText(L["Show raid icons"])
-	table.insert(options.widgets, check)
-
+	table.insert(options.widgets, check)
+
 	local iconPositionDropDown = CreateFrame("Frame", "PRConfig_IconPositionDropDown", options, "UIDropDownMenuTemplate")
 	local clickFunc = function(self) UIDropDownMenu_SetSelectedValue(iconPositionDropDown, self.value) end
 	iconPositionDropDown.Initialize = function()
@@ -110,6 +130,10 @@ function Config:CreateOptions(opt)
 		local locked = PRConfig_Lock:GetChecked() and true or false
 		local showRaidIcons = PRConfig_RaidIcons:GetChecked() and true or false
 		local showIncomingHeals = PRConfig_IncomingHeals:GetChecked() and true or false
+		local showRoles = PRConfig_RaidRole:GetChecked() and true or false
+		local showRoleTank = PRConfig_RaidRoleTank:GetChecked() and true or false
+		local showRoleDamager = PRConfig_RaidRoleDamager:GetChecked() and true or false
+		local showRoleHealer = PRConfig_RaidRoleHealer:GetChecked() and true or false
 		local raidIconPosition = UIDropDownMenu_GetSelectedValue(PRConfig_IconPositionDropDown)

 		PerfectRaid.db.profile.hideparty = hideParty
@@ -117,6 +141,10 @@ function Config:CreateOptions(opt)
 		PerfectRaid.db.profile.clickcast = clickCast
 		PerfectRaid.db.profile.locked = locked
 		PerfectRaid.db.profile.showraidicons = showRaidIcons
+		PerfectRaid.db.profile.showroles = showRoles
+		PerfectRaid.db.profile.showroletank = showRoleTank
+		PerfectRaid.db.profile.showroledamager = showRoleDamager
+		PerfectRaid.db.profile.showrolehealer = showRoleHealer
 		PerfectRaid.db.profile.raidiconposition = raidIconPosition
 		PerfectRaid.db.profile.showincomingheals = showIncomingHeals

@@ -131,6 +159,10 @@ function Config:CreateOptions(opt)
 		PRConfig_Lock:SetChecked(PerfectRaid.db.profile.locked)
 		PRConfig_RaidIcons:SetChecked(PerfectRaid.db.profile.showraidicons)
 		PRConfig_IncomingHeals:SetChecked(PerfectRaid.db.profile.showincomingheals)
+		PRConfig_RaidRole:SetChecked(PerfectRaid.db.profile.showroles)
+		PRConfig_RaidRoleTank:SetChecked(PerfectRaid.db.profile.showroletank)
+		PRConfig_RaidRoleDamager:SetChecked(PerfectRaid.db.profile.showroledamager)
+		PRConfig_RaidRoleHealer:SetChecked(PerfectRaid.db.profile.showrolehealer)
 		UIDropDownMenu_SetSelectedValue(PRConfig_IconPositionDropDown,PerfectRaid.db.profile.raidiconposition)
 	end

@@ -145,7 +177,8 @@ function Config:CreateOptions(opt)
 			widget:SetPoint("TOPLEFT", options.widgets[idx - 1], "BOTTOMLEFT", 0, -15)
 		end
 	end
-	options.iconposition:Show();
+	options.iconposition:Show();
+
 end

 local old_ShowPartyFrame = ShowPartyFrame
diff --git a/PerfectRaid_Roles.lua b/PerfectRaid_Roles.lua
new file mode 100644
index 0000000..4b5842e
--- /dev/null
+++ b/PerfectRaid_Roles.lua
@@ -0,0 +1,112 @@
+--[[-------------------------------------------------------------------------
+  *
+  * RaidRoles module for PerfectRaid addon.
+  *
+  * Written by: Panoramix
+  * Version: 1.0
+  *
+---------------------------------------------------------------------------]]
+
+local RaidRoles = PerfectRaid:NewModule("PerfectRaid-Roles")
+local L = PerfectRaidLocals
+local utils, frames
+
+function RaidRoles:Initialize()
+
+	frames = PerfectRaid.frames
+	utils = PerfectRaid.utils
+
+	self:RegisterMessage("DONGLE_PROFILE_CHANGED")
+	self:RegisterMessage("PERFECTRAID_CONFIG_CHANGED")
+end
+
+-- Update Raid Roles when profiles changes
+function RaidRoles:DONGLE_PROFILE_CHANGED(event, addon, svname, name)
+	if svname == "PerfectRaidDB" then
+		RaidRoles:ShowRaidRoles(PerfectRaid.db.profile.showroles)
+	end
+end
+
+-- Update Raid Roles when config is changed
+function RaidRoles:PERFECTRAID_CONFIG_CHANGED(event, addon, svname, name)
+	self:ShowRaidRoles(PerfectRaid.db.profile.showroles)
+end
+
+-- Update Raid Roles when addon is enabled
+function RaidRoles:Enable()
+	self:ShowRaidRoles(PerfectRaid.db.profile.showroles)
+end
+
+-- Show/Hide raid icons depending on value
+function RaidRoles:ShowRaidRoles(value)
+	if value then
+		self:RegisterEvent( "PLAYER_ROLES_ASSIGNED", "UpdateAllUnits" )
+	else
+		self:UnregisterEvent("PLAYER_ROLES_ASSIGNED" )
+	end
+	self:UpdateAllUnits()
+end
+
+-- Request full update for all units
+function RaidRoles:FullUpdate()
+	self:UpdateAllUnits()
+end
+
+function RaidRoles:UpdateAllUnits()
+
+	local showRoles   = PerfectRaid.db.profile.showroles
+	local showTank    = PerfectRaid.db.profile.showroletank
+	local showDamager = PerfectRaid.db.profile.showroledamager
+	local showHealer  = PerfectRaid.db.profile.showrolehealer
+
+
+    for unit, tbl in pairs(frames) do
+		local role = UnitGroupRolesAssigned( unit )
+
+		if role == "NONE" then
+			if GetPartyAssignment("MAINTANK", unit) or GetPartyAssignment("MAINASSIST", unit) then
+				role = "TANK"
+			end
+		end
+
+		if ( role and frames and frames[unit] ) then
+
+			for frame in pairs( frames[unit] ) do
+
+				-- create indicator and texture
+				if (not frame.raidrole) then
+					frame.raidrole = CreateFrame("Frame", nil, frame.leftbox)
+					frame.raidrole:SetHeight(frame:GetHeight() * 0.75)
+					frame.raidrole:SetWidth(frame:GetHeight() * 0.75)
+					frame.raidrole:SetFrameLevel(frame.leftbox:GetFrameLevel()+1)
+					frame.raidrole:SetParent(frame.leftbox)
+
+					frame.raidroletex = frame.raidrole:CreateTexture(nil, "OVERLAY")
+					frame.raidroletex:SetAllPoints()
+					frame.raidroletex:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES")
+				end
+
+				frame.raidrole:ClearAllPoints()
+				frame.raidrole:SetPoint("RIGHT", -3-frame.name:GetWidth(), 0)
+
+				if ( showRoles and showTank and role == "TANK" ) then
+					frame.raidroletex:SetTexCoord(0, 19/64, 22/64, 41/64)
+					frame.raidroletex:Show()
+
+				elseif ( showRoles and showHealer and role == "HEALER" ) then
+					frame.raidroletex:SetTexCoord(20/64, 39/64, 1/64, 20/64)
+					frame.raidroletex:Show()
+
+				elseif ( showRoles and showDamager and role == "DAMAGER" ) then
+					frame.raidroletex:SetTexCoord(20/64, 39/64, 22/64, 41/64)
+					frame.raidroletex:Show()
+
+				else
+					frame.raidroletex:Hide()
+				end
+
+			end
+		end
+
+	end
+end