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:
@@ -146,7 +146,7 @@ public class SoundControl{
|
|||||||
if(state.isMenu()){
|
if(state.isMenu()){
|
||||||
silenced = false;
|
silenced = false;
|
||||||
if(ui.planet.isShown()){
|
if(ui.planet.isShown()){
|
||||||
play(Musics.launch);
|
play(ui.planet.state.planet.launchMusic);
|
||||||
}else if(ui.editor.isShown()){
|
}else if(ui.editor.isShown()){
|
||||||
play(Musics.editor);
|
play(Musics.editor);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mindustry.mod;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.assets.*;
|
import arc.assets.*;
|
||||||
|
import arc.assets.loaders.MusicLoader.*;
|
||||||
import arc.assets.loaders.SoundLoader.*;
|
import arc.assets.loaders.SoundLoader.*;
|
||||||
import arc.audio.*;
|
import arc.audio.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
@@ -61,6 +62,7 @@ public class ContentParser{
|
|||||||
ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
|
ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
|
||||||
ObjectSet<Class<?>> implicitNullable = ObjectSet.with(TextureRegion.class, TextureRegion[].class, TextureRegion[][].class, TextureRegion[][][].class);
|
ObjectSet<Class<?>> implicitNullable = ObjectSet.with(TextureRegion.class, TextureRegion[].class, TextureRegion[][].class, TextureRegion[][][].class);
|
||||||
ObjectMap<String, AssetDescriptor<?>> sounds = new ObjectMap<>();
|
ObjectMap<String, AssetDescriptor<?>> sounds = new ObjectMap<>();
|
||||||
|
ObjectMap<String, AssetDescriptor<?>> musics = new ObjectMap<>();
|
||||||
Seq<ParseListener> listeners = new Seq<>();
|
Seq<ParseListener> listeners = new Seq<>();
|
||||||
|
|
||||||
ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<>(){{
|
ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<>(){{
|
||||||
@@ -284,6 +286,20 @@ public class ContentParser{
|
|||||||
sounds.put(path, desc);
|
sounds.put(path, desc);
|
||||||
return sound;
|
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) -> {
|
put(Objectives.Objective.class, (type, data) -> {
|
||||||
if(data.isString()){
|
if(data.isString()){
|
||||||
var cont = locateAny(data.asString());
|
var cont = locateAny(data.asString());
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.type;
|
package mindustry.type;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.audio.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g3d.*;
|
import arc.graphics.g3d.*;
|
||||||
@@ -15,6 +16,7 @@ import mindustry.content.TechTree.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.EventType.ContentInitEvent;
|
import mindustry.game.EventType.ContentInitEvent;
|
||||||
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.graphics.g3d.*;
|
import mindustry.graphics.g3d.*;
|
||||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||||
@@ -128,6 +130,8 @@ public class Planet extends UnlockableContent{
|
|||||||
public boolean allowLaunchToNumbered = true;
|
public boolean allowLaunchToNumbered = true;
|
||||||
/** Icon as displayed in the planet selection dialog. This is a string, as drawables are null at load time. */
|
/** Icon as displayed in the planet selection dialog. This is a string, as drawables are null at load time. */
|
||||||
public String icon = "planet";
|
public String icon = "planet";
|
||||||
|
/** Plays in the planet dialog when this planet is selected. */
|
||||||
|
public Music launchMusic = Musics.launch;
|
||||||
/** Default core block for launching. */
|
/** Default core block for launching. */
|
||||||
public Block defaultCore = Blocks.coreShard;
|
public Block defaultCore = Blocks.coreShard;
|
||||||
/** Sets up rules on game load for any sector on this planet. */
|
/** Sets up rules on game load for any sector on this planet. */
|
||||||
|
|||||||
Reference in New Issue
Block a user