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.157 by root, Tue Jun 26 05:06:01 2007 UTC vs.
Revision 1.167 by root, Fri Jul 13 05:31:32 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3my $startup_done = sub { }; 3my $startup_done = sub { };
4our $PANGO = "1.5.0";
4 5
5# do splash-screen thingy on win32 6# do splash-screen thingy on win32
6BEGIN { 7BEGIN {
7 if (%PAR::LibCache && $^O eq "MSWin32") { 8 if (%PAR::LibCache && $^O eq "MSWin32") {
8 while (my ($filename, $zip) = each %PAR::LibCache) { 9 while (my ($filename, $zip) = each %PAR::LibCache) {
43 44
44 if ($^O eq "MSWin32") { 45 if ($^O eq "MSWin32") {
45 # relocatable 46 # relocatable
46 } else { 47 } else {
47 # unix, need to patch pango rc file 48 # unix, need to patch pango rc file
48 open my $fh, "<:perlio", "$tmp/usr/lib/pango/1.5.0/module-files.d/libpango1.0-0.modules" 49 open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules"
49 or die "$tmp/usr/lib/1.5.0/module-files.d/libpango1.0-0.modules: $!"; 50 or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!";
50 local $/; 51 local $/;
51 my $rc = <$fh>; 52 my $rc = <$fh>;
52 $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones 53 $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones
53 54
54 mkdir "$tmp/pango-modules"; 55 mkdir "$tmp/pango-modules";
158 159
159our $SDL_ACTIVE; 160our $SDL_ACTIVE;
160our %SDL_CB; 161our %SDL_CB;
161 162
162our $SDL_MIXER; 163our $SDL_MIXER;
164our $MUSIC_DEFAULT = "in_a_heartbeat.ogg";
165our @MUSIC_WANT;
166our $MUSIC_PLAYING;
167our $MUSIC_PLAYER;
163our @SOUNDS; # event => file mapping 168our @SOUNDS; # event => file mapping
164our %AUDIO_CHUNKS; # audio files 169our %AUDIO_CHUNKS; # audio files
165 170
166our $ALT_ENTER_MESSAGE; 171our $ALT_ENTER_MESSAGE;
167our $STATUSBOX; 172our $STATUSBOX;
497 $SETUP_DIALOG->show; 502 $SETUP_DIALOG->show;
498 $PL_WINDOW->hide; 503 $PL_WINDOW->hide;
499 $SPELL_LIST->clear_spells; 504 $SPELL_LIST->clear_spells;
500 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); 505 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN);
501 506
507 &audio_music_set ([]);
508
502 return unless $CONN; 509 return unless $CONN;
503 510
504 status "connection closed"; 511 status "connection closed";
505 512
506 destroy_query_dialog $CONN; 513 destroy_query_dialog $CONN;
746 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 753 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
747 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); 754 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS");
748 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); 755 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
749 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 756 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips");
750 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 757 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
751 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { die "violator" } ); 758 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } );
752 759
753 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); 760 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
754 761
755 for my $x (0..2) { 762 for my $x (0..2) {
756 for my $y (0 .. 2) { 763 for my $y (0 .. 2) {
2001 CFPlus::OpenGL::shutdown; 2008 CFPlus::OpenGL::shutdown;
2002 2009
2003 undef $SDL_ACTIVE; 2010 undef $SDL_ACTIVE;
2004} 2011}
2005 2012
2006my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
2007my $bgmusic;#TODO#hack#d#
2008
2009sub audio_channel_finished { 2013sub audio_channel_finished {
2010 my ($channel) = @_; 2014 my ($channel) = @_;
2011 2015
2012 #warn "channel $channel finished\n";#d# 2016 #warn "channel $channel finished\n";#d#
2013} 2017}
2014 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
2015sub audio_music_finished { 2067sub audio_music_finished {
2016 return unless $CFG->{bgm_enable}; 2068 $MUSIC_PLAYING = undef;
2069 undef $MUSIC_PLAYER;
2017 2070
2018 # TODO: hack, do play loop and mood music 2071 audio_music_changed;
2019 $bgmusic = new_from_file CFPlus::MixMusic CFPlus::find_rcfile "music/$bgmusic[0]";
2020 $bgmusic->play (0);
2021
2022 push @bgmusic, shift @bgmusic;
2023} 2072}
2024 2073
2025sub audio_init { 2074sub audio_init {
2026 if ($CFG->{audio_enable}) { 2075 if ($CFG->{audio_enable}) {
2027 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