Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/map.cc108
-rw-r--r--src/client/map.h4
-rw-r--r--src/client/targets.cc2
3 files changed, 55 insertions, 59 deletions
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<core::EntityDynamic *>(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) {
diff --git a/src/client/map.h b/src/client/map.h
index 2b1bacf..37da19a 100644
--- a/src/client/map.h
+++ b/src/client/map.h
@@ -18,7 +18,7 @@ public:
Map(ui::Widget *parent = 0);
virtual ~Map();
- inline size_t hover() const { return map_hover; }
+ inline unsigned int hover() const { return map_hover; }
/// toggle the map window
void toggle();
@@ -32,7 +32,7 @@ public:
protected:
virtual void draw();
- size_t map_hover;
+ unsigned int map_hover;
core::Entity *map_target;
};
diff --git a/src/client/targets.cc b/src/client/targets.cc
index ec15df9..af49826 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -86,7 +86,7 @@ void select_target(core::Entity *entity)
current_target_id = current_target->id();
else
current_target_id = 0;
- core::application()->notify_sound("ui/target");
+ audio::play("ui/target");
}
void select_target(unsigned int id)