# console_internal.h

Go to the documentation of this file.

    00001 /* $Id: console_internal.h 18809 2010-01-15 16:41:15Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef CONSOLE_INTERNAL_H
    00013 #define CONSOLE_INTERNAL_H
    00014
    00015 #include "console_type.h"
    00016
    00017 enum {
    00018   ICON_CMDLN_SIZE     = 1024,
    00019   ICON_MAX_STREAMSIZE = 2048,
    00020 };
    00021
    00022 enum IConsoleVarTypes {
    00023   ICONSOLE_VAR_BOOLEAN,
    00024   ICONSOLE_VAR_BYTE,
    00025   ICONSOLE_VAR_UINT16,
    00026   ICONSOLE_VAR_UINT32,
    00027   ICONSOLE_VAR_INT16,
    00028   ICONSOLE_VAR_INT32,
    00029   ICONSOLE_VAR_STRING
    00030 };
    00031
    00032 enum IConsoleHookTypes {
    00033   ICONSOLE_HOOK_ACCESS,
    00034   ICONSOLE_HOOK_PRE_ACTION,
    00035   ICONSOLE_HOOK_POST_ACTION
    00036 };
    00037
    00043 typedef bool IConsoleHook();
    00044 struct IConsoleHooks{
    00045   IConsoleHook *access;
    00046   IConsoleHook *pre;
    00047   IConsoleHook *post;
    00048 };
    00049
    00057 typedef bool (IConsoleCmdProc)(byte argc, char *argv[]);
    00058
    00059 struct IConsoleCmd {
    00060   char *name;
    00061   IConsoleCmd *next;
    00062
    00063   IConsoleCmdProc *proc;
    00064   IConsoleHooks hook;
    00065 };
    00066
    00076 struct IConsoleVar {
    00077   char *name;
    00078   IConsoleVar *next;
    00079
    00080   void *addr;
    00081   uint32 size;
    00082   char *help;
    00083   IConsoleVarTypes type;
    00084   IConsoleCmdProc *proc;
    00085   IConsoleHooks hook;
    00086 };
    00087
    00099 struct IConsoleAlias {
    00100   char *name;
    00101   IConsoleAlias *next;
    00102
    00103   char *cmdline;
    00104 };
    00105
    00106 /* console parser */
    00107 extern IConsoleCmd   *_iconsole_cmds;
    00108 extern IConsoleVar   *_iconsole_vars;
    00109 extern IConsoleAlias *_iconsole_aliases;
    00110
    00111 /* console functions */
    00112 void IConsoleClearBuffer();
    00113
    00114 /* Commands */
    00115 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc);
    00116 void IConsoleAliasRegister(const char *name, const char *cmd);
    00117 IConsoleCmd *IConsoleCmdGet(const char *name);
    00118 IConsoleAlias *IConsoleAliasGet(const char *name);
    00119
    00120 /* Variables */
    00121 void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help);
    00122 void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help);
    00123 IConsoleVar *IConsoleVarGet(const char *name);
    00124 void IConsoleVarPrintGetValue(const IConsoleVar *var);
    00125
    00126 /* console std lib (register ingame commands/aliases/variables) */
    00127 void IConsoleStdLibRegister();
    00128
    00129 /* Hooking code */
    00130 void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
    00131 void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
    00132 void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc);
    00133
    00134 /* Supporting functions */
    00135 bool GetArgumentInteger(uint32 *value, const char *arg);
    00136
    00137 void IConsoleGUIInit();
    00138 void IConsoleGUIFree();
    00139 void IConsoleGUIPrint(ConsoleColour colour_code, char *string);
    00140
    00141 #endif /* CONSOLE_INTERNAL_H */