mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
Object-ified console commands (singleton!)
Former-commit-id: d04fc939a659fc4a6b952d64894bd28edf97bc38 Former-commit-id: 6c20526f3bdda2d9d08dc156b3b0fe271e89bffb
This commit is contained in:
@@ -83,8 +83,6 @@ constructor() : BasicGameState() {
|
||||
|
||||
private val CORES = ThreadPool.POOL_SIZE
|
||||
|
||||
val auth = Authenticator()
|
||||
|
||||
val KEY_LIGHTMAP_RENDER = Key.F7
|
||||
val KEY_LIGHTMAP_SMOOTH = Key.F8
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.apache.commons.codec.digest.DigestUtils
|
||||
/**
|
||||
* Created by minjaesong on 16-02-19.
|
||||
*/
|
||||
class Authenticator : ConsoleCommand {
|
||||
internal object Authenticator : ConsoleCommand {
|
||||
|
||||
private var a = false
|
||||
|
||||
@@ -19,7 +19,7 @@ class Authenticator : ConsoleCommand {
|
||||
if ("65b9aa150332ed7096134efb20220e5ebec04d4dbe1c537ff3816f68c2391c1c".equals(hashedPwd, ignoreCase = true)) {
|
||||
// aryll
|
||||
val msg = if (a) "Locked" else "Authenticated"
|
||||
Echo().execute(msg)
|
||||
Echo.execute(msg)
|
||||
println("[Authenticator] " + msg)
|
||||
a = !a
|
||||
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).reset()
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.nio.file.Files
|
||||
/**
|
||||
* Created by minjaesong on 16-03-07.
|
||||
*/
|
||||
class Batch : ConsoleCommand {
|
||||
internal object Batch : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
@@ -19,6 +19,6 @@ class Batch : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: batch path/to/batch.txt")
|
||||
Echo.execute("Usage: batch path/to/batch.txt")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,26 +7,24 @@ import java.nio.file.Files
|
||||
/**
|
||||
* Created by minjaesong on 16-02-10.
|
||||
*/
|
||||
class CatStdout : ConsoleCommand {
|
||||
internal object CatStdout : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
val echo = Echo()
|
||||
|
||||
if (args.size == 1) {
|
||||
printUsage()
|
||||
return
|
||||
}
|
||||
|
||||
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) {
|
||||
echo.execute("CatStdout: could not read file -- IOException")
|
||||
Echo.execute("CatStdout: could not read file -- IOException")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("usage: cat 'path/to/text/file")
|
||||
Echo.execute("usage: cat 'path/to/text/file")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Formatter
|
||||
/**
|
||||
* Created by minjaesong on 16-01-16.
|
||||
*/
|
||||
class CodexEdictis : ConsoleCommand {
|
||||
internal object CodexEdictis : ConsoleCommand {
|
||||
|
||||
val ccW = GameFontBase.colToCode["o"]
|
||||
|
||||
@@ -25,24 +25,22 @@ class CodexEdictis : ConsoleCommand {
|
||||
val sb = StringBuilder()
|
||||
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() {
|
||||
val echo = Echo()
|
||||
echo.execute("Usage: codex (command)")
|
||||
echo.execute("shows how to use 'command'")
|
||||
echo.execute("leave blank to get list of available commands")
|
||||
Echo.execute("Usage: codex (command)")
|
||||
Echo.execute("shows how to use 'command'")
|
||||
Echo.execute("leave blank to get list of available commands")
|
||||
}
|
||||
|
||||
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 ->
|
||||
echo.execute("$ccW• " + name)
|
||||
Echo.execute("$ccW• " + name)
|
||||
cmd.printUsage()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,44 +10,44 @@ import java.util.HashMap
|
||||
object CommandDict {
|
||||
|
||||
internal var dict: HashMap<String, ConsoleCommand> = hashMapOf(
|
||||
Pair("echo", Echo()),
|
||||
Pair("error", Error()),
|
||||
Pair("setav", SetAV()),
|
||||
Pair("qqq", QuitApp()),
|
||||
Pair("codex", CodexEdictis()),
|
||||
Pair("export", ExportMap()),
|
||||
Pair("gc", ForceGC()),
|
||||
Pair("getav", GetAV()),
|
||||
Pair("getlocale", GetLocale()),
|
||||
Pair("togglenoclip", ToggleNoClip()),
|
||||
Pair("nc", ToggleNoClip()),
|
||||
Pair("setlocale", SetLocale()),
|
||||
Pair("zoom", Zoom()),
|
||||
Pair("teleport", TeleportPlayer()),
|
||||
Pair("tp", TeleportPlayer()),
|
||||
Pair("cat", CatStdout()),
|
||||
Pair("exportav", ExportAV()),
|
||||
Pair("setgl", SetGlobalLightOverride()),
|
||||
Pair("getfaction", GetFactioning()),
|
||||
Pair("auth", Terrarum.ingame.auth),
|
||||
Pair("spawnball", SpawnPhysTestBall()),
|
||||
Pair("batch", Batch()),
|
||||
Pair("settime", SetTime()),
|
||||
Pair("gettime", GetTime()),
|
||||
Pair("settimedelta", SetTimeDelta()),
|
||||
Pair("help", Help()),
|
||||
Pair("version", Version()),
|
||||
Pair("seed", Seed()),
|
||||
Pair("testgetlight", TestGetLight()),
|
||||
Pair("println", EchoConsole()),
|
||||
Pair("inventory", Inventory()),
|
||||
Pair("echo", Echo),
|
||||
Pair("error", Error),
|
||||
Pair("setav", SetAV),
|
||||
Pair("qqq", QuitApp),
|
||||
Pair("codex", CodexEdictis),
|
||||
Pair("export", ExportMap),
|
||||
Pair("gc", ForceGC),
|
||||
Pair("getav", GetAV),
|
||||
Pair("getlocale", GetLocale),
|
||||
Pair("togglenoclip", ToggleNoClip),
|
||||
Pair("nc", ToggleNoClip),
|
||||
Pair("setlocale", SetLocale),
|
||||
Pair("zoom", Zoom),
|
||||
Pair("teleport", TeleportPlayer),
|
||||
Pair("tp", TeleportPlayer),
|
||||
Pair("cat", CatStdout),
|
||||
Pair("exportav", ExportAV),
|
||||
Pair("setgl", SetGlobalLightOverride),
|
||||
Pair("getfaction", GetFactioning),
|
||||
Pair("auth", Authenticator),
|
||||
Pair("spawnball", SpawnPhysTestBall),
|
||||
Pair("batch", Batch),
|
||||
Pair("settime", SetTime),
|
||||
Pair("gettime", GetTime),
|
||||
Pair("settimedelta", SetTimeDelta),
|
||||
Pair("help", Help),
|
||||
Pair("version", Version),
|
||||
Pair("seed", Seed),
|
||||
Pair("testgetlight", TestGetLight),
|
||||
Pair("println", EchoConsole),
|
||||
Pair("inventory", Inventory),
|
||||
|
||||
// Test codes
|
||||
Pair("bulletintest", SetBulletin()),
|
||||
Pair("gsontest", GsonTest()),
|
||||
Pair("tips", PrintRandomTips()),
|
||||
Pair("langtest", LangTest()),
|
||||
Pair("musictest", MusicTest())
|
||||
Pair("bulletintest", SetBulletin),
|
||||
Pair("gsontest", GsonTest),
|
||||
Pair("tips", PrintRandomTips),
|
||||
Pair("langtest", LangTest),
|
||||
Pair("musictest", MusicTest)
|
||||
)
|
||||
|
||||
operator fun get(commandName: String): ConsoleCommand {
|
||||
|
||||
@@ -33,7 +33,7 @@ object CommandInterpreter {
|
||||
|
||||
fun execute(command: String) {
|
||||
val cmd: Array<CommandInput?> = parse(command)
|
||||
val echo = Echo()
|
||||
|
||||
val error = Error()
|
||||
|
||||
for (single_command in cmd) {
|
||||
@@ -46,7 +46,7 @@ object CommandInterpreter {
|
||||
commandObj = CommandDict[single_command.name.toLowerCase()]
|
||||
}
|
||||
else {
|
||||
if (Terrarum.ingame.auth.b()) {
|
||||
if (Authenticator.b()) {
|
||||
commandObj = CommandDict[single_command.name.toLowerCase()]
|
||||
}
|
||||
else {
|
||||
@@ -59,7 +59,7 @@ object CommandInterpreter {
|
||||
|
||||
}
|
||||
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'")
|
||||
try {
|
||||
if (commandObj != null) {
|
||||
@@ -73,7 +73,7 @@ object CommandInterpreter {
|
||||
catch (e: Exception) {
|
||||
System.err.print("[CommandInterpreter] ")
|
||||
e.printStackTrace()
|
||||
error.execute(Lang["ERROR_GENERIC_TEXT"])
|
||||
Error.execute(Lang["ERROR_GENERIC_TEXT"])
|
||||
}
|
||||
|
||||
}
|
||||
@@ -115,7 +115,7 @@ object CommandInterpreter {
|
||||
val sb = StringBuilder()
|
||||
val formatter = Formatter(sb)
|
||||
|
||||
Error().execute(
|
||||
Error.execute(
|
||||
formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], cmdname).toString())
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Arrays
|
||||
/**
|
||||
* Created by minjaesong on 16-01-16.
|
||||
*/
|
||||
internal class Echo : ConsoleCommand {
|
||||
internal object Echo : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]})
|
||||
argsWoHeader.forEach { execute(it) }
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
|
||||
/**
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
class EchoConsole : ConsoleCommand {
|
||||
internal object EchoConsole : ConsoleCommand {
|
||||
/**
|
||||
* Args 0: command given
|
||||
* Args 1: first argument
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.ui.ConsoleWindow
|
||||
/**
|
||||
* Created by minjaesong on 16-04-25.
|
||||
*/
|
||||
class Error : ConsoleCommand {
|
||||
internal object Error : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]})
|
||||
argsWoHeader.forEach { execute(it) }
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.IOException
|
||||
/**
|
||||
* Created by minjaesong on 16-02-10.
|
||||
*/
|
||||
class ExportAV : ConsoleCommand {
|
||||
internal object ExportAV : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
@@ -16,10 +16,10 @@ class ExportAV : ConsoleCommand {
|
||||
Terrarum.ingame.player.actorValue,
|
||||
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) {
|
||||
Echo().execute("ExportAV: IOException raised.")
|
||||
Echo.execute("ExportAV: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
@@ -30,9 +30,8 @@ class ExportAV : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Export ActorValue as JSON format.")
|
||||
echo.execute("Usage: exportav (id) filename-without-extension")
|
||||
echo.execute("blank ID for player")
|
||||
Echo.execute("Export ActorValue as JSON format.")
|
||||
Echo.execute("Usage: exportav (id) filename-without-extension")
|
||||
Echo.execute("blank ID for player")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.HashMap
|
||||
/**
|
||||
* Created by minjaesong on 16-01-17.
|
||||
*/
|
||||
class ExportMap : ConsoleCommand {
|
||||
internal object ExportMap : ConsoleCommand {
|
||||
|
||||
//private var mapData: ByteArray? = null
|
||||
// private var mapDataPointer = 0
|
||||
@@ -45,11 +45,11 @@ class ExportMap : ConsoleCommand {
|
||||
try {
|
||||
RasterWriter.writePNG_RGB(
|
||||
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) {
|
||||
Echo().execute("ExportMap: IOException raised.")
|
||||
Echo.execute("ExportMap: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ class ExportMap : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Usage: export <name>")
|
||||
echo.execute("Exports current map into echo image.")
|
||||
echo.execute("The image can be found at %adddata%/terrarum/Exports")
|
||||
|
||||
Echo.execute("Usage: export <name>")
|
||||
Echo.execute("Exports current map into echo image.")
|
||||
Echo.execute("The image can be found at %adddata%/terrarum/Exports")
|
||||
}
|
||||
|
||||
private fun buildColorTable() {
|
||||
|
||||
@@ -3,13 +3,13 @@ package net.torvald.terrarum.console
|
||||
/**
|
||||
* Created by minjaesong on 16-01-18.
|
||||
*/
|
||||
class ForceGC : ConsoleCommand {
|
||||
internal object ForceGC : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
System.gc()
|
||||
Echo().execute("Invoked System.gc")
|
||||
Echo.execute("Invoked System.gc")
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Invoke garbage collection of JVM.")
|
||||
Echo.execute("Invoke garbage collection of JVM.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
class GetAV : ConsoleCommand {
|
||||
internal object GetAV : ConsoleCommand {
|
||||
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
@@ -16,19 +16,16 @@ class GetAV : ConsoleCommand {
|
||||
val ccO = GameFontBase.colToCode["o"]
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
val error = Error()
|
||||
|
||||
try {
|
||||
if (args.size == 1) {
|
||||
// print all actorvalue of player
|
||||
val av = Terrarum.ingame.player.actorValue
|
||||
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' ==")
|
||||
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]}")
|
||||
}
|
||||
}
|
||||
@@ -38,7 +35,7 @@ class GetAV : ConsoleCommand {
|
||||
else if (args.size == 2) {
|
||||
// check if args[1] is number or not
|
||||
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 +
|
||||
Terrarum.ingame.player.actorValue[args[1]] +
|
||||
" $ccO" +
|
||||
@@ -56,15 +53,15 @@ class GetAV : ConsoleCommand {
|
||||
val av = actor.actorValue
|
||||
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' ==")
|
||||
if (keyset.size == 0) {
|
||||
echo.execute("$ccK(nothing)")
|
||||
Echo.execute("$ccK(nothing)")
|
||||
println("[GetAV] (nothing)")
|
||||
}
|
||||
else {
|
||||
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]}")
|
||||
}
|
||||
}
|
||||
@@ -73,7 +70,7 @@ class GetAV : ConsoleCommand {
|
||||
else if (args.size == 3) {
|
||||
val id = args[1].toInt()
|
||||
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] +
|
||||
" $ccO" +
|
||||
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
@@ -87,11 +84,11 @@ class GetAV : ConsoleCommand {
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
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.")
|
||||
}
|
||||
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.")
|
||||
}
|
||||
else {
|
||||
@@ -99,7 +96,7 @@ class GetAV : ConsoleCommand {
|
||||
}
|
||||
}
|
||||
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.")
|
||||
}
|
||||
|
||||
@@ -116,9 +113,8 @@ class GetAV : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("${ccW}Get desired ActorValue of specific target.")
|
||||
echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>")
|
||||
echo.execute("${ccW}blank ID for player")
|
||||
Echo.execute("${ccW}Get desired ActorValue of specific target.")
|
||||
Echo.execute("${ccW}Usage: ${ccY}getav ${ccG}(id) <av>")
|
||||
Echo.execute("${ccW}blank ID for player")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.gameactors.Player
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
*/
|
||||
class GetFactioning : ConsoleCommand {
|
||||
internal object GetFactioning : ConsoleCommand {
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
val ccY = GameFontBase.colToCode["y"]
|
||||
@@ -21,62 +21,62 @@ class GetFactioning : ConsoleCommand {
|
||||
private val PRINT_INDENTATION = "$ccK --> $ccW"
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
|
||||
val error = Error()
|
||||
|
||||
fun printOutFactioning(id: Int) {
|
||||
val a = Terrarum.ingame.getActorByID(id)
|
||||
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()}' ==")
|
||||
|
||||
// get all factioning data of player
|
||||
val factionSet = a.faction
|
||||
|
||||
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.")
|
||||
return
|
||||
}
|
||||
|
||||
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.")
|
||||
|
||||
for (faction in factionSet) {
|
||||
echo.execute("${ccW}faction $ccM${faction.factionName}")
|
||||
Echo.execute("${ccW}faction $ccM${faction.factionName}")
|
||||
println("[GetFactioning] faction '${faction.factionName}'")
|
||||
echo.execute("$ccY Amicable")
|
||||
Echo.execute("$ccY Amicable")
|
||||
println("[GetFactioning] Amicable")
|
||||
faction.factionAmicable.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
Echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Explicit neutral")
|
||||
Echo.execute("$ccY Explicit neutral")
|
||||
println("[GetFactioning] Explicit neutral")
|
||||
faction.factionNeutral.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
Echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Hostile")
|
||||
Echo.execute("$ccY Hostile")
|
||||
println("[GetFactioning] Hostile")
|
||||
faction.factionHostile.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
Echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
|
||||
echo.execute("$ccY Fearful")
|
||||
Echo.execute("$ccY Fearful")
|
||||
println("[GetFactioning] Fearful")
|
||||
faction.factionFearful.forEach { s ->
|
||||
echo.execute(PRINT_INDENTATION + s)
|
||||
Echo.execute(PRINT_INDENTATION + s)
|
||||
println("[GetFactioning] --> $s")
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error.execute("The actor is not factionable.")
|
||||
Error.execute("The actor is not factionable.")
|
||||
System.err.println("[GetFactioning] The actor is not factionable.")
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class GetFactioning : ConsoleCommand {
|
||||
}
|
||||
else {
|
||||
if (!args[1].isNum()) {
|
||||
error.execute("Invalid actor ID input.")
|
||||
Error.execute("Invalid actor ID input.")
|
||||
System.err.println("[GetFactioning] Invalid actor ID input.")
|
||||
return
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class GetFactioning : ConsoleCommand {
|
||||
printOutFactioning(actorID)
|
||||
}
|
||||
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.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-22.
|
||||
*/
|
||||
class GetLocale : ConsoleCommand {
|
||||
internal object GetLocale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
Echo().execute(
|
||||
Echo.execute(
|
||||
"Locale: "
|
||||
+ Lang["MENU_LANGUAGE_THIS"]
|
||||
+ " ("
|
||||
@@ -17,8 +17,8 @@ class GetLocale : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Usage: getlocale")
|
||||
echo.execute("Get name of locale currently using.")
|
||||
|
||||
Echo.execute("Usage: getlocale")
|
||||
Echo.execute("Get name of locale currently using.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
*/
|
||||
class GetTime : ConsoleCommand {
|
||||
internal object GetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
|
||||
val worldTime = Terrarum.ingame.world.time
|
||||
echo.execute(worldTime.getFormattedTime())
|
||||
Echo.execute(worldTime.getFormattedTime())
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Print current world time in convenient form")
|
||||
Echo.execute("Print current world time in convenient form")
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.io.IOException
|
||||
/**
|
||||
* Created by minjaesong on 16-02-10.
|
||||
*/
|
||||
class GsonTest : ConsoleCommand {
|
||||
internal object GsonTest : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val avelem = Gson().toJsonTree(Terrarum.ingame.player)
|
||||
@@ -27,10 +27,10 @@ class GsonTest : ConsoleCommand {
|
||||
bufferedWriter.write(jsonString)
|
||||
bufferedWriter.close()
|
||||
|
||||
Echo().execute("GsonTest: exported to " + args[1] + ".json")
|
||||
Echo.execute("GsonTest: exported to " + args[1] + ".json")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo().execute("GsonTest: IOException raised.")
|
||||
Echo.execute("GsonTest: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class GsonTest : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
echo.execute("Usage: gsontest filename-without-extension")
|
||||
|
||||
Echo.execute("Usage: gsontest filename-without-extension")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ import net.torvald.terrarum.langpack.Lang
|
||||
/**
|
||||
* Created by minjaesong on 16-03-22.
|
||||
*/
|
||||
class Help : ConsoleCommand {
|
||||
internal object Help : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
|
||||
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") {
|
||||
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 {
|
||||
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() {
|
||||
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.")
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.itemproperties.ItemPropCodex
|
||||
/**
|
||||
* Created by SKYHi14 on 2016-12-12.
|
||||
*/
|
||||
class Inventory : ConsoleCommand {
|
||||
internal object Inventory : ConsoleCommand {
|
||||
|
||||
private var target: ActorInventory = Terrarum.ingame.player.inventory
|
||||
|
||||
@@ -29,13 +29,13 @@ class Inventory : ConsoleCommand {
|
||||
|
||||
private fun listInventory() {
|
||||
if (target.getTotalUniqueCount() == 0) {
|
||||
Echo().execute("(inventory empty)")
|
||||
Echo.execute("(inventory empty)")
|
||||
} else {
|
||||
target.forEach { refId, amount ->
|
||||
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) {
|
||||
val actor = Terrarum.ingame.getActorByID(actorRefId)
|
||||
if (actor !is Pocketed) {
|
||||
Error().execute("Cannot edit inventory of incompatible actor: $actor")
|
||||
Error.execute("Cannot edit inventory of incompatible actor: $actor")
|
||||
} else {
|
||||
target = actor.inventory
|
||||
}
|
||||
@@ -58,8 +58,8 @@ class Inventory : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: inventory command arguments")
|
||||
Echo().execute("Available commands:")
|
||||
Echo().execute("list | assign slot | add itemid [amount] | target [actorid]")
|
||||
Echo.execute("Usage: inventory command arguments")
|
||||
Echo.execute("Available commands:")
|
||||
Echo.execute("list | assign slot | add itemid [amount] | target [actorid]")
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,15 @@ import net.torvald.terrarum.langpack.Lang
|
||||
/**
|
||||
* Created by minjaesong on 16-07-11.
|
||||
*/
|
||||
class LangTest : ConsoleCommand {
|
||||
internal object LangTest : ConsoleCommand {
|
||||
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>) {
|
||||
if (args.size < 2)
|
||||
printUsage()
|
||||
else
|
||||
Echo().execute(Lang[args[1].toUpperCase()])
|
||||
Echo.execute(Lang[args[1].toUpperCase()])
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import java.io.File
|
||||
/**
|
||||
* Created by minjaesong on 16-08-02.
|
||||
*/
|
||||
class MusicTest : ConsoleCommand {
|
||||
internal object MusicTest : ConsoleCommand {
|
||||
|
||||
var music: Music? = null
|
||||
|
||||
@@ -39,7 +39,7 @@ class MusicTest : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: musictest filename/in/res/sounds/test")
|
||||
Echo().execute("musictest stop to stop playback")
|
||||
Echo.execute("Usage: musictest filename/in/res/sounds/test")
|
||||
Echo.execute("musictest stop to stop playback")
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import java.util.*
|
||||
/**
|
||||
* Created by minjaesong on 16-07-04.
|
||||
*/
|
||||
class PrintRandomTips : ConsoleCommand {
|
||||
internal object PrintRandomTips : ConsoleCommand {
|
||||
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() {
|
||||
Echo().execute("Prints random tips for game.")
|
||||
Echo.execute("Prints random tips for game.")
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
*/
|
||||
class QuitApp : ConsoleCommand {
|
||||
internal object QuitApp : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
System.exit(1)
|
||||
|
||||
@@ -6,18 +6,18 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-06-16.
|
||||
*/
|
||||
class Seed : ConsoleCommand {
|
||||
internal object Seed : ConsoleCommand {
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccY = GameFontBase.colToCode["y"]
|
||||
// tsalagi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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.")
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
*/
|
||||
internal class SetAV : ConsoleCommand {
|
||||
internal object SetAV : ConsoleCommand {
|
||||
|
||||
val ccW = GameFontBase.colToCode["w"]
|
||||
val ccG = GameFontBase.colToCode["g"]
|
||||
@@ -16,13 +16,13 @@ internal class SetAV : ConsoleCommand {
|
||||
val ccM = GameFontBase.colToCode["m"]
|
||||
|
||||
override fun printUsage() {
|
||||
val echo = Echo()
|
||||
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}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}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}Set actor value of specific target to desired value.")
|
||||
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("${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("${ccW}Use ${ccG}__true ${ccW}and ${ccG}__false ${ccW}for boolean value.")
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
@@ -53,7 +53,7 @@ internal class SetAV : ConsoleCommand {
|
||||
return `val`
|
||||
}
|
||||
|
||||
val echo = Echo()
|
||||
|
||||
val error = Error()
|
||||
|
||||
// setav <id, or blank for player> <av> <val>
|
||||
@@ -65,13 +65,13 @@ internal class SetAV : ConsoleCommand {
|
||||
|
||||
// check if av is number
|
||||
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.")
|
||||
return
|
||||
}
|
||||
|
||||
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`'.")
|
||||
}
|
||||
else if (args.size == 4) {
|
||||
@@ -82,18 +82,18 @@ internal class SetAV : ConsoleCommand {
|
||||
|
||||
// check if av is number
|
||||
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.")
|
||||
return
|
||||
}
|
||||
|
||||
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`'.")
|
||||
}
|
||||
catch (e: IllegalArgumentException) {
|
||||
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.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.ui.Notification
|
||||
/**
|
||||
* Created by minjaesong on 16-01-23.
|
||||
*/
|
||||
class SetBulletin : ConsoleCommand {
|
||||
internal object SetBulletin : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val testMsg = arrayOf(
|
||||
Lang["ERROR_SAVE_CORRUPTED"],
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
*/
|
||||
class SetGlobalLightOverride : ConsoleCommand {
|
||||
internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
|
||||
var lightOverride = false
|
||||
private set
|
||||
@@ -23,10 +23,10 @@ class SetGlobalLightOverride : ConsoleCommand {
|
||||
Terrarum.ingame.world.globalLight = GL
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
Echo().execute("Wrong number input.")
|
||||
Echo.execute("Wrong number input.")
|
||||
}
|
||||
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()
|
||||
|
||||
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 {
|
||||
Terrarum.ingame.world.globalLight = GL
|
||||
@@ -45,7 +45,7 @@ class SetGlobalLightOverride : ConsoleCommand {
|
||||
if (args[1].toLowerCase() == "none")
|
||||
lightOverride = false
|
||||
else
|
||||
Echo().execute("Wrong number input.")
|
||||
Echo.execute("Wrong number input.")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,6 +55,6 @@ class SetGlobalLightOverride : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: setgl [raw_value|r g b|“none”]")
|
||||
Echo.execute("Usage: setgl [raw_value|r g b|“none”]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,25 +11,25 @@ import java.io.IOException
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
class SetLocale : ConsoleCommand {
|
||||
internal object SetLocale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val prevLocale = Terrarum.gameLocale
|
||||
Terrarum.gameLocale = args[1]
|
||||
try {
|
||||
Echo().execute("Set locale to '" + Terrarum.gameLocale + "'.")
|
||||
Echo.execute("Set locale to '" + Terrarum.gameLocale + "'.")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo().execute("could not read lang file.")
|
||||
Echo.execute("could not read lang file.")
|
||||
Terrarum.gameLocale = prevLocale
|
||||
}
|
||||
|
||||
}
|
||||
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 {
|
||||
printUsage()
|
||||
@@ -37,6 +37,6 @@ class SetLocale : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: setlocale [locale]")
|
||||
Echo.execute("Usage: setlocale [locale]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
*/
|
||||
class SetTime : ConsoleCommand {
|
||||
internal object SetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val timeToSet = WorldTime.parseTime(args[1])
|
||||
|
||||
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)})")
|
||||
}
|
||||
else {
|
||||
@@ -26,6 +26,6 @@ class SetTime : ConsoleCommand {
|
||||
}
|
||||
|
||||
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>")
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,20 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
*/
|
||||
class SetTimeDelta : ConsoleCommand {
|
||||
internal object SetTimeDelta : ConsoleCommand {
|
||||
|
||||
val HARD_LIMIT = 60
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
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())
|
||||
if (Terrarum.ingame.world.time.timeDelta == 0)
|
||||
Echo().execute("時間よ止まれ!ザ・ワルド!!")
|
||||
Echo.execute("時間よ止まれ!ザ・ワルド!!")
|
||||
else
|
||||
Echo().execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
|
||||
Echo.execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
@@ -26,6 +26,6 @@ class SetTimeDelta : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("usage: settimedelta <int>")
|
||||
Echo.execute("usage: settimedelta <int>")
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
*/
|
||||
class SpawnPhysTestBall : ConsoleCommand {
|
||||
internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
@@ -33,6 +33,6 @@ class SpawnPhysTestBall : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("usage: spawnball [elasticity]")
|
||||
Echo.execute("usage: spawnball [elasticity]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-24.
|
||||
*/
|
||||
class TeleportPlayer : ConsoleCommand {
|
||||
internal object TeleportPlayer : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size != 3) {
|
||||
@@ -22,7 +22,7 @@ class TeleportPlayer : ConsoleCommand {
|
||||
y = args[2].toInt() * MapDrawer.TILE_SIZE + MapDrawer.TILE_SIZE / 2
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
Echo().execute("Wrong number input.")
|
||||
Echo.execute("Wrong number input.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ class TeleportPlayer : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: teleport [x-tile] [y-tile]")
|
||||
Echo.execute("Usage: teleport [x-tile] [y-tile]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||
/**
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
class TestGetLight : ConsoleCommand {
|
||||
internal object TestGetLight : ConsoleCommand {
|
||||
/**
|
||||
* Args 0: command given
|
||||
* Args 1: first argument
|
||||
@@ -16,7 +16,7 @@ class TestGetLight : ConsoleCommand {
|
||||
val x = args[1].toInt()
|
||||
val y = args[2].toInt()
|
||||
val l = LightmapRenderer.getLightRawPos(16, 16)
|
||||
EchoConsole().execute(l.toString())
|
||||
EchoConsole.execute(l.toString())
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
|
||||
@@ -6,15 +6,15 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
class ToggleNoClip : ConsoleCommand {
|
||||
internal object ToggleNoClip : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val status = Terrarum.ingame.player.isNoClip()
|
||||
|
||||
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() {
|
||||
Echo().execute("toggle no-clip status of player")
|
||||
Echo.execute("toggle no-clip status of player")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import net.torvald.terrarum.langpack.Lang
|
||||
/**
|
||||
* Created by minjaesong on 16-04-23.
|
||||
*/
|
||||
class Version : ConsoleCommand {
|
||||
internal object Version : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val echo = Echo()
|
||||
echo.execute("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
echo.execute("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
|
||||
|
||||
Echo.execute("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
Echo.execute("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Prints out current version of the application")
|
||||
Echo.execute("Prints out current version of the application")
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.torvald.terrarum.Terrarum
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
class Zoom : ConsoleCommand {
|
||||
internal object Zoom : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class Zoom : ConsoleCommand {
|
||||
zoom = args[1].toFloat()
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
Echo().execute("Wrong number input.")
|
||||
Echo.execute("Wrong number input.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Zoom : ConsoleCommand {
|
||||
|
||||
System.gc()
|
||||
|
||||
Echo().execute("Set screen zoom to " + zoom.toString())
|
||||
Echo.execute("Set screen zoom to " + zoom.toString())
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
@@ -37,6 +37,6 @@ class Zoom : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: zoom [zoom]")
|
||||
Echo.execute("Usage: zoom [zoom]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import net.torvald.gadgets.HistoryArray
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.Authenticator
|
||||
import net.torvald.terrarum.console.CommandInterpreter
|
||||
import net.torvald.terrarum.gamecontroller.Key
|
||||
import org.newdawn.slick.Color
|
||||
@@ -171,7 +172,7 @@ class ConsoleWindow : UICanvas, KeyboardControlled {
|
||||
commandHistory = HistoryArray<String>(COMMAND_HISTORY_MAX)
|
||||
commandInputPool = StringBuilder()
|
||||
|
||||
if (Terrarum.ingame.auth.b()) {
|
||||
if (Authenticator.b()) {
|
||||
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user