From dd2162af7727c0f30d77cc7ae33ccbb346611b20 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 8 Nov 2013 21:01:05 +0000 Subject: Code cleanups, removed unnecessary functions, added star coronas to the map. --- src/client/mapwidget.cc | 58 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'src/client/mapwidget.cc') diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc index 3c0b95a..770abb2 100644 --- a/src/client/mapwidget.cc +++ b/src/client/mapwidget.cc @@ -7,6 +7,8 @@ #include "client/mapwidget.h" #include "client/targets.h" #include "core/application.h" +#include "core/entity.h" +#include "core/entityglobe.h" #include "ui/paint.h" #include "render/render.h" #include "render/gl.h" @@ -112,7 +114,6 @@ void MapWidget::draw() const float r = 12.0f; // radius of map icons float scale = 4096.0f; // map size in game units math::Color color; - const core::Entity *entity = 0; // draw map icons gl::enable(GL_TEXTURE_2D); @@ -120,7 +121,7 @@ void MapWidget::draw() for (core::Zone::Content::iterator it = mapwidget_zone->content().begin(); it != mapwidget_zone->content().end(); it++) { - entity = (*it); + core::Entity *entity = (*it); bool draw_icon = false; @@ -143,14 +144,53 @@ void MapWidget::draw() } if (draw_icon) { + color.assign(entity->color()); + color.a = 1.0f; + if (entity->type() == core::Entity::Globe) { - if (entity->has_flag(core::Entity::Bright)) { + // FIXME this is copy paste from the renderer and can use a cleanup + core::EntityGlobe *globe = static_cast(entity); + + if (globe->has_flag(core::Entity::Bright)) { + + // load globe corona texture + if (!globe->corona_id() && globe->coronaname().size()) { + globe->set_corona_id(render::Textures::load("textures/" + globe->coronaname())); + if (!globe->corona_id()) { + globe->set_coronaname(""); + } + } + + // draw corona + if (globe->corona_id()) { + gl::end(); + + texture_current = render::Textures::bind(globe->corona_id()); + + gl::begin(gl::Quads); + gl::color(color); + glTexCoord2f(0.0f, 0.0f); + gl::vertex(icon_location.x() - r * 2.0f, icon_location.y() - r * 2.0f); + + glTexCoord2f(1.0f, 0.0f); + gl::vertex(icon_location.x() + r * 2.0f, icon_location.y() - r * 2.0f); + + glTexCoord2f(1.0f, 1.0f); + gl::vertex(icon_location.x() + r * 2.0f, icon_location.y() + r * 2.0f); + + glTexCoord2f(0.0f, 1.0f); + gl::vertex(icon_location.x() - r * 2.0f, icon_location.y() + r * 2.0f); + } + + // bind bright globe icon texture if (texture_current != texture_bright) { gl::end(); texture_current = render::Textures::bind(texture_bright); gl::begin(gl::Quads); } } else { + + // bind globe icon texture if (texture_current != texture_globe) { gl::end(); texture_current = render::Textures::bind(texture_globe); @@ -167,10 +207,8 @@ void MapWidget::draw() if (entity == core::localplayer()->mission_target()) { color.assign(palette()->mission()); - } else { - color.assign(entity->color()); + } - color.a = 1.0f; gl::color(color); glTexCoord2f(0.0f, 0.0f); @@ -192,18 +230,18 @@ void MapWidget::draw() // draw localcontrol icon // TODO draw a ship icon if (core::localcontrol()->zone() == mapwidget_zone) { - entity = core::localcontrol(); + core::EntityControlable *controlable = 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(); + 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) { texture_current = render::Textures::bind(texture_entity); gl::begin(gl::Quads); - math::Color color(entity->color()); + math::Color color(controlable->color()); color.a = 1.0f; gl::color(color); glTexCoord2f(0.0f, 0.0f); -- cgit v1.2.3