From d2e9d7532f58f07c0ede3fad2dbf39a92130670c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 23 Dec 2012 17:10:54 +0000 Subject: Split HUD components into seperate widgets, added health bar,added temporary target health bar. --- src/client/hudplayerstatus.cc | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/client/hudplayerstatus.cc (limited to 'src/client/hudplayerstatus.cc') diff --git a/src/client/hudplayerstatus.cc b/src/client/hudplayerstatus.cc new file mode 100644 index 0000000..e1f921a --- /dev/null +++ b/src/client/hudplayerstatus.cc @@ -0,0 +1,53 @@ +/* + client/hudplayerstatus.cc + This file is part of the Osirion project and is distributed under + the terms and conditions of the GNU General Public License version 2 +*/ + +#include "client/hudplayerstatus.h" +#include "core/core.h" +#include "core/application.h" +#include "ui/ui.h" +#include "ui/paint.h" + +namespace client +{ + +HUDPlayerStatus::HUDPlayerStatus(ui::Widget *parent) : ui::Widget(parent) +{ + set_border(true); + set_background(true); + set_font(ui::root()->font_tiny()); +} + +void HUDPlayerStatus::draw_background() +{ + ui::Paint::draw_material(global_location(), size(), "ui/window"); +} + +void HUDPlayerStatus::draw() +{ + const float padding = font()->width() * 0.25f; + + math::Vector2f pos(global_location()); + pos[0] += padding; + pos[1] += padding; + + math::Vector2f s(width() - 2.0f * padding, height() - 2.0f * padding); + + std::ostringstream playerinfostr; + playerinfostr << "^B" << core::localplayer()->name() << '\n'; + playerinfostr << "^B" << core::localcontrol()->name() << '\n'; + playerinfostr << "^NCredits: " << core::localplayer()->credits(); + + ui::Paint::set_color(palette()->foreground()); + ui::Paint::draw_label(pos, s, font(), playerinfostr.str(), ui::AlignLeft | ui::AlignTop); +} + +bool HUDPlayerStatus::on_keypress(const int key, const unsigned int modifier) +{ + return false; +} + +} // namespace client + -- cgit v1.2.3