Add main menu music
This commit is contained in:
parent
2405078bf6
commit
e42b0e6627
26
credits.toml
26
credits.toml
@ -59,4 +59,30 @@ link = "https://www.kenney.nl/"
|
||||
credit = "Game icons"
|
||||
link = "https://opengameart.org/content/game-icons"
|
||||
|
||||
[[people]]
|
||||
name = "section31"
|
||||
[[people.credits]]
|
||||
credit = "Sewer Nightclub"
|
||||
link = "https://opengameart.org/content/sewer-nightclub"
|
||||
|
||||
[[people]]
|
||||
name = "Alexandr Zhelanov"
|
||||
[[people.credits]]
|
||||
credit = "Cyber Implant In My Butt"
|
||||
link = "https://opengameart.org/content/cyber-implant-in-my-butt"
|
||||
|
||||
[[people]]
|
||||
name = "Matthew Pablo"
|
||||
[[people.credits]]
|
||||
credit = "Red Doors v2.0"
|
||||
link = "https://opengameart.org/content/red-doors-v20"
|
||||
[[people.credits]]
|
||||
credit = "Thrust Sequence"
|
||||
link = "https://opengameart.org/content/thrust-sequence"
|
||||
[[people.credits]]
|
||||
credit = "Space Dimensions (8bit/Retro Version)"
|
||||
link = "https://opengameart.org/content/space-dimensions-8bitretro-version"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ CliParserGlobal="*uid://c52o7xa0fnr53"
|
||||
GameSettingsGlobal="*uid://bjr15hjiojecw"
|
||||
AnnouncerGlobal="*uid://5gey4i80mmsa"
|
||||
StandaloneReplayGlobal="*uid://djmb2jqcpkuep"
|
||||
MusicManagerGlobal="*uid://c2q1twneefbjb"
|
||||
|
||||
[display]
|
||||
|
||||
|
||||
BIN
godot/raw_assets/music/Red Doors 2.0 (GameClosure Edition).mp3
Normal file
BIN
godot/raw_assets/music/Red Doors 2.0 (GameClosure Edition).mp3
Normal file
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dkgm7o8u0w550"
|
||||
path="res://.godot/imported/Red Doors 2.0 (GameClosure Edition).mp3-95b4082934392fbc576f9bf3a6e9eafe.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/Red Doors 2.0 (GameClosure Edition).mp3"
|
||||
dest_files=["res://.godot/imported/Red Doors 2.0 (GameClosure Edition).mp3-95b4082934392fbc576f9bf3a6e9eafe.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
godot/raw_assets/music/S31-Sewer Nightclub.ogg
Normal file
BIN
godot/raw_assets/music/S31-Sewer Nightclub.ogg
Normal file
Binary file not shown.
19
godot/raw_assets/music/S31-Sewer Nightclub.ogg.import
Normal file
19
godot/raw_assets/music/S31-Sewer Nightclub.ogg.import
Normal file
@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://cnvikognjv8go"
|
||||
path="res://.godot/imported/S31-Sewer Nightclub.ogg-377cb00f9a5b1b0ffa58a20d2c68ef8e.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/S31-Sewer Nightclub.ogg"
|
||||
dest_files=["res://.godot/imported/S31-Sewer Nightclub.ogg-377cb00f9a5b1b0ffa58a20d2c68ef8e.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
godot/raw_assets/music/Thrust Sequence.mp3
Normal file
BIN
godot/raw_assets/music/Thrust Sequence.mp3
Normal file
Binary file not shown.
19
godot/raw_assets/music/Thrust Sequence.mp3.import
Normal file
19
godot/raw_assets/music/Thrust Sequence.mp3.import
Normal file
@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dai8by348wqss"
|
||||
path="res://.godot/imported/Thrust Sequence.mp3-66527297e2eda55683d766578b64502c.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/Thrust Sequence.mp3"
|
||||
dest_files=["res://.godot/imported/Thrust Sequence.mp3-66527297e2eda55683d766578b64502c.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
godot/raw_assets/music/cyber_implant_in_my_butt.ogg
Normal file
BIN
godot/raw_assets/music/cyber_implant_in_my_butt.ogg
Normal file
Binary file not shown.
19
godot/raw_assets/music/cyber_implant_in_my_butt.ogg.import
Normal file
19
godot/raw_assets/music/cyber_implant_in_my_butt.ogg.import
Normal file
@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://c1q565bmxqy4q"
|
||||
path="res://.godot/imported/cyber_implant_in_my_butt.ogg-9923ee8228149321edae0e811aa330ff.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/cyber_implant_in_my_butt.ogg"
|
||||
dest_files=["res://.godot/imported/cyber_implant_in_my_butt.ogg-9923ee8228149321edae0e811aa330ff.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
godot/raw_assets/music/n-Dimensions (Main Theme - Retro Ver.mp3
Normal file
BIN
godot/raw_assets/music/n-Dimensions (Main Theme - Retro Ver.mp3
Normal file
Binary file not shown.
@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://d3tpaim4ia0xr"
|
||||
path="res://.godot/imported/n-Dimensions (Main Theme - Retro Ver.mp3-4639c477544a2dfc07354bab284a7098.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/n-Dimensions (Main Theme - Retro Ver.mp3"
|
||||
dest_files=["res://.godot/imported/n-Dimensions (Main Theme - Retro Ver.mp3-4639c477544a2dfc07354bab284a7098.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
12
godot/scenes/misc/music_manager_global.tscn
Normal file
12
godot/scenes/misc/music_manager_global.tscn
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_scene format=3 uid="uid://c2q1twneefbjb"]
|
||||
|
||||
[ext_resource type="AudioStream" uid="uid://cnvikognjv8go" path="res://raw_assets/music/S31-Sewer Nightclub.ogg" id="1_xy4vl"]
|
||||
[ext_resource type="AudioStream" uid="uid://c1q565bmxqy4q" path="res://raw_assets/music/cyber_implant_in_my_butt.ogg" id="2_t25pm"]
|
||||
|
||||
[node name="music_manager_global" type="MusicManager" unique_id=86652643 node_paths=PackedStringArray("player")]
|
||||
player = NodePath("audio_stream_player")
|
||||
main_menu_songs = Array[AudioStream]([ExtResource("1_xy4vl"), ExtResource("2_t25pm")])
|
||||
|
||||
[node name="audio_stream_player" type="AudioStreamPlayer" parent="." unique_id=1469531096]
|
||||
bus = &"Music"
|
||||
playback_type = 1
|
||||
54
rust/src/bgm.rs
Normal file
54
rust/src/bgm.rs
Normal file
@ -0,0 +1,54 @@
|
||||
use godot::{
|
||||
classes::{AudioStream, AudioStreamPlayer},
|
||||
prelude::*,
|
||||
tools::get_autoload_by_name,
|
||||
};
|
||||
|
||||
pub const MUSIC_MANAGER_GLOBAL: &str = "MusicManagerGlobal";
|
||||
|
||||
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
|
||||
pub enum Music {
|
||||
MainMenu,
|
||||
Map(u8),
|
||||
}
|
||||
|
||||
#[derive(GodotClass)]
|
||||
#[class(base=Node3D, init)]
|
||||
pub struct MusicManager {
|
||||
#[export]
|
||||
player: Option<Gd<AudioStreamPlayer>>,
|
||||
#[export]
|
||||
main_menu_songs: Array<Gd<AudioStream>>,
|
||||
|
||||
currently_playing: Option<Music>,
|
||||
|
||||
base: Base<Node3D>,
|
||||
}
|
||||
|
||||
impl MusicManager {
|
||||
pub fn singleton() -> Gd<MusicManager> {
|
||||
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
|
||||
}
|
||||
|
||||
pub fn play(&mut self, music: Option<Music>) {
|
||||
if self.currently_playing == music {
|
||||
return;
|
||||
}
|
||||
self.currently_playing = music;
|
||||
if let Some(player) = &mut self.player {
|
||||
match music {
|
||||
Some(music) => {
|
||||
let songs = match music {
|
||||
Music::MainMenu => self.main_menu_songs.clone(),
|
||||
Music::Map(_) => self.main_menu_songs.clone(),
|
||||
};
|
||||
if let Some(song) = songs.pick_random() {
|
||||
player.set_stream(&song);
|
||||
player.play();
|
||||
}
|
||||
}
|
||||
None => player.stop(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ impl VolumeSettings {
|
||||
}
|
||||
|
||||
pub fn music(&self) -> f32 {
|
||||
(self.music_volume / 10_000.) as f32
|
||||
(self.music_volume / 100.) as f32
|
||||
}
|
||||
|
||||
pub fn announcer(&self) -> f32 {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use godot::prelude::*;
|
||||
|
||||
pub mod announcer;
|
||||
pub mod bgm;
|
||||
pub mod chat;
|
||||
pub mod cli_parser;
|
||||
pub mod credits;
|
||||
|
||||
@ -10,6 +10,7 @@ use godot::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
bgm::{Music, MusicManager},
|
||||
game_manager::GameManager,
|
||||
game_settings::{GameSettingsManager, RecentServer},
|
||||
net::network_manager::NetworkManager,
|
||||
@ -104,6 +105,10 @@ impl INode3D for MainMenu {
|
||||
.connect_other(self, Self::on_open_replay);
|
||||
}
|
||||
self.hide_popup();
|
||||
|
||||
MusicManager::singleton()
|
||||
.bind_mut()
|
||||
.play(Some(Music::MainMenu));
|
||||
}
|
||||
|
||||
fn process(&mut self, _delta: f64) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user