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