mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
lang composition
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"BLOCK_WALL_NAME_TEMPLATE": "%1$s Wall",
|
||||||
|
|
||||||
"BLOCK_AIR": "Air",
|
"BLOCK_AIR": "Air",
|
||||||
|
|
||||||
"BLOCK_STONE": "Stone",
|
"BLOCK_STONE": "Stone",
|
||||||
|
|||||||
3
assets/mods/basegame/locales/fiFI/blocks.json
Normal file
3
assets/mods/basegame/locales/fiFI/blocks.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"BLOCK_WALL_NAME_TEMPLATE": "%1$sseinä"
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"BLOCK_WALL_NAME_TEMPLATE": "%1$s 벽",
|
||||||
|
|
||||||
"BLOCK_STONE": "돌",
|
"BLOCK_STONE": "돌",
|
||||||
"BLOCK_STONE_PLURAL": "돌",
|
"BLOCK_STONE_PLURAL": "돌",
|
||||||
"BLOCK_DIRT": "흙",
|
"BLOCK_DIRT": "흙",
|
||||||
@@ -21,8 +23,8 @@
|
|||||||
"BLOCK_TRUNK_BIRCH_PLURAL": "자작나무",
|
"BLOCK_TRUNK_BIRCH_PLURAL": "자작나무",
|
||||||
"BLOCK_TRUNK_BLOODROSE": "자단나무",
|
"BLOCK_TRUNK_BLOODROSE": "자단나무",
|
||||||
"BLOCK_TRUNK_BLOODROSE_PLURAL": "자단나무",
|
"BLOCK_TRUNK_BLOODROSE_PLURAL": "자단나무",
|
||||||
"BLOCK_STONE_QUARRIED": "석재",
|
"BLOCK_STONE_QUARRIED": "조약돌",
|
||||||
"BLOCK_STONE_QUARRIED_PLURAL": "석재",
|
"BLOCK_STONE_QUARRIED_PLURAL": "조약돌",
|
||||||
"BLOCK_SAND": "모래",
|
"BLOCK_SAND": "모래",
|
||||||
"BLOCK_SAND_PLURAL": "모래",
|
"BLOCK_SAND_PLURAL": "모래",
|
||||||
"BLOCK_GRAVEL": "자갈",
|
"BLOCK_GRAVEL": "자갈",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package net.torvald.spriteanimation
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import net.torvald.spriteassembler.AssembleSheetPixmap
|
import net.torvald.terrarum.spriteassembler.AssembleSheetPixmap
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2015-12-31.
|
|
||||||
*/
|
|
||||||
enum class EnumKeyFunc {
|
|
||||||
UI_CONSOLE, UI_BASIC_INFO,
|
|
||||||
MOVE_LEFT, MOVE_RIGHT, MOVE_UP, MOVE_DOWN, JUMP,
|
|
||||||
HAND_PRIMARY, HAND_SECONDARY
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2016-01-15.
|
|
||||||
*/
|
|
||||||
/*@Deprecated("Use Gdx.Input.Keys")
|
|
||||||
object DeprecatedAsFuckKey {
|
|
||||||
|
|
||||||
val RETURN = 28
|
|
||||||
val BACKSPACE = 14
|
|
||||||
val GRAVE = 41
|
|
||||||
val TAB = 15
|
|
||||||
val ESCAPE = 1
|
|
||||||
val SPACE = 57
|
|
||||||
val CAPS_LOCK = 58
|
|
||||||
val L_CONTROL = 29
|
|
||||||
|
|
||||||
// same position keys
|
|
||||||
val L_ALT = 56
|
|
||||||
val L_COMMAND = 219 // Mac
|
|
||||||
|
|
||||||
val DELETE = 211
|
|
||||||
|
|
||||||
val L_SHIFT = 42
|
|
||||||
val R_SHIFT = 54
|
|
||||||
|
|
||||||
val UP = 200
|
|
||||||
val DOWN = 208
|
|
||||||
val LEFT = 203
|
|
||||||
val RIGHT = 205
|
|
||||||
|
|
||||||
val F1 = 59
|
|
||||||
val F2 = 60
|
|
||||||
val F3 = 61
|
|
||||||
val F4 = 62
|
|
||||||
|
|
||||||
val F5 = 63
|
|
||||||
val F6 = 64
|
|
||||||
val F7 = 65
|
|
||||||
val F8 = 66
|
|
||||||
|
|
||||||
val F9 = 67
|
|
||||||
val F10 = 68
|
|
||||||
val F11 = 87
|
|
||||||
val F12 = 88
|
|
||||||
|
|
||||||
val NUM_1 = 8
|
|
||||||
val NUM_2 = 9
|
|
||||||
val NUM_3 = 10
|
|
||||||
val NUM_4 = 11
|
|
||||||
val NUM_5 = 12
|
|
||||||
val NUM_6 = 13
|
|
||||||
val NUM_7 = 14
|
|
||||||
val NUM_8 = 15
|
|
||||||
val NUM_9 = 16
|
|
||||||
val NUM_0 = 7
|
|
||||||
|
|
||||||
// JInput is QWERTY-based
|
|
||||||
val Q = 16
|
|
||||||
val W = 17
|
|
||||||
val E = 18
|
|
||||||
val R = 19
|
|
||||||
val T = 20
|
|
||||||
val Y = 21
|
|
||||||
val U = 22
|
|
||||||
val I = 23
|
|
||||||
val O = 24
|
|
||||||
val P = 25
|
|
||||||
|
|
||||||
val A = 30
|
|
||||||
val S = 31
|
|
||||||
val D = 32
|
|
||||||
val F = 33
|
|
||||||
val G = 34
|
|
||||||
val H = 35
|
|
||||||
val J = 36
|
|
||||||
val K = 37
|
|
||||||
val L = 38
|
|
||||||
val SEMICOLON = 39
|
|
||||||
|
|
||||||
val Z = 44
|
|
||||||
val X = 45
|
|
||||||
val C = 46
|
|
||||||
val V = 47
|
|
||||||
val B = 48
|
|
||||||
val N = 49
|
|
||||||
val M = 50
|
|
||||||
|
|
||||||
val PGUP = 201
|
|
||||||
val PGDN = 209
|
|
||||||
val HOME = 199
|
|
||||||
val END = 207
|
|
||||||
}*/
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.JsonValue
|
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2016-07-28.
|
|
||||||
*/
|
|
||||||
object KeyLayout {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HashMap<identifier: String, KeyLayoutClass>
|
|
||||||
*/
|
|
||||||
val layouts: HashMap<String, KeyLayoutClass>
|
|
||||||
|
|
||||||
init {
|
|
||||||
layouts = HashMap<String, KeyLayoutClass>()
|
|
||||||
|
|
||||||
val map = net.torvald.terrarum.utils.JsonFetcher("./res/keylayout.json")
|
|
||||||
JsonFetcher.forEach(map) { name, entry ->
|
|
||||||
layouts.put(
|
|
||||||
name,
|
|
||||||
KeyLayoutClass(
|
|
||||||
entry.getString("layout"),
|
|
||||||
entry.getString("name"),
|
|
||||||
entry.getString("capslock")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class KeyLayoutClass(layoutString: String, val layoutName: String, capsMode: String) {
|
|
||||||
val disposition = intArrayOf(
|
|
||||||
// alphanumeric
|
|
||||||
2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,
|
|
||||||
16,17,18,19,20,21,22,23,24,25,26,27,
|
|
||||||
30,31,32,33,34,35,36,37,38,39,40,
|
|
||||||
44,45,46,47,48,49,50,51,52,53,
|
|
||||||
// control keys
|
|
||||||
14, // back
|
|
||||||
15, // tab
|
|
||||||
58, 28, // capslock, return/enter
|
|
||||||
42, // lshift
|
|
||||||
29, 57 // lcontrol, space
|
|
||||||
)
|
|
||||||
val engraving = ArrayList<String>(disposition.size)
|
|
||||||
|
|
||||||
init {
|
|
||||||
/* ================== *
|
|
||||||
* parse layoutString *
|
|
||||||
* ================== */
|
|
||||||
// zero-fill engraving
|
|
||||||
for (i in 1..disposition.size) engraving.add("")
|
|
||||||
|
|
||||||
// Backspace
|
|
||||||
engraving[disposition.indexOf(14)] = "BACK"
|
|
||||||
// Tab
|
|
||||||
engraving[disposition.indexOf(15)] = "TAB"
|
|
||||||
// Capslock
|
|
||||||
engraving[disposition.indexOf(58)] = "CAPS"
|
|
||||||
// Enter
|
|
||||||
engraving[disposition.indexOf(28)] = "ENTER"
|
|
||||||
// LShift
|
|
||||||
engraving[disposition.indexOf(42)] = "SHIFT"
|
|
||||||
// Control
|
|
||||||
engraving[disposition.indexOf(29)] = "CTRL"
|
|
||||||
// Space
|
|
||||||
engraving[disposition.indexOf(57)] = "SPACE"
|
|
||||||
|
|
||||||
// alphanumeric
|
|
||||||
for (i in 0..layoutString.length - 1) {
|
|
||||||
engraving[disposition.indexOf(i)] = layoutString[i].toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun codeToLabel(code: Int) = engraving[disposition.indexOf(code)]
|
|
||||||
|
|
||||||
fun labelToCode(char: Char) = disposition[engraving.indexOf(char.toUpperCase().toString())]
|
|
||||||
}
|
|
||||||
@@ -39,6 +39,11 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* OriginalName is always read from Language files.
|
* OriginalName is always read from Language files.
|
||||||
|
*
|
||||||
|
* Syntax example:
|
||||||
|
*
|
||||||
|
* - `BLOCK_AIR` – Prints out `Lang.get("BLOCK_AIR")`
|
||||||
|
* - `BLOCK_AIR>>=BLOCK_WALL_NAME_TEMPLATE` – Prints out `Formatter().format(Lang.get("BLOCK_WALL_NAME_TEMPLATE"), Lang.get("BLOCK_AIR")).toString()`
|
||||||
*/
|
*/
|
||||||
abstract val originalName: String
|
abstract val originalName: String
|
||||||
|
|
||||||
|
|||||||
@@ -123,10 +123,37 @@ object Lang {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val bindOp = ">>="
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Syntax example:
|
||||||
|
*
|
||||||
|
* - `BLOCK_AIR` – Prints out `Lang.get("BLOCK_AIR")`
|
||||||
|
* - `BLOCK_AIR>>=BLOCK_WALL_NAME_TEMPLATE` – Prints out `Formatter().format(Lang.get("BLOCK_WALL_NAME_TEMPLATE"), Lang.get("BLOCK_AIR")).toString()`
|
||||||
|
*/
|
||||||
operator fun get(key: String, capitalise: Boolean = true): String {
|
operator fun get(key: String, capitalise: Boolean = true): String {
|
||||||
return getByLocale(key, App.GAME_LOCALE, capitalise) ?: getByLocale(key, FALLBACK_LANG_CODE, capitalise) ?: "$$key"
|
fun getstr(s: String) = getByLocale(s, App.GAME_LOCALE, capitalise) ?: getByLocale(s, FALLBACK_LANG_CODE, capitalise) ?: "$$s"
|
||||||
|
|
||||||
|
|
||||||
|
val args = key.split(bindOp).filter { it.isNotBlank() }.map { it.trim() }
|
||||||
|
if (args.isEmpty()) return ""
|
||||||
|
|
||||||
|
val sb = StringBuilder()
|
||||||
|
val formatter = Formatter(sb)
|
||||||
|
|
||||||
|
sb.append(getstr(args[0]))
|
||||||
|
args.subList(1, args.size).forEach {
|
||||||
|
val oldstr = sb.toString()
|
||||||
|
sb.clear()
|
||||||
|
formatter.format(getstr(it), oldstr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does NOT parse the operators
|
||||||
|
*/
|
||||||
fun getByLocale(key: String, locale: String, capitalise: Boolean): String? {
|
fun getByLocale(key: String, locale: String, capitalise: Boolean): String? {
|
||||||
val ret = langpack["${key}_$locale"] ?: return null
|
val ret = langpack["${key}_$locale"] ?: return null
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
override val isUnique: Boolean = false
|
override val isUnique: Boolean = false
|
||||||
override var baseMass: Double = tile.density / 1000.0
|
override var baseMass: Double = tile.density / 1000.0
|
||||||
override var baseToolSize: Double? = null
|
override var baseToolSize: Double? = null
|
||||||
override val originalName = tile.nameKey
|
override val originalName = if (isWall) "${tile.nameKey}>>=BLOCK_WALL_NAME_TEMPLATE" else tile.nameKey
|
||||||
override var stackable = true
|
override var stackable = true
|
||||||
override var inventoryCategory = if (isWall) Category.WALL else Category.BLOCK
|
override var inventoryCategory = if (isWall) Category.WALL else Category.BLOCK
|
||||||
override var isDynamic = false
|
override var isDynamic = false
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.spriteanimation.SpriteAnimation
|
import net.torvald.spriteanimation.SpriteAnimation
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import net.torvald.spriteassembler.AssembleSheetPixmap
|
import net.torvald.terrarum.spriteassembler.AssembleSheetPixmap
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.torvald.EMDASH
|
|||||||
import net.torvald.getKeycapConsole
|
import net.torvald.getKeycapConsole
|
||||||
import net.torvald.getKeycapPC
|
import net.torvald.getKeycapPC
|
||||||
import net.torvald.spriteanimation.SpriteAnimation
|
import net.torvald.spriteanimation.SpriteAnimation
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.serialise
|
|||||||
|
|
||||||
import net.torvald.spriteanimation.HasAssembledSprite
|
import net.torvald.spriteanimation.HasAssembledSprite
|
||||||
import net.torvald.spriteanimation.SpriteAnimation
|
import net.torvald.spriteanimation.SpriteAnimation
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import net.torvald.terrarum.ItemCodex
|
import net.torvald.terrarum.ItemCodex
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.torvald.spriteassembler
|
package net.torvald.terrarum.spriteassembler
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import net.torvald.terrarum.linearSearchBy
|
import net.torvald.terrarum.linearSearchBy
|
||||||
@@ -259,10 +259,10 @@ class ADPropertyObject(propertyRaw: String) {
|
|||||||
val name: String
|
val name: String
|
||||||
val input: Any?
|
val input: Any?
|
||||||
get() = when (type) {
|
get() = when (type) {
|
||||||
ADPropertyType.IVEC2 -> field!! as Vector2i
|
ADPropertyType.IVEC2 -> field!! as Vector2i
|
||||||
ADPropertyType.FLOAT -> field!! as Float
|
ADPropertyType.FLOAT -> field!! as Float
|
||||||
ADPropertyType.STRING_PAIR -> field!! as String
|
ADPropertyType.STRING_PAIR -> field!! as String
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
val type: ADPropertyType
|
val type: ADPropertyType
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.torvald.spriteassembler
|
package net.torvald.terrarum.spriteassembler
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.torvald.spriteassembler
|
package net.torvald.terrarum.spriteassembler
|
||||||
|
|
||||||
import com.badlogic.gdx.Game
|
import com.badlogic.gdx.Game
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.tests
|
package net.torvald.terrarum.tests
|
||||||
|
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.torvald.terrarum.tests
|
package net.torvald.terrarum.tests
|
||||||
|
|
||||||
import net.torvald.spriteassembler.ADProperties
|
import net.torvald.terrarum.spriteassembler.ADProperties
|
||||||
import net.torvald.spriteassembler.AssembleSheetPixmap
|
import net.torvald.terrarum.spriteassembler.AssembleSheetPixmap
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user