From f6e1f9b9c27203b54afdb52d47d99c715dd19d3c Mon Sep 17 00:00:00 2001 From: AlmTech Date: Mon, 14 Oct 2019 21:59:55 +0200 Subject: [PATCH] Character creation UI stuff --- gamemode/cl_init.lua | 3 +- gamemode/engine/derma/lib/cl_menu_theme.lua | 4 +- .../engine/derma/menus/menu_character.lua | 114 +++++++++++++----- gamemode/init.lua | 2 +- .../{sh_models.lua => sh_settings.lua} | 0 gamemode/shared.lua | 2 +- 6 files changed, 93 insertions(+), 32 deletions(-) rename gamemode/settings/{sh_models.lua => sh_settings.lua} (100%) diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua index bfed309..0991a92 100644 --- a/gamemode/cl_init.lua +++ b/gamemode/cl_init.lua @@ -7,9 +7,10 @@ if CLIENT then include( "shared.lua" ) + --local gmfolder = GAMEMODE.FolderName || GM.FolderName Quantum.Client = {} Quantum.Client.ResolutionScale = ScrH() / 1080 - Quantum.Client.ServerBannerPath = "gamemodes/" .. GAMEMODE.FolderName .. "/gamemode/content/materials/quantum/server_banner.png" + Quantum.Client.ServerBannerPath = "gamemodes/" .. GM.FolderName .. "/gamemode/content/materials/quantum/server_banner.png" local function loadCoreFiles() local fol = GM.FolderName .. "/gamemode/engine/core/" diff --git a/gamemode/engine/derma/lib/cl_menu_theme.lua b/gamemode/engine/derma/lib/cl_menu_theme.lua index 9d37715..37a86c0 100644 --- a/gamemode/engine/derma/lib/cl_menu_theme.lua +++ b/gamemode/engine/derma/lib/cl_menu_theme.lua @@ -27,7 +27,7 @@ end function theme.panel( p, color ) local w, h = p:GetSize() - local clr = color || Color( 0, 0, 0, 100 ) + local clr = color || Color( 0, 0, 0, 200 ) local bclr = Color( 50, 50, 50, 105 ) draw.RoundedBox( 6, 0, 0, w, h, bclr ) -- border @@ -36,7 +36,7 @@ end function theme.blurpanel( p, color ) local w, h = p:GetSize() - local clr = color || Color( 0, 0, 0, 100 ) + local clr = color || Color( 0, 0, 0, 200 ) local bclr = Color( 50, 50, 50, 105 ) renderBlur( p, 2, 7 ) diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index 995048b..bb0e9b1 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -37,27 +37,95 @@ local pages = { p:Remove() end + local banner = vgui.Create( "DImage", p ) + banner:SetImage( Quantum.Client.ServerBannerPath ) + banner:SizeToContents() + banner.w, banner.h = banner:GetSize() + banner:SetSize( (banner.w * resScale)/2.8, (banner.h * resScale)/2.8 ) + banner.w, banner.h = banner:GetSize() + banner:SetPos( (p.w - banner.w) + padding*2, 0 ) local ip = vgui.Create( "DPanel", p ) -- input panel ip:SetSize( 400 * resScale, p.h * 0.9 ) ip.w, ip.h = ip:GetSize() ip:SetPos( padding*4, p.h/2 - ip.h/2 ) ip.Paint = function( self ) theme.blurpanel(self) end + ip.x, ip.y = ip:GetPos() + + local header = vgui.Create( "DLabel", p ) + header:SetText( "Character Creation" ) + header:SetFont( "q_header" ) + header:SetTextColor( Color( 255, 255, 255, 255 ) ) + header:SizeToContents() + header.w, header.h = header:GetSize() + header:SetPos( (ip.x + ip.w/2) - header.w/2, header.h/2 ) + + -- character model panel + local mdl = vgui.Create( "DModelPanel", p ) + mdl:SetSize( 600 * resScale, 1000 * resScale ) + mdl.w, mdl.h = mdl:GetSize() + mdl:SetPos( p.w/2 - mdl.w/2, p.h/2 - mdl.h/2 ) + mdl:SetFOV( 55 ) + function mdl:LayoutEntity( ent ) return end local inputs = {} + local name = vgui.Create( "DTextEntry", p ) + name:SetText( "" ) + name:SetFont( "q_button2" ) + name:SetTextColor( Color( 255, 255, 255, 255 ) ) + name:SetSize( 300 * resScale, 40 * resScale ) + name.w, name.h = name:GetSize() + name:SetPos( p.w/2 - name.w/2, p.h*0.85 - name.h/2 ) + name.Paint = function( self ) + theme.blurpanel( self ) + self:DrawTextEntryText( Color( 255, 255, 255, 255 ), Color( 150, 150, 150, 255 ), Color( 100, 100, 100, 255 ) ) + end + --function name:OnChange() inputs.name = self:GetValue() end + -- input panel contens -- - local gbuttons = {} + + local rheader = vgui.Create( "DLabel", ip ) + rheader:SetText("Select Race") + rheader:SetFont( "q_button2" ) + rheader:SetTextColor( Color( 255, 255, 255, 255 ) ) + rheader:SizeToContents() + rheader.w, rheader.h = rheader:GetSize() + rheader:SetPos( ip.w/2 - rheader.w/2, rheader.h ) + rheader.x, rheader.y = rheader:GetPos() + + local gbuttons = {} + + gbuttons.female = vgui.Create( "DButton", ip ) + local selectedGenderButton = gbuttons.female -- select itself + gbuttons.female:SetText( "Female" ) + gbuttons.female:SetTextColor( Color( 0, 0, 0, 255 ) ) + gbuttons.female:SetFont( "q_button2" ) + gbuttons.female.Paint = function( self, w, h ) + theme.sharpbutton( self ) + if( selectedGenderButton == self ) then + surface.SetDrawColor( 100, 100, 100, 100 ) + surface.DrawRect( 0, 0, w, h ) + end + end + gbuttons.female:SizeToContents() + gbuttons.female.w, gbuttons.female.h = gbuttons.female:GetSize() + gbuttons.female:SetPos( padding, rheader.y + gbuttons.female.h + padding ) + gbuttons.female.x, gbuttons.female.y = gbuttons.female:GetPos() + gbuttons.female.DoClick = function( self ) + if( selectedGenderButton ~= self ) then + selectedGenderButton = self + surface.PlaySound( "UI/buttonclick.wav" ) + end + end + gbuttons.male = vgui.Create( "DButton", ip ) - gbuttons.male:SetText( "M" ) + gbuttons.male:SetText( "Male" ) gbuttons.male:SetTextColor( Color( 0, 0, 0, 255 ) ) gbuttons.male:SetFont( "q_button2" ) - gbuttons.male:SizeToContents() + gbuttons.male:SetSize( gbuttons.female:GetSize() ) gbuttons.male.w, gbuttons.male.h = gbuttons.male:GetSize() gbuttons.male:SetPos( (ip.w/2 - padding) - gbuttons.male.w/2, ip.h/2 - gbuttons.male.h/2 ) - gbuttons.male.x, gbuttons.male.y = gbuttons.male:GetPos() - - local selectedGenderButton = gbuttons.male -- select itself gbuttons.male.Paint = function( self, w, h ) theme.sharpbutton( self ) @@ -67,29 +135,21 @@ local pages = { end end gbuttons.male.DoClick = function( self ) - selectedGenderButton = self - surface.PlaySound( "UI/buttonclick.wav" ) + if( selectedGenderButton ~= self ) then + selectedGenderButton = self + surface.PlaySound( "UI/buttonclick.wav" ) + end end - gbuttons.female = vgui.Create( "DButton", ip ) - gbuttons.female:SetText( "F" ) - gbuttons.female:SetTextColor( Color( 0, 0, 0, 255 ) ) - gbuttons.female:SetFont( "q_button2" ) - gbuttons.female.Paint = function( self, w, h ) - theme.sharpbutton( self ) - if( selectedGenderButton == self ) then - surface.SetDrawColor( 100, 100, 100, 100 ) - surface.DrawRect( 0, 0, w, h ) - end - end - gbuttons.female:SetSize( gbuttons.male:GetSize() ) - gbuttons.female.w, gbuttons.female.h = gbuttons.female:GetSize() - gbuttons.female:SetPos( (ip.w/2 + padding) + gbuttons.female.w/2, gbuttons.male.y ) - gbuttons.female.DoClick = function( self ) - selectedGenderButton = self - surface.PlaySound( "UI/buttonclick.wav" ) - end + + --- set the model + mdl:SetModel( Quantum.Models.Player.Male[1] ) -- set the char model + local minv, maxv = mdl.Entity:GetRenderBounds() + local eyepos = mdl.Entity:GetBonePosition( mdl.Entity:LookupBone( "ValveBiped.Bip01_Head1" ) ) + eyepos:Add( Vector( 40, 0, -15 ) ) + mdl:SetCamPos( eyepos - Vector( -10, 0, -2 ) ) + mdl:SetLookAt( eyepos ) return p, c end @@ -126,7 +186,7 @@ function menu.open( dt ) clist:SetPos( (sw - clist.w) - padding*2, padding*6 ) clist.x, clist.y = clist:GetPos() clist.Paint = function( self, w, h ) - theme.blurpanel( self, Color( 0, 0, 0, 200 ) ) + theme.blurpanel( self ) end local sbar = clist:GetVBar() diff --git a/gamemode/init.lua b/gamemode/init.lua index 36f2264..48f8b2c 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -7,7 +7,7 @@ if SERVER then AddCSLuaFile( "engine/sh_debug.lua" ) - AddCSLuaFile( "settings/sh_models.lua" ) + AddCSLuaFile( "settings/sh_settings.lua" ) AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) diff --git a/gamemode/settings/sh_models.lua b/gamemode/settings/sh_settings.lua similarity index 100% rename from gamemode/settings/sh_models.lua rename to gamemode/settings/sh_settings.lua diff --git a/gamemode/shared.lua b/gamemode/shared.lua index 6a324de..ecfca58 100644 --- a/gamemode/shared.lua +++ b/gamemode/shared.lua @@ -14,4 +14,4 @@ Quantum = {} include( "engine/sh_debug.lua" ) -- add the debug functions and stuff -include( "settings/sh_models.lua" ) \ No newline at end of file +include( "settings/sh_settings.lua" ) \ No newline at end of file