diff --git a/gamemode/engine/core/server/sv_player_init.lua b/gamemode/engine/core/server/sv_player_init.lua index 02eb6d1..4de9961 100644 --- a/gamemode/engine/core/server/sv_player_init.lua +++ b/gamemode/engine/core/server/sv_player_init.lua @@ -31,12 +31,12 @@ end function GM:PlayerSpawn( ply ) - if( ply.isloaded ) then -- replace logic ( reversed ) - ply:Spectate( OBS_MODE_FIXED ) - Quantum.Net.OpenMenu( ply, "character", Quantum.Server.Char.GetPlayerChars( ply ) ) - else + if( ply.isloaded == true ) then -- replace logic ( reversed ) ply:UnSpectate() setUpPlayer( ply ) + else + ply:SetPos( Vector( -8936.411133, 8244.439453, 7744.031250 ) ) + Quantum.Net.OpenMenu( ply, "main", Quantum.Server.Char.GetPlayerChars_cl( ply ) ) -- make the player open the main menu end end \ No newline at end of file diff --git a/gamemode/engine/derma/cl_menu.lua b/gamemode/engine/derma/cl_menu.lua index 9a16762..8949a4f 100644 --- a/gamemode/engine/derma/cl_menu.lua +++ b/gamemode/engine/derma/cl_menu.lua @@ -10,7 +10,8 @@ local libs = { ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua", ["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua", ["theme"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_theme.lua", - ["dialogue"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua" + ["dialogue"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua", + ["sure"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_areusure.lua" } Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end diff --git a/gamemode/engine/derma/lib/cl_menu_areusure.lua b/gamemode/engine/derma/lib/cl_menu_areusure.lua index 60d1310..c64130b 100644 --- a/gamemode/engine/derma/lib/cl_menu_areusure.lua +++ b/gamemode/engine/derma/lib/cl_menu_areusure.lua @@ -7,9 +7,79 @@ local sure = {} -function sure.openSureBox( text, parent, func ) +local scale = Quantum.Client.ResolutionScale +local padding = 10 * scale +local padding_s = 4 * scale + +local theme = Quantum.Client.Menu.GetAPI( "theme" ) + +function sure.open( text, parent, func ) + local p = vgui.Create( "DPanel", parent ) - p:SetSize( 100, 100 ) + p:SetSize( parent:GetSize() ) + p.Paint = function( self ) end -- paint nothing + p.w, p.h = p:GetSize() + + func = func || function() end + + local box = vgui.Create( "DPanel", p ) + box:SetSize( 380 * scale, 180 * scale ) + box.w, box.h = box:GetSize() + box:SetPos( p.w/2 - box.w/2, p.h/2 - box.h/2 ) + + local barH = box.h/6 - padding + + box.Paint = function( self, w, h ) + theme.sharpblurpanel( self ) + + surface.SetDrawColor( 255, 255, 255, 225 ) + surface.DrawRect( 0, 0, w, barH ) + end + + local txt = vgui.Create( "DLabel", box ) + txt:SetText( "Are you sure?" ) + txt:SetFont( "q_button_m" ) + txt:SetTextColor( Color( 0, 0, 0, 255 ) ) + txt:SizeToContents() + txt.w, txt.h = txt:GetSize() + txt:SetPos( box.w/2 - txt.w/2, barH/3 - txt.h/2 ) + + local info = vgui.Create( "DLabel", box ) + info:SetText( text ) + info:SetFont( "q_text2" ) + info:SetTextColor( Color( 255, 255, 255, 225 ) ) + info:SizeToContents() + info.w, info.h = info:GetSize() + info:SetPos( box.w/2 - info.w/2, box.h/3 - info.h/2 ) + + local yes = vgui.Create( "DButton", box ) + yes:SetText( "Yes" ) + yes:SetFont( "q_button_m" ) + yes:SetTextColor( Color( 0, 0, 0, 255 ) ) + yes:SizeToContents() + yes.w, yes.h = yes:GetSize() + yes:SetPos( box.w/4 - yes.w/2, (box.h*0.75) - yes.h/2 ) + yes.Paint = function( self ) theme.sharpbutton( self, Color( 80, 190, 90, 225 ) ) end + yes.DoClick = function( self ) + surface.PlaySound( "UI/buttonclick.wav" ) + func() + p:Remove() + end + yes.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end + + local no = vgui.Create( "DButton", box ) + no:SetText( "No" ) + no:SetFont( "q_button_m" ) + no:SetTextColor( Color( 0, 0, 0, 255 ) ) + no:SetSize( yes:GetSize() ) + no.w, no.h = no:GetSize() + no:SetPos( box.w*0.75 - no.w/2, (box.h*0.75) - no.h/2 ) + no.Paint = function( self ) theme.sharpbutton( self, Color( 190, 110, 90, 225 ) ) end + no.DoClick = function( self ) + surface.PlaySound( "UI/buttonclick.wav" ) + p:Remove() + end + no.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end end return sure \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_character.lua b/gamemode/engine/derma/menus/menu_character.lua index ed2a6bf..3b80a87 100644 --- a/gamemode/engine/derma/menus/menu_character.lua +++ b/gamemode/engine/derma/menus/menu_character.lua @@ -303,10 +303,19 @@ local pages = { cr:SetPos( name.x + name.w/2 - cr.w/2, name.y + cr.h + padding ) cr.Paint = function( self ) theme.sharpbutton( self ) end cr.DoClick = function( self ) - surface.PlaySound( "UI/buttonclick.wav" ) + -- create char inputs.name = checkNameString( name:GetText() ) - snm.RunNetworkedFunc( "createChar", inputs ) + if( #inputs.name > Quantum.CharacterNameLimit || #inputs.name < Quantum.CharacterNameMin ) then + surface.PlaySound( "common/wpn_denyselect.wav" ) + return + else + surface.PlaySound( "UI/buttonclick.wav" ) + snm.RunNetworkedFunc( "createChar", inputs ) + inputs.model = Quantum.Classes[inputs.class].Models[inputs.gender][inputs.index] + table.insert( Quantum.Client.Chars, inputs ) + end + end return p, c @@ -315,6 +324,7 @@ local pages = { function menu.open( dt ) Quantum.Client.IsInMenu = true -- hide the hud + Quantum.Client.Chars = dt.cont if( !f ) then local f = vgui.Create( "DFrame" ) f:SetTitle( "" ) @@ -327,6 +337,7 @@ function menu.open( dt ) f:ShowCloseButton( false ) f:MakePopup() function f:OnClose() + Quantum.Client.Chars = nil Quantum.Client.IsInMenu = false -- show the hud when closed Quantum.Client.Cam.Stop() end @@ -394,7 +405,7 @@ function menu.open( dt ) local cpanels = {} local selectedChar - if( table.Count( chars ) >= 1 ) then + if( table.Count( Quantum.Client.Chars ) >= 1 ) then -- Char model p.mdl = vgui.Create( "DModelPanel", p ) p.mdl:SetSize( 600 * resScale, 1000 * resScale ) @@ -422,7 +433,7 @@ function menu.open( dt ) end local count = 0 - for k, v in pairs( chars ) do + for k, v in pairs( Quantum.Client.Chars ) do count = count + 1 cpanels[count] = vgui.Create( "DButton", clist ) cpanels[count].index = count diff --git a/gamemode/engine/derma/menus/menu_main.lua b/gamemode/engine/derma/menus/menu_main.lua index 851f2a0..ee0e79b 100644 --- a/gamemode/engine/derma/menus/menu_main.lua +++ b/gamemode/engine/derma/menus/menu_main.lua @@ -8,6 +8,7 @@ local main = {} local theme = Quantum.Client.Menu.GetAPI( "theme" ) +local surebox = Quantum.Client.Menu.GetAPI( "sure" ) local scenes = { ["rp_truenorth_v1a_livin"] = { @@ -46,6 +47,8 @@ local scenes = { } } +local charmenu = include( GAMEMODE.FolderName .. "/gamemode/engine/derma/menus/menu_character.lua" ) + function main.open(dt) if( !f ) then @@ -65,13 +68,15 @@ function main.open(dt) f:SetSize( sw, sh ) f:SetTitle( "" ) f:IsDraggable( false ) + f:ShowCloseButton( false ) f:MakePopup() f.Paint = function( self ) theme.renderblur( self, 2, 7 ) end f.OnClose = function( self ) - Quantum.Client.IsInMenu = false - Quantum.Client.Cam.Stop() + --Quantum.Client.IsInMenu = false + --Quantum.Client.Cam.Stop() + charmenu.open( dt ) end Quantum.Client.Cam.Start( scenes[ game.GetMap() ][math.random( 1, table.Count(scenes[ game.GetMap() ])) ], false ) @@ -125,6 +130,7 @@ function main.open(dt) play.DoClick = function( self ) surface.PlaySound( "UI/buttonclick.wav" ) + --charmenu.open( dt ) f:Close() end play.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end @@ -170,6 +176,7 @@ function main.open(dt) end ws.DoClick = function( self ) surface.PlaySound( "UI/buttonclick.wav" ) + gui.OpenURL( Quantum.WorkshopLink ) end ws.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end @@ -192,6 +199,7 @@ function main.open(dt) end inv.DoClick = function( self ) surface.PlaySound( "UI/buttonclick.wav" ) + gui.OpenURL( Quantum.DiscordInvite ) end inv.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end @@ -214,7 +222,9 @@ function main.open(dt) end quit.DoClick = function( self ) surface.PlaySound( "UI/buttonclick.wav" ) - LocalPlayer():ConCommand("disconnect") + surebox.open( "You are about to leave the server.", self:GetParent(), function() + LocalPlayer():ConCommand("disconnect") + end) end quit.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end diff --git a/gamemode/engine/lib/server/sv_character.lua b/gamemode/engine/lib/server/sv_character.lua index 1332789..c869a1b 100644 --- a/gamemode/engine/lib/server/sv_character.lua +++ b/gamemode/engine/lib/server/sv_character.lua @@ -59,6 +59,7 @@ function Quantum.Server.Char.GetCurrentCharacter( pl ) end local function setupCharacter( pl, char ) + pl.isloaded = true pl:Spawn() pl:SetMaxHealth( char.maxhealth ) pl:SetHealth( char.health ) diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index d51cde0..c86b08b 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -6,7 +6,11 @@ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ Quantum.CharacterLimit = 5 +Quantum.CharacterNameLimit = 12 +Quantum.CharacterNameMin = 3 Quantum.ServerTitle = "Electron Networks: CityRP" +Quantum.DiscordInvite = "https://discord.gg/heUJB4B" +Quantum.WorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=1842234130" Quantum.Models = { NPC = {},