From ad6ce4a6ee3fbd805f0881d2741cf4ddca8b349b Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Wed, 8 Jan 2020 18:13:36 +0100 Subject: [PATCH] Fixed equip & unequip bug (UI) --- gamemode/engine/core/client/cl_holster.lua | 1 + gamemode/engine/derma/lib/cl_menu_iteminfo.lua | 15 +++++++++------ gamemode/engine/derma/menus/menu_charinfo.lua | 11 ++++++++--- gamemode/settings/sh_settings.lua | 3 ++- plugins/plugin_addweaponsasitems.lua | 4 +++- 5 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 gamemode/engine/core/client/cl_holster.lua diff --git a/gamemode/engine/core/client/cl_holster.lua b/gamemode/engine/core/client/cl_holster.lua new file mode 100644 index 0000000..4ba2805 --- /dev/null +++ b/gamemode/engine/core/client/cl_holster.lua @@ -0,0 +1 @@ +-- diff --git a/gamemode/engine/derma/lib/cl_menu_iteminfo.lua b/gamemode/engine/derma/lib/cl_menu_iteminfo.lua index 55c403f..e7c3057 100644 --- a/gamemode/engine/derma/lib/cl_menu_iteminfo.lua +++ b/gamemode/engine/derma/lib/cl_menu_iteminfo.lua @@ -161,19 +161,21 @@ function iteminfo.giveoptions( p, page ) if( page.shownOption == options ) then page.shownOption = nil page.showtooltips = true - options:SetVisible( false ) - options:SetPos( 0, 0 ) + options:Remove() elseif( page.shownOption != nil ) then page.shownOption.Close() end end + + options.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 ypos = ybasepos local yspacing = padding/4 - local op = {} + local op = options.panels ---- Allways create the title for the item ---- op.title = vgui.Create( "DLabel", options ) @@ -189,8 +191,8 @@ function iteminfo.giveoptions( p, page ) 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:SetText( "Equip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" ) op.equip:SetFont( "q_item_option_button" ) @@ -220,7 +222,7 @@ function iteminfo.giveoptions( p, page ) end else - + print( "FALSE", page.equippanels[item.equipslot].GetCurrentEquipedIndex(), index ) op.equip = vgui.Create( "DButton", options ) op.equip:SetText( "Unequip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" ) op.equip:SetFont( "q_item_option_button" ) @@ -237,6 +239,7 @@ function iteminfo.giveoptions( p, page ) if( page.equippanels[item.equipslot] != nil ) then page.equippanels[item.equipslot].SetItem( nil ) -- remove the item from the display + page.equippanels[item.equipslot].itemindex = nil end if( page.markedItemPanel[item.equipslot] != nil ) then diff --git a/gamemode/engine/derma/menus/menu_charinfo.lua b/gamemode/engine/derma/menus/menu_charinfo.lua index 71dea9c..fd93836 100644 --- a/gamemode/engine/derma/menus/menu_charinfo.lua +++ b/gamemode/engine/derma/menus/menu_charinfo.lua @@ -67,7 +67,6 @@ local function createEquipSlotPanel( equiptype, x, y, scale, parent ) function p.SetItem( itemindex, itemid ) local item = Quantum.Client.Inventory[itemindex] - if( item != nil ) then itemid = itemid || item[1] local itemTbl = Quantum.Item.Get( itemid ) @@ -99,6 +98,10 @@ local function createEquipSlotPanel( equiptype, x, y, scale, parent ) end end + function p.GetCurrentEquipedIndex() + return p.itemindex + end + p.icon = vgui.Create( "DModelPanel", p ) p.icon:SetSize( p:GetSize() ) p.icon.w, p.icon.h = p.icon:GetSize() @@ -397,10 +400,12 @@ function menu.open( dt ) ---- ---- Click Options ---- - itempanels[ii].icon.options = iteminfo.giveoptions( itempanels[ii].icon, f, itempanels[ii].item.amount ) - itempanels[ii].icon.DoClick = function( self ) 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() end diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index c4a5b43..a1d06ee 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -27,7 +27,8 @@ Quantum.Money = { } Quantum.Bind = { - OpenInventory = KEY_TAB + OpenInventory = KEY_TAB, + HolsterWeapon = "" } Quantum.Models = { diff --git a/plugins/plugin_addweaponsasitems.lua b/plugins/plugin_addweaponsasitems.lua index ae048be..39a1bfe 100644 --- a/plugins/plugin_addweaponsasitems.lua +++ b/plugins/plugin_addweaponsasitems.lua @@ -11,6 +11,7 @@ plugin.types = { pwb = "weapon_pwb", quantum = "quantum", cw = "cw", + fas2 = "fas2", m9k = "m9k", weapon = "weapon" } @@ -20,7 +21,8 @@ plugin.AllowedTypes = { [plugin.types.weapon] = true, [plugin.types.quantum] = true, [plugin.types.cw] = true, - [plugin.types.m9k] = true + [plugin.types.m9k] = true, + [plugin.types.fas2] = true } local function createItemName( entclass )