mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
simplified a structure of UIs a bit
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user