public/IRootConsoleMenu.h
author Scott Ehlert <ds@alliedmods.net>
Wed Mar 21 21:35:07 2012 -0500 (2012-03-21)
changeset 3472 7c8bf140de6b
parent 2728 96022dad7e53
permissions -rw-r--r--
Fixed build scripts for OS X 10.7 build slave.
dvander@372
     1
/**
dvander@2728
     2
 * vim: set ts=4 sw=4 :
ds@1330
     3
 * =============================================================================
dvander@1226
     4
 * SourceMod
dvander@2728
     5
 * Copyright (C) 2004-2009 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
dvander@372
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@379
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1226
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1226
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
dvander@372
    28
 *
dvander@372
    29
 * Version: $Id$
dvander@372
    30
 */
dvander@372
    31
dvander@324
    32
#ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
dvander@324
    33
#define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
dvander@324
    34
dvander@324
    35
/**
dvander@372
    36
 * @file IRootConsoleMenu.h
dvander@372
    37
 * @brief Defines the interface for adding options to the "sm" console command.
dvander@372
    38
 *
dvander@1883
    39
 * You must be using the compat_wrappers.h header file to use this on 
dvander@1883
    40
 * Original/Episode1 builds.  
dvander@324
    41
 */
dvander@324
    42
dvander@1883
    43
#define SMINTERFACE_ROOTCONSOLE_NAME			"IRootConsole"
dvander@2728
    44
#define SMINTERFACE_ROOTCONSOLE_VERSION			2
dvander@1883
    45
dvander@1545
    46
class CCommand;
dvander@1545
    47
dvander@324
    48
namespace SourceMod
dvander@324
    49
{
dvander@324
    50
	/**
dvander@2728
    51
	 * @brief Wrapper around CCommand.
dvander@2728
    52
	 */
dvander@2728
    53
	class ICommandArgs
dvander@2728
    54
	{
dvander@2728
    55
	public:
dvander@2728
    56
		/**
dvander@2728
    57
		 * @brief Returns an argument by number.
dvander@2728
    58
		 *
dvander@2728
    59
		 * @brief n		Argument number.
dvander@2728
    60
		 * @return		Argument string.
dvander@2728
    61
		 */
dvander@2728
    62
		virtual const char *Arg(int n) const = 0;
dvander@2728
    63
dvander@2728
    64
		/**
dvander@2728
    65
		 * @brief Returns the argument count.
dvander@2728
    66
		 *
dvander@2728
    67
		 * @return		Argument count.
dvander@2728
    68
		 */
dvander@2728
    69
		virtual int ArgC() const = 0;
dvander@2728
    70
dvander@2728
    71
		/**
dvander@2728
    72
		 * @brief Returns the full argument string.
dvander@2728
    73
		 *
dvander@2728
    74
		 * @return		Argument string.
dvander@2728
    75
		 */
dvander@2728
    76
		virtual const char *ArgS() const = 0;
dvander@2728
    77
	};
dvander@2728
    78
dvander@2728
    79
	/**
dvander@324
    80
	 * @brief Handles a root console menu action.
dvander@324
    81
	 */
dvander@324
    82
	class IRootConsoleCommand
dvander@324
    83
	{
dvander@324
    84
	public:
dvander@2728
    85
		virtual void OnRootConsoleCommand(const char *cmdname, const CCommand &command)
dvander@2728
    86
		{
dvander@2728
    87
		}
dvander@2728
    88
dvander@2728
    89
		virtual void OnRootConsoleCommand2(const char *cmdname, const ICommandArgs *args)
dvander@2728
    90
		{
dvander@2728
    91
		}
dvander@324
    92
	};
dvander@324
    93
dvander@324
    94
	/**
dvander@324
    95
	 * @brief Manages the root console menu - the "sm" command for servers.
dvander@324
    96
	 */
dvander@1883
    97
	class IRootConsole : public SMInterface
dvander@324
    98
	{
dvander@324
    99
	public:
dvander@324
   100
		/**
dvander@324
   101
		 * @brief Adds a root console command handler.  The command must be unique.
dvander@324
   102
		 *
dvander@324
   103
		 * @param cmd			String containing the console command.
dvander@324
   104
		 * @param text			Description text.
dvander@324
   105
		 * @param pHandler		An IRootConsoleCommand pointer to handle the command.
dvander@324
   106
		 * @return				True on success, false on too many commands or duplicate command.
dvander@324
   107
		 */
dvander@324
   108
		virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
dvander@324
   109
dvander@324
   110
		/**
dvander@324
   111
		 * @brief Removes a root console command handler.
dvander@324
   112
		 *
dvander@324
   113
		 * @param cmd			String containing the console command.
dvander@324
   114
		 * @param pHandler		An IRootConsoleCommand pointer for verification.
dvander@324
   115
		 * @return				True on success, false otherwise.
dvander@324
   116
		 */
dvander@324
   117
		virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
dvander@324
   118
dvander@324
   119
		/**
dvander@324
   120
		 * @brief Prints text back to the console.
dvander@324
   121
		 *
dvander@324
   122
		 * @param fmt			Format of string.
dvander@324
   123
		 * @param ...			Format arguments.
dvander@324
   124
		 */
dvander@324
   125
		virtual void ConsolePrint(const char *fmt, ...) =0;
dvander@324
   126
dvander@324
   127
		/**
dvander@324
   128
		 * @brief Draws a generic command/description pair.
dvander@324
   129
		 * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
dvander@324
   130
		 * N being the length of the command name.  This is subject to change in case we
dvander@324
   131
		 * account for Valve's font choices.
dvander@324
   132
		 *
dvander@372
   133
		 * @param cmd		String containing the command option.
dvander@372
   134
		 * @param text		String containing the command description.
dvander@324
   135
		 */
dvander@324
   136
		virtual void DrawGenericOption(const char *cmd, const char *text) =0;
dvander@2728
   137
dvander@2728
   138
		/**
dvander@2728
   139
		 * @brief Adds a root console command handler.  The command must be unique.
dvander@2728
   140
		 *
dvander@2728
   141
		 * This version of the function uses the OnRootConsoleCommand2 callback.
dvander@2728
   142
		 *
dvander@2728
   143
		 * @param cmd			String containing the console command.
dvander@2728
   144
		 * @param text			Description text.
dvander@2728
   145
		 * @param pHandler		An IRootConsoleCommand pointer to handle the command.
dvander@2728
   146
		 * @return				True on success, false on too many commands or duplicate command.
dvander@2728
   147
		 */
dvander@2728
   148
		virtual bool AddRootConsoleCommand2(const char *cmd,
dvander@2728
   149
											const char *text,
dvander@2728
   150
											IRootConsoleCommand *pHandler) =0;
dvander@324
   151
	};
ds@432
   152
}
dvander@324
   153
dvander@324
   154
#endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
dvander@2728
   155