… | |
… | |
248 | } else { |
248 | } else { |
249 | # fetch from database |
249 | # fetch from database |
250 | CFPlus::DB::get res_data => $meta->{name}, sub { |
250 | CFPlus::DB::get res_data => $meta->{name}, sub { |
251 | my $rwops = new CFPlus::RW $_[0]; |
251 | my $rwops = new CFPlus::RW $_[0]; |
252 | my $chunk = new CFPlus::MixChunk $rwops |
252 | my $chunk = new CFPlus::MixChunk $rwops |
253 | or Carp::confess "sound face $meta->{face} unloadable: " . CFPlus::Mix_GetError; |
253 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
254 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
254 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
255 | $AUDIO_CHUNK{$face} = $chunk; |
255 | $AUDIO_CHUNK{$face} = $chunk; |
256 | |
256 | |
257 | audio_sound_push ($face); |
257 | audio_sound_push ($face); |
258 | }; |
258 | }; |
… | |
… | |
877 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
877 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
878 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
878 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
879 | # $CFG->{effects_volume} = $_[1]; |
879 | # $CFG->{effects_volume} = $_[1]; |
880 | # }); |
880 | # }); |
881 | |
881 | |
882 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
882 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); |
883 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
883 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
884 | expand => 1, state => $CFG->{effects_enable}, |
884 | expand => 1, state => $CFG->{effects_enable}, |
885 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
885 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
|
|
886 | on_changed => sub { |
886 | on_changed => sub { $CFG->{effects_enable} = $_[1]; 0 } |
887 | $CFG->{effects_enable} = $_[1]; |
|
|
888 | $CONN->update_fx_want if $CONN; |
|
|
889 | 0 |
|
|
890 | } |
887 | ); |
891 | ); |
888 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
892 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
889 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
893 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
890 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
894 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
891 | . "is set highest and you use your operating system volume setting. Changes are instant.", |
895 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
892 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } |
896 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } |
893 | ); |
897 | ); |
894 | |
898 | |
895 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
899 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
896 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
900 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
897 | expand => 1, state => $CFG->{bgm_enable}, |
901 | expand => 1, state => $CFG->{bgm_enable}, |
898 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
902 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
899 | on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 } |
903 | on_changed => sub { |
|
|
904 | $CFG->{bgm_enable} = $_[1]; |
|
|
905 | $CONN->update_fx_want if $CONN; |
|
|
906 | 0 |
|
|
907 | } |
900 | ); |
908 | ); |
901 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
909 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
902 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
910 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
903 | tooltip => "The volume of the background music. Changes are instant.", |
911 | tooltip => "The volume of the background music. Changes are instant.", |
904 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
912 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |