/src/ChorusThreatFrameTemplate.lua (7d348008a9e32cb13ad031424e319ea089da7579) (2274 bytes) (mode 100644) (type blob)
--[[--
`ChorusThreatFrameTemplate` displays a color coded pictogram for general threat
situation for the corresponding unit and the player character.
@submodule chorus
]]
local Chorus = Chorus
local GetThreatStatusColor = GetThreatStatusColor
local UnitExists = Chorus.test.UnitExists or UnitExists
local UnitIsConnected = Chorus.test.UnitIsConnected or UnitIsConnected
local UnitIsFriend = Chorus.test.UnitIsFriend or UnitIsFriend
local UnitThreatSituation = UnitThreatSituation
local SecureButton_GetUnit = Chorus.test.SecureButton_GetUnit or SecureButton_GetUnit
local function threatFrameEventProcessor(self)
assert(self ~= nil)
local unitButton = self:GetParent()
assert(unitButton ~= nil)
local u = SecureButton_GetUnit(self) or 'none'
assert(u ~= nil)
if UnitExists(u) and UnitIsConnected(u) then
self:Show()
else
self:Hide()
return
end
local threatStatus, threatPercentage
local owner = 'player'
if UnitIsFriend(owner, u) then
threatStatus = UnitThreatSituation(u)
else
local _, threatStatus0, threatPercentage0 = UnitDetailedThreatSituation(owner, u)
threatStatus = threatStatus0
threatPercentage = threatPercentage0
end
local r = 0
local g = 0
local b = 0
local a = 0
if threatStatus then
r, g, b = GetThreatStatusColor(threatStatus)
a = 1
end
local artwork = self.artwork
assert (artwork ~= nil)
artwork:SetVertexColor(r, g, b, a)
local label = self.label or _G[self:GetName() .. 'Text']
if label and threatPercentage then
assert('number' == type(threatPercentage))
assert(threatPercentage >= 0)
label:SetText(string.format('%d%%', threatPercentage))
elseif label then
label:SetText(nil)
end
end
local function threatFrameMain(self)
assert(self ~= nil)
local artwork = _G[self:GetName() .. 'Artwork']
assert(artwork ~= nil)
self.artwork = artwork
self:RegisterEvent('PARTY_MEMBERS_CHANGED')
self:RegisterEvent('PLAYER_ALIVE')
self:RegisterEvent('PLAYER_ENTERING_WORLD')
self:RegisterEvent('PLAYER_FOCUS_CHANGED')
self:RegisterEvent('PLAYER_TARGET_CHANGED')
self:RegisterEvent('RAID_ROSTER_UPDATE')
self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE')
self:SetScript('OnEvent', threatFrameEventProcessor)
end
Chorus.threatFrameMain = function(...)
return threatFrameMain(...)
end
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
35 |
5c40e6e2862d70b5c51c326a13073a4012ac05c7 |
.gitignore |
100644 |
blob |
3606 |
f73da473168d1897963fd2e32d89841ca0461ec0 |
README.adoc |
040000 |
tree |
- |
271296b4bafcaa151458a0192fd313641ca9b409 |
bin |
100644 |
blob |
228 |
c7dd24afa7d5c2375ff60a91c73623a304b808f9 |
chorus.toc |
040000 |
tree |
- |
99c99c3cbc641f8954a5be291e61681cb5e74629 |
conf |
040000 |
tree |
- |
efa7258757edf7b888ea13c215e14b497fef8a16 |
doc |
100644 |
blob |
2391 |
1b0ca1bc25f74a34476360e5a8f14e28767b204e |
makefile |
040000 |
tree |
- |
b9d3ea9d61b99ee71b5fcdbc6b18843df20c8c3c |
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