2004-09-11 19:18:30 +00:00
|
|
|
#ifndef CONSOLE_H
|
|
|
|
#define CONSOLE_H
|
2004-09-12 20:15:18 +00:00
|
|
|
|
2004-08-24 22:41:42 +00:00
|
|
|
// ** console parser ** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
typedef enum _iconsole_var_types {
|
|
|
|
ICONSOLE_VAR_NONE,
|
2004-08-24 22:41:42 +00:00
|
|
|
ICONSOLE_VAR_BOOLEAN,
|
|
|
|
ICONSOLE_VAR_BYTE,
|
|
|
|
ICONSOLE_VAR_UINT16,
|
|
|
|
ICONSOLE_VAR_UINT32,
|
|
|
|
ICONSOLE_VAR_INT16,
|
|
|
|
ICONSOLE_VAR_INT32,
|
|
|
|
ICONSOLE_VAR_STRING,
|
|
|
|
ICONSOLE_VAR_POINTER,
|
2004-08-25 22:11:41 +00:00
|
|
|
ICONSOLE_VAR_REFERENCE,
|
2004-09-19 15:24:45 +00:00
|
|
|
ICONSOLE_VAR_UNKNOWN
|
2004-08-24 22:41:42 +00:00
|
|
|
} _iconsole_var_types;
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
typedef enum _iconsole_hook_types {
|
2004-09-12 20:15:18 +00:00
|
|
|
ICONSOLE_HOOK_ACCESS,
|
|
|
|
ICONSOLE_HOOK_BEFORE_CHANGE,
|
|
|
|
ICONSOLE_HOOK_BEFORE_EXEC,
|
|
|
|
ICONSOLE_HOOK_AFTER_CHANGE,
|
2004-09-19 15:24:45 +00:00
|
|
|
ICONSOLE_HOOK_AFTER_EXEC
|
2004-09-12 20:15:18 +00:00
|
|
|
} _iconsole_hook_types;
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
struct _iconsole_var;
|
|
|
|
typedef bool (*iconsole_var_hook)(struct _iconsole_var* hook_var);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
typedef struct _iconsole_var {
|
2004-08-24 22:41:42 +00:00
|
|
|
// --------------- //
|
2004-09-19 15:24:45 +00:00
|
|
|
union {
|
|
|
|
void* addr;
|
|
|
|
bool* bool_;
|
|
|
|
byte* byte_;
|
|
|
|
uint16* uint16_;
|
|
|
|
uint32* uint32_;
|
|
|
|
int16* int16_;
|
|
|
|
int32* int32_;
|
|
|
|
char* string_;
|
|
|
|
struct _iconsole_var* reference_;
|
|
|
|
} data;
|
|
|
|
char* name;
|
|
|
|
_iconsole_var_types type;
|
2004-08-24 22:41:42 +00:00
|
|
|
// -------------- //
|
2004-09-19 15:24:45 +00:00
|
|
|
iconsole_var_hook hook_access;
|
|
|
|
iconsole_var_hook hook_before_change;
|
|
|
|
iconsole_var_hook hook_after_change;
|
2004-09-12 20:15:18 +00:00
|
|
|
// -------------- //
|
2004-09-19 15:24:45 +00:00
|
|
|
struct _iconsole_var* _next;
|
2004-08-24 22:41:42 +00:00
|
|
|
bool _malloc;
|
2004-09-19 15:24:45 +00:00
|
|
|
} _iconsole_var;
|
|
|
|
|
|
|
|
struct _iconsole_cmd;
|
|
|
|
typedef bool (*iconsole_cmd_hook)(struct _iconsole_cmd* hook_cmd);
|
|
|
|
|
|
|
|
typedef _iconsole_var* (*_iconsole_cmd_addr)(byte argc, char* argv[], byte argt[]);
|
|
|
|
|
|
|
|
typedef struct _iconsole_cmd {
|
|
|
|
// -------------- //
|
|
|
|
_iconsole_cmd_addr addr;
|
|
|
|
char* name;
|
|
|
|
// -------------- //
|
|
|
|
iconsole_cmd_hook hook_access;
|
|
|
|
iconsole_cmd_hook hook_before_exec;
|
|
|
|
iconsole_cmd_hook hook_after_exec;
|
|
|
|
// -------------- //
|
|
|
|
void* _next;
|
|
|
|
} _iconsole_cmd;
|
2004-08-24 22:41:42 +00:00
|
|
|
|
2004-09-12 20:15:18 +00:00
|
|
|
// ** console parser ** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
_iconsole_cmd* _iconsole_cmds; // list of registred commands
|
|
|
|
_iconsole_var* _iconsole_vars; // list of registred vars
|
2004-09-12 20:15:18 +00:00
|
|
|
|
2004-08-25 22:11:41 +00:00
|
|
|
// ** console colors ** //
|
|
|
|
VARDEF byte _iconsole_color_default;
|
|
|
|
VARDEF byte _iconsole_color_error;
|
2004-09-14 16:30:33 +00:00
|
|
|
VARDEF byte _iconsole_color_warning;
|
2004-08-25 22:11:41 +00:00
|
|
|
VARDEF byte _iconsole_color_debug;
|
|
|
|
VARDEF byte _iconsole_color_commands;
|
|
|
|
|
2004-08-24 22:41:42 +00:00
|
|
|
// ** ttd.c functions ** //
|
2004-09-12 20:15:18 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
void SetDebugString(const char* s);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
|
|
|
// ** console functions ** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleInit(void);
|
|
|
|
void IConsoleClear(void);
|
|
|
|
void IConsoleFree(void);
|
|
|
|
void IConsoleResize(void);
|
|
|
|
void IConsoleSwitch(void);
|
|
|
|
void IConsoleClose(void);
|
|
|
|
void IConsoleOpen(void);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
2004-08-25 22:11:41 +00:00
|
|
|
// ** console cmd buffer ** //
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleCmdBufferAdd(const char* cmd);
|
2004-08-25 22:11:41 +00:00
|
|
|
void IConsoleCmdBufferNavigate(signed char direction);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
2004-08-25 22:11:41 +00:00
|
|
|
// ** console output ** //
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsolePrint(byte color_code, const char* string);
|
|
|
|
void CDECL IConsolePrintF(byte color_code, const char* s, ...);
|
|
|
|
void IConsoleDebug(const char* string);
|
|
|
|
void IConsoleError(const char* string);
|
|
|
|
void IConsoleWarning(const char* string);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
|
|
|
// *** Commands *** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr);
|
|
|
|
_iconsole_cmd* IConsoleCmdGet(const char* name);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
|
|
|
// *** Variables *** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleVarRegister(const char* name, void* addr, _iconsole_var_types type);
|
|
|
|
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type);
|
|
|
|
void IConsoleVarInsert(_iconsole_var* var, const char* name);
|
|
|
|
_iconsole_var* IConsoleVarGet(const char* name);
|
|
|
|
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type);
|
|
|
|
void IConsoleVarFree(_iconsole_var* var);
|
|
|
|
void IConsoleVarSetString(_iconsole_var* var, const char* string);
|
|
|
|
void IConsoleVarSetValue(_iconsole_var* var, int value);
|
|
|
|
void IConsoleVarDump(const _iconsole_var* var, const char* dump_desc);
|
2004-08-24 22:41:42 +00:00
|
|
|
|
|
|
|
// *** Parser *** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleCmdExec(const char* cmdstr);
|
2004-09-11 19:18:30 +00:00
|
|
|
|
2004-09-12 20:15:18 +00:00
|
|
|
// ** console std lib ** //
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleStdLibRegister(void);
|
2004-09-12 20:15:18 +00:00
|
|
|
|
|
|
|
// ** hook code ** //
|
2004-09-19 15:24:45 +00:00
|
|
|
void IConsoleVarHook(const char* name, _iconsole_hook_types type, iconsole_var_hook proc);
|
|
|
|
void IConsoleCmdHook(const char* name, _iconsole_hook_types type, iconsole_cmd_hook proc);
|
|
|
|
bool IConsoleVarHookHandle(_iconsole_var* hook_var, _iconsole_hook_types type);
|
|
|
|
bool IConsoleCmdHookHandle(_iconsole_cmd* hook_cmd, _iconsole_hook_types type);
|
2004-09-12 20:15:18 +00:00
|
|
|
|
2004-09-11 19:18:30 +00:00
|
|
|
#endif /* CONSOLE_H */
|