From 840f9b8678f607aecc15d47bc77248c4ac8b8574 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Feb 2008 00:54:30 +0000 Subject: tweaked console client status with timer and fps core connect/disconnect --- src/client/console.cc | 134 ++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 81 deletions(-) (limited to 'src/client/console.cc') diff --git a/src/client/console.cc b/src/client/console.cc index a0cc7c5..dfc1d08 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -14,7 +14,7 @@ namespace client { Console::Console() { - visible = false; + console_visible = true; } std::ostream & Console::messagestream() @@ -40,87 +40,65 @@ std::ostream & Console::debugstream() void Console::draw() { using namespace render; - - // flush console messages in the buffer - flush(); - - float height; - bool showloader = false; - - if (core::game()) { - if (!core::game()->ready()) { - height = 0.6f; - showloader = true; - } else if (visible) - height = 0.6f; - else - height = 0.0f; - } else { - showloader = true; - height = 1.0f; - } + + console.flush(); + if(!console_visible) + return; - if (showloader) { - // draw the loader background - gl::color(0.5f, 0.5f, 0.5f, 1.0f); + float con_height = 0.70f; - gl::begin(gl::Quads); - gl::vertex(0,0, 0); - gl::vertex(video.width,0,0); - gl::vertex(video.width,video.height,0); - gl::vertex(0,video.height,0); - gl::end(); - } + glBindTexture(GL_TEXTURE_2D, render::textures[1]); // bitmaps/conchars.tga + + // draw version below the bottom of the console + gl::enable(GL_TEXTURE_2D); + gl::color(0.0f, 1.0f, 0.0f, 0.5f); + std:: string version = std::string("The Osirion Project "); + version.append(VERSION); + draw_text(video.width-CHARWIDTH*(version.size()+1), video.height*con_height-CHARHEIGHT-4, version); + gl::disable(GL_TEXTURE_2D); + + // draw the transparent console background + gl::color(1.0f, 1.0f, 1.0f, 0.01f); + + gl::begin(gl::Quads); + gl::vertex(0.0f, 0.0f, 0.0f); + gl::vertex(video.width, 0.0f,0.0f); + gl::vertex(video.width,video.height*con_height,0.0f); + gl::vertex(0,video.height*con_height,0.0f); + gl::end(); - if (height > 0) { - // draw version below the bottom of the console - gl::color(0.0f, 1.0f, 0.0f, 1.0f); - std:: string version = std::string("The Osirion Project "); - version.append(PACKAGE_VERSION); - draw_text(video.width-CHARSIZE*(version.size()+1), video.height*height-CHARSIZE-4, version); - - // draw the transparent console background - gl::color(1, 1, 1, .5); + // draw the console text + gl::enable(GL_TEXTURE_2D); + std::deque::reverse_iterator rit = console.text.rbegin(); + float y = video.height*con_height-2*CHARHEIGHT-8; + while (y > 0 && rit < console.text.rend()) { + std::string line(*rit); - gl::enable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, render::textures[0]); // bitmaps/loader.tga + if (line[0] == '?') + gl::color(0.7f,0.7f,0.7f, 1.0f); + else if (line[0] == '*') + gl::color(1.0f,1.0f,0.0f, 1.0f); + 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); + line.erase(0,2); - gl::begin(gl::Quads); - glTexCoord2f(0.0f, 0.0f); - gl::vertex(0,0, 0); - - glTexCoord2f(1.0f, 0.0f); - gl::vertex(video.width,0,0); - - glTexCoord2f(1.0f, 1.0f); - gl::vertex(video.width,video.height*height,0); - - glTexCoord2f(0.0f, 1.0f); - gl::vertex(0,video.height*height,0); - - gl::end(); + draw_text(CHARWIDTH, y, line); + y -= CHARHEIGHT; + ++rit; + } - glBindTexture(GL_TEXTURE_2D, render::textures[1]); // bitmaps/conchars.tga - gl::enable(GL_BLEND); - - // draw the console text - gl::color(1,1,1,1); - std::deque::reverse_iterator rit = console.text.rbegin(); - float y = video.height*height-2*CHARSIZE-8; - while (y > 0 && rit < console.text.rend()) { - draw_text(0, y, *rit); - y -= CHARSIZE; - ++rit; - } + // draw the console input + gl::color(0.0f, 1.0f, 0.0f, 1.0f); + draw_text(CHARWIDTH, video.height*con_height - CHARHEIGHT - 4, input); - // draw the console input - gl::color(0.0f, 1.0f, 0.0f, 1.0f); - draw_text(0, video.height*height - CHARSIZE - 4, input); - - gl::disable(GL_TEXTURE_2D); - gl::disable(GL_BLEND); + // draw cursor + if ((core::time() - floorf(core::time())) < 0.5f) { + std::string cursor("_"); + draw_text(CHARWIDTH*(input.size()+1), video.height*con_height - CHARHEIGHT - 4 , cursor); } - + gl::disable(GL_TEXTURE_2D); } void Console::flush() @@ -140,18 +118,12 @@ void Console::flush() void Console::toggle() { - visible = !visible; + console_visible = !console_visible; } void Console::handle_keyreleased(SDL_keysym* keysym) { switch( keysym->sym ) { - case '`': - case '~': - toggle(); - return; - break; - case SDLK_RETURN: if (input.size()) { core::cmd << input << std::endl; -- cgit v1.2.3