diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index 8cd2dd8..a6d3093 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -16,6 +16,8 @@ local sw, sh = ScrW(), ScrH() local padding = 10 * resScale local padding_s = 4 * resScale +local function getMaxModel( tbl, index ) return tbl[math.Clamp( index, 1, #tbl )] end + local pages = { charCreate = function( parent ) @@ -68,7 +70,12 @@ local pages = { mdl:SetFOV( 55 ) function mdl:LayoutEntity( ent ) return end - local inputs = {} + local inputs = { + gender = "Male", + class = "Citizen", + modelIndex = 1, + name = "" + } local name = vgui.Create( "DTextEntry", p ) name:SetText( "" ) @@ -81,12 +88,11 @@ local pages = { 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 rheader = vgui.Create( "DLabel", ip ) - rheader:SetText("Select Race") + rheader:SetText("Select Model") rheader:SetFont( "q_button2" ) rheader:SetTextColor( Color( 255, 255, 255, 255 ) ) rheader:SizeToContents() @@ -115,6 +121,7 @@ local pages = { gbuttons.female.DoClick = function( self ) if( selectedGenderButton ~= self ) then selectedGenderButton = self + inputs.gender = "Female" surface.PlaySound( "UI/buttonclick.wav" ) end end @@ -138,20 +145,47 @@ local pages = { gbuttons.male.DoClick = function( self ) if( selectedGenderButton ~= self ) then selectedGenderButton = self + inputs.gender = "Male" surface.PlaySound( "UI/buttonclick.wav" ) end end + --- Class buttons --- + + local cscroll = vgui.Create( "DScrollPanel", ip ) + cscroll:SetSize( ip.w, ip.h/2 ) + cscroll.w, cscroll.h = cscroll:GetSize() + cscroll:SetPos( 0, ip.h/5 ) + --cscroll.Paint = function( self ) theme.panel( self ) end + cscroll:GetVBar():SetSize( 0, 0 ) + + local classButtons = {} + local classCount = 0 + for n, class in pairs( Quantum.Classes ) do + classCount = classCount + 1 -- keep count + classButtons[classCount] = vgui.Create( "DButton", cscroll ) + classButtons[classCount]:SetText( class.Name ) + classButtons[classCount]:SetFont( "q_button2" ) + classButtons[classCount]:SetTextColor( Color( 255, 255, 255, 255 ) ) + classButtons[classCount]:SizeToContents() + classButtons[classCount].Paint = function( self ) theme.sharpbutton( self, Color( 20, 20, 120, 100 ) ) end + end --- set the model - mdl:SetModel( Quantum.Models.Player.Male[1] ) -- set the char model + mdl:SetModel( Quantum.Models.Player.Citizen.Male[math.random(1, #Quantum.Models.Player.Citizen.Male)] ) -- 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 ) + mdl.Think = function( self ) + if( self:GetModel() ~= getMaxModel( Quantum.Models.Player[inputs.class][inputs.gender], inputs.modelIndex ) ) then + self:SetModel( getMaxModel( Quantum.Models.Player[inputs.class][inputs.gender], inputs.modelIndex ) ) + end + end + return p, c end } diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index b4c25df..ae1b63f 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -8,26 +8,34 @@ Quantum.Models = { NPC = {}, Player = { + Citizen = { + Male = { + "models/player/Group01/male_01.mdl", + "models/player/Group01/male_02.mdl", + "models/player/Group01/male_03.mdl", + "models/player/Group01/male_04.mdl", + "models/player/Group01/male_05.mdl", + "models/player/Group01/male_06.mdl", + "models/player/Group01/male_07.mdl", + "models/player/Group01/male_08.mdl", + "models/player/Group01/male_09.mdl" + }, - Male = { - "models/player/Group01/male_01.mdl", - "models/player/Group01/male_02.mdl", - "models/player/Group01/male_03.mdl", - "models/player/Group01/male_04.mdl", - "models/player/Group01/male_05.mdl", - "models/player/Group01/male_06.mdl", - "models/player/Group01/male_07.mdl", - "models/player/Group01/male_08.mdl", - "models/player/Group01/male_09.mdl" - }, - - Female = { - "models/player/group01/female_01.mdl", - "models/player/group01/female_02.mdl", - "models/player/group01/female_03.mdl", - "models/player/group01/female_04.mdl", - "models/player/group01/female_05.mdl", - "models/player/group01/female_06.mdl" + Female = { + "models/player/group01/female_01.mdl", + "models/player/group01/female_02.mdl", + "models/player/group01/female_03.mdl", + "models/player/group01/female_04.mdl", + "models/player/group01/female_05.mdl", + "models/player/group01/female_06.mdl" + } } } +} + +Quantum.Classes = { + Citizen = { + Name = "Downtown Citizen", + Models = Quantum.Models.Player.Citizen + } } \ No newline at end of file