diff options
Diffstat (limited to 'src/client/view.cc')
-rw-r--r-- | src/client/view.cc | 81 |
1 files changed, 61 insertions, 20 deletions
diff --git a/src/client/view.cc b/src/client/view.cc index eef3920..e1e0820 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -31,7 +31,7 @@ namespace client core::Cvar *draw_ui = 0; core::Cvar *draw_stats = 0; -core::Cvar *draw_location = 0; +core::Cvar *draw_devinfo = 0; core::Cvar *draw_keypress = 0; core::Cvar *ui_pointercolor = 0; @@ -53,8 +53,8 @@ void init() draw_stats = core::Cvar::get("draw_stats", "0", core::Cvar::Archive); draw_stats->set_info("[bool] draw network and render statistics"); - draw_location = core::Cvar::get("draw_location", "0", core::Cvar::Archive); - draw_location->set_info("[bool] draw world location"); + draw_devinfo = core::Cvar::get("draw_devinfo", "0", core::Cvar::Archive); + draw_devinfo->set_info("[bool] draw developer information"); draw_ui = core::Cvar::get("draw_ui", "1", core::Cvar::Archive); draw_ui->set_info("[bool] draw the user interface"); @@ -161,16 +161,14 @@ void draw_status() Text::draw(video::width-Text::fontwidth()*12-4, 4 + Text::fontheight()*2, stats); } + // draw keypress + if (draw_keypress->value() && input::last_key_pressed()) { + Text::setcolor('F'); //set fancy color + Text::draw(video::width-4-Text::fontwidth()*6, video::height-Text::fontheight()-4, input::last_key_pressed()->name()); + } + // draw a basic HUD if (core::localcontrol()) { - status.str(""); - status << "^Nthrust ^B" << std::setfill(' ') << std::setw(5) << std::fixed - << std::setprecision(2) << core::localcontrol()->thrust() << " "; - - status << "^Nspeed ^B" << std::setfill(' ') << std::setw(5) << std::fixed - << std::setprecision(2) << core::localcontrol()->speed(); - - Text::draw(4, video::height - Text::fontheight()-4, status); unsigned int state = core::localcontrol()->eventstate(); if (state) { @@ -186,16 +184,19 @@ void draw_status() statestr << "^FJumping..."; } - Text::draw(4, video::height - Text::fontheight()*2-4, statestr); + Text::draw(4, video::height - Text::fontheight()*3-4, statestr); } - if (draw_location->value()) { - std::stringstream location; - location << std::fixed << std::setprecision(2) + if (draw_devinfo->value()) { + std::stringstream devinfo; + devinfo << std::fixed << std::setprecision(2) << "^Nx:^B" << core::localcontrol()->location().x << " " << "^Ny:^B" << core::localcontrol()->location().y << " " << "^Nz:^B" << core::localcontrol()->location().z << '\n'; - Text::draw(4, video::height - Text::fontheight()*3 -4, location); + + devinfo << "^Nthurst:^B " << core::localcontrol()->thrust() << " " + << "^Nspeed:^B " << core::localcontrol()->speed() << '\n'; + Text::draw(4, 4 + Text::fontheight(), devinfo); } float y = 1.0f; @@ -216,12 +217,52 @@ void draw_status() y = 3.0f; } + Text::setcolor('N'); //set normal color Text::draw(video::width-4-Text::fontwidth()*32, video::height-Text::fontheight()*y-4, core::localcontrol()->zone()->name()); - } - if (draw_keypress->value() && input::last_key_pressed()) { - Text::setcolor('F'); //set fancy color - Text::draw(video::width-4-Text::fontwidth()*6, video::height-Text::fontheight()-4, input::last_key_pressed()->name()); + Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap + gl::color(1, 1, 1, 1); + gl::begin(render::gl::Quads); + + glTexCoord2f(0, 0); + gl::vertex(4, video::height - 4 - 32, 0); + + glTexCoord2f(1, 0); + gl::vertex(4 + 316, video::height - 4 - 32, 0); + + glTexCoord2f(1, 1); + gl::vertex(4 + 316, video::height - 4 , 0); + + glTexCoord2f(0, 1); + gl::vertex(4, video::height - 4 , 0); + + gl::end(); + + float u = core::localcontrol()->thrust(); + if ( u > 0) { + Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap + gl::begin(render::gl::Quads); + glTexCoord2f(0, 0); + gl::vertex(4, video::height - 4 - 32, 0); + + glTexCoord2f(u, 0); + gl::vertex(4.0f + u * 316.0f, video::height - 4 - 32, 0); + + glTexCoord2f(u, 1); + gl::vertex(4.0f + u * 316.0f, video::height - 4 , 0); + + glTexCoord2f(0, 1); + gl::vertex(4, video::height - 4 , 0); + + gl::end(); + } + Text::setfont("bitmaps/fonts/gui", 14, 24); + std::stringstream speedstr; + speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f); + Text::draw( 316+4+10, video::height - 6 -16 - render::Text::fontwidth() /2, speedstr); + + Text::setfont("bitmaps/fonts/gui", 12, 18); + Text::setcolor('N'); //set normal color } } |