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>2012-12-16 20:20:16 +0000
committerStijn Buys <ingar@osirion.org>2012-12-16 20:20:16 +0000
commit3351dc03541a473f651e7c1c7e00fbafd73fec69 (patch)
tree918415710b34c6a42570f0ad0fc233ae3bc23086 /src/client
parentb9cb984081106923524eed68cc7f73023377c844 (diff)
Improved target HUD when selecting other players.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/hud.cc113
1 files changed, 59 insertions, 54 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index c3a6a71..f7fc0d7 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -143,7 +143,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
gl::vertex(cx, cy - r + 2);
gl::end();
- if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
+ if (entity->has_flag(core::Entity::Dockable)) {
gl::begin(gl::LineLoop);
gl::vertex(cx + (r*0.25f), cy + 2);
gl::vertex(cx, cy + (r*0.25f) + 2);
@@ -155,7 +155,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
if (entity == core::localplayer()->mission_target()) {
gl::color(palette()->mission());
} else if (entity->type() == core::Entity::Controlable) {
- gl::color(0, 1, 0, 1); // FIXME allegiance color
+ gl::color(0, 1, 0, 1); // FIXME faction color
} else {
gl::color(1, 1, 1, 1); // FIXME neutral color
}
@@ -168,7 +168,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
gl::vertex(cx, cy - r);
gl::end();
- if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
+ if (entity->has_flag(core::Entity::Dockable)) {
gl::begin(gl::LineLoop);
gl::vertex(cx + (r*0.25f), cy);
gl::vertex(cx, cy + (r*0.25f));
@@ -179,8 +179,27 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
gl::enable(GL_TEXTURE_2D);
if (is_active_target) {
+
+ // owner name
+ if (entity->type() == core::Entity::Controlable) {
+ const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
+ if (ec->owner()) {
+ std::ostringstream strtoplabel;
+ strtoplabel << "^B" << ec->owner()->name() << "^B\n";
+ render::Text::draw(
+ cx - aux::text_length(strtoplabel.str()) * render::Text::fontwidth() * 0.5f,
+ cy - r - 4 - render::Text::fontheight(), strtoplabel.str()
+ );
+ }
+ }
- // entity name and distance
+ // entity name
+ render::Text::draw(
+ cx - aux::text_length(entity->name()) * render::Text::fontwidth() * 0.5f,
+ cy + r + 4, entity->name()
+ );
+
+ // distance
std::ostringstream strdistance;
float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius();
if (d > 0) {
@@ -192,29 +211,10 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
} else {
strdistance << "--";
}
-
- // owner name
- if (entity->type() == core::Entity::Controlable) {
- const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
- if (ec->owner()) {
- render::Text::setcolor('B');
- render::Text::draw(cx - aux::text_length(ec->owner()->name()) * render::Text::fontwidth()*0.5f,
- cy - r - 4 - 2*render::Text::fontheight(), ec->owner()->name());
- }
- render::Text::setcolor('B');
-
- } else if (entity == core::localplayer()->mission_target()) {
- gl::color(palette()->mission());
-
- } else {
- render::Text::setcolor('N');
- }
-
- render::Text::draw(cx - aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f,
- cy - r - 4 - render::Text::fontheight(), entity->name());
-
- render::Text::draw(cx - aux::text_length(strdistance.str()) * render::Text::fontwidth() * 0.5f,
- cy + r + 4, strdistance.str());
+ render::Text::draw(
+ cx - aux::text_length(strdistance.str()) * render::Text::fontwidth() * 0.5f,
+ cy + r + 4 + render::Text::fontheight(), strdistance.str()
+ );
}
}
@@ -264,29 +264,36 @@ void HUD::draw()
draw_target(entity, false);
}
}
+
+
+ // ---------------------------------------------------------
+ // player info pane
+
+ std::ostringstream playerinfostr;
+ playerinfostr << "^B" << core::localplayer()->name() << '\n';
+ playerinfostr << "^B" << core::localcontrol()->name() << '\n';
+ playerinfostr << "^Ncredits: " << core::localplayer()->credits();
+
+ Text::draw(width() - 4 - Text::fontwidth() * 52, height() - Text::fontheight() * 3 - 4, playerinfostr.str());
- /*
- unsigned int state = core::localcontrol()->state();
- if (state) {
- std::ostringstream 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.str());
- }
- */
-
+ // ---------------------------------------------------------
+ // target info pane
+
const core::Entity *target = targets::current();
if (target) {
std::ostringstream strtarget;
+
+ if (target->type() == core::Entity::Controlable) {
+ const core::EntityControlable *target_controlable = static_cast<const core::EntityControlable *>(target);
+ if (target_controlable->owner()) {
+ strtarget << "^B" << target_controlable->owner()->name() << "\n";
+ } else {
+ strtarget << "\n";
+ }
+ } else {
+ strtarget << "\n";
+ }
+
strtarget << "^B" << target->name() << "\n^B";
float d = math::distance(core::localcontrol()->location(), target->location())
@@ -312,15 +319,13 @@ void HUD::draw()
}
} else {
strtarget << " --";
- }
- Text::draw(width() - 4 - Text::fontwidth()*30, height() - Text::fontheight()*2 - 4, strtarget.str());
+ }
+ Text::draw(width() - 4 - Text::fontwidth() * 30, height() - Text::fontheight() * 3 - 4, strtarget.str());
}
-
- // draw player info
- std::ostringstream playerinfostr;
- playerinfostr << "^B" << core::localcontrol()->name() << '\n' << "^Ncredits: " << core::localplayer()->credits();
- Text::draw(width() - 4 - Text::fontwidth()*52, height() - Text::fontheight()*2 - 4, playerinfostr.str());
-
+
+ //----------------------------------------------------------
+ // engine info pane
+
// draw thruster indicator
Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
gl::color(1, 1, 1, 1);