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>2012-10-07 21:46:02 +0000
committerStijn Buys <ingar@osirion.org>2012-10-07 21:46:02 +0000
commit60b0e02ab6b8910b3870d16a6eef9d67c6a6f34e (patch)
tree8702424723a66ad2d65298d63160ef25ef83898e /src/client/mapwidget.cc
parente065de3bf7f15b895c7a22e9fdbf8125c94406b3 (diff)
Add galactic map, make it possible to other zones on the map.
Diffstat (limited to 'src/client/mapwidget.cc')
-rw-r--r--src/client/mapwidget.cc65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc
index 5f5d5d6..44ec32a 100644
--- a/src/client/mapwidget.cc
+++ b/src/client/mapwidget.cc
@@ -5,6 +5,7 @@
*/
#include "client/mapwidget.h"
+#include "client/targets.h"
#include "core/application.h"
#include "ui/paint.h"
#include "render/render.h"
@@ -42,6 +43,22 @@ void MapWidget::set_zone(core::Zone *zone)
mapwidget_zone = zone;
}
+bool MapWidget::on_keypress(const int key, const unsigned int modifier)
+{
+ if (key == 512 + SDL_BUTTON_LEFT) {
+ if (mapwidget_zone && has_mouse_focus() && hover()) {
+ core::Entity *target = mapwidget_zone->find_entity(hover());
+
+ if (targets::is_valid_map_target(target)) {
+ set_target(target);
+ emit(ui::Widget::EventClicked);
+ }
+ }
+ return true;
+
+ }
+ return false;
+}
void MapWidget::draw()
{
if (!mapwidget_zone)
@@ -170,39 +187,41 @@ void MapWidget::draw()
}
}
+ gl::end();
// draw localcontrol icon
- entity = core::localcontrol();
+ // TODO draw a ship icon
+ if (core::localcontrol()->zone() == mapwidget_zone) {
+ entity = core::localcontrol();
- //if (core::localcontrol()->state() != core::Entity::Docked) {
- icon_location.assign(map_center);
- icon_location[0] -= map_size / scale * entity->location().y();
- icon_location[1] -= map_size / scale * entity->location().x();
-
- if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
- if (texture_current != texture_entity) {
- gl::end();
+ //if (core::localcontrol()->state() != core::Entity::Docked) {
+ icon_location.assign(map_center);
+ icon_location[0] -= map_size / scale * entity->location().y();
+ icon_location[1] -= map_size / scale * entity->location().x();
+
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
texture_current = render::Textures::bind(texture_entity);
gl::begin(gl::Quads);
- }
-
- math::Color color(entity->color());
- color.a = 1.0f;
- gl::color(color);
- glTexCoord2f(0.0f, 0.0f);
- gl::vertex(icon_location.x() - r, icon_location.y() - r);
+
+ math::Color color(entity->color());
+ color.a = 1.0f;
+ gl::color(color);
+ glTexCoord2f(0.0f, 0.0f);
+ gl::vertex(icon_location.x() - r, icon_location.y() - r);
- glTexCoord2f(1.0f, 0.0f);
- gl::vertex(icon_location.x() + r, icon_location.y() - r);
+ glTexCoord2f(1.0f, 0.0f);
+ gl::vertex(icon_location.x() + r, icon_location.y() - r);
- glTexCoord2f(1.0f, 1.0f);
- gl::vertex(icon_location.x() + r, icon_location.y() + r);
+ glTexCoord2f(1.0f, 1.0f);
+ gl::vertex(icon_location.x() + r, icon_location.y() + r);
- glTexCoord2f(0.0f, 1.0f);
- gl::vertex(icon_location.x() - r, icon_location.y() + r);
+ glTexCoord2f(0.0f, 1.0f);
+ gl::vertex(icon_location.x() - r, icon_location.y() + r);
+
+ gl::end();
+ }
}
- gl::end();
gl::disable(GL_TEXTURE_2D);
if (has_mouse_focus()) {