From 1a28393dabf4f4696bf433ddde52e7a25253c955 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 16 Oct 2008 16:34:15 +0000 Subject: various user interface related updates --- src/client/console.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/client/console.cc') diff --git a/src/client/console.cc b/src/client/console.cc index 0ab0767..80b6224 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -48,18 +48,17 @@ Console::Console(ui::Widget *parent) : ui::Window(parent) set_background(true); set_label("console"); - //clear_notify(); - load_history(); - console_scroll = 0; history.clear(); history.push_back(""); history_pos = history.rbegin(); - console_input = new ui::Input(this); + console_input = new ui::InputBox(this); console_input->set_focus(); console_input->set_border(false); console_input->set_background(false); + + load_history(); } Console::~Console() @@ -125,15 +124,12 @@ bool Console::on_keypress(const int key, const unsigned int modifier) case SDLK_RETURN: if (console_input->text().size()) { // store input in history - (*history_pos).assign(console_input->text()); while (history.size() >= DEFAULT_MAX_HISTO_LINES) { history.pop_front(); } - - core::cmd() << (*history_pos) << std::endl; - con_print << "^B>" << (*history_pos) << std::endl; - (*history.rbegin()) = (*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)); @@ -209,10 +205,10 @@ void Console::draw() if (console_scroll > log().size()) console_scroll = log().size(); - size_t height = (size_t) (this->height() / font()->height()) -1; - size_t width = (size_t) ((this->width()-8) / font()->width()); - size_t bottom = log().size() - console_scroll; - size_t current_line = 0; + int height = (size_t) (this->height() / font()->height()) -1; + int width = (size_t) ((this->width()-8) / font()->width()); + int bottom = (int) log().size() - console_scroll; + int current_line = 0; Text lines; for (Text::iterator it = log().begin(); it != log().end() && current_line < bottom; it++) { @@ -243,7 +239,7 @@ void Console::draw() // new word, wrap if necessary else if ((*c == '\n' ) || ( *c == ' ')) { - if (line_length + word_length > width) { + if (line_length + word_length > (size_t) width) { if (line.size()) { lines.push_back(line); line.clear(); @@ -277,7 +273,7 @@ void Console::draw() word += *c; word_length++; - if (word_length == width) { + if (word_length == (size_t) width) { if (line.size()) { lines.push_back(line); line.clear(); -- cgit v1.2.3