Files
Terrarum/src/net/torvald/terrarum/console/SetGlobalLightLevel.kt
Song Minjae 186d6a8cb9 monitor adjustment screen, changed "calibrate" to "adjust" (NOT the STRING_ID of langpack)
Former-commit-id: ffae41e5876e54e2e0aedb5a93092db8e8f75d01
Former-commit-id: 65883b385a205d47b76c60f18a91186c2be922b2
2016-07-06 20:17:51 +09:00

53 lines
1.5 KiB
Kotlin

package net.torvald.terrarum.console
import net.torvald.terrarum.mapdrawer.LightmapRenderer
import net.torvald.terrarum.Terrarum
/**
* Created by minjaesong on 16-02-17.
*/
class SetGlobalLightLevel : ConsoleCommand {
override fun execute(args: Array<String>) {
if (args.size == 4) {
try {
val r = args[1].toInt()
val g = args[2].toInt()
val b = args[3].toInt()
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
Terrarum.ingame.map.globalLight = GL
}
catch (e: NumberFormatException) {
Echo().execute("Wrong number input.")
}
catch (e1: IllegalArgumentException) {
Echo().execute("Range: 0-" + LightmapRenderer.CHANNEL_MAX + " per channel")
}
}
else if (args.size == 2) {
try {
val GL = args[1].toInt()
if (GL.toInt() < 0 || GL.toInt() >= LightmapRenderer.COLOUR_RANGE_SIZE) {
Echo().execute("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
}
else {
Terrarum.ingame.map.globalLight = GL
}
}
catch (e: NumberFormatException) {
Echo().execute("Wrong number input.")
}
}
else {
printUsage()
}
}
override fun printUsage() {
Echo().execute("Usage: setgl [raw_value|r g b]")
}
}