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/ChorusFrame.lua (f3340f6841593ff9c4756545829f970d1db8d57d) (2836 bytes) (mode 100644) (type blob)

local UIParent = UIParent

local Chorus = Chorus

local function disableNativeFrames()
	local t = {
		FocusFrame,
		PlayerFrame,
		TargetFrame,
		PartyMemberFrame1,
		PartyMemberFrame2,
		PartyMemberFrame3,
		PartyMemberFrame4,
		PartyMemberBackground,
	}
	local i = 0
	while (i < #t) do
		i = i + 1
		local e = t[i]
		if e then
			e:Hide()
			e:HookScript('OnShow', function(self)
				self:Hide()
			end)
			--[[ Post-hook hack ]]--
			local v = e:GetScript('OnEvent')
			e:SetScript('OnEvent', function(self, ...)
				v(self, ...)
				self:Hide()
			end)
		end
	end
end

local function applyLayout(self)
	assert(self ~= nil)
	assert(UIParent ~= nil)

	self:UnregisterAllEvents();
	self:SetScript('OnEvent', nil)

	--[[ FIXME Range indicator shows false information. ]]--

	ChorusPlayerButtonHealthFrame.strategy = 'UnitClass'
	ChorusPlayerButton.menu = function()
		local offsetX = ChorusPlayerButton:GetWidth() / 2
		local offsetY = ChorusPlayerButton:GetHeight()
		ToggleDropDownMenu(1, nil, PlayerFrameDropDown, 'ChorusPlayerButton', offsetX, offsetY)
	end

	local focuscastModifier = GetModifiedClick('FOCUSCAST')
	if focuscastModifier and 'NONE' ~= focuscastModifier then
		local key = string.lower(focuscastModifier) .. '-type1'
		ChorusPlayerButton:SetAttribute(key, 'focus')
		ChorusTargetButton:SetAttribute(key, 'focus')
	end

	ChorusFocusButtonHealthFrame.strategy = 'UnitIsFriend'
	ChorusFocusButtonUnitNameFrame.strategy = 'UnitClass'

	ChorusTargetButtonHealthFrame.strategy = 'UnitIsFriend'
	ChorusTargetButtonUnitNameFrame.strategy = 'UnitClass'

	--[[ FIXME Selecting "Set focus" option in the context menu for Chorus
	unit button results in permission violation exception (restricted
	execution environment issue). ]]--

	ChorusTargetButton.menu = function()
		local offsetX = ChorusTargetButton:GetWidth() / 2
		local offsetY = ChorusTargetButton:GetHeight()
		ToggleDropDownMenu(1, nil, TargetFrameDropDown, 'ChorusTargetButton', offsetX, offsetY)
	end

	ChorusFocusButton.menu = function()
		local offsetX = ChorusFocusButton:GetWidth() / 2
		local offsetY = ChorusFocusButton:GetHeight()
		ToggleDropDownMenu(1, nil, FocusFrameDropDown, 'ChorusFocusButton', offsetX, offsetY)
	end

	--[[ NOTE The menu functions are equivalent of PlayerFrame.menu and
	TargetFrame.menu. It is possible to use them direcctly. THe only
	quirk is that the context menu will be displayed at the display point
	of the native unit frames. Hence, the need to define separate menu
	functions. ]]--
end

local function chorusFrameMain(self)
	--[[ Wait for the game to finish loading completely, only then apply
	changes. ]]--

	--[[ TODO Add pet buttons. ]]--

	self:RegisterEvent('PLAYER_LOGIN'); self:SetScript('OnEvent', applyLayout)

	disableNativeFrames()
end

Chorus.chorusFrameMain = function(...)
	return chorusFrameMain(...)
end


Mode Type Size Ref File
100644 blob 2761 8660a7b6b158b3d7c82af258020ea93722ae2bee README.md
040000 tree - 386cdd1448b396d67052c9c421df4d307621c280 bin
100644 blob 255 4ea44ab0938378fbfd697b6a70e318371d15570c chorus-0.1-1.rockspec
100644 blob 111 b22afedfa744551589b080882fdc70c11ab6b17d chorus.toc
040000 tree - de9110b7af6abd67b529e6b6a844de41c3d37373 etc
040000 tree - 5b8dd064c04749cf19281ed90842d3996ad61dc6 share
040000 tree - ee0d05f4e288db1bae1bc0d1b6582e34caea5c0c 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