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.162 by root, Thu Jul 5 07:06:05 2007 UTC vs.
Revision 1.163 by root, Thu Jul 12 17:56:51 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;
2002 CFPlus::OpenGL::shutdown; 2006 CFPlus::OpenGL::shutdown;
2003 2007
2004 undef $SDL_ACTIVE; 2008 undef $SDL_ACTIVE;
2005} 2009}
2006 2010
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 { 2011sub audio_channel_finished {
2011 my ($channel) = @_; 2012 my ($channel) = @_;
2012 2013
2013 #warn "channel $channel finished\n";#d# 2014 #warn "channel $channel finished\n";#d#
2014} 2015}
2015 2016
2017sub audio_music_set {
2018 my ($songs) = @_;
2019
2020 my $count = @$songs;
2021 my @meta;
2022
2023 for my $name (@$songs) {
2024 CFPlus::DB::get resmap => $name, sub {
2025 my ($data) = @_;
2026
2027 if ($data) {
2028 $data = JSON::XS->new->utf8->decode ($data);
2029 $data->{path} = CFPlus::DB::path_of $name;
2030 push @meta, $data;
2031 }
2032
2033 unless (--$count) {
2034 if (@meta) {
2035 @MUSIC_WANT = @meta;
2036 &audio_music_changed ();
2037 }
2038 }
2039 };
2040 }
2041}
2042
2043sub audio_music_changed {
2044 return unless $CFG->{bgm_enable};
2045
2046 # default MUSIC_WANT, undef/0 == MUSIC_DEFAULT
2047 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT;
2048
2049 # if the currently playing song is acceptable, let it continue
2050 return if grep $MUSIC_PLAYING eq $_->{path}, @MUSIC_WANT;
2051
2052 if (defined $MUSIC_PLAYING) {
2053 warn "fade out";
2054 CFPlus::MixMusic::fade_out 2000;
2055 } else {
2056 warn "new music\n";
2057
2058 my $music = $MUSIC_WANT [rand @MUSIC_WANT];
2059
2060 $MUSIC_PLAYING = $music->{path};
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