From 3cf0d66d369c0445a58a6da8abfca61a5dcd9178 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 24 Feb 2009 20:59:46 +0000 Subject: split map target selection from hud target selection --- src/client/map.cc | 108 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) (limited to 'src/client/map.cc') diff --git a/src/client/map.cc b/src/client/map.cc index f366b40..e433d40 100644 --- a/src/client/map.cc +++ b/src/client/map.cc @@ -5,6 +5,7 @@ the terms of the GNU General Public License version 2 */ +#include "audio/audio.h" #include "core/application.h" #include "client/map.h" #include "client/input.h" @@ -99,23 +100,16 @@ void Map::draw() for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { core::Entity *entity = (*it); - bool has_icon = false; - bool draw_icon = true; + bool draw_icon = false; + math::Vector2f l(v); if (entity->flag_is_set(core::Entity::ShowOnMap)) { - has_icon = true; - - if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) { - core::EntityDynamic *ed = dynamic_cast(entity); - if (ed->eventstate() ==core::Entity::Docked) { - draw_icon = false; - } - } + draw_icon = true; + l.x -= s / scale * entity->location().y; + l.y -= s / scale * entity->location().x; - if (entity == core::localcontrol()) { - if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { - draw_icon = false; - } + if (math::distancesquared(cursor, l) < (r*r)) { + map_hover = entity->id(); } if (entity == map_target) { @@ -125,55 +119,53 @@ void Map::draw() } } - if (has_icon) { - math::Vector2f l(v); - l.x -= s / scale * entity->location().y; - l.y -= s / scale * entity->location().x; - - if (math::distancesquared(cursor, l) < (r*r)) { - map_hover = entity->id(); + if (entity == core::localcontrol()) { + draw_icon = true; + if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { + draw_icon = false; } + } - if (draw_icon) { - if (entity->type() == core::Entity::Globe) { - if (entity->flag_is_set(core::Entity::Bright)) { - if (texture_current != texture_bright) { - gl::end(); - texture_current = render::Textures::bind(texture_bright); - gl::begin(gl::Quads); - } - } else { - if (texture_current != texture_globe) { - gl::end(); - texture_current = render::Textures::bind(texture_globe); - gl::begin(gl::Quads); - } + if (draw_icon) { + if (entity->type() == core::Entity::Globe) { + if (entity->flag_is_set(core::Entity::Bright)) { + if (texture_current != texture_bright) { + gl::end(); + texture_current = render::Textures::bind(texture_bright); + gl::begin(gl::Quads); } } else { - if (texture_current != texture_entity) { + if (texture_current != texture_globe) { gl::end(); - texture_current = render::Textures::bind(texture_entity); + texture_current = render::Textures::bind(texture_globe); gl::begin(gl::Quads); } } - - - math::Color color(entity->color()); - color.a = 1.0f; - gl::color(color); - glTexCoord2f(0.0f, 0.0f); - gl::vertex(l.x-r, l.y-r); - - glTexCoord2f(1.0f, 0.0f); - gl::vertex(l.x+r, l.y-r); - - glTexCoord2f(1.0f, 1.0f); - gl::vertex(l.x+r, l.y+r); - - glTexCoord2f(0.0f, 1.0f); - gl::vertex(l.x-r, l.y+r); + } else { + if (texture_current != texture_entity) { + gl::end(); + 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(l.x-r, l.y-r); + + glTexCoord2f(1.0f, 0.0f); + gl::vertex(l.x+r, l.y-r); + + glTexCoord2f(1.0f, 1.0f); + gl::vertex(l.x+r, l.y+r); + + glTexCoord2f(0.0f, 1.0f); + gl::vertex(l.x-r, l.y+r); } + } gl::end(); gl::disable(GL_TEXTURE_2D); @@ -181,9 +173,13 @@ void Map::draw() bool Map::on_keypress(const int key, const unsigned int modifier) { - if ((hover()) && (key == 512 + SDL_BUTTON_LEFT)) { - //targets::select_target(hover()); - //TODO set map target + if (key == 512 + SDL_BUTTON_LEFT) { + if (hover()) { + map_target = core::localplayer()->zone()->find_entity(hover()); + if (map_target) { + audio::play("ui/target"); + } + } return true; } else if (key == SDLK_ESCAPE) { -- cgit v1.2.3