diff --git a/annotations/src/main/java/io/anuke/annotations/AssetsAnnotationProcessor.java b/annotations/src/main/java/io/anuke/annotations/AssetsAnnotationProcessor.java new file mode 100644 index 0000000000..afc58ccedf --- /dev/null +++ b/annotations/src/main/java/io/anuke/annotations/AssetsAnnotationProcessor.java @@ -0,0 +1,94 @@ +package io.anuke.annotations; + +import com.squareup.javapoet.*; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; +import javax.tools.StandardLocation; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +@SupportedSourceVersion(SourceVersion.RELEASE_8) +public class AssetsAnnotationProcessor extends AbstractProcessor{ + /** Name of the base package to put all the generated classes. */ + private static final String packageName = "io.anuke.mindustry.gen"; + private int round; + + @Override + public synchronized void init(ProcessingEnvironment processingEnv){ + super.init(processingEnv); + //put all relevant utils into utils class + Utils.typeUtils = processingEnv.getTypeUtils(); + Utils.elementUtils = processingEnv.getElementUtils(); + Utils.filer = processingEnv.getFiler(); + Utils.messager = processingEnv.getMessager(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv){ + if(round++ != 0) return false; //only process 1 round + + try{ + + String path = Paths.get(Utils.filer.createResource(StandardLocation.CLASS_OUTPUT, "no", "no") + .toUri().toURL().toString().substring("file:".length())) + .getParent().getParent().getParent().getParent().getParent().getParent().toString(); + + process("Sounds", path + "/assets/sounds", "io.anuke.arc.audio.Sound", "newSound"); + process("Musics", path + "/assets/music", "io.anuke.arc.audio.Music", "newMusic"); + + return true; + }catch(Exception e){ + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + @Override + public Set getSupportedAnnotationTypes() { + return Collections.singleton("*"); + } + + void process(String classname, String path, String rtype, String loadMethod) throws Exception{ + TypeSpec.Builder type = TypeSpec.classBuilder(classname).addModifiers(Modifier.PUBLIC); + MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC); + MethodSpec.Builder dispose = MethodSpec.methodBuilder("dispose").addModifiers(Modifier.PUBLIC, Modifier.STATIC); + + + HashSet names = new HashSet<>(); + Files.list(Paths.get(path)).forEach(p -> { + String fname = p.getFileName().toString(); + String name = p.getFileName().toString(); + name = name.substring(0, name.indexOf(".")); + + if(names.contains(name)){ + Utils.messager.printMessage(Kind.ERROR, "Duplicate file name: " + p.toString() + "!"); + }else{ + names.add(name); + } + + if(SourceVersion.isKeyword(name)){ + name = name + "s"; + } + + load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal($S))", path.substring(path.lastIndexOf("/") + 1) + "/" + fname); + dispose.addStatement(name + ".dispose()"); + dispose.addStatement(name + " = null"); + type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), name, Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build()); + //cons.consume(type, fname, name); + }); + + type.addMethod(load.build()); + type.addMethod(dispose.build()); + JavaFile.builder(packageName, type.build()).build().writeTo(Utils.filer); + } +} diff --git a/annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor index 5954bfccb9..0094bb0b52 100644 --- a/annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/annotations/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -1,4 +1,5 @@ io.anuke.annotations.RemoteMethodAnnotationProcessor io.anuke.annotations.SerializeAnnotationProcessor io.anuke.annotations.StructAnnotationProcessor -io.anuke.annotations.CallSuperAnnotationProcessor \ No newline at end of file +io.anuke.annotations.CallSuperAnnotationProcessor +io.anuke.annotations.AssetsAnnotationProcessor \ No newline at end of file diff --git a/core/assets/music/editor.mp3 b/core/assets/music/editor.mp3 new file mode 100644 index 0000000000..922d194e5f Binary files /dev/null and b/core/assets/music/editor.mp3 differ diff --git a/core/assets/music/menu.mp3 b/core/assets/music/menu.mp3 new file mode 100644 index 0000000000..b171f126a0 Binary files /dev/null and b/core/assets/music/menu.mp3 differ diff --git a/core/assets/sounds/back.ogg b/core/assets/sounds/back.ogg new file mode 100644 index 0000000000..b1176d6b7f Binary files /dev/null and b/core/assets/sounds/back.ogg differ diff --git a/core/assets/sounds/bang.mp3 b/core/assets/sounds/bang.mp3 new file mode 100644 index 0000000000..d859b89aab Binary files /dev/null and b/core/assets/sounds/bang.mp3 differ diff --git a/core/assets/sounds/bang2.mp3 b/core/assets/sounds/bang2.mp3 new file mode 100644 index 0000000000..71e3deffa4 Binary files /dev/null and b/core/assets/sounds/bang2.mp3 differ diff --git a/core/assets/sounds/bigshot.mp3 b/core/assets/sounds/bigshot.mp3 new file mode 100644 index 0000000000..2139d15232 Binary files /dev/null and b/core/assets/sounds/bigshot.mp3 differ diff --git a/core/assets/sounds/blast.mp3 b/core/assets/sounds/blast.mp3 new file mode 100644 index 0000000000..f05f080eae Binary files /dev/null and b/core/assets/sounds/blast.mp3 differ diff --git a/core/assets/sounds/bloop.mp3 b/core/assets/sounds/bloop.mp3 new file mode 100644 index 0000000000..c77f53d7fe Binary files /dev/null and b/core/assets/sounds/bloop.mp3 differ diff --git a/core/assets/sounds/break.mp3 b/core/assets/sounds/break.mp3 new file mode 100644 index 0000000000..56487e4af1 Binary files /dev/null and b/core/assets/sounds/break.mp3 differ diff --git a/core/assets/sounds/corexplode.mp3 b/core/assets/sounds/corexplode.mp3 new file mode 100644 index 0000000000..2ee50fb405 Binary files /dev/null and b/core/assets/sounds/corexplode.mp3 differ diff --git a/core/assets/sounds/die.mp3 b/core/assets/sounds/die.mp3 new file mode 100644 index 0000000000..ae87ef7aa9 Binary files /dev/null and b/core/assets/sounds/die.mp3 differ diff --git a/core/assets/sounds/enemyshoot.mp3 b/core/assets/sounds/enemyshoot.mp3 new file mode 100644 index 0000000000..7deb792726 Binary files /dev/null and b/core/assets/sounds/enemyshoot.mp3 differ diff --git a/core/assets/sounds/explosion.mp3 b/core/assets/sounds/explosion.mp3 new file mode 100644 index 0000000000..f5f6e08fa7 Binary files /dev/null and b/core/assets/sounds/explosion.mp3 differ diff --git a/core/assets/sounds/flame.mp3 b/core/assets/sounds/flame.mp3 new file mode 100644 index 0000000000..a49ae44245 Binary files /dev/null and b/core/assets/sounds/flame.mp3 differ diff --git a/core/assets/sounds/flame2.mp3 b/core/assets/sounds/flame2.mp3 new file mode 100644 index 0000000000..c0d71a7b1d Binary files /dev/null and b/core/assets/sounds/flame2.mp3 differ diff --git a/core/assets/sounds/laser.mp3 b/core/assets/sounds/laser.mp3 new file mode 100644 index 0000000000..f0b2398aef Binary files /dev/null and b/core/assets/sounds/laser.mp3 differ diff --git a/core/assets/sounds/lasershot.mp3 b/core/assets/sounds/lasershot.mp3 new file mode 100644 index 0000000000..1db62aa08a Binary files /dev/null and b/core/assets/sounds/lasershot.mp3 differ diff --git a/core/assets/sounds/missile.mp3 b/core/assets/sounds/missile.mp3 new file mode 100644 index 0000000000..89af9f5157 Binary files /dev/null and b/core/assets/sounds/missile.mp3 differ diff --git a/core/assets/sounds/ping.mp3 b/core/assets/sounds/ping.mp3 new file mode 100644 index 0000000000..b9692a37fc Binary files /dev/null and b/core/assets/sounds/ping.mp3 differ diff --git a/core/assets/sounds/place.mp3 b/core/assets/sounds/place.mp3 new file mode 100644 index 0000000000..3f5369e4fa Binary files /dev/null and b/core/assets/sounds/place.mp3 differ diff --git a/core/assets/sounds/press.ogg b/core/assets/sounds/press.ogg new file mode 100644 index 0000000000..a5f6a3525e Binary files /dev/null and b/core/assets/sounds/press.ogg differ diff --git a/core/assets/sounds/purchase.mp3 b/core/assets/sounds/purchase.mp3 new file mode 100644 index 0000000000..6edc48eebd Binary files /dev/null and b/core/assets/sounds/purchase.mp3 differ diff --git a/core/assets/sounds/railgun.mp3 b/core/assets/sounds/railgun.mp3 new file mode 100644 index 0000000000..a9bb203a7c Binary files /dev/null and b/core/assets/sounds/railgun.mp3 differ diff --git a/core/assets/sounds/resonate.mp3 b/core/assets/sounds/resonate.mp3 new file mode 100644 index 0000000000..ea456660de Binary files /dev/null and b/core/assets/sounds/resonate.mp3 differ diff --git a/core/assets/sounds/respawn.mp3 b/core/assets/sounds/respawn.mp3 new file mode 100644 index 0000000000..56e6fff2fc Binary files /dev/null and b/core/assets/sounds/respawn.mp3 differ diff --git a/core/assets/sounds/shoot.mp3 b/core/assets/sounds/shoot.mp3 new file mode 100644 index 0000000000..4a826fdfdd Binary files /dev/null and b/core/assets/sounds/shoot.mp3 differ diff --git a/core/assets/sounds/spawn.mp3 b/core/assets/sounds/spawn.mp3 new file mode 100644 index 0000000000..c0235b640c Binary files /dev/null and b/core/assets/sounds/spawn.mp3 differ diff --git a/core/assets/sounds/tesla.mp3 b/core/assets/sounds/tesla.mp3 new file mode 100644 index 0000000000..c8f053fbd3 Binary files /dev/null and b/core/assets/sounds/tesla.mp3 differ diff --git a/core/assets/sounds/waveend.mp3 b/core/assets/sounds/waveend.mp3 new file mode 100644 index 0000000000..60a48c0ba4 Binary files /dev/null and b/core/assets/sounds/waveend.mp3 differ diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index f7befa8c19..9ed18ca79d 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,12 +1,12 @@ package io.anuke.mindustry; import io.anuke.arc.*; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Log; -import io.anuke.arc.util.Time; +import io.anuke.arc.math.*; +import io.anuke.arc.util.*; import io.anuke.mindustry.core.*; -import io.anuke.mindustry.game.EventType.GameLoadEvent; -import io.anuke.mindustry.io.BundleLoader; +import io.anuke.mindustry.game.EventType.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.io.*; import static io.anuke.mindustry.Vars.*; @@ -26,6 +26,9 @@ public class Mindustry extends ApplicationCore{ Vars.init(); Log.setUseColors(false); BundleLoader.load(); + Musics.load(); + Sounds.load(); + content.load(); content.loadColors(); diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index baa5204a34..2946dce679 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -33,6 +33,7 @@ import static io.anuke.mindustry.Vars.*; */ public class Control implements ApplicationListener{ public final Saves saves; + public final MusicControl music; private Interval timer = new Interval(2); private boolean hiscore = false; @@ -42,6 +43,7 @@ public class Control implements ApplicationListener{ public Control(){ batch = new SpriteBatch(); saves = new Saves(); + music = new MusicControl(); data = new GlobalData(); Unit.dp.product = settings.getInt("uiscale", 100) / 100f; @@ -228,6 +230,8 @@ public class Control implements ApplicationListener{ public void dispose(){ content.dispose(); Net.dispose(); + Musics.dispose(); + Sounds.dispose(); ui.editor.dispose(); } @@ -307,6 +311,19 @@ public class Control implements ApplicationListener{ //autosave global data if it's modified data.checkSave(); + if(state.is(State.menu)){ + if(ui.deploy.isShown()){ + music.silence(); //TODO deploy music + }else if(ui.editor.isShown()){ + music.play(Musics.editor); + }else{ + music.play(Musics.menu); + } + }else{ + //TODO game music + music.silence(); + } + if(!state.is(State.menu)){ input.update(); diff --git a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java index a8dd3b5670..a0ce31d3b7 100644 --- a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java @@ -60,6 +60,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } unit.onSuperDeath(); + unit.type.deathSound.at(unit); //visual only. if(Net.client()){ diff --git a/core/src/io/anuke/mindustry/entities/type/TileEntity.java b/core/src/io/anuke/mindustry/entities/type/TileEntity.java index c7793c5895..f34815cf92 100644 --- a/core/src/io/anuke/mindustry/entities/type/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/type/TileEntity.java @@ -257,6 +257,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ dead = true; Events.fire(new BlockDestroyEvent(tile)); + block.breakSound.at(tile); block.onDestroyed(tile); world.removeBlock(tile); remove(); diff --git a/core/src/io/anuke/mindustry/entities/type/Unit.java b/core/src/io/anuke/mindustry/entities/type/Unit.java index b36e8dde83..833d908782 100644 --- a/core/src/io/anuke/mindustry/entities/type/Unit.java +++ b/core/src/io/anuke/mindustry/entities/type/Unit.java @@ -20,6 +20,7 @@ import io.anuke.mindustry.entities.units.Statuses; import io.anuke.mindustry.game.EventType.UnitDestroyEvent; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Teams.TeamData; +import io.anuke.mindustry.gen.*; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.net.Interpolator; import io.anuke.mindustry.net.Net; @@ -108,6 +109,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ Effects.effect(Fx.explosion, this); Effects.shake(2f, 2f, this); + Sounds.bang.at(this); item.amount = 0; drownTime = 0f; status.clear(); diff --git a/core/src/io/anuke/mindustry/game/MusicControl.java b/core/src/io/anuke/mindustry/game/MusicControl.java new file mode 100644 index 0000000000..ca1b902475 --- /dev/null +++ b/core/src/io/anuke/mindustry/game/MusicControl.java @@ -0,0 +1,40 @@ +package io.anuke.mindustry.game; + +import io.anuke.annotations.Annotations.*; +import io.anuke.arc.audio.*; +import io.anuke.arc.math.*; +import io.anuke.arc.util.*; + +/** Controls playback of multiple music tracks.*/ +public class MusicControl{ + private static final float finTime = 80f, foutTime = 80f; + private @Nullable Music current; + + public void play(@Nullable Music music){ + if(current == null && music != null){ + current = music; + current.setLooping(true); + current.setVolume(0f); + current.play(); + }else if(current == music && music != null){ + current.setVolume(Mathf.clamp(current.getVolume() + Time.delta()/finTime)); + }else if(current != null){ + current.setVolume(Mathf.clamp(current.getVolume() - Time.delta()/foutTime)); + + if(current.getVolume() <= 0.01f){ + current.stop(); + current = null; + if(music != null){ + current = music; + current.setVolume(0f); + current.setLooping(true); + current.play(); + } + } + } + } + + public void silence(){ + play(null); + } +} diff --git a/core/src/io/anuke/mindustry/net/CrashSender.java b/core/src/io/anuke/mindustry/net/CrashSender.java index f034c781dd..44a57ea8ac 100644 --- a/core/src/io/anuke/mindustry/net/CrashSender.java +++ b/core/src/io/anuke/mindustry/net/CrashSender.java @@ -50,12 +50,12 @@ public class CrashSender{ try{ File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + DateTimeFormatter.ofPattern("MM_dd_yyyy_HH_mm_ss").format(LocalDateTime.now()) + ".txt"); - new File(OS.getAppDataDirectoryString(Vars.appName)).mkdir(); - Files.write(file.toPath(), parseException(exception).getBytes()); Files.createDirectories(Paths.get(OS.getAppDataDirectoryString(Vars.appName), "crashes")); + Files.write(file.toPath(), parseException(exception).getBytes()); writeListener.accept(file); - }catch(Throwable ignored){ + }catch(Throwable e){ + e.printStackTrace(); Log.err("Failed to save local crash report."); } diff --git a/core/src/io/anuke/mindustry/type/UnitType.java b/core/src/io/anuke/mindustry/type/UnitType.java index bfe6042e23..a32590c1fd 100644 --- a/core/src/io/anuke/mindustry/type/UnitType.java +++ b/core/src/io/anuke/mindustry/type/UnitType.java @@ -1,14 +1,16 @@ package io.anuke.mindustry.type; -import io.anuke.arc.Core; -import io.anuke.arc.collection.ObjectSet; -import io.anuke.arc.function.Supplier; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.mindustry.content.Items; -import io.anuke.mindustry.entities.type.BaseUnit; +import io.anuke.arc.*; +import io.anuke.arc.audio.*; +import io.anuke.arc.collection.*; +import io.anuke.arc.function.*; +import io.anuke.arc.graphics.g2d.*; +import io.anuke.arc.scene.ui.layout.*; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.*; -import io.anuke.mindustry.ui.ContentDisplay; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.ui.*; public class UnitType extends UnlockableContent{ public final TypeID typeID; @@ -35,6 +37,7 @@ public class UnitType extends UnlockableContent{ public Weapon weapon; public float weaponOffsetY, engineOffset = 6f, engineSize = 2f; public ObjectSet immunities = new ObjectSet<>(); + public Sound deathSound = Sounds.bang; public TextureRegion iconRegion, legRegion, baseRegion, region; diff --git a/core/src/io/anuke/mindustry/type/Weapon.java b/core/src/io/anuke/mindustry/type/Weapon.java index 7d2a22c98f..5ed8ff79ac 100644 --- a/core/src/io/anuke/mindustry/type/Weapon.java +++ b/core/src/io/anuke/mindustry/type/Weapon.java @@ -1,22 +1,20 @@ package io.anuke.mindustry.type; -import io.anuke.annotations.Annotations.Loc; -import io.anuke.annotations.Annotations.Remote; -import io.anuke.arc.Core; -import io.anuke.arc.graphics.g2d.TextureRegion; -import io.anuke.arc.math.Angles; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.Tmp; -import io.anuke.mindustry.Vars; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.bullet.BulletType; -import io.anuke.mindustry.entities.traits.ShooterTrait; -import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.gen.Call; +import io.anuke.annotations.Annotations.*; +import io.anuke.arc.*; +import io.anuke.arc.audio.*; +import io.anuke.arc.graphics.g2d.*; +import io.anuke.arc.math.*; +import io.anuke.arc.util.*; +import io.anuke.mindustry.*; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.Effects.*; +import io.anuke.mindustry.entities.bullet.*; +import io.anuke.mindustry.entities.traits.*; +import io.anuke.mindustry.entities.type.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.gen.Sounds; import io.anuke.mindustry.net.Net; public class Weapon{ @@ -56,6 +54,8 @@ public class Weapon{ /** whether shooter rotation is ignored when shooting. */ public boolean ignoreRotation = false; + public Sound shootSound = Sounds.shoot; + public TextureRegion region; protected Weapon(String name){ @@ -69,6 +69,7 @@ public class Weapon{ @Remote(targets = Loc.server, called = Loc.both, unreliable = true) public static void onPlayerShootWeapon(Player player, float x, float y, float rotation, boolean left){ + if(player == null) return; //clients do not see their own shoot events: they are simulated completely clientside to prevent laggy visuals //messing with the firerate or any other stats does not affect the server (take that, script kiddies!) @@ -91,6 +92,7 @@ public class Weapon{ float baseX = shooter.getX(), baseY = shooter.getY(); Weapon weapon = shooter.getWeapon(); + weapon.shootSound.at(x, y); sequenceNum = 0; if(weapon.shotDelay > 0.01f){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java index 7910a4ddd6..e8958d770f 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/FloatingDialog.java @@ -1,18 +1,17 @@ package io.anuke.mindustry.ui.dialogs; -import io.anuke.arc.Core; -import io.anuke.arc.Events; -import io.anuke.arc.input.KeyCode; -import io.anuke.arc.scene.ui.Dialog; -import io.anuke.arc.scene.ui.ScrollPane; -import io.anuke.arc.util.Align; -import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.game.EventType.ResizeEvent; -import io.anuke.mindustry.graphics.Pal; +import io.anuke.arc.*; +import io.anuke.arc.input.*; +import io.anuke.arc.scene.event.*; +import io.anuke.arc.scene.ui.*; +import io.anuke.arc.util.*; +import io.anuke.mindustry.core.GameState.*; +import io.anuke.mindustry.game.EventType.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.net.Net; -import static io.anuke.mindustry.Vars.iconsize; -import static io.anuke.mindustry.Vars.state; +import static io.anuke.mindustry.Vars.*; public class FloatingDialog extends Dialog{ private boolean wasPaused; @@ -32,7 +31,9 @@ public class FloatingDialog extends Dialog{ state.set(State.playing); } } + Sounds.back.play(); }); + ClickListener.clicked = () -> Sounds.press.play(); shown(() -> { if(shouldPause && !state.is(State.menu)){ diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index cb546d8e02..fb0fb7b3d3 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -1,38 +1,36 @@ package io.anuke.mindustry.world; -import io.anuke.annotations.Annotations.CallSuper; -import io.anuke.arc.Core; -import io.anuke.arc.Graphics.Cursor; -import io.anuke.arc.Graphics.Cursor.SystemCursor; -import io.anuke.arc.collection.Array; +import io.anuke.annotations.Annotations.*; +import io.anuke.arc.*; +import io.anuke.arc.Graphics.*; +import io.anuke.arc.Graphics.Cursor.*; +import io.anuke.arc.audio.*; import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.function.BooleanProvider; -import io.anuke.arc.function.Function; -import io.anuke.arc.graphics.Color; +import io.anuke.arc.collection.*; +import io.anuke.arc.function.*; +import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; -import io.anuke.arc.graphics.g2d.TextureAtlas.AtlasRegion; -import io.anuke.arc.math.Mathf; -import io.anuke.arc.scene.ui.layout.Table; -import io.anuke.arc.util.Align; -import io.anuke.arc.util.Time; -import io.anuke.arc.util.pooling.Pools; -import io.anuke.mindustry.entities.Damage; -import io.anuke.mindustry.entities.bullet.Bullet; -import io.anuke.mindustry.entities.effect.Puddle; -import io.anuke.mindustry.entities.effect.RubbleDecal; +import io.anuke.arc.graphics.g2d.TextureAtlas.*; +import io.anuke.arc.math.*; +import io.anuke.arc.scene.ui.layout.*; +import io.anuke.arc.util.*; +import io.anuke.arc.util.pooling.*; +import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.bullet.*; +import io.anuke.mindustry.entities.effect.*; +import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.entities.type.*; -import io.anuke.mindustry.game.UnlockableContent; +import io.anuke.mindustry.game.*; +import io.anuke.mindustry.gen.*; import io.anuke.mindustry.graphics.*; -import io.anuke.mindustry.input.InputHandler.PlaceDraw; +import io.anuke.mindustry.input.InputHandler.*; import io.anuke.mindustry.type.*; -import io.anuke.mindustry.ui.Bar; -import io.anuke.mindustry.ui.ContentDisplay; -import io.anuke.mindustry.world.blocks.Floor; -import io.anuke.mindustry.world.blocks.OverlayFloor; +import io.anuke.mindustry.ui.*; +import io.anuke.mindustry.world.blocks.*; import io.anuke.mindustry.world.consumers.*; import io.anuke.mindustry.world.meta.*; -import java.util.Arrays; +import java.util.*; import static io.anuke.mindustry.Vars.*; @@ -98,6 +96,8 @@ public class Block extends BlockStorage{ public boolean outlineIcon = false; /** Whether this block has a shadow under it. */ public boolean hasShadow = true; + /** Sounds made when this block breaks.*/ + public Sound breakSound = Sounds.die; /** Cost of constructing this block. */ public ItemStack[] buildRequirements = new ItemStack[]{}; diff --git a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java index a896f8583b..c8d571a395 100644 --- a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java @@ -15,7 +15,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.EventType.BlockBuildEndEvent; import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.gen.Call; +import io.anuke.mindustry.gen.*; import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.world.Block; @@ -54,6 +54,7 @@ public class BuildBlock extends Block{ Effects.effect(Fx.breakBlock, tile.drawx(), tile.drawy(), block.size); world.removeBlock(tile); Events.fire(new BlockBuildEndEvent(tile, team, true)); + Sounds.breaks.at(tile); } @Remote(called = Loc.server) @@ -74,6 +75,7 @@ public class BuildBlock extends Block{ Core.app.post(() -> tile.block().playerPlaced(tile)); } Core.app.post(() -> Events.fire(new BlockBuildEndEvent(tile, team, false))); + Sounds.place.at(tile); } @Override diff --git a/desktop-sdl/build.gradle b/desktop-sdl/build.gradle index 2b15ccc5ca..03eb0fa12f 100644 --- a/desktop-sdl/build.gradle +++ b/desktop-sdl/build.gradle @@ -9,7 +9,7 @@ project.ext.assetsDir = new File("../core/assets") def IKVM_DIR = System.env.IKVM_HOME def getTarget = { return project.hasProperty("target") ? project.properties["target"] : "windows" } -task run(dependsOn: classes, type: JavaExec) { +task run(dependsOn: classes, type: JavaExec){ main = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in @@ -29,20 +29,23 @@ task run(dependsOn: classes, type: JavaExec) { } } -task dist(type: Jar, dependsOn: classes) { +task dist(type: Jar, dependsOn: classes){ from files(sourceSets.main.output.classesDirs) from files(sourceSets.main.output.resourcesDir) from {configurations.compile.collect {zipTree(it)}} - from files(project.assetsDir); + from files(project.assetsDir) //use target = all for all platforms def target = getTarget() - if(target == "windows") exclude('**.so', "**.dylib") + if(target.contains("windows")){ + def prefix = target.contains("32") ? "64" : "" + exclude('**.so', "**.dylib", "sdl-arc${prefix}.dll", "gdx${prefix}.dll", "gdx-freetype${prefix}.dll") + } if(target == "mac") exclude('**.so', "**.dll") if(target == "linux") exclude('**.dll', "**.dylib") archivesBaseName = appName + "-" + target - manifest { + manifest{ attributes 'Main-Class': project.mainClassName } } @@ -61,7 +64,8 @@ task ikdist{ doLast{ def filename = "$appName-windows-${version}" def folder = "build/libs/$filename" - def args = ["mono", "$IKVM_DIR/ikvmc.exe", "-target:winexe", "-static", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"] + def baseArgs = System.properties['os.name'].toLowerCase().contains('windows') ? [] : ["mono"] + def args = baseArgs + ["$IKVM_DIR/ikvmc.exe", "-target:winexe", "-static", "-out:build/libs/${filename}.exe", "build/libs/${filename}.jar"] if(file("../core/assets/sprites/icon.ico").exists()){ args += ["-win32icon:../core/assets/sprites/icon.ico"] }else if(file("../core/assets/icons/icon.ico").exists()){ @@ -78,7 +82,7 @@ task ikdist{ } copy{ - from "$IKVM_DIR/libraries" + from(getTarget().contains("32") ? "$IKVM_DIR/libraries_32" : "$IKVM_DIR/libraries") into folder } } diff --git a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java b/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java index 12f6dc2e46..dd7e108d98 100644 --- a/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java +++ b/desktop-sdl/src/io/anuke/mindustry/desktopsdl/DesktopPlatform.java @@ -41,7 +41,7 @@ public class DesktopPlatform extends Platform{ } static void handleCrash(Throwable e){ - Consumer dialog = r -> new Thread(r).start(); + Consumer dialog = Runnable::run; boolean badGPU = false; if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){ @@ -58,7 +58,7 @@ public class DesktopPlatform extends Platform{ CrashSender.send(e, file -> { if(!fbgp){ - dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath())); + dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + (e.getMessage() == null ? "" : "\n" + e.getMessage()))); } }); }