PDA

View Full Version : CommandMenu for CSS



P47R!CK
02-11-2005, 01:22 PM
first you need to include all the files from
public/vgui/
public/vgui_controls/
and "public/cl_dll/game_controls/commandmenu.h"
then add this code



class cMenu
{
private:
vgui::Frame* m_pFrame;
CommandMenu* m_CMDMenu;

public:
cMenu();
void Create ( void );
void Destroy( void );

// these need to be registered
// in command wrappers so the user can bind the menu to a key of choice
void HideWindow( void );
void ShowWindow( void );
};



cMenu::cMenu( void )
{
m_pFrame = NULL;
}

void cMenu::Create ( void )
{
m_pFrame = new vgui::Frame( NULL , "GDMenu" );
m_pFrame->SetScheme("ClientScheme");// there are of course more shemes and you can set custom ones
m_pFrame->SetSize( 400, 400 );
m_pFrame->SetPos( 200, 200 );
m_pFrame->SetTitle(" [GD Menu]", true );
m_pFrame->SetVisible( true );

// first param tells the command menu to be bound to the window (NULL for an independant window)
// second is the name
// third is the viewport NULL is default

m_CMDMenu = new CommandMenu( NULL, "GD.OWNS", GetViewport() );// use default
m_CMDMenu->SetScheme("ClientScheme");
m_CMDMenu->SetPos( 100, 100 );
m_CMDMenu->SetSize( 200, 200 );
m_CMDMenu->SetVisible( true );
bool bOK = m_CMDMenu->LoadFromFile( "Resource/UI/BottomSpectator.res" ); // you need to make it load your resource script of course...

if (!bOK)
{
// gClientFuncs.HudText(" couldn't load resource script!");
}
}

void cMenu::Destroy( void )
{
if ( m_pFrame )
{
m_pFrame->SetParent( (vgui::Panel *)NULL );
delete m_pFrame;
}
}

void cMenu::HideWindow( void )
{
m_pFrame->SetVisible( false );
m_CMDMenu->SetVisible( false );
}

void cMenu::ShowWindow( void )
{
m_pFrame->SetVisible( true );
m_CMDMenu->SetVisible( true );
}


Credits: Source SDK, Tetsuo and the rest of the gang!

This may not appear elsewhere without permission, but may be linked.

juxtapose
02-11-2005, 03:06 PM
omg i was working on this too! thanks for the release i guess this wouldve been somewhat how mine would look if i finished =)