Loading...

Update Tukui_RoleIcons for Tukui 18

#1
in preparation for BFA and the adjustments made in Tukui 18 I'm struggling with the following...

lfdrole.lua has been removed from the Tukui\Libs\oUF\elements folder. This was the oUF part that (i guess) made it possible to set RoleIcons on our raidframes.
I have no trouble updating the code for the RoleIcons. Something like this including options I'm adding. If I copy the lfdrole.lua from Tukui 17 into Tukui 18, edit the .xml to load this like before, it all works like it should. But I'm looking for a way not to do that and to add/implement the lfdrole.lua into this seperate addon. But failing at it...

If I put lfdrole.lua into this small addon, load it from the .toc or a .xml you'll get an error saying it can't find the local oUF at the end...

I guess my knowledge is still to limited thus asking for help/a fix.

Code: Select all

---------------------------------------------------------------
-- Tukui RoleIcons
---------------------------------------------------------------
local T, C, L = Tukui:unpack()
local UnitFrames = T.UnitFrames

---------------------------------------------------------------
-- Tukui RoleIcons OPTIONS
---------------------------------------------------------------
C["RollIcons"] = {
	["CustomIcons"] = true,
	["IconSize"] = 18,
	["Position"] = {
		["Options"] = {
			["Top"] = "Top",
			["Center"] = "Center",
			["Left"] = "Right",
			["Right"] = "Large",
		},
		["Value"] = "Top",
	},
}

local RollIcons = {
		["CustomIcons"] = {
			["Name"] = "Custom Made Roll Icons",
			["Desc"] = "Enable/Disable the custom Roll Icons for Tukui",
		},

		["IconSize"] = {
			["Name"] = "Icon Size",
			["Desc"] = "Set a value for the Icon Size",
		},
	
		["Position"] = {
			["Name"] = "Position",
			["Desc"] = "Set a the position of the Roll Icon",
		},
	}
TukuiConfig.enUS["RollIcons"] = RollIcons

---------------------------------------------------------------
-- Function
---------------------------------------------------------------
function T.UnitFrames:SetGridGroupRole()
	local LFDRole = self.LFDRole
	local Role = UnitGroupRolesAssigned(self.unit)

	if Role == "TANK" then
		LFDRole:SetTexture("Interface\\AddOns\\Tukui_RoleIcons\\Textures\\tank2.tga")
		LFDRole:Show()
	elseif Role == "HEALER" then
		LFDRole:SetTexture("Interface\\AddOns\\Tukui_RoleIcons\\Textures\\healer3.tga")
		LFDRole:Show()
	elseif Role == "DAMAGER" then
		LFDRole:SetTexture("Interface\\AddOns\\Tukui_RoleIcons\\Textures\\dps2.tga")
		LFDRole:Show()
	else
		LFDRole:Hide()
	end
end

---------------------------------------------------------------
-- RoleIcons
---------------------------------------------------------------
local function Raid(self)
	local Health = self.Health
	local IconSize = C["RollIcons"]["IconSize"]
	local LFDRole = Health:CreateTexture(nil, "OVERLAY")
	LFDRole:Size(IconSize)
	
	LFDRole:SetPoint("TOP", Health, 0, 5)
	--LFDRole:SetPoint("CENTER", Health, 0, 0)
	--LFDRole:SetPoint("RIGHT", Health, -2, 0)
	--LFDRole:SetPoint("LEFT", Health, 2, 0)
	
	LFDRole.Override = T.UnitFrames.SetGridGroupRole
	self.LFDRole = LFDRole
end
hooksecurefunc(T.UnitFrames, "Raid", Raid)
the original lfdrole.lua

Code: Select all

--[[ Element: LFD Role Icon

 Toggles visibility of the LFD role icon based upon the units current dungeon
 role.

 Widget

 LFDRole - A Texture containing the LFD role icons at specific locations. Look
           at the default LFD role icon texture for an example of this.
           Alternatively you can look at the return values of
           GetTexCoordsForRoleSmallCircle(role).

 Notes

 The default LFD role texture will be applied if the UI widget is a texture and
 doesn't have a texture or color defined.

 Examples

   -- Position and size
   local LFDRole = self:CreateTexture(nil, "OVERLAY")
   LFDRole:SetSize(16, 16)
   LFDRole:SetPoint("LEFT", self)
   
   -- Register it with oUF
   self.LFDRole = LFDRole

 Hooks

 Override(self) - Used to completely override the internal update function.
                  Removing the table key entry will make the element fall-back
                  to its internal function again.
]]

local parent, ns = ...
local oUF = ns.oUF

local Update = function(self, event)
	local lfdrole = self.LFDRole
	if(lfdrole.PreUpdate) then
		lfdrole:PreUpdate()
	end

	local role = UnitGroupRolesAssigned(self.unit)
	if(role == 'TANK' or role == 'HEALER' or role == 'DAMAGER') then
		lfdrole:SetTexCoord(GetTexCoordsForRoleSmallCircle(role))
		lfdrole:Show()
	else
		lfdrole:Hide()
	end

	if(lfdrole.PostUpdate) then
		return lfdrole:PostUpdate(role)
	end
end

local Path = function(self, ...)
	return (self.LFDRole.Override or Update) (self, ...)
end

local ForceUpdate = function(element)
	return Path(element.__owner, 'ForceUpdate')
end

local Enable = function(self)
	local lfdrole = self.LFDRole
	if(lfdrole) then
		lfdrole.__owner = self
		lfdrole.ForceUpdate = ForceUpdate

		if(self.unit == "player") then
			self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Path, true)
		else
			self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true)
		end

		if(lfdrole:IsObjectType"Texture" and not lfdrole:GetTexture()) then
			lfdrole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]
		end

		return true
	end
end

local Disable = function(self)
	local lfdrole = self.LFDRole
	if(lfdrole) then
		lfdrole:Hide()
		self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Path)
		self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path)
	end
end

oUF:AddElement('LFDRole', Path, Enable, Disable)
Maximvs-Aszune, MaxUI

Who is online

Users browsing this forum: No registered users and 1 guest