vrtc / chorus (public) (License: CC0) (since 2023-08-12) (hash sha1)
World of Warcraft add-on stub. The overall goal is to create a specialized raid frame.

/src/ChorusUnitNameFrameTemplate.lua (51cb554f698bafa2611a38ef22a7ca8d06fc25a7) (2277 bytes) (mode 100644) (type blob)

local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local UnitClass = UnitClass
local UnitIsPlayer = UnitIsPlayer
local UnitName = UnitName

local Chorus = Chorus

local function unitNameEventProcessor(self)
	assert(self ~= nil)

	local label = self.label
	assert(label ~= nil)

	local unitDesignation = SecureButton_GetUnit(self) or 'none'
	assert(unitDesignation ~= nil)
	assert('string' == type(unitDesignation))
	unitDesignation = string.lower(strtrim(unitDesignation))
	assert(string.len(unitDesignation) >= 1)
	assert(string.len(unitDesignation) <= 256)

	local name = UnitName(unitDesignation)
	label:SetText(name)

	if UnitIsConnected(unitDesignation) and UnitExists(unitDesignation) then
		label:SetTextColor(1, 1, 1)
	else
		label:SetTextColor(0.7, 0.7, 0.7)
		return
	end

	if not self.strategy then
		return
	elseif 'UnitClass' ~= self.strategy then
		return
	end

	local _, classDesignation = UnitClass(unitDesignation)
	if not classDesignation or not UnitIsPlayer(unitDesignation) then
		label:SetTextColor(1, 1, 1)
		return
	end

	local map = RAID_CLASS_COLORS
	assert(map ~= nil)
	assert('table' == type(map))
	local colorTuple = map[classDesignation]

	local r = 1
	local g = 1
	local b = 1
	if colorTuple then
		assert('table' == type(colorTuple))
		r = math.min(math.max(0, math.abs(colorTuple.r)), 1)
		g = math.min(math.max(0, math.abs(colorTuple.g)), 1)
		b = math.min(math.max(0, math.abs(colorTuple.b)), 1)
	end

	label:SetTextColor(r, g, b)
end

function Chorus.unitNameFrameMain(self)
	assert(self ~= nil)

	local label = _G[self:GetName() .. 'Text']
	assert(label ~= nil)
	self.label = label

	--[[ FIXME Sometimes some unit buttons in raid frames cannot be clicked. ]]--
	self:SetScript('OnEvent', unitNameEventProcessor)

	self:RegisterEvent('PARTY_CONVERTED_TO_RAID')
	self:RegisterEvent('PARTY_MEMBERS_CHANGED')
	self:RegisterEvent('PARTY_MEMBER_DISABLE')
	self:RegisterEvent('PARTY_MEMBER_ENABLE')
	self:RegisterEvent('PLAYER_ALIVE')
	self:RegisterEvent('PLAYER_ENTERING_WORLD')
	self:RegisterEvent('PLAYER_FOCUS_CHANGED')
	self:RegisterEvent('PLAYER_LOGIN')
	self:RegisterEvent('PLAYER_LOGOUT')
	self:RegisterEvent('PLAYER_TARGET_CHANGED')
	self:RegisterEvent('RAID_ROSTER_UPDATE')
	self:RegisterEvent('UNIT_NAME_UPDATE')

	RegisterUnitWatch(self)
end


Mode Type Size Ref File
100644 blob 22 d7f81b36af99095409dbf9a7a92e18a5c74e5ff5 .gitignore
100644 blob 2761 8660a7b6b158b3d7c82af258020ea93722ae2bee README.md
040000 tree - 386cdd1448b396d67052c9c421df4d307621c280 bin
100644 blob 376 7c6577431ffa8a42b6e2570c37b2e7bbe6f952ce chorus-0.2-1.rockspec
100644 blob 111 b22afedfa744551589b080882fdc70c11ab6b17d chorus.toc
040000 tree - cac8af7ca5d8adc7771598e6faae482998b25fa2 doc
040000 tree - b30875c0405a889b8e1ef8838ccd70adde587bdd etc
040000 tree - 89b0ab39d95faab01a754a25f5a5269d5f5bbcea rocketgit
040000 tree - 5b8dd064c04749cf19281ed90842d3996ad61dc6 share
040000 tree - 17333a2ce6b635748cd2f722d7073f41e6fe79b4 src
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/chorus

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/chorus

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/chorus

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main