From 381c729e777b50771626703e60b422aafc791513 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 29 Sep 2008 18:01:35 +0000 Subject: adds introduction screen to the client --- osirion.kdevelop | 2 +- src/client/client.cc | 3 --- src/client/view.cc | 48 +++++++++++++++++++++++++++++++++++++++++++--- src/core/application.cc | 37 ++++++++++++++++++++++++++--------- src/core/application.h | 7 +++++++ src/core/gameconnection.h | 4 ++++ src/core/gameinterface.h | 3 +++ src/core/gameserver.cc | 11 ++++++++++- src/core/gameserver.h | 3 +++ src/core/module.cc | 1 + src/core/module.h | 4 ++++ src/game/base/jumppoint.cc | 2 +- src/game/game.cc | 7 +++++-- src/game/game.h | 2 +- src/game/intro/intro.cc | 4 ++++ 15 files changed, 117 insertions(+), 21 deletions(-) diff --git a/osirion.kdevelop b/osirion.kdevelop index 4afbfd0..39c38aa 100644 --- a/osirion.kdevelop +++ b/osirion.kdevelop @@ -21,7 +21,7 @@ - src/core/libcore.la + src/game/intro/libintro.la debug diff --git a/src/client/client.cc b/src/client/client.cc index a8d4ca8..ca88f88 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -246,9 +246,6 @@ void Client::notify_message(core::Message::Channel const channel, std::string co void Client::notify_zoneclear(core::Zone *zone) { - if (!zone) - return; - view::clear_zone(zone); } diff --git a/src/client/view.cc b/src/client/view.cc index bbf9088..03ce42b 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -84,6 +84,11 @@ void 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); @@ -125,6 +130,28 @@ void draw_loader() gl::end(); } +void draw_banner() +{ + using namespace render; + + render::Textures::bind("bitmaps/banner"); + + gl::begin(gl::Quads); + + glTexCoord2f(0.0f, 0.0f); + gl::vertex(0,0, 0); + + glTexCoord2f(1.0f, 0.0f); + gl::vertex(video::width,0,0); + + glTexCoord2f(1.0f, 1.0f); + gl::vertex(video::width,video::height,0); + + glTexCoord2f(0.0f, 1.0f); + gl::vertex(0,video::height,0); + + gl::end(); +} /* FIXME should be merged with the render passes @@ -349,7 +376,7 @@ void draw_status() std::stringstream status; - if (core::game()) { + if (core::game() && core::game()->interactive()) { int minutes = (int) floorf(core::game()->clientframetime() / 60.0f); int seconds = (int) floorf( core::game()->clientframetime() - (float) minutes* 60.0f); @@ -740,6 +767,16 @@ void frame(float seconds) render::Stats::clear(); + // load the intro + if (!core::application()->connected()) { + if (core::application()->load("intro")) { + current_zone = 0; + core::application()->connect(""); + if (!console()->visible()) + console()->toggle(); + } + } + if (core::application()->connected() && core::game()->serverframetime()) { if (core::localplayer()->zone() != current_zone) { @@ -754,6 +791,8 @@ void frame(float seconds) if (targets::current()) // draw target docks etc draw_entity_world_target(targets::current()); } else { + // FIXME this should be handle through a module_disconnect signal + // this should to the same as calling clear_zone(0) current_zone = 0; } @@ -765,6 +804,7 @@ void frame(float seconds) gl::matrixmode(GL_MODELVIEW); gl::loadidentity(); + gl::enable(GL_BLEND); gl::enable(GL_TEXTURE_2D); gl::color(1.0f, 1.0f, 1.0f, 1.0f); @@ -776,9 +816,11 @@ void frame(float seconds) // force console on if not connected if (!console()->visible()) console()->toggle(); - } - gl::enable(GL_BLEND); + } else if (!core::game()->interactive()) { + // draw the banner bitmap + draw_banner(); + } // draw text elements if (draw_ui->value()) { diff --git a/src/core/application.cc b/src/core/application.cc index 2b3f41f..c02db9b 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -98,15 +98,9 @@ void func_load(std::string const &args) return; } - if (game()) { - con_warn << "Connected. Disconnect first.\n"; - return; - } - std::string name(args); aux::to_label(name); - - Module::load(name.c_str()); + application()->load(name); } // --------------- signal_handler ----------------------------------- @@ -156,6 +150,8 @@ Application::Application() application_time = 0; application_game = 0; + module_interactive = 0; + #ifndef _WIN32 sys::signal(SIGHUP, signal_handler); sys::signal(SIGINT, signal_handler); @@ -312,11 +308,33 @@ void Application::quit(int status) } +Module *Application::load(std::string const &module_name) +{ + if (game()) { + con_warn << "Connected. Disconnect first.\n"; + return 0; + } + + if (Module::current() && Module::current()->interactive()) { + module_interactive = Module::current(); + } + return Module::load(module_name.c_str()); +} + void Application::connect(std::string const &host) { if (connected()) { - con_warn << "Connected. Disconnect first.\n"; - return; + if (!Module::current()->interactive() && module_interactive) { + /* if the current running module is non-interactive, + disconnect, and load the last interactive module_interactive + */ + disconnect(); + Module::load(module_interactive->label().c_str()); + + } else { + con_warn << "Connected. Disconnect first.\n"; + return; + } } if (application_game) { @@ -350,6 +368,7 @@ void Application::disconnect() notify_disconnect(); delete application_game; application_game = 0; + notify_zoneclear(0); con_print << "^BDisconnected.\n"; } } diff --git a/src/core/application.h b/src/core/application.h index 0dfa652..3769941 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -13,6 +13,7 @@ #include "core/netserver.h" #include "core/netconnection.h" #include "core/gameinterface.h" +#include "core/module.h" namespace core { @@ -46,6 +47,9 @@ public: /// disconnect from the game module void disconnect(); + /// load a module + Module *load(std::string const &module_name); + /*----- virtual mutators ------------------------------------------ */ /// initialize the application @@ -100,6 +104,9 @@ private: float application_time; GameInterface *application_game; static Application *application_instance; + + /// last loaded interactive module + Module *module_interactive; }; /// pointer to the current Application diff --git a/src/core/gameconnection.h b/src/core/gameconnection.h index ecf50f2..973d96f 100644 --- a/src/core/gameconnection.h +++ b/src/core/gameconnection.h @@ -28,6 +28,10 @@ public: /// returns true if the game connection can not run a time frime inline bool error() { return !connection_running; } + /// returns true if the game is running an interactive module + inline bool interactive() { return true; } + + /*----- mutators -------------------------------------------------- */ /// run a game connection time frame diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index 69cd588..b6d7cb6 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -54,6 +54,9 @@ public: /// returns true if the game server can run a time frime virtual bool running() = 0; + /// returns true if the game is running an interactive module + virtual bool interactive() = 0; + /*----- mutators ------------------------------------------------- */ /// clear all game variables, game functions and entities diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 70786af..4037c70 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -135,7 +135,7 @@ GameServer::GameServer() : GameInterface() con_print << " module '^B" << server_module->name() << "^N'\n"; - if ((Cvar::sv_dedicated->value() || Cvar::sv_private->value())) { + if (server_module->interactive() && (Cvar::sv_dedicated->value() || Cvar::sv_private->value())) { server_network = new NetServer(Cvar::net_host->str(), (unsigned int) Cvar::net_port->value()); if (!server_network->valid()) { delete server_network; @@ -220,6 +220,15 @@ void GameServer::abort() server_running = false; } +bool GameServer::interactive() +{ + if (!server_module) { + return false; + } else { + return server_module->interactive(); + } +} + void GameServer::showtime() { using namespace std; diff --git a/src/core/gameserver.h b/src/core/gameserver.h index b25f1a0..0dfdd9d 100644 --- a/src/core/gameserver.h +++ b/src/core/gameserver.h @@ -33,6 +33,9 @@ public: /// returns true if the game server can not run a time frime inline bool error() { return !server_running; } + /// returns true if the game is running an interactive module + bool interactive(); + /// show the current time void showtime(); diff --git a/src/core/module.cc b/src/core/module.cc index 29c9eb8..ae78260 100644 --- a/src/core/module.cc +++ b/src/core/module.cc @@ -76,6 +76,7 @@ Module::Module(const char *name) : module_name(name) { module_running = false; + module_interactive = true; } Module::~Module() diff --git a/src/core/module.h b/src/core/module.h index b46c296..20029cf 100644 --- a/src/core/module.h +++ b/src/core/module.h @@ -33,6 +33,9 @@ public: /// label of the module inline std::string const & label() const { return module_label; } + /// indicates if this is an interactive module or not + inline bool interactive() const { return module_interactive; } + /*----- mutators -------------------------------------------------- */ /// initialize the game module @@ -80,6 +83,7 @@ protected: void abort(); bool module_running; + bool module_interactive; private: std::string module_name; diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc index bcaf8c5..da221cf 100644 --- a/src/game/base/jumppoint.cc +++ b/src/game/base/jumppoint.cc @@ -10,7 +10,7 @@ namespace base { -JumpPoint::JumpPoint() : core::Entity(core::Entity::Static) +JumpPoint::JumpPoint() : core::Entity(core::Entity::Static | core::Entity::Bright) { entity_shape = core::Entity::Diamond; entity_color.assign(0.0f, 0.8f, 0.8f, 1.0f); diff --git a/src/game/game.cc b/src/game/game.cc index 5e7c826..7e89a0d 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -14,12 +14,15 @@ namespace game { /// register game modules -void register_modules(bool register_client_modules) +void register_modules(bool register_noninteractive_modules) { con_print << "^BRegistering game modules..." << std::endl; + + // non-interactive modules core::Module::add("base", new base::Base()); - if (register_client_modules) { + // interactive modules + if (register_noninteractive_modules) { core::Module::add("intro", new intro::Intro()); } } diff --git a/src/game/game.h b/src/game/game.h index 544f26b..236299b 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -9,7 +9,7 @@ namespace game { - void register_modules(bool register_client_modules=false); + void register_modules(bool register_noninteractive_modules=false); } #endif // __INCLUDED_GAME_H__ diff --git a/src/game/intro/intro.cc b/src/game/intro/intro.cc index f5b4e2f..4ad183f 100644 --- a/src/game/intro/intro.cc +++ b/src/game/intro/intro.cc @@ -16,6 +16,7 @@ namespace intro { Intro::Intro() : core::Module("Introduction") { + module_interactive = false; intro_zone = 0; intro_convoy = 0; } @@ -95,6 +96,9 @@ bool Intro::load_world() } else if (ini.got_section("intro")) { continue; + } else if (ini.got_section("convoy")) { + continue; + } else if (ini.got_section("globe")) { globe = new core::EntityGlobe(); globe->set_zone(intro_zone); -- cgit v1.2.3