00001
00002 #ifndef RC_COMMAND_H
00003 #define RC_COMMAND_H
00004
00005 #define RC_COMMAND_MAX_ARGS 32
00006 #define RC_COMMAND_HASH_SIZE 1001
00007
00008
00009
00010 typedef struct {
00011
00012 u32 key;
00013 char *line;
00014
00015 } KeyBinding_t;
00016
00017 typedef struct Command_t Command_t;
00018
00019 struct Command_t {
00020
00021 char *name;
00022 char *desc;
00023 bool (* funcptr)(u32, char **);
00024
00025 Command_t *hash_next;
00026 Command_t *list_next;
00027
00028 };
00029
00030 class Command {
00031
00032 public:
00033
00034 static void init();
00035
00036 static void destroy();
00037
00038 static void add(
00039 const char *command_name,
00040 const char *desc,
00041 bool (* funcptr)(u32, char **)
00042 );
00043
00044 static void remove(
00045 const char *command_name
00046 );
00047
00048 static void run(
00049 char *str
00050 );
00051
00052 static bool Command::bindKey(
00053 char *keyn,
00054 char *line
00055 );
00056
00057 static bool checkArgCount(
00058 u32 expected,
00059 u32 got,
00060 char **args
00061 );
00062
00063 static void consumeKeys();
00064
00065
00066 public:
00067
00068 static Command_t *command_hash[RC_COMMAND_HASH_SIZE];
00069 static Command_t *command_head;
00070
00071 static u32 n_bindings;
00072 static KeyBinding_t binding[RC_KEY_LAST];
00073
00074 static Key_t key[RC_KEY_LAST];
00075
00076 };
00077
00078
00079
00080 #if 0
00081
00082 static const char *CMDHELP_draw_fps = {
00083 "/draw_fps [bool]"
00084 };
00085
00086 bool CMD_draw_fps(
00087 u32 n_args,
00088 char **args
00089 );
00090
00091
00092
00093 static const char *CMDHELP_list = {
00094 "/list"
00095 };
00096
00097 bool CMD_list(
00098 u32 n_args,
00099 char **args
00100 );
00101
00102
00103
00104 static const char *CMDHELP_scene_tree = {
00105 "/scene_tree"
00106 };
00107
00108 bool CMD_scene_tree(
00109 u32 n_args,
00110 char **args
00111 );
00112
00113
00114
00115 static const char *CMDHELP_load_scene = {
00116 "/load_scene <Group> <Filename>"
00117 };
00118
00119 bool CMD_load_scene(
00120 u32 n_args,
00121 char **args
00122 );
00123
00124
00125
00126 #endif
00127
00128 #endif
00129