diff --git a/README.md b/README.md index 55ef2482d..f2c01b5a5 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,9 @@ Note: Right-to-left languages (arabic, hebrew, etc.) are not supported. 4. Export the image as TGA 5. Include the converted PNG to the project +### Game font ### + +The font for the game is managed on [this GitHub repository](https://github.com/minjaesong/Terrarum-sans-bitmap). Make your contribution there and file a pull request on this project. diff --git a/src/com/sudoplay/joise/generator.tar b/src/com/sudoplay/joise/generator.tar new file mode 100644 index 000000000..267bf2de0 Binary files /dev/null and b/src/com/sudoplay/joise/generator.tar differ diff --git a/src/net/torvald/imagefont/GameFontImpl.kt b/src/net/torvald/imagefont/GameFontImpl.kt index 65f73e1c9..3a67f5ba1 100644 --- a/src/net/torvald/imagefont/GameFontImpl.kt +++ b/src/net/torvald/imagefont/GameFontImpl.kt @@ -1,5 +1,6 @@ package net.torvald.imagefont +import net.torvald.terrarum.Terrarum import org.newdawn.slick.* /** @@ -29,7 +30,11 @@ class GameFontImpl : GameFontBase() { , W_UNIHAN, H_UNIHAN );*/ GameFontBase.cyrilic = SpriteSheet( - "./assets/graphics/fonts/cyrilic_variable.tga", 15, 19, 1) + when (Terrarum.gameLocale.substring(0..1)) { + "bg" -> "./assets/graphics/fonts/cyrilic_bulgarian_variable.tga" + "sr" -> "./assets/graphics/fonts/cyrilic_serbian_variable.tga" + else -> "./assets/graphics/fonts/cyrilic_variable.tga" + }, 15, 19, 1) GameFontBase.fullwidthForms = SpriteSheet( "./assets/graphics/fonts/fullwidth_forms.tga", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN) GameFontBase.uniPunct = SpriteSheet( @@ -77,4 +82,13 @@ class GameFontImpl : GameFontBase() { buildWidthTable(cyrilic, 0x400, 0..0x5F) buildWidthTable(greekSheet, 0x370, 0..0x5F) } + + fun reload() { + GameFontBase.cyrilic = SpriteSheet( + when (Terrarum.gameLocale.substring(0..1)) { + "bg" -> "./assets/graphics/fonts/cyrilic_bulgarian_variable.tga" + "sr" -> "./assets/graphics/fonts/cyrilic_serbian_variable.tga" + else -> "./assets/graphics/fonts/cyrilic_variable.tga" + }, 15, 19, 1) + } } diff --git a/src/net/torvald/terrarum/StateFontTester.kt b/src/net/torvald/terrarum/StateFontTester.kt index 86c7b573c..1b3ba322d 100644 --- a/src/net/torvald/terrarum/StateFontTester.kt +++ b/src/net/torvald/terrarum/StateFontTester.kt @@ -29,8 +29,6 @@ nopqrstuvwxyz override fun init(gc: GameContainer, game: StateBasedGame) { canvas = Graphics(1024, 1024) - Terrarum.gameLocale = "fiFI" - /*segfont = SpriteSheetFont( SpriteSheet("./assets/graphics/fonts/24-seg_red.tga", 22, 31), ' ' @@ -121,6 +119,15 @@ nopqrstuvwxyz g.drawString(s, 10f, 70f + 20 * i) } + /*val text = arrayOf( + "ru: Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства", + "bg: Под южно дърво, цъфтящо в синьо, бягаше малко пухкаво зайче", + "sr: Ајшо, лепото и чежњо, за љубав срца мога дођи у Хаџиће на кафу" + ) + + (0..2).forEach { + g.drawString(text[it], 10f, 70f + 20 * it) + }*/ } diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index a638637dd..fea5668a6 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -67,17 +67,6 @@ constructor(gamename: String) : StateBasedGame(gamename) { val readFromDisk = readConfigJson() if (!readFromDisk) readConfigJson() - // get locale from config - val gameLocaleFromConfig = gameConfig.getAsString("language") ?: sysLang - - // if bad game locale were set, use system locale - if (gameLocaleFromConfig.length < 2) - gameLocale = sysLang - else - gameLocale = gameLocaleFromConfig - - println("[Terrarum] Locale: " + gameLocale) - try { Controllers.getController(0) environment = if (getConfigString("pcgamepadenv") == "console") @@ -94,9 +83,24 @@ constructor(gamename: String) : StateBasedGame(gamename) { override fun initStatesList(gc: GameContainer) { gc.input.enableKeyRepeat() + + // get locale from config + val gameLocaleFromConfig = gameConfig.getAsString("language") ?: sysLang + + // if bad game locale were set, use system locale + if (gameLocaleFromConfig.length < 2) + gameLocale = sysLang + else + gameLocale = gameLocaleFromConfig + + println("[Terrarum] Locale: " + gameLocale) + + fontGame = GameFontImpl() fontSmallNumbers = TinyAlphNum() + + // search for real controller // exclude controllers with name "Mouse", "keyboard" val notControllerRegex = Regex("mouse|keyboard") @@ -212,9 +216,11 @@ constructor(gamename: String) : StateBasedGame(gamename) { field = value.substring(0..1) else field = value + + if (fontGame != null) (fontGame as GameFontImpl).reload() } - lateinit var fontGame: Font + var fontGame: Font? = null private set lateinit var fontSmallNumbers: Font private set @@ -282,6 +288,9 @@ constructor(gamename: String) : StateBasedGame(gamename) { const val NAME = "Terrarum" fun main(args: Array) { + System.setProperty("java.library.path", "lib") + System.setProperty("org.lwjgl.librarypath", File("lib").absolutePath) + try { appgc = AppGameContainer(Terrarum(NAME)) appgc.setDisplayMode(WIDTH, HEIGHT, false) @@ -301,7 +310,7 @@ constructor(gamename: String) : StateBasedGame(gamename) { appgc.start() } - catch (ex: SlickException) { + catch (ex: Exception) { val logger = Logger.getLogger(Terrarum::class.java.name) val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss") val calendar = Calendar.getInstance() diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 46f5448f6..6e6654ef3 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -12,7 +12,7 @@ import org.newdawn.slick.Input class UIQuickBar : UICanvas, MouseControlled { private val gutter = 8 override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT - override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.fontGame.lineHeight + override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.fontGame!!.lineHeight /** * In milliseconds */