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>2015-01-06 21:38:33 +0000
committerStijn Buys <ingar@osirion.org>2015-01-06 21:38:33 +0000
commit9626a5ce823fe94970b04dc504993583996e6074 (patch)
tree6c751347b75ce952169da889abd74853f5544857 /src/client
parent22785c4e7eb0be49a795f4b2bcdf5cbda1626a5a (diff)
Fixed target selection in the map window.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/galaxymapwidget.cc11
-rw-r--r--src/client/galaxymapwidget.h19
-rw-r--r--src/client/mapwidget.cc10
-rw-r--r--src/client/mapwidget.h22
4 files changed, 42 insertions, 20 deletions
diff --git a/src/client/galaxymapwidget.cc b/src/client/galaxymapwidget.cc
index a49e004..47d1f79 100644
--- a/src/client/galaxymapwidget.cc
+++ b/src/client/galaxymapwidget.cc
@@ -36,10 +36,10 @@ void GalaxyMapWidget::set_zone(core::Zone *zone)
galaxymapwidget_zone = zone;
}
-bool GalaxyMapWidget::on_keypress(const int key, const unsigned int modifier)
+bool GalaxyMapWidget::on_mousepress(const unsigned int button)
{
- if (key == 512 + SDL_BUTTON_LEFT) {
- if (has_mouse_focus() && hover()) {
+ if (button == SDL_BUTTON_LEFT) {
+ if (hover()) {
if (zone() && (zone()->id() == hover())) {
emit(ui::Widget::EventDoubleClicked);
} else {
@@ -48,9 +48,10 @@ bool GalaxyMapWidget::on_keypress(const int key, const unsigned int modifier)
}
}
return true;
-
}
+
return false;
+
}
void GalaxyMapWidget::draw()
@@ -105,7 +106,7 @@ void GalaxyMapWidget::draw()
// draw map icons
/*
* Note: the galactic coordinate system differs from the zone coordinate system:
- * positive X-axis runs left-to-right on the screen and the positive U-axis runs bottom-to-top on the screen.
+ * positive X-axis runs left-to-right on the screen and the positive Y-axis runs bottom-to-top on the screen.
*
* This is because I'm lazy and I just copy the coordinates from the SVG starsystem roadmap as shown in Inkscape.
*/
diff --git a/src/client/galaxymapwidget.h b/src/client/galaxymapwidget.h
index 3e74903..a3cc01d 100644
--- a/src/client/galaxymapwidget.h
+++ b/src/client/galaxymapwidget.h
@@ -10,7 +10,8 @@
#include "core/zone.h"
#include "ui/widget.h"
-namespace client {
+namespace client
+{
class GalaxyMapWidget : public ui::Widget
{
@@ -23,19 +24,26 @@ public:
void set_zone(core::Zone *zone);
- inline unsigned int hover() const {
+ inline unsigned int hover() const
+ {
return galaxymapwidget_hover_id;
}
- inline core::Zone *zone() const {
+ inline core::Zone *zone() const
+ {
return galaxymapwidget_zone;
}
protected:
+ /**
+ * @brief draw event handler
+ * */
virtual void draw();
- /// called when the widget receives a key press
- virtual bool on_keypress(const int key, const unsigned int modifier);
+ /**
+ * @brief mouse button press event handler
+ * */
+ virtual bool on_mousepress(const unsigned int button);
private:
float galaxymapwidget_zoom;
@@ -46,4 +54,5 @@ private:
}; // class GalaxyMapWidget
} // namespace client
+
#endif // __INCLUDED_CLIENT_GALAXYMAPWIDGET_H__
diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc
index 52fe074..54e109e 100644
--- a/src/client/mapwidget.cc
+++ b/src/client/mapwidget.cc
@@ -45,10 +45,10 @@ void MapWidget::set_zone(core::Zone *zone)
mapwidget_zone = zone;
}
-bool MapWidget::on_keypress(const int key, const unsigned int modifier)
+bool MapWidget::on_mousepress(const unsigned int button)
{
- if (key == 512 + SDL_BUTTON_LEFT) {
- if (mapwidget_zone && has_mouse_focus() && hover()) {
+ if (button == SDL_BUTTON_LEFT) {
+ if (mapwidget_zone && hover()) {
core::Entity *target = mapwidget_zone->find_entity(hover());
if (targets::is_valid_map_target(target)) {
@@ -57,10 +57,12 @@ bool MapWidget::on_keypress(const int key, const unsigned int modifier)
}
}
return true;
+ }
- }
return false;
+
}
+
void MapWidget::draw()
{
if (!mapwidget_zone)
diff --git a/src/client/mapwidget.h b/src/client/mapwidget.h
index 0482330..38485fd 100644
--- a/src/client/mapwidget.h
+++ b/src/client/mapwidget.h
@@ -10,7 +10,8 @@
#include "core/zone.h"
#include "ui/widget.h"
-namespace client {
+namespace client
+{
class MapWidget : public ui::Widget
{
@@ -25,23 +26,31 @@ public:
void set_target(const core::Entity *entity);
- inline unsigned int hover() const {
+ inline unsigned int hover() const
+ {
return mapwidget_hover_id;
}
- inline const core::Entity *target() const {
+ inline const core::Entity *target() const
+ {
return mapwidget_target;
}
- inline core::Zone *zone() const {
+ inline core::Zone *zone() const
+ {
return mapwidget_zone;
}
protected:
+ /**
+ * @brief draw event handler
+ * */
virtual void draw();
- /// called when the widget receives a key press
- virtual bool on_keypress(const int key, const unsigned int modifier);
+ /**
+ * @brief mouse button press event handler
+ * */
+ virtual bool on_mousepress(const unsigned int button);
private:
float mapwidget_zoom;
@@ -53,4 +62,5 @@ private:
}; // class MapWidget
} // namespace client
+
#endif // __INCLUDED_CLIENT_MAPWIDGET_H__