From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/client/chat.cc | 127 +++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 63 deletions(-) (limited to 'src/client/chat.cc') diff --git a/src/client/chat.cc b/src/client/chat.cc index 137e6b1..5eb1922 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -1,7 +1,7 @@ /* client/chat.cc - This file is part of the Osirion project and is distributed under - the terms and conditions of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms and conditions of the GNU General Public License version 2 */ #include "auxiliary/functions.h" @@ -11,7 +11,8 @@ #include "sys/sys.h" #include "ui/ui.h" -namespace client { +namespace client +{ const size_t DEFAULT_CHAT_LOG_SIZE = 2048; const size_t DEFAULT_CHAT_HISTO_SIZE = 512; @@ -69,7 +70,7 @@ void Chat::show() history_pos = history.rbegin(); (*history_pos).clear(); - chat_input->set_text((*history_pos)); + chat_input->set_text((*history_pos)); chat_scrollpane->set_scroll(0); } @@ -89,67 +90,67 @@ bool Chat::on_keypress(const int key, const unsigned int modifier) History::reverse_iterator upit; - switch( key ) { - case SDLK_ESCAPE: - if (visible()) { - hide(); + switch (key) { + case SDLK_ESCAPE: + if (visible()) { + hide(); + return true; + } else { + return false; + } + case SDLK_RETURN: + if (chat_input->text().size()) { + // store input into history + while (history.size() >= DEFAULT_CHAT_HISTO_SIZE) { + history.pop_front(); + } + + if (chat_input->text().c_str()[0] == '/' || chat_input->text().c_str()[0] == '\\') { + core::cmd() << &chat_input->text().c_str()[1] << std::endl; + } else { + core::cmd() << "say " << chat_input->text() << std::endl; + } + (*history.rbegin()) = chat_input->text(); + + history.push_back(""); + history_pos = history.rbegin(); + chat_input->set_text((*history_pos)); + + if (chat_small) + hide(); + } else { + hide(); + } return true; - } else { - return false; - } - case SDLK_RETURN: - if (chat_input->text().size()) { - // store input into history - while (history.size() >= DEFAULT_CHAT_HISTO_SIZE) { - history.pop_front(); + break; + + case SDLK_UP: + upit = history_pos; + ++upit; + if (upit != history.rend()) { + history_pos = upit; + chat_input->set_text((*history_pos)); } + return true; + break; - if (chat_input->text().c_str()[0] == '/' || chat_input->text().c_str()[0] == '\\') { - core::cmd() << &chat_input->text().c_str()[1] << std::endl; - } else { - core::cmd() << "say " << chat_input->text() << std::endl; + case SDLK_DOWN: + if (history_pos != history.rbegin()) { + --history_pos; + chat_input->set_text((*history_pos)); } - (*history.rbegin()) = chat_input->text(); + return true; + break; - history.push_back(""); - history_pos = history.rbegin(); - chat_input->set_text((*history_pos)); + case SDLK_PAGEUP: + chat_scrollpane->inc_scroll(scroll_offset); + return true; + break; - if (chat_small) - hide(); - } else { - hide(); - } - return true; - break; - - case SDLK_UP: - upit = history_pos; - ++upit; - if (upit != history.rend()) { - history_pos = upit; - chat_input->set_text((*history_pos)); - } - return true; - break; - - case SDLK_DOWN: - if (history_pos != history.rbegin()) { - --history_pos; - chat_input->set_text((*history_pos)); - } - return true; - break; - - case SDLK_PAGEUP: - chat_scrollpane->inc_scroll(scroll_offset); - return true; - break; - - case SDLK_PAGEDOWN: - chat_scrollpane->dec_scroll(scroll_offset); - return true; - break; + case SDLK_PAGEDOWN: + chat_scrollpane->dec_scroll(scroll_offset); + return true; + break; } return false; @@ -169,7 +170,7 @@ void Chat::event_draw() hide(); return; } - + if (chat_small) { chat_scrollpane->hide(); } else { @@ -183,12 +184,12 @@ void Chat::resize() const float margin = 8.0f; math::Vector2f s(size()); - s[0] -= margin*2; - s[1] -= margin*2; + s[0] -= margin * 2; + s[1] -= margin * 2; chat_scrollpane->set_location(margin, margin); chat_scrollpane->set_size(s.width(), s.height() - font()->height() *1.5f); - + chat_input->set_location(margin, height() - font()->height() - margin); chat_input->set_size(s.width(), font()->height()); } -- cgit v1.2.3