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-11 10:53:20 +0000
committerStijn Buys <ingar@osirion.org>2008-05-11 10:53:20 +0000
commitd82c8f449c604d0f957e3dd190f7beae3596e6f9 (patch)
treee64ad617cd609437f2177922e3d90693fa38940d /src/client/console.cc
parentfb227d62e699ebaea6e428f570bedc684873f15b (diff)
brute force line wrapping
Diffstat (limited to 'src/client/console.cc')
-rw-r--r--src/client/console.cc31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/client/console.cc b/src/client/console.cc
index 9e2a782..3331792 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -148,13 +148,15 @@ void draw()
console_scroll = text.size();
gl::enable(GL_TEXTURE_2D);
+
std::deque<std::string>::reverse_iterator rit = text.rbegin();
+ size_t width = (size_t) (video::width / CHARWIDTH) -2;
float bottom = video::height*con_height-2*CHARHEIGHT-8;
float y = bottom+console_scroll*CHARHEIGHT;
while (y > 0 && rit < text.rend()) {
if (y <= bottom) {
std::string line(*rit);
-
+
if (line[0] == '?')
gl::color(0.7f,0.7f,0.7f, 1.0f);
else if (line[0] == '*')
@@ -164,21 +166,40 @@ void draw()
else
gl::color(1.0f,1.0f,1.0f, 1.0f);
line.erase(0,2);
+
+ std::deque<std::string> lines;
+
+ while (line.size() > width) {
+ lines.push_back(line.substr(0, width));
+ line.erase(0, width);
+ }
+ if (line.size())
+ lines.push_back(line);
+
- draw_text(CHARWIDTH, y, line);
+ std::deque<std::string>::reverse_iterator lrit;
+ for (lrit = lines.rbegin(); (lrit != lines.rend()) && (y > 0); ++lrit) {
+ draw_text(CHARWIDTH, y, (*lrit));
+ y -= CHARHEIGHT;
+ }
+ } else {
+ y -= CHARHEIGHT;
}
- y -= CHARHEIGHT;
++rit;
}
// draw the console input
+ size_t draw_pos = 0;
+ while (input_pos - draw_pos > width)
+ draw_pos += 2;
+
gl::color(0.0f, 1.0f, 0.0f, 1.0f);
- draw_text(CHARWIDTH, video::height*con_height - CHARHEIGHT - 4, (*history_pos));
+ draw_text(CHARWIDTH, video::height*con_height - CHARHEIGHT - 4, (*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+1), video::height*con_height - CHARHEIGHT - 4 , cursor);
+ draw_text(CHARWIDTH*(input_pos-draw_pos+1), video::height*con_height - CHARHEIGHT - 4 , cursor);
}
}