diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/client.cc | 47 | ||||
-rw-r--r-- | src/client/client.h | 2 | ||||
-rw-r--r-- | src/client/input.cc | 3 | ||||
-rw-r--r-- | src/client/view.cc | 78 | ||||
-rw-r--r-- | src/core/application.cc | 15 | ||||
-rw-r--r-- | src/core/application.h | 12 | ||||
-rw-r--r-- | src/core/gameinterface.cc | 1 | ||||
-rw-r--r-- | src/core/gameserver.cc | 6 | ||||
-rw-r--r-- | src/core/netconnection.cc | 5 | ||||
-rw-r--r-- | src/core/netserver.cc | 5 | ||||
-rw-r--r-- | src/render/draw.cc | 6 | ||||
-rw-r--r-- | src/render/render.cc | 25 | ||||
-rw-r--r-- | src/render/render.h | 5 | ||||
-rw-r--r-- | src/ui/ui.cc | 29 | ||||
-rw-r--r-- | src/ui/ui.h | 3 | ||||
-rw-r--r-- | src/ui/window.cc | 10 | ||||
-rw-r--r-- | src/ui/window.h | 13 |
17 files changed, 149 insertions, 116 deletions
diff --git a/src/client/client.cc b/src/client/client.cc index 81aba9d..3f368a7 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -141,8 +141,9 @@ void Client::run() // default framerate 125fps, 8 milliseconds Uint32 client_frame_lenght = 8; - Uint32 client_previous_timestamp = 0; Uint32 client_current_timestamp = 0; + Uint32 client_previous_timestamp = 0; + console()->flush(); console()->clear_notify(); @@ -158,7 +159,7 @@ void Client::run() (*cl_framerate) = 1000.0f; } - if (cl_framerate->value()) { + if (cl_framerate->value()) { client_frame_lenght = (Uint32) roundf(1000.0f / cl_framerate->value()); } else { client_frame_lenght = 0; @@ -234,14 +235,28 @@ void Client::shutdown() quit(0); } -void Client::notify_sound(const char * name) +/* -- notifications from core::Application ------------------------- */ + +void Client::notify_connect() { - audio::play(name); + ui::root()->hide_window(); } -void Client::notify_remove_sound(size_t source) +void Client::notify_disconnect() { - audio::Sources::remove(source); + // FIXME unload sounds + //audio::reset(); + render::reset(); +} + +void Client::notify_zonechange() +{ + render::unload(); +} + +void Client::notify_sound(const char * name) +{ + audio::play(name); } void Client::notify_message(core::Message::Channel const channel, std::string const message) @@ -270,26 +285,18 @@ void Client::notify_message(core::Message::Channel const channel, std::string co break; } - con_print << message << std::endl; + con_print << message << std::endl; console()->notify(message); } -void Client::notify_zoneclear(core::Zone *zone) -{ - view::clear_zone(zone); -} +/* FIXME -void Client::notify_disconnect() -{ - // FIXME unload sounds - render::unload(); - view::clear_zone(0); -} + these notifications are hacks and need to be fixed +*/ -void Client::notify_connect() +void Client::notify_remove_sound(size_t source) { - ui::root()->hide_window(); - view::clear_zone(0); + audio::Sources::remove(source); } } // namespace client diff --git a/src/client/client.h b/src/client/client.h index dc4f05f..bd7af6b 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -38,7 +38,7 @@ public: virtual void notify_remove_sound(size_t source); /// clear zone notification - virtual void notify_zoneclear(core::Zone *zone); + virtual void notify_zonechange(); /// connect notification virtual void notify_connect(); diff --git a/src/client/input.cc b/src/client/input.cc index 31d514f..d2a53e1 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -20,6 +20,7 @@ #include "math/functions.h" #include "render/camera.h" #include "render/draw.h" +#include "render/dust.h" #include "render/text.h" #include "ui/ui.h" @@ -659,10 +660,10 @@ void reset() mouse_x = video::width / 2; mouse_y = video::height / 2; render::Camera::reset(); + render::Dust::reset(); mouse_control_override = false; mouse_control_override_time = 0; targets::reset(); - render::reset(); for (Keyboard::iterator it = keyboard->begin(); it != keyboard->end(); it++) { Key *key = (*it).second; diff --git a/src/client/view.cc b/src/client/view.cc index 38d22d4..15f70bc 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -30,15 +30,16 @@ namespace client { -core::Cvar *draw_ui = 0; -core::Cvar *draw_stats = 0; -core::Cvar *draw_devinfo = 0; -core::Cvar *draw_keypress = 0; +core::Cvar *draw_ui = 0; +core::Cvar *draw_stats = 0; +core::Cvar *draw_devinfo = 0; +core::Cvar *draw_keypress = 0; -core::Cvar *ui_pointercolor = 0; -core::Cvar *ui_pointerhovercolor =0; +core::Cvar *ui_pointercolor = 0; +core::Cvar *ui_pointerhovercolor = 0; /* -- DevInfo------------------------------------------------------- */ + DevInfo::DevInfo(ui::Widget *parent) : ui::Widget(parent) { set_label("devinfo"); @@ -213,6 +214,8 @@ void View::draw() view_devinfo->set_visible(draw_devinfo->value() ? true : false); view_stats->set_visible(draw_stats->value() ? true : false); view_keypress->set_visible(draw_keypress->value() ? true : false); + + //draw_world(); } /* -- namespace view ----------------------------------------------- */ @@ -220,8 +223,6 @@ void View::draw() namespace view { -core::Zone *current_zone = 0; - void init() { // FIXME integrate with libui @@ -242,31 +243,6 @@ void shutdown() targets::shutdown(); } -void clear_zone(core::Zone *zone) -{ - if (!zone) { - current_zone = 0; - return; - } - - for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { - core:: Entity *entity = (*it); - - if (entity->type() == core::Entity::Globe) { - core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); - if (globe->render_texture) { - render::Textures::unload(globe->render_texture); - globe->render_texture = 0; - } - } - } - - if (zone->sky_texture()) { - render::Textures::unload(zone->sky_texture()); - zone->set_sky_texture(0); - } -} - /* FIXME should be merged with the render passes and in the bbox pass @@ -483,7 +459,7 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) } } -void draw_status() +void draw_hud() { using namespace render; std::stringstream status; @@ -525,32 +501,17 @@ void draw_status() } core::Entity *target = targets::current(); - float d = 0; std::stringstream strdistance; - - if (target) { - d = math::distance(core::localcontrol()->location(), target->state()->location()) - target->radius() - core::localcontrol()->radius(); - } -/* - if (draw_devinfo->value()) { - std::stringstream devinfo; - devinfo << std::fixed << std::setprecision(2) - << "^Nx:^B" << core::localcontrol()->location().x << " " - << "^Ny:^B" << core::localcontrol()->location().y << " " - << "^Nz:^B" << core::localcontrol()->location().z << '\n'; - - devinfo << "^Nthurst:^B " << core::localcontrol()->thrust() << " " - << "^Nspeed:^B " << core::localcontrol()->speed() << '\n'; - if (target) - devinfo << "^Ndist:^B " << d << '\n'; - Text::draw(4, 4 + Text::fontheight(), devinfo); - } -*/ + float d = 0; float y = 1.0f; + if (target) { std::stringstream strtarget; strtarget << "^B" << target->name() << "\n^B"; + d = math::distance(core::localcontrol()->location(), target->state()->location()) + - target->radius() - core::localcontrol()->radius(); + if (d > 0 ) { strtarget << "^Ndist:^B "; if (d > 100.0f) { @@ -833,11 +794,6 @@ void frame(float seconds) render::Stats::clear(); if (core::application()->connected() && core::game()->serverframetime()) { - if (core::localplayer()->zone() != current_zone) { - if (current_zone) - clear_zone(current_zone); - current_zone = core::localplayer()->zone(); - } render::draw(seconds); // draw the world targets::draw(); // validate current target, render sound @@ -870,8 +826,8 @@ void frame(float seconds) if (draw_ui->value()) { Text::setfont("gui", 12, 18); - // draw the player status - draw_status(); + // draw the hud + draw_hud(); // draw the chat box chat::draw(); diff --git a/src/core/application.cc b/src/core/application.cc index 3b30962..db4f338 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -371,7 +371,6 @@ void Application::disconnect() notify_disconnect(); delete application_game; application_game = 0; - notify_zoneclear(0); con_print << "^BDisconnected.\n"; } } @@ -524,13 +523,7 @@ void Application::notify_sound(const char *name) // Dedicated servers don't need sounds } -void Application::notify_remove_sound(size_t source) -{ - // the default implementation does nothing. - // Dedicated servers don't need sounds -} - -void Application::notify_zoneclear(Zone *zone) +void Application::notify_zonechange() { // the default implementation does nothing. // The client uses this to clear old zones @@ -547,4 +540,10 @@ void Application::notify_connect() { } +void Application::notify_remove_sound(size_t source) +{ + // the default implementation does nothing. + // Dedicated servers don't need sounds +} + } diff --git a/src/core/application.h b/src/core/application.h index 9ac82f7..e55c37f 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -69,18 +69,18 @@ public: /// text notifications from the core to the application virtual void notify_message(Message::Channel const channel, std::string const message); - /// remove sound source notification - virtual void notify_remove_sound(size_t source); - - /// zone clear notification - virtual void notify_zoneclear(Zone *zone); - /// connect notification virtual void notify_connect(); /// disconnect notification virtual void notify_disconnect(); + /// zone change notification + virtual void notify_zonechange(); + + /// remove sound source notification + virtual void notify_remove_sound(size_t source); + /*----- static --------------------------------------------------- */ /// a pointer to the current application instance diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index 1ea3b55..74acced 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -82,7 +82,6 @@ void GameInterface::clear() // remove all zones for (Zone::Registry::iterator it = Zone::registry().begin(); it != Zone::registry().end(); it++) { Zone *zone = (*it).second; - application()->notify_zoneclear(zone); delete zone; } Zone::registry().clear(); diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index b6767ad..46c3624 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -622,7 +622,6 @@ void GameServer::frame(float seconds) if (server_network) { // send network updates server_network->frame(server_time, server_previoustime); - } // mark all entities as updated @@ -639,6 +638,11 @@ void GameServer::frame(float seconds) } } + if (localplayer()->zonechange()) { + application()->notify_zonechange(); + localplayer()->player_zonechange = false; + } + if (!Cvar::sv_dedicated->value()) { update_clientstate(0); } diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 9268447..ae1118f 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -557,7 +557,7 @@ void NetConnection::parse_incoming_message(const std::string & message) if (connection()->localplayer()->zonechange() && oldzone && (oldzone != connection()->localplayer()->zone())) { // notify the applciation to clear none-core zone assets (textures etc) - application()->notify_zoneclear(oldzone); + application()->notify_zonechange(); // delete all entities in the old zone for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) { @@ -573,7 +573,8 @@ void NetConnection::parse_incoming_message(const std::string & message) oldzone->content().clear(); } } else { - // FIXME find player + // find player + // FIXME player might be localplayer() Player *player = 0; for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) { if( (*it)->id() == player_id) { diff --git a/src/core/netserver.cc b/src/core/netserver.cc index e1bd41a..95b047a 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -364,10 +364,6 @@ void NetServer::client_frame(NetClient *client, float timestamp, float previoust void NetServer::frame(float timestamp, float previoustimestamp) { /* FIXME - This code has to be rewritten to send per-player updates. - Players should only receive updates from their current zone - Fix zonechange events - Only entities within visual range should send updates (1024 game units?) Fix reliable messages It would be nice if players with the highest ping got their updates first @@ -390,7 +386,6 @@ void NetServer::frame(float timestamp, float previoustimestamp) client->player()->player_dirty = false; client->player()->player_zonechange = false; } - client->transmit(fd()); } } diff --git a/src/render/draw.cc b/src/render/draw.cc index 6de398a..573587e 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -1107,10 +1107,4 @@ void draw(float seconds) // GL_BLEND must be enabled for the GUI } -// reset drawing parameters for a new localcontrol -void reset() -{ - Dust::reset(); -} - } diff --git a/src/render/render.cc b/src/render/render.cc index f018510..3ba7e92 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -115,6 +115,30 @@ void clear() void unload() { + // clear zone sky textures + for (core::Zone::Registry::iterator it = core::Zone::registry().begin(); it != core::Zone::registry().end(); it++) { + core::Zone *zone = (*it).second; + if (zone->sky_texture()) { + render::Textures::unload(zone->sky_texture()); + zone->set_sky_texture(0); + } + } + + for (core::Entity::Registry::iterator it = core::Entity::registry().begin(); it != core::Entity::registry().end(); it++) { + core:: Entity *entity = (*it).second; + + if (entity->type() == core::Entity::Globe) { + core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); + if (globe->render_texture) { + render::Textures::unload(globe->render_texture); + globe->render_texture = 0; + } + } + } +} + +void reset() +{ clear(); Textures::shutdown(); @@ -128,6 +152,7 @@ void unload() vertexarray = new VertexArray(mb); } + void shutdown() { con_print << "^BShutting down renderer..." << std::endl; diff --git a/src/render/render.h b/src/render/render.h index 5d8d12f..3faa097 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -29,7 +29,10 @@ namespace render { /// shutdown the render subsystem void shutdown(); - /// unload render data + /// reset all render data + void reset(); + + /// unload game render data void unload(); extern core::Cvar *r_arraysize; diff --git a/src/ui/ui.cc b/src/ui/ui.cc index bba9ea6..8242381 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -89,9 +89,11 @@ void help_menu() con_print << "^Bmenu functions" << std::endl; con_print << " menu help show this help" << std::endl; con_print << " menu list list available menus" << std::endl; - con_print << " menu hide hide the current menu" << std::endl; - con_print << " menu close close the current menu" << std::endl; con_print << " menu [name] show a menu" << std::endl; + con_print << " menu back return to the previous menu" << std::endl; + con_print << " menu previous return to the previous menu" << std::endl; + con_print << " menu close close the current menu" << std::endl; + con_print << " menu hide hide the current menu" << std::endl; root()->list_menus(); } @@ -117,6 +119,12 @@ void func_menu(std::string const &args) } else if (command.compare("close") == 0) { root()->hide_window(); + } else if (command.compare("back") == 0) { + root()->previous_window(); + + } else if (command.compare("previous") == 0) { + root()->previous_window(); + } else if (command.compare("list") == 0) { root()->list_menus(); } else { @@ -345,8 +353,12 @@ void UI::show_window(const char *label) Window *window = find_window(label); if (window) { - if (ui_active_window) + if (ui_active_window) { ui_active_window->hide(); + window->set_previous(ui_active_window); + } else { + window->clear_previous(); + } ui_active_window = window; ui_active_window->event_resize(); ui_active_window->raise(); @@ -365,6 +377,17 @@ void UI::hide_window() } } +void UI::previous_window() +{ + if (ui_active_window) { + if (ui_active_window->previous().size()) { + show_window(ui_active_window->previous().c_str()); + } else { + hide_window(); + } + } +} + void UI::frame() { ui_focus = event_focus(mouse_cursor); diff --git a/src/ui/ui.h b/src/ui/ui.h index 3a4ba75..a555e97 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -37,6 +37,9 @@ public: /// hide the active window void hide_window(); + /// show previous window + void previous_window(); + /// return the active window Window *active() { return ui_active_window; } diff --git a/src/ui/window.cc b/src/ui/window.cc index b18348b..cc9f3b5 100644 --- a/src/ui/window.cc +++ b/src/ui/window.cc @@ -24,6 +24,16 @@ Window::~Window() window_children.clear(); } +void Window::set_previous(Window *previous) +{ + window_previous.assign(previous->label()); +} + +void Window::clear_previous() +{ + window_previous.clear(); +} + void Window::draw_border() { if (!border()) diff --git a/src/ui/window.h b/src/ui/window.h index f88d5aa..a134f04 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -19,6 +19,13 @@ public: virtual void draw_border(); + /// set the label of the previous window + void set_previous(Window *previous); + /// clear the label of the previous window + void clear_previous(); + + inline std::string const &previous() const { return window_previous; } + protected: typedef std::list<Window *> Windows; Windows window_children; @@ -27,6 +34,12 @@ protected: virtual void add_window(Window *window); virtual void remove_window(Window *window); + + /// label of the previous window that got activated + /** This label is used to implement the 'menu previous' + * command + */ + std::string window_previous; }; } |