Added equip marks on items in inventory

master
AlmTech Software 5 years ago
parent 4ef0e30c28
commit 95becb5793
  1. 6
      gamemode/engine/core/client/cl_fonts.lua
  2. 10
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  3. 45
      gamemode/engine/derma/menus/menu_charinfo.lua
  4. 2
      gamemode/engine/lib/sh_items.lua
  5. 1
      gamemode/settings/sh_items.lua

@ -121,6 +121,12 @@ surface.CreateFont( "q_item_amount", {
antialias = true
})
surface.CreateFont( "q_item_mark", {
font = "Cambria Bold",
size = 26 * Quantum.Client.ResolutionScale,
antialias = true
})
surface.CreateFont( "q_item_option_button", {
font = "Cambria",
size = 24 * Quantum.Client.ResolutionScale,

@ -204,7 +204,15 @@ function iteminfo.giveoptions( p, page )
surface.PlaySound( "UI/buttonclick.wav" )
options.Close()
page.equippanels[item.equipslot].SetItem( item.id ) -- set its item
if( page.equippanels[item.equipslot] != nil ) then
page.equippanels[item.equipslot].SetItem( item.id ) -- set its item
end
if( page.markedItemPanel[item.equipslot] != nil ) then
page.markedItemPanel[item.equipslot]:SetVisible( false ) -- unmark the old panel
end
p.mark:SetVisible( true ) -- mark the new one
page.markedItemPanel[item.equipslot] = p.mark -- and save it to the table for future use
---- EQUIP NET ----
Quantum.Client.InventoryNet.EquipItem( index )

@ -30,6 +30,18 @@ local function createItemAmountLabel( icon, item )
return icon.amountpanel
end
local function createItemEquipMark( icon )
icon.mark = vgui.Create( "DLabel", icon )
icon.mark:SetText( "E" )
icon.mark:SetTextColor( Color( 205, 205, 205, 255 ) )
icon.mark:SetFont( "q_item_mark" )
icon.mark:SetVisible( false )
icon.mark:SizeToContents()
icon.mark.w, icon.mark.h = icon.mark:GetSize()
icon.mark:SetPos( padding_s, padding_s )
return icon.mark
end
local function configureCamLookPos( icon )
local mn, mx = icon.Entity:GetRenderBounds()
local size = 0
@ -115,6 +127,27 @@ local function getItemInSlot( pos )
end
end
local function getEquippedItems()
local returnTbl = {}
for equipType, equipSlot in pairs( Quantum.Client.Equipped ) do
returnTbl[ #returnTbl + 1 ] = { type = equipType, slot = equipSlot }
end
return returnTbl
end
local function checkIfItemIsEquipped( index )
local equipItems = getEquippedItems()
for ie, ii in pairs( equipItems ) do
if( ii.slot == index ) then
return true
end
end
return false
end
function menu.open( dt )
local items = Quantum.Client.Inventory
local equipped = Quantum.Client.Equipped
@ -200,7 +233,7 @@ function menu.open( dt )
function char:LayoutEntity( Entity ) return end
---- EQUIP INFO----
f.markedItemPanel = {}
f.equippanels = {} -- so we can access it later
local slotScale = 1.2
@ -283,6 +316,7 @@ function menu.open( dt )
if( itempanels[ii].icon != nil ) then
if( IsValid( itempanels[ii].icon.amountpanel ) ) then
itempanels[ii].icon.amountpanel:Remove()
itempanels[ii].icon.mark:Remove()
end
if( itempanels[ii].item.amount > 1 ) then
itempanels[ii].icon.amountpanel = createItemAmountLabel( itempanels[ii].icon, itempanels[ii].item )
@ -313,10 +347,17 @@ function menu.open( dt )
configureCamLookPos( itempanels[ii].icon )
---- Amount Text ----
if( itempanels[ii].item.amount > 1 ) then
if( itempanels[ii].GetItemAmount() > 1 ) then
itempanels[ii].icon.amountpanel = createItemAmountLabel( itempanels[ii].icon, itempanels[ii].item )
end
---- Equip Mark ----
itempanels[ii].icon.mark = createItemEquipMark( itempanels[ii].icon )
if( checkIfItemIsEquipped( itempanels[ii].index ) ) then
itempanels[ii].icon.mark:SetVisible( true )
f.markedItemPanel[itempanels[ii].item.equipslot] = itempanels[ii].icon.mark
end
---- Tooltip ----
itempanels[ii].icon.tooltip = iteminfo.givetooltip( itempanels[ii].icon, f ) -- give the item a tooltip
itempanels[ii].icon.tooltip:CreateInfo() -- create the labels for the tooltip & such

@ -57,7 +57,7 @@ if SERVER then
end
end
function Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) -- Quantum.Server.Item.SpawnItemAtPlayer( Entity(1), "test2", 5 )
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 )
end
end

@ -11,6 +11,7 @@ Quantum.Item.Create( "test", {
model = "models/props_phx/gears/bevel12.mdl",
soulbound = true,
rarity = Quantum.Rarity.Rare,
equipslot = Quantum.EquipSlots.Chest
} )
Quantum.Item.Create( "test2", {

Loading…
Cancel
Save