diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /tools/toolutils/ToolHelpMenuButton.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'tools/toolutils/ToolHelpMenuButton.cpp')
| -rw-r--r-- | tools/toolutils/ToolHelpMenuButton.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/toolutils/ToolHelpMenuButton.cpp b/tools/toolutils/ToolHelpMenuButton.cpp new file mode 100644 index 0000000..6ee6567 --- /dev/null +++ b/tools/toolutils/ToolHelpMenuButton.cpp @@ -0,0 +1,60 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Core Movie Maker UI API +// +//============================================================================= + +#include "toolutils/toolswitchmenubutton.h" +#include "vgui_controls/panel.h" +#include "toolutils/toolmenubutton.h" +#include "toolutils/enginetools_int.h" +#include "tier1/KeyValues.h" +#include "vgui_controls/menu.h" +#include "vgui/ILocalize.h" +#include "toolframework/ienginetool.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + + +//----------------------------------------------------------------------------- +// Menu to switch between tools +//----------------------------------------------------------------------------- +class CToolHelpMenuButton : public CToolMenuButton +{ + DECLARE_CLASS_SIMPLE( CToolHelpMenuButton, CToolMenuButton ); + +public: + CToolHelpMenuButton( char const *toolName, char const *helpBinding, vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget ); +}; + + +//----------------------------------------------------------------------------- +// Global function to create the help menu +//----------------------------------------------------------------------------- +CToolMenuButton* CreateToolHelpMenuButton( char const *toolName, char const *helpBinding, vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget ) +{ + return new CToolHelpMenuButton( toolName, helpBinding, parent, panelName, text, pActionTarget ); +} + + +//----------------------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------------------- +CToolHelpMenuButton::CToolHelpMenuButton( char const *toolName, char const *helpBinding, vgui::Panel *parent, const char *panelName, const char *text, vgui::Panel *pActionTarget ) : + BaseClass( parent, panelName, text, pActionTarget ) +{ + wchar_t *fmt = g_pVGuiLocalize->Find( "ToolHelpShowHelp" ); + if ( fmt ) + { + wchar_t desc[ 256 ]; + g_pVGuiLocalize->ConvertANSIToUnicode( toolName, desc, sizeof( desc ) ); + + wchar_t buf[ 512 ]; + g_pVGuiLocalize->ConstructString( buf, sizeof( buf ), fmt, 1, desc ); + + AddMenuItem( "help", buf, new KeyValues( "OnHelp" ), pActionTarget, NULL, helpBinding ); + } + + SetMenu(m_pMenu); +} |