public/IRootConsoleMenu.h
author David Anderson <dvander@alliedmods.net>
Wed Aug 08 02:44:36 2007 +0000 (2007-08-08)
changeset 1271 22f1534f2a61
parent 1226 478550a4d5ec
child 1330 ab94316bb52b
permissions -rw-r--r--
added a menu parameter to the vote callback
     1 /**
     2  * vim: set ts=4 :
     3  * ================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     6  * ================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or 
     9  * modify it under the terms of the GNU General Public License, 
    10  * version 3.0, as published by the Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to 
    21  * link the code of this program (as well as its derivative works) to 
    22  * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any 
    23  * Game MODs that run on software by the Valve Corporation.  You must 
    24  * obey the GNU General Public License in all respects for all other 
    25  * code used. Additionally, AlliedModders LLC grants this exception 
    26  * to all derivative works. AlliedModders LLC defines further 
    27  * exceptions, found in LICENSE.txt (as of this writing, version 
    28  * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
    34 #define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
    35 
    36 /**
    37  * @file IRootConsoleMenu.h
    38  * @brief Defines the interface for adding options to the "sm" console command.
    39  *
    40  *  This interface is not yet exported.  It will be eventually.  The initial reason should 
    41  * be obvious: we do not want users actually touching it.  If we exposed this, every little 
    42  * plugin would be dropping down a silly set of user commands, and exploiting/cluttering the menu.
    43  * Since this menu is explicitly provided for stuff that only Core itself is capable of managing,
    44  * we won't expose it until a legitimate reason comes up.
    45  */
    46 
    47 namespace SourceMod
    48 {
    49 	/**
    50 	 * @brief Handles a root console menu action.
    51 	 */
    52 	class IRootConsoleCommand
    53 	{
    54 	public:
    55 		virtual void OnRootConsoleCommand(const char *command, unsigned int argcount) =0;
    56 	};
    57 
    58 	/**
    59 	 * @brief Manages the root console menu - the "sm" command for servers.
    60 	 */
    61 	class IRootConsole
    62 	{
    63 	public:
    64 		/**
    65 		 * @brief Adds a root console command handler.  The command must be unique.
    66 		 *
    67 		 * @param cmd			String containing the console command.
    68 		 * @param text			Description text.
    69 		 * @param pHandler		An IRootConsoleCommand pointer to handle the command.
    70 		 * @return				True on success, false on too many commands or duplicate command.
    71 		 */
    72 		virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
    73 
    74 		/**
    75 		 * @brief Removes a root console command handler.
    76 		 *
    77 		 * @param cmd			String containing the console command.
    78 		 * @param pHandler		An IRootConsoleCommand pointer for verification.
    79 		 * @return				True on success, false otherwise.
    80 		 */
    81 		virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
    82 
    83 		/**
    84 		 * @brief Prints text back to the console.
    85 		 *
    86 		 * @param fmt			Format of string.
    87 		 * @param ...			Format arguments.
    88 		 */
    89 		virtual void ConsolePrint(const char *fmt, ...) =0;
    90 
    91 		/**
    92 		 * @brief Returns the string of an argument.
    93 		 *
    94 		 * @param argno			The index of the argument.
    95 		 * @return				A string containing the argument, or nothing if invalid.
    96 		 */
    97 		virtual const char *GetArgument(unsigned int argno) =0;
    98 
    99 		/**
   100 		 * @brief Returns the number of arguments.
   101 		 *
   102 		 * @return				Number of arguments.
   103 		 */
   104 		virtual unsigned int GetArgumentCount() =0;
   105 
   106 		/** 
   107 		 * @brief Returns the entire argument string.
   108 		 *
   109 		 * @return				String containing all arguments.
   110 		 */
   111 		virtual const char *GetArguments() =0;
   112 
   113 		/**
   114 		 * @brief Draws a generic command/description pair.
   115 		 * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
   116 		 * N being the length of the command name.  This is subject to change in case we
   117 		 * account for Valve's font choices.
   118 		 *
   119 		 * @param cmd		String containing the command option.
   120 		 * @param text		String containing the command description.
   121 		 */
   122 		virtual void DrawGenericOption(const char *cmd, const char *text) =0;
   123 	};
   124 }
   125 
   126 #endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_