diff --git a/res/graphics/fonts/numeric_small.png b/res/graphics/fonts/numeric_small.png index 851d2bc46..0419393e7 100644 Binary files a/res/graphics/fonts/numeric_small.png and b/res/graphics/fonts/numeric_small.png differ diff --git a/res/locales/helpOnTheFly.csv b/res/locales/helpOnTheFly.csv index 6451a9938..27433e804 100644 --- a/res/locales/helpOnTheFly.csv +++ b/res/locales/helpOnTheFly.csv @@ -1,14 +1,14 @@ "STRING_ID";"IETF language tag(s) without dash";"enUS";"frFR";"esES";"deDE";"itIT";"ptBR";"ptPT";"ruRU";"elGR";"trTR";"daDK";"noNB";"svSE";"nlNL";"plPL";"fiFI";"jaJP";"zhCN";"zhTW";"koKR";"csCZ";"huHU";"roRO";"thTH";"bgBG";"heIL";"jakanaJP";"isIC" -"HELP_OTF_MAIN_1";;"Type “help slow” for the ways to make the game run faster.";"Tapez « help slow » si votre jeu fonctionne lentement.";;;;;;;;;;;;;;;;;;"게임이 느리게 돌아간다면 “help slow”를 입력해 보세요." -"HELP_OTF_MAIN_2";;"Press PageUp/PageDown to scroll the messages.";"Appuyez sur PageUp/PageDown pour faire défiler les messages.";;;;;;;;;;;;;;;;;;"PageUp/PageDown 키를 사용해 메시지를 스크롤할 수 있습니다." -"HELP_OTF_MAIN_3";;"Utility keys:";"Touches utilitaires:";;;;;;;;;;;;;;;;;;"기능 키:" -"HELP_OTF_MAIN_4";;"• F3: basic information";"• F3: informations de base";;;;;;;;;;;;;;;;;;"• F3: 기본 정보" -"HELP_OTF_MAIN_5";;"• F7: (debug) toggle light blending";"• F7: (déboguer) basculer fusion de lumière";;;;;;;;;;;;;;;;;;"• F7: (디버그용) 광원 블렌딩 켜고 끄기" -"HELP_OTF_MAIN_6";;"• F8: toggle smooth lighting";"• F8: basculer éclairage lisse";;;;;;;;;;;;;;;;;;"• F8: 부드러운 광원 켜고 끄기" +"HELP_OTF_MAIN_1";;"Type “help slow” for the ways to make the game run faster.";"Tapez « help slow » si votre jeu fonctionne lentement.";;;;;;;;;;;;;;;"ゲームの実行がおそければ「help slow」を入力してください。";;;"게임이 느리게 돌아간다면 “help slow”를 입력해 보세요." +"HELP_OTF_MAIN_2";;"Press PageUp/PageDown to scroll the messages.";"Appuyez sur PageUp/PageDown pour faire défiler les messages.";;;;;;;;;;;;;;;"PageUp/PageDownを使ってメッセージのスクロールができます。";;;"PageUp/PageDown 키를 사용해 메시지를 스크롤할 수 있습니다." +"HELP_OTF_MAIN_3";;"Utility keys:";"Touches utilitaires:";;;;;;;;;;;;;;;"技能キー";;;"기능 키:" +"HELP_OTF_MAIN_4";;"• F3: basic information";"• F3: informations de base";;;;;;;;;;;;;;;"• F3: 基本的な情報";;;"• F3: 기본 정보" +"HELP_OTF_MAIN_5";;"• F7: (debug) toggle light blending";"• F7: (déboguer) basculer fusion de lumière";;;;;;;;;;;;;;;"• F7: (デバッグ)光源のブレンドON/OFF";;;"• F7: (디버그용) 광원 블렌딩 켜고 끄기" +"HELP_OTF_MAIN_6";;"• F8: toggle smooth lighting";"• F8: basculer éclairage lisse";;;;;;;;;;;;;;;"• F8: すべすべの光源ON/OFF";;;"• F8: 부드러운 광원 켜고 끄기" -"HELP_OTF_SLOW_1";;"If your game runs slowly:";"Si votre jeu tourne lentement :";;;;;;;;;;;;;;;;;"";"게임이 느리게 돌아간다면" -"HELP_OTF_SLOW_2";;"• Reset screen zoom to 1.";"• Réinitialisez le zoom de l‘écran à 1.";;;;;;;;;;;;;;;;;;"• 화면 줌을 1로 돌려주세요. " -"HELP_OTF_SLOW_3";;"• Turn off the basic information window.";"• Désactivez la fenêtre d‘informations.";;;;;;;;;;;;;;;;;;"• 기본 정보 창을 꺼 주세요." -"HELP_OTF_SLOW_4";;"• Turn off smooth lighting. You can do it now by pressing F8.";"• Désactivez éclairage lisse en utilisant F8.";;;;;;;;;;;;;;;;;;"• 부드러운 광원 효과를 꺼 주세요. F8을 사용할 수 있습니다." +"HELP_OTF_SLOW_1";;"If your game runs slowly:";"Si votre jeu tourne lentement :";;;;;;;;;;;;;;;"ゲームの実行がおそければ";;;"게임이 느리게 돌아간다면" +"HELP_OTF_SLOW_2";;"• Reset screen zoom to 1.";"• Réinitialisez le zoom de l‘écran à 1.";;;;;;;;;;;;;;;"• スクリーンのズームを1倍にリセットしてください。";;;"• 화면 줌을 1로 돌려주세요. " +"HELP_OTF_SLOW_3";;"• Close the basic information window.";"• Désactivez la fenêtre d‘informations.";;;;;;;;;;;;;;;"• 情報ウィンドウをとじてください。";;;"• 기본 정보 창을 꺼 주세요." +"HELP_OTF_SLOW_4";;"• Turn off smooth lighting. You can do it now by pressing F8.";"• Désactivez éclairage lisse en utilisant F8.";;;;;;;;;;;;;;;"• F8で、すべすべの光源をオフしてください。";;;"• 부드러운 광원 효과를 꺼 주세요. F8을 사용할 수 있습니다." diff --git a/src/net/torvald/imagefont/GameFontBase.kt b/src/net/torvald/imagefont/GameFontBase.kt index 1768511dd..eb92cb2f4 100644 --- a/src/net/torvald/imagefont/GameFontBase.kt +++ b/src/net/torvald/imagefont/GameFontBase.kt @@ -156,9 +156,7 @@ constructor() : Font { override fun getLineHeight() = H - override fun drawString(x: Float, y: Float, s: String) { - drawString(x, y, s, Color.white) - } + override fun drawString(x: Float, y: Float, s: String) = drawString(x, y, s, Color.white) override fun drawString(x: Float, y: Float, s: String, color: Color) { GL11.glEnable(GL11.GL_BLEND) @@ -364,10 +362,13 @@ constructor() : Font { )*/ sheetKey[prevInstance].getSubImage(sheetX, sheetY).draw( Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat() // Interchar: pull punct right next to hangul to the left - + if (i > 0 && isHangul(s[i - 1])) -3f else 0f, + + if (i > 0 && isHangul(s[i - 1])) -3f + else 0f, + Math.round(y).toFloat() + (if (prevInstance == SHEET_CJK_PUNCT) -1 else if (prevInstance == SHEET_FW_UNI) (H - H_HANGUL) / 2 else 0).toFloat(), + color ) } diff --git a/src/net/torvald/imagefont/SmallNumbers.kt b/src/net/torvald/imagefont/SmallNumbers.kt new file mode 100644 index 000000000..a38c038e6 --- /dev/null +++ b/src/net/torvald/imagefont/SmallNumbers.kt @@ -0,0 +1,50 @@ +package net.torvald.imagefont + +import org.newdawn.slick.Color +import org.newdawn.slick.Font +import org.newdawn.slick.SpriteSheet + +/** + * Created by minjaesong on 16-04-15. + */ +class SmallNumbers : Font { + + internal val fontSheet: SpriteSheet + + internal val W = 8 + internal val H = 8 + + private val chars = arrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-') + + init { + fontSheet = SpriteSheet("./res/graphics/fonts/numeric_small.png", W, H) + } + + override fun getHeight(str: String): Int = H + + override fun getWidth(str: String): Int = str.length * W + + override fun getLineHeight(): Int = H + + override fun drawString(x: Float, y: Float, text: String) = drawString(x, y, text, Color.white) + + override fun drawString(x: Float, y: Float, text: String, col: Color) { + for (i in 0..text.length - 1) { + val index = charToSpriteNum(text.codePointAt(i)) + if (index != null) { + fontSheet.getSubImage(index, 0).draw( + x + i * W, y, col + ) + } + } + } + + override fun drawString(x: Float, y: Float, text: String, col: Color, startIndex: Int, endIndex: Int) { + throw UnsupportedOperationException() + } + + private fun charToSpriteNum(ch: Int): Int? = + if (ch in '0'.toInt()..'9'.toInt()) ch - '0'.toInt() + else if (ch == '-'.toInt()) 10 + else null +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/Game.kt b/src/net/torvald/terrarum/Game.kt index 70f4bf1a2..2ec5983ce 100644 --- a/src/net/torvald/terrarum/Game.kt +++ b/src/net/torvald/terrarum/Game.kt @@ -172,18 +172,20 @@ constructor() : BasicGameState() { override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) { setBlendNormal() + // determine if lightmap blending should be done Terrarum.gameConfig["smoothlighting"] = KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH) + // set antialias as on if (!g.isAntiAlias) g.isAntiAlias = true drawSkybox(g) // compensate for zoom. UIs have to be treated specially! (see UIHandler) - g.translate( - -MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom) + g.translate(-MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom) MapCamera.renderBehind(gc, g) + // draw actors actorContainer.forEach { actor -> if (actor is Visible) actor.drawBody(gc, g) } player.drawBody(gc, g) @@ -201,9 +203,27 @@ constructor() : BasicGameState() { setBlendNormal() + // draw actor glows actorContainer.forEach { actor -> if (actor is Glowing) actor.drawGlow(gc, g) } player.drawGlow(gc, g) + // draw reference ID if debugWindow is open + if (debugWindow.isVisible) { + actorContainer.forEach { actor -> + if (actor is Visible) { + g.color = Color.white + g.font = Terrarum.smallNumbers + g.drawString( + actor.referenceID.toString(), + actor.hitbox.posX, + actor.hitbox.pointedY + 4 + ) + g.font = Terrarum.gameFont + } + } + } + + // draw UIs uiContainer.forEach { ui -> ui.render(gc, g) } debugWindow.render(gc, g) consoleHandler.render(gc, g) @@ -287,14 +307,14 @@ constructor() : BasicGameState() { /** * actorContainer extensions */ - fun hasActor(ID: Long): Boolean { + fun hasActor(ID: Int): Boolean { for (actor in actorContainer) { if (actor.referenceID == ID) return true } return false } - fun removeActor(ID: Long) { + fun removeActor(ID: Int) { for (actor in actorContainer) { if (actor.referenceID == ID) actorContainer.remove(actor) @@ -307,7 +327,7 @@ constructor() : BasicGameState() { return true } - fun getActor(ID: Long): Actor { + fun getActor(ID: Int): Actor { for (actor in actorContainer) { if (actor.referenceID == ID) return actor diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 166baccd7..a7f847b2c 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum import net.torvald.imagefont.GameFontWhite import net.torvald.JsonFetcher import net.torvald.JsonWriter +import net.torvald.imagefont.SmallNumbers import org.lwjgl.input.Controllers import org.lwjgl.opengl.GL11 import org.newdawn.slick.* @@ -46,6 +47,7 @@ constructor(gamename: String) : StateBasedGame(gamename) { @Throws(SlickException::class) override fun initStatesList(gc: GameContainer) { gameFont = GameFontWhite() + smallNumbers = SmallNumbers() hasController = gc.input.controllerCount > 0 if (hasController) { @@ -100,6 +102,9 @@ constructor(gamename: String) : StateBasedGame(gamename) { var gameLocale = "" // locale override lateinit var gameFont: Font + private set + lateinit var smallNumbers: Font + private set val SCENE_ID_HOME = 1 val SCENE_ID_GAME = 3 diff --git a/src/net/torvald/terrarum/gameactors/Actor.kt b/src/net/torvald/terrarum/gameactors/Actor.kt index 0ced4dcac..61be521b1 100644 --- a/src/net/torvald/terrarum/gameactors/Actor.kt +++ b/src/net/torvald/terrarum/gameactors/Actor.kt @@ -11,9 +11,9 @@ interface Actor { /** * Valid RefID is equal to or greater than 32768. - * @return Reference ID. (32768-0x7FFF_FFFF_FFFF_FFFF) + * @return Reference ID. (32768-0xFFFF_FFFF) */ - var referenceID: Long + var referenceID: Int var actorValue: ActorValue } \ No newline at end of file diff --git a/src/net/torvald/terrarum/gameactors/ActorInventory.kt b/src/net/torvald/terrarum/gameactors/ActorInventory.kt index 39e6e7a2d..361ff3b66 100644 --- a/src/net/torvald/terrarum/gameactors/ActorInventory.kt +++ b/src/net/torvald/terrarum/gameactors/ActorInventory.kt @@ -23,7 +23,7 @@ class ActorInventory() { /** * <ReferenceID, Amounts> */ - private val itemList: HashMap = HashMap() + private val itemList: HashMap = HashMap() /** * Default constructor with no encumbrance. @@ -74,7 +74,7 @@ class ActorInventory() { * Get reference to the itemList * @return */ - fun getItemList(): Map? { + fun getItemList(): Map? { return itemList } @@ -83,8 +83,8 @@ class ActorInventory() { * @return */ @Suppress("UNCHECKED_CAST") - fun getCopyOfItemList(): Map? { - return itemList.clone() as Map + fun getCopyOfItemList(): Map? { + return itemList.clone() as Map } fun getTotalWeight(): Float { diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 5801efdf1..5ead41124 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -53,11 +53,11 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { internal var baseSpriteWidth: Int = 0 internal var baseSpriteHeight: Int = 0 - override var referenceID: Long = 0L + override var referenceID: Int = 0 /** * Positions: top-left point */ - val hitbox = Hitbox(0f,0f,0f,0f) + override val hitbox = Hitbox(0f,0f,0f,0f) @Transient val nextHitbox = Hitbox(0f,0f,0f,0f) /** @@ -137,7 +137,7 @@ open class ActorWithBody constructor() : Actor, Visible, Glowing { init { do { - referenceID = HQRNG().nextLong() // set new ID + referenceID = HQRNG().nextInt() // set new ID } while (Terrarum.game.hasActor(referenceID)) // check for collision map = Terrarum.game.map diff --git a/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt b/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt index d39402ec4..ccf81752f 100644 --- a/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt +++ b/src/net/torvald/terrarum/gameactors/NPCIntelligentBase.kt @@ -15,7 +15,7 @@ open class NPCIntelligentBase : ActorWithBody() , AIControlled, Pocketed, CanBeAnItem, Factionable, LandHolder { override var itemData: InventoryItem = object : InventoryItem { - override var itemID = HQRNG().nextLong() + override var itemID = HQRNG().nextInt() override var mass: Float get() = actorValue.get("mass") as Float @@ -55,7 +55,7 @@ open class NPCIntelligentBase : ActorWithBody() private val factionSet = HashSet() - override var referenceID: Long = HQRNG().nextLong() + override var referenceID: Int = HQRNG().nextInt() override var faction: HashSet = HashSet() diff --git a/src/net/torvald/terrarum/gameactors/Player.kt b/src/net/torvald/terrarum/gameactors/Player.kt index 4a5cbb594..02a246f86 100644 --- a/src/net/torvald/terrarum/gameactors/Player.kt +++ b/src/net/torvald/terrarum/gameactors/Player.kt @@ -79,7 +79,7 @@ class Player : ActorWithBody, Controllable, Pocketed, Factionable, Luminous, Lan @Transient internal const val WALK_STOP_ACCEL = 0.32f @Transient internal const val WALK_ACCEL_BASE = 0.32f - @Transient const val PLAYER_REF_ID: Long = 0x51621D + @Transient const val PLAYER_REF_ID: Int = 0x51621D @Transient const val BASE_HEIGHT = 40 } diff --git a/src/net/torvald/terrarum/gameactors/Visible.kt b/src/net/torvald/terrarum/gameactors/Visible.kt index 1a44d75c7..872f52771 100644 --- a/src/net/torvald/terrarum/gameactors/Visible.kt +++ b/src/net/torvald/terrarum/gameactors/Visible.kt @@ -7,6 +7,8 @@ import org.newdawn.slick.Graphics * Created by minjaesong on 16-03-14. */ interface Visible { + val hitbox: Hitbox + fun drawBody(gc: GameContainer, g: Graphics) fun updateBodySprite(gc: GameContainer, delta: Int) diff --git a/src/net/torvald/terrarum/gameitem/InventoryItem.kt b/src/net/torvald/terrarum/gameitem/InventoryItem.kt index beb9c98f2..a1ad61821 100644 --- a/src/net/torvald/terrarum/gameitem/InventoryItem.kt +++ b/src/net/torvald/terrarum/gameitem/InventoryItem.kt @@ -12,7 +12,7 @@ interface InventoryItem { * 4097-32767: Various items * >=32768: Actor RefID */ - var itemID: Long + var itemID: Int /** * Weight of the item, Float diff --git a/src/net/torvald/terrarum/gameitem/TileAsItem.kt b/src/net/torvald/terrarum/gameitem/TileAsItem.kt index d0f7c6b79..4876c0543 100644 --- a/src/net/torvald/terrarum/gameitem/TileAsItem.kt +++ b/src/net/torvald/terrarum/gameitem/TileAsItem.kt @@ -8,12 +8,12 @@ import org.newdawn.slick.GameContainer */ class TileAsItem(tileNum: Int) : InventoryItem { - override var itemID: Long = -1 + override var itemID: Int = 0 override var mass: Float = 0f override var scale: Float = 1f init { - itemID = tileNum.toLong() + itemID = tileNum mass = TilePropCodex.getProp(tileNum).density / 1000f } diff --git a/src/net/torvald/terrarum/itemproperties/ItemPropCodex.kt b/src/net/torvald/terrarum/itemproperties/ItemPropCodex.kt index b7271780c..029ab825b 100644 --- a/src/net/torvald/terrarum/itemproperties/ItemPropCodex.kt +++ b/src/net/torvald/terrarum/itemproperties/ItemPropCodex.kt @@ -29,9 +29,9 @@ object ItemPropCodex { } - fun getItem(code: Long): InventoryItem { + fun getItem(code: Int): InventoryItem { if (code < ITEM_UNIQUE_MAX) - return itemCodex[(code and 0xFFFFFFFF).toInt()] + return itemCodex[code] else { for (actor in Terrarum.game.actorContainer) { if (actor is CanBeAnItem && actor.referenceID == code)