From 1e0df536c2fae85c317ce9c3cc17603d5f98c911 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 15 Oct 2008 20:33:15 +0000 Subject: moved client console into a Widget --- src/client/console.h | 77 ++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'src/client/console.h') diff --git a/src/client/console.h b/src/client/console.h index e280e9d..4b2df20 100644 --- a/src/client/console.h +++ b/src/client/console.h @@ -8,35 +8,31 @@ #define __INCLUDED_CLIENT_CONSOLE_H__ #include "sys/consoleinterface.h" +#include "ui/window.h" +#include "ui/input.h" namespace client { -const size_t MAXNOTIFYLINES = 5; -const size_t MAXHISTOLINES = 512; +/* -- class ConsoleBuffer ------------------------------------------ */ -/// client console implementation -class Console : public sys::ConsoleInterface { +/// client console buffer +/** stores incoming console messages + */ +class ConsoleBuffer : public sys::ConsoleInterface { public: - Console(); - virtual ~Console(); - - /// add notification - void notify(std::string const &message); - - /// clear notifications - void clear_notify(); - - /// draw client notifications or console text - void draw(bool draw_ui_notifications); + ConsoleBuffer(); + ~ConsoleBuffer(); +}; - /// toggle the console on or off - void toggle(); +/* -- class Console ------------------------------------------------ */ - /// handle keyboard input - void keypressed(unsigned int key); +/// client system console widget +class Console : public ui::Window { +public: + typedef std::deque Text; - /// true of the console is visible - inline bool visible() { return console_visible; } + Console(Widget *parent); + virtual ~Console(); /// load input history void load_history(); @@ -44,37 +40,40 @@ public: /// save input history void save_history(); - /// clear console - void clear(); + /// show console + virtual void show(); - /// initialize client console - static void init(); + /// hide console + virtual void hide(); - /// shutdown the client console - static void shutdown(); + void toggle(); protected: - void draw_console(); + /// draw event + virtual void event_draw(); - void draw_notify(); + /// draw the client console text + virtual void draw(); + + /// handle keypress events + virtual bool on_keypress(const int key, const unsigned int modifier); private: - // notifications - size_t notify_pos; - std::string notify_text[MAXNOTIFYLINES]; - float notify_time[MAXNOTIFYLINES]; + inline Text & log() { return con_buffer.log(); } // input history - std::deque history; - std::deque::reverse_iterator history_pos; - size_t input_pos; + Text history; + Text::reverse_iterator history_pos; - bool console_visible; + // scroll position size_t console_scroll; -}; + // input widget + ui::Input *console_input; -Console *console(); + // console buffer + static ConsoleBuffer con_buffer; +}; } -- cgit v1.2.3