Crafting UI fixes

master
AlmTech Software 5 years ago
parent 1def9f6672
commit ddc016460a
  1. 19
      gamemode/engine/derma/menus/menu_crafting.lua
  2. 9
      gamemode/settings/sh_recipes.lua

@ -222,6 +222,7 @@ function menu.open( dt )
local cont = vgui.Create( "DPanel", f ) local cont = vgui.Create( "DPanel", f )
cont:SetSize( f.w - list.w, f.h - bar.h ) cont:SetSize( f.w - list.w, f.h - bar.h )
cont.w, cont.h = cont:GetSize()
cont:SetPos( list.w, bar.h ) cont:SetPos( list.w, bar.h )
cont.Paint = function( self ) cont.Paint = function( self )
theme.blurpanel( self, Color( 255, 255, 255, 1 ) ) theme.blurpanel( self, Color( 255, 255, 255, 1 ) )
@ -229,6 +230,15 @@ function menu.open( dt )
local resBars = {} local resBars = {}
local selectedBar local selectedBar
local selTxt = vgui.Create( "DLabel", cont )
selTxt:SetText( "Select a recipe" )
selTxt:SetFont( "q_info" )
selTxt:SetTextColor( Color( 255, 255, 255 ) )
selTxt:SizeToContents()
selTxt.w, selTxt.h = selTxt:GetSize()
selTxt:SetPos( cont.w/2 - selTxt.w/2, cont.h/2 - selTxt.h/2 - padding*10 )
for i, resID in pairs( recipes ) do for i, resID in pairs( recipes ) do
resBars[resID] = vgui.Create( "DPanel", scroll ) resBars[resID] = vgui.Create( "DPanel", scroll )
resBars[resID].resTbl = Quantum.Recipe.Get( resID ) resBars[resID].resTbl = Quantum.Recipe.Get( resID )
@ -261,17 +271,20 @@ function menu.open( dt )
overlay:SetPos( 0, 0 ) overlay:SetPos( 0, 0 )
overlay.Paint = function( self, w, h ) overlay.Paint = function( self, w, h )
theme.sharpbutton( self, Color( 0, 0, 0, 0 ), 10, 80 ) theme.sharpbutton( self, Color( 0, 0, 0, 0 ), 10, 80 )
if( selectedBar == self:GetParent() ) then
surface.SetDrawColor( Color( 255, 255, 255, 10 ) )
surface.DrawRect( 0, 0, w, h )
end
end end
overlay.DoClick = function( self ) overlay.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
selectedBar = resBars[resID] selectedBar = resBars[resID]
selTxt:Remove()
end end
overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
end end
if( #resBars > 0 ) then
selectedBar = resBars[1]
end
end end
end end

@ -24,3 +24,12 @@ Quantum.Recipe.Add( "test", "barrel", {
{ item = "potatoe", amount = 1 } { item = "potatoe", amount = 1 }
} }
}) })
Quantum.Recipe.Add( "test2", "barrel", {
name = "Test2 Recipe",
amount = 5,
delay = 5,
recipe = {
{ item = "potatoe", amount = 1 }
}
})

Loading…
Cancel
Save