… | |
… | |
228 | $channel->set_position_r ($dx, $dy, 20); |
228 | $channel->set_position_r ($dx, $dy, 20); |
229 | $chunk->play ($channel); |
229 | $chunk->play ($channel); |
230 | } |
230 | } |
231 | } else { |
231 | } else { |
232 | # sound_meta not set means data is in flight either way |
232 | # sound_meta not set means data is in flight either way |
233 | my $meta = $CONN->{sound_meta}{$face} |
233 | my $meta = $CONN->{face}[$face] |
234 | or return; |
234 | or return; |
235 | |
235 | |
|
|
236 | $meta->{data} |
|
|
237 | or return; |
|
|
238 | |
236 | # if its a jingle, play it as ambient music |
239 | # if its a jingle, play it as ambient music |
237 | if ($meta->{meta}{jingle}) { |
240 | if ($meta->{data}{jingle}) { |
238 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
241 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
239 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
242 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
240 | &audio_music_push ($face); |
243 | &audio_music_push ($face); |
241 | } |
244 | } |
242 | } else { |
245 | } else { |
243 | # fetch from database |
246 | # fetch from database |
244 | CFPlus::DB::get res_data => $meta->{name}, sub { |
247 | CFPlus::DB::get res_data => $meta->{name}, sub { |
245 | my $rwops = new CFPlus::RW $_[0]; |
248 | my $rwops = new CFPlus::RW $_[0]; |
246 | my $chunk = new CFPlus::MixChunk $rwops |
249 | my $chunk = new CFPlus::MixChunk $rwops |
247 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
250 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
248 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
251 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
249 | $AUDIO_CHUNK{$face} = $chunk; |
252 | $AUDIO_CHUNK{$face} = $chunk; |
250 | |
253 | |
251 | audio_sound_push ($face); |
254 | audio_sound_push ($face); |
252 | }; |
255 | }; |
253 | } |
256 | } |
… | |
… | |
271 | sub audio_music_set_meta { |
274 | sub audio_music_set_meta { |
272 | my ($meta) = @_; |
275 | my ($meta) = @_; |
273 | |
276 | |
274 | $MUSIC_PLAYING_META = $meta; |
277 | $MUSIC_PLAYING_META = $meta; |
275 | $MUSIC_PLAYING_WIDGET->set_markup ( |
278 | $MUSIC_PLAYING_WIDGET->set_markup ( |
276 | "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" |
279 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
277 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" |
280 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
278 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" |
281 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
279 | . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) |
282 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
280 | ); |
283 | ); |
281 | } |
284 | } |
282 | |
285 | |
283 | sub audio_music_update_volume { |
286 | sub audio_music_update_volume { |
284 | return unless $MUSIC_PLAYING_META; |
287 | return unless $MUSIC_PLAYING_META; |
285 | my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; |
288 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
286 | my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; |
289 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
287 | CFPlus::MixMusic::volume $base * $volume * 128; |
290 | CFPlus::MixMusic::volume $base * $volume * 128; |
288 | } |
291 | } |
289 | |
292 | |
290 | sub audio_music_start { |
293 | sub audio_music_start { |
291 | my $meta = $MUSIC_PLAYING_META; |
294 | my $meta = $MUSIC_PLAYING_META; |
… | |
… | |
334 | $fade_out = 333; |
337 | $fade_out = 333; |
335 | } else { |
338 | } else { |
336 | return unless $CFG->{bgm_enable}; |
339 | return unless $CFG->{bgm_enable}; |
337 | |
340 | |
338 | my @have = |
341 | my @have = |
339 | grep $_, |
342 | grep $_ && $_->{data}, |
340 | map $CONN->{music_meta}{$_}, |
343 | map $CONN->{face}[$_], |
341 | @$MUSIC_WANT; |
344 | @$MUSIC_WANT; |
342 | |
345 | |
343 | @MUSIC_HAVE = @have |
346 | @MUSIC_HAVE = @have |
344 | if @have; |
347 | if @have; |
345 | |
348 | |
… | |
… | |
784 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
787 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
785 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
788 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
786 | state => $CFG->{texture_compression}, |
789 | state => $CFG->{texture_compression}, |
787 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
790 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
788 | . "will save a lot of memory and increase performance. The compression algorithm " |
791 | . "will save a lot of memory and increase performance. The compression algorithm " |
789 | . "can differ form card to card, so your mileage may vary.", |
792 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
|
|
793 | . "forced OpenGL 1.1 mode.", |
790 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
794 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
791 | ); |
795 | ); |
792 | |
796 | |
793 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
797 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
794 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
798 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
… | |
… | |
917 | expand => 1, state => $CFG->{bgm_enable}, |
921 | expand => 1, state => $CFG->{bgm_enable}, |
918 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
922 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
919 | on_changed => sub { |
923 | on_changed => sub { |
920 | $CFG->{bgm_enable} = $_[1]; |
924 | $CFG->{bgm_enable} = $_[1]; |
921 | $CONN->update_fx_want if $CONN; |
925 | $CONN->update_fx_want if $CONN; |
|
|
926 | audio_music_push; |
922 | 0 |
927 | 0 |
923 | } |
928 | } |
924 | ); |
929 | ); |
925 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
930 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
926 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
931 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
… | |
… | |
1650 | } |
1655 | } |
1651 | |
1656 | |
1652 | sub add_license { |
1657 | sub add_license { |
1653 | my ($meta) = @_; |
1658 | my ($meta) = @_; |
1654 | |
1659 | |
1655 | $meta = $meta->{meta} |
1660 | $meta = $meta->{data} |
1656 | or return; |
1661 | or return; |
1657 | |
1662 | |
1658 | $meta->{license} || $meta->{author} || $meta->{source} |
1663 | $meta->{license} || $meta->{author} || $meta->{source} |
1659 | or return; |
1664 | or return; |
1660 | |
1665 | |
… | |
… | |
2201 | |
2206 | |
2202 | my %DEF_CFG = ( |
2207 | my %DEF_CFG = ( |
2203 | sdl_mode => 0, |
2208 | sdl_mode => 0, |
2204 | fullscreen => 0, |
2209 | fullscreen => 0, |
2205 | fast => 0, |
2210 | fast => 0, |
2206 | force_opengl11 => 0, |
2211 | force_opengl11 => undef, |
2207 | texture_compression => 1, |
2212 | texture_compression => 1, |
2208 | map_scale => 1, |
2213 | map_scale => 1, |
2209 | fow_enable => 1, |
2214 | fow_enable => 1, |
2210 | fow_intensity => 0, |
2215 | fow_intensity => 0, |
2211 | map_smoothing => 1, |
2216 | map_smoothing => 1, |