ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.197 by root, Tue Jul 31 02:25:52 2007 UTC vs.
Revision 1.198 by root, Tue Jul 31 02:45:39 2007 UTC

159our $STATWIDS; 159our $STATWIDS;
160 160
161our $SDL_ACTIVE; 161our $SDL_ACTIVE;
162our %SDL_CB; 162our %SDL_CB;
163 163
164our $ALT_ENTER_MESSAGE;
165our $STATUSBOX;
166our $DEBUG_STATUS;
167
168our $INV;
169our $INVR;
170our $INV_RIGHT_HB;
171
172our $PICKUP_CFG;
173
174#############################################################################
175
176sub status {
177 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
178}
179
180sub debug {
181 $DEBUG_STATUS->set_text ($_[0]);
182}
183
184sub message {
185 my ($para) = @_;
186 $MESSAGE_WINDOW->message ($para);
187}
188
189#############################################################################
190#TODO: maybe move into own audio module...
191
164our $SDL_MIXER; 192our $SDL_MIXER;
193
165our $MUSIC_DEFAULT = "in_a_heartbeat.ogg"; 194our $MUSIC_DEFAULT = "in_a_heartbeat.ogg";
166our $MUSIC_WANT; # arryref of ambient music 195our $MUSIC_WANT; # arryref of ambient music we want to play
167our @MUSIC_HAVE; # ambient music we want now 196our @MUSIC_HAVE; # ambient music we have on disk
168our $MUSIC_START; 197our $MUSIC_START;
169our @MUSIC_JINGLE; # which jingles to play 198our @MUSIC_JINGLE; # which jingles to play next
170our $MUSIC_PLAYING_DATA; 199our $MUSIC_PLAYING_DATA;
171our $MUSIC_PLAYING_META; 200our $MUSIC_PLAYING_META;
172our $MUSIC_PLAYER; 201our $MUSIC_PLAYER;
173our $MUSIC_RESUME = 30; # resume music when players less than these many seconds before 202our $MUSIC_RESUME = 30; # resume music when played less than these many seconds before
174our @SOUNDS; # event => file mapping 203
175our %AUDIO_CHUNK; # audio files 204our %AUDIO_CHUNK; # audio "files"
176 205our %AUDIO_PLAY; # which audio faces should be played
177our $ALT_ENTER_MESSAGE;
178our $STATUSBOX;
179our $DEBUG_STATUS;
180
181our $INV;
182our $INVR;
183our $INV_RIGHT_HB;
184
185our $PICKUP_CFG;
186
187#############################################################################
188#TODO: maybe move into own audio module...
189 206
190sub audio_channel_finished { 207sub audio_channel_finished {
191 my ($channel) = @_; 208 my ($channel) = @_;
192 209
193# warn "channel $channel finished\n";#d# 210# warn "channel $channel finished\n";#d#
194} 211}
195
196our %AUDIO_PLAY;
197our %AUDIO_CHUNK;
198 212
199sub audio_sound_push($) { 213sub audio_sound_push($) {
200 my ($face) = @_; 214 my ($face) = @_;
201 215
202 if (my $chunk = $AUDIO_CHUNK{$face}) { 216 if (my $chunk = $AUDIO_CHUNK{$face}) {
219 my $meta = $CONN->{sound_meta}{$face} 233 my $meta = $CONN->{sound_meta}{$face}
220 or return; 234 or return;
221 235
222 # if its a jingle, play it as ambient music 236 # if its a jingle, play it as ambient music
223 if ($meta->{meta}{jingle}) { 237 if ($meta->{meta}{jingle}) {
224 push @MUSIC_JINGLE, $meta; 238 delete $AUDIO_PLAY{$face}; # take the jingle out of the sound queue
225 delete $AUDIO_PLAY{$face}; 239 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
226 &audio_music_push ($face); 240 &audio_music_push ($face);
227 } else { 241 } else {
228 # fetch from database 242 # fetch from database
229 CFPlus::DB::get res_data => $meta->{name}, sub { 243 CFPlus::DB::get res_data => $meta->{name}, sub {
230 my $rwops = new CFPlus::RW $_[0]; 244 my $rwops = new CFPlus::RW $_[0];
349 $MUSIC_WANT = $songs; 363 $MUSIC_WANT = $songs;
350 audio_music_push; 364 audio_music_push;
351} 365}
352 366
353sub audio_music_finished { 367sub audio_music_finished {
368 # we compress multiple jingles of the same type
354 shift @MUSIC_JINGLE 369 shift @MUSIC_JINGLE
355 if $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; 370 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0];
356 371
357 undef $MUSIC_PLAYER; 372 undef $MUSIC_PLAYER;
358 undef $MUSIC_PLAYING_META; 373 undef $MUSIC_PLAYING_META;
359 undef $MUSIC_PLAYING_DATA; 374 undef $MUSIC_PLAYING_DATA;
360 375
361 audio_music_push; 376 audio_music_push;
362} 377}
363 378
379sub audio_init {
380 if ($CFG->{audio_enable}) {
381 $ENV{MIX_EFFECTSMAXSPEED} = 1;
382 $SDL_MIXER = !CFPlus::Mix_OpenAudio;
383
384 unless ($SDL_MIXER) {
385 status "Unable to open sound device: there will be no sound";
386 return;
387 }
388
389 CFPlus::Mix_AllocateChannels 16;
390
391 audio_music_finished;
392 } else {
393 undef $SDL_MIXER;
394 }
395}
396
397sub audio_shutdown {
398 undef $MUSIC_PLAYER;
399 undef $MUSIC_PLAYING_META;
400 undef $MUSIC_PLAYING_DATA;
401
402 $MUSIC_WANT = [];
403 @MUSIC_JINGLE = ();
404 %AUDIO_PLAY = ();
405 %AUDIO_CHUNK = ();
406
407 CFPlus::Mix_CloseAudio if $SDL_MIXER;
408 undef $SDL_MIXER;
409}
410
364############################################################################# 411#############################################################################
365
366sub status {
367 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
368}
369
370sub debug {
371 $DEBUG_STATUS->set_text ($_[0]);
372}
373
374sub message {
375 my ($para) = @_;
376 $MESSAGE_WINDOW->message ($para);
377}
378 412
379sub destroy_query_dialog { 413sub destroy_query_dialog {
380 (delete $_[0]{query_dialog})->destroy 414 (delete $_[0]{query_dialog})->destroy
381 if $_[0]{query_dialog}; 415 if $_[0]{query_dialog};
382} 416}
1966 2000
1967sub video_shutdown { 2001sub video_shutdown {
1968 CFPlus::OpenGL::shutdown; 2002 CFPlus::OpenGL::shutdown;
1969 2003
1970 undef $SDL_ACTIVE; 2004 undef $SDL_ACTIVE;
1971}
1972
1973sub audio_init {
1974 if ($CFG->{audio_enable}) {
1975 $ENV{MIX_EFFECTSMAXSPEED} = 1;
1976 $SDL_MIXER = !CFPlus::Mix_OpenAudio;
1977
1978 unless ($SDL_MIXER) {
1979 status "Unable to open sound device: there will be no sound";
1980 return;
1981 }
1982
1983 CFPlus::Mix_AllocateChannels 16;
1984
1985 audio_music_finished;
1986 } else {
1987 undef $SDL_MIXER;
1988 }
1989}
1990
1991sub audio_shutdown {
1992 CFPlus::Mix_CloseAudio if $SDL_MIXER;
1993 undef $SDL_MIXER;
1994 @SOUNDS = ();
1995 %AUDIO_CHUNK = ();
1996} 2005}
1997 2006
1998my %animate_object; 2007my %animate_object;
1999my $animate_timer; 2008my $animate_timer;
2000 2009

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines