mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 06:22:17 -08:00
Custom Launch Music for Each Planet (#8901)
* plant * what * literal ctrl+c ctrl+v * more music * issue * feedback * commit return
This commit is contained in:
parent
0afed49b7c
commit
5fe28254e7
3 changed files with 21 additions and 1 deletions
|
|
@ -146,7 +146,7 @@ public class SoundControl{
|
|||
if(state.isMenu()){
|
||||
silenced = false;
|
||||
if(ui.planet.isShown()){
|
||||
play(Musics.launch);
|
||||
play(ui.planet.state.planet.launchMusic);
|
||||
}else if(ui.editor.isShown()){
|
||||
play(Musics.editor);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mindustry.mod;
|
|||
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.assets.loaders.MusicLoader.*;
|
||||
import arc.assets.loaders.SoundLoader.*;
|
||||
import arc.audio.*;
|
||||
import arc.files.*;
|
||||
|
|
@ -61,6 +62,7 @@ public class ContentParser{
|
|||
ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
|
||||
ObjectSet<Class<?>> implicitNullable = ObjectSet.with(TextureRegion.class, TextureRegion[].class, TextureRegion[][].class, TextureRegion[][][].class);
|
||||
ObjectMap<String, AssetDescriptor<?>> sounds = new ObjectMap<>();
|
||||
ObjectMap<String, AssetDescriptor<?>> musics = new ObjectMap<>();
|
||||
Seq<ParseListener> listeners = new Seq<>();
|
||||
|
||||
ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<>(){{
|
||||
|
|
@ -284,6 +286,20 @@ public class ContentParser{
|
|||
sounds.put(path, desc);
|
||||
return sound;
|
||||
});
|
||||
put(Music.class, (type, data) -> {
|
||||
if(fieldOpt(Musics.class, data) != null) return fieldOpt(Musics.class, data);
|
||||
if(Vars.headless) return new Music();
|
||||
|
||||
String name = "music/" + data.asString();
|
||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||
|
||||
if(musics.containsKey(path)) return ((MusicParameter)musics.get(path).params).music;
|
||||
var music = new Music();
|
||||
AssetDescriptor<?> desc = Core.assets.load(path, Music.class, new MusicParameter(music));
|
||||
desc.errored = Throwable::printStackTrace;
|
||||
musics.put(path, desc);
|
||||
return music;
|
||||
});
|
||||
put(Objectives.Objective.class, (type, data) -> {
|
||||
if(data.isString()){
|
||||
var cont = locateAny(data.asString());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mindustry.type;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g3d.*;
|
||||
|
|
@ -15,6 +16,7 @@ import mindustry.content.TechTree.*;
|
|||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.ContentInitEvent;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
|
|
@ -128,6 +130,8 @@ public class Planet extends UnlockableContent{
|
|||
public boolean allowLaunchToNumbered = true;
|
||||
/** Icon as displayed in the planet selection dialog. This is a string, as drawables are null at load time. */
|
||||
public String icon = "planet";
|
||||
/** Plays in the planet dialog when this planet is selected. */
|
||||
public Music launchMusic = Musics.launch;
|
||||
/** Default core block for launching. */
|
||||
public Block defaultCore = Blocks.coreShard;
|
||||
/** Sets up rules on game load for any sector on this planet. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue