Major tweaks & crafting UI stuff

master
AlmTech Software 5 years ago
parent caffcbdb21
commit 4347d45c56
  1. 6
      gamemode/engine/core/client/cl_fonts.lua
  2. 9
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  3. 8
      gamemode/engine/derma/lib/cl_menu_theme.lua
  4. 77
      gamemode/engine/derma/menus/menu_crafting.lua
  5. 2
      gamemode/engine/derma/menus/menu_main.lua
  6. 2
      gamemode/engine/lib/sh_items.lua
  7. 9
      gamemode/engine/lib/sh_recipe.lua
  8. 2
      gamemode/engine/lib/sh_station.lua
  9. 41
      gamemode/init.lua
  10. 13
      gamemode/settings/sh_items.lua
  11. 11
      gamemode/settings/sh_recipes.lua
  12. 9
      gamemode/settings/sv_crafting_stations_locations.lua

@ -67,6 +67,12 @@ surface.CreateFont( "q_header_s", {
antialias = true antialias = true
}) })
surface.CreateFont( "q_header_vs", {
font = "Constantia Bold Italic",
size = 35 * Quantum.Client.ResolutionScale,
antialias = true
})
surface.CreateFont( "q_title", { surface.CreateFont( "q_title", {
font = "Cambria Bold", font = "Cambria Bold",
size = 60 * Quantum.Client.ResolutionScale, size = 60 * Quantum.Client.ResolutionScale,

@ -367,7 +367,7 @@ function iteminfo.giveoptions( p, page )
end end
function iteminfo.givetooltip( p, page ) function iteminfo.givetooltip( p, page, addW )
local item = p:GetParent().item local item = p:GetParent().item
local parWidth, parHeight = p:GetParent():GetSize() local parWidth, parHeight = p:GetParent():GetSize()
@ -492,10 +492,15 @@ function iteminfo.givetooltip( p, page )
p.ItemTooltipPanel = tooltip -- set the tooltip p.ItemTooltipPanel = tooltip -- set the tooltip
local addToW = 0
if( addW ) then
addToW = tooltip.w
end
p.Think = function( self ) p.Think = function( self )
self.ItemTooltipPanel:SetVisible( self:IsHovered() ) self.ItemTooltipPanel:SetVisible( self:IsHovered() )
if( self:IsHovered() ) then if( self:IsHovered() ) then
self.ItemTooltipPanel:SetPos( gui.MouseX() - tooltip.w/2, gui.MouseY() - ( tooltip.h + padding ) ) self.ItemTooltipPanel:SetPos( gui.MouseX() - tooltip.w/2 + addToW, gui.MouseY() - ( tooltip.h + padding ) )
end end
end end

@ -75,14 +75,16 @@ function theme.button( b, color )
draw.RoundedBox( 4, padding_s/2, padding_s/2, w - padding_s, h - padding_s, clr ) -- inner draw.RoundedBox( 4, padding_s/2, padding_s/2, w - padding_s, h - padding_s, clr ) -- inner
end end
function theme.sharpbutton( b, inClr ) function theme.sharpbutton( b, inClr, borderAlpha, hoverBorderAlpha )
borderAlpha = borderAlpha || 255
hoverBorderAlpha = hoverBorderAlpha || borderAlpha
local w, h = b:GetSize() local w, h = b:GetSize()
inClr = inClr || Color( 235, 64, 52, 255 ) inClr = inClr || Color( 235, 64, 52, 255 )
if( !b:IsHovered() ) then if( !b:IsHovered() ) then
surface.SetDrawColor( 205, 205, 205, 255 ) surface.SetDrawColor( 205, 205, 205, borderAlpha )
else else
surface.SetDrawColor( 116, 185, 255, 255 ) surface.SetDrawColor( 116, 185, 255, hoverBorderAlpha )
end end
surface.DrawOutlinedRect( 0, 0, w, h ) surface.DrawOutlinedRect( 0, 0, w, h )

@ -40,7 +40,7 @@ local function createItemAmountLabel( icon, item )
return icon.amountpanel return icon.amountpanel
end end
local function createItemPanel( x, y, scale, parent, frame ) local function createItemPanel( x, y, scale, parent, frame, addW )
local p = vgui.Create( "DPanel", parent ) local p = vgui.Create( "DPanel", parent )
p:SetSize( itemWidth * scale, itemHeight * scale ) p:SetSize( itemWidth * scale, itemHeight * scale )
p.w, p.h = p:GetSize() p.w, p.h = p:GetSize()
@ -67,7 +67,7 @@ local function createItemPanel( x, y, scale, parent, frame )
p.icon.tooltip:Remove() -- remove the old p.icon.tooltip:Remove() -- remove the old
end end
p.icon.tooltip = iteminfo.givetooltip( p.icon, frame ) -- create a new p.icon.tooltip = iteminfo.givetooltip( p.icon, frame, addW ) -- create a new
p.icon.tooltip:CreateInfo() p.icon.tooltip:CreateInfo()
p.icon:SetVisible( true ) p.icon:SetVisible( true )
@ -120,20 +120,29 @@ function menu.open( dt )
if( !Quantum.Client.CurStationMenu ) then if( !Quantum.Client.CurStationMenu ) then
Quantum.Client.IsInMenu = true Quantum.Client.IsInMenu = true
local back = vgui.Create( "DPanel" )
back:SetSize( sw, sh )
back.Paint = function( self )
theme.renderblur( self, 20, 20 )
end
local f = vgui.Create( "DFrame" ) local f = vgui.Create( "DFrame" )
Quantum.Client.CurStationMenu = f Quantum.Client.CurStationMenu = f
f:SetSize( sw, sh ) f:SetSize( 1100 * resScale, 800 * resScale )
f.w, f.h = f:GetSize() f.w, f.h = f:GetSize()
f:SetPos( sw/2 - f.w/2, sh/2 - f.h/2 )
f:SetTitle( "" ) f:SetTitle( "" )
f:SetDraggable( false ) f:SetDraggable( false )
f:ShowCloseButton( false ) f:ShowCloseButton( false )
f:MakePopup() f:MakePopup()
f.Paint = function( self, w, h ) f.Paint = function( self, w, h )
surface.SetDrawColor( 0, 0, 0, 40 ) surface.SetDrawColor( 0, 0, 0, 120 )
surface.DrawRect( 0, 0, w, h ) surface.DrawRect( 0, 0, w, h )
theme.renderblur( self, 10, 10 ) theme.renderblur( self, 10, 10 )
end end
function f:OnClose() function f:OnClose()
back:Remove()
Quantum.Client.IsInMenu = false Quantum.Client.IsInMenu = false
Quantum.Client.CurStationMenu = nil Quantum.Client.CurStationMenu = nil
Quantum.Client.Cam.Stop() Quantum.Client.Cam.Stop()
@ -162,7 +171,7 @@ function menu.open( dt )
-- Title -- -- Title --
local bar = vgui.Create( "DPanel", f ) local bar = vgui.Create( "DPanel", f )
bar:SetSize( f.w, padding*5 ) bar:SetSize( f.w, padding*4 )
bar.w, bar.h = bar:GetSize() bar.w, bar.h = bar:GetSize()
bar:SetPos( 0, 0 ) bar:SetPos( 0, 0 )
bar.Paint = function( self ) theme.blurpanel( self ) end bar.Paint = function( self ) theme.blurpanel( self ) end
@ -171,7 +180,7 @@ function menu.open( dt )
-- Inventory title -- -- Inventory title --
title = vgui.Create( "DLabel", bar ) title = vgui.Create( "DLabel", bar )
title:SetText( stationTbl.name || "ERROR name=nil" ) title:SetText( stationTbl.name || "ERROR name=nil" )
title:SetFont( "q_header_s" ) title:SetFont( "q_header_vs" )
title:SetTextColor( Color( 255, 255, 255, 255 ) ) title:SetTextColor( Color( 255, 255, 255, 255 ) )
title.Paint = function( self ) title.Paint = function( self )
theme.pagetext( self ) theme.pagetext( self )
@ -184,7 +193,7 @@ function menu.open( dt )
---- recipe list ---- ---- recipe list ----
local list = vgui.Create( "DPanel", f ) local list = vgui.Create( "DPanel", f )
list:SetSize( 400 * resScale, f.h - bar.h ) list:SetSize( f.w/4.2, f.h - bar.h )
list.w, list.h = list:GetSize() list.w, list.h = list:GetSize()
list:SetPos( 0, bar.h ) list:SetPos( 0, bar.h )
list.Paint = function( self ) list.Paint = function( self )
@ -193,6 +202,7 @@ function menu.open( dt )
local scroll = vgui.Create( "DScrollPanel", list ) local scroll = vgui.Create( "DScrollPanel", list )
scroll:SetSize( list.w, list.h ) scroll:SetSize( list.w, list.h )
scroll.w, scroll.h = scroll:GetSize()
local vbar = scroll:GetVBar() local vbar = scroll:GetVBar()
function vbar:Paint() theme.borderpanel( vbar, Color( 200, 200, 200, 200 ) ) end function vbar:Paint() theme.borderpanel( vbar, Color( 200, 200, 200, 200 ) ) end
@ -217,17 +227,50 @@ function menu.open( dt )
theme.blurpanel( self, Color( 255, 255, 255, 1 ) ) theme.blurpanel( self, Color( 255, 255, 255, 1 ) )
end end
local items = { local resBars = {}
"test", local selectedBar
"test2", for i, resID in pairs( recipes ) do
"potatoe", resBars[resID] = vgui.Create( "DPanel", scroll )
"bomb" resBars[resID].resTbl = Quantum.Recipe.Get( resID )
} resBars[resID].resItemTbl = Quantum.Item.Get( resID )
for i=1, 10 do ---- ADD CRAFT SELECT PANELS HERE
local p = createItemPanel( 200, 200*(i-1), 1.25, scroll, f ) resBars[resID]:SetSize( scroll.w, 30 * resScale )
p.SetItem( table.Random( items ) ) resBars[resID].w, resBars[resID].h = resBars[resID]:GetSize()
end
resBars[resID]:SetPos( 0, resBars[resID].h * (i-1) + padding*i )
resBars[resID].x, resBars[resID].y = resBars[resID]:GetPos()
resBars[resID].Paint = function( self, w, h )
surface.SetDrawColor( 255, 255, 255, 1 )
surface.DrawRect( 0, 0, w, h )
end
resBars[resID].txt_panel = vgui.Create( "DLabel", resBars[resID] )
resBars[resID].txt_panel:SetText( resBars[resID].resTbl.name )
resBars[resID].txt_panel:SetFont( "q_text" )
resBars[resID].txt_panel:SetTextColor( theme.color.setalpha(resBars[resID].resItemTbl.rarity.color, 200) )
resBars[resID].txt_panel:SizeToContents()
resBars[resID].txt_panel.w, resBars[resID].txt_panel.h = resBars[resID].txt_panel:GetSize()
resBars[resID].txt_panel:SetPos( padding, resBars[resID].h/2 - resBars[resID].txt_panel.h/2 )
local overlay = vgui.Create( "DButton", resBars[resID] )
overlay:SetText("")
overlay:SetSize( resBars[resID].w, resBars[resID].h )
overlay:SetPos( 0, 0 )
overlay.Paint = function( self, w, h )
theme.sharpbutton( self, Color( 0, 0, 0, 0 ), 10, 80 )
end
overlay.DoClick = function( self )
selectedBar = resBars[resID]
end
overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
end
if( #resBars > 0 ) then
selectedBar = resBars[1]
end
end end
end end

@ -80,7 +80,7 @@ function main.open(dt)
local padding_s = 4 * resScale local padding_s = 4 * resScale
local buttonWidth = 255 * resScale local buttonWidth = 255 * resScale
local buttonColor = Color( 20, 20, 20, 100 ) local buttonColor = Color( 20, 20, 20, 180 )
local buttonTextColor = Color( 255, 255, 255, 255 ) local buttonTextColor = Color( 255, 255, 255, 255 )
local buttonFont = "q_button2" local buttonFont = "q_button2"

@ -59,6 +59,6 @@ if SERVER then
end end
function Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) -- Quantum.Server.Item.SpawnItemAtPlayer( Entity(1), "potatoe", 1 ) function Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) -- Quantum.Server.Item.SpawnItemAtPlayer( Entity(1), "potatoe", 1 )
Quantum.Server.Item.SpawnItem( pl:GetPos() + ( pl:GetForward() * 40 ) + Vector( 0, 0, 40 ), itemid, amount ) Quantum.Server.Item.SpawnItem( pl:GetPos() + ( pl:GetForward() * 40 ) + Vector( 0, 0, 40 ), itemid, amount ) -- Quantum.Server.Item.SpawnItemAtPlayer( Entity(1), "jetpack", 1 )
end end
end end

@ -25,8 +25,15 @@ function Quantum.Recipe.Add( itemid, station, tbl )
Quantum.Recipes[ itemid ].delay = math.Clamp( Quantum.Recipes[ itemid ].delay, Quantum.MinCraftDelay, Quantum.MaxCraftDelay ) Quantum.Recipes[ itemid ].delay = math.Clamp( Quantum.Recipes[ itemid ].delay, Quantum.MinCraftDelay, Quantum.MaxCraftDelay )
-- add the recipe to the stations recipe list -- -- add the recipe to the stations recipe list --
if( returnTbl.station != nil ) then if( station != nil ) then
if( Quantum.Stations[ returnTbl.station ].recipes == nil ) then
Quantum.Stations[ returnTbl.station ].recipes = {}
end
table.insert( Quantum.Stations[ returnTbl.station ].recipes, itemid ) table.insert( Quantum.Stations[ returnTbl.station ].recipes, itemid )
else
if SERVER then
Quantum.Error( "Recipe '" .. itemid .. "' does not have a station! You will not be able to craft this item!" )
end
end end
return returnTbl return returnTbl

@ -15,7 +15,7 @@ function Quantum.Station.Add( id, tbl )
stationid = id, stationid = id,
name = tbl.name || "Crafting Station", -- name of the station name = tbl.name || "Crafting Station", -- name of the station
model = tbl.model || "models/props_phx/facepunch_barrel.mdl", model = tbl.model || "models/props_phx/facepunch_barrel.mdl",
recipes = tbl.recipes || {} recipes = tbl.recipes
} }
Quantum.Stations[ id ] = returnTbl Quantum.Stations[ id ] = returnTbl

@ -21,7 +21,8 @@ if SERVER then
AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "shared.lua" )
-- Content -- -- Content --
local path = "gamemodes/" .. GM.FolderName .. "/gamemode/content/materials/quantum/server_banner.png" local folname = GM.FolderName
local path = "gamemodes/" .. folname .. "/gamemode/content/materials/quantum/server_banner.png"
resource.AddSingleFile( path ) resource.AddSingleFile( path )
resource.AddSingleFile( "materials/quantum/mic_icon48.png" ) -- add the mic icon resource.AddSingleFile( "materials/quantum/mic_icon48.png" ) -- add the mic icon
@ -120,17 +121,7 @@ if SERVER then
include( "settings/sh_recipes.lua" ) include( "settings/sh_recipes.lua" )
end end
local function loadStations()
include( "settings/sv_crafting_stations_locations.lua" )
end
hook.Add( "PostGamemodeLoaded", "Quantum_Init_Stations_Load", function()
Quantum.Debug( "Spawning crafting stations..." )
loadStations()
end)
local function loadPlugins() local function loadPlugins()
local fol = GM.FolderName .. "/plugins/" local fol = GM.FolderName .. "/plugins/"
local pluginFiles = file.Find( fol .. "plugin_*.lua", "LUA" ) local pluginFiles = file.Find( fol .. "plugin_*.lua", "LUA" )
@ -148,6 +139,7 @@ if SERVER then
end end
end end
function Quantum.Server.Load() function Quantum.Server.Load()
-- Add all of the base files -- Add all of the base files
loadCoreFiles() loadCoreFiles()
@ -159,9 +151,34 @@ if SERVER then
-- Plugins -- Plugins
loadPlugins() loadPlugins()
Quantum.Server.Loaded = true
end end
local function loadStations( luaRefresh )
print( luaRefresh, Quantum.Server.Loaded, Quantum.Server.LoadedStations )
local basepath = "gamemodes/" .. folname .. "/gamemode/settings/"
print( basepath )
if( !luaRefresh ) then
include( basepath .. "sv_crafting_stations_locations.lua" )
elseif( luaRefresh && Quantum.Server.Loaded && Quantum.Server.LoadedStations ) then
include( basepath .. "sv_crafting_stations_locations.lua" )
end
end
hook.Add( "PlayerInitialSpawn", "Quantum_Init_Stations_Load", function()
Quantum.Debug( "Spawning crafting stations..." )
if( #player.GetAll() == 1 ) then -- spawn the stations when the first player joins
loadStations()
Quantum.Server.LoadedStations = true
end
end)
Quantum.Server.Load() Quantum.Server.Load()
loadStations() loadStations( true )
MsgC( "\n" ) MsgC( "\n" )
end end

@ -44,3 +44,16 @@ Quantum.Item.Create( "potatoe", {
equipslot = Quantum.EquipSlots.Head, equipslot = Quantum.EquipSlots.Head,
consumeeffect = "eat_potatoe" consumeeffect = "eat_potatoe"
} ) } )
-- weapon_gta_sa_jetpack.lua
Quantum.Item.Create( "jetpack", {
name = "Jetpack",
desc = "A jet engine strapped onto your back? Sounds fun!",
model = "models/sa_jetpack.mdl",
stack = 1,
soulbound = false,
rarity = Quantum.Rarity.Legendary,
equipslot = Quantum.EquipSlots.Weapon,
equipgive = "weapon_gta_sa_jetpack"
} )

@ -6,7 +6,7 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Recipe.Add( "potatoe", nil, { --Quantum.Server.Crafting.MakeItem( Entity(1), "potatoe" ) Quantum.Recipe.Add( "potatoe", "barrel", { --Quantum.Server.Crafting.MakeItem( Entity(1), "potatoe" )
name = "Legendary Potatoe Recipe", name = "Legendary Potatoe Recipe",
amount = 1, amount = 1,
delay = 5, delay = 5,
@ -15,3 +15,12 @@ Quantum.Recipe.Add( "potatoe", nil, { --Quantum.Server.Crafting.MakeItem( Entity
{ item = "test", amount = 2 } { item = "test", amount = 2 }
} }
}) })
Quantum.Recipe.Add( "test", "barrel", {
name = "Test Recipe",
amount = 2,
delay = 5,
recipe = {
{ item = "potatoe", amount = 1 }
}
})

@ -6,11 +6,6 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Server.Station.Create( "barrel", { Quantum.Server.Station.Create( "barrel", {
pos = Vector( 10, 0, 0 ), pos = Vector( 747.13494873047, 10483.685546875, 7168.0317382813 ),
ang = Angle( 0, 0, 0 ) ang = Angle( 0, -118.23150634766, 0 )
})
Quantum.Server.Station.Create( "barrel", {
pos = Vector( 11972.8359375, 8478.060546875, 8.03125 ),
ang = Angle( 0, -166.42593383789, 0 )
}) })
Loading…
Cancel
Save