add JupiterRecording.ogg, toggle BGM with TAB

This commit is contained in:
yuni 2024-05-23 03:56:13 +02:00
parent 8d4ad64330
commit 2a6e14aa90
3 changed files with 49 additions and 21 deletions

View file

@ -41,7 +41,11 @@
- https://pixabay.com/sound-effects/whoosh-blow-flutter-shortwav-14678/
- https://pixabay.com/sound-effects/dslr-camera-sounds-26117/
- https://pixabay.com/sound-effects/beep-6-96243
- Music: [Cinematic Cello](https://pixabay.com/music/build-up-scenes-cinematic-cello-115667) by [Aleksey Chistilin](https://pixabay.com/users/lexin_music-28841948/), [Pixabay Content License](https://pixabay.com/service/license-summary)
- Music:
- JupiterRecording.ogg is an [actual Jupiter recording by NASA](https://archive.org/download/voyager-1-and-2-1990-jupiter-nasa-voyager-space-sounds-electronic), public domain.
- Processed by cutting out min 1:47-3:47 and applying a 10s linear crossfade at the end. Exported as ogg with quality=3, see [.kdenlive file](src/audio/JupiterRecording.kdenlive).
- The source file has been taken down, and generally, I can't find information on how exactly this was produced. Hoping it's not a hoax.
- [Cinematic Cello](https://pixabay.com/music/build-up-scenes-cinematic-cello-115667) by [Aleksey Chistilin](https://pixabay.com/users/lexin_music-28841948/), [Pixabay Content License](https://pixabay.com/service/license-summary)
- Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database)
- Font Yupiter-Regular.ttf is placed under the SIL OPEN FONT LICENSE Version 1.1 and is based on:
- Noto Sans Symbols 2, Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols)

Binary file not shown.

View file

@ -21,12 +21,19 @@ impl Plugin for AudioPlugin {
app.add_systems(Startup, setup);
app.add_systems(
Update,
(
play_zoom_sfx,
respawn_sinks.run_if(on_event::<RespawnSinksEvent>()),
pause_all.run_if(on_event::<PauseAllSfxEvent>()),
),
);
app.add_systems(
PostUpdate,
(
play_sfx,
toggle_music.run_if(on_event::<ToggleMusicEvent>()),
),
);
app.add_systems(Update, play_zoom_sfx);
app.add_systems(Update, pause_all.run_if(on_event::<PauseAllSfxEvent>()));
app.add_systems(PostUpdate, play_sfx);
app.add_systems(PostUpdate, update_music);
app.add_event::<PlaySfxEvent>();
app.add_event::<PauseAllSfxEvent>();
app.add_event::<ToggleMusicEvent>();
@ -44,6 +51,11 @@ const PATHS: &[(SfxType, Sfx, &str)] = &[
Sfx::BGM,
"music/Aleksey Chistilin - Cinematic Cello.ogg",
),
(
SfxType::BGMNoAR,
Sfx::BGMActualJupiterRecording,
"music/JupiterRecording.ogg",
),
(
SfxType::LoopSfx,
Sfx::ElectricMotor,
@ -81,6 +93,7 @@ const PATHS: &[(SfxType, Sfx, &str)] = &[
pub enum Sfx {
Achieve,
BGM,
BGMActualJupiterRecording,
Click,
Connect,
Crash,
@ -115,6 +128,7 @@ pub fn str2sfx(sfx_label: &str) -> Sfx {
pub enum SfxType {
BGM,
BGMNoAR,
LoopSfx,
OneOff,
}
@ -163,7 +177,20 @@ pub fn respawn_sinks(
source,
settings: PlaybackSettings {
mode: PlaybackMode::Loop,
paused: settings.mute_music,
paused: settings.mute_music || !settings.hud_active,
..default()
},
},
));
}
SfxType::BGMNoAR => {
commands.spawn((
*sfx,
AudioBundle {
source,
settings: PlaybackSettings {
mode: PlaybackMode::Loop,
paused: settings.mute_music || settings.hud_active,
..default()
},
},
@ -207,24 +234,21 @@ pub fn play_sfx(
}
}
pub fn update_music(
mut events: EventReader<ToggleMusicEvent>,
q_audiosinks: Query<(&AudioSink, &Sfx)>,
settings: Res<var::Settings>,
) {
if !events.is_empty() {
events.clear();
pub fn toggle_music(q_audiosinks: Query<(&AudioSink, &Sfx)>, settings: Res<var::Settings>) {
for (bgm_sink, sfx) in &q_audiosinks {
if *sfx != Sfx::BGM {
let play = match *sfx {
Sfx::BGM => settings.hud_active,
Sfx::BGMActualJupiterRecording => !settings.hud_active,
_ => {
continue;
}
if settings.mute_music {
};
if settings.mute_music || !play {
bgm_sink.pause();
} else {
bgm_sink.play();
}
}
}
}
pub fn play_zoom_sfx(