00001 #ifndef RC_CONSOLE_H
00002 #define RC_CONSOLE_H
00003
00004 #define RC_CONSOLE_MAX_LINE_WIDTH 512
00005 #define RC_CONSOLE_MAX_MESSAGES 1024
00006 #define RC_CONSOLE_MAX_STACK 32
00007
00008 #define RC_FPS_BUF 32
00009
00010 typedef struct {
00011
00012 char *msg;
00013
00014 union {
00015 u32 alive;
00016 f32 timestamp;
00017 };
00018
00019 } ConsoleMessage_t;
00020
00021 typedef union {
00022 f32 time;
00023 u32 alive;
00024 } Key_t;
00025
00026 static const char default_desc[] = "No command description added";
00027
00028 class Console {
00029
00030 public:
00031
00032 static void init();
00033
00034 static void destroy();
00035
00036 static void toggle();
00037
00038 static void log(
00039 const char *str,
00040 ...
00041 );
00042
00043 static void keyPress();
00044
00045 static void render();
00046
00047 static void toggleDrawFPS(
00048 bool draw
00049 );
00050
00051 static bool drawsFPS() { return draw_fps; }
00052
00053 static bool isShowing();
00054
00055 private:
00056
00057 static void initBackdrop();
00058
00059 private:
00060
00061 static Geometry *backdrop;
00062
00063
00064 static char cmdline[RC_CONSOLE_MAX_LINE_WIDTH];
00065 static u32 cmdline_pos;
00066
00067 static char cmdstack[RC_CONSOLE_MAX_STACK][RC_CONSOLE_MAX_LINE_WIDTH];
00068 static u32 cmdstack_ptr;
00069 static u32 cmdstack_next;
00070
00071 static char cmdbuf[RC_CONSOLE_MAX_LINE_WIDTH];
00072
00073
00074 static u32 curr_msg;
00075 static ConsoleMessage_t msg_list[RC_CONSOLE_MAX_MESSAGES];
00076 static f32 msg_linger_time;
00077 static u32 msg_offset;
00078 static i32 n_msgs;
00079
00080 static u32 off_console_draw_n_msgs;
00081 static u32 on_console_draw_n_msgs;
00082
00083 static Text *text;
00084
00085 static bool show;
00086
00087 static f32 nextBackspace;
00088
00089 static Key_t key[RC_KEY_LAST];
00090
00091
00092 static bool draw_fps;
00093 static f32 fps_buf[RC_FPS_BUF];
00094 static u32 curr_fps;
00095
00096
00097 public:
00098 static bool initiated;
00099
00100 };
00101
00102 #endif
00103