diff --git a/assets/locales/en/game.json b/assets/locales/en/game.json index 41f2b5ca4..68634ad92 100644 --- a/assets/locales/en/game.json +++ b/assets/locales/en/game.json @@ -11,5 +11,6 @@ "GAME_INVENTORY_POTIONS" : "Potions", "GAME_INVENTORY_BLOCKS" : "Blocks", "GAME_INVENTORY_WALLS" : "Walls", - "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Equipments" + "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Equipments", + "GAME_INVENTORY_FAVORITES" : "Favorites" } \ No newline at end of file diff --git a/assets/locales/fiFI/game.json b/assets/locales/fiFI/game.json index 36515cd37..6cff1c7f5 100644 --- a/assets/locales/fiFI/game.json +++ b/assets/locales/fiFI/game.json @@ -12,5 +12,6 @@ "GAME_INVENTORY_POTIONS" : "Juomat", "GAME_INVENTORY_BLOCKS" : "Lohkareet", "GAME_INVENTORY_WALLS" : "Seinät", - "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Varusteet" + "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Varusteet", + "GAME_INVENTORY_FAVORITES" : "Suosikit" } \ No newline at end of file diff --git a/assets/locales/frFR/game.json b/assets/locales/frFR/game.json index 3faab54c6..0d081ba1e 100644 --- a/assets/locales/frFR/game.json +++ b/assets/locales/frFR/game.json @@ -12,5 +12,6 @@ "GAME_INVENTORY_POTIONS" : "Potions", "GAME_INVENTORY_BLOCKS" : "Blocs", "GAME_INVENTORY_WALLS" : "Murs", - "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Équipements" + "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Équipements", + "GAME_INVENTORY_FAVORITES" : "Favoris" } \ No newline at end of file diff --git a/assets/locales/koKR/game.json b/assets/locales/koKR/game.json index ab9334102..fb603a837 100644 --- a/assets/locales/koKR/game.json +++ b/assets/locales/koKR/game.json @@ -12,5 +12,6 @@ "GAME_INVENTORY_POTIONS" : "물약", "GAME_INVENTORY_BLOCKS" : "블록", "GAME_INVENTORY_WALLS" : "벽지", - "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "장비" + "CONTEXT_ITEM_EQUIPMENT_PLURAL" : "장비", + "GAME_INVENTORY_FAVORITES" : "중요" } \ No newline at end of file diff --git a/src/net/torvald/terrarum/StateUITest.kt b/src/net/torvald/terrarum/StateUITest.kt index 05caa9d31..0599647ca 100644 --- a/src/net/torvald/terrarum/StateUITest.kt +++ b/src/net/torvald/terrarum/StateUITest.kt @@ -81,13 +81,16 @@ private class SimpleUI : UICanvas { "CONTEXT_ITEM_MAGIC", "GAME_INVENTORY_BLOCKS", "GAME_INVENTORY_WALLS", + "GAME_INVENTORY_FAVORITES", "MENU_LABEL_ALL" ), width = (width / 3 / 100) * 100, // chop to hundreds unit (100, 200, 300, ...) with the black magic of integer division height = height, readFromLang = true, highlightBackCol = Color(0x202020), - highlightBackBlendMode = BlendMode.NORMAL + highlightBackBlendMode = BlendMode.NORMAL, + backgroundCol = Color(0x383838), + kinematic = true ) override fun update(gc: GameContainer, delta: Int) { @@ -100,10 +103,6 @@ private class SimpleUI : UICanvas { g.color = Color(0x202020) g.fillRect(0f, 0f, width.toFloat(), height.toFloat()) - g.color = Color(0x383838) - g.fillRect(0f, 0f, buttons.width.toFloat(), height.toFloat()) - - buttons.render(gc, g) } diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 31fd83039..c2b3368d7 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -26,6 +26,8 @@ import java.util.logging.SimpleFormatter const val GAME_NAME = "Terrarum" +typealias Millisec = Int + /** * Created by minjaesong on 15-12-30. */ diff --git a/src/net/torvald/terrarum/gameactors/ActorWithSprite.kt b/src/net/torvald/terrarum/gameactors/ActorWithSprite.kt index 25a760f99..2e2cef9d3 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithSprite.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithSprite.kt @@ -202,7 +202,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean = /** * Post-hit invincibility, in milliseconds */ - @Transient val INVINCIBILITY_TIME: Int = 500 + @Transient val INVINCIBILITY_TIME: Millisec = 500 @Transient internal val BASE_FRICTION = 0.3 diff --git a/src/net/torvald/terrarum/tileproperties/TilePropUtil.kt b/src/net/torvald/terrarum/tileproperties/TilePropUtil.kt index 8fc4ec81b..310b6fe94 100644 --- a/src/net/torvald/terrarum/tileproperties/TilePropUtil.kt +++ b/src/net/torvald/terrarum/tileproperties/TilePropUtil.kt @@ -2,6 +2,7 @@ package net.torvald.terrarum.tileproperties import com.jme3.math.FastMath import net.torvald.random.HQRNG +import net.torvald.terrarum.Millisec import net.torvald.terrarum.Terrarum import net.torvald.terrarum.gameworld.WorldTime import net.torvald.terrarum.mapdrawer.LightmapRenderer @@ -13,17 +14,17 @@ import org.newdawn.slick.Color * Created by minjaesong on 16-06-16. */ object TilePropUtil { - var flickerFuncX = 0 // in milliseconds; saves current status (time) of func - val flickerFuncDomain = 100 // time between two noise sample, in milliseconds + var flickerFuncX: Millisec = 0 // in milliseconds; saves current status (time) of func + val flickerFuncDomain: Millisec = 100 // time between two noise sample, in milliseconds val flickerFuncRange = 0.012f // intensity [0, 1] var breathFuncX = 0 val breathRange = 0.02f - val breathCycleDuration = 2000 // in milliseconds + val breathCycleDuration: Millisec = 2000 // in milliseconds var pulsateFuncX = 0 val pulsateRange = 0.034f - val pulsateCycleDuration = 500 // in milliseconds + val pulsateCycleDuration: Millisec = 500 // in milliseconds val random = HQRNG() diff --git a/src/net/torvald/terrarum/ui/UICanvas.kt b/src/net/torvald/terrarum/ui/UICanvas.kt index b6deec8cf..880f4ebe0 100644 --- a/src/net/torvald/terrarum/ui/UICanvas.kt +++ b/src/net/torvald/terrarum/ui/UICanvas.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.ui +import net.torvald.terrarum.Millisec import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics import org.newdawn.slick.Input @@ -22,7 +23,7 @@ interface UICanvas { * * Timer itself is implemented in the handler. */ - var openCloseTime: Int + var openCloseTime: Millisec fun update(gc: GameContainer, delta: Int) diff --git a/src/net/torvald/terrarum/ui/ItemImageGallery.kt b/src/net/torvald/terrarum/ui/UIItemImageGallery.kt similarity index 100% rename from src/net/torvald/terrarum/ui/ItemImageGallery.kt rename to src/net/torvald/terrarum/ui/UIItemImageGallery.kt diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index 088508a3f..04b3999eb 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -19,8 +19,8 @@ class UIItemTextButton( override val width: Int, val readFromLang: Boolean = false, val activeCol: Color = Color.white, - val activeBackCol: Color = Color(0xd0d0d0), - val activeBackBlendMode: String = BlendMode.MULTIPLY, + val activeBackCol: Color = Color(0,0,0,0), + val activeBackBlendMode: String = BlendMode.NORMAL, val highlightCol: Color = Color(0x00f8ff), val highlightBackCol: Color = Color(0xb0b0b0), val highlightBackBlendMode: String = BlendMode.MULTIPLY, diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index 94f4e2749..6b2f33ee0 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum.ui import net.torvald.terrarum.BlendMode import net.torvald.terrarum.gameactors.roundInt import net.torvald.terrarum.langpack.Lang +import net.torvald.terrarum.Millisec import org.newdawn.slick.Color import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics @@ -18,50 +19,95 @@ class UIItemTextButtonList( val readFromLang: Boolean = false, // copied directly from UIItemTextButton - activeCol: Color = Color.white, - activeBackCol: Color = Color(0xd0d0d0), - activeBackBlendMode: String = BlendMode.MULTIPLY, - highlightCol: Color = Color(0x00f8ff), - highlightBackCol: Color = Color(0xb0b0b0), - highlightBackBlendMode: String = BlendMode.MULTIPLY, - inactiveCol: Color = Color(0xc8c8c8) + val activeCol: Color = Color.white, + val activeBackCol: Color = Color(0,0,0,0), + val activeBackBlendMode: String = BlendMode.NORMAL, + val highlightCol: Color = Color(0x00f8ff), + val highlightBackCol: Color = Color(0xb0b0b0), + val highlightBackBlendMode: String = BlendMode.MULTIPLY, + val inactiveCol: Color = Color(0xc8c8c8), + val backgroundCol: Color = Color(0,0,0,0), + val backgroundBlendMode: String = BlendMode.NORMAL, + val kinematic: Boolean = false // more "kinetic" movement of selector ) : UIItem(parentUI) { val buttons = labelsList.mapIndexed { index, s -> val height = this.height - UIItemTextButton.height - UIItemTextButton( - parentUI, s, - posX = 0, - posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(), - width = width, - readFromLang = true, - activeCol = activeCol, - activeBackCol = activeBackCol, - activeBackBlendMode = activeBackBlendMode, - highlightCol = highlightCol, - highlightBackCol = highlightBackCol, - highlightBackBlendMode = highlightBackBlendMode, - inactiveCol = inactiveCol - ) + if (!kinematic) { + UIItemTextButton( + parentUI, s, + posX = 0, + posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(), + width = width, + readFromLang = true, + activeCol = activeCol, + activeBackCol = activeBackCol, + activeBackBlendMode = activeBackBlendMode, + highlightCol = highlightCol, + highlightBackCol = highlightBackCol, + highlightBackBlendMode = highlightBackBlendMode, + inactiveCol = inactiveCol + ) + } + else { + UIItemTextButton( + parentUI, s, + posX = 0, + posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(), + width = width, + readFromLang = true, + activeBackCol = Color(0,0,0,0), + activeBackBlendMode = BlendMode.NORMAL, + highlightBackCol = Color(0,0,0,0) + ) + } } override var posX = 0 override var posY = 0 - var selected: Int? = labelsList.size - 1 // default to "All" + var selected = labelsList.size - 1 // default to "All" + private var highlightY = buttons[selected].posY.toDouble() + private val highlighterMoveDuration: Millisec = 100 + private var highlighterMoveTimer: Millisec = 0 + private var highlighterMoving = false + private var highlighterYStart = highlightY + private var highlighterYEnd = highlightY + override fun update(gc: GameContainer, delta: Int) { - buttons.forEachIndexed { index, btn -> - // update width because Lang is mutable (you can change language at any moment) - val textW = UIItemTextButton.font.getWidth( - if (readFromLang) Lang[btn.labelText] else btn.labelText + if (highlighterMoving) { + highlighterMoveTimer += delta + highlightY = UIUtils.moveQuick( + highlighterYStart, + highlighterYEnd, + highlighterMoveTimer.toDouble(), + highlighterMoveDuration.toDouble() ) + if (highlighterMoveTimer > highlighterMoveDuration) { + highlighterMoveTimer = 0 + highlighterYStart = highlighterYEnd + highlightY = highlighterYEnd + highlighterMoving = false + } + } + + buttons.forEachIndexed { index, btn -> btn.update(gc, delta) - if (btn.mousePushed) { - selected = index + if (btn.mousePushed && index != selected) { + if (kinematic) { + highlighterYStart = buttons[selected].posY.toDouble() + selected = index + highlighterMoving = true + highlighterYEnd = buttons[selected].posY.toDouble() + } + else { + selected = index + highlightY = buttons[selected].posY.toDouble() + } } btn.highlighted = (index == selected) // forcibly highlight if this.highlighted != null @@ -69,6 +115,13 @@ class UIItemTextButtonList( } override fun render(gc: GameContainer, g: Graphics) { + g.color = backgroundCol + BlendMode.resolve(backgroundBlendMode) + g.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) + + g.color = highlightBackCol + g.fillRect(posX.toFloat(), highlightY.toFloat(), width.toFloat(), UIItemTextButton.height.toFloat()) + buttons.forEach { it.render(gc, g) } } diff --git a/src/net/torvald/terrarum/ui/UIPieMenu.kt b/src/net/torvald/terrarum/ui/UIPieMenu.kt index 6cd2b8086..cf5ddca1b 100644 --- a/src/net/torvald/terrarum/ui/UIPieMenu.kt +++ b/src/net/torvald/terrarum/ui/UIPieMenu.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.ui import com.jme3.math.FastMath +import net.torvald.terrarum.Millisec import net.torvald.terrarum.Terrarum import net.torvald.terrarum.gameactors.AVKey import org.dyn4j.geometry.Vector2 @@ -26,7 +27,7 @@ class UIPieMenu : UICanvas { /** * In milliseconds */ - override var openCloseTime: Int = 160 + override var openCloseTime: Millisec = 160 private val smallenSize = 0.93f diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 137443c9a..cda0ff339 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.ui +import net.torvald.terrarum.Millisec import net.torvald.terrarum.Terrarum import net.torvald.terrarum.gameactors.AVKey import org.newdawn.slick.GameContainer @@ -16,7 +17,7 @@ class UIQuickBar : UICanvas, MouseControlled { /** * In milliseconds */ - override var openCloseTime: Int = 160 + override var openCloseTime: Millisec = 160 private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2 private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2 diff --git a/src/net/torvald/terrarum/ui/UIUtils.kt b/src/net/torvald/terrarum/ui/UIUtils.kt new file mode 100644 index 000000000..63410c3b3 --- /dev/null +++ b/src/net/torvald/terrarum/ui/UIUtils.kt @@ -0,0 +1,11 @@ +package net.torvald.terrarum.ui + +import net.torvald.terrarum.gameactors.sqr + +/** + * Created by SKYHi14 on 2017-03-14. + */ +object UIUtils { + fun moveQuick(start: Double, end: Double, timer: Double, duration: Double) = + (start - end) * ((timer / duration) - 1).sqr() + end +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/virtualcomputer/computer/TerrarumComputer.kt b/src/net/torvald/terrarum/virtualcomputer/computer/TerrarumComputer.kt index 4d49d03b2..c25389f22 100644 --- a/src/net/torvald/terrarum/virtualcomputer/computer/TerrarumComputer.kt +++ b/src/net/torvald/terrarum/virtualcomputer/computer/TerrarumComputer.kt @@ -8,6 +8,7 @@ import org.luaj.vm2.lib.TwoArgFunction import org.luaj.vm2.lib.ZeroArgFunction import org.luaj.vm2.lib.jse.JsePlatform import net.torvald.terrarum.KVHashMap +import net.torvald.terrarum.Millisec import net.torvald.terrarum.gameactors.roundInt import net.torvald.terrarum.virtualcomputer.luaapi.* import net.torvald.terrarum.virtualcomputer.peripheral.* @@ -361,7 +362,7 @@ class TerrarumComputer(peripheralSlots: Int) { // let's regard it as a tracker... private val beepQueue = ArrayList>() private var beepCursor = -1 - private var beepQueueLineExecTimer = 0 // millisec + private var beepQueueLineExecTimer: Millisec = 0 private var beepQueueFired = false private fun driveBeepQueueManager(delta: Int) { @@ -432,7 +433,7 @@ class TerrarumComputer(peripheralSlots: Int) { * * ,---. (true, true) ,---- (true, false) ----. (false, true) ----- (false, false) */ - private fun makeAudioData(duration: Int, freq: Double, + private fun makeAudioData(duration: Millisec, freq: Double, rampUp: Boolean = true, rampDown: Boolean = true): ByteBuffer { val audioData = BufferUtils.createByteBuffer(duration.times(sampleRate).div(1000)) diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/Terminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/Terminal.kt index e83a14d16..e9138aea3 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/Terminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/Terminal.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.virtualcomputer.terminal +import net.torvald.terrarum.Millisec import org.newdawn.slick.Color import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics @@ -61,7 +62,7 @@ interface Terminal : Teletype { * @param duration: milliseconds * @param freg: Frequency (float) */ - fun emitTone(duration: Int, freq: Double) + fun emitTone(duration: Millisec, freq: Double) override fun bell(pattern: String) /** Requires keyPressed() event to be processed. diff --git a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt index 03993092f..5885e899c 100644 --- a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.virtualcomputer.worldobject.ui +import net.torvald.terrarum.Millisec import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.UICanvas.Companion.OPENCLOSE_GENERIC import net.torvald.terrarum.virtualcomputer.terminal.Terminal @@ -52,7 +53,7 @@ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyboardControlled, Mou * * Timer itself is implemented in the handler. */ - override var openCloseTime: Int = OPENCLOSE_GENERIC + override var openCloseTime: Millisec = OPENCLOSE_GENERIC override fun update(gc: GameContainer, delta: Int) { terminal.update(gc, delta) diff --git a/work_files/UI/inventory_nouveau.png b/work_files/UI/inventory_nouveau.png index 846b52518..b8d833569 100644 Binary files a/work_files/UI/inventory_nouveau.png and b/work_files/UI/inventory_nouveau.png differ diff --git a/work_files/UI_fast_pull_out.gcx b/work_files/UI_fast_pull_out.gcx index d029d124c..97110d227 100644 Binary files a/work_files/UI_fast_pull_out.gcx and b/work_files/UI_fast_pull_out.gcx differ