/* 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_keypress(const int key, const unsigned int modifier) { if (key == 512 + SDL_BUTTON_LEFT) { if (enabled() && command().size() && targets::current()) { core::cmd() << "@" << command() << " " << targets::current_id() << std::endl; audio::play("ui/button"); } return true; } return false; } void TargetIconButton::draw() { enable(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags)); ui::IconButton::draw(); } }