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.cc91
1 files changed, 76 insertions, 15 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index f7fc0d7..7db0398 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -8,6 +8,9 @@
#include "core/core.h"
#include "client/client.h"
#include "client/hud.h"
+#include "client/hudenginestatus.h"
+#include "client/hudplayerstatus.h"
+#include "client/hudtargetstatus.h"
#include "client/input.h"
#include "client/targets.h"
#include "render/render.h"
@@ -23,14 +26,17 @@ HUD::HUD(ui::Widget *parent) : Widget(parent)
set_border(false);
set_background(false);
- /*hud_toolbar = new ui::Toolbar(this);
-
- hud_toolbar->add_button("", "Menu", "ui_menu");
- hud_toolbar->add_button("", "Chat", "ui_chat");
- hud_toolbar->add_button("", "Map", "ui_map");
- */
hud_center = new ui::Bitmap(this, "bitmaps/pointers/center");
hud_center->set_color(palette()->pointer());
+
+ // player status
+ hud_playerstatus = new HUDPlayerStatus(this);
+
+ // engine status
+ hud_enginestatus = new HUDEngineStatus(this);
+
+ // target status
+ hud_targetstatus = new HUDTargetStatus(this);
}
@@ -38,8 +44,21 @@ void HUD::resize()
{
//hud_toolbar->set_geometry(0.0f, 0.0f, width(), font()->height() *2 );
+ const float padding = ui::root()->font_large()->height();
+
hud_center->set_size(ui::pointer_size, ui::pointer_size);
hud_center->set_location((size() - hud_center->size()) * 0.5f);
+
+ const float w = (width() - 4 * padding) / 3.0f;
+ hud_playerstatus->set_size(w,ui::UI::elementsize.height() * 3.0f);
+ hud_playerstatus->set_location(padding, height() - hud_playerstatus->height() - padding);
+
+ hud_enginestatus->set_size(w,ui::UI::elementsize.height());
+ hud_enginestatus->set_location(hud_playerstatus->right() + padding, height() - hud_enginestatus->height() - padding);
+
+ hud_targetstatus->set_size(w,ui::UI::elementsize.height() * 3.0f);
+ hud_targetstatus->set_location(hud_enginestatus->right() + padding, height() - hud_targetstatus->height() - padding);
+
}
void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
@@ -154,10 +173,12 @@ 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 faction color
+
} else {
- gl::color(1, 1, 1, 1); // FIXME neutral color
+ gl::color(palette()->foreground());
}
// outer square0
@@ -176,13 +197,41 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
gl::vertex(cx, cy - (r*0.25f));
gl::end();
}
-
- gl::enable(GL_TEXTURE_2D);
+
if (is_active_target) {
+ gl::color(palette()->foreground());
+
// owner name
if (entity->type() == core::Entity::Controlable) {
const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
+
+ if (ec->health() > 0) {
+ // on-screen health indicator
+ const float f = 2.0f * r * ec->health() / 100.0f;
+
+ // health bar
+ gl::color(0, 1, 0, 1);
+ gl::begin(gl::Quads);
+ gl::vertex(cx - r, cy + r - 4 - render::Text::fontheight() * 0.5f);
+ gl::vertex(cx - r + f, cy + r - 4 - render::Text::fontheight() * 0.5f);
+ gl::vertex(cx - r + f, cy + r - 4);
+ gl::vertex(cx - r, cy + r - 4);
+ gl::end();
+
+ // frame
+ gl::color(palette()->foreground());
+
+ gl::begin(gl::LineLoop);
+ gl::vertex(cx - r, cy + r - 4 - render::Text::fontheight() * 0.5f);
+ gl::vertex(cx + r, cy + r - 4 - render::Text::fontheight() * 0.5f);
+ gl::vertex(cx + r, cy + r - 4);
+ gl::vertex(cx - r, cy + r - 4);
+ gl::end();
+ }
+
+ gl::enable(GL_TEXTURE_2D);
+
if (ec->owner()) {
std::ostringstream strtoplabel;
strtoplabel << "^B" << ec->owner()->name() << "^B\n";
@@ -191,15 +240,20 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
cy - r - 4 - render::Text::fontheight(), strtoplabel.str()
);
}
+
+ } else {
+ gl::enable(GL_TEXTURE_2D);
}
- // entity name
+ gl::color(palette()->foreground());
+
+ // on-screen entity name
render::Text::draw(
cx - aux::text_length(entity->name()) * render::Text::fontwidth() * 0.5f,
cy + r + 4, entity->name()
);
- // distance
+ // on-screen distance
std::ostringstream strdistance;
float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius();
if (d > 0) {
@@ -247,7 +301,7 @@ void HUD::draw()
gl::enable(GL_TEXTURE_2D);
Text::setfont("gui", 12, 18);
Text::setcolor('N'); //set normal color
-
+
core::Zone *zone = core::localcontrol()->zone();
// draw HUD targets
@@ -265,7 +319,9 @@ void HUD::draw()
}
}
+ gl::disable(GL_TEXTURE_2D);
+ /*
// ---------------------------------------------------------
// player info pane
@@ -275,7 +331,9 @@ void HUD::draw()
playerinfostr << "^Ncredits: " << core::localplayer()->credits();
Text::draw(width() - 4 - Text::fontwidth() * 52, height() - Text::fontheight() * 3 - 4, playerinfostr.str());
-
+ */
+
+ /*
// ---------------------------------------------------------
// target info pane
@@ -323,6 +381,10 @@ void HUD::draw()
Text::draw(width() - 4 - Text::fontwidth() * 30, height() - Text::fontheight() * 3 - 4, strtarget.str());
}
+ */
+
+ /*
+
//----------------------------------------------------------
// engine info pane
@@ -397,8 +459,7 @@ void HUD::draw()
Text::setfont("gui", 12, 18);
Text::setcolor('N'); //set normal color
-
- gl::disable(GL_TEXTURE_2D);
+ */
if (has_mouse_focus()) {