Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VGui: Rework #1752

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3d81e10
reworked TTT2:DLabel
TimGoll Jan 30, 2025
53a7c8d
reverted tooltip check from recent PR
TimGoll Jan 30, 2025
b2aed66
deastically cleaned up TTT2:DPanel
TimGoll Jan 30, 2025
7be1a8f
removed duplication
TimGoll Jan 30, 2025
a8f8031
cleaned up inheritance names
TimGoll Jan 30, 2025
44c7e9a
started TTT2:DButton Rework
TimGoll Jan 30, 2025
7c4c4e0
renamed DButton
TimGoll Jan 30, 2025
144f7a2
reverted renaming in cl_changes
TimGoll Jan 30, 2025
95d18fb
no self
TimGoll Jan 30, 2025
e7091e9
reworked TTT2:DButton
TimGoll Jan 30, 2025
d276784
replaced DButtonPanelTTT2 with TTT2:DPanel
TimGoll Jan 30, 2025
252eee6
started with TTT2:DSubmenuButton
TimGoll Jan 31, 2025
caea88f
replaced RContentPanelTTT2 with TTT2:DPanel
TimGoll Jan 31, 2025
9a1a0b2
replaced DNavPanelTTT2 with TTT2:DPanel
TimGoll Jan 31, 2025
8f22f93
applied prepared changes to scoring
TimGoll Jan 31, 2025
8697e00
applied prepared changes to search
TimGoll Jan 31, 2025
c3b9c33
removed DColoredBox and DColoredTextBox in favor of TTT2:DPanel
TimGoll Feb 1, 2025
83d0a2b
refactored rendering & caching
TimGoll Feb 2, 2025
efd3100
Merge branch 'master' into vgui-method-chaining
TimGoll Feb 2, 2025
c00ee13
missing method chaining
TimGoll Feb 2, 2025
de92351
added support to actually render icon
TimGoll Feb 2, 2025
9d21cf8
support outlines; removed some skin functions
TimGoll Feb 2, 2025
529965f
fixed some dosc
TimGoll Feb 2, 2025
4aaa394
actually render outline
TimGoll Feb 2, 2025
11a8a03
included button color handling
TimGoll Feb 2, 2025
9a6541e
added pre and post render hooks for special cases
TimGoll Feb 2, 2025
b2e976d
added support for description lines
TimGoll Feb 2, 2025
a7088ce
removed menu button render hooks
TimGoll Feb 2, 2025
304a846
removed paint menu button
TimGoll Feb 3, 2025
a589d90
removed paint submennu button
TimGoll Feb 3, 2025
96e1d8f
loads of fixes
TimGoll Feb 4, 2025
c876c78
even more debugging
TimGoll Feb 4, 2025
4523f83
improved alpha attribute handling
TimGoll Feb 4, 2025
ea6d809
some minor bug fixes
TimGoll Feb 4, 2025
21ba6ff
some liniting tweaks
TimGoll Feb 4, 2025
fbb3d57
improved padding handling
TimGoll Feb 5, 2025
6f1808d
inheritance tests
TimGoll Feb 5, 2025
deee032
vastly simplified color handling
TimGoll Feb 5, 2025
03bfb3c
moved helpbox to new system
TimGoll Feb 5, 2025
0be0932
improved rounded corner support
TimGoll Feb 5, 2025
08e188f
added support for key bindings
TimGoll Feb 5, 2025
eb27f4f
more fixes
TimGoll Feb 6, 2025
6986a37
doc fixes
TimGoll Feb 6, 2025
af0d7c5
invalidate parent if size changed
TimGoll Feb 6, 2025
d2e6e2f
minor improvement on center alignment
TimGoll Feb 6, 2025
3a2fb3b
started fixing main menu
TimGoll Feb 6, 2025
66900d0
reintroduced color shift in a simplified way
TimGoll Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gamemodes/terrortown/gamemode/client/cl_changes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ function CreateChanges()
<li>A value of <code>0.13</code> ducks someone's volume at 90% down to effectively 78%, according to the client's scaling mode.</li>
</ul>
</ul>
<li>Added the option for <code>DButtonTTT2</code> to have an icon next to the title (by @TimGoll)</li>
<li>Added the option for <code>TTT2:DButtonTTT2</code> to have an icon next to the title (by @TimGoll)</li>
<li>Added a cached equipment item icon to its table as <code>.iconMaterial</code> (by @TimGoll)</li>
<li>Added a new <code>bodysearch</code> library that handles the search (by @TimGoll)</li>
<li>Completely reworked the body search UI (by @TimGoll)</li>
Expand Down
82 changes: 39 additions & 43 deletions gamemodes/terrortown/gamemode/client/cl_help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,27 @@ HELPSCRN.padding = 5

-- define sizes
local width, height = 1100, 700
local heightMainMenuButton = 120
local heightMainMenuButton = 110

local widthNav = 300
local widthContent, heightContent = 800, 700
local heightButtonPanel = 80
local heightAdminSeperator = 50
local sizeIcon = 64

local function AddMenuButtons(menuTbl, parent, widthButton, heightButton)
for i = 1, #menuTbl do
local menuClass = menuTbl[i]

local settingsButton = parent:Add("DMenuButtonTTT2")
settingsButton:SetSize(widthButton, heightButton)
settingsButton:SetTitle(menuClass.title or menuClass.type)
settingsButton:SetDescription(menuClass.description)
settingsButton:SetImage(menuClass.icon)

settingsButton.DoClick = function(slf)
HELPSCRN:ShowSubmenu(menuClass)
end
local settingsButton = parent:Add("TTT2:DMainMenuButton")
settingsButton
:SetSize(widthButton, heightButton)
:SetText(menuClass.title or menuClass.type)
:SetDescription(menuClass.description)
:SetIcon(menuClass.icon, nil, nil, sizeIcon)
:On("LeftClick", function()
HELPSCRN:ShowSubmenu(menuClass)
end)
end
end

Expand Down Expand Up @@ -236,16 +237,12 @@ function HELPSCRN:ShowMainMenu()
return
end

local labelSpacer = dsettings:Add("DLabelTTT2")
labelSpacer.OwnLine = true
labelSpacer:SetText("label_menu_admin_spacer")
labelSpacer:SetSize(width - 2 * self.padding - scrollSize, heightAdminSeperator)
labelSpacer:SetFont("DermaTTT2TextLarge")
labelSpacer.Paint = function(slf, w, h)
derma.SkinHook("Paint", "LabelSpacerTTT2", slf, w, h)

return true
end
local labelSpacer = dsettings:Add("TTT2:DLabel")
labelSpacer
:SetSize(width - 2 * self.padding - scrollSize, heightAdminSeperator)
:SetFont("DermaTTT2TextLarge")
:SetText("label_menu_admin_spacer")
:SetPaintHookName("LabelSpacerTTT2")

AddMenuButtons(menusAdmin, dsettings, widthMainMenuButton, heightMainMenuButton)
end
Expand Down Expand Up @@ -327,9 +324,10 @@ function HELPSCRN:BuildContentArea()

-- ADD BUTTON BOX AND BUTTONS
if self.submenuClass:HasButtonPanel() then
local buttonArea = vgui.Create("DButtonPanelTTT2", parent)
buttonArea:SetSize(width2, heightButtonPanel)
buttonArea:Dock(BOTTOM)
local buttonArea = vgui.Create("TTT2:DPanel", parent)
:SetSize(width2, heightButtonPanel)
:Dock(BOTTOM)
:SetOutline(0, 0, 0, 1)

self.submenuClass:PopulateButtonPanel(buttonArea)
end
Expand Down Expand Up @@ -361,29 +359,27 @@ function HELPSCRN:ShowSubmenu(menuClass)
self.currentMenuId = menuClass.type

-- BUILD GENERAL BOX STRUCTURE
local navArea = vgui.Create("DNavPanelTTT2", frame)
navArea:SetWide(widthNav)
navArea:SetPos(0, 0)
navArea:DockPadding(0, 0, 1, 0)
navArea:Dock(LEFT)

local contentArea = vgui.Create("DContentPanelTTT2", frame)
contentArea:SetSize(
widthContent,
heightContent - vskin.GetHeaderHeight() - vskin.GetBorderSize()
)
contentArea:SetPos(widthNav, 0)
contentArea:DockPadding(self.padding, self.padding, self.padding, self.padding)
contentArea:Dock(TOP)
local navArea = vgui
.Create("TTT2:DPanel", frame)
:SetWide(widthNav)
:SetPos(0, 0)
:DockPadding(0, 0, 1, 0) -- todo still needed with new outline?
:Dock(LEFT)
:SetOutline(0, 0, 1, 0)

local contentArea = vgui.Create("TTT2:DPanel", frame)
:SetSize(widthContent, heightContent - vskin.GetHeaderHeight() - vskin.GetBorderSize())
:SetPos(widthNav, 0)
:DockPadding(self.padding, self.padding, self.padding, self.padding)
:Dock(TOP)
--:SetColorShift(30)

-- MAKE SEPARATE SUBMENULIST ON THE NAVAREA WITH A CONTENT AREA
local submenuList = vgui.Create("DSubmenuListTTT2", navArea)
submenuList:Dock(FILL)
submenuList:SetPadding(self.padding)
submenuList:SetBasemenuClass(menuClass, contentArea)
if menuClass.searchBarPlaceholderText then
submenuList:SetSearchBarPlaceholderText(menuClass.searchBarPlaceholderText)
end
:Dock(FILL)
:SetPadding(self.padding)
:SetBasemenuClass(menuClass, contentArea)
:SetSearchBarPlaceholderText(menuClass.searchBarPlaceholderText)

-- REFRESH SIZE OF SUBMENULIST FOR CORRECT SUBMENU DEPENDENT SIZE
submenuList:InvalidateLayout(true)
Expand Down
3 changes: 3 additions & 0 deletions gamemodes/terrortown/gamemode/client/cl_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

LANG.Strings = {}

LANG_DO_TRANSLATE_PARAMS = true
LANG_DONT_TRANSLATE_PARAMS = false

local table = table
local pairs = pairs

Expand Down
6 changes: 1 addition & 5 deletions gamemodes/terrortown/gamemode/client/cl_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ ttt_include("cl_vskin__vgui__dimagecheckbox")
ttt_include("cl_vskin__vgui__droleimage")
ttt_include("cl_vskin__vgui__dmenubutton")
ttt_include("cl_vskin__vgui__dsubmenubutton")
ttt_include("cl_vskin__vgui__dnavpanel")
ttt_include("cl_vskin__vgui__dcontentpanel")
ttt_include("cl_vskin__vgui__dshopcard")
ttt_include("cl_vskin__vgui__dcombocard")
ttt_include("cl_vskin__vgui__dbuttonpanel")
ttt_include("cl_vskin__vgui__dcategoryheader")
ttt_include("cl_vskin__vgui__dcategorycollapse")
ttt_include("cl_vskin__vgui__dform")
Expand All @@ -73,8 +70,6 @@ ttt_include("cl_vskin__vgui__dtextentry")
ttt_include("cl_vskin__vgui__dbinderpanel")
ttt_include("cl_vskin__vgui__dscrollpanel")
ttt_include("cl_vskin__vgui__dvscrollbar")
ttt_include("cl_vskin__vgui__dcoloredbox")
ttt_include("cl_vskin__vgui__dcoloredtextbox")
ttt_include("cl_vskin__vgui__dtooltip")
ttt_include("cl_vskin__vgui__deventbox")
ttt_include("cl_vskin__vgui__ddragbase")
Expand All @@ -87,6 +82,7 @@ ttt_include("cl_vskin__vgui__dsubmenulist")
ttt_include("cl_vskin__vgui__dweaponpreview")
ttt_include("cl_vskin__vgui__dpippanel")
ttt_include("cl_vskin__vgui__dplayergraph")
ttt_include("cl_vskin__vgui__dhelpbox")

ttt_include("cl_changes")
ttt_include("cl_network_sync")
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/terrortown/gamemode/client/cl_radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function RADIO:ShowRadioCommands(state)

for key = 1, #commands do
local command = commands[key]
local dlabel = vgui.Create("DLabel", radioframe)
local dlabel = vgui.Create("TTT2:DLabel", radioframe)
local id = key .. ": "
local txt = id

Expand Down
108 changes: 52 additions & 56 deletions gamemodes/terrortown/gamemode/client/cl_scoring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,79 +153,75 @@ function CLSCORE:CreatePanel()
end

-- LEFT HAND MENU STRIP
local menuBox = vgui.Create("DPanelTTT2", frame)
menuBox:SetSize(self.sizes.widthMenu, self.sizes.heightMainArea)
menuBox:DockMargin(0, self.sizes.padding, 0, self.sizes.padding)
menuBox:Dock(LEFT)
menuBox.Paint = function(slf, w, h)
derma.SkinHook("Paint", "VerticalBorderedBoxTTT2", slf, w, h)

return false
end
local menuBox = vgui.Create("TTT2:DPanel", frame)
:SetSize(self.sizes.widthMenu, self.sizes.heightMainArea)
:DockMargin(0, self.sizes.padding, 0, self.sizes.padding)
:Dock(LEFT)
:SetPaintHookName("VerticalBorderedBoxTTT2")

local menuBoxGrid = vgui.Create("DIconLayout", menuBox)
menuBoxGrid:Dock(FILL)
menuBoxGrid:SetSpaceY(self.sizes.padding)

-- RIGHT HAND MAIN AREA
local mainBox = vgui.Create("DPanelTTT2", frame)
mainBox:SetSize(self.sizes.widthMainArea, self.sizes.heightMainArea)
mainBox:DockMargin(
self.sizes.padding,
self.sizes.padding,
self.sizes.padding,
self.sizes.padding
)
mainBox:Dock(RIGHT)

local contentBox = vgui.Create("DPanelTTT2", mainBox)
contentBox:SetSize(self.sizes.widthMainArea, self.sizes.heightMainArea)
contentBox:Dock(TOP)

local buttonArea = vgui.Create("DButtonPanelTTT2", mainBox)
buttonArea:SetSize(self.sizes.widthMainArea, self.sizes.heightBottomButtonPanel)
buttonArea:Dock(BOTTOM)

local buttonSave = vgui.Create("DButtonTTT2", buttonArea)
buttonSave:SetText("report_save")
buttonSave:SetSize(self.sizes.widthButton, self.sizes.heightButton)
buttonSave:SetPos(0, self.sizes.padding + 1)
buttonSave.DoClick = function(btn)
self:SaveLog()
end

local buttonClose = vgui.Create("DButtonTTT2", buttonArea)
buttonClose:SetText("close")
buttonClose:SetSize(self.sizes.widthButton, self.sizes.heightButton)
buttonClose:SetPos(self.sizes.widthMainArea - self.sizes.widthButton, self.sizes.padding + 1)
buttonClose.DoClick = function(btn)
self:HidePanel()
end
local mainBox = vgui.Create("TTT2:DPanel", frame)
:SetSize(self.sizes.widthMainArea, self.sizes.heightMainArea)
:DockMargin(self.sizes.padding, self.sizes.padding, self.sizes.padding, self.sizes.padding)
:Dock(RIGHT)

local contentBox = vgui.Create("TTT2:DPanel", mainBox)
:SetSize(self.sizes.widthMainArea, self.sizes.heightMainArea)
:Dock(TOP)

local buttonArea = vgui.Create("TTT2:DPanel", mainBox)
:SetSize(self.sizes.widthMainArea, self.sizes.heightBottomButtonPanel)
:Dock(BOTTOM)
:SetOutline(0, 0, 0, 1)

-- Button SAVE
vgui.Create("TTT2:DButton", buttonArea)
:SetSize(self.sizes.widthButton, self.sizes.heightButton)
:SetPos(0, self.sizes.padding + 1)
:SetText("report_save")
:On("LeftClick", function()
self:SaveLog()
end)

-- Button SAVE
vgui.Create("TTT2:DButton", buttonArea)
:SetSize(self.sizes.widthButton, self.sizes.heightButton)
:SetPos(self.sizes.widthMainArea - self.sizes.widthButton, self.sizes.padding + 1)
:SetText("close")
:On("LeftClick", function()
self:HidePanel()
end)

-- POPULATE SIDEBAR PANEL
local lastActive

for i = 1, #subMenusIndexed do
local data = subMenusIndexed[i]

local menuButton = menuBoxGrid:Add("DSubmenuButtonTTT2")
menuButton:SetSize(self.sizes.widthMenu - 1, self.sizes.heightMenuButton)
menuButton:SetIcon(data.icon)
menuButton:SetTooltip(data.title)
menuButton.DoClick = function(slf)
contentBox:Clear()
local menuButton = menuBoxGrid:Add("TTT2:DSubmenuButton")
menuButton
:SetSize(self.sizes.widthMenu - 1, self.sizes.heightMenuButton)
:SetIcon(data.icon)
:SetTooltip(data.title)
:On("LeftClick", function(slf)
contentBox:Clear()

if isfunction(data.Populate) then
data:Populate(contentBox)
end
if isfunction(data.Populate) then
data:Populate(contentBox)
end

slf:SetActive(true)
lastActive:SetActive(false)
lastActive = slf
end
slf:SetToggle(true)
lastActive:SetToggle(false)
lastActive = slf
end)

if i == 1 then
menuButton:SetActive(true)
menuButton:SetToggle(true)

lastActive = menuButton
end
end
Expand Down
Loading
Loading