Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/hud.cc')
-rw-r--r--src/client/hud.cc218
1 files changed, 105 insertions, 113 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index beeefd3..014f4df 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -229,150 +229,142 @@ void HUD::draw()
Text::setcolor('N'); //set normal color
- if(core::localplayer()->view()) {
- Text::setcolor('N'); //set normal color
- Text::draw(render::State::width()-4-Text::fontwidth()*32, render::State::height()-Text::fontheight()*3-4, core::localcontrol()->zone()->name());
+ core::Zone *zone = core::localcontrol()->zone();
- Text::setcolor('B'); //set bold color
- Text::draw(render::State::width() - 4-Text::fontwidth()*32, render::State::height() - Text::fontheight()*2 -4, core::localplayer()->view()->name());
+ // draw targets
+ for (core::Zone::Content::iterator it=zone->content().begin(); it != zone->content().end(); it++) {
+ core::Entity *entity = (*it);
- } else if (core::localcontrol() && core::localcontrol()->zone()) {
- core::Zone *zone = core::localcontrol()->zone();
-
- // draw targets
- for (core::Zone::Content::iterator it=zone->content().begin(); it != zone->content().end(); it++) {
- core::Entity *entity = (*it);
-
- if (targets::is_legal_target(entity)) {
- if (entity == core::localplayer()->mission_target()) {
- draw_target(entity, true);
- } else if (entity == targets::current()) {
- draw_target(entity, true);
- } else if (entity->type() == core::Entity::Controlable) {
- draw_target(entity, false);
- }
+ if (targets::is_legal_target(entity)) {
+ if (entity == core::localplayer()->mission_target()) {
+ draw_target(entity, true);
+ } else if (entity == targets::current()) {
+ draw_target(entity, true);
+ } else if (entity->type() == core::Entity::Controlable) {
+ draw_target(entity, false);
}
}
+ }
- unsigned int state = core::localcontrol()->eventstate();
- if (state) {
- std::stringstream statestr;
- statestr.clear();
- if (state == core::Entity::ImpulseInitiate) {
- statestr << "^FInitializing kinetic impulse drive " << core::localcontrol()->timer();
- } else if (state == core::Entity::Impulse) {
- //statestr << "^FKinetic impulse";
- } else if (state == core::Entity::JumpInitiate) {
- statestr << "^FInitializing hyperspace jump drive "<< core::localcontrol()->timer();
- } else if (state == core::Entity::Jump) {
- statestr << "^FJumping...";
- }
-
- Text::draw(4, render::State::height() - Text::fontheight()*3-4, statestr);
+ unsigned int state = core::localcontrol()->eventstate();
+ if (state) {
+ std::stringstream statestr;
+ statestr.clear();
+ if (state == core::Entity::ImpulseInitiate) {
+ statestr << "^FInitializing kinetic impulse drive " << core::localcontrol()->timer();
+ } else if (state == core::Entity::Impulse) {
+ //statestr << "^FKinetic impulse";
+ } else if (state == core::Entity::JumpInitiate) {
+ statestr << "^FInitializing hyperspace jump drive "<< core::localcontrol()->timer();
+ } else if (state == core::Entity::Jump) {
+ statestr << "^FJumping...";
}
- core::Entity *target = targets::current();
- std::stringstream strdistance;
+ Text::draw(4, render::State::height() - Text::fontheight()*3-4, statestr);
+ }
- if (target) {
- std::stringstream strtarget;
- strtarget << "^B" << target->name() << "\n^B";
+ core::Entity *target = targets::current();
+ std::stringstream strdistance;
- float d = math::distance(core::localcontrol()->location(), target->location())
- - target->radius() - core::localcontrol()->radius();
+ if (target) {
+ std::stringstream strtarget;
+ strtarget << "^B" << target->name() << "\n^B";
- if (d > 0 ) {
- strtarget << "^Ndist:^B ";
- if (d > 100.0f) {
- strtarget << roundf(d * 0.1f) << "km";
- } else {
- strtarget << roundf(d * 100.0f) << "m";
- }
+ float d = math::distance(core::localcontrol()->location(), target->location())
+ - target->radius() - core::localcontrol()->radius();
- if (core::localcontrol()->speed() > 0.1f) {
- strtarget << "^N eta:^B ";
- float eta = floorf(d / core::localcontrol()->speed() );
- if (eta > 60.0f) {
- float etamin = floorf(eta / 60.0f);
- strtarget << etamin << "min ";
- eta -= etamin * 60;
- }
- strtarget << eta << "sec";
- }
+ if (d > 0 ) {
+ strtarget << "^Ndist:^B ";
+ if (d > 100.0f) {
+ strtarget << roundf(d * 0.1f) << "km";
} else {
- strtarget << " --";
+ strtarget << roundf(d * 100.0f) << "m";
}
- strtarget << '\n';
- Text::draw(width() - 4-Text::fontwidth()*30, height() - Text::fontheight()*2 -4, strtarget);
+
+ if (core::localcontrol()->speed() > 0.1f) {
+ strtarget << "^N eta:^B ";
+ float eta = floorf(d / core::localcontrol()->speed() );
+ if (eta > 60.0f) {
+ float etamin = floorf(eta / 60.0f);
+ strtarget << etamin << "min ";
+ eta -= etamin * 60;
+ }
+ strtarget << eta << "sec";
+ }
+ } else {
+ strtarget << " --";
}
+ strtarget << '\n';
+ Text::draw(width() - 4-Text::fontwidth()*30, height() - Text::fontheight()*2 -4, strtarget);
+ }
- // draw player info
- std::stringstream playerinfostr;
- playerinfostr <<"^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
- Text::draw(width() - 4-Text::fontwidth()*52, height() - Text::fontheight()*2 -4, playerinfostr);
+ // draw player info
+ std::stringstream playerinfostr;
+ playerinfostr <<"^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
+ Text::draw(width() - 4-Text::fontwidth()*52, height() - Text::fontheight()*2 -4, playerinfostr);
- Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
- gl::color(1, 1, 1, 1);
- gl::begin(gl::Quads);
+ Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
+ gl::color(1, 1, 1, 1);
+ gl::begin(gl::Quads);
- glTexCoord2f(0, 0);
- gl::vertex(4, height() - 4 - 32, 0);
+ glTexCoord2f(0, 0);
+ gl::vertex(4, height() - 4 - 32, 0);
- glTexCoord2f(1, 0);
- gl::vertex(4 + 316, height() - 4 - 32, 0);
+ glTexCoord2f(1, 0);
+ gl::vertex(4 + 316, height() - 4 - 32, 0);
- glTexCoord2f(1, 1);
- gl::vertex(4 + 316, height() - 4 , 0);
+ glTexCoord2f(1, 1);
+ gl::vertex(4 + 316, height() - 4 , 0);
- glTexCoord2f(0, 1);
- gl::vertex(4, height() - 4 , 0);
+ glTexCoord2f(0, 1);
+ gl::vertex(4, height() - 4 , 0);
- gl::end();
+ gl::end();
- float u = core::localcontrol()->thrust();
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
- u = 1.0;
- }
+ float u = core::localcontrol()->thrust();
+ if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ u = 1.0;
+ }
- if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
+ if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) {
- if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
- gl::color(0, .8, 0);
- } else {
- float d = math::absf(input::local_thrust - u);
- if (d > 0.1) {
- d = 0.1f;
- }
- gl::color(1, 1, .5f + d * 5.0f);
+ if (core::localcontrol()->eventstate() == core::Entity::Impulse) {
+ gl::color(0, .8, 0);
+ } else {
+ float d = math::absf(input::local_thrust - u);
+ if (d > 0.1) {
+ d = 0.1f;
}
- Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap
- gl::begin(gl::Quads);
- glTexCoord2f(0, 0);
- gl::vertex(4, height() - 4 - 32, 0);
-
- glTexCoord2f(u, 0);
- gl::vertex(4.0f + u * 316.0f, height() - 4 - 32, 0);
-
- glTexCoord2f(u, 1);
- gl::vertex(4.0f + u * 316.0f, height() - 4 , 0);
-
- glTexCoord2f(0, 1);
- gl::vertex(4, height() - 4 , 0);
-
- gl::end();
+ gl::color(1, 1, .5f + d * 5.0f);
}
+ Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap
+ gl::begin(gl::Quads);
+ glTexCoord2f(0, 0);
+ gl::vertex(4, height() - 4 - 32, 0);
+
+ glTexCoord2f(u, 0);
+ gl::vertex(4.0f + u * 316.0f, height() - 4 - 32, 0);
- Text::setfont("gui", 14, 24);
- Text::setcolor('B'); //set normal color
+ glTexCoord2f(u, 1);
+ gl::vertex(4.0f + u * 316.0f, height() - 4 , 0);
- std::stringstream speedstr;
- speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
- Text::draw( 316+4+10, height() - 6 -16 - render::Text::fontwidth() /2, speedstr);
+ glTexCoord2f(0, 1);
+ gl::vertex(4, height() - 4 , 0);
- Text::setfont("gui", 12, 18);
- Text::setcolor('N'); //set normal color
+ gl::end();
}
+ Text::setfont("gui", 14, 24);
+ Text::setcolor('B'); //set normal color
+
+ std::stringstream speedstr;
+ speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
+ Text::draw( 316+4+10, height() - 6 -16 - render::Text::fontwidth() /2, speedstr);
+
+ Text::setfont("gui", 12, 18);
+ Text::setcolor('N'); //set normal color
+
+
gl::disable(GL_TEXTURE_2D);
}