Former-commit-id: bf42a690c7cd199d4f2ec00855213b83aecb144b
Former-commit-id: b992aac69b93c5d1632e96c4985cf61a6419b6a8
This commit is contained in:
Song Minjae
2017-02-20 01:43:26 +09:00
parent 96da189891
commit c78c1b132a
6 changed files with 50 additions and 17 deletions

View File

@@ -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.

Binary file not shown.

View File

@@ -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)
}
}

View File

@@ -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)
}*/
}

View File

@@ -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<String>) {
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()

View File

@@ -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
*/