From d82c8f449c604d0f957e3dd190f7beae3596e6f9 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 11 May 2008 10:53:20 +0000 Subject: brute force line wrapping --- src/client/chat.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/client/chat.cc') diff --git a/src/client/chat.cc b/src/client/chat.cc index fc0ce1b..4d2f759 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -8,6 +8,7 @@ #include "client/chat.h" #include "client/console.h" #include "client/keyboard.h" +#include "client/video.h" #include "render/render.h" namespace client { @@ -73,6 +74,11 @@ void draw() if (console::visible() || !visible()) return; + size_t width = (size_t) (video::width / CHARWIDTH) - 7; + size_t draw_pos = 0; + while (input_pos - draw_pos > width) + draw_pos += 2; + // draw the console input gl::color(1.0f, 1.0f, 1.0f, 1.0f); draw_text(CHARWIDTH , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), "say"); @@ -80,12 +86,12 @@ void draw() draw_text(CHARWIDTH*4 , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), ":"); gl::color(1.0f, 1.0f, 1.0f, 1.0f); - draw_text(CHARWIDTH*6, 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), (*history_pos)); + draw_text(CHARWIDTH*6, 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), (*history_pos).substr(draw_pos, width)); // draw cursor if ((core::application()->time() - ::floorf(core::application()->time())) < 0.5f) { std::string cursor("_"); - draw_text(CHARWIDTH*(input_pos+6), 4 + CHARHEIGHT * (MAXNOTIFYLINES+1) , cursor); + draw_text(CHARWIDTH*(input_pos - draw_pos+6), 4 + CHARHEIGHT * (MAXNOTIFYLINES+1) , cursor); } } -- cgit v1.2.3