Object-ified console commands (singleton!)

Former-commit-id: d04fc939a659fc4a6b952d64894bd28edf97bc38
Former-commit-id: 6c20526f3bdda2d9d08dc156b3b0fe271e89bffb
This commit is contained in:
Song Minjae
2016-12-14 00:28:09 +09:00
parent e1642c799c
commit 22bb5d83e1
38 changed files with 204 additions and 214 deletions

View File

@@ -83,8 +83,6 @@ constructor() : BasicGameState() {
private val CORES = ThreadPool.POOL_SIZE private val CORES = ThreadPool.POOL_SIZE
val auth = Authenticator()
val KEY_LIGHTMAP_RENDER = Key.F7 val KEY_LIGHTMAP_RENDER = Key.F7
val KEY_LIGHTMAP_SMOOTH = Key.F8 val KEY_LIGHTMAP_SMOOTH = Key.F8

View File

@@ -7,7 +7,7 @@ import org.apache.commons.codec.digest.DigestUtils
/** /**
* Created by minjaesong on 16-02-19. * Created by minjaesong on 16-02-19.
*/ */
class Authenticator : ConsoleCommand { internal object Authenticator : ConsoleCommand {
private var a = false private var a = false
@@ -19,7 +19,7 @@ class 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.execute(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

@@ -6,7 +6,7 @@ import java.nio.file.Files
/** /**
* Created by minjaesong on 16-03-07. * Created by minjaesong on 16-03-07.
*/ */
class Batch : ConsoleCommand { internal object Batch : ConsoleCommand {
@Throws(Exception::class) @Throws(Exception::class)
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
@@ -19,6 +19,6 @@ class Batch : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: batch path/to/batch.txt") Echo.execute("Usage: batch path/to/batch.txt")
} }
} }

View File

@@ -7,26 +7,24 @@ import java.nio.file.Files
/** /**
* Created by minjaesong on 16-02-10. * Created by minjaesong on 16-02-10.
*/ */
class CatStdout : ConsoleCommand { internal object CatStdout : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
if (args.size == 1) { if (args.size == 1) {
printUsage() printUsage()
return return
} }
try { try {
Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ echo.execute(it) }) Files.lines(FileSystems.getDefault().getPath(args[1])).forEach({ Echo.execute(it) })
} }
catch (e: IOException) { catch (e: IOException) {
echo.execute("CatStdout: could not read file -- IOException") Echo.execute("CatStdout: could not read file -- IOException")
} }
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("usage: cat 'path/to/text/file") Echo.execute("usage: cat 'path/to/text/file")
} }
} }

View File

@@ -8,7 +8,7 @@ import java.util.Formatter
/** /**
* Created by minjaesong on 16-01-16. * Created by minjaesong on 16-01-16.
*/ */
class CodexEdictis : ConsoleCommand { internal object CodexEdictis : ConsoleCommand {
val ccW = GameFontBase.colToCode["o"] val ccW = GameFontBase.colToCode["o"]
@@ -25,24 +25,22 @@ class 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.execute("Codex: " + formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], args[1]).toString())
} }
} }
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo() Echo.execute("Usage: codex (command)")
echo.execute("Usage: codex (command)") Echo.execute("shows how to use 'command'")
echo.execute("shows how to use 'command'") Echo.execute("leave blank to get list of available commands")
echo.execute("leave blank to get list of available commands")
} }
private fun printList() { private fun printList() {
val echo = Echo() Echo.execute(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"])
echo.execute(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"])
CommandDict.dict.forEach { name, cmd -> CommandDict.dict.forEach { name, cmd ->
echo.execute("$ccW" + name) Echo.execute("$ccW" + name)
cmd.printUsage() cmd.printUsage()
} }
} }

View File

@@ -10,44 +10,44 @@ import java.util.HashMap
object CommandDict { 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", Error),
Pair("setav", SetAV()), Pair("setav", SetAV),
Pair("qqq", QuitApp()), Pair("qqq", QuitApp),
Pair("codex", CodexEdictis()), Pair("codex", CodexEdictis),
Pair("export", ExportMap()), Pair("export", ExportMap),
Pair("gc", ForceGC()), Pair("gc", ForceGC),
Pair("getav", GetAV()), Pair("getav", GetAV),
Pair("getlocale", GetLocale()), Pair("getlocale", GetLocale),
Pair("togglenoclip", ToggleNoClip()), Pair("togglenoclip", ToggleNoClip),
Pair("nc", ToggleNoClip()), Pair("nc", ToggleNoClip),
Pair("setlocale", SetLocale()), Pair("setlocale", SetLocale),
Pair("zoom", Zoom()), Pair("zoom", Zoom),
Pair("teleport", TeleportPlayer()), Pair("teleport", TeleportPlayer),
Pair("tp", TeleportPlayer()), Pair("tp", TeleportPlayer),
Pair("cat", CatStdout()), Pair("cat", CatStdout),
Pair("exportav", ExportAV()), Pair("exportav", ExportAV),
Pair("setgl", SetGlobalLightOverride()), Pair("setgl", SetGlobalLightOverride),
Pair("getfaction", GetFactioning()), Pair("getfaction", GetFactioning),
Pair("auth", Terrarum.ingame.auth), Pair("auth", Authenticator),
Pair("spawnball", SpawnPhysTestBall()), Pair("spawnball", SpawnPhysTestBall),
Pair("batch", Batch()), Pair("batch", Batch),
Pair("settime", SetTime()), Pair("settime", SetTime),
Pair("gettime", GetTime()), Pair("gettime", GetTime),
Pair("settimedelta", SetTimeDelta()), Pair("settimedelta", SetTimeDelta),
Pair("help", Help()), Pair("help", Help),
Pair("version", Version()), Pair("version", Version),
Pair("seed", Seed()), Pair("seed", Seed),
Pair("testgetlight", TestGetLight()), Pair("testgetlight", TestGetLight),
Pair("println", EchoConsole()), Pair("println", EchoConsole),
Pair("inventory", Inventory()), Pair("inventory", Inventory),
// Test codes // Test codes
Pair("bulletintest", SetBulletin()), Pair("bulletintest", SetBulletin),
Pair("gsontest", GsonTest()), Pair("gsontest", GsonTest),
Pair("tips", PrintRandomTips()), Pair("tips", PrintRandomTips),
Pair("langtest", LangTest()), Pair("langtest", LangTest),
Pair("musictest", MusicTest()) Pair("musictest", MusicTest)
) )
operator fun get(commandName: String): ConsoleCommand { operator fun get(commandName: String): ConsoleCommand {

View File

@@ -33,7 +33,7 @@ object CommandInterpreter {
fun execute(command: String) { fun execute(command: String) {
val cmd: Array<CommandInput?> = parse(command) val cmd: Array<CommandInput?> = parse(command)
val echo = Echo()
val error = Error() val error = Error()
for (single_command in cmd) { for (single_command in cmd) {
@@ -46,7 +46,7 @@ object CommandInterpreter {
commandObj = CommandDict[single_command.name.toLowerCase()] commandObj = CommandDict[single_command.name.toLowerCase()]
} }
else { else {
if (Terrarum.ingame.auth.b()) { if (Authenticator.b()) {
commandObj = CommandDict[single_command.name.toLowerCase()] commandObj = CommandDict[single_command.name.toLowerCase()]
} }
else { else {
@@ -59,7 +59,7 @@ object CommandInterpreter {
} }
finally { finally {
echo.execute("$ccW> $single_command") // prints out the input Echo.execute("$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"]) Error.execute(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( Error.execute(
formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], cmdname).toString()) formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], cmdname).toString())
} }

View File

@@ -9,7 +9,7 @@ import java.util.Arrays
/** /**
* Created by minjaesong on 16-01-16. * Created by minjaesong on 16-01-16.
*/ */
internal class Echo : ConsoleCommand { internal object Echo : 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) }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
/** /**
* Created by minjaesong on 16-09-07. * Created by minjaesong on 16-09-07.
*/ */
class EchoConsole : ConsoleCommand { internal object EchoConsole : ConsoleCommand {
/** /**
* Args 0: command given * Args 0: command given
* Args 1: first argument * Args 1: first argument

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.
*/ */
class Error : ConsoleCommand { internal object Error : 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) }

View File

@@ -8,7 +8,7 @@ import java.io.IOException
/** /**
* Created by minjaesong on 16-02-10. * Created by minjaesong on 16-02-10.
*/ */
class ExportAV : ConsoleCommand { internal object ExportAV : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
try { try {
@@ -16,10 +16,10 @@ class 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.execute("ExportAV: exported to " + args[1] + ".json")
} }
catch (e: IOException) { catch (e: IOException) {
Echo().execute("ExportAV: IOException raised.") Echo.execute("ExportAV: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -30,9 +30,8 @@ class ExportAV : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo() Echo.execute("Export ActorValue as JSON format.")
echo.execute("Export ActorValue as JSON format.") Echo.execute("Usage: exportav (id) filename-without-extension")
echo.execute("Usage: exportav (id) filename-without-extension") Echo.execute("blank ID for player")
echo.execute("blank ID for player")
} }
} }

View File

@@ -11,7 +11,7 @@ import java.util.HashMap
/** /**
* Created by minjaesong on 16-01-17. * Created by minjaesong on 16-01-17.
*/ */
class ExportMap : ConsoleCommand { internal object ExportMap : ConsoleCommand {
//private var mapData: ByteArray? = null //private var mapData: ByteArray? = null
// private var mapDataPointer = 0 // private var mapDataPointer = 0
@@ -45,11 +45,11 @@ class 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.execute("ExportMap: exported to " + args[1] + ".png")
} }
catch (e: IOException) { catch (e: IOException) {
Echo().execute("ExportMap: IOException raised.") Echo.execute("ExportMap: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -65,10 +65,10 @@ class ExportMap : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo()
echo.execute("Usage: export <name>") Echo.execute("Usage: export <name>")
echo.execute("Exports current map into echo image.") Echo.execute("Exports current map into echo image.")
echo.execute("The image can be found at %adddata%/terrarum/Exports") Echo.execute("The image can be found at %adddata%/terrarum/Exports")
} }
private fun buildColorTable() { private fun buildColorTable() {

View File

@@ -3,13 +3,13 @@ package net.torvald.terrarum.console
/** /**
* Created by minjaesong on 16-01-18. * Created by minjaesong on 16-01-18.
*/ */
class 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.execute("Invoked System.gc")
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Invoke garbage collection of JVM.") Echo.execute("Invoke garbage collection of JVM.")
} }
} }

View File

@@ -6,7 +6,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-19. * Created by minjaesong on 16-01-19.
*/ */
class GetAV : ConsoleCommand { internal object GetAV : ConsoleCommand {
val ccW = GameFontBase.colToCode["w"] val ccW = GameFontBase.colToCode["w"]
val ccG = GameFontBase.colToCode["g"] val ccG = GameFontBase.colToCode["g"]
@@ -16,19 +16,16 @@ class GetAV : ConsoleCommand {
val ccO = GameFontBase.colToCode["o"] val ccO = GameFontBase.colToCode["o"]
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
val error = Error()
try { try {
if (args.size == 1) { if (args.size == 1) {
// print all actorvalue of player // print all actorvalue of player
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.execute("$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.execute("$ccM$elem $ccW= $ccG${av[elem as String]}")
println("[GetAV] $elem = ${av[elem]}") println("[GetAV] $elem = ${av[elem]}")
} }
} }
@@ -38,7 +35,7 @@ class 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.execute("${ccW}player.$ccM${args[1]} $ccW= " +
ccG + ccG +
Terrarum.ingame.player.actorValue[args[1]] + Terrarum.ingame.player.actorValue[args[1]] +
" $ccO" + " $ccO" +
@@ -56,15 +53,15 @@ class 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.execute("$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.execute("$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.execute("$ccM$elem $ccW= $ccG${av[elem as String]}")
println("[GetAV] $elem = ${av[elem]}") println("[GetAV] $elem = ${av[elem]}")
} }
} }
@@ -73,7 +70,7 @@ class 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.execute("$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
@@ -87,11 +84,11 @@ class 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.") Error.execute(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.") Error.execute(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 {
@@ -99,7 +96,7 @@ class GetAV : ConsoleCommand {
} }
} }
catch (e1: IllegalArgumentException) { catch (e1: IllegalArgumentException) {
error.execute("${args[1]}: no actor with this ID.") Error.execute("${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.")
} }
@@ -116,9 +113,8 @@ class GetAV : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo() Echo.execute("${ccW}Get desired ActorValue of specific target.")
echo.execute("${ccW}Get desired ActorValue of specific target.") Echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>")
echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>") Echo.execute("${ccW}blank ID for player")
echo.execute("${ccW}blank ID for player")
} }
} }

View File

@@ -10,7 +10,7 @@ import net.torvald.terrarum.gameactors.Player
/** /**
* Created by minjaesong on 16-02-17. * Created by minjaesong on 16-02-17.
*/ */
class GetFactioning : ConsoleCommand { internal object GetFactioning : ConsoleCommand {
val ccW = GameFontBase.colToCode["w"] val ccW = GameFontBase.colToCode["w"]
val ccG = GameFontBase.colToCode["g"] val ccG = GameFontBase.colToCode["g"]
val ccY = GameFontBase.colToCode["y"] val ccY = GameFontBase.colToCode["y"]
@@ -21,62 +21,62 @@ class GetFactioning : ConsoleCommand {
private val PRINT_INDENTATION = "$ccK --> $ccW" private val PRINT_INDENTATION = "$ccK --> $ccW"
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
val error = Error() val error = Error()
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.execute("$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.execute("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.execute("$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.execute("${ccW}faction $ccM${faction.factionName}")
println("[GetFactioning] faction '${faction.factionName}'") println("[GetFactioning] faction '${faction.factionName}'")
echo.execute("$ccY Amicable") Echo.execute("$ccY Amicable")
println("[GetFactioning] Amicable") println("[GetFactioning] Amicable")
faction.factionAmicable.forEach { s -> faction.factionAmicable.forEach { s ->
echo.execute(PRINT_INDENTATION + s) Echo.execute(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
echo.execute("$ccY Explicit neutral") Echo.execute("$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.execute(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
echo.execute("$ccY Hostile") Echo.execute("$ccY Hostile")
println("[GetFactioning] Hostile") println("[GetFactioning] Hostile")
faction.factionHostile.forEach { s -> faction.factionHostile.forEach { s ->
echo.execute(PRINT_INDENTATION + s) Echo.execute(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
echo.execute("$ccY Fearful") Echo.execute("$ccY Fearful")
println("[GetFactioning] Fearful") println("[GetFactioning] Fearful")
faction.factionFearful.forEach { s -> faction.factionFearful.forEach { s ->
echo.execute(PRINT_INDENTATION + s) Echo.execute(PRINT_INDENTATION + s)
println("[GetFactioning] --> $s") println("[GetFactioning] --> $s")
} }
} }
} }
else { else {
error.execute("The actor is not factionable.") Error.execute("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 @@ class GetFactioning : ConsoleCommand {
} }
else { else {
if (!args[1].isNum()) { if (!args[1].isNum()) {
error.execute("Invalid actor ID input.") Error.execute("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 @@ class GetFactioning : ConsoleCommand {
printOutFactioning(actorID) printOutFactioning(actorID)
} }
catch (e: IllegalArgumentException) { catch (e: IllegalArgumentException) {
error.execute("${args[1]}: no actor with this ID.") Error.execute("${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

@@ -6,9 +6,9 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-22. * Created by minjaesong on 16-01-22.
*/ */
class GetLocale : ConsoleCommand { internal object GetLocale : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo().execute( Echo.execute(
"Locale: " "Locale: "
+ Lang["MENU_LANGUAGE_THIS"] + Lang["MENU_LANGUAGE_THIS"]
+ " (" + " ("
@@ -17,8 +17,8 @@ class GetLocale : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo()
echo.execute("Usage: getlocale") Echo.execute("Usage: getlocale")
echo.execute("Get name of locale currently using.") Echo.execute("Get name of locale currently using.")
} }
} }

View File

@@ -5,14 +5,14 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-03-20. * Created by minjaesong on 16-03-20.
*/ */
class GetTime : ConsoleCommand { internal object GetTime : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
val worldTime = Terrarum.ingame.world.time val worldTime = Terrarum.ingame.world.time
echo.execute(worldTime.getFormattedTime()) Echo.execute(worldTime.getFormattedTime())
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Print current world time in convenient form") Echo.execute("Print current world time in convenient form")
} }
} }

View File

@@ -11,7 +11,7 @@ import java.io.IOException
/** /**
* Created by minjaesong on 16-02-10. * Created by minjaesong on 16-02-10.
*/ */
class GsonTest : ConsoleCommand { internal object GsonTest : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
val avelem = Gson().toJsonTree(Terrarum.ingame.player) val avelem = Gson().toJsonTree(Terrarum.ingame.player)
@@ -27,10 +27,10 @@ class GsonTest : ConsoleCommand {
bufferedWriter.write(jsonString) bufferedWriter.write(jsonString)
bufferedWriter.close() bufferedWriter.close()
Echo().execute("GsonTest: exported to " + args[1] + ".json") Echo.execute("GsonTest: exported to " + args[1] + ".json")
} }
catch (e: IOException) { catch (e: IOException) {
Echo().execute("GsonTest: IOException raised.") Echo.execute("GsonTest: IOException raised.")
e.printStackTrace() e.printStackTrace()
} }
@@ -41,7 +41,7 @@ class GsonTest : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
val echo = Echo()
echo.execute("Usage: gsontest filename-without-extension") Echo.execute("Usage: gsontest filename-without-extension")
} }
} }

View File

@@ -6,21 +6,21 @@ import net.torvald.terrarum.langpack.Lang
/** /**
* Created by minjaesong on 16-03-22. * Created by minjaesong on 16-03-22.
*/ */
class Help : ConsoleCommand { internal object Help : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
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.execute(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.execute(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.execute(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.execute("Prints some utility functions assigned to function row of the keyboard.")
} }
} }

View File

@@ -9,7 +9,7 @@ import net.torvald.terrarum.itemproperties.ItemPropCodex
/** /**
* Created by SKYHi14 on 2016-12-12. * Created by SKYHi14 on 2016-12-12.
*/ */
class Inventory : ConsoleCommand { internal object Inventory : ConsoleCommand {
private var target: ActorInventory = Terrarum.ingame.player.inventory private var target: ActorInventory = Terrarum.ingame.player.inventory
@@ -29,13 +29,13 @@ class Inventory : ConsoleCommand {
private fun listInventory() { private fun listInventory() {
if (target.getTotalUniqueCount() == 0) { if (target.getTotalUniqueCount() == 0) {
Echo().execute("(inventory empty)") Echo.execute("(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") Error.execute("Unexpected zero-amounted item: ID $refId")
} }
Echo().execute("ID $refId${if (amount > 1) " ($amount)" else ""}") Echo.execute("ID $refId${if (amount > 1) " ($amount)" else ""}")
} }
} }
} }
@@ -43,7 +43,7 @@ class 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") Error.execute("Cannot edit inventory of incompatible actor: $actor")
} else { } else {
target = actor.inventory target = actor.inventory
} }
@@ -58,8 +58,8 @@ class Inventory : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: inventory command arguments") Echo.execute("Usage: inventory command arguments")
Echo().execute("Available commands:") Echo.execute("Available commands:")
Echo().execute("list | assign slot | add itemid [amount] | target [actorid]") Echo.execute("list | assign slot | add itemid [amount] | target [actorid]")
} }
} }

View File

@@ -5,15 +5,15 @@ import net.torvald.terrarum.langpack.Lang
/** /**
* Created by minjaesong on 16-07-11. * Created by minjaesong on 16-07-11.
*/ */
class 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.execute("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.execute(Lang[args[1].toUpperCase()])
} }
} }

View File

@@ -7,7 +7,7 @@ import java.io.File
/** /**
* Created by minjaesong on 16-08-02. * Created by minjaesong on 16-08-02.
*/ */
class MusicTest : ConsoleCommand { internal object MusicTest : ConsoleCommand {
var music: Music? = null var music: Music? = null
@@ -39,7 +39,7 @@ class MusicTest : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: musictest filename/in/res/sounds/test") Echo.execute("Usage: musictest filename/in/res/sounds/test")
Echo().execute("musictest stop to stop playback") Echo.execute("musictest stop to stop playback")
} }
} }

View File

@@ -6,12 +6,12 @@ import java.util.*
/** /**
* Created by minjaesong on 16-07-04. * Created by minjaesong on 16-07-04.
*/ */
class 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.execute(Lang["GAME_TIPS_${Random().nextInt(Lang.TIPS_COUNT) + 1}"])
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Prints random tips for game.") Echo.execute("Prints random tips for game.")
} }
} }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
/** /**
* Created by minjaesong on 16-01-15. * Created by minjaesong on 16-01-15.
*/ */
class QuitApp : ConsoleCommand { internal object QuitApp : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
System.exit(1) System.exit(1)

View File

@@ -6,18 +6,18 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-06-16. * Created by minjaesong on 16-06-16.
*/ */
class Seed : ConsoleCommand { internal object Seed : ConsoleCommand {
val ccG = GameFontBase.colToCode["g"] val ccG = GameFontBase.colToCode["g"]
val ccW = GameFontBase.colToCode["w"] val ccW = GameFontBase.colToCode["w"]
val ccY = GameFontBase.colToCode["y"] val ccY = GameFontBase.colToCode["y"]
// tsalagi // tsalagi
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo().execute("Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}") Echo.execute("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.execute("prints out the generator seed of the current game.")
} }
} }

View File

@@ -7,7 +7,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-15. * Created by minjaesong on 16-01-15.
*/ */
internal class SetAV : ConsoleCommand { internal object SetAV : ConsoleCommand {
val ccW = GameFontBase.colToCode["w"] val ccW = GameFontBase.colToCode["w"]
val ccG = GameFontBase.colToCode["g"] val ccG = GameFontBase.colToCode["g"]
@@ -16,13 +16,13 @@ internal class SetAV : ConsoleCommand {
val ccM = GameFontBase.colToCode["m"] val ccM = GameFontBase.colToCode["m"]
override fun printUsage() { override fun printUsage() {
val echo = Echo()
echo.execute("${ccW}Set actor value of specific target to desired value.") Echo.execute("${ccW}Set actor value of specific target to desired value.")
echo.execute("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>") Echo.execute("${ccW}Usage: ${ccY}setav ${ccG}(id) <av> <val>")
echo.execute("${ccW}blank ID for player. Data type will be inferred automatically.") Echo.execute("${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.execute("${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.execute("${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.execute("${ccW}Use ${ccG}__true ${ccW}and ${ccG}__false ${ccW}for boolean value.")
} }
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
@@ -53,7 +53,7 @@ internal class SetAV : ConsoleCommand {
return `val` return `val`
} }
val echo = Echo()
val error = Error() val error = Error()
// setav <id, or blank for player> <av> <val> // setav <id, or blank for player> <av> <val>
@@ -65,13 +65,13 @@ internal class 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.") Error.execute("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.execute("${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 class 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.") Error.execute("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.execute("${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.") Error.execute("${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

@@ -7,7 +7,7 @@ import net.torvald.terrarum.ui.Notification
/** /**
* Created by minjaesong on 16-01-23. * Created by minjaesong on 16-01-23.
*/ */
class SetBulletin : ConsoleCommand { internal object SetBulletin : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val testMsg = arrayOf( val testMsg = arrayOf(
Lang["ERROR_SAVE_CORRUPTED"], Lang["ERROR_SAVE_CORRUPTED"],

View File

@@ -6,7 +6,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-02-17. * Created by minjaesong on 16-02-17.
*/ */
class SetGlobalLightOverride : ConsoleCommand { internal object SetGlobalLightOverride : ConsoleCommand {
var lightOverride = false var lightOverride = false
private set private set
@@ -23,10 +23,10 @@ class SetGlobalLightOverride : ConsoleCommand {
Terrarum.ingame.world.globalLight = GL Terrarum.ingame.world.globalLight = GL
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo().execute("Wrong number input.") Echo.execute("Wrong number input.")
} }
catch (e1: IllegalArgumentException) { catch (e1: IllegalArgumentException) {
Echo().execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel") Echo.execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel")
} }
} }
@@ -35,7 +35,7 @@ class 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.execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
} }
else { else {
Terrarum.ingame.world.globalLight = GL Terrarum.ingame.world.globalLight = GL
@@ -45,7 +45,7 @@ class SetGlobalLightOverride : ConsoleCommand {
if (args[1].toLowerCase() == "none") if (args[1].toLowerCase() == "none")
lightOverride = false lightOverride = false
else else
Echo().execute("Wrong number input.") Echo.execute("Wrong number input.")
} }
} }
@@ -55,6 +55,6 @@ class SetGlobalLightOverride : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: setgl [raw_value|r g b|“none”]") Echo.execute("Usage: setgl [raw_value|r g b|“none”]")
} }
} }

View File

@@ -11,25 +11,25 @@ import java.io.IOException
/** /**
* Created by minjaesong on 16-01-25. * Created by minjaesong on 16-01-25.
*/ */
class SetLocale : ConsoleCommand { internal object SetLocale : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
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.execute("Set locale to '" + Terrarum.gameLocale + "'.")
} }
catch (e: IOException) { catch (e: IOException) {
Echo().execute("could not read lang file.") Echo.execute("could not read lang file.")
Terrarum.gameLocale = prevLocale Terrarum.gameLocale = prevLocale
} }
} }
else if (args.size == 1) { else if (args.size == 1) {
val echo = Echo()
echo.execute("Locales:")
Lang.languageList.forEach { echo.execute("--> $it") } Echo.execute("Locales:")
Lang.languageList.forEach { Echo.execute("--> $it") }
} }
else { else {
printUsage() printUsage()
@@ -37,6 +37,6 @@ class SetLocale : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: setlocale [locale]") Echo.execute("Usage: setlocale [locale]")
} }
} }

View File

@@ -6,14 +6,14 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-03-20. * Created by minjaesong on 16-03-20.
*/ */
class SetTime : ConsoleCommand { internal object SetTime : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
val timeToSet = WorldTime.parseTime(args[1]) val timeToSet = WorldTime.parseTime(args[1])
Terrarum.ingame.world.time.setTime(timeToSet) Terrarum.ingame.world.time.setTime(timeToSet)
Echo().execute("Set time to ${Terrarum.ingame.world.time.elapsedSeconds} " + Echo.execute("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 @@ class SetTime : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("usage: settime <39201-in sec or 13h32-in hour>") Echo.execute("usage: settime <39201-in sec or 13h32-in hour>")
} }
} }

View File

@@ -5,20 +5,20 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-03-20. * Created by minjaesong on 16-03-20.
*/ */
class SetTimeDelta : ConsoleCommand { internal object SetTimeDelta : ConsoleCommand {
val HARD_LIMIT = 60 val HARD_LIMIT = 60
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.") Error.execute("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.execute("時間よ止まれ!ザ・ワルド!!")
else else
Echo().execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}") Echo.execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
} }
else { else {
printUsage() printUsage()
@@ -26,6 +26,6 @@ class SetTimeDelta : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("usage: settimedelta <int>") Echo.execute("usage: settimedelta <int>")
} }
} }

View File

@@ -9,7 +9,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-03-05. * Created by minjaesong on 16-03-05.
*/ */
class SpawnPhysTestBall : ConsoleCommand { internal object SpawnPhysTestBall : ConsoleCommand {
@Throws(Exception::class) @Throws(Exception::class)
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
@@ -33,6 +33,6 @@ class SpawnPhysTestBall : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("usage: spawnball [elasticity]") Echo.execute("usage: spawnball [elasticity]")
} }
} }

View File

@@ -7,7 +7,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-24. * Created by minjaesong on 16-01-24.
*/ */
class TeleportPlayer : ConsoleCommand { internal object TeleportPlayer : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size != 3) { if (args.size != 3) {
@@ -22,7 +22,7 @@ class 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.execute("Wrong number input.")
return return
} }
@@ -31,6 +31,6 @@ class TeleportPlayer : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: teleport [x-tile] [y-tile]") Echo.execute("Usage: teleport [x-tile] [y-tile]")
} }
} }

View File

@@ -5,7 +5,7 @@ import net.torvald.terrarum.mapdrawer.LightmapRenderer
/** /**
* Created by minjaesong on 16-09-07. * Created by minjaesong on 16-09-07.
*/ */
class TestGetLight : ConsoleCommand { internal object TestGetLight : ConsoleCommand {
/** /**
* Args 0: command given * Args 0: command given
* Args 1: first argument * Args 1: first argument
@@ -16,7 +16,7 @@ class TestGetLight : ConsoleCommand {
val x = args[1].toInt() val x = args[1].toInt()
val y = args[2].toInt() val y = args[2].toInt()
val l = LightmapRenderer.getLightRawPos(16, 16) val l = LightmapRenderer.getLightRawPos(16, 16)
EchoConsole().execute(l.toString()) EchoConsole.execute(l.toString())
} }
override fun printUsage() { override fun printUsage() {

View File

@@ -6,15 +6,15 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-19. * Created by minjaesong on 16-01-19.
*/ */
class ToggleNoClip : ConsoleCommand { internal object ToggleNoClip : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
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.execute("Set no-clip status to " + (!status).toString())
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("toggle no-clip status of player") Echo.execute("toggle no-clip status of player")
} }
} }

View File

@@ -6,14 +6,14 @@ import net.torvald.terrarum.langpack.Lang
/** /**
* Created by minjaesong on 16-04-23. * Created by minjaesong on 16-04-23.
*/ */
class Version : ConsoleCommand { internal object Version : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
val echo = Echo()
echo.execute("${Terrarum.NAME} ${Terrarum.VERSION_STRING}") Echo.execute("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
echo.execute("Polyglot language pack version ${Lang.POLYGLOT_VERSION}") Echo.execute("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Prints out current version of the application") Echo.execute("Prints out current version of the application")
} }
} }

View File

@@ -5,7 +5,7 @@ import net.torvald.terrarum.Terrarum
/** /**
* Created by minjaesong on 16-01-25. * Created by minjaesong on 16-01-25.
*/ */
class Zoom : ConsoleCommand { internal object Zoom : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
@@ -14,7 +14,7 @@ class Zoom : ConsoleCommand {
zoom = args[1].toFloat() zoom = args[1].toFloat()
} }
catch (e: NumberFormatException) { catch (e: NumberFormatException) {
Echo().execute("Wrong number input.") Echo.execute("Wrong number input.")
return return
} }
@@ -29,7 +29,7 @@ class Zoom : ConsoleCommand {
System.gc() System.gc()
Echo().execute("Set screen zoom to " + zoom.toString()) Echo.execute("Set screen zoom to " + zoom.toString())
} }
else { else {
printUsage() printUsage()
@@ -37,6 +37,6 @@ class Zoom : ConsoleCommand {
} }
override fun printUsage() { override fun printUsage() {
Echo().execute("Usage: zoom [zoom]") Echo.execute("Usage: zoom [zoom]")
} }
} }

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
import net.torvald.gadgets.HistoryArray import net.torvald.gadgets.HistoryArray
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.Authenticator
import net.torvald.terrarum.console.CommandInterpreter import net.torvald.terrarum.console.CommandInterpreter
import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.gamecontroller.Key
import org.newdawn.slick.Color import org.newdawn.slick.Color
@@ -171,7 +172,7 @@ class ConsoleWindow : UICanvas, KeyboardControlled {
commandHistory = HistoryArray<String>(COMMAND_HISTORY_MAX) commandHistory = HistoryArray<String>(COMMAND_HISTORY_MAX)
commandInputPool = StringBuilder() commandInputPool = StringBuilder()
if (Terrarum.ingame.auth.b()) { if (Authenticator.b()) {
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}") sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"]) sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
} }