Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: ebd5ec31bbab43614a1c6d924b6b5be5fc0e31ba (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
/*
   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 *command, unsigned int flags) : IconButton(parent, icon, command)
{
	set_label("targeticonbutton");
	entity_flags = flags;
}

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();
}

}