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.159 by root, Thu Jul 5 06:49:10 2007 UTC vs.
Revision 1.167 by root, Fri Jul 13 05:31:32 2007 UTC

159 159
160our $SDL_ACTIVE; 160our $SDL_ACTIVE;
161our %SDL_CB; 161our %SDL_CB;
162 162
163our $SDL_MIXER; 163our $SDL_MIXER;
164our $MUSIC_DEFAULT = "in_a_heartbeat.ogg";
165our @MUSIC_WANT;
166our $MUSIC_PLAYING;
167our $MUSIC_PLAYER;
164our @SOUNDS; # event => file mapping 168our @SOUNDS; # event => file mapping
165our %AUDIO_CHUNKS; # audio files 169our %AUDIO_CHUNKS; # audio files
166 170
167our $ALT_ENTER_MESSAGE; 171our $ALT_ENTER_MESSAGE;
168our $STATUSBOX; 172our $STATUSBOX;
497 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 501 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
498 $SETUP_DIALOG->show; 502 $SETUP_DIALOG->show;
499 $PL_WINDOW->hide; 503 $PL_WINDOW->hide;
500 $SPELL_LIST->clear_spells; 504 $SPELL_LIST->clear_spells;
501 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); 505 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN);
506
507 &audio_music_set ([]);
502 508
503 return unless $CONN; 509 return unless $CONN;
504 510
505 status "connection closed"; 511 status "connection closed";
506 512
2002 CFPlus::OpenGL::shutdown; 2008 CFPlus::OpenGL::shutdown;
2003 2009
2004 undef $SDL_ACTIVE; 2010 undef $SDL_ACTIVE;
2005} 2011}
2006 2012
2007my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
2008my $bgmusic;#TODO#hack#d#
2009
2010sub audio_channel_finished { 2013sub audio_channel_finished {
2011 my ($channel) = @_; 2014 my ($channel) = @_;
2012 2015
2013 #warn "channel $channel finished\n";#d# 2016 #warn "channel $channel finished\n";#d#
2014} 2017}
2015 2018
2019sub audio_music_set {
2020 my ($songs) = @_;
2021
2022 my $count = @$songs;
2023 my @meta;
2024
2025 for my $name (@$songs) {
2026 CFPlus::DB::get "res-metadata" => $name, sub {
2027 my ($data) = @_;
2028
2029 if ($data) {
2030 $data = JSON::XS->new->utf8->decode ($data);
2031 $data->{path} = CFPlus::DB::path_of $name;
2032 push @meta, $data;
2033 }
2034
2035 unless (--$count) {
2036 if (@meta) {
2037 @MUSIC_WANT = @meta;
2038 &audio_music_changed ();
2039 }
2040 }
2041 };
2042 }
2043}
2044
2045sub audio_music_changed {
2046 return unless $CFG->{bgm_enable};
2047
2048 # default MUSIC_WANT == MUSIC_DEFAULT
2049 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT;
2050
2051 # if the currently playing song is acceptable, let it continue
2052 return if $MUSIC_PLAYING
2053 && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT;
2054
2055 if ($MUSIC_PLAYING) {
2056 CFPlus::MixMusic::fade_out 1000;
2057 } else {
2058 my $music = $MUSIC_WANT [rand @MUSIC_WANT];
2059
2060 $MUSIC_PLAYING = $music;
2061
2062 $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path};
2063 $MUSIC_PLAYER->play (0);
2064 }
2065}
2066
2016sub audio_music_finished { 2067sub audio_music_finished {
2017 return unless $CFG->{bgm_enable}; 2068 $MUSIC_PLAYING = undef;
2069 undef $MUSIC_PLAYER;
2018 2070
2019 # TODO: hack, do play loop and mood music 2071 audio_music_changed;
2020 $bgmusic = new_from_file CFPlus::MixMusic CFPlus::find_rcfile "music/$bgmusic[0]";
2021 $bgmusic->play (0);
2022
2023 push @bgmusic, shift @bgmusic;
2024} 2072}
2025 2073
2026sub audio_init { 2074sub audio_init {
2027 if ($CFG->{audio_enable}) { 2075 if ($CFG->{audio_enable}) {
2028 if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") { 2076 if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines