mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
fixed a bug where colourmap won't interpolate properly. BUG: fadeout/fadein is somewhat glitched, UIQuickBar does not fade-in/out instead it just (dis)appears with no effect
Former-commit-id: 029f504b7e2e4d85676ec8b36b27dcbed5e5db47 Former-commit-id: 0b56ca1e8976bfc5e7ea8d665e6ed6496a52de85
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Input
|
||||
@@ -7,58 +9,87 @@ import org.newdawn.slick.Input
|
||||
/**
|
||||
* Created by minjaesong on 16-07-20.
|
||||
*/
|
||||
class UIQuickBar : UICanvas {
|
||||
override var width: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
override var height: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
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.gameFont.lineHeight
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
override var openCloseTime: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
override var openCloseTimer: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
override var openCloseTime: Int = 160
|
||||
override var openCloseTimer: Int = 0
|
||||
|
||||
private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2
|
||||
private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2
|
||||
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey._PLAYER_QUICKBARSEL)!!
|
||||
set(value) { Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = value }
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
for (i in 0..SLOT_COUNT - 1) {
|
||||
val color = if (i == selection)
|
||||
ItemSlotImageBuilder.COLOR_WHITE
|
||||
else
|
||||
ItemSlotImageBuilder.COLOR_BLACK
|
||||
|
||||
// draw slots
|
||||
g.drawImage(
|
||||
if (i == selection)
|
||||
ItemSlotImageBuilder.produceLarge(color, i + 1)
|
||||
else
|
||||
ItemSlotImageBuilder.produce(color, i + 1),
|
||||
startPointX + (CELL_SIZE + gutter).times(i).toFloat(),
|
||||
startPointY.toFloat()
|
||||
)
|
||||
// draw items
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun processInput(input: Input) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime
|
||||
}
|
||||
|
||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime
|
||||
}
|
||||
|
||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
handler!!.opacity = 1f
|
||||
}
|
||||
|
||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
handler!!.opacity = 0f
|
||||
}
|
||||
|
||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
}
|
||||
|
||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
}
|
||||
|
||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
}
|
||||
|
||||
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||
}
|
||||
|
||||
override fun mouseWheelMoved(change: Int) {
|
||||
selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).mod(SLOT_COUNT)
|
||||
if (selection < 0) selection += SLOT_COUNT
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SLOT_COUNT = 10
|
||||
const val CELL_SIZE = 32
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user