… | |
… | |
501 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
501 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
502 | $SETUP_DIALOG->show; |
502 | $SETUP_DIALOG->show; |
503 | $PL_WINDOW->hide; |
503 | $PL_WINDOW->hide; |
504 | $SPELL_LIST->clear_spells; |
504 | $SPELL_LIST->clear_spells; |
505 | $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); |
505 | $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); |
|
|
506 | |
|
|
507 | &audio_music_set ([]); |
506 | |
508 | |
507 | return unless $CONN; |
509 | return unless $CONN; |
508 | |
510 | |
509 | status "connection closed"; |
511 | status "connection closed"; |
510 | |
512 | |
… | |
… | |
2019 | |
2021 | |
2020 | my $count = @$songs; |
2022 | my $count = @$songs; |
2021 | my @meta; |
2023 | my @meta; |
2022 | |
2024 | |
2023 | for my $name (@$songs) { |
2025 | for my $name (@$songs) { |
2024 | CFPlus::DB::get resmap => $name, sub { |
2026 | CFPlus::DB::get "res-metadata" => $name, sub { |
2025 | my ($data) = @_; |
2027 | my ($data) = @_; |
2026 | |
2028 | |
2027 | if ($data) { |
2029 | if ($data) { |
2028 | $data = JSON::XS->new->utf8->decode ($data); |
2030 | $data = JSON::XS->new->utf8->decode ($data); |
2029 | $data->{path} = CFPlus::DB::path_of $name; |
2031 | $data->{path} = CFPlus::DB::path_of $name; |
… | |
… | |
2041 | } |
2043 | } |
2042 | |
2044 | |
2043 | sub audio_music_changed { |
2045 | sub audio_music_changed { |
2044 | return unless $CFG->{bgm_enable}; |
2046 | return unless $CFG->{bgm_enable}; |
2045 | |
2047 | |
2046 | # default MUSIC_WANT, undef/0 == MUSIC_DEFAULT |
2048 | # default MUSIC_WANT == MUSIC_DEFAULT |
2047 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
2049 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
2048 | |
2050 | |
2049 | # if the currently playing song is acceptable, let it continue |
2051 | # if the currently playing song is acceptable, let it continue |
2050 | return if $MUSIC_PLAYING |
2052 | return if $MUSIC_PLAYING |
2051 | && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT; |
2053 | && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT; |
2052 | |
2054 | |
2053 | if ($MUSIC_PLAYING) { |
2055 | if ($MUSIC_PLAYING) { |
2054 | warn "fade out"; |
|
|
2055 | CFPlus::MixMusic::fade_out 1500; |
2056 | CFPlus::MixMusic::fade_out 1000; |
2056 | } else { |
2057 | } else { |
2057 | warn "new music\n"; |
|
|
2058 | |
|
|
2059 | my $music = $MUSIC_WANT [rand @MUSIC_WANT]; |
2058 | my $music = $MUSIC_WANT [rand @MUSIC_WANT]; |
2060 | |
2059 | |
2061 | $MUSIC_PLAYING = $music; |
2060 | $MUSIC_PLAYING = $music; |
2062 | |
2061 | |
2063 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path}; |
2062 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path}; |