• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

public/IRootConsoleMenu.h

Go to the documentation of this file.
00001 /**
00002  * vim: set ts=4 sw=4 :
00003  * =============================================================================
00004  * SourceMod
00005  * Copyright (C) 2004-2009 AlliedModders LLC.  All rights reserved.
00006  * =============================================================================
00007  *
00008  * This program is free software; you can redistribute it and/or modify it under
00009  * the terms of the GNU General Public License, version 3.0, as published by the
00010  * Free Software Foundation.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  *
00017  * You should have received a copy of the GNU General Public License along with
00018  * this program.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  * As a special exception, AlliedModders LLC gives you permission to link the
00021  * code of this program (as well as its derivative works) to "Half-Life 2," the
00022  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
00023  * by the Valve Corporation.  You must obey the GNU General Public License in
00024  * all respects for all other code used.  Additionally, AlliedModders LLC grants
00025  * this exception to all derivative works.  AlliedModders LLC defines further
00026  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
00027  * or <http://www.sourcemod.net/license.php>.
00028  *
00029  * Version: $Id$
00030  */
00031 
00032 #ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
00033 #define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
00034 
00035 /**
00036  * @file IRootConsoleMenu.h
00037  * @brief Defines the interface for adding options to the "sm" console command.
00038  *
00039  * You must be using the compat_wrappers.h header file to use this on 
00040  * Original/Episode1 builds.  
00041  */
00042 
00043 #define SMINTERFACE_ROOTCONSOLE_NAME                        "IRootConsole"
00044 #define SMINTERFACE_ROOTCONSOLE_VERSION                     2
00045 
00046 class CCommand;
00047 
00048 namespace SourceMod
00049 {
00050           /**
00051            * @brief Wrapper around CCommand.
00052            */
00053           class ICommandArgs
00054           {
00055           public:
00056                     /**
00057                      * @brief Returns an argument by number.
00058                      *
00059                      * @brief n                   Argument number.
00060                      * @return                    Argument string.
00061                      */
00062                     virtual const char *Arg(int n) const = 0;
00063 
00064                     /**
00065                      * @brief Returns the argument count.
00066                      *
00067                      * @return                    Argument count.
00068                      */
00069                     virtual int ArgC() const = 0;
00070 
00071                     /**
00072                      * @brief Returns the full argument string.
00073                      *
00074                      * @return                    Argument string.
00075                      */
00076                     virtual const char *ArgS() const = 0;
00077           };
00078 
00079           /**
00080            * @brief Handles a root console menu action.
00081            */
00082           class IRootConsoleCommand
00083           {
00084           public:
00085                     virtual void OnRootConsoleCommand(const char *cmdname, const CCommand &command)
00086                     {
00087                     }
00088 
00089                     virtual void OnRootConsoleCommand2(const char *cmdname, const ICommandArgs *args)
00090                     {
00091                     }
00092           };
00093 
00094           /**
00095            * @brief Manages the root console menu - the "sm" command for servers.
00096            */
00097           class IRootConsole : public SMInterface
00098           {
00099           public:
00100                     /**
00101                      * @brief Adds a root console command handler.  The command must be unique.
00102                      *
00103                      * @param cmd                           String containing the console command.
00104                      * @param text                          Description text.
00105                      * @param pHandler            An IRootConsoleCommand pointer to handle the command.
00106                      * @return                                        True on success, false on too many commands or duplicate command.
00107                      */
00108                     virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
00109 
00110                     /**
00111                      * @brief Removes a root console command handler.
00112                      *
00113                      * @param cmd                           String containing the console command.
00114                      * @param pHandler            An IRootConsoleCommand pointer for verification.
00115                      * @return                                        True on success, false otherwise.
00116                      */
00117                     virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
00118 
00119                     /**
00120                      * @brief Prints text back to the console.
00121                      *
00122                      * @param fmt                           Format of string.
00123                      * @param ...                           Format arguments.
00124                      */
00125                     virtual void ConsolePrint(const char *fmt, ...) =0;
00126 
00127                     /**
00128                      * @brief Draws a generic command/description pair.
00129                      * NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
00130                      * N being the length of the command name.  This is subject to change in case we
00131                      * account for Valve's font choices.
00132                      *
00133                      * @param cmd                 String containing the command option.
00134                      * @param text                String containing the command description.
00135                      */
00136                     virtual void DrawGenericOption(const char *cmd, const char *text) =0;
00137 
00138                     /**
00139                      * @brief Adds a root console command handler.  The command must be unique.
00140                      *
00141                      * This version of the function uses the OnRootConsoleCommand2 callback.
00142                      *
00143                      * @param cmd                           String containing the console command.
00144                      * @param text                          Description text.
00145                      * @param pHandler            An IRootConsoleCommand pointer to handle the command.
00146                      * @return                                        True on success, false on too many commands or duplicate command.
00147                      */
00148                     virtual bool AddRootConsoleCommand2(const char *cmd,
00149                                                                                                               const char *text,
00150                                                                                                               IRootConsoleCommand *pHandler) =0;
00151           };
00152 }
00153 
00154 #endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
00155 

Generated on Wed Dec 7 2011 18:50:02 for SourceMod SDK by  doxygen 1.7.1