… | |
… | |
170 | video_shutdown (); |
170 | video_shutdown (); |
171 | video_init (); |
171 | video_init (); |
172 | }); |
172 | }); |
173 | |
173 | |
174 | $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); |
174 | $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); |
175 | $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{sound}, connect_changed => sub { |
175 | $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
176 | my ($self, $value) = @_; |
176 | my ($self, $value) = @_; |
177 | $CFG->{sound} = $value; |
177 | $CFG->{audio_enable} = $value; |
178 | }); |
178 | }); |
179 | $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); |
179 | $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); |
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bg_music_enable}, connect_changed => sub { |
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bgm_enable}, connect_changed => sub { |
181 | my ($self, $value) = @_; |
181 | my ($self, $value) = @_; |
182 | $CFG->{bg_music_enable} = $value; |
182 | $CFG->{bgm_enable} = $value; |
183 | }); |
183 | }); |
184 | $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
184 | $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
185 | audio_shutdown (); |
185 | audio_shutdown (); |
186 | audio_init (); |
186 | audio_init (); |
187 | }); |
187 | }); |
… | |
… | |
484 | } |
484 | } |
485 | |
485 | |
486 | my $bgmusic;#TODO#hack#d# |
486 | my $bgmusic;#TODO#hack#d# |
487 | |
487 | |
488 | sub audio_init { |
488 | sub audio_init { |
489 | if ($CFG->{sound} || 1) { |
489 | if ($CFG->{audio_enable}) { |
490 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
490 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
491 | $SDL_MIXER = new SDL::Mixer; |
491 | $SDL_MIXER = new SDL::Mixer; |
492 | $SDL_MIXER->allocate_channels (8); |
492 | $SDL_MIXER->allocate_channels (8); |
493 | |
493 | |
|
|
494 | # TODO: hack, do play loop and mood music |
494 | if ($CFG->{bg_music_enable}) { |
495 | if ($CFG->{bgm_enable}) { |
495 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
496 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
496 | $SDL_MIXER->play_music ($bgmusic, -1); |
497 | $SDL_MIXER->play_music ($bgmusic, -1); |
497 | } |
498 | } |
498 | |
499 | |
499 | while (<$fh>) { |
500 | while (<$fh>) { |
… | |
… | |
772 | }; |
773 | }; |
773 | } |
774 | } |
774 | |
775 | |
775 | sub conn::sound_play { |
776 | sub conn::sound_play { |
776 | my ($self, $x, $y, $soundnum, $type) = @_; |
777 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
778 | |
|
|
779 | $SDL_MIXER |
|
|
780 | or return; |
777 | |
781 | |
778 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
782 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
779 | or return; |
783 | or return; |
780 | |
784 | |
781 | $SDL_MIXER->play_channel (-1, $chunk); |
785 | $SDL_MIXER->play_channel (-1, $chunk); |
… | |
… | |
867 | fow_smooth => 0, |
871 | fow_smooth => 0, |
868 | log_fontsize => 14, |
872 | log_fontsize => 14, |
869 | mapsize => 100, |
873 | mapsize => 100, |
870 | host => "crossfire.schmorp.de", |
874 | host => "crossfire.schmorp.de", |
871 | say_command => 'say', |
875 | say_command => 'say', |
872 | sound => 1, |
876 | audio_enable => 1, |
873 | bg_music_enable => 1, |
877 | bgm_enable => 1, |
874 | ); |
878 | ); |
875 | |
879 | |
876 | while (my ($k, $v) = each %DEF_CFG) { |
880 | while (my ($k, $v) = each %DEF_CFG) { |
877 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
881 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
878 | } |
882 | } |