Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-05-10 15:33:16 +0000
committerStijn Buys <ingar@osirion.org>2009-05-10 15:33:16 +0000
commitb3083a4fe57cc99c6972180a40091001cb209ad7 (patch)
tree52552b1fc62ff361867a7171404e5c5bd9e52917 /src/client
parent3dde787b2546958072e8a98350335b2bab6d1c17 (diff)
added disabled ui palette color, added dock and launch buttons
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am6
-rw-r--r--src/client/targeticonbutton.cc40
-rw-r--r--src/client/targeticonbutton.h33
-rw-r--r--src/client/worldview.cc27
-rw-r--r--src/client/worldview.h4
5 files changed, 104 insertions, 6 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index f8d3c10..68c4a78 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -9,12 +9,14 @@ endif
libclient_la_SOURCES = action.cc buymenu.cc chat.cc client.cc clientext.cc \
entitymenu.cc hud.cc infowidget.cc input.cc joystick.cc key.cc keyboard.cc map.cc \
- notifications.cc playerview.cc soundext.cc targets.cc trademenu.cc video.cc worldview.cc
+ notifications.cc playerview.cc soundext.cc targeticonbutton.cc targets.cc trademenu.cc \
+ video.cc worldview.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_HEADERS = action.h chat.h client.h clientext.h hud.h entitymenu.h \
input.h joystick.h key.h keyboard.h map.h notifications.h soundext.h \
- targets.h video.h infowidget.h playerview.h worldview.h trademenu.h buymenu.h
+ targets.h video.h infowidget.h playerview.h worldview.h trademenu.h buymenu.h \
+ targeticonbutton.h
libclient_la_LIBADD = $(top_builddir)/src/core/libcore.la $(top_builddir)/src/audio/libaudio.la \
$(top_builddir)/src/render/librender.la $(top_builddir)/src/ui/libui.la
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();
+}
+
+}
diff --git a/src/client/targeticonbutton.h b/src/client/targeticonbutton.h
new file mode 100644
index 0000000..a08c5c9
--- /dev/null
+++ b/src/client/targeticonbutton.h
@@ -0,0 +1,33 @@
+/*
+ client/targeticonbutton.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_TARGETICONBUTTON_H__
+#define __INCLUDED_CLIENT_TARGETICONBUTTON_H__
+
+#include "ui/iconbutton.h"
+
+namespace client {
+
+class TargetIconButton : public ui::IconButton {
+
+public:
+ /// special icon button that sends target '@' commands.
+ TargetIconButton(Widget *parent, const char *icon, const char *command, unsigned int flags = 0);
+
+ /// called when the widget receives a key press
+ virtual bool on_keypress(const int key, const unsigned int modifier);
+
+protected:
+ /// update enabled/disabled state and draw the IconButton
+ virtual void draw();
+
+private:
+ unsigned int entity_flags;
+};
+
+}
+
+#endif // __INCLUDED_CLIENT_TARGETICONBUTTON_H__
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
index dc8370d..cb46a17 100644
--- a/src/client/worldview.cc
+++ b/src/client/worldview.cc
@@ -5,6 +5,7 @@
*/
#include "core/application.h"
+#include "client/targeticonbutton.h"
#include "client/worldview.h"
#include "client/video.h"
#include "ui/ui.h"
@@ -28,6 +29,10 @@ WorldView::WorldView(ui::Widget *parent) : ui::Widget(parent)
// icon buttons
view_menubutton = new ui::IconButton(this, "icons/button_menu", "ui_menu");
+
+ view_launchbutton = new ui::IconButton(this, "icons/button_launch", "launch");
+ view_dockbutton = new TargetIconButton(this, "icons/button_dock", "dock", core::Entity::Dockable);
+
view_chatbutton = new ui::IconButton(this, "icons/button_chat", "ui_chat");
view_mapbutton = new ui::IconButton(this, "icons/button_map", "ui_map");
}
@@ -63,13 +68,16 @@ void WorldView::resize()
// icons
const float icon_margin = 4.0f;
const float icon_size = 48.0f;
- const float icon_count = 4;
+ const float icon_count = 6;
const float l = (width() -((icon_count +1) * icon_margin) - (icon_count * icon_size)) * 0.5f;
view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size);
// spacer
- view_chatbutton->set_geometry( l + 2.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_mapbutton->set_geometry( l + 3.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_dockbutton->set_geometry( l + 2.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_launchbutton->set_geometry( l + 2.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ // spacer
+ view_chatbutton->set_geometry( l + 4.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_mapbutton->set_geometry( l + 5.0f * (icon_margin + icon_size), icon_margin, icon_size, icon_size);
}
void WorldView::clear()
@@ -91,13 +99,24 @@ void WorldView::draw()
view_statsinfo->set_visible(draw_stats->value() ? true : false);
view_keyinfo->set_visible(draw_keypress->value() ? true : false);
- if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol()) {
+ if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size()) ) {
view_playerview->hide();
view_menubutton->hide();
+ view_dockbutton->hide();
+ view_launchbutton->hide();
view_chatbutton->hide();
view_mapbutton->hide();
} else {
view_playerview->show();
+
+ if (core::localcontrol()->state() == core::Entity::Docked) {
+ view_launchbutton->show();
+ view_dockbutton->hide();
+ } else {
+ view_launchbutton->hide();
+ view_dockbutton->show();
+ }
+
view_menubutton->show();
view_chatbutton->show();
view_mapbutton->show();
diff --git a/src/client/worldview.h b/src/client/worldview.h
index 1889186..e42ac86 100644
--- a/src/client/worldview.h
+++ b/src/client/worldview.h
@@ -39,6 +39,10 @@ private:
PlayerView *view_playerview;
ui::IconButton *view_menubutton;
+
+ ui::IconButton *view_dockbutton;
+ ui::IconButton *view_launchbutton;
+
ui::IconButton *view_chatbutton;
ui::IconButton *view_mapbutton;
};