Greek support, modular weather, command history for console window

Former-commit-id: b72d0b018c084e80cf4fef77e1b1a81101d6daea
Former-commit-id: 32da6a2998826de6519a901dcff7bf058f689b2f
This commit is contained in:
Song Minjae
2016-07-13 21:48:14 +09:00
parent c52015e429
commit 1d1f99605c
74 changed files with 1067 additions and 387 deletions

View File

@@ -1,8 +1,7 @@
package net.torvald.terrarum.console
import net.torvald.terrarum.StateInGame
import net.torvald.imagefont.GameFontBase
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.ConsoleWindow
import java.util.Formatter
@@ -10,6 +9,9 @@ import java.util.Formatter
* Created by minjaesong on 16-01-16.
*/
class CodexEdictis : ConsoleCommand {
val ccW = GameFontBase.colToCode["o"]
override fun execute(args: Array<String>) {
if (args.size == 1) {
printList()
@@ -23,7 +25,7 @@ class CodexEdictis : ConsoleCommand {
val sb = StringBuilder()
val formatter = Formatter(sb)
Echo().execute("Codex: " + formatter.format(Lang.get("DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"), args[1]).toString())
Echo().execute("Codex: " + formatter.format(Lang["DEV_MESSAGE_CONSOLE_COMMAND_UNKNOWN"], args[1]).toString())
}
}
@@ -38,8 +40,11 @@ class CodexEdictis : ConsoleCommand {
private fun printList() {
val echo = Echo()
echo.execute(Lang.get("DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"))
CommandDict.dict.keys.forEach { s -> echo.execute("" + s) }
echo.execute(Lang["DEV_MESSAGE_CONSOLE_AVAILABLE_COMMANDS"])
CommandDict.dict.forEach { name, cmd ->
echo.execute("$ccW" + name)
cmd.printUsage()
}
}
}

View File

@@ -42,7 +42,8 @@ object CommandDict {
// Test codes
Pair("bulletintest", SetBulletin()),
Pair("gsontest", GsonTest()),
Pair("tips", PrintRandomTips())
Pair("tips", PrintRandomTips()),
Pair("langtest", LangTest())
)
fun getCommand(commandName: String): ConsoleCommand {

View File

@@ -5,6 +5,12 @@ package net.torvald.terrarum.console
*/
interface ConsoleCommand {
/**
* Args 0: command given
* Args 1: first argument
*
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
*/
@Throws(Exception::class)
fun execute(args: Array<String>)

View File

@@ -22,10 +22,10 @@ class ExportMap : ConsoleCommand {
if (args.size == 2) {
buildColorTable()
var mapData = ByteArray(Terrarum.ingame.map.width * Terrarum.ingame.map.height * 3)
var mapData = ByteArray(Terrarum.ingame.world.width * Terrarum.ingame.world.height * 3)
var mapDataPointer = 0
for (tile in Terrarum.ingame.map.terrainIterator()) {
for (tile in Terrarum.ingame.world.terrainIterator()) {
val colArray = (colorTable as Map<Int, Col4096>)
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
@@ -44,7 +44,7 @@ class ExportMap : ConsoleCommand {
try {
RasterWriter.writePNG_RGB(
Terrarum.ingame.map.width, Terrarum.ingame.map.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")
}

View File

@@ -8,7 +8,7 @@ import net.torvald.terrarum.Terrarum
class GetTime : ConsoleCommand {
override fun execute(args: Array<String>) {
val echo = Echo()
val worldTime = Terrarum.ingame.map.worldTime
val worldTime = Terrarum.ingame.world.time
echo.execute("Year ${worldTime.years}, Month ${worldTime.months}, " +
"Day ${worldTime.days} (${worldTime.getDayNameShort()}), " +
"${worldTime.getFormattedTime()}"

View File

@@ -0,0 +1,19 @@
package net.torvald.terrarum.console
import net.torvald.terrarum.langpack.Lang
/**
* Created by minjaesong on 16-07-11.
*/
class LangTest : ConsoleCommand {
override fun printUsage() {
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()])
}
}

View File

@@ -13,7 +13,7 @@ class Seed : ConsoleCommand {
// tsalagi
override fun execute(args: Array<String>) {
Echo().execute("${ccY}Map$ccW: $ccG${Terrarum.ingame.map.generatorSeed}")
Echo().execute("Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}")
// TODO display randomiser seed
}

View File

@@ -19,8 +19,8 @@ internal class SetAV : ConsoleCommand {
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")
echo.execute("${ccR}Contaminated (double -> string) ActorValue will crash the game,")
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.")
}

View File

@@ -15,7 +15,7 @@ class SetGlobalLightLevel : ConsoleCommand {
val b = args[3].toInt()
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
Terrarum.ingame.map.globalLight = GL
Terrarum.ingame.world.globalLight = GL
}
catch (e: NumberFormatException) {
Echo().execute("Wrong number input.")
@@ -33,7 +33,7 @@ class SetGlobalLightLevel : ConsoleCommand {
Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
}
else {
Terrarum.ingame.map.globalLight = GL
Terrarum.ingame.world.globalLight = GL
}
}
catch (e: NumberFormatException) {

View File

@@ -11,10 +11,10 @@ class SetTime : ConsoleCommand {
if (args.size == 2) {
val timeToSet = WorldTime.parseTime(args[1])
Terrarum.ingame.map.worldTime.setTime(timeToSet)
Terrarum.ingame.world.time.setTime(timeToSet)
Echo().execute("Set time to ${Terrarum.ingame.map.worldTime.elapsedSeconds()} " +
"(${Terrarum.ingame.map.worldTime.hours}h${formatMin(Terrarum.ingame.map.worldTime.minutes)})")
Echo().execute("Set time to ${Terrarum.ingame.world.time.elapsedSeconds()} " +
"(${Terrarum.ingame.world.time.hours}h${formatMin(Terrarum.ingame.world.time.minutes)})")
}
else {
printUsage()

View File

@@ -14,11 +14,11 @@ class SetTimeDelta : ConsoleCommand {
if (args[1].toInt() > HARD_LIMIT)
Error().execute("Delta too large -- acceptable delta is 0-60.")
Terrarum.ingame.map.worldTime.setTimeDelta(args[1].toInt())
if (Terrarum.ingame.map.worldTime.timeDelta == 0)
Terrarum.ingame.world.time.setTimeDelta(args[1].toInt())
if (Terrarum.ingame.world.time.timeDelta == 0)
Echo().execute("時間よ止まれ!ザ・ワルド!!")
else
Echo().execute("Set time delta to ${Terrarum.ingame.map.worldTime.timeDelta}")
Echo().execute("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
}
else {
printUsage()