Skip to content

Commit cb34ac0

Browse files
TimGollnike4613
andauthored
vgui: Toggleable Role Indicator (#1724)
Added option to show and hide these indicators for `DRoleImageTTT2`. ![image](https://github.com/user-attachments/assets/87a6d233-2cf3-411b-a730-a1d4e923ef60) --------- Co-authored-by: nike4613 <danike@cirr.com>
1 parent c70a015 commit cb34ac0

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,8 +1723,9 @@ end
17231723
function SKIN:PaintRoleImageTTT2(panel, w, h)
17241724
local widthBorder = 2
17251725
local widthBorder2 = widthBorder * 2
1726+
local sizeIconRole = w - widthBorder2
17261727
local padding = 3
1727-
local sizeMode = 18
1728+
local sizeMode = 18 * w / 64
17281729
local sizeIconMode = sizeMode - 2 * padding
17291730
local posIconModeX = w - sizeMode + padding
17301731
local posIconModeY = h - sizeMode + padding
@@ -1744,23 +1745,31 @@ function SKIN:PaintRoleImageTTT2(panel, w, h)
17441745

17451746
local colorBorderIcon = utilGetDefaultColor(colorBorder)
17461747

1747-
drawRoundedBox(sizes.cornerRadius, 0, 0, w, h, colorBorder)
1748+
if panel:GetIsActiveIndicator() then
1749+
drawRoundedBox(sizes.cornerRadius, 0, 0, w, h, colorBorder)
17481750

1749-
drawRoundedBox(
1750-
sizes.cornerRadius,
1751-
widthBorder,
1752-
widthBorder,
1753-
w - widthBorder2,
1754-
h - widthBorder2,
1755-
colorBackground
1756-
)
1751+
drawRoundedBox(
1752+
sizes.cornerRadius,
1753+
widthBorder,
1754+
widthBorder,
1755+
w - widthBorder2,
1756+
h - widthBorder2,
1757+
colorBackground
1758+
)
1759+
else
1760+
drawRoundedBox(sizes.cornerRadius, 0, 0, w, h, colorBackground)
1761+
1762+
widthBorder = 0
1763+
widthBorder2 = 0
1764+
sizeIconRole = w
1765+
end
17571766

17581767
if panel:GetValue() then
17591768
drawFilteredShadowedTexture(
17601769
widthBorder,
17611770
widthBorder,
1762-
w - widthBorder2,
1763-
h - widthBorder2,
1771+
sizeIconRole - widthBorder2,
1772+
sizeIconRole - widthBorder2,
17641773
panel:GetMaterial(),
17651774
colorIcon.a,
17661775
colorIcon
@@ -1769,14 +1778,18 @@ function SKIN:PaintRoleImageTTT2(panel, w, h)
17691778
drawFilteredTexture(
17701779
widthBorder,
17711780
widthBorder,
1772-
w - widthBorder2,
1773-
h - widthBorder2,
1781+
sizeIconRole - widthBorder2,
1782+
sizeIconRole - widthBorder2,
17741783
panel:GetMaterial(),
17751784
colorIcon.a * 0.5,
17761785
colorIcon
17771786
)
17781787
end
17791788

1789+
if not panel:GetIsActiveIndicator() then
1790+
return
1791+
end
1792+
17801793
drawRoundedBoxEx(
17811794
sizes.cornerRadius,
17821795
w - sizeMode,

gamemodes/terrortown/gamemode/client/cl_vskin/vgui/droleimage_ttt2.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function PANEL:Init()
99
self.data = {
1010
color = COLOR_WHITE,
1111
icon = nil,
12+
indicatorState = false,
1213
}
1314
end
1415

@@ -49,6 +50,20 @@ function PANEL:DoRightClick()
4950
self:ValueChanged(newValue)
5051
end
5152

53+
---
54+
-- @param boolean state
55+
-- @realm client
56+
function PANEL:SetIsActiveIndicator(state)
57+
self.data.indicatorState = state
58+
end
59+
60+
---
61+
-- @return boolean
62+
-- @realm client
63+
function PANEL:GetIsActiveIndicator()
64+
return self.data.indicatorState or false
65+
end
66+
5267
---
5368
-- @ignore
5469
function PANEL:Paint(w, h)

lua/terrortown/menus/gamemode/roles/rolelayering.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ hook.Add("TTT2ReceivedRolelayerData", "received_layer_data", function(role, laye
153153
ic:SetTooltip(roleData.name)
154154
ic:SetTooltipFixedPosition(0, 64)
155155
ic:SetServerConVar("ttt_" .. roleData.name .. "_enabled")
156+
ic:SetIsActiveIndicator(true)
156157

157158
ic.subrole = subrole
158159

0 commit comments

Comments
 (0)