Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-19 13:45:07 +0000
committerStijn Buys <ingar@osirion.org>2008-10-19 13:45:07 +0000
commit56cdfd3822d2800abdd2f912ab7f76a5764793a7 (patch)
tree2656c7ef694117e0554ae4a47bb09629c78ed8af /src/client/console.cc
parente6f1fad441a7737549f463ebac1c9de062b5173d (diff)
scrollpane widget, updated chatbox
Diffstat (limited to 'src/client/console.cc')
-rw-r--r--src/client/console.cc64
1 files changed, 38 insertions, 26 deletions
diff --git a/src/client/console.cc b/src/client/console.cc
index 3b94b4d..f4f66c1 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -16,8 +16,8 @@
#include "client/keyboard.h"
#include "core/core.h"
#include "filesystem/filesystem.h"
-#include "render/render.h"
-#include "render/textures.h"
+#include "render/gl.h"
+#include "ui/paint.h"
namespace client {
@@ -48,15 +48,19 @@ Console::Console(ui::Widget *parent) : ui::Window(parent)
set_background(true);
set_label("console");
- console_scroll = 0;
history.clear();
history.push_back("");
history_pos = history.rbegin();
+ console_scrollpane = new ui::ScrollPane(this, con_buffer.log());
+ console_scrollpane->set_border(false);
+ console_scrollpane->set_scroll(0);
+
console_input = new ui::InputBox(this);
console_input->set_focus();
console_input->set_border(false);
console_input->set_background(false);
+ console_input->set_prompt("^N>");
load_history();
}
@@ -73,7 +77,8 @@ void Console::show()
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(SDL_ENABLE);
- console_scroll = 0;
+ console_scrollpane->set_scroll(0);
+
history_pos = history.rbegin();
(*history_pos).clear();
console_input->set_text((*history_pos));
@@ -103,7 +108,7 @@ bool Console::on_keypress(const int key, const unsigned int modifier)
// number of lines to scroll
const size_t scroll_offset = 3;
- Text::reverse_iterator upit;
+ ui::Text::reverse_iterator upit;
switch( key ) {
@@ -154,17 +159,12 @@ bool Console::on_keypress(const int key, const unsigned int modifier)
return true;
break;
case SDLK_PAGEUP:
- console_scroll += scroll_offset;
- if (console_scroll > log().size())
- console_scroll = log().size();
+ console_scrollpane->inc_scroll(scroll_offset);
return true;
break;
case SDLK_PAGEDOWN:
- if (console_scroll > scroll_offset)
- console_scroll -= scroll_offset;
- else
- console_scroll = 0;
+ console_scrollpane->dec_scroll(scroll_offset);
return true;
break;
}
@@ -172,7 +172,7 @@ bool Console::on_keypress(const int key, const unsigned int modifier)
return false;
}
-void Console::event_draw()
+void Console::draw()
{
if (core::application()->connected()) {
set_size(parent()->size().width(), parent()->size().height() * DEFAULT_CONSOLE_HEIGHT);
@@ -180,17 +180,29 @@ void Console::event_draw()
set_size(parent()->size());
}
- ui::Window::event_draw();
-}
+ math::Vector2f s(size());
+ s.x -= 8;
+ s.y -= 8;
-void Console::draw()
-{
- console_input->set_size(this->width(), font()->height());
- console_input->set_location(0, this->height()-font()->height());
+ console_scrollpane->set_location(4, 4);
+ console_scrollpane->set_size(s.x, s.y - font()->height());
+
+ console_input->set_location(4, height() - font()->height() -4);
+ console_input->set_size(s.x, font()->height());
- draw_background();
- draw_border();
+ std::string version(core::name());
+ version += ' ';
+ version.append(core::version());
+ render::gl::color(0.0f, 1.0f, 0.0f, 0.5f);
+
+ s.assign(version.size() * font()->width(), font()->height());
+ math::Vector2f l(global_location());
+ l.x += width() - s.width() -4;
+ l.y += height() - s.height() -4;
+ ui::paint::text(l, s, font(), version);
+
+/*
render::Text::setfont(font()->name().c_str(), font()->width(), font()->height());
render::gl::enable(GL_TEXTURE_2D);
@@ -210,8 +222,8 @@ void Console::draw()
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++) {
+ ui::Text lines;
+ for (ui::Text::iterator it = log().begin(); it != log().end() && current_line < bottom; it++) {
if (current_line >= bottom - height) {
std::string linedata(*it);
linedata += '\n';
@@ -300,13 +312,13 @@ void Console::draw()
float y = this->height()-2*font()->height()-4;
render::Text::setcolor('N');
- for (Text::reverse_iterator rit = lines.rbegin(); (y >= 4) && (rit != lines.rend()); ++rit) {
+ for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 4) && (rit != lines.rend()); ++rit) {
render::Text::draw(4, y, (*rit));
y -= font()->height();
}
render::gl::disable(GL_TEXTURE_2D);
-
+*/
}
void Console::save_history()
@@ -322,7 +334,7 @@ void Console::save_history()
con_warn << "Could not write " << filename << std::endl;
return;
}
- Text::iterator it;
+ ui::Text::iterator it;
size_t l = 1;
for (it = history.begin(); it != history.end(); it++) {
if (l < history.size())