Quantcast

Dungeons roles

F. Dekker [04-21-13 - 11:53]
Dungeons roles
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 df35232..6781956 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -159,6 +159,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",
@@ -167,6 +169,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 8cc4dcf..e24dafa 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 33a2238..c1b6db7 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -28,3 +28,4 @@ PerfectRaid_Range.lua
 PerfectRaid_Highlight.lua
 PerfectRaid_Config.lua
 PerfectRaid_RaidIcons.lua
+PerfectRaid_Roles.lua
diff --git a/PerfectRaid_Config.lua b/PerfectRaid_Config.lua
index 5abaf80..5dc5cab 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()
@@ -105,6 +125,10 @@ function Config:CreateOptions(opt)
 		local clickCast = PRConfig_ClickCast:GetChecked() and true or false
 		local locked = PRConfig_Lock:GetChecked() and true or false
 		local showRaidIcons = PRConfig_RaidIcons: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
@@ -112,6 +136,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:TriggerMessage("PERFECTRAID_CONFIG_CHANGED")
@@ -124,6 +152,10 @@ function Config:CreateOptions(opt)
 		PRConfig_ClickCast:SetChecked(PerfectRaid.db.profile.clickcast)
 		PRConfig_Lock:SetChecked(PerfectRaid.db.profile.locked)
 		PRConfig_RaidIcons:SetChecked(PerfectRaid.db.profile.showraidicons)
+		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

@@ -138,7 +170,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..f604eea
--- /dev/null
+++ b/PerfectRaid_Roles.lua
@@ -0,0 +1,110 @@
+--[[-------------------------------------------------------------------------
+  *
+  * 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.raidrole:SetPoint("RIGHT", -3-frame.name:GetWidth(), 0)
+
+					frame.raidroletex = frame.raidrole:CreateTexture(nil, "OVERLAY")
+					frame.raidroletex:SetAllPoints()
+					frame.raidroletex:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES")
+				end
+
+				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