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 --- README | 4 ++-- TODO | 15 ++++++++++----- osirion.kdevelop.pcs | Bin 655486 -> 655559 bytes osirion.kdevses | 21 +++++++++------------ src/client/chat.cc | 10 ++++++++-- src/client/console.cc | 31 ++++++++++++++++++++++++++----- src/client/view.cc | 36 ++++++++++++++++++++++-------------- 7 files changed, 77 insertions(+), 40 deletions(-) diff --git a/README b/README index b08720f..4ab0dc0 100644 --- a/README +++ b/README @@ -98,8 +98,8 @@ Statistics fps frames per second tris number of triangles drawn quads number of quads drawn - tx network upstream traffic, in kb - rx network downstream traffic, in kb + tx network upstream traffic, in kilobyte + rx network downstream traffic, in kilobyte The fps counter will not show values above 9999. diff --git a/TODO b/TODO index 61f2736..15cdc5f 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,16 @@ TODO +(ok) done +(--) postponed + milestone 1: console text color and wrapping + keyboard binds + entity axis interpolation - camera axis interpolation + camera axis interpolation (--) camera tracking mode camera frustum clip - keyboard binds milestone 2: server-client event system, hit-once lightweight entities @@ -18,8 +22,8 @@ filesystem: write handlers for zip model: - split map loader from model support map classes (e.g. func_rotate), requires class VertexData + split map loader from model, load vertices into VertexData engine flare key core: @@ -29,7 +33,8 @@ core: parse command line options (ok) execute command line options (ok) globe entity (ok) - execute config files + + execute config files (ok, autoexec.cfg still missing) game module loading/unloading network: @@ -44,6 +49,7 @@ network: fix lag protocol version in handshake detect and disconnect clients behaving badly + client: input handler switching (ok) console chars (ok) @@ -72,4 +78,3 @@ win32 port: screenshots are broken (ok) directory creation - diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs index aff14ba..6bf305e 100644 Binary files a/osirion.kdevelop.pcs and b/osirion.kdevelop.pcs differ diff --git a/osirion.kdevses b/osirion.kdevses index 1c4a484..97be539 100644 --- a/osirion.kdevses +++ b/osirion.kdevses @@ -1,22 +1,19 @@ - - - + + + - - + + - - + + - - + + - - - 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); } } 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::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 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::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); } } diff --git a/src/client/view.cc b/src/client/view.cc index 3524403..3576b90 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -155,39 +155,47 @@ void draw_status() } stats << "tx "<< std::setw(5) << (core::Stats::network_bytes_sent >> 10) << "\n"; stats << "rx "<< std::setw(5) << (core::Stats::network_bytes_received >> 10) << "\n"; - draw_text(video::width-CHARWIDTH*12, 4, stats); + draw_text(video::width-CHARWIDTH*12, video::height - CHARHEIGHT*10, stats); } - /* - // print the version number in the upper right corner - gl::color(0.0f, 1.0f, 0.0f, 1.0f); - std::string version("ver. "); - version.append(core::version()); - draw_text(video::width-(version.size()+1)*CHARWIDTH, 4, version); - */ - // draw notifications gl::color(1.0f, 1.0f, 1.0f, 1.0f); + size_t width = (size_t) (video::width / CHARWIDTH) -2; size_t n = console::notify_pos % MAXNOTIFYLINES; int h = 4 + CHARHEIGHT; for (size_t l = 0; l < MAXNOTIFYLINES; l++) { if (console::notify_text[n].size() > 2 && console::notify_time[n] + 4 > core::application()->time()) { - if (console::notify_text[n][0] == '?') + std::string line(console::notify_text[n]); + + if (line[0] == '?') gl::color(0.7f,0.7f,0.7f, 1.0f); - else if (console::notify_text[n][0] == '*') + else if (line[0] == '*') gl::color(1.0f,1.0f,0.0f, 1.0f); - else if (console::notify_text[n][0] == '!') + else if (line[0] == '!') gl::color(1.0f,0.0f,0.0f, 1.0f); else gl::color(1.0f,1.0f,1.0f, 1.0f); - draw_text(CHARWIDTH, h, console::notify_text[n].substr(2)); - h += CHARHEIGHT; + line.erase(0,2); + + std::deque lines; + + while (line.size() > width) { + draw_text(CHARWIDTH, h, line.substr(0, width)); + line.erase(0, width); + h += CHARHEIGHT; + } + if (line.size()) { + draw_text(CHARWIDTH, h, line); + h += CHARHEIGHT; + } } n = (n+1) % MAXNOTIFYLINES; } // draw a basic HUD if (core::localcontrol()) { + gl::color(1.0f,1.0f,1.0f, 1.0f); + status.str(""); status << "thrust " << std::setfill(' ') << std::setw(5) << std::fixed << std::setprecision(2) << core::localcontrol()->thrust() << " "; -- cgit v1.2.3