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 /engine/baseautocompletefilelist.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'engine/baseautocompletefilelist.h')
| -rw-r--r-- | engine/baseautocompletefilelist.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/engine/baseautocompletefilelist.h b/engine/baseautocompletefilelist.h new file mode 100644 index 0000000..6424974 --- /dev/null +++ b/engine/baseautocompletefilelist.h @@ -0,0 +1,61 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + +#ifndef BASEAUTOCOMPLETEFILELIST_H +#define BASEAUTOCOMPLETEFILELIST_H +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/convar.h" + +//----------------------------------------------------------------------------- +// Purpose: Simple helper class for doing autocompletion of all files in a specific directory by extension +//----------------------------------------------------------------------------- +class CBaseAutoCompleteFileList +{ +public: + CBaseAutoCompleteFileList( const char *cmdname, const char *subdir, const char *extension ) + { + m_pszCommandName = cmdname; + m_pszSubDir = subdir; + m_pszExtension = extension; + } + + int AutoCompletionFunc( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ); + +private: + const char *m_pszCommandName; + const char *m_pszSubDir; + const char *m_pszExtension; +}; + +#define DECLARE_AUTOCOMPLETION_FUNCTION( command, subdirectory, extension ) \ + static int g_##command##_CompletionFunc( const char *partial, \ + char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ) \ + { \ + static CBaseAutoCompleteFileList command##Complete( #command, subdirectory, #extension ); \ + return command##Complete.AutoCompletionFunc( partial, commands ); \ + } + +#define AUTOCOMPLETION_FUNCTION( command ) \ + g_##command##_CompletionFunc + +//----------------------------------------------------------------------------- +// Purpose: Utility to quicky generate a simple console command with file name autocompletion +//----------------------------------------------------------------------------- +#if !defined( _XBOX ) +#define CON_COMMAND_AUTOCOMPLETEFILE( name, func, description, subdirectory, extension ) \ + DECLARE_AUTOCOMPLETION_FUNCTION( name, subdirectory, extension ) \ + static ConCommand name##_command( #name, func, description, 0, AUTOCOMPLETION_FUNCTION( name ) ); + +#else + #define CON_COMMAND_AUTOCOMPLETEFILE( name, func, description, subdirectory, extension ) \ + static ConCommand name##_command( #name, func, description ); + +#endif +#endif // BASEAUTOCOMPLETEFILELIST_H |