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 15:16:25 +0000
committerStijn Buys <ingar@osirion.org>2008-05-11 15:16:25 +0000
commitd2e93235b9ccd37bf8c8fb7c4376ab1911c83639 (patch)
tree61bfbf023228ba10abe488d8c8bd27359171c9f7 /src/client/console.cc
parentd82c8f449c604d0f957e3dd190f7beae3596e6f9 (diff)
console font
Diffstat (limited to 'src/client/console.cc')
-rw-r--r--src/client/console.cc53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/client/console.cc b/src/client/console.cc
index 3331792..fae402c 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -7,6 +7,7 @@
#include "filesystem/filesystem.h"
#include "core/core.h"
#include "render/render.h"
+#include "render/textures.h"
#include "client/console.h"
#include "client/video.h"
#include "client/keyboard.h"
@@ -124,13 +125,13 @@ void draw()
return;
float con_height = 0.70f;
-
+
// draw version below the bottom of the console
gl::color(0.0f, 1.0f, 0.0f, 0.5f);
std::string version(core::name());
version += ' ';
version.append(core::version());
- draw_text(video::width-CHARWIDTH*(version.size()+1), video::height*con_height-CHARHEIGHT-4, version);
+ Text::draw(video::width-Text::fontwidth()*(version.size()+1), video::height*con_height-Text::fontheight()-4, version);
gl::disable(GL_TEXTURE_2D);
// draw the transparent console background
@@ -148,15 +149,15 @@ void draw()
console_scroll = text.size();
gl::enable(GL_TEXTURE_2D);
+
+ //gl::color(0.7f,0.7f,0.7f, 1.0f);
+ gl::color(1.0f,1.0f,1.0f, 1.0f);
- 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);
-
+ size_t height = (size_t) (video::height * con_height / Text::fontheight()) -1;
+ size_t width = (size_t) (video::width / Text::fontwidth()) -2;
+ size_t bottom = text.size() - console_scroll;
+ size_t current_line = 0;
+/*
if (line[0] == '?')
gl::color(0.7f,0.7f,0.7f, 1.0f);
else if (line[0] == '*')
@@ -165,41 +166,43 @@ void draw()
gl::color(1.0f,0.0f,0.0f, 1.0f);
else
gl::color(1.0f,1.0f,1.0f, 1.0f);
- line.erase(0,2);
-
- std::deque<std::string> lines;
+*/
+ std::deque<std::string> lines;
+ for (std::deque<std::string>::iterator it = text.begin(); it != text.end() && current_line < bottom; it++) {
+ if (current_line >= bottom - height) {
+ std::string line(*it);
+ line.erase(0,2);
+
while (line.size() > width) {
lines.push_back(line.substr(0, width));
line.erase(0, width);
}
if (line.size())
lines.push_back(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;
}
- ++rit;
+ current_line++;
}
+ float y = video::height*con_height-2*Text::fontheight()-4;
+ for (std::deque<std::string>::reverse_iterator rit = lines.rbegin(); (y >= 4) && (rit != lines.rend()); ++rit) {
+ Text::draw(4, y, (*rit));
+ y -= Text::fontheight();
+ }
+
+
// 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).substr(draw_pos, width));
+ Text::draw(Text::fontwidth(), video::height*con_height - Text::fontheight() - 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-draw_pos+1), video::height*con_height - CHARHEIGHT - 4 , cursor);
+ Text::draw(Text::fontwidth()*(input_pos-draw_pos+1), video::height*con_height - Text::fontheight() - 4 , cursor);
}
}