Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 27dfd0e276d16d278c09af062c0d71231ad2b2c5 (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
/*
   client/targeticonbutton.cc
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2
*/

#include "audio/audio.h"
#include "client/targeticonbutton.h"
#include "client/targets.h"
#include "core/commandbuffer.h"

namespace client
{

TargetIconButton::TargetIconButton(Widget *parent, const char *icon, const char *tooltip, const char *command, unsigned int flags) : IconButton(parent, icon, tooltip, command)
{
	set_label("targeticonbutton");
	entity_flags = flags;
}

TargetIconButton::~TargetIconButton()
{
	entity_flags = 0;
}

bool TargetIconButton::on_mousepress(const unsigned int button)
{
	if (button == SDL_BUTTON_LEFT)
	{
		if (enabled() && command().size() && targets::current())
		{
			core::cmd() << "@" << command() << " " << targets::current_id() << std::endl;
			audio::play("ui/clicked");
		}
		return true;
	}

	return false;
}

void TargetIconButton::draw()
{
	set_enabled(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags));
	ui::IconButton::draw();
}

}