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>2013-11-05 21:03:33 +0000
committerStijn Buys <ingar@osirion.org>2013-11-05 21:03:33 +0000
commit34f7ba0489b5c44c52db64c509a096090bff845f (patch)
treebcf9cee3cd94088c72dac9348ec0d2f02f9c7158 /src/client
parentd77635aebe26fb79936a7d75dd0bb1b60c5855a2 (diff)
Improved HUD target indicators.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/hud.cc97
1 files changed, 67 insertions, 30 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index 7069310..8c33014 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -72,6 +72,8 @@ void HUD::resize()
void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
{
+ const core::EntityControlable *controlable = ( (entity->type() == core::Entity::Controlable) ? static_cast<core::EntityControlable *>(entity) : 0 );
+
math::Vector3f target(entity->location() - render::Camera::eye());
target = render::Camera::axis().transpose() * target;
@@ -92,10 +94,26 @@ void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
screen_edge[1] = (0.5f - screen_edge[1]) * ((float) render::State::height());
const float bitmap_margin = 24.0f;
- float bitmap_radius = 32.0f;
+ float bitmap_radius = 24.0f;
- if (!is_active_target) {
- bitmap_radius = 24.0f;
+ if (is_active_target) {
+ bitmap_radius = 32.0f;
+
+ } else if (controlable) {
+
+ if (render::ext_render(controlable)->distance() > core::range::fxdistance) {
+ if (controlable->owner()) {
+ bitmap_radius = 24.0f;
+ } else {
+ return;
+ }
+ } else {
+ if (controlable->owner()) {
+ bitmap_radius = 32.0f;
+ } else {
+ bitmap_radius = 16.0f;
+ }
+ }
}
math::Vector2f screen_center((float) render::State::width() * 0.5f, (float) render::State::height() * 0.5f);
@@ -165,8 +183,9 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
using math::Vector3f;
// don't draw target if we're very close to it
- if (render::ext_render(entity)->distance() < 0.001f)
+ if (render::ext_render(entity)->distance() < 0.001f) {
return;
+ }
// don't draw target if it is outside the visible cone
Vector3f target(entity->location() - render::Camera::eye());
@@ -174,6 +193,8 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
draw_offscreen_target(entity, is_active_target);
return;
}
+
+ const core::EntityControlable *controlable = ( (entity->type() == core::Entity::Controlable) ? static_cast<core::EntityControlable *>(entity) : 0 );
// calculate target screen position
@@ -191,26 +212,31 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
draw_offscreen_target(entity, is_active_target);
return;
}
-
- // target bitmap properties
- float bitmap_radius = 32.0f;
+
+ // ---------------------------------------------------------
+ // draw target bitmap
+ float bitmap_radius = 32.0f;
if (is_active_target) {
bitmap_radius *= 2.0f;
if (hud_splash_time > 0.0f) {
bitmap_radius *= (core::application()->time() - hud_splash_time) / SPLASH_POPUP_DELAY;
}
+ } else if (controlable && (render::ext_render(controlable)->distance() > core::range::fxdistance)) {
+ bitmap_radius *= 0.5f;
}
math::Vector2f bitmap_location(cx - bitmap_radius, cy - bitmap_radius);
math::Vector2f bitmap_size(2.0f * bitmap_radius, 2.0f * bitmap_radius);
math::Color bitmap_color;
std:: string bitmap_material;
- if (entity->type() == core::Entity::Controlable) {
- if (is_active_target) {
+ if (controlable) {
+ if (controlable->owner()) {
bitmap_material.assign("bitmaps/hud/target_controlable");
} else {
bitmap_material.assign("bitmaps/hud/target_default");
}
+
+ // FIXME reputation color
bitmap_color.assign(palette()->fancy());
} else if (entity->has_flag(core::Entity::Dockable)) {
@@ -225,27 +251,38 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
if (entity == core::localplayer()->mission_target()) {
bitmap_color.assign(palette()->mission());
}
-
ui::Paint::draw_bitmap(bitmap_location, bitmap_size, bitmap_color, bitmap_material);
-
- if (!(is_active_target && (hud_splash_time > 0.0f))) {
-
- // labels
- std::string label_text;
+ // ---------------------------------------------------------
+ // draw target entity text labels
+
+ bool do_draw_label = true;
+ if (is_active_target) {
+ // check if the splash animation is still running
+ if (hud_splash_time > 0.0f) {
+ do_draw_label = false;
+ }
- if (entity->type() == core::Entity::Controlable) {
- const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
- if (ec->owner()) {
+ } else if (controlable) {
+ // do not show labels on far away NPCSs
+ if (!controlable->owner() && (render::ext_render(controlable)->distance() > core::range::fxdistance)) {
+ do_draw_label = false;
+ }
+ }
+
+ if (do_draw_label) {
+
+ // draw name label
+ std::string label_text;
+ if (controlable) {
+ if (controlable->owner()) {
label_text.append("^B");
- label_text.append(ec->owner()->name());
+ label_text.append(controlable->owner()->name());
} else {
label_text.append("^N");
label_text.append(entity->name());
}
-
} else {
-
if (entity->has_flag(core::Entity::Dockable)) {
label_text.append("^B");
label_text.append(entity->name());
@@ -264,14 +301,14 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
}
math::Vector2f label_size(2.0f * bitmap_radius, label_font->height());
- math::Vector2f label_location(cx - bitmap_radius, cy + bitmap_radius);
+ math::Vector2f label_location(cx - bitmap_radius, cy - bitmap_radius -label_size.height());
ui::Paint::draw_label(label_location, label_size,label_font, label_text);
+ // draw distance label
if (is_active_target) {
- // draw distance
std::ostringstream strdistance;
- if (entity->type() == core::Entity::Controlable) {
+ if (controlable) {
strdistance << "^B";
} else if (entity->has_flag(core::Entity::Dockable)) {
strdistance << "^B";
@@ -290,25 +327,25 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
strdistance << "--";
}
- label_location[1] += - label_size.height();
+ label_location.assign(cx - bitmap_radius, cy + bitmap_radius);
ui::Paint::draw_label(label_location, label_size, label_font, strdistance.str());
}
- if (entity->type() == core::Entity::Controlable) {
- const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
-
+
+ if (controlable && (is_active_target || (render::ext_render(controlable)->distance() < core::range::fxdistance))) {
+
// health bar size
const float hb_width = bitmap_radius;
float hb_height = ui::root()->font_tiny()->width();
if (!is_active_target) {
hb_height *= 0.5f;
}
- const float hb_f = hb_width * ec->health() / 100.0f;
+ const float hb_f = hb_width * controlable->health() / 100.0f;
math::Vector2f pos;
pos[0] = cx - bitmap_radius;
pos[0] += bitmap_radius - 0.5f * hb_width;
- pos[1] = cy - bitmap_radius;
+ pos[1] = cy + bitmap_radius - hb_height * 0.5f;
// health bar
gl::color(0, 1, 0, 1);