Main menu & character menu stuff

master
AlmTech Software 5 years ago
parent 9de566ddae
commit ea42c992fd
  1. 8
      gamemode/engine/core/server/sv_player_init.lua
  2. 3
      gamemode/engine/derma/cl_menu.lua
  3. 74
      gamemode/engine/derma/lib/cl_menu_areusure.lua
  4. 19
      gamemode/engine/derma/menus/menu_character.lua
  5. 16
      gamemode/engine/derma/menus/menu_main.lua
  6. 1
      gamemode/engine/lib/server/sv_character.lua
  7. 4
      gamemode/settings/sh_settings.lua

@ -31,12 +31,12 @@ end
function GM:PlayerSpawn( ply ) function GM:PlayerSpawn( ply )
if( ply.isloaded ) then -- replace logic ( reversed ) if( ply.isloaded == true ) then -- replace logic ( reversed )
ply:Spectate( OBS_MODE_FIXED )
Quantum.Net.OpenMenu( ply, "character", Quantum.Server.Char.GetPlayerChars( ply ) )
else
ply:UnSpectate() ply:UnSpectate()
setUpPlayer( ply ) 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
end end

@ -10,7 +10,8 @@ local libs = {
["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua", ["net"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_network.lua",
["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua", ["page"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_pages.lua",
["theme"] = GM.FolderName .. "/gamemode/engine/derma/lib/cl_menu_theme.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 Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end

@ -7,9 +7,79 @@
local sure = {} 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 ) 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 end
return sure return sure

@ -303,10 +303,19 @@ local pages = {
cr:SetPos( name.x + name.w/2 - cr.w/2, name.y + cr.h + padding ) cr:SetPos( name.x + name.w/2 - cr.w/2, name.y + cr.h + padding )
cr.Paint = function( self ) theme.sharpbutton( self ) end cr.Paint = function( self ) theme.sharpbutton( self ) end
cr.DoClick = function( self ) cr.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" )
-- create char -- create char
inputs.name = checkNameString( name:GetText() ) 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 end
return p, c return p, c
@ -315,6 +324,7 @@ local pages = {
function menu.open( dt ) function menu.open( dt )
Quantum.Client.IsInMenu = true -- hide the hud Quantum.Client.IsInMenu = true -- hide the hud
Quantum.Client.Chars = dt.cont
if( !f ) then if( !f ) then
local f = vgui.Create( "DFrame" ) local f = vgui.Create( "DFrame" )
f:SetTitle( "" ) f:SetTitle( "" )
@ -327,6 +337,7 @@ function menu.open( dt )
f:ShowCloseButton( false ) f:ShowCloseButton( false )
f:MakePopup() f:MakePopup()
function f:OnClose() function f:OnClose()
Quantum.Client.Chars = nil
Quantum.Client.IsInMenu = false -- show the hud when closed Quantum.Client.IsInMenu = false -- show the hud when closed
Quantum.Client.Cam.Stop() Quantum.Client.Cam.Stop()
end end
@ -394,7 +405,7 @@ function menu.open( dt )
local cpanels = {} local cpanels = {}
local selectedChar local selectedChar
if( table.Count( chars ) >= 1 ) then if( table.Count( Quantum.Client.Chars ) >= 1 ) then
-- Char model -- Char model
p.mdl = vgui.Create( "DModelPanel", p ) p.mdl = vgui.Create( "DModelPanel", p )
p.mdl:SetSize( 600 * resScale, 1000 * resScale ) p.mdl:SetSize( 600 * resScale, 1000 * resScale )
@ -422,7 +433,7 @@ function menu.open( dt )
end end
local count = 0 local count = 0
for k, v in pairs( chars ) do for k, v in pairs( Quantum.Client.Chars ) do
count = count + 1 count = count + 1
cpanels[count] = vgui.Create( "DButton", clist ) cpanels[count] = vgui.Create( "DButton", clist )
cpanels[count].index = count cpanels[count].index = count

@ -8,6 +8,7 @@
local main = {} local main = {}
local theme = Quantum.Client.Menu.GetAPI( "theme" ) local theme = Quantum.Client.Menu.GetAPI( "theme" )
local surebox = Quantum.Client.Menu.GetAPI( "sure" )
local scenes = { local scenes = {
["rp_truenorth_v1a_livin"] = { ["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) function main.open(dt)
if( !f ) then if( !f ) then
@ -65,13 +68,15 @@ function main.open(dt)
f:SetSize( sw, sh ) f:SetSize( sw, sh )
f:SetTitle( "" ) f:SetTitle( "" )
f:IsDraggable( false ) f:IsDraggable( false )
f:ShowCloseButton( false )
f:MakePopup() f:MakePopup()
f.Paint = function( self ) f.Paint = function( self )
theme.renderblur( self, 2, 7 ) theme.renderblur( self, 2, 7 )
end end
f.OnClose = function( self ) f.OnClose = function( self )
Quantum.Client.IsInMenu = false --Quantum.Client.IsInMenu = false
Quantum.Client.Cam.Stop() --Quantum.Client.Cam.Stop()
charmenu.open( dt )
end end
Quantum.Client.Cam.Start( scenes[ game.GetMap() ][math.random( 1, table.Count(scenes[ game.GetMap() ])) ], false ) 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 ) play.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
--charmenu.open( dt )
f:Close() f:Close()
end end
play.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end play.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
@ -170,6 +176,7 @@ function main.open(dt)
end end
ws.DoClick = function( self ) ws.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
gui.OpenURL( Quantum.WorkshopLink )
end end
ws.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end ws.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
@ -192,6 +199,7 @@ function main.open(dt)
end end
inv.DoClick = function( self ) inv.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
gui.OpenURL( Quantum.DiscordInvite )
end end
inv.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end inv.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
@ -214,7 +222,9 @@ function main.open(dt)
end end
quit.DoClick = function( self ) quit.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) 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 end
quit.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end quit.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end

@ -59,6 +59,7 @@ function Quantum.Server.Char.GetCurrentCharacter( pl )
end end
local function setupCharacter( pl, char ) local function setupCharacter( pl, char )
pl.isloaded = true
pl:Spawn() pl:Spawn()
pl:SetMaxHealth( char.maxhealth ) pl:SetMaxHealth( char.maxhealth )
pl:SetHealth( char.health ) pl:SetHealth( char.health )

@ -6,7 +6,11 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.CharacterLimit = 5 Quantum.CharacterLimit = 5
Quantum.CharacterNameLimit = 12
Quantum.CharacterNameMin = 3
Quantum.ServerTitle = "Electron Networks: CityRP" Quantum.ServerTitle = "Electron Networks: CityRP"
Quantum.DiscordInvite = "https://discord.gg/heUJB4B"
Quantum.WorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=1842234130"
Quantum.Models = { Quantum.Models = {
NPC = {}, NPC = {},

Loading…
Cancel
Save