diff --git a/gamemode/engine/core/sh_player_binds.lua b/gamemode/engine/core/sh_player_binds.lua index 3d0b3e4..3f887bc 100644 --- a/gamemode/engine/core/sh_player_binds.lua +++ b/gamemode/engine/core/sh_player_binds.lua @@ -13,7 +13,7 @@ if SERVER then Quantum.Net.OpenMenu( pl, "main", { chars = Quantum.Server.Char.GetPlayerChars_cl( pl ), resume = true } ) end, ["charinfo"] = function( pl ) - Quantum.Net.OpenMenu( pl, "charinfo", {} ) + Quantum.Net.OpenMenu( pl, "charinfo", { char = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ) } ) end } diff --git a/gamemode/engine/derma/lib/cl_menu_theme.lua b/gamemode/engine/derma/lib/cl_menu_theme.lua index aae26cd..0dc8f89 100644 --- a/gamemode/engine/derma/lib/cl_menu_theme.lua +++ b/gamemode/engine/derma/lib/cl_menu_theme.lua @@ -135,4 +135,16 @@ function theme.pagetitle( b ) surface.DrawRect( 0, 0, w, h ) end +function theme.itempanel( p ) + local w, h = p:GetSize() + surface.SetDrawColor( 0, 0, 0, 120 ) + surface.DrawRect( 0, 0, w, h ) + + if( p:IsHovered() ) then + theme.borderpanel( p, Color( 116, 185, 255, 90 ) ) + else + theme.borderpanel( p, Color( 255, 255, 255, 150 ) ) + end +end + return theme \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_charinfo.lua b/gamemode/engine/derma/menus/menu_charinfo.lua index cb68221..df4a521 100644 --- a/gamemode/engine/derma/menus/menu_charinfo.lua +++ b/gamemode/engine/derma/menus/menu_charinfo.lua @@ -19,6 +19,7 @@ local errorMdl = "models/player.mdl" function menu.open( dt ) local items = dt.cont.items + PrintTable(dt) if( !f ) then Quantum.Client.IsInMenu = true @@ -48,11 +49,6 @@ function menu.open( dt ) bar.Paint = function( self ) theme.blurpanel( self ) end bar.DoClick = function( self ) f:Close() end - f.pages = { - inventory = { title = "Inventory" }, - info = { title = "Character Information" } - } - -- Inventory button -- title = vgui.Create( "DLabel", bar ) title:SetText( "Inventory" ) @@ -66,12 +62,25 @@ function menu.open( dt ) title.w, title.h = title:GetSize() title:SetPos( bar.w/2 - title.w/2, bar.h/2 - title.h/2 ) - ---- Character view ---- local char = vgui.Create( "DModelPanel", f ) - char:SetSize( 500, 500 ) - --char:SetModel( dt.cont.char.model ) ------------FIX THIS + char:SetSize( 550 * resScale, f.h - bar.h ) + char.w, char.h = char:GetSize() + char:SetPos( 0, bar.h ) + char.x, char.y = char:GetPos() + char:SetFOV( 25 ) + char:SetModel( dt.cont.char.model || errorMdl ) + char:SetDirectionalLight( BOX_FRONT, Color( 116, 205, 255 ) ) + local ent = char.Entity + local eyepos = ent:GetBonePosition( ent:LookupBone( "ValveBiped.Bip01_Head1" ) ) + eyepos:Add( Vector( 40, 0, -15 ) ) + char:SetCamPos( eyepos + Vector( 40, -5, 2 ) ) + char:SetLookAt( eyepos ) + ent:SetEyeTarget( eyepos + Vector( 40, -5, 2 ) ) + function char:LayoutEntity( Entity ) return end + + ---- TEMPORARY: REMOVE WHEN THE MENU IS DONE ---- local close = vgui.Create( "DButton", f ) close:SetText( "DEV CLOSE" ) @@ -80,6 +89,67 @@ function menu.open( dt ) close:SetPos( 0, f.h - close.h ) close.DoClick = function( self ) f:Close() end + ---- Inventory panel ---- + + local inv = vgui.Create( "DPanel", f ) -- section for all of the item panels + inv:SetSize( f.w - char.w, f.h - bar.h ) + inv.w, inv.h = inv:GetSize() + inv:SetPos( char.w, bar.h ) + inv.Paint = function( self, w, h ) + surface.SetDrawColor( 0, 0, 0, 0 ) + surface.DrawRect( 0, 0, w, h ) + end + + local itemWidth, itemHeight = 70 * resScale, 70 * resScale + local maxW, maxH = Quantum.Inventory.Width, Quantum.Inventory.Height + + local itempanels = {} + + local count = 0 + local xbasepos, ybasepos = 0, 0 + local xintervall, yintervall = itemWidth + padding/2, itemHeight + padding/2 + local xpos, ypos = 0, 0 + local rows = 0 + + local itemframe = vgui.Create( "DPanel", inv ) -- container for all of the item panels + itemframe:SetSize( inv:GetSize() ) + itemframe:SetPos( 0, 0 ) + itemframe.Paint = function( self, w, h ) + surface.SetDrawColor( 0, 0, 0, 10 ) + surface.DrawRect( 0, 0, w, h ) + end + + for ii=1, maxW * maxH, 1 do -- create all of the item panels + if( ii != 1 ) then count = count + 1 end + + itempanels[ii] = vgui.Create( "DPanel", itemframe ) + itempanels[ii]:SetSize( itemWidth, itemHeight ) + if( count >= maxW ) then + ypos = ypos + yintervall + xpos = xbasepos + count = 0 + rows = rows + 1 + else + if( count != 0 ) then + xpos = xpos + xintervall + else + xpos = 0 + end + end + itempanels[ii]:SetPos( xpos, ypos ) + itempanels[ii].x, itempanels[ii].y = itempanels[ii]:GetPos() + + itempanels[ii].Paint = function( self ) + theme.itempanel( self ) + end + end + + -- get the width and height of all of the items + local iwidth, iheight = (itempanels[maxW].x - xbasepos) + itemWidth, (itempanels[#itempanels].y - ybasepos) + itemHeight + itemframe:SetSize( iwidth, iheight ) -- set the frames dimensions to all of the items dimensions combined. + itemframe.w, itemframe.h = itemframe:GetSize() + itemframe:SetPos( inv.w/2 - itemframe.w/2, inv.h/2 - itemframe.h/2 ) -- center the item panels + end end diff --git a/gamemode/engine/lib/server/sv_character.lua b/gamemode/engine/lib/server/sv_character.lua index b85138d..db5e8bd 100644 --- a/gamemode/engine/lib/server/sv_character.lua +++ b/gamemode/engine/lib/server/sv_character.lua @@ -94,7 +94,7 @@ function Quantum.Server.Char.GetCharCount( pl ) return table.Count( Quantum.Server.Char.GetPlayerChars( pl ) ) || 0 end -local function getBasicCharInfo( char ) +function Quantum.Server.Char.getBasicCharInfo( char ) return { name = char.name, model = char.model, @@ -108,7 +108,7 @@ function Quantum.Server.Char.GetPlayerChars_cl( pl ) local count = 0 for id, char in pairs( Quantum.Server.Char.GetPlayerChars( pl ) ) do count = count + 1 - chars[count] = getBasicCharInfo( char ) + chars[count] = Quantum.Server.Char.getBasicCharInfo( char ) end return chars end \ No newline at end of file diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index b754f09..20e55b8 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -10,12 +10,12 @@ Quantum.Server.Inventory = {} function Quantum.Server.Inventory.Create( char ) char.inventory = {} - for i = 1, Quantum.Server.Settings.Inventory.Width do + for i = 1, Quantum.Inventory.Width do char.inventory[i] = {} end for h, v in pairs( char.inventory ) do - for w = 1, Quantum.Server.Settings.Inventory.Height do + for w = 1, Quantum.Inventory.Height do char.inventory[h][w] = 0 end end diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index c86b08b..ed88a71 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -12,6 +12,11 @@ Quantum.ServerTitle = "Electron Networks: CityRP" Quantum.DiscordInvite = "https://discord.gg/heUJB4B" Quantum.WorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=1842234130" +Quantum.Inventory = { + Height = 12, -- NOTE: MAX HEIGHT=12 + Width = 18 -- NOTE: MAX WIDTH=18 +} + Quantum.Models = { NPC = {}, Player = { diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua index 5283c07..650ec7c 100644 --- a/gamemode/settings/sv_settings.lua +++ b/gamemode/settings/sv_settings.lua @@ -13,11 +13,6 @@ Quantum.Server.Settings.MaxHealth = 100 Quantum.Server.Settings.StarterMoney = 0 -Quantum.Server.Settings.Inventory = { - Height = 5, - Width = 5 -} - Quantum.Server.Settings.InitSpawnLocation = { pos = Vector( 5054.682617, 3152.809326, 168.031250 ), ang = Angle( 3.009660, 89.639153, 0.000000 )