diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-18 19:22:39 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-18 19:22:39 +0000 |
commit | 2f4c20a0b6fa0397d623d883ee48ba59563f1e2f (patch) | |
tree | 2186c4ada36a9bc832a89c662029d3b12bf1840e /src/client | |
parent | cc0a133a616aeff57887b27497e4a978b5697c04 (diff) |
standard hail
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.cc | 6 | ||||
-rw-r--r-- | src/client/client.h | 5 | ||||
-rw-r--r-- | src/client/console.cc | 28 | ||||
-rw-r--r-- | src/client/console.h | 12 |
4 files changed, 23 insertions, 28 deletions
diff --git a/src/client/client.cc b/src/client/client.cc index ed31c65..80b983e 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -166,5 +166,11 @@ void Client::notify_sound(const char * name) audio::play(name); } +void Client::notify_message(std::string const & message) +{ + con_print << message << std::endl; + console()->notify(message); +} + } // namespace client diff --git a/src/client/client.h b/src/client/client.h index 57488ec..8bd6d45 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -28,8 +28,11 @@ public: /// quit the client virtual void quit(int status); - /// sound notifications from the core to the application + /// sound notifications from the core virtual void notify_sound(const char * name); + + /// text notifications from the core + virtual void notify_message(std::string const & message); }; diff --git a/src/client/console.cc b/src/client/console.cc index ac977f2..db2aa83 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -102,7 +102,7 @@ void Console::toggle() } else { SDL_WM_GrabInput(SDL_GRAB_ON); SDL_ShowCursor(SDL_DISABLE); - clear_notify(); + //clear_notify(); } setkeyboardmode(visible()); @@ -527,28 +527,12 @@ void Console::clear_notify() notify_pos = 0; } -void Console::flush() +void Console::notify(std::string const & message) { - char line[MAXCMDSIZE]; - - while(consoleinterface_buffer.getline(line, MAXCMDSIZE-1)) { - - while (consoleinterface_text.size() >= sys::MAXCONLINES) { - consoleinterface_text.pop_front(); - } - consoleinterface_text.push_back(std::string(line)); - - // save notification - notify_text[notify_pos] = line; - notify_time[notify_pos] = core::application()->time(); - notify_pos = (notify_pos+1) % MAXNOTIFYLINES; - - // print to stdout - print_ansi(line); - std::cout << std::endl; - } - - consoleinterface_buffer.clear(); + // save notification + notify_text[notify_pos] = message; + notify_time[notify_pos] = core::application()->time(); + notify_pos = (notify_pos+1) % MAXNOTIFYLINES; } } // namespace client diff --git a/src/client/console.h b/src/client/console.h index 5bdbde6..533a8be 100644 --- a/src/client/console.h +++ b/src/client/console.h @@ -20,11 +20,8 @@ public: Console(); virtual ~Console(); - virtual void flush(); - - void draw_console(); - - void draw_notify(); + /// add notification + void notify(std::string const &message); /// clear notifications void clear_notify(); @@ -56,6 +53,11 @@ public: /// shutdown the client console static void shutdown(); +protected: + void draw_console(); + + void draw_notify(); + private: // notifications size_t notify_pos; |