Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-15 20:33:15 +0000
committerStijn Buys <ingar@osirion.org>2008-10-15 20:33:15 +0000
commit1e0df536c2fae85c317ce9c3cc17603d5f98c911 (patch)
tree3ab262d51451cda3e926e9581b294f08d39031d9 /src/client/console.h
parent97fca172fd51270cebd5b722f861a6c753bd4d2a (diff)
moved client console into a Widget
Diffstat (limited to 'src/client/console.h')
-rw-r--r--src/client/console.h77
1 files changed, 38 insertions, 39 deletions
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<std::string> 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<std::string> history;
- std::deque<std::string>::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;
+};
}