Inventory backend & menu stuff

master
AlmTech Software 5 years ago
parent a8cc0ffd9f
commit ab0598a4a9
  1. 12
      gamemode/engine/core/client/cl_fonts.lua
  2. 7
      gamemode/engine/core/sh_player_binds.lua
  3. 8
      gamemode/engine/derma/lib/cl_menu_theme.lua
  4. 54
      gamemode/engine/derma/menus/menu_charinfo.lua
  5. 3
      gamemode/engine/lib/server/sv_character.lua
  6. 31
      gamemode/engine/lib/sh_format.lua
  7. 1
      gamemode/init.lua
  8. 9
      gamemode/settings/sh_settings.lua

@ -78,3 +78,15 @@ surface.CreateFont( "q_subtitle", {
size = 38 * Quantum.Client.ResolutionScale, size = 38 * Quantum.Client.ResolutionScale,
antialias = true antialias = true
}) })
surface.CreateFont( "q_name", {
font = "Cambria Bold",
size = 38 * Quantum.Client.ResolutionScale,
antialias = true
})
surface.CreateFont( "q_money", {
font = "Cambria Bold",
size = 42 * Quantum.Client.ResolutionScale,
antialias = true
})

@ -13,7 +13,12 @@ if SERVER then
Quantum.Net.OpenMenu( pl, "main", { chars = Quantum.Server.Char.GetPlayerChars_cl( pl ), resume = true } ) Quantum.Net.OpenMenu( pl, "main", { chars = Quantum.Server.Char.GetPlayerChars_cl( pl ), resume = true } )
end, end,
["charinfo"] = function( pl ) ["charinfo"] = function( pl )
Quantum.Net.OpenMenu( pl, "charinfo", { char = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ) } ) Quantum.Net.OpenMenu( pl, "charinfo", { char = {
model = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ).model,
name = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ).name,
money = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ).money
}, items = {} } )
end end
} }

@ -126,10 +126,10 @@ function theme.skipbutton( b, inClr )
surface.DrawRect( padding_s/2, padding_s/2, w - padding_s, h - padding_s ) surface.DrawRect( padding_s/2, padding_s/2, w - padding_s, h - padding_s )
end end
function theme.pagetitle( b ) function theme.pagetext( p )
local w, h = b:GetSize() local w, h = p:GetSize()
b:SetTextColor( Color( 205, 205, 205, 255 ) ) p:SetTextColor( Color( 205, 205, 205, 255 ) )
surface.SetDrawColor( Color( 0, 0, 0, 0 ) ) surface.SetDrawColor( Color( 0, 0, 0, 0 ) )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
@ -143,7 +143,7 @@ function theme.itempanel( p )
if( p:IsHovered() ) then if( p:IsHovered() ) then
theme.borderpanel( p, Color( 116, 185, 255, 90 ) ) theme.borderpanel( p, Color( 116, 185, 255, 90 ) )
else else
theme.borderpanel( p, Color( 255, 255, 255, 150 ) ) theme.borderpanel( p, Color( 255, 255, 255, 200 ) )
end end
end end

@ -55,7 +55,7 @@ function menu.open( dt )
title:SetFont( "q_header_s" ) title:SetFont( "q_header_s" )
title:SetTextColor( Color( 255, 255, 255, 255 ) ) title:SetTextColor( Color( 255, 255, 255, 255 ) )
title.Paint = function( self ) title.Paint = function( self )
theme.pagetitle( self ) theme.pagetext( self )
end end
title:SizeToContents() title:SizeToContents()
@ -80,15 +80,6 @@ function menu.open( dt )
ent:SetEyeTarget( eyepos + Vector( 40, -5, 2 ) ) ent:SetEyeTarget( eyepos + Vector( 40, -5, 2 ) )
function char:LayoutEntity( Entity ) return end function char:LayoutEntity( Entity ) return end
---- TEMPORARY: REMOVE WHEN THE MENU IS DONE ----
local close = vgui.Create( "DButton", f )
close:SetText( "DEV CLOSE" )
close:SizeToContents()
close.w, close.h = close:GetSize()
close:SetPos( 0, f.h - close.h )
close.DoClick = function( self ) f:Close() end
---- Inventory panel ---- ---- Inventory panel ----
local inv = vgui.Create( "DPanel", f ) -- section for all of the item panels local inv = vgui.Create( "DPanel", f ) -- section for all of the item panels
@ -100,7 +91,7 @@ function menu.open( dt )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
end end
local itemWidth, itemHeight = 70 * resScale, 70 * resScale local itemWidth, itemHeight = 65 * resScale, 65 * resScale
local maxW, maxH = Quantum.Inventory.Width, Quantum.Inventory.Height local maxW, maxH = Quantum.Inventory.Width, Quantum.Inventory.Height
local itempanels = {} local itempanels = {}
@ -115,7 +106,7 @@ function menu.open( dt )
itemframe:SetSize( inv:GetSize() ) itemframe:SetSize( inv:GetSize() )
itemframe:SetPos( 0, 0 ) itemframe:SetPos( 0, 0 )
itemframe.Paint = function( self, w, h ) itemframe.Paint = function( self, w, h )
surface.SetDrawColor( 0, 0, 0, 10 ) surface.SetDrawColor( 0, 0, 0, 0 )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
end end
@ -148,7 +139,44 @@ function menu.open( dt )
local iwidth, iheight = (itempanels[maxW].x - xbasepos) + itemWidth, (itempanels[#itempanels].y - ybasepos) + itemHeight 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:SetSize( iwidth, iheight ) -- set the frames dimensions to all of the items dimensions combined.
itemframe.w, itemframe.h = itemframe:GetSize() itemframe.w, itemframe.h = itemframe:GetSize()
itemframe:SetPos( inv.w/2 - itemframe.w/2, inv.h/2 - itemframe.h/2 ) -- center the item panels itemframe:SetPos( inv.w/2 - itemframe.w/2, inv.h/2 - itemframe.h/2 + padding*8 ) -- center the item panels
itemframe.x, itemframe.y = itemframe:GetPos()
----CHAR INFO----
--Money text
local money = vgui.Create( "DLabel", inv )
money:SetText( Quantum.Format.Money( dt.cont.char.money ) )
money:SetFont( "q_money" )
money:SetTextColor( Color( 90, 218, 132, 255 ) )
money:SizeToContents()
money.w, money.h = money:GetSize()
money:SetPos( itemframe.x, itemframe.y - money.h - padding )
money.x, money.y = money:GetPos()
money.Paint = function( self, w, h )
draw.RoundedBox( 5, 0, 0, w, h, Color( 0, 0, 0, 90 ) )
end
--Name text
local name = vgui.Create( "DLabel", inv )
name:SetText( dt.cont.char.name || "ERROR: NAME=nil" )
name:SetFont( "q_name" )
name:SizeToContents()
name.w, name.h = name:GetSize()
name:SetPos( itemframe.x, money.y - name.h - padding )
name.Paint = function( self, w, h )
draw.RoundedBox( 5, 0, 0, w, h, Color( 0, 0, 0, 90 ) )
theme.pagetext( self )
end
---- TEMPORARY: REMOVE WHEN THE MENU IS DONE ----
local close = vgui.Create( "DButton", f )
close:SetText( "DEV CLOSE" )
close:SizeToContents()
close.w, close.h = close:GetSize()
close:SetPos( 0, f.h - close.h )
close.DoClick = function( self ) f:Close() end
end end
end end

@ -99,7 +99,8 @@ function Quantum.Server.Char.getBasicCharInfo( char )
name = char.name, name = char.name,
model = char.model, model = char.model,
class = char.class.Name, class = char.class.Name,
job = char.jobs[1] job = char.jobs[1],
money = char.money
} }
end end

@ -0,0 +1,31 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Format = {}
local function addMoneyVal( num )
return Quantum.Money.Prefix .. tostring( num ) .. Quantum.Money.Surfix
end
function Quantum.Format.Money( num )
if( num == nil ) then return addMoneyVal( 0 ) end
if( num >= 1e14 ) then
return addMoneyVal( num )
elseif( num <= -1e14 ) then
return addMoneyVal( "-" .. tostring( math.abs( num ) ) )
end
num = tostring( math.abs( num ) )
local sep = sep || ","
local dp = string.find( num, "%." ) || #num + 1
for i = dp - 4, 1, -3 do
num = num:sub( 1, i ) .. sep .. num:sub( i + 1 )
end
return ( negative && "-" || "" ) .. addMoneyVal( num )
end

@ -108,4 +108,5 @@ if SERVER then
end end
Quantum.Server.Load() Quantum.Server.Load()
MsgC( "\n" )
end end

@ -13,8 +13,13 @@ Quantum.DiscordInvite = "https://discord.gg/heUJB4B"
Quantum.WorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=1842234130" Quantum.WorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=1842234130"
Quantum.Inventory = { Quantum.Inventory = {
Height = 12, -- NOTE: MAX HEIGHT=12 Height = 10, -- NOTE: MAX HEIGHT=12
Width = 18 -- NOTE: MAX WIDTH=18 Width = 16 -- NOTE: MAX WIDTH=18
}
Quantum.Money = {
Prefix = "$",
Surfix = ""
} }
Quantum.Models = { Quantum.Models = {

Loading…
Cancel
Save