mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
Former-commit-id: f91181caee4dabf4cb2e51d8077441c6b0f83757 Former-commit-id: 8b450303698c5c85dea9145a056b290b95a6a7b0
45 lines
1.1 KiB
Kotlin
45 lines
1.1 KiB
Kotlin
package net.torvald.terrarum.console
|
|
|
|
import org.newdawn.slick.Music
|
|
import org.newdawn.slick.openal.AudioLoader
|
|
import java.io.File
|
|
|
|
/**
|
|
* Created by minjaesong on 16-08-02.
|
|
*/
|
|
class MusicTest : ConsoleCommand {
|
|
|
|
var music: Music? = null
|
|
|
|
/**
|
|
* Args 0: command given
|
|
* Args 1: first argument
|
|
*
|
|
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
|
|
*/
|
|
override fun execute(args: Array<String>) {
|
|
if (args.size < 2) {
|
|
printUsage()
|
|
return
|
|
}
|
|
|
|
if (args[1] == "stop") {
|
|
music!!.stop()
|
|
return
|
|
}
|
|
|
|
val type = args[1].substringAfter('.').toUpperCase()
|
|
/*AudioLoader.getStreamingAudio(
|
|
type,
|
|
File("./assets/sounds/test/${args[1]}").absoluteFile.toURI().toURL()
|
|
).playAsMusic(1f, 1f, false)*/
|
|
|
|
music = Music("./assets/sounds/test/${args[1]}")
|
|
music!!.play()
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo().execute("Usage: musictest filename/in/res/sounds/test")
|
|
Echo().execute("musictest stop to stop playback")
|
|
}
|
|
} |