From 4a2bad92171ff8a9a248599f47087cfe39e93653 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 18 May 2008 09:21:20 +0000 Subject: OpenAL support --- src/client/client.cc | 39 ++++++++++++++++----------------------- src/client/client.h | 25 +++++++++++++++++++++++++ src/client/console.cc | 4 ++-- src/client/console.h | 2 +- src/client/view.cc | 6 +++--- 5 files changed, 47 insertions(+), 29 deletions(-) (limited to 'src/client') diff --git a/src/client/client.cc b/src/client/client.cc index 85dec27..ed31c65 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -10,6 +10,7 @@ #include #include +#include "audio/audio.h" #include "client/chat.h" #include "client/client.h" #include "client/video.h" @@ -23,26 +24,6 @@ namespace client { core::Cvar *cl_framerate = 0; - -//--- private definition ------------------------------------------ - -/// client application implementation -class Client : public core::Application -{ -public: - /// initialize the client Client - virtual void init(int count, char **arguments); - - /// run the client Client - virtual void run(); - - /// shutdown the client Client - virtual void shutdown(); - - /// quit the client Client - virtual void quit(int status); -}; - Client app; //--- engine functions -------------------------------------------- @@ -71,6 +52,11 @@ void client_main(int count, char **arguments) app.shutdown(); } +Client *client() +{ + return &app; +} + //--- private ----------------------------------------------------- void Client::quit(int status) @@ -112,6 +98,9 @@ void Client::init(int count, char **arguments) // initialize input input::init(); + + // initialize audio + audio::init(); // add engine functions core::Func *func = 0; @@ -147,8 +136,6 @@ void Client::run() } }; - //con_debug << "tick " << std::setw(8) << chrono << " " << std::setw(8) << current << " " << elapsed; - } } @@ -157,11 +144,12 @@ void Client::shutdown() { con_print << "^BShutting down client..." << std::endl; - // remove engine functions core::Func::remove("r_restart"); chat::shutdown(); + audio::shutdown(); + Console::shutdown(); input::shutdown(); @@ -173,5 +161,10 @@ void Client::shutdown() quit(0); } +void Client::notify_sound(const char * name) +{ + audio::play(name); +} + } // namespace client diff --git a/src/client/client.h b/src/client/client.h index b1a50df..57488ec 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -7,12 +7,37 @@ #ifndef __INCLUDED_CLIENT_H__ #define __INCLUDED_CLIENT_H__ +#include "core/application.h" + /// client part of the engine namespace client { +/// client application implementation +class Client : public core::Application +{ +public: + /// initialize the client + virtual void init(int count, char **arguments); + + /// run the client + virtual void run(); + + /// shutdown the client + virtual void shutdown(); + + /// quit the client + virtual void quit(int status); + + /// sound notifications from the core to the application + virtual void notify_sound(const char * name); +}; + + /// the client main loop void client_main(int count, char **arguments); +Client *client(); + } #endif // __INCLUDED_CLIENT_H__ diff --git a/src/client/console.cc b/src/client/console.cc index f692db4..ac977f2 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -245,9 +245,9 @@ void Console::draw_notify() Text::setcolor('N'); size_t width = (size_t) ((video::width-8) / Text::fontwidth()); size_t n = notify_pos % MAXNOTIFYLINES; - float h = 4 + 2*Text::fontheight(); + float h = video::height/2; for (size_t l = 0; l < MAXNOTIFYLINES; l++) { - if (notify_text[n].size() > 2 && notify_time[n] + 4 > core::application()->time()) { + if (notify_text[n].size() > 2 && notify_time[n] + 5 > core::application()->time()) { std::string linedata(notify_text[n]); linedata += '\n'; diff --git a/src/client/console.h b/src/client/console.h index 2f8d6a0..5bdbde6 100644 --- a/src/client/console.h +++ b/src/client/console.h @@ -11,7 +11,7 @@ namespace client { -const size_t MAXNOTIFYLINES = 3; +const size_t MAXNOTIFYLINES = 5; const size_t MAXHISTOLINES = 512; /// client console implementation diff --git a/src/client/view.cc b/src/client/view.cc index e2c8687..5c12710 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -138,8 +138,8 @@ void draw_status() int minutes = (int) floorf(core::game()->clientframetime() / 60.0f); int seconds = (int) floorf( core::game()->clientframetime() - (float) minutes* 60.0f); - status << "^Ntime ^B" << std::setfill('0') << std::setw(2) << minutes << "^N:^B" << std::setfill('0') << std::setw(2) << seconds; - Text::draw(4, 4, status); + status << "^Ntime ^B" << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds; + Text::draw(video::width-Text::fontwidth()*11-4, 4+Text::fontheight(), status); } // print stats if desired @@ -152,7 +152,7 @@ void draw_status() } stats << "^Ntx ^B"<< std::setw(5) << (core::Stats::network_bytes_sent >> 10) << "\n"; stats << "^Nrx ^B"<< std::setw(5) << (core::Stats::network_bytes_received >> 10) << "\n"; - Text::draw(video::width-Text::fontwidth()*12, video::height - Text::fontheight()*8, stats); + Text::draw(video::width-Text::fontwidth()*11-4, 4 + Text::fontheight()*3, stats); } // draw a basic HUD -- cgit v1.2.3