… | |
… | |
178 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
178 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
179 | $CFG->{bgm_enable} = $_[1]; |
179 | $CFG->{bgm_enable} = $_[1]; |
180 | }); |
180 | }); |
181 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
181 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
182 | $CFG->{bgm_volume} = $_[1]; |
182 | $CFG->{bgm_volume} = $_[1]; |
183 | CFClient::Mix_VolumeMusic ($_[1]); |
183 | CFClient::MixMusic::volume $_[1] * 128; |
184 | }); |
184 | }); |
185 | |
185 | |
186 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
186 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
187 | audio_shutdown (); |
187 | audio_shutdown (); |
188 | audio_init (); |
188 | audio_init (); |
… | |
… | |
468 | if ($CFG->{audio_enable}) { |
468 | if ($CFG->{audio_enable}) { |
469 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
469 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
470 | |
470 | |
471 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
471 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
472 | CFClient::Mix_AllocateChannels 8; |
472 | CFClient::Mix_AllocateChannels 8; |
473 | CFClient::MixMusic::volume $CFG->{bgm_volume}; |
473 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
474 | |
474 | |
475 | # TODO: hack, do play loop and mood music |
475 | # TODO: hack, do play loop and mood music |
476 | if ($CFG->{bgm_enable}) { |
476 | if ($CFG->{bgm_enable}) { |
477 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg"; |
477 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg"; |
478 | $bgmusic->play; |
478 | $bgmusic->play; |
… | |
… | |
880 | mapsize => 100, |
880 | mapsize => 100, |
881 | host => "crossfire.schmorp.de", |
881 | host => "crossfire.schmorp.de", |
882 | say_command => 'say', |
882 | say_command => 'say', |
883 | audio_enable => 1, |
883 | audio_enable => 1, |
884 | bgm_enable => 1, |
884 | bgm_enable => 1, |
885 | bgm_volume => 64, |
885 | bgm_volume => 0.25, |
886 | ); |
886 | ); |
887 | |
887 | |
888 | while (my ($k, $v) = each %DEF_CFG) { |
888 | while (my ($k, $v) = each %DEF_CFG) { |
889 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
889 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
890 | } |
890 | } |