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/mapwidget.cc')
-rw-r--r--src/client/mapwidget.cc85
1 files changed, 60 insertions, 25 deletions
diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc
index 54e109e..20bb979 100644
--- a/src/client/mapwidget.cc
+++ b/src/client/mapwidget.cc
@@ -47,11 +47,14 @@ void MapWidget::set_zone(core::Zone *zone)
bool MapWidget::on_mousepress(const unsigned int button)
{
- if (button == SDL_BUTTON_LEFT) {
- if (mapwidget_zone && 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)) {
+ if (targets::is_valid_map_target(target))
+ {
set_target(target);
emit(ui::Widget::EventClicked);
}
@@ -63,6 +66,16 @@ bool MapWidget::on_mousepress(const unsigned int button)
}
+bool MapWidget::on_mouserelease(const unsigned int button)
+{
+ if (button == SDL_BUTTON_LEFT)
+ {
+ return true;
+ }
+
+ return false;
+}
+
void MapWidget::draw()
{
if (!mapwidget_zone)
@@ -72,10 +85,12 @@ void MapWidget::draw()
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;
}
@@ -122,52 +137,63 @@ void MapWidget::draw()
gl::begin(gl::Quads);
- for (core::Zone::Content::iterator it = mapwidget_zone->content().begin(); it != mapwidget_zone->content().end(); it++) {
+ for (core::Zone::Content::iterator it = mapwidget_zone->content().begin(); it != mapwidget_zone->content().end(); it++)
+ {
core::Entity *entity = (*it);
bool draw_icon = false;
icon_location.assign(map_center);
- if (targets::is_valid_map_target(entity)) {
+ if (targets::is_valid_map_target(entity))
+ {
draw_icon = true;
icon_location[0] -= map_size / scale * entity->location().y();
icon_location[1] -= map_size / scale * entity->location().x();
- if (math::distancesquared(cursor, icon_location) < (r*r)) {
+ if (math::distancesquared(cursor, icon_location) < (r*r))
+ {
mapwidget_hover_id = entity->id();
}
- if (entity == mapwidget_target) {
- if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
+ if (entity == mapwidget_target)
+ {
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f)
+ {
draw_icon = false;
}
}
}
- if (draw_icon) {
+ if (draw_icon)
+ {
color.assign(entity->color());
color.a = 1.0f;
- if (entity->type() == core::Entity::Globe) {
+ if (entity->type() == core::Entity::Globe)
+ {
// FIXME this is copy paste from the renderer and can use a cleanup
core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
- if (globe->has_flag(core::Entity::Bright)) {
+ if (globe->has_flag(core::Entity::Bright))
+ {
gl::end();
// load globe corona texture
- if (!globe->corona_id() && globe->coronaname().size()) {
+ if (!globe->corona_id() && globe->coronaname().size())
+ {
globe->set_corona_id(render::Textures::load("textures/" + globe->coronaname()));
- if (!globe->corona_id()) {
+ if (!globe->corona_id())
+ {
globe->set_coronaname("");
}
}
// draw corona
- if (globe->corona_id()) {
+ if (globe->corona_id())
+ {
texture_current = render::Textures::bind(globe->corona_id());
gl::begin(gl::Quads);
@@ -187,30 +213,37 @@ void MapWidget::draw()
}
// bind bright globe icon texture
- if (texture_current != texture_bright) {
+ if (texture_current != texture_bright)
+ {
texture_current = render::Textures::bind(texture_bright);
}
gl::begin(gl::Quads);
- } else {
-
+ }
+ else
+ {
// bind globe icon texture
- if (texture_current != texture_globe) {
+ if (texture_current != texture_globe)
+ {
gl::end();
texture_current = render::Textures::bind(texture_globe);
gl::begin(gl::Quads);
}
}
- } else {
- if (texture_current != texture_entity) {
+ }
+ else
+ {
+ if (texture_current != texture_entity)
+ {
gl::end();
texture_current = render::Textures::bind(texture_entity);
gl::begin(gl::Quads);
}
}
- if (entity == core::localplayer()->mission_target()) {
+ if (entity == core::localplayer()->mission_target())
+ {
color.assign(palette()->mission());
}
@@ -234,7 +267,8 @@ void MapWidget::draw()
// draw localcontrol icon
// TODO draw a ship icon
- if (core::localcontrol()->zone() == mapwidget_zone) {
+ if (core::localcontrol()->zone() == mapwidget_zone)
+ {
core::EntityControlable *controlable = core::localcontrol();
//if (core::localcontrol()->state() != core::Entity::Docked) {
@@ -242,7 +276,8 @@ void MapWidget::draw()
icon_location[0] -= map_size / scale * controlable->location().y();
icon_location[1] -= map_size / scale * controlable->location().x();
- if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
+ if (core::application()->time() - floorf(core::application()->time()) < 0.5f)
+ {
texture_current = render::Textures::bind(texture_entity);
gl::begin(gl::Quads);