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')
-rw-r--r--src/client/Makefile.am5
-rw-r--r--src/client/hud.cc12
-rw-r--r--src/client/map.cc33
-rw-r--r--src/client/map.h4
-rw-r--r--src/client/targets.cc9
5 files changed, 35 insertions, 28 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 2786d80..f8d3c10 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -15,9 +15,6 @@ libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_HEADERS = action.h chat.h client.h clientext.h hud.h entitymenu.h \
input.h joystick.h key.h keyboard.h map.h notifications.h soundext.h \
- targets.h video.h infowidget.h playerview.h worldview.h
+ targets.h video.h infowidget.h playerview.h worldview.h trademenu.h buymenu.h
libclient_la_LIBADD = $(top_builddir)/src/core/libcore.la $(top_builddir)/src/audio/libaudio.la \
$(top_builddir)/src/render/librender.la $(top_builddir)/src/ui/libui.la
-
-_SOURCES = trademenu.h
-_SOURCES = buymenu.h
diff --git a/src/client/hud.cc b/src/client/hud.cc
index d0b7e0d..991f02b 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -190,20 +190,20 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
} else {
strdistance << "--";
}
- if (entity->type() == core::Entity::Controlable) {
- render::Text::setcolor('B');
- } else {
- render::Text::setcolor('N');
- }
// owner name
if (entity->type() == core::Entity::Controlable) {
+ render::Text::setcolor('B');
const core::EntityControlable *ec = static_cast<core::EntityControlable *>(entity);
- if (ec->owner()) {
+ if (ec->owner()) {
+ render::Text::setcolor('B');
render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f,
cy-r-4-2*render::Text::fontheight(), ec->owner()->name());
}
+ } else {
+ render::Text::setcolor('N');
}
+
render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f,
cy-r-4-render::Text::fontheight(), entity->name());
diff --git a/src/client/map.cc b/src/client/map.cc
index 6ad8b23..f10b03c 100644
--- a/src/client/map.cc
+++ b/src/client/map.cc
@@ -40,7 +40,7 @@ Map::Map(ui::Widget *parent) : ui::Window(parent)
set_background(true);
set_font(ui::root()->font_small());
- //map_target = 0;
+ map_target = 0;
map_hover = 0;
hide();
}
@@ -53,7 +53,14 @@ void Map::hide()
{
ui::Window::hide();
map_hover = 0;
- //map_target = 0;
+ map_target = 0;
+}
+
+void Map::show()
+{
+ ui::Window::show();
+ map_hover = 0;
+ map_target = targets::current();
}
void Map::toggle()
@@ -74,6 +81,9 @@ void Map::draw()
const float gridsize=16;
core::Entity *entity;
+ const core::Entity *current_target = map_target;
+ map_target = 0;
+
math::Color color;
math::Vector2f v(global_location());
@@ -123,7 +133,6 @@ void Map::draw()
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++) {
entity = (*it);
@@ -139,23 +148,18 @@ void Map::draw()
map_hover = entity->id();
}
- if (entity == targets::current()) {
- valid_target = true;
+ if (entity == current_target) {
+ map_target = entity;
if (core::application()->time() - floorf(core::application()->time()) < 0.5f) {
draw_icon = false;
}
}
if (entity == core::localplayer()->view()) {
- valid_target = true;
if (core::application()->time() - floorf(core::application()->time()) > 0.5f) {
draw_icon = false;
}
- }
- }
-
- if (entity == core::localcontrol()) {
- draw_icon = false;
+ }
}
if (draw_icon) {
@@ -238,7 +242,7 @@ void Map::draw()
gl::end();
- if (targets::current()) {
+ if (map_target) {
l.assign(v);
if (h > s ) {
@@ -257,7 +261,7 @@ void Map::draw()
render::Text::setcolor('B');
render::Text::setfont(font()->name().c_str(), font()->width(), font()->height());
- render::Text::draw(l.x, l.y, targets::current()->name());
+ render::Text::draw(l.x, l.y, map_target->name());
render::Text::setcolor('N');
}
@@ -270,7 +274,8 @@ bool Map::on_keypress(const int key, const unsigned int modifier)
if (hover()) {
core::Entity *target = core::localplayer()->zone()->find_entity(hover());
if (is_valid_map_target(target)) {
- targets::select_target(target);
+ map_target = target;
+ audio::play("ui/target");
}
}
return true;
diff --git a/src/client/map.h b/src/client/map.h
index b7b60cc..2ddab57 100644
--- a/src/client/map.h
+++ b/src/client/map.h
@@ -26,6 +26,9 @@ public:
/// hide the map window
virtual void hide();
+ /// show the map window
+ virtual void show();
+
/// called when the widget receives a key press
virtual bool on_keypress(const int key, const unsigned int modifier);
@@ -33,6 +36,7 @@ protected:
virtual void draw();
unsigned int map_hover;
+ core::Entity *map_target;
};
diff --git a/src/client/targets.cc b/src/client/targets.cc
index af8ec17..2350fce 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -71,11 +71,12 @@ unsigned int hover()
void select_target(core::Entity *entity)
{
current_target = entity;
- if (entity)
+ if (entity) {
current_target_id = current_target->id();
- else
+ audio::play("ui/target");
+ } else {
current_target_id = 0;
- audio::play("ui/target");
+ }
}
void select_target(unsigned int id)
@@ -88,7 +89,7 @@ void select_target(unsigned int id)
core::Entity *entity = zone->find_entity(id);
- if (entity)
+ if (entity && is_valid_hud_target(entity))
select_target(entity);
}