simplified a structure of UIs a bit

This commit is contained in:
minjaesong
2017-07-16 23:15:32 +09:00
parent 98409f09c0
commit dad876308c
29 changed files with 321 additions and 371 deletions

View File

@@ -13,7 +13,7 @@ import org.dyn4j.geometry.Vector2
/**
* Created by minjaesong on 16-07-20.
*/
class UIPieMenu : UICanvas {
class UIPieMenu : UICanvas() {
private val cellSize = UIQuickBar.CELL_SIZE
private val slotCount = UIQuickBar.SLOT_COUNT
@@ -40,6 +40,19 @@ class UIPieMenu : UICanvas {
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
selection % slotCount
}
// update controls
if (handler!!.isOpened || handler!!.isOpening) {
val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY)
val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble())
val deg = -(centre - cursorPos).direction.toFloat()
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
if (selection < 0) selection += 10
// TODO add gamepad support
}
}
override fun render(batch: SpriteBatch) {
@@ -86,19 +99,6 @@ class UIPieMenu : UICanvas {
}
}
override fun processInput(delta: Float) {
if (handler!!.isOpened || handler!!.isOpening) {
val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY)
val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble())
val deg = -(centre - cursorPos).direction.toFloat()
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
if (selection < 0) selection += 10
// TODO add gamepad support
}
}
override fun doOpening(delta: Float) {
UICanvas.doOpeningFade(handler, openCloseTime)
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)