Skip to content

Commit

Permalink
call detective button gryed out + infobox
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll committed Oct 8, 2023
1 parent 79dcd1f commit 4dcc9f2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
39 changes: 35 additions & 4 deletions gamemodes/terrortown/gamemode/client/cl_search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ function SEARCHSCRN:CalculateSizes()
self.sizes.heightInfoItem = 78
end

function SEARCHSCRN:MakeInfoItem(parent, name, data)
function SEARCHSCRN:MakeInfoItem(parent, name, data, height)

Check failure on line 206 in gamemodes/terrortown/gamemode/client/cl_search.lua

View workflow job for this annotation

GitHub Actions / doc-check

Missing essential param --> "Missing '@realm' in function 'SEARCHSCRN:MakeInfoItem'"

Check failure on line 206 in gamemodes/terrortown/gamemode/client/cl_search.lua

View workflow job for this annotation

GitHub Actions / doc-check

Param mismatch --> "In 'function' datastructure ('function SEARCHSCRN:MakeInfoItem(parent, name, data, height)'), detected params (0): " "Expected Params (4): " "- 'parent'" "- 'name'" "- 'data'" "- 'height'"
local box = vgui.Create("DInfoItemTTT2", parent)
box:SetSize(self.sizes.widthContentBox, self.sizes.heightInfoItem)
box:SetSize(self.sizes.widthContentBox, height or self.sizes.heightInfoItem)
box:Dock(TOP)
box:DockMargin(0, 0, 0, self.sizes.padding)
box:SetData(data)
Expand Down Expand Up @@ -262,6 +262,25 @@ function SEARCHSCRN:Show(data)
contentAreaScroll:SetSize(self.sizes.widthContentArea, self.sizes.heightMainArea)
contentAreaScroll:Dock(RIGHT)

-- POPULATE WITH SPECIAL INFORMATION
if data.owner and IsValid(data.owner) and not data.owner:TTT2NETGetBool("body_found", false) then
-- a detective can only be called AFTER a body was confirmed

self:MakeInfoItem(contentAreaScroll, "detective_call_confirm", {
text = {
title = {
body = "search_title_detective_call_confirm",
params = nil
},
text = {{
body = "search_detective_call_confirm",
params = nil
}}
},
colorBox = roles.DETECTIVE.ltcolor
}, 62)
end

-- POPULATE WITH INFORMATION
for i = 1, #bodysearch.searchResultOrder do
local searchResultName = bodysearch.searchResultOrder[i]
Expand Down Expand Up @@ -299,6 +318,10 @@ function SEARCHSCRN:Show(data)
end
buttonCall:SetIcon(roles.DETECTIVE.iconMaterial, true, 16)

if client:IsSpec() or data.owner and IsValid(data.owner) and not data.owner:TTT2NETGetBool("body_found", false) then
buttonCall:SetEnabled(false)
end

local buttonConfirm = vgui.Create("DButtonTTT2", buttonArea)

if client:IsSpec() then
Expand Down Expand Up @@ -333,10 +356,18 @@ function SEARCHSCRN:Show(data)
RunConsoleCommand("ttt_confirm_death", data.eidx, data.eidx + data.dtime, data.lrng)

local creditBox = self.infoBoxes["credits"]

if (IsValid(creditBox) and btn.player_can_take_credits) then
if IsValid(creditBox) and btn.player_can_take_credits then
creditBox:Remove()
end

local confirmBox = self.infoBoxes["detective_call_confirm"]
if IsValid(confirmBox) then
confirmBox:Remove()
end

if not client:IsSpec() then
buttonCall:SetEnabled(true)
end
end

self.buttonConfirm = buttonConfirm
Expand Down
10 changes: 7 additions & 3 deletions gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,8 @@ end
-- @param number h
-- @realm client
function SKIN:PaintInfoItemTTT2(panel, w, h)
local hasIcon = panel:HasIcon()

local padding = 5

local widthBorder = 2
Expand All @@ -1629,7 +1631,7 @@ function SKIN:PaintInfoItemTTT2(panel, w, h)
local sizeIcon = 64
local posIcon = widthBorder + padding

local posText = posIcon + sizeIcon + 2 * padding
local posText = hasIcon and (posIcon + sizeIcon + 2 * padding) or (posIcon + padding)
local heightText = 15

local colorBackground = panel:GetColor() or colors.settingsBox
Expand All @@ -1639,9 +1641,11 @@ function SKIN:PaintInfoItemTTT2(panel, w, h)
drawRoundedBox(sizes.cornerRadius, 0, 0, w, h, colorBorderDefault)
drawRoundedBox(sizes.cornerRadius, widthBorder, widthBorder, w - widthBorder2, h - widthBorder2, colorBackground)

drawFilteredTexture(posIcon, posIcon, sizeIcon, sizeIcon, panel:GetIcon())
if hasIcon then
drawFilteredTexture(posIcon, posIcon, sizeIcon, sizeIcon, panel:GetIcon())
end

if (panel:HasIconTextFunction()) then
if (hasIcon and panel:HasIconTextFunction()) then
local textString = panel:GetIconText()

local widthIconText = drawGetTextSize(textString, "DermaTTT2SmallBold")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ function PANEL:GetIcon()
return self.data.iconMaterial
end

---
-- @return boolean
-- @realm client
function PANEL:HasIcon()
return self.data.iconMaterial ~= nil
end

---
-- @return Color
-- @realm client
Expand Down
3 changes: 3 additions & 0 deletions lua/terrortown/lang/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,8 @@ L.search_hitgroup_rightleg = "The projectile was found in their right leg."
L.search_hitgroup_leftleg = "The projectile was found in their left leg."
L.search_hitgroup_gear = "The projectile was found in their hip."

L.search_detective_call_confirm = "A detective can only be called to a dead body after the corpse was confirmed dead."

L.search_title_words = "Victim's last words"
L.search_title_c4 = "Defusion mishap"
L.search_title_dmg_crush = "Crush damage ({amount} HP)"
Expand All @@ -1955,3 +1957,4 @@ L.search_title_eyes = "The killer's shadow"
L.search_title_floor = "Floor of the crime scene"
L.search_title_credits = "{credits} Equipment credit(s)"
L.search_title_water = "Water level {level}"
L.search_title_detective_call_confirm = "Confirm to call detective"
2 changes: 1 addition & 1 deletion lua/ttt2/libraries/bodysearch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ if CLIENT then
},
text = {{
body = floorIDToText[data.floorSurface],
params = {}
params = nil
}}
}
end,
Expand Down

0 comments on commit 4dcc9f2

Please sign in to comment.