Echo().execute(message) is now just Echo(message)

Former-commit-id: 851e141fc91b170190d6027f42f59906dda0f31f
Former-commit-id: 03dbb9da1788e1c50e84ae33d95f76194ad9a08d
This commit is contained in:
Song Minjae
2016-12-14 12:40:53 +09:00
parent 1dd156d172
commit 7078ecfed4
32 changed files with 127 additions and 121 deletions

View File

@@ -19,7 +19,7 @@ internal object Authenticator : ConsoleCommand {
if ("65b9aa150332ed7096134efb20220e5ebec04d4dbe1c537ff3816f68c2391c1c".equals(hashedPwd, ignoreCase = true)) { if ("65b9aa150332ed7096134efb20220e5ebec04d4dbe1c537ff3816f68c2391c1c".equals(hashedPwd, ignoreCase = true)) {
// aryll // aryll
val msg = if (a) "Locked" else "Authenticated" val msg = if (a) "Locked" else "Authenticated"
Echo.execute(msg) Echo(msg)
println("[Authenticator] " + msg) println("[Authenticator] " + msg)
a = !a a = !a
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).reset() (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).reset()

View File

@@ -19,6 +19,6 @@ internal object Batch : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: batch path/to/batch.txt") Echo("Usage: batch path/to/batch.txt")
} }
} }

View File

@@ -16,15 +16,15 @@ internal object CatStdout : ConsoleCommand {
} }
try { try {
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ Echo.execute(it) }) Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ Echo(it) })
} }
catch (e: IOException) { catch (e: IOException) {
Echo.execute("CatStdout: could not read file -- IOException") Echo("CatStdout: could not read file -- IOException")
} }
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("usage: cat 'path/to/text/file") Echo("usage: cat 'path/to/text/file")
} }
} }

View File

@@ -25,22 +25,22 @@ internal object CodexEdictis : ConsoleCommand {
val sb = StringBuilder() val sb = StringBuilder()
val formatter = Formatter(sb) val formatter = Formatter(sb)
Echo.execute("Codex: " + formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], args[1]).toString()) Echo("Codex: " + formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], args[1]).toString())
} }
} }
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: codex (command)") Echo("Usage: codex (command)")
Echo.execute("shows how to use 'command'") Echo("shows how to use 'command'")
Echo.execute("leave blank to get list of available commands") Echo("leave blank to get list of available commands")
} }
private fun printList() { private fun printList() {
Echo.execute(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"]) Echo(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"])
CommandDict.dict.forEach { name, cmd -> CommandDict.dict.forEach { name, cmd ->
Echo.execute("$ccW" + name) Echo("$ccW" + name)
cmd.printUsage() cmd.printUsage()
} }
} }

View File

@@ -11,7 +11,7 @@ object CommandDict {
internal var dict: HashMap<String, ConsoleCommand> = hashMapOf( internal var dict: HashMap<String, ConsoleCommand> = hashMapOf(
Pair("echo", Echo), Pair("echo", Echo),
Pair("error", Error), Pair("error", EchoError),
Pair("setav", SetAV), Pair("setav", SetAV),
Pair("qqq", QuitApp), Pair("qqq", QuitApp),
Pair("codex", CodexEdictis), Pair("codex", CodexEdictis),

View File

@@ -59,7 +59,7 @@ object CommandInterpreter {
} }
finally { finally {
Echo.execute("$ccW> $single_command") // prints out the input Echo("$ccW> $single_command") // prints out the input
println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'") println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'")
try { try {
if (commandObj != null) { if (commandObj != null) {
@@ -73,7 +73,7 @@ object CommandInterpreter {
catch (e: Exception) { catch (e: Exception) {
System.err.print("[CommandInterpreter] ") System.err.print("[CommandInterpreter] ")
e.printStackTrace() e.printStackTrace()
Error.execute(Lang["ERROR_GENERIC_TEXT"]) EchoError(Lang["ERROR_GENERIC_TEXT"])
} }
} }
@@ -115,7 +115,7 @@ object CommandInterpreter {
val sb = StringBuilder() val sb = StringBuilder()
val formatter = Formatter(sb) val formatter = Formatter(sb)
Error.execute( EchoError(
formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], cmdname).toString()) formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], cmdname).toString())
} }

View File

@@ -28,6 +28,9 @@ internal object Echo : ConsoleCommand {
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString()) (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
} }
operator fun invoke(args: Array<String>) = execute(args)
operator fun invoke(single_line: String) = execute(single_line)
override fun printUsage() { override fun printUsage() {
} }

View File

@@ -7,7 +7,7 @@ import net.torvald.terrarum.ui.ConsoleWindow
/** /**
* Created by minjaesong on 16-04-25. * Created by minjaesong on 16-04-25.
*/ */
internal object Error : ConsoleCommand { internal object EchoError : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]}) val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]})
argsWoHeader.forEach { execute(it) } argsWoHeader.forEach { execute(it) }
@@ -17,6 +17,9 @@ internal object Error : ConsoleCommand {
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line") (Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line")
} }
operator fun invoke(args: Array<String>) = execute(args)
operator fun invoke(single_line: String) = execute(single_line)
override fun printUsage() { override fun printUsage() {
} }

View File

@@ -16,10 +16,10 @@ internal object ExportAV : ConsoleCommand {
Terrarum.ingame.player.actorValue, Terrarum.ingame.player.actorValue,
Terrarum.defaultDir + "/Exports/" + args[1] + ".json") Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
Echo.execute("ExportAV: exported to " + args[1] + ".json") Echo("ExportAV: exported to " + args[1] + ".json")
} }
catch (e: IOException) { catch (e: IOException) {
Echo.execute("ExportAV: IOException raised.") Echo("ExportAV: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -30,8 +30,8 @@ internal object ExportAV : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Export ActorValue as JSON format.") Echo("Export ActorValue as JSON format.")
Echo.execute("Usage: exportav (id) filename-without-extension") Echo("Usage: exportav (id) filename-without-extension")
Echo.execute("blank ID for player") Echo("blank ID for player")
} }
} }

View File

@@ -45,11 +45,11 @@ internal object ExportMap : ConsoleCommand {
try { try {
RasterWriter.writePNG_RGB( RasterWriter.writePNG_RGB(
Terrarum.ingame.world.width, Terrarum.ingame.world.height, mapData, dir + args[1] + ".png") Terrarum.ingame.world.width, Terrarum.ingame.world.height, mapData, dir + args[1] + ".png")
Echo.execute("ExportMap: exported to " + args[1] + ".png") Echo("ExportMap: exported to " + args[1] + ".png")
} }
catch (e: IOException) { catch (e: IOException) {
Echo.execute("ExportMap: IOException raised.") Echo("ExportMap: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -66,9 +66,9 @@ internal object ExportMap : ConsoleCommand {
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: export <name>") Echo("Usage: export <name>")
Echo.execute("Exports current map into echo image.") Echo("Exports current map into echo image.")
Echo.execute("The image can be found at %adddata%/terrarum/Exports") Echo("The image can be found at %adddata%/terrarum/Exports")
} }
private fun buildColorTable() { private fun buildColorTable() {

View File

@@ -6,10 +6,10 @@ package net.torvald.terrarum.console
internal object ForceGC : ConsoleCommand { internal object ForceGC : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
System.gc() System.gc()
Echo.execute("Invoked System.gc") Echo("Invoked System.gc")
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Invoke garbage collection of JVM.") Echo("Invoke garbage collection of JVM.")
} }
} }

View File

@@ -22,10 +22,10 @@ internal object GetAV : ConsoleCommand {
val av = Terrarum.ingame.player.actorValue val av = Terrarum.ingame.player.actorValue
val keyset = av.keySet val keyset = av.keySet
Echo.execute("$ccW== ActorValue list for ${ccY}player $ccW==") Echo("$ccW== ActorValue list for ${ccY}player $ccW==")
println("[GetAV] == ActorValue list for 'player' ==") println("[GetAV] == ActorValue list for 'player' ==")
keyset.forEach { elem -> keyset.forEach { elem ->
Echo.execute("$ccM$elem $ccW= $ccG${av[elem as String]}") Echo("$ccM$elem $ccW= $ccG${av[elem as String]}")
println("[GetAV] $elem = ${av[elem]}") println("[GetAV] $elem = ${av[elem]}")
} }
} }
@@ -35,7 +35,7 @@ internal object GetAV : ConsoleCommand {
else if (args.size == 2) { else if (args.size == 2) {
// check if args[1] is number or not // check if args[1] is number or not
if (!args[1].isNum()) { // args[1] is ActorValue name if (!args[1].isNum()) { // args[1] is ActorValue name
Echo.execute("${ccW}player.$ccM${args[1]} $ccW= " + Echo("${ccW}player.$ccM${args[1]} $ccW= " +
ccG + ccG +
Terrarum.ingame.player.actorValue[args[1]] + Terrarum.ingame.player.actorValue[args[1]] +
" $ccO" + " $ccO" +
@@ -53,15 +53,15 @@ internal object GetAV : ConsoleCommand {
val av = actor.actorValue val av = actor.actorValue
val keyset = av.keySet val keyset = av.keySet
Echo.execute("$ccW== ActorValue list for $ccY$actor $ccW==") Echo("$ccW== ActorValue list for $ccY$actor $ccW==")
println("[GetAV] == ActorValue list for '$actor' ==") println("[GetAV] == ActorValue list for '$actor' ==")
if (keyset.size == 0) { if (keyset.size == 0) {
Echo.execute("$ccK(nothing)") Echo("$ccK(nothing)")
println("[GetAV] (nothing)") println("[GetAV] (nothing)")
} }
else { else {
keyset.forEach { elem -> keyset.forEach { elem ->
Echo.execute("$ccM$elem $ccW= $ccG${av[elem as String]}") Echo("$ccM$elem $ccW= $ccG${av[elem as String]}")
println("[GetAV] $elem = ${av[elem]}") println("[GetAV] $elem = ${av[elem]}")
} }
} }
@@ -70,7 +70,7 @@ internal object GetAV : ConsoleCommand {
else if (args.size == 3) { else if (args.size == 3) {
val id = args[1].toInt() val id = args[1].toInt()
val av = args[2] val av = args[2]
Echo.execute("$ccW$id.$ccM$av $ccW= $ccG" + Echo("$ccW$id.$ccM$av $ccW= $ccG" +
Terrarum.ingame.getActorByID(id).actorValue[av] + Terrarum.ingame.getActorByID(id).actorValue[av] +
" $ccO" + " $ccO" +
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
@@ -84,11 +84,11 @@ internal object GetAV : ConsoleCommand {
} }
catch (e: NullPointerException) { catch (e: NullPointerException) {
if (args.size == 2) { if (args.size == 2) {
Error.execute(args[1] + ": actor value does not exist.") EchoError(args[1] + ": actor value does not exist.")
System.err.println("[GetAV] ${args[1]}: actor value does not exist.") System.err.println("[GetAV] ${args[1]}: actor value does not exist.")
} }
else if (args.size == 3) { else if (args.size == 3) {
Error.execute(args[2] + ": actor value does not exist.") EchoError(args[2] + ": actor value does not exist.")
System.err.println("[GetAV] ${args[2]}: actor value does not exist.") System.err.println("[GetAV] ${args[2]}: actor value does not exist.")
} }
else { else {
@@ -96,7 +96,7 @@ internal object GetAV : ConsoleCommand {
} }
} }
catch (e1: IllegalArgumentException) { catch (e1: IllegalArgumentException) {
Error.execute("${args[1]}: no actor with this ID.") EchoError("${args[1]}: no actor with this ID.")
System.err.println("[GetAV] ${args[1]}: no actor with this ID.") System.err.println("[GetAV] ${args[1]}: no actor with this ID.")
} }
@@ -113,8 +113,8 @@ internal object GetAV : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("${ccW}Get desired ActorValue of specific target.") Echo("${ccW}Get desired ActorValue of specific target.")
Echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>") Echo("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>")
Echo.execute("${ccW}blank ID for player") Echo("${ccW}blank ID for player")
} }
} }

View File

@@ -27,56 +27,56 @@ internal object GetFactioning : ConsoleCommand {
fun printOutFactioning(id: Int) { fun printOutFactioning(id: Int) {
val a = Terrarum.ingame.getActorByID(id) val a = Terrarum.ingame.getActorByID(id)
if (a is Factionable) { if (a is Factionable) {
Echo.execute("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==") Echo("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==") println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")
// get all factioning data of player // get all factioning data of player
val factionSet = a.faction val factionSet = a.faction
if (factionSet.isEmpty()) { if (factionSet.isEmpty()) {
Echo.execute("The actor has empty faction set.") Echo("The actor has empty faction set.")
println("[GetFactioning] The actor has empty faction set.") println("[GetFactioning] The actor has empty faction set.")
return return
} }
val count = factionSet.size val count = factionSet.size
Echo.execute("$ccG${count.toString()} $ccW${Lang.pluralise(" faction", count)} assigned.") Echo("$ccG${count.toString()} $ccW${Lang.pluralise(" faction", count)} assigned.")
println("[GetFactioning] ${count.toString()} ${Lang.pluralise(" faction", count)} assigned.") println("[GetFactioning] ${count.toString()} ${Lang.pluralise(" faction", count)} assigned.")
for (faction in factionSet) { for (faction in factionSet) {
Echo.execute("${ccW}faction $ccM${faction.factionName}") Echo("${ccW}faction $ccM${faction.factionName}")
println("[GetFactioning] faction '${faction.factionName}'") println("[GetFactioning] faction '${faction.factionName}'")
Echo.execute("$ccY Amicable") Echo("$ccY Amicable")
println("[GetFactioning] Amicable") println("[GetFactioning] Amicable")
faction.factionAmicable.forEach { s -> faction.factionAmicable.forEach { s ->
Echo.execute(PRINT_INDENTATION + s) Echo(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
Echo.execute("$ccY Explicit neutral") Echo("$ccY Explicit neutral")
println("[GetFactioning] Explicit neutral") println("[GetFactioning] Explicit neutral")
faction.factionNeutral.forEach { s -> faction.factionNeutral.forEach { s ->
Echo.execute(PRINT_INDENTATION + s) Echo(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
Echo.execute("$ccY Hostile") Echo("$ccY Hostile")
println("[GetFactioning] Hostile") println("[GetFactioning] Hostile")
faction.factionHostile.forEach { s -> faction.factionHostile.forEach { s ->
Echo.execute(PRINT_INDENTATION + s) Echo(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
Echo.execute("$ccY Fearful") Echo("$ccY Fearful")
println("[GetFactioning] Fearful") println("[GetFactioning] Fearful")
faction.factionFearful.forEach { s -> faction.factionFearful.forEach { s ->
Echo.execute(PRINT_INDENTATION + s) Echo(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
} }
} }
else { else {
Error.execute("The actor is not factionable.") EchoError("The actor is not factionable.")
System.err.println("[GetFactioning] The actor is not factionable.") System.err.println("[GetFactioning] The actor is not factionable.")
} }
} }
@@ -86,7 +86,7 @@ internal object GetFactioning : ConsoleCommand {
} }
else { else {
if (!args[1].isNum()) { if (!args[1].isNum()) {
Error.execute("Invalid actor ID input.") EchoError("Invalid actor ID input.")
System.err.println("[GetFactioning] Invalid actor ID input.") System.err.println("[GetFactioning] Invalid actor ID input.")
return return
} }
@@ -95,7 +95,7 @@ internal object GetFactioning : ConsoleCommand {
printOutFactioning(actorID) printOutFactioning(actorID)
} }
catch (e: IllegalArgumentException) { catch (e: IllegalArgumentException) {
Error.execute("${args[1]}: no actor with this ID.") EchoError("${args[1]}: no actor with this ID.")
System.err.println("[GetFactioning] ${args[1]}: no actor with this ID.") System.err.println("[GetFactioning] ${args[1]}: no actor with this ID.")
} }
} }

View File

@@ -8,7 +8,7 @@ import net.torvald.terrarum.Terrarum
*/ */
internal object GetLocale : ConsoleCommand { internal object GetLocale : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo.execute( Echo(
"Locale: " "Locale: "
+ Lang["MENU_LANGUAGE_THIS"] + Lang["MENU_LANGUAGE_THIS"]
+ " (" + " ("
@@ -18,7 +18,7 @@ internal object GetLocale : ConsoleCommand {
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: getlocale") Echo("Usage: getlocale")
Echo.execute("Get name of locale currently using.") Echo("Get name of locale currently using.")
} }
} }

View File

@@ -9,10 +9,10 @@ internal object GetTime : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val worldTime = Terrarum.ingame.world.time val worldTime = Terrarum.ingame.world.time
Echo.execute(worldTime.getFormattedTime()) Echo(worldTime.getFormattedTime())
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Print current world time in convenient form") Echo("Print current world time in convenient form")
} }
} }

View File

@@ -27,10 +27,10 @@ internal object GsonTest : ConsoleCommand {
bufferedWriter.write(jsonString) bufferedWriter.write(jsonString)
bufferedWriter.close() bufferedWriter.close()
Echo.execute("GsonTest: exported to " + args[1] + ".json") Echo("GsonTest: exported to " + args[1] + ".json")
} }
catch (e: IOException) { catch (e: IOException) {
Echo.execute("GsonTest: IOException raised.") Echo("GsonTest: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -42,6 +42,6 @@ internal object GsonTest : ConsoleCommand {
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: gsontest filename-without-extension") Echo("Usage: gsontest filename-without-extension")
} }
} }

View File

@@ -10,17 +10,17 @@ internal object Help : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 1) { if (args.size == 1) {
for (i in 1..6) Echo.execute(Lang["HELP_OTF_MAIN_$i"]) for (i in 1..6) Echo(Lang["HELP_OTF_MAIN_$i"])
} }
else if (args[1].toLowerCase() == "slow") { else if (args[1].toLowerCase() == "slow") {
for (i in 1..4) Echo.execute(Lang["HELP_OTF_SLOW_$i"]) for (i in 1..4) Echo(Lang["HELP_OTF_SLOW_$i"])
} }
else { else {
for (i in 1..6) Echo.execute(Lang["HELP_OTF_MAIN_$i"]) for (i in 1..6) Echo(Lang["HELP_OTF_MAIN_$i"])
} }
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Prints some utility functions assigned to function row of the keyboard.") Echo("Prints some utility functions assigned to function row of the keyboard.")
} }
} }

View File

@@ -29,13 +29,13 @@ internal object Inventory : ConsoleCommand {
private fun listInventory() { private fun listInventory() {
if (target.getTotalUniqueCount() == 0) { if (target.getTotalUniqueCount() == 0) {
Echo.execute("(inventory empty)") Echo("(inventory empty)")
} else { } else {
target.forEach { refId, amount -> target.forEach { refId, amount ->
if (amount == 0) { if (amount == 0) {
Error.execute("Unexpected zero-amounted item: ID $refId") EchoError("Unexpected zero-amounted item: ID $refId")
} }
Echo.execute("ID $refId${if (amount > 1) " ($amount)" else ""}") Echo("ID $refId${if (amount > 1) " ($amount)" else ""}")
} }
} }
} }
@@ -43,7 +43,7 @@ internal object Inventory : ConsoleCommand {
private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) { private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) {
val actor = Terrarum.ingame.getActorByID(actorRefId) val actor = Terrarum.ingame.getActorByID(actorRefId)
if (actor !is Pocketed) { if (actor !is Pocketed) {
Error.execute("Cannot edit inventory of incompatible actor: $actor") EchoError("Cannot edit inventory of incompatible actor: $actor")
} else { } else {
target = actor.inventory target = actor.inventory
} }
@@ -58,8 +58,8 @@ internal object Inventory : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: inventory command arguments") Echo("Usage: inventory command arguments")
Echo.execute("Available commands:") Echo("Available commands:")
Echo.execute("list | assign slot | add itemid [amount] | target [actorid]") Echo("list | assign slot | add itemid [amount] | target [actorid]")
} }
} }

View File

@@ -7,13 +7,13 @@ import net.torvald.terrarum.langpack.Lang
*/ */
internal object LangTest : ConsoleCommand { internal object LangTest : ConsoleCommand {
override fun printUsage() { override fun printUsage() {
Echo.execute("Prints out string in the current lang pack by STRING_ID provided") Echo("Prints out string in the current lang pack by STRING_ID provided")
} }
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size < 2) if (args.size < 2)
printUsage() printUsage()
else else
Echo.execute(Lang[args[1].toUpperCase()]) Echo(Lang[args[1].toUpperCase()])
} }
} }

View File

@@ -39,7 +39,7 @@ internal object MusicTest : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: musictest filename/in/res/sounds/test") Echo("Usage: musictest filename/in/res/sounds/test")
Echo.execute("musictest stop to stop playback") Echo("musictest stop to stop playback")
} }
} }

View File

@@ -8,10 +8,10 @@ import java.util.*
*/ */
internal object PrintRandomTips : ConsoleCommand { internal object PrintRandomTips : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo.execute(Lang["GAME_TIPS_${Random().nextInt(Lang.TIPS_COUNT) + 1}"]) Echo(Lang["GAME_TIPS_${Random().nextInt(Lang.TIPS_COUNT) + 1}"])
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Prints random tips for game.") Echo("Prints random tips for game.")
} }
} }

View File

@@ -13,11 +13,11 @@ internal object Seed : ConsoleCommand {
// tsalagi // tsalagi
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo.execute("Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}") Echo("Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}")
// TODO display randomiser seed // TODO display randomiser seed
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("prints out the generator seed of the current game.") Echo("prints out the generator seed of the current game.")
} }
} }

View File

@@ -17,12 +17,12 @@ internal object SetAV : ConsoleCommand {
override fun printUsage() { override fun printUsage() {
Echo.execute("${ccW}Set actor value of specific target to desired value.") Echo("${ccW}Set actor value of specific target to desired value.")
Echo.execute("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>") Echo("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>")
Echo.execute("${ccW}blank ID for player. Data type will be inferred automatically.") Echo("${ccW}blank ID for player. Data type will be inferred automatically.")
Echo.execute("${ccR}Contaminated (e.g. double -> string) ActorValue will crash the game,") Echo("${ccR}Contaminated (e.g. double -> string) ActorValue will crash the game,")
Echo.execute("${ccR}so make sure it will not happen before you issue the command!") Echo("${ccR}so make sure it will not happen before you issue the command!")
Echo.execute("${ccW}Use ${ccG}__true ${ccW}and ${ccG}__false ${ccW}for boolean value.") Echo("${ccW}Use ${ccG}__true ${ccW}and ${ccG}__false ${ccW}for boolean value.")
} }
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
@@ -65,13 +65,13 @@ internal object SetAV : ConsoleCommand {
// check if av is number // check if av is number
if (args[1].isNum()) { if (args[1].isNum()) {
Error.execute("Illegal ActorValue ${args[1]}: ActorValue cannot be a number.") EchoError("Illegal ActorValue ${args[1]}: ActorValue cannot be a number.")
System.err.println("[SetAV] Illegal ActorValue ${args[1]}: ActorValue cannot be a number.") System.err.println("[SetAV] Illegal ActorValue ${args[1]}: ActorValue cannot be a number.")
return return
} }
Terrarum.ingame.player.actorValue[args[1]] = `val` Terrarum.ingame.player.actorValue[args[1]] = `val`
Echo.execute("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$`val`") Echo("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$`val`")
println("[SetAV] set ActorValue '${args[1]}' for player to '$`val`'.") println("[SetAV] set ActorValue '${args[1]}' for player to '$`val`'.")
} }
else if (args.size == 4) { else if (args.size == 4) {
@@ -82,18 +82,18 @@ internal object SetAV : ConsoleCommand {
// check if av is number // check if av is number
if (args[2].isNum()) { if (args[2].isNum()) {
Error.execute("Illegal ActorValue ${args[2]}: ActorValue cannot be a number.") EchoError("Illegal ActorValue ${args[2]}: ActorValue cannot be a number.")
System.err.println("[SetAV] Illegal ActorValue ${args[2]}: ActorValue cannot be a number.") System.err.println("[SetAV] Illegal ActorValue ${args[2]}: ActorValue cannot be a number.")
return return
} }
actor.actorValue[args[2]] = `val` actor.actorValue[args[2]] = `val`
Echo.execute("${ccW}Set $ccM${args[2]} ${ccW}for $ccY$id ${ccW}to $ccG$`val`") Echo("${ccW}Set $ccM${args[2]} ${ccW}for $ccY$id ${ccW}to $ccG$`val`")
println("[SetAV] set ActorValue '${args[2]}' for $actor to '$`val`'.") println("[SetAV] set ActorValue '${args[2]}' for $actor to '$`val`'.")
} }
catch (e: IllegalArgumentException) { catch (e: IllegalArgumentException) {
if (args.size == 4) { if (args.size == 4) {
Error.execute("${args[1]}: no actor with this ID.") EchoError("${args[1]}: no actor with this ID.")
System.err.println("[SetAV] ${args[1]}: no actor with this ID.") System.err.println("[SetAV] ${args[1]}: no actor with this ID.")
} }
} }

View File

@@ -23,10 +23,10 @@ internal object SetGlobalLightOverride : ConsoleCommand {
Terrarum.ingame.world.globalLight = GL Terrarum.ingame.world.globalLight = GL
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo.execute("Wrong number input.") Echo("Wrong number input.")
} }
catch (e1: IllegalArgumentException) { catch (e1: IllegalArgumentException) {
Echo.execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel") Echo("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel")
} }
} }
@@ -35,7 +35,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
val GL = args[1].toInt() val GL = args[1].toInt()
if (GL.toInt() < 0 || GL.toInt() >= LightmapRenderer.COLOUR_RANGE_SIZE) { if (GL.toInt() < 0 || GL.toInt() >= LightmapRenderer.COLOUR_RANGE_SIZE) {
Echo.execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1)) Echo("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
} }
else { else {
Terrarum.ingame.world.globalLight = GL Terrarum.ingame.world.globalLight = GL
@@ -45,7 +45,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
if (args[1].toLowerCase() == "none") if (args[1].toLowerCase() == "none")
lightOverride = false lightOverride = false
else else
Echo.execute("Wrong number input.") Echo("Wrong number input.")
} }
} }
@@ -55,6 +55,6 @@ internal object SetGlobalLightOverride : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: setgl [raw_value|r g b|“none”]") Echo("Usage: setgl [raw_value|r g b|“none”]")
} }
} }

View File

@@ -17,19 +17,19 @@ internal object SetLocale : ConsoleCommand {
val prevLocale = Terrarum.gameLocale val prevLocale = Terrarum.gameLocale
Terrarum.gameLocale = args[1] Terrarum.gameLocale = args[1]
try { try {
Echo.execute("Set locale to '" + Terrarum.gameLocale + "'.") Echo("Set locale to '" + Terrarum.gameLocale + "'.")
} }
catch (e: IOException) { catch (e: IOException) {
Echo.execute("could not read lang file.") Echo("could not read lang file.")
Terrarum.gameLocale = prevLocale Terrarum.gameLocale = prevLocale
} }
} }
else if (args.size == 1) { else if (args.size == 1) {
Echo.execute("Locales:") Echo("Locales:")
Lang.languageList.forEach { Echo.execute("--> $it") } Lang.languageList.forEach { Echo("--> $it") }
} }
else { else {
printUsage() printUsage()
@@ -37,6 +37,6 @@ internal object SetLocale : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: setlocale [locale]") Echo("Usage: setlocale [locale]")
} }
} }

View File

@@ -13,7 +13,7 @@ internal object SetTime : ConsoleCommand {
Terrarum.ingame.world.time.setTime(timeToSet) Terrarum.ingame.world.time.setTime(timeToSet)
Echo.execute("Set time to ${Terrarum.ingame.world.time.elapsedSeconds} " + Echo("Set time to ${Terrarum.ingame.world.time.elapsedSeconds} " +
"(${Terrarum.ingame.world.time.hours}h${formatMin(Terrarum.ingame.world.time.minutes)})") "(${Terrarum.ingame.world.time.hours}h${formatMin(Terrarum.ingame.world.time.minutes)})")
} }
else { else {
@@ -26,6 +26,6 @@ internal object SetTime : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("usage: settime <39201-in sec or 13h32-in hour>") Echo("usage: settime <39201-in sec or 13h32-in hour>")
} }
} }

View File

@@ -12,13 +12,13 @@ internal object SetTimeDelta : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
if (args[1].toInt() > HARD_LIMIT) if (args[1].toInt() > HARD_LIMIT)
Error.execute("Delta too large -- acceptable delta is 0-60.") EchoError("Delta too large -- acceptable delta is 0-60.")
Terrarum.ingame.world.time.setTimeDelta(args[1].toInt()) Terrarum.ingame.world.time.setTimeDelta(args[1].toInt())
if (Terrarum.ingame.world.time.timeDelta == 0) if (Terrarum.ingame.world.time.timeDelta == 0)
Echo.execute("時間よ止まれ!ザ・ワルド!!") Echo("時間よ止まれ!ザ・ワルド!!")
else else
Echo.execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}") Echo("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
} }
else { else {
printUsage() printUsage()
@@ -26,6 +26,6 @@ internal object SetTimeDelta : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("usage: settimedelta <int>") Echo("usage: settimedelta <int>")
} }
} }

View File

@@ -33,6 +33,6 @@ internal object SpawnPhysTestBall : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("usage: spawnball [elasticity]") Echo("usage: spawnball [elasticity]")
} }
} }

View File

@@ -22,7 +22,7 @@ internal object TeleportPlayer : ConsoleCommand {
y = args[2].toInt() * MapDrawer.TILE_SIZE + MapDrawer.TILE_SIZE / 2 y = args[2].toInt() * MapDrawer.TILE_SIZE + MapDrawer.TILE_SIZE / 2
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo.execute("Wrong number input.") Echo("Wrong number input.")
return return
} }
@@ -31,6 +31,6 @@ internal object TeleportPlayer : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: teleport [x-tile] [y-tile]") Echo("Usage: teleport [x-tile] [y-tile]")
} }
} }

View File

@@ -11,10 +11,10 @@ internal object ToggleNoClip : ConsoleCommand {
val status = Terrarum.ingame.player.isNoClip() val status = Terrarum.ingame.player.isNoClip()
Terrarum.ingame.player.setNoClip(!status) Terrarum.ingame.player.setNoClip(!status)
Echo.execute("Set no-clip status to " + (!status).toString()) Echo("Set no-clip status to " + (!status).toString())
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("toggle no-clip status of player") Echo("toggle no-clip status of player")
} }
} }

View File

@@ -9,11 +9,11 @@ import net.torvald.terrarum.langpack.Lang
internal object Version : ConsoleCommand { internal object Version : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo.execute("${Terrarum.NAME} ${Terrarum.VERSION_STRING}") Echo("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
Echo.execute("Polyglot language pack version ${Lang.POLYGLOT_VERSION}") Echo("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Prints out current version of the application") Echo("Prints out current version of the application")
} }
} }

View File

@@ -14,7 +14,7 @@ internal object Zoom : ConsoleCommand {
zoom = args[1].toFloat() zoom = args[1].toFloat()
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo.execute("Wrong number input.") Echo("Wrong number input.")
return return
} }
@@ -29,7 +29,7 @@ internal object Zoom : ConsoleCommand {
System.gc() System.gc()
Echo.execute("Set screen zoom to " + zoom.toString()) Echo("Set screen zoom to " + zoom.toString())
} }
else { else {
printUsage() printUsage()
@@ -37,6 +37,6 @@ internal object Zoom : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo.execute("Usage: zoom [zoom]") Echo("Usage: zoom [zoom]")
} }
} }