mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
69
lua/derma/derma_menus.lua
Normal file
69
lua/derma/derma_menus.lua
Normal file
@@ -0,0 +1,69 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local tblOpenMenus = {}
|
||||
|
||||
function RegisterDermaMenuForClose( dmenu )
|
||||
|
||||
table.insert( tblOpenMenus, dmenu )
|
||||
|
||||
end
|
||||
|
||||
function DermaMenu( parentmenu, parent )
|
||||
|
||||
if ( !parentmenu ) then CloseDermaMenus() end
|
||||
|
||||
local dmenu = vgui.Create( "DMenu", parent )
|
||||
|
||||
return dmenu
|
||||
|
||||
end
|
||||
|
||||
function CloseDermaMenus()
|
||||
|
||||
for k, dmenu in pairs( tblOpenMenus ) do
|
||||
|
||||
if ( IsValid( dmenu ) ) then
|
||||
|
||||
dmenu:SetVisible( false )
|
||||
if ( dmenu:GetDeleteSelf() ) then
|
||||
dmenu:Remove()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tblOpenMenus = {}
|
||||
hook.Run( "CloseDermaMenus" )
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- Here we detect when the mouse is pressed on another panel
|
||||
-- This allows us to close the menus.
|
||||
--
|
||||
local function DermaDetectMenuFocus( panel, mousecode )
|
||||
|
||||
if ( IsValid( panel ) ) then
|
||||
|
||||
if ( panel.m_bIsMenuComponent ) then return end
|
||||
|
||||
-- Is the parent a menu?
|
||||
return DermaDetectMenuFocus( panel:GetParent(), mousecode )
|
||||
|
||||
end
|
||||
|
||||
CloseDermaMenus()
|
||||
|
||||
end
|
||||
|
||||
hook.Add( "VGUIMousePressed", "DermaDetectMenuFocus", DermaDetectMenuFocus )
|
||||
Reference in New Issue
Block a user