From da36f97e1d764e1125deba86a403eee66e937d0b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 19 Apr 2009 18:29:26 +0000 Subject: added jumpdrive capability to shipmodel info message, Makefile.am cleanups, improved map targetting, corrected hud target owner color leak bug --- src/client/Makefile.am | 5 +---- src/client/hud.cc | 12 ++++++------ src/client/map.cc | 33 +++++++++++++++++++-------------- src/client/map.h | 4 ++++ src/client/targets.cc | 9 +++++---- src/core/Makefile.am | 3 +-- src/game/base/shipmodel.cc | 5 +++++ 7 files changed, 41 insertions(+), 30 deletions(-) (limited to 'src') 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(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); } diff --git a/src/core/Makefile.am b/src/core/Makefile.am index af59d00..0c1e5fb 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -14,5 +14,4 @@ noinst_LTLIBRARIES = libcore.la noinst_HEADERS = application.h commandbuffer.h core.h cvar.h entity.h func.h \ gameconnection.h gameinterface.h gameserver.h message.h module.h net.h netclient.h \ netconnection.h netserver.h player.h range.h stats.h timer.h parser.h descriptions.h \ - extension.h loader.h -_SOURCES = info.h + extension.h loader.h info.h diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc index fc4781a..b3802f7 100644 --- a/src/game/base/shipmodel.cc +++ b/src/game/base/shipmodel.cc @@ -79,6 +79,11 @@ void ShipModel::generate_info(core::Info *info) str << "acceleration: ^B" << acceleration() << " ^Nstandard"; info->add_text(str.str()); str.str(""); + + if(shipmodel_jumpdrive) { + str << "hyperspace jump drive capable"; + info->add_text(str.str()); str.str(""); + } } void ShipModel::list() -- cgit v1.2.3