Skip to content

Commit

Permalink
voice color supports team changes now
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll committed Apr 12, 2024
1 parent 5fcd4f4 commit 86881f4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
16 changes: 0 additions & 16 deletions gamemodes/terrortown/gamemode/client/cl_player_ext.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,6 @@ function plymeta:IsSpeakingInVoice()
return self.speaking or false
end

---
-- Sets the color of the voice panel.
-- @param Color color The color of the voice panel
-- @realm client
function plymeta:SetVoiceColor(color)
self.voiceColor = color
end

---
-- Returns the color of the voice panel.
-- @return Color The color of the voice panel
-- @realm client
function plymeta:GetVoiceColor()
return self.voiceColor or INNOCENT.color
end

-- Creates an elliptic nick for a given length.
-- @param number width The maximum width that should be used to limit the nick
-- @param[default="DefaultBold"] string font The font ID
Expand Down
31 changes: 31 additions & 0 deletions gamemodes/terrortown/gamemode/client/cl_voice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ local player = player
local IsValid = IsValid
local hook = hook

VOCIE_MODE_GLOBAL = 0
VOICE_MODE_TEAM = 1

-- voicechat stuff
VOICE = {}

Expand Down Expand Up @@ -144,6 +147,34 @@ function VOICE.GetFakeVoiceSpectrum(ply, stepCount)
return ply.lastSteps
end

---
-- Sets the mode of the voice panel.
-- @param number mode The voice mode
-- @realm client
function VOICE.SetVoiceMode(ply, mode)

Check failure on line 154 in gamemodes/terrortown/gamemode/client/cl_voice.lua

View workflow job for this annotation

GitHub Actions / doc-check

Param mismatch --> "In 'function' datastructure ('function VOICE.SetVoiceMode(ply, mode)'), detected params (1): " "- 'mode'" "Expected Params (2): " "- 'ply'" "- 'mode'"
self.voiceMode = mode
end

---
-- Returns the mode of the voice panel.
-- @return number The mode of the voice panel
-- @realm client
function VOICE.GetVoiceMode(ply)

Check failure on line 162 in gamemodes/terrortown/gamemode/client/cl_voice.lua

View workflow job for this annotation

GitHub Actions / doc-check

Param mismatch --> "In 'function' datastructure ('function VOICE.GetVoiceMode(ply)'), detected params (0): " "Expected Params (1): " "- 'ply'"
return ply.voiceMode or VOICE_MODE_GLOBAL
end

---
-- Returns the color of the voice panel.
-- @return Color The color of the voice panel
-- @realm client
function VOICE.GetVoiceColor(ply)

Check failure on line 170 in gamemodes/terrortown/gamemode/client/cl_voice.lua

View workflow job for this annotation

GitHub Actions / doc-check

Param mismatch --> "In 'function' datastructure ('function VOICE.GetVoiceColor(ply)'), detected params (0): " "Expected Params (1): " "- 'ply'"
if VOICE.GetVoiceMode(ply) then
return INNOCENT.color
else
TEAMS[ply:GetTeam()].color
end

Check failure on line 175 in gamemodes/terrortown/gamemode/client/cl_voice.lua

View workflow job for this annotation

GitHub Actions / lint

"Parse error"

unexpected end expecting indexation or function call
end

---
-- Creates a closure that dynamically calls a function from VOICE.ActivationModes depending on the current mode.
-- @param string func The name of the function to call on the current voice activation mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if CLIENT then
end

function HUDELEMENT:DrawVoiceBar(ply, xPos, yPos, w, h)
local color = ply:GetVoiceColor()
local color = VOICE.GetVoiceColor(ply)
local data = VOICE.GetFakeVoiceSpectrum(ply, 24)

local widthBar = (w - h - self.padding) / #data - 1
Expand Down

0 comments on commit 86881f4

Please sign in to comment.