diff --git a/gamemodes/terrortown/gamemode/client/cl_search.lua b/gamemodes/terrortown/gamemode/client/cl_search.lua index 1a07e5043..ada2cb021 100644 --- a/gamemodes/terrortown/gamemode/client/cl_search.lua +++ b/gamemodes/terrortown/gamemode/client/cl_search.lua @@ -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) 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) @@ -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] @@ -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 @@ -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 diff --git a/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua b/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua index 0b6e5483e..997188dc6 100644 --- a/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua +++ b/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua @@ -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 @@ -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 @@ -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") diff --git a/gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dinfoitem_ttt2.lua b/gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dinfoitem_ttt2.lua index 303c5aadf..0ae5947ac 100644 --- a/gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dinfoitem_ttt2.lua +++ b/gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dinfoitem_ttt2.lua @@ -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 diff --git a/lua/terrortown/lang/en.lua b/lua/terrortown/lang/en.lua index 799afc74e..e2665eb69 100644 --- a/lua/terrortown/lang/en.lua +++ b/lua/terrortown/lang/en.lua @@ -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)" @@ -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" diff --git a/lua/ttt2/libraries/bodysearch.lua b/lua/ttt2/libraries/bodysearch.lua index effc1ed6e..9f9ed6d51 100644 --- a/lua/ttt2/libraries/bodysearch.lua +++ b/lua/ttt2/libraries/bodysearch.lua @@ -309,7 +309,7 @@ if CLIENT then }, text = {{ body = floorIDToText[data.floorSurface], - params = {} + params = nil }} } end,