public/IRootConsoleMenu.h
author David Anderson <dvander@alliedmods.net>
Fri Jan 26 02:04:07 2007 +0000 (2007-01-26)
changeset 373 bf3335acefdd
parent 372 47f21574db6d
child 375 a31ff1b6ae46
permissions -rw-r--r--
added license headers to extensions
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     7  * or modified under the Terms and Conditions of its License Agreement, which is found 
     8  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
     9  * may change at any time.  To view the latest information, see:
    10  *   http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
    16 #define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
    17 
    18 /**
    19  * @file IRootConsoleMenu.h
    20  * @brief Defines the interface for adding options to the "sm" console command.
    21  *
    22  *  This interface is not yet exported.  It will be eventually.  The initial reason should 
    23  * be obvious: we do not want users actually touching it.  If we exposed this, every little 
    24  * plugin would be dropping down a silly set of user commands, and exploiting/cluttering the menu.
    25  * Since this menu is explicitly provided for stuff that only Core itself is capable of managing,
    26  * we won't expose it until a legitimate reason comes up.
    27  */
    28 
    29 namespace SourceMod
    30 {
    31 	/**
    32 	 * @brief Handles a root console menu action.
    33 	 */
    34 	class IRootConsoleCommand
    35 	{
    36 	public:
    37 		virtual void OnRootConsoleCommand(const char *command, unsigned int argcount) =0;
    38 	};
    39 
    40 	/**
    41 	 * @brief Manages the root console menu - the "sm" command for servers.
    42 	 */
    43 	class IRootConsole
    44 	{
    45 	public:
    46 		/**
    47 		 * @brief Adds a root console command handler.  The command must be unique.
    48 		 *
    49 		 * @param cmd			String containing the console command.
    50 		 * @param text			Description text.
    51 		 * @param pHandler		An IRootConsoleCommand pointer to handle the command.
    52 		 * @return				True on success, false on too many commands or duplicate command.
    53 		 */
    54 		virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
    55 
    56 		/**
    57 		 * @brief Removes a root console command handler.
    58 		 *
    59 		 * @param cmd			String containing the console command.
    60 		 * @param pHandler		An IRootConsoleCommand pointer for verification.
    61 		 * @return				True on success, false otherwise.
    62 		 */
    63 		virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
    64 
    65 		/**
    66 		 * @brief Prints text back to the console.
    67 		 *
    68 		 * @param fmt			Format of string.
    69 		 * @param ...			Format arguments.
    70 		 */
    71 		virtual void ConsolePrint(const char *fmt, ...) =0;
    72 
    73 		/**
    74 		 * @brief Returns the string of an argument.
    75 		 *
    76 		 * @param argno			The index of the argument.
    77 		 * @return				A string containing the argument, or nothing if invalid.
    78 		 */
    79 		virtual const char *GetArgument(unsigned int argno) =0;
    80 
    81 		/**
    82 		 * @brief Returns the number of arguments.
    83 		 *
    84 		 * @return				Number of arguments.
    85 		 */
    86 		virtual unsigned int GetArgumentCount() =0;
    87 
    88 		/** 
    89 		 * @brief Returns the entire argument string.
    90 		 *
    91 		 * @return				String containing all arguments.
    92 		 */
    93 		virtual const char *GetArguments() =0;
    94 
    95 		/**
    96 		 * @brief Draws a generic command/description pair.
    97 		 * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
    98 		 * N being the length of the command name.  This is subject to change in case we
    99 		 * account for Valve's font choices.
   100 		 *
   101 		 * @param cmd		String containing the command option.
   102 		 * @param text		String containing the command description.
   103 		 */
   104 		virtual void DrawGenericOption(const char *cmd, const char *text) =0;
   105 	};
   106 };
   107 
   108 #endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_