From e4618a1c7e5fb0629997d389cb941a61095490ac Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 8 Mar 2009 11:00:30 +0000 Subject: changed camera settings for crash-view, map tweaks --- src/client/map.cc | 82 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 11 deletions(-) (limited to 'src/client/map.cc') diff --git a/src/client/map.cc b/src/client/map.cc index 35a1be7..6384588 100644 --- a/src/client/map.cc +++ b/src/client/map.cc @@ -9,9 +9,11 @@ #include "core/application.h" #include "client/map.h" #include "client/input.h" +#include "ui/ui.h" #include "ui/paint.h" #include "render/gl.h" #include "render/textures.h" +#include "render/text.h" namespace client { @@ -20,6 +22,7 @@ Map::Map(ui::Widget *parent) : ui::Window(parent) set_label("map"); set_border(true); set_background(true); + set_font(ui::root()->font_small()); map_target = 0; map_hover = 0; @@ -53,7 +56,12 @@ void Map::draw() const float blue = 0.8f; const float gridsize=16; + core::Entity *entity; + math::Color color; + math::Vector2f v(global_location()); + math::Vector2f l; + v.x += margin; v.y += margin; map_hover = 0; @@ -97,11 +105,13 @@ void Map::draw() gl::enable(GL_TEXTURE_2D); gl::begin(gl::Quads); + // draw map icons + bool valid_target = false; for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { - core::Entity *entity = (*it); + entity = (*it); bool draw_icon = false; - math::Vector2f l(v); + l.assign(v); if (entity->flag_is_set(core::Entity::ShowOnMap)) { draw_icon = true; @@ -113,6 +123,7 @@ void Map::draw() } if (entity == map_target) { + valid_target = true; if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { draw_icon = false; } @@ -120,13 +131,7 @@ void Map::draw() } if (entity == core::localcontrol()) { - draw_icon = true; - l.x -= s / scale * entity->location().y; - l.y -= s / scale * entity->location().x; - - if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { - draw_icon = false; - } + draw_icon = false; } if (draw_icon) { @@ -152,8 +157,7 @@ void Map::draw() } } - - math::Color color(entity->color()); + color.assign(entity->color()); color.a = 1.0f; gl::color(color); glTexCoord2f(0.0f, 0.0f); @@ -170,7 +174,63 @@ void Map::draw() } } + + // draw localcontrol icon + entity = core::localcontrol(); + l.assign(v); + l.x -= s / scale * entity->location().y; + l.y -= s / scale * entity->location().x; + if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { + 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(); + + + if (!valid_target) { + map_target = 0; + } else { + l.assign(v); + + if (h > s ) { + // target information below + l.x -= s * 0.5f; + l.y += s * 0.5f; + + l.y += margin; + } else { + // target information right + l.x += s * 0.5f; + l.y -= s * 0.5f; + + l.x += margin; + } + + render::Text::setcolor('B'); + render::Text::setfont(font()->name().c_str(), font()->width(), font()->height()); + render::Text::draw(l.x, l.y, map_target->name()); + render::Text::setcolor('N'); + } + gl::disable(GL_TEXTURE_2D); } -- cgit v1.2.3