mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
com.torvald → net.torvald
Former-commit-id: 375604da8a20a6ba7cd0a8d05a44add02b2d04f4 Former-commit-id: 287287c5920b07618174d7a7573f049d350ded66
This commit is contained in:
43
src/net/torvald/terrarum/console/SetLocale.kt
Normal file
43
src/net/torvald/terrarum/console/SetLocale.kt
Normal file
@@ -0,0 +1,43 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import org.apache.commons.csv.CSVRecord
|
||||
import org.newdawn.slick.SlickException
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
class 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 + "'.")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo().execute("could not read lang file.")
|
||||
Terrarum.gameLocale = prevLocale
|
||||
}
|
||||
|
||||
}
|
||||
else if (args.size == 1) {
|
||||
val echo = Echo()
|
||||
echo.execute("Locales:")
|
||||
|
||||
val record = Lang.getRecord("LANGUAGE_ID")
|
||||
record.forEach { field -> echo.execute("] " + field) }
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
}
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo().execute("Usage: setlocale [locale]")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user