Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/galaxymapwidget.cc')
-rw-r--r--src/client/galaxymapwidget.cc44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/client/galaxymapwidget.cc b/src/client/galaxymapwidget.cc
index 47d1f79..25460b8 100644
--- a/src/client/galaxymapwidget.cc
+++ b/src/client/galaxymapwidget.cc
@@ -38,11 +38,16 @@ void GalaxyMapWidget::set_zone(core::Zone *zone)
bool GalaxyMapWidget::on_mousepress(const unsigned int button)
{
- if (button == SDL_BUTTON_LEFT) {
- if (hover()) {
- if (zone() && (zone()->id() == hover())) {
+ if (button == SDL_BUTTON_LEFT)
+ {
+ if (hover())
+ {
+ if (zone() && (zone()->id() == hover()))
+ {
emit(ui::Widget::EventDoubleClicked);
- } else {
+ }
+ else
+ {
set_zone(core::Zone::find(hover()));
emit(ui::Widget::EventClicked);
}
@@ -54,16 +59,28 @@ bool GalaxyMapWidget::on_mousepress(const unsigned int button)
}
+bool GalaxyMapWidget::on_mouserelease(const unsigned int button)
+{
+ if (button == SDL_BUTTON_LEFT)
+ {
+ return true;
+ }
+
+ return false;
+}
+
void GalaxyMapWidget::draw()
{
// size and global location of the map
const float map_size = math::min(width(), height());
math::Vector2f map_location(global_location());
- if (map_size < width()) {
+ if (map_size < width())
+ {
map_location[0] += (width() - map_size) * 0.5f;
}
- if (map_size < height()) {
+ if (map_size < height())
+ {
map_location[1] += (height() - map_size) * 0.5f;
}
@@ -78,7 +95,8 @@ void GalaxyMapWidget::draw()
gl::color(0, 0, 0.25f);
gl::begin(gl::Lines);
- for (float i = 0; i <= grid_size; i += 1.0f) {
+ for (float i = 0; i <= grid_size; i += 1.0f)
+ {
gl::vertex(map_location.x(), map_location.y() + map_size / grid_size * i);
gl::vertex(map_location.x() + map_size, map_location.y() + map_size / grid_size * i);
@@ -117,7 +135,8 @@ void GalaxyMapWidget::draw()
for (core::Zone::Registry::iterator it = core::Zone::registry().begin(); it != core::Zone::registry().end(); it++) {
zone = (*it).second;
- if (zone->has_flag(core::Zone::Hidden)) {
+ if (zone->has_flag(core::Zone::Hidden))
+ {
continue;
}
@@ -127,12 +146,15 @@ void GalaxyMapWidget::draw()
icon_location[0] += map_size / scale * zone->location().x();
icon_location[1] += map_size - map_size / scale * zone->location().y(); // flip vertically
- if (math::distancesquared(cursor, icon_location) < (r*r)) {
+ if (math::distancesquared(cursor, icon_location) < (r*r))
+ {
galaxymapwidget_hover_id = zone->id();
}
- if (zone == galaxymapwidget_zone) {
- if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
+ if (zone == galaxymapwidget_zone)
+ {
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f)
+ {
draw_icon = false;
}
}