From b3083a4fe57cc99c6972180a40091001cb209ad7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 May 2009 15:33:16 +0000 Subject: added disabled ui palette color, added dock and launch buttons --- src/client/targeticonbutton.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/client/targeticonbutton.cc (limited to 'src/client/targeticonbutton.cc') 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(); +} + +} -- cgit v1.2.3