1.1 --- a/public/IRootConsoleMenu.h Wed May 13 22:07:11 2009 -0400
1.2 +++ b/public/IRootConsoleMenu.h Thu May 14 11:24:07 2009 -0400
1.3 @@ -1,8 +1,8 @@
1.4 /**
1.5 - * vim: set ts=4 :
1.6 + * vim: set ts=4 sw=4 :
1.7 * =============================================================================
1.8 * SourceMod
1.9 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.10 + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
1.11 * =============================================================================
1.12 *
1.13 * This program is free software; you can redistribute it and/or modify it under
1.14 @@ -41,19 +41,54 @@
1.15 */
1.16
1.17 #define SMINTERFACE_ROOTCONSOLE_NAME "IRootConsole"
1.18 -#define SMINTERFACE_ROOTCONSOLE_VERSION 1
1.19 +#define SMINTERFACE_ROOTCONSOLE_VERSION 2
1.20
1.21 class CCommand;
1.22
1.23 namespace SourceMod
1.24 {
1.25 /**
1.26 + * @brief Wrapper around CCommand.
1.27 + */
1.28 + class ICommandArgs
1.29 + {
1.30 + public:
1.31 + /**
1.32 + * @brief Returns an argument by number.
1.33 + *
1.34 + * @brief n Argument number.
1.35 + * @return Argument string.
1.36 + */
1.37 + virtual const char *Arg(int n) const = 0;
1.38 +
1.39 + /**
1.40 + * @brief Returns the argument count.
1.41 + *
1.42 + * @return Argument count.
1.43 + */
1.44 + virtual int ArgC() const = 0;
1.45 +
1.46 + /**
1.47 + * @brief Returns the full argument string.
1.48 + *
1.49 + * @return Argument string.
1.50 + */
1.51 + virtual const char *ArgS() const = 0;
1.52 + };
1.53 +
1.54 + /**
1.55 * @brief Handles a root console menu action.
1.56 */
1.57 class IRootConsoleCommand
1.58 {
1.59 public:
1.60 - virtual void OnRootConsoleCommand(const char *cmdname, const CCommand &command) =0;
1.61 + virtual void OnRootConsoleCommand(const char *cmdname, const CCommand &command)
1.62 + {
1.63 + }
1.64 +
1.65 + virtual void OnRootConsoleCommand2(const char *cmdname, const ICommandArgs *args)
1.66 + {
1.67 + }
1.68 };
1.69
1.70 /**
1.71 @@ -99,7 +134,22 @@
1.72 * @param text String containing the command description.
1.73 */
1.74 virtual void DrawGenericOption(const char *cmd, const char *text) =0;
1.75 +
1.76 + /**
1.77 + * @brief Adds a root console command handler. The command must be unique.
1.78 + *
1.79 + * This version of the function uses the OnRootConsoleCommand2 callback.
1.80 + *
1.81 + * @param cmd String containing the console command.
1.82 + * @param text Description text.
1.83 + * @param pHandler An IRootConsoleCommand pointer to handle the command.
1.84 + * @return True on success, false on too many commands or duplicate command.
1.85 + */
1.86 + virtual bool AddRootConsoleCommand2(const char *cmd,
1.87 + const char *text,
1.88 + IRootConsoleCommand *pHandler) =0;
1.89 };
1.90 }
1.91
1.92 #endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
1.93 +