From b7d62e90a7a0e4e404623af0c646495a3dd3fd2b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 31 May 2011 13:17:14 +0000 Subject: Removed a forced recalculateLocalAabb for compound shapes, semi-colon in chat messages doesn't truncate the chat text any more, changed chat prompt to "Command:" if the first character is a slash, small misc cleanups --- src/client/chat.cc | 15 +++++++++++++-- src/client/chat.h | 5 +++++ src/client/client.h | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/client') diff --git a/src/client/chat.cc b/src/client/chat.cc index bdce6d8..cf995cb 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -34,7 +34,7 @@ Chat::Chat(ui::Widget *parent) : ui::Window(parent) chat_input = new ui::InputBox(this); chat_input->set_border(false); - chat_input->set_prompt("^BSay^F:^B "); + set_prompt(); chat_input->set_focus(); set_background(true); @@ -117,7 +117,8 @@ bool Chat::on_keypress(const int key, const unsigned int modifier) core::cmd() << &chat_input->text().c_str()[1] << std::endl; } else { // FIXME semi-column ; truncates the command - core::cmd() << "say " << chat_input->text() << std::endl; + //core::cmd() << "say " << chat_input->text() << std::endl; + client()->say(chat_input->text()); } (*history.rbegin()) = chat_input->text(); @@ -165,12 +166,22 @@ bool Chat::on_keypress(const int key, const unsigned int modifier) return false; } +void Chat::set_prompt() +{ + if (chat_input->text().size() && chat_input->text()[0] == '/') { + chat_input->set_prompt("^BCommand^F:^B "); + } else { + chat_input->set_prompt("^BSay^F:^B "); + } +} + void Chat::draw() { if (!chat_small && (chat_playerlist_timestamp != core::game()->playerlist_timestamp())) { update_player_list(); } + set_prompt(); ui::Window::draw(); } diff --git a/src/client/chat.h b/src/client/chat.h index 0972400..fa50e87 100644 --- a/src/client/chat.h +++ b/src/client/chat.h @@ -43,6 +43,11 @@ protected: virtual void resize(); virtual bool on_keypress(const int key, const unsigned int modifier); + + /** + * @brief set the chatbox prompt to 'say:' or 'command:' depending on the current input text. + */ + void set_prompt(); private: diff --git a/src/client/client.h b/src/client/client.h index 85562a1..ddc6dd5 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -73,6 +73,11 @@ public: return client_testmodelview; } + /// local client seds a chat message + inline void say(std::string const &text) { + func_say(text); + } + protected: /// run a client frame virtual void frame(); -- cgit v1.2.3