From ddc016460ab1ae6842c2330fda22b0edca116779 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Fri, 31 Jan 2020 21:46:28 +0100 Subject: [PATCH] Crafting UI fixes --- gamemode/engine/derma/menus/menu_crafting.lua | 19 ++++++++++++++++--- gamemode/settings/sh_recipes.lua | 9 +++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gamemode/engine/derma/menus/menu_crafting.lua b/gamemode/engine/derma/menus/menu_crafting.lua index fd042ff..8e2f450 100644 --- a/gamemode/engine/derma/menus/menu_crafting.lua +++ b/gamemode/engine/derma/menus/menu_crafting.lua @@ -222,6 +222,7 @@ function menu.open( dt ) local cont = vgui.Create( "DPanel", f ) cont:SetSize( f.w - list.w, f.h - bar.h ) + cont.w, cont.h = cont:GetSize() cont:SetPos( list.w, bar.h ) cont.Paint = function( self ) theme.blurpanel( self, Color( 255, 255, 255, 1 ) ) @@ -229,6 +230,15 @@ function menu.open( dt ) local resBars = {} 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 resBars[resID] = vgui.Create( "DPanel", scroll ) resBars[resID].resTbl = Quantum.Recipe.Get( resID ) @@ -261,17 +271,20 @@ function menu.open( dt ) overlay:SetPos( 0, 0 ) overlay.Paint = function( self, w, h ) 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 overlay.DoClick = function( self ) surface.PlaySound( "UI/buttonclick.wav" ) selectedBar = resBars[resID] + selTxt:Remove() end + overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end end - if( #resBars > 0 ) then - selectedBar = resBars[1] - end end end diff --git a/gamemode/settings/sh_recipes.lua b/gamemode/settings/sh_recipes.lua index f352f50..a501e0e 100644 --- a/gamemode/settings/sh_recipes.lua +++ b/gamemode/settings/sh_recipes.lua @@ -24,3 +24,12 @@ Quantum.Recipe.Add( "test", "barrel", { { item = "potatoe", amount = 1 } } }) + +Quantum.Recipe.Add( "test2", "barrel", { + name = "Test2 Recipe", + amount = 5, + delay = 5, + recipe = { + { item = "potatoe", amount = 1 } + } +})