Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 0dba3c848f199196bfbbab0c44d10d5e5e286feb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
   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';
	
	if (core::localcontrol()->info()) {
		core::game()->request_info(core::localcontrol()->info()->id());
		playerinfostr << "^B" << core::localcontrol()->info()->name() << '\n';
	} else {
		playerinfostr << '\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