Added icons to crafting UI & amount labels

master
AlmTech Software 5 years ago
parent 0a2e07fadc
commit 9638d2c49f
  1. 5
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  2. 43
      gamemode/engine/derma/menus/menu_crafting.lua
  3. 2
      gamemode/settings/sh_recipes.lua

@ -222,7 +222,6 @@ function iteminfo.giveoptions( p, page )
end end
else else
print( "FALSE", page.equippanels[item.equipslot].GetCurrentEquipedIndex(), index )
op.equip = vgui.Create( "DButton", options ) op.equip = vgui.Create( "DButton", options )
op.equip:SetText( "Unequip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" ) op.equip:SetText( "Unequip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" )
op.equip:SetFont( "q_item_option_button" ) op.equip:SetFont( "q_item_option_button" )
@ -493,14 +492,14 @@ function iteminfo.givetooltip( p, page, addW )
p.ItemTooltipPanel = tooltip -- set the tooltip p.ItemTooltipPanel = tooltip -- set the tooltip
local addToW = 0 local addToW = 0
if( addW ) then if( addW == true ) then
addToW = tooltip.w addToW = tooltip.w
end 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 + addToW, gui.MouseY() - ( tooltip.h + padding ) ) self.ItemTooltipPanel:SetPos( (gui.MouseX() - tooltip.w/2) + addToW, gui.MouseY() - (tooltip.h + padding*2) )
end end
end end

@ -33,14 +33,14 @@ local function createItemAmountLabel( icon, item )
icon.amountpanel = vgui.Create( "DLabel", icon ) icon.amountpanel = vgui.Create( "DLabel", icon )
icon.amountpanel:SetText( tostring( item.amount ) ) icon.amountpanel:SetText( tostring( item.amount ) )
icon.amountpanel:SetTextColor( Color( 205, 205, 205, 255 ) ) icon.amountpanel:SetTextColor( Color( 205, 205, 205, 255 ) )
icon.amountpanel:SetFont( "q_item_amount" ) icon.amountpanel:SetFont( "q_info" )
icon.amountpanel:SizeToContents() icon.amountpanel:SizeToContents()
icon.amountpanel.w, icon.amountpanel.h = icon.amountpanel:GetSize() icon.amountpanel.w, icon.amountpanel.h = icon.amountpanel:GetSize()
icon.amountpanel:SetPos( ( icon.w - icon.amountpanel.w ) - padding_s, icon.h - icon.amountpanel.h ) icon.amountpanel:SetPos( ( icon.w - icon.amountpanel.w ) - padding_s, icon.h - icon.amountpanel.h )
return icon.amountpanel return icon.amountpanel
end end
local function createItemPanel( x, y, scale, parent, frame, addW ) local function createItemPanel( x, y, scale, parent, frame, addW, giveToolTip )
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,8 +67,10 @@ local function createItemPanel( x, y, scale, parent, frame, addW )
p.icon.tooltip:Remove() -- remove the old p.icon.tooltip:Remove() -- remove the old
end end
if( giveToolTip == true ) then
p.icon.tooltip = iteminfo.givetooltip( p.icon, frame, addW ) -- create a new p.icon.tooltip = iteminfo.givetooltip( p.icon, frame, addW ) -- create a new
p.icon.tooltip:CreateInfo() p.icon.tooltip:CreateInfo()
end
p.icon:SetVisible( true ) p.icon:SetVisible( true )
p.icon:SetModel( itemTbl.model ) p.icon:SetModel( itemTbl.model )
@ -233,9 +235,6 @@ function menu.open( dt )
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 )
if( i == 1 ) then selectedBar = resBars[resID] end
resBars[resID].resTbl = Quantum.Recipe.Get( resID ) resBars[resID].resTbl = Quantum.Recipe.Get( resID )
resBars[resID].resItemTbl = Quantum.Item.Get( resID ) resBars[resID].resItemTbl = Quantum.Item.Get( resID )
@ -260,6 +259,32 @@ function menu.open( dt )
resBars[resID].txt_panel:SetPos( padding, resBars[resID].h/2 - resBars[resID].txt_panel.h/2 ) resBars[resID].txt_panel:SetPos( padding, resBars[resID].h/2 - resBars[resID].txt_panel.h/2 )
---- content page ----
resBars[resID].cont = vgui.Create( "DPanel", cont )
resBars[resID].cont:SetSize( cont:GetSize() )
resBars[resID].cont.Paint = function( self ) end
resBars[resID].cont.w ,resBars[resID].cont.h = resBars[resID].cont:GetSize()
local mw, mh = resBars[resID].cont.w ,resBars[resID].cont.h
-- icon
resBars[resID].cont.icon = createItemPanel( mw/8, mh/8, 2, resBars[resID].cont, f )
resBars[resID].cont.icon.SetItem( resID )
if( resBars[resID].resTbl.amount > 1 ) then
createItemAmountLabel( resBars[resID].cont.icon, resBars[resID].resTbl )
end
-- title
resBars[resID].cont.title = vgui.Create( "DLabel", resBars[resID].cont )
resBars[resID].cont.title:SetText( resBars[resID].resTbl.name )
resBars[resID].cont.title:SetFont( "q_header_vs" )
resBars[resID].cont.title:SetTextColor( theme.color.setalpha( resBars[resID].resItemTbl.rarity.color, 255 ) )
resBars[resID].cont.title:SizeToContents()
resBars[resID].cont.title.w, resBars[resID].cont.title.h = resBars[resID].cont.title:GetSize()
resBars[resID].cont.title:SetPos( resBars[resID].cont.icon.x + resBars[resID].cont.icon.w + padding*2, resBars[resID].cont.icon.y )
resBars[resID].cont:SetVisible( false )
local overlay = vgui.Create( "DButton", resBars[resID] ) local overlay = vgui.Create( "DButton", resBars[resID] )
overlay:SetText("") overlay:SetText("")
overlay:SetSize( resBars[resID].w, resBars[resID].h ) overlay:SetSize( resBars[resID].w, resBars[resID].h )
@ -274,11 +299,17 @@ function menu.open( dt )
overlay.DoClick = function( self ) overlay.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
selectedBar.cont:SetVisible( false )
selectedBar = resBars[resID] selectedBar = resBars[resID]
selTxt:Remove() resBars[resID].cont:SetVisible( true )
end end
overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end overlay.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
if( i == 1 ) then
selectedBar = resBars[resID]
selectedBar.cont:SetVisible( true )
end
end end
end end

@ -6,7 +6,7 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Recipe.Add( "potatoe", "barrel", { --Quantum.Server.Crafting.MakeItem( Entity(1), "potatoe" ) Quantum.Recipe.Add( "potatoe", "barrel", {
name = "Legendary Potatoe Recipe", name = "Legendary Potatoe Recipe",
amount = 1, amount = 1,
delay = 5, delay = 5,

Loading…
Cancel
Save