Fixed equip & unequip bug (UI)

master
AlmTech Software 5 years ago
parent f2c110ee73
commit ad6ce4a6ee
  1. 1
      gamemode/engine/core/client/cl_holster.lua
  2. 15
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  3. 11
      gamemode/engine/derma/menus/menu_charinfo.lua
  4. 3
      gamemode/settings/sh_settings.lua
  5. 4
      plugins/plugin_addweaponsasitems.lua

@ -161,19 +161,21 @@ function iteminfo.giveoptions( p, page )
if( page.shownOption == options ) then if( page.shownOption == options ) then
page.shownOption = nil page.shownOption = nil
page.showtooltips = true page.showtooltips = true
options:SetVisible( false ) options:Remove()
options:SetPos( 0, 0 )
elseif( page.shownOption != nil ) then elseif( page.shownOption != nil ) then
page.shownOption.Close() page.shownOption.Close()
end end
end end
options.panels = {}
---- all of the option panels ---- ---- all of the option panels ----
local xbasepos, ybasepos = padding_s, padding_s -- everything needs to be a bit to the side on both axises local xbasepos, ybasepos = padding_s, padding_s -- everything needs to be a bit to the side on both axises
local ypos = ybasepos local ypos = ybasepos
local yspacing = padding/4 local yspacing = padding/4
local op = {} local op = options.panels
---- Allways create the title for the item ---- ---- Allways create the title for the item ----
op.title = vgui.Create( "DLabel", options ) op.title = vgui.Create( "DLabel", options )
@ -189,8 +191,8 @@ function iteminfo.giveoptions( p, page )
if( item.equipslot != nil ) then -- Equip if( item.equipslot != nil ) then -- Equip
if( page.equippanels[item.equipslot].itemindex != index ) then if( page.equippanels[item.equipslot].GetCurrentEquipedIndex() != index ) then
print( "TRUE", page.equippanels[item.equipslot].GetCurrentEquipedIndex(), index )
op.equip = vgui.Create( "DButton", options ) op.equip = vgui.Create( "DButton", options )
op.equip:SetText( "Equip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" ) op.equip:SetText( "Equip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" )
op.equip:SetFont( "q_item_option_button" ) op.equip:SetFont( "q_item_option_button" )
@ -220,7 +222,7 @@ 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" )
@ -237,6 +239,7 @@ function iteminfo.giveoptions( p, page )
if( page.equippanels[item.equipslot] != nil ) then if( page.equippanels[item.equipslot] != nil ) then
page.equippanels[item.equipslot].SetItem( nil ) -- remove the item from the display page.equippanels[item.equipslot].SetItem( nil ) -- remove the item from the display
page.equippanels[item.equipslot].itemindex = nil
end end
if( page.markedItemPanel[item.equipslot] != nil ) then if( page.markedItemPanel[item.equipslot] != nil ) then

@ -67,7 +67,6 @@ local function createEquipSlotPanel( equiptype, x, y, scale, parent )
function p.SetItem( itemindex, itemid ) function p.SetItem( itemindex, itemid )
local item = Quantum.Client.Inventory[itemindex] local item = Quantum.Client.Inventory[itemindex]
if( item != nil ) then if( item != nil ) then
itemid = itemid || item[1] itemid = itemid || item[1]
local itemTbl = Quantum.Item.Get( itemid ) local itemTbl = Quantum.Item.Get( itemid )
@ -99,6 +98,10 @@ local function createEquipSlotPanel( equiptype, x, y, scale, parent )
end end
end end
function p.GetCurrentEquipedIndex()
return p.itemindex
end
p.icon = vgui.Create( "DModelPanel", p ) p.icon = vgui.Create( "DModelPanel", p )
p.icon:SetSize( p:GetSize() ) p.icon:SetSize( p:GetSize() )
p.icon.w, p.icon.h = p.icon:GetSize() p.icon.w, p.icon.h = p.icon:GetSize()
@ -397,10 +400,12 @@ function menu.open( dt )
---- ----
---- Click Options ---- ---- Click Options ----
itempanels[ii].icon.options = iteminfo.giveoptions( itempanels[ii].icon, f, itempanels[ii].item.amount )
itempanels[ii].icon.DoClick = function( self ) itempanels[ii].icon.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) surface.PlaySound( "UI/buttonclick.wav" )
if( self.options ) then self.options:Remove() end -- remove old options panel if it exists
self.options = iteminfo.giveoptions( self, f, itempanels[ii].item.amount ) -- create a options panel
self.options.Open() self.options.Open()
end end

@ -27,7 +27,8 @@ Quantum.Money = {
} }
Quantum.Bind = { Quantum.Bind = {
OpenInventory = KEY_TAB OpenInventory = KEY_TAB,
HolsterWeapon = ""
} }
Quantum.Models = { Quantum.Models = {

@ -11,6 +11,7 @@ plugin.types = {
pwb = "weapon_pwb", pwb = "weapon_pwb",
quantum = "quantum", quantum = "quantum",
cw = "cw", cw = "cw",
fas2 = "fas2",
m9k = "m9k", m9k = "m9k",
weapon = "weapon" weapon = "weapon"
} }
@ -20,7 +21,8 @@ plugin.AllowedTypes = {
[plugin.types.weapon] = true, [plugin.types.weapon] = true,
[plugin.types.quantum] = true, [plugin.types.quantum] = true,
[plugin.types.cw] = true, [plugin.types.cw] = true,
[plugin.types.m9k] = true [plugin.types.m9k] = true,
[plugin.types.fas2] = true
} }
local function createItemName( entclass ) local function createItemName( entclass )

Loading…
Cancel
Save