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/ui/console.cc | 131 +++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 65 deletions(-) (limited to 'src/ui/console.cc') diff --git a/src/ui/console.cc b/src/ui/console.cc index 4fcba7d..c486c65 100644 --- a/src/ui/console.cc +++ b/src/ui/console.cc @@ -1,7 +1,7 @@ /* client/console.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 @@ -18,7 +18,8 @@ #include "ui/console.h" #include "ui/paint.h" -namespace ui { +namespace ui +{ const float DEFAULT_CONSOLE_HEIGHT = 0.7f; const size_t DEFAULT_MAX_HISTO_LINES = 512; @@ -29,7 +30,7 @@ ConsoleBuffer Console::con_buffer; /* -- ConsoleBuffer ------------------------------------------------ */ ConsoleBuffer::ConsoleBuffer() : sys::ConsoleInterface() { - //con_print << "^BInitializing console..." << std::endl; + //con_print << "^BInitializing console..." << std::endl; } @@ -109,64 +110,64 @@ bool Console::on_keypress(const int key, const unsigned int modifier) ui::Text::reverse_iterator upit; - switch( key ) { - - case SDLK_ESCAPE: - if (visible()) { - hide(); + switch (key) { + + case SDLK_ESCAPE: + if (visible()) { + hide(); + return true; + } else { + return false; + } + break; + /* + case SDLK_TAB: + core::CommandBuffer::complete( (*history_pos), input_pos); + return true; + break; + */ + case SDLK_RETURN: + if (console_input->text().size()) { + // store input in history + while (history.size() >= DEFAULT_MAX_HISTO_LINES) { + history.pop_front(); + } + core::cmd() << console_input->text() << std::endl; + con_print << "^B>" << console_input->text() << std::endl; + (*history.rbegin()).assign(console_input->text()); + history.push_back(""); + history_pos = history.rbegin(); + console_input->set_text((*history_pos)); + } return true; - } else { - return false; - } - break; -/* - case SDLK_TAB: - core::CommandBuffer::complete( (*history_pos), input_pos); - return true; - break; -*/ - case SDLK_RETURN: - if (console_input->text().size()) { - // store input in history - while (history.size() >= DEFAULT_MAX_HISTO_LINES) { - history.pop_front(); + break; + + case SDLK_UP: + upit = history_pos; + ++upit; + if (upit != history.rend()) { + history_pos = upit; + console_input->set_text((*history_pos)); } - core::cmd() << console_input->text() << std::endl; - con_print << "^B>" << console_input->text() << std::endl; - (*history.rbegin()).assign(console_input->text()); - history.push_back(""); - history_pos = history.rbegin(); - console_input->set_text((*history_pos)); - } - return true; - break; - - case SDLK_UP: - upit = history_pos; - ++upit; - if (upit != history.rend()) { - history_pos = upit; - console_input->set_text((*history_pos)); - } - return true; - break; - case SDLK_DOWN: - if (history_pos != history.rbegin()) { - --history_pos; - console_input->set_text((*history_pos)); - } - return true; - break; - case 512 + SDL_BUTTON_WHEELUP: - case SDLK_PAGEUP: - console_scrollpane->inc_scroll(scroll_offset); - return true; - break; - case 512 + SDL_BUTTON_WHEELDOWN: - case SDLK_PAGEDOWN: - console_scrollpane->dec_scroll(scroll_offset); - return true; - break; + return true; + break; + case SDLK_DOWN: + if (history_pos != history.rbegin()) { + --history_pos; + console_input->set_text((*history_pos)); + } + return true; + break; + case 512 + SDL_BUTTON_WHEELUP: + case SDLK_PAGEUP: + console_scrollpane->inc_scroll(scroll_offset); + return true; + break; + case 512 + SDL_BUTTON_WHEELDOWN: + case SDLK_PAGEDOWN: + console_scrollpane->dec_scroll(scroll_offset); + return true; + break; } return false; @@ -186,8 +187,8 @@ void Console::draw() console_scrollpane->set_location(4, 4); console_scrollpane->set_size(s.width(), s.height() - font()->height()); - - console_input->set_location(4, height() - font()->height() -4); + + console_input->set_location(4, height() - font()->height() - 4); console_input->set_size(s.width(), font()->height()); math::Color fancy(palette()->fancy()); @@ -196,8 +197,8 @@ void Console::draw() std::string version(core::name() + ' ' + core::version()); s.assign(version.size() * font()->width(), font()->height()); math::Vector2f l(global_location()); - l[0] += width() - s.width() -4; - l[1] += height() - s.height() -4; + l[0] += width() - s.width() - 4; + l[1] += height() - s.height() - 4; paint::text(l, s, font(), version); } @@ -238,7 +239,7 @@ void Console::load_history() history.clear(); char line[MAXCMDSIZE]; - while (ifs.getline(line, MAXCMDSIZE-1)) { + while (ifs.getline(line, MAXCMDSIZE - 1)) { history.push_back(line); } -- cgit v1.2.3