Skip to content

Commit

Permalink
infobox mockup
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll committed Oct 6, 2023
1 parent 823654a commit 49babe3
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 2 deletions.
1 change: 1 addition & 0 deletions gamemodes/terrortown/gamemode/client/cl_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ttt_include("cl_vskin__vgui__drolelayeringreceiver")
ttt_include("cl_vskin__vgui__drolelayeringsender")
ttt_include("cl_vskin__vgui__dsearchbar")
ttt_include("cl_vskin__vgui__dprofilepanel")
ttt_include("cl_vskin__vgui__dinfoicon")
ttt_include("cl_vskin__vgui__dsubmenulist")

ttt_include("cl_changes")
Expand Down
106 changes: 104 additions & 2 deletions gamemodes/terrortown/gamemode/client/cl_search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ function SEARCHSCRN:CalculateSizes()
self.sizes.heightMainArea = self.sizes.height - self.sizes.heightBottomButtonPanel - 3 * self.sizes.padding - vskin.GetHeaderHeight() - vskin.GetBorderSize()

self.sizes.widthProfileArea = 200

self.sizes.widthContentArea = self.sizes.width - self.sizes.widthProfileArea - 3 * self.sizes.padding
self.sizes.widthContentBox = self.sizes.widthContentArea - 2 * self.sizes.padding - 100
end

function SEARCHSCRN:Show()
Expand Down Expand Up @@ -777,8 +780,107 @@ function SEARCHSCRN:Show()
profileBox:SetModel(self.data.player:GetModel())
profileBox:SetPlayer(LocalPlayer())

-- BUTTONS --

-- ADD STATUS BOX AND ITS CONTENT
local contentAreaScroll = vgui.Create("DScrollPanelTTT2", contentBox)
contentAreaScroll:SetVerticalScrollbarEnabled(true)
contentAreaScroll:SetSize(self.sizes.widthContentArea, self.sizes.heightMainArea)
contentAreaScroll:Dock(RIGHT)

--[[local scrollAreaIconLayout = vgui.Create("DIconLayout", contentAreaScroll)
scrollAreaIconLayout:SetSpaceY(0)
scrollAreaIconLayout:SetSpaceX(0)
local card1 = scrollAreaIconLayout:Add("DInfoItemTTT2")
card1:SetSize(300, 78)
card1:SetIcon(profileBox:GetPlayerIcon())
card1:SetText("data.label")
card1.color = COLOR_WHITE
local card2 = scrollAreaIconLayout:Add("DInfoItemTTT2")
card2:SetSize(self.sizes.widthContentArea, 78)
card2:SetIcon(profileBox:GetPlayerIcon())
card2:SetText("data.label")
card2.color = COLOR_RED
local card3 = scrollAreaIconLayout:Add("DInfoItemTTT2")
card3:SetSize(self.sizes.widthContentArea, 78)
card3:SetIcon(profileBox:GetPlayerIcon())
card3:SetText("data.label")
card3.color = COLOR_ORANGE
local card4 = scrollAreaIconLayout:Add("DInfoItemTTT2")
card4:SetSize(self.sizes.widthContentArea, 78)
card4:SetIcon(profileBox:GetPlayerIcon())
card4:SetText("data.label")
card4.color = COLOR_YELLOW
local card5 = scrollAreaIconLayout:Add("DInfoItemTTT2")
card5:SetSize(self.sizes.widthContentArea, 78)
card5:SetIcon(profileBox:GetPlayerIcon())
card5:SetText("data.label")
card5.color = COLOR_BLUE]]

local box1 = vgui.Create("DInfoItemTTT2", contentAreaScroll)
box1:SetSize(self.sizes.widthContentBox, 78)
box1:Dock(TOP)
box1:DockMargin(0, 0, 0, 10)
box1.color = COLOR_YELLOW
local box2 = vgui.Create("DInfoItemTTT2", contentAreaScroll)
box2:SetSize(self.sizes.widthContentBox, 78)
box2:Dock(TOP)
box2:DockMargin(0, 0, 0, 10)
box2.color = COLOR_RED
local box3 = vgui.Create("DInfoItemTTT2", contentAreaScroll)
box3:SetSize(self.sizes.widthContentBox, 78)
box3:Dock(TOP)
box3:DockMargin(0, 0, 0, 10)
box3.color = COLOR_BLUE
local box4 = vgui.Create("DInfoItemTTT2", contentAreaScroll)
box4:SetSize(self.sizes.widthContentBox, 78)
box4:Dock(TOP)
box4:DockMargin(0, 0, 0, 10)
box4.color = COLOR_ORANGE
--[[local box5 = vgui.Create("DInfoItemTTT2", contentAreaScroll)
box5:SetSize(self.sizes.widthContentBox, 78)
box5:Dock(TOP)
--box5:SetPadding(0, 0, 0, 10)
box5.color = COLOR_GREEN]]

--[[
local form = vgui.CreateTTT2Form(contentAreaScroll, "Dead Player Info")
form:SetPadding(0)
form:SetSpacing(0)
form:SetSize(self.sizes.widthContentArea, self.sizes.heightMainArea)
form:Dock(TOP)
local base = form:MakeIconLayout()
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)
form:MakeInfoItem({
label = "item.shopTitle",
icon = profileBox:GetPlayerIcon(),
}, base)]]

-- BUTTONS
local buttonArea = vgui.Create("DButtonPanelTTT2", frame)
buttonArea:SetSize(self.sizes.width, self.sizes.heightBottomButtonPanel)
buttonArea:Dock(BOTTOM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1561,5 +1561,14 @@ function SKIN:PaintProfilePanelTTT2(panel, w, h)
)
end

---
-- @param Panel panel
-- @param number w
-- @param number h
-- @realm client
function SKIN:PaintInfoItemTTT2(panel, w, h)
drawRoundedBox(sizes.cornerRadius, 0, 0, w, h, panel.color)
end

-- REGISTER DERMA SKIN
derma.DefineSkin(SKIN.Name, "TTT2 default skin for all vgui elements", SKIN)
17 changes: 17 additions & 0 deletions gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dform_ttt2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,23 @@ function PANEL:MakeCard(data, base)
return card
end

---
-- Adds a new info icon box to the form.
-- @param table data The data for the card
-- @param PANEL base The base Panel (DIconLayout) where this card will be added
-- @param[default=78] number height The height of the info icon box
-- @return Panel The created card
-- @realm client
function PANEL:MakeInfoItem(data, base, height)
local card = base:Add("DInfoItemTTT2")

card:SetSize(base:GetWide(), height or 78)
card:SetIcon(data.icon)
card:SetText(data.label)

return card
end

---
-- Adds a new image check box to the form.
-- @param table data The data for the image check box
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
-- @class PANEL
-- @section DCardTTT2

local PANEL = {}

---
-- @ignore
function PANEL:Init()
self:SetContentAlignment(5)

self:SetTall(22)
self:SetMouseInputEnabled(true)
self:SetKeyboardInputEnabled(true)

self.data = {
title = "",
icon = nil
}
end

---
-- @param string text
-- @realm client
function PANEL:SetText(text)
self.data.text = text
end

---
-- @return string
-- @realm client
function PANEL:GetText()
return self.data.text
end

---
-- @param Material icon
-- @realm client
function PANEL:SetIcon(icon)
self.data.icon = icon
end

---
-- @return Matieral
-- @realm client
function PANEL:GetIcon()
return self.data.icon
end

---
-- @ignore
function PANEL:Paint(w, h)
derma.SkinHook("Paint", "InfoItemTTT2", self, w, h)

return false
end

derma.DefineControl("DInfoItemTTT2", "A special info box used for body search info", PANEL, "DPanelTTT2")
1 change: 1 addition & 0 deletions gamemodes/terrortown/gamemode/shared/sh_include.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ TTTFiles = {
cl_vskin__vgui__drolelayeringsender = {file = "cl_vskin/vgui/drolelayeringsender_ttt2.lua", on = "client"},
cl_vskin__vgui__dsearchbar = {file = "cl_vskin/vgui/dsearchbar_ttt2.lua", on = "client"},
cl_vskin__vgui__dsubmenulist = {file = "cl_vskin/vgui/dsubmenulist_ttt2.lua", on = "client"},
cl_vskin__vgui__dinfoicon = {file = "cl_vskin/vgui/dinfoicon_ttt2.lua", on = "client"},
cl_vskin__vgui__dprofilepanel = {file = "cl_vskin/vgui/dprofilepanel_ttt2.lua", on = "client"}
}

Expand Down

0 comments on commit 49babe3

Please sign in to comment.