From 82f0ac05f5da2d89c4a544ca22ff47e116e6dd97 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 15:11:49 +0000 Subject: Introduced global variables for reputation hostile/friendly thresholds, do not allow players to dock at hostile bases, indicate target reputation in the hud target info widget. --- src/client/hud.cc | 80 +++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 47 deletions(-) (limited to 'src/client/hud.cc') diff --git a/src/client/hud.cc b/src/client/hud.cc index 1b2ddd8..1fabe10 100644 --- a/src/client/hud.cc +++ b/src/client/hud.cc @@ -6,6 +6,7 @@ #include "core/core.h" +#include "core/range.h" #include "client/client.h" #include "client/hud.h" #include "client/hudenginestatus.h" @@ -144,9 +145,9 @@ void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target) } // reputation color - if (reputation > 50.0f) { + if (reputation >= core::range::reputation_friendly) { bitmap_color.assign(0.0f, 1.0f, 0.0f); // green - } else if (reputation < -50.0f) { + } else if (reputation <= core::range::reputation_hostile) { bitmap_color.assign(1.0f, 0.0f, 0.0f); // red } else { bitmap_color.assign(1.0f, 1.0f, 1.0f); // white @@ -156,9 +157,9 @@ void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target) bitmap_material.assign("bitmaps/hud/offscreen_dockable"); // reputation color - if (reputation > 50.0f) { + if (reputation >= core::range::reputation_friendly) { bitmap_color.assign(0.0f, 1.0f, 0.0f); // green - } else if (reputation < -50.0f) { + } else if (reputation <= core::range::reputation_hostile) { bitmap_color.assign(1.0f, 0.0f, 0.0f); // red } else { bitmap_color.assign(1.0f, 1.0f, 1.0f); // white @@ -257,31 +258,24 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target) } else { bitmap_material.assign("bitmaps/hud/target_default"); } - - // reputation color - if (reputation > 50.0f) { - bitmap_color.assign(0.0f, 1.0f, 0.0f); // green - } else if (reputation < -50.0f) { - bitmap_color.assign(1.0f, 0.0f, 0.0f); // red - } else { - bitmap_color.assign(1.0f, 1.0f, 1.0f); // white - } + bitmap_color.assign(1.0f, 1.0f, 1.0f); // white } else if (entity->has_flag(core::Entity::Dockable)) { bitmap_material.assign("bitmaps/hud/target_dockable"); - // reputation color - if (reputation > 50.0f) { - bitmap_color.assign(0.0f, 1.0f, 0.0f); // green - } else if (reputation < -50.0f) { - bitmap_color.assign(1.0f, 0.0f, 0.0f); // red - } else { - bitmap_color.assign(1.0f, 1.0f, 1.0f); // white - } - + bitmap_color.assign(1.0f, 1.0f, 1.0f); // white } else { bitmap_material.assign("bitmaps/hud/target_default"); - bitmap_color.assign(palette()->text()); + bitmap_color.assign(palette()->text()); // default text color + } + + // reputation color + if (reputation >= core::range::reputation_friendly) { + // friendly + bitmap_color.assign(0.0f, 1.0f, 0.0f); // green + } else if (reputation <= core::range::reputation_hostile) { + // hostile + bitmap_color.assign(1.0f, 0.0f, 0.0f); // red } if (entity == core::localplayer()->mission_target()) { @@ -309,24 +303,23 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target) if (do_draw_label) { // draw name label + std::string label_color; std::string label_text; - if (controlable) { - if (controlable->owner()) { - label_text.append("^B"); - label_text.append(controlable->owner()->name()); - } else { - label_text.append("^N"); - label_text.append(entity->name()); - } + + if (controlable && controlable->owner()) { + label_color.assign("^B"); + } else if (entity->has_flag(core::Entity::Dockable)) { + label_color.assign("^B"); } else { - if (entity->has_flag(core::Entity::Dockable)) { - label_text.append("^B"); - label_text.append(entity->name()); - - } else { - label_text.append("^N"); - label_text.append(entity->name()); - } + label_color.assign("^N"); + } + + label_text.assign(label_color); + + if (controlable && controlable->owner()) { + label_text.append(controlable->owner()->name()); + } else { + label_text.append(entity->name()); } const ui::Font *label_font; @@ -343,14 +336,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target) // draw distance label if (is_active_target) { std::ostringstream strdistance; - - if (controlable && controlable->owner()) { - strdistance << "^B"; - } else if (entity->has_flag(core::Entity::Dockable)) { - strdistance << "^B"; - } else { - strdistance << "^N"; - } + strdistance << label_color; float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius(); if (d > 0) { -- cgit v1.2.3