diff options
Diffstat (limited to 'src/client/targeticonbutton.cc')
-rw-r--r-- | src/client/targeticonbutton.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/client/targeticonbutton.cc b/src/client/targeticonbutton.cc new file mode 100644 index 0000000..cd3716f --- /dev/null +++ b/src/client/targeticonbutton.cc @@ -0,0 +1,40 @@ +/* + 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(); +} + +} |