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-05-14 21:07:10 +0000
committerStijn Buys <ingar@osirion.org>2008-05-14 21:07:10 +0000
commita185c11f2397c0296a4b62cc266b4fa00a63c1e2 (patch)
tree186da4cdee2d9cd46fb2415567da1c441c7431ef /src/client/chat.cc
parent599adb817e19d9be3502e501dc904c7255cd616c (diff)
console, camera & interpolation
Diffstat (limited to 'src/client/chat.cc')
-rw-r--r--src/client/chat.cc51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index 1953390..9171387 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -4,6 +4,7 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include "auxiliary/functions.h"
#include "core/core.h"
#include "client/chat.h"
#include "client/console.h"
@@ -71,24 +72,54 @@ void draw()
{
using namespace render;
- if (console::visible() || !visible())
+ if (console()->visible() || !visible())
return;
- size_t width = (size_t) (video::width / Text::fontwidth()) - 7;
- size_t draw_pos = 0;
- while (input_pos - draw_pos > width)
- draw_pos += 2;
+ size_t width = (size_t) (video::width / Text::fontwidth()) - 8;
+ float y = video::height*8/10;
+ Text::draw(4, y, "^BSay^F:^B ");
- // draw the chat input
- float y = video::height * 8.0 / 10.0;
+ std::string firstpart((*history_pos).substr(0, input_pos));
+ size_t draw_width = 0;
+ const char *c = firstpart.c_str();
- Text::draw(4 , y, "^Bsay^F:^B");
- Text::draw(4+Text::fontwidth()*5 , y, (*history_pos).substr(draw_pos, width));
+ while (*c) {
+ if (aux::is_color_code(c)) {
+ c++;
+ } else {
+ draw_width++;
+ }
+ c++;
+ }
+
+ c = firstpart.c_str();
+ while (*c && draw_width > width - 2) {
+ if (aux::is_color_code(c)) {
+ c++;
+ Text::setcolor(*c);
+ } else {
+ draw_width--;
+ }
+ c++;
+ }
+
+ if (*c) {
+ Text::draw(4+5*Text::fontwidth(), y, c);
+ }
+
+ if (input_pos < (*history_pos).size()) {
+ // FIXME limit to width
+ if (input_pos > 1 && aux::is_color_code((*history_pos).c_str() + input_pos -1)) {
+ Text::setcolor((*history_pos)[input_pos]);
+ }
+ c = (*history_pos).c_str() + input_pos;
+ Text::draw(4+Text::fontwidth()*(draw_width+5), y, c);
+ }
// draw cursor
if ((core::application()->time() - ::floorf(core::application()->time())) < 0.5f) {
std::string cursor("^B_");
- Text::draw(4+Text::fontwidth()*(input_pos - draw_pos+5), y, cursor);
+ Text::draw(4+Text::fontwidth()*(draw_width+5), y , cursor);
}
}