implementation of Pie Menu
Former-commit-id: 0ff65782d25f0bf73435d297cf70d93e80882090 Former-commit-id: c31e1675890bb098addd2467f1137cb20038ec7d
BIN
res/graphics/fonts/numeric_small.png
Normal file
|
After Width: | Height: | Size: 932 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 626 B |
BIN
res/graphics/gui/quickbar/item_slot.bmp
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
res/graphics/gui/quickbar/item_slot.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
@@ -19,10 +19,7 @@ import net.torvald.terrarum.mapgenerator.MapGenerator
|
|||||||
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser
|
||||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||||
import net.torvald.terrarum.tilestats.TileStats
|
import net.torvald.terrarum.tilestats.TileStats
|
||||||
import net.torvald.terrarum.ui.BasicDebugInfoWindow
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.ui.ConsoleWindow
|
|
||||||
import net.torvald.terrarum.ui.Notification
|
|
||||||
import net.torvald.terrarum.ui.UIHandler
|
|
||||||
import net.torvald.terrarum.weather.WeatherMixer
|
import net.torvald.terrarum.weather.WeatherMixer
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
import org.newdawn.slick.*
|
import org.newdawn.slick.*
|
||||||
@@ -87,6 +84,13 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
var UPDATE_DELTA: Int = 0
|
var UPDATE_DELTA: Int = 0
|
||||||
|
|
||||||
|
// UI aliases
|
||||||
|
val uiAliases = HashMap<String, UIHandler>()
|
||||||
|
private val UI_PIE_MENU = "uiPieMenu"
|
||||||
|
private val UI_QUICK_BAR = "uiQuickBar"
|
||||||
|
private val UI_INVENTORY_PLAYER = "uiInventoryPlayer"
|
||||||
|
private val UI_INVENTORY_ANON = "uiInventoryAnon"
|
||||||
|
|
||||||
@Throws(SlickException::class)
|
@Throws(SlickException::class)
|
||||||
override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) {
|
override fun init(gameContainer: GameContainer, stateBasedGame: StateBasedGame) {
|
||||||
// load necessary shaders
|
// load necessary shaders
|
||||||
@@ -126,12 +130,20 @@ constructor() : BasicGameState() {
|
|||||||
notifier = UIHandler(Notification())
|
notifier = UIHandler(Notification())
|
||||||
notifier.setPosition(
|
notifier.setPosition(
|
||||||
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
|
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
|
||||||
notifier.visible = true
|
notifier.isVisible = true
|
||||||
|
|
||||||
// set smooth lighting as in config
|
// set smooth lighting as in config
|
||||||
KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, Terrarum.getConfigBoolean("smoothlighting"))
|
KeyToggler.forceSet(KEY_LIGHTMAP_SMOOTH, Terrarum.getConfigBoolean("smoothlighting"))
|
||||||
|
|
||||||
|
// queue up game UIs
|
||||||
|
// lesser UIs
|
||||||
|
uiAliases[UI_PIE_MENU] = UIHandler(UIPieMenu())
|
||||||
|
uiAliases[UI_PIE_MENU]!!.setPosition(
|
||||||
|
(Terrarum.WIDTH - uiAliases[UI_PIE_MENU]!!.UI.width) / 2,
|
||||||
|
(Terrarum.HEIGHT - uiAliases[UI_PIE_MENU]!!.UI.height) / 2
|
||||||
|
)
|
||||||
|
uiAliases[UI_PIE_MENU]!!.UI.handler = uiAliases[UI_PIE_MENU]
|
||||||
|
uiContainer.add(uiAliases[UI_PIE_MENU]!!)
|
||||||
|
|
||||||
// audio test
|
// audio test
|
||||||
//AudioResourceLibrary.ambientsWoods[0].play()
|
//AudioResourceLibrary.ambientsWoods[0].play()
|
||||||
@@ -149,6 +161,7 @@ constructor() : BasicGameState() {
|
|||||||
world.globalLight = globalLightByTime.toInt()
|
world.globalLight = globalLightByTime.toInt()
|
||||||
|
|
||||||
GameController.processInput(gc.input)
|
GameController.processInput(gc.input)
|
||||||
|
uiContainer.forEach { it.processInput(gc.input) }
|
||||||
|
|
||||||
TileStats.update()
|
TileStats.update()
|
||||||
|
|
||||||
@@ -184,6 +197,8 @@ constructor() : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
|
override fun render(gc: GameContainer, sbg: StateBasedGame, g: Graphics) {
|
||||||
|
g.setAntiAlias(true)
|
||||||
|
|
||||||
setBlendNormal()
|
setBlendNormal()
|
||||||
|
|
||||||
// determine if lightmap blending should be done
|
// determine if lightmap blending should be done
|
||||||
@@ -232,7 +247,7 @@ constructor() : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw reference ID if debugWindow is open
|
// draw reference ID if debugWindow is open
|
||||||
if (debugWindow.visible) {
|
if (debugWindow.isVisible) {
|
||||||
actorContainer.forEachIndexed { i, actor ->
|
actorContainer.forEachIndexed { i, actor ->
|
||||||
if (actor is Visible) {
|
if (actor is Visible) {
|
||||||
g.color = Color.white
|
g.color = Color.white
|
||||||
@@ -266,38 +281,68 @@ constructor() : BasicGameState() {
|
|||||||
|
|
||||||
override fun keyPressed(key: Int, c: Char) {
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
GameController.keyPressed(key, c)
|
GameController.keyPressed(key, c)
|
||||||
|
|
||||||
|
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||||
|
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||||
|
uiAliases[UI_PIE_MENU]!!.setAsOpening()
|
||||||
|
// TODO hide quick bar
|
||||||
|
}
|
||||||
|
|
||||||
|
uiContainer.forEach { it.keyPressed(key, c) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyReleased(key: Int, c: Char) {
|
override fun keyReleased(key: Int, c: Char) {
|
||||||
GameController.keyReleased(key, c)
|
GameController.keyReleased(key, c)
|
||||||
|
|
||||||
|
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||||
|
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||||
|
uiAliases[UI_PIE_MENU]!!.setAsClosing()
|
||||||
|
// TODO show quick bar
|
||||||
|
}
|
||||||
|
|
||||||
|
uiContainer.forEach { it.keyReleased(key, c) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
GameController.mouseMoved(oldx, oldy, newx, newy)
|
GameController.mouseMoved(oldx, oldy, newx, newy)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
GameController.mouseDragged(oldx, oldy, newx, newy)
|
GameController.mouseDragged(oldx, oldy, newx, newy)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
GameController.mousePressed(button, x, y)
|
GameController.mousePressed(button, x, y)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.mousePressed(button, x, y) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
GameController.mouseReleased(button, x, y)
|
GameController.mouseReleased(button, x, y)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.mouseReleased(button, x, y) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mouseWheelMoved(change: Int) {
|
override fun mouseWheelMoved(change: Int) {
|
||||||
GameController.mouseWheelMoved(change)
|
GameController.mouseWheelMoved(change)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.mouseWheelMoved(change) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun controllerButtonPressed(controller: Int, button: Int) {
|
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
GameController.controllerButtonPressed(controller, button)
|
GameController.controllerButtonPressed(controller, button)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.controllerButtonPressed(controller, button) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun controllerButtonReleased(controller: Int, button: Int) {
|
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
GameController.controllerButtonReleased(controller, button)
|
GameController.controllerButtonReleased(controller, button)
|
||||||
|
|
||||||
|
uiContainer.forEach { it.controllerButtonReleased(controller, button) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getID(): Int = Terrarum.SCENE_ID_GAME
|
override fun getID(): Int = Terrarum.SCENE_ID_GAME
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
|
|
||||||
override fun init(gc: GameContainer, g: StateBasedGame) {
|
override fun init(gc: GameContainer, g: StateBasedGame) {
|
||||||
uiMonitorCheck = UIHandler(MonitorCheckUI())
|
uiMonitorCheck = UIHandler(MonitorCheckUI())
|
||||||
uiMonitorCheck.visible = true
|
uiMonitorCheck.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
||||||
@@ -41,6 +41,9 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
override var width = Terrarum.WIDTH
|
override var width = Terrarum.WIDTH
|
||||||
override var height = Terrarum.HEIGHT
|
override var height = Terrarum.HEIGHT
|
||||||
override var openCloseTime = 150
|
override var openCloseTime = 150
|
||||||
|
override var openCloseTimer: Int = 0
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private val colourLUT = arrayOf(
|
private val colourLUT = arrayOf(
|
||||||
0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40,
|
0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import com.google.gson.JsonPrimitive
|
||||||
import net.torvald.imagefont.GameFontWhite
|
import net.torvald.imagefont.GameFontWhite
|
||||||
import net.torvald.JsonFetcher
|
import net.torvald.JsonFetcher
|
||||||
import net.torvald.JsonWriter
|
import net.torvald.JsonWriter
|
||||||
@@ -156,7 +159,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
*
|
*
|
||||||
* e.g. 0x02010034 can be translated as 2.1.52
|
* e.g. 0x02010034 can be translated as 2.1.52
|
||||||
*/
|
*/
|
||||||
const val VERSION_RAW = 0x00020041
|
const val VERSION_RAW = 0x0002006D
|
||||||
const val VERSION_STRING: String =
|
const val VERSION_STRING: String =
|
||||||
"${VERSION_RAW.ushr(24)}.${VERSION_RAW.and(0xFF0000).ushr(16)}.${VERSION_RAW.and(0xFFFF)}"
|
"${VERSION_RAW.ushr(24)}.${VERSION_RAW.and(0xFF0000).ushr(16)}.${VERSION_RAW.and(0xFFFF)}"
|
||||||
const val NAME = "Terrarum"
|
const val NAME = "Terrarum"
|
||||||
@@ -281,30 +284,11 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
* @throws NullPointerException if the specified config simply does not exist.
|
* @throws NullPointerException if the specified config simply does not exist.
|
||||||
*/
|
*/
|
||||||
fun getConfigInt(key: String): Int {
|
fun getConfigInt(key: String): Int {
|
||||||
var cfg: Int = 0
|
val cfg = getConfigMaster(key)
|
||||||
try {
|
if (cfg is JsonPrimitive)
|
||||||
cfg = gameConfig.getAsInt(key)!!
|
return cfg.asInt
|
||||||
}
|
else
|
||||||
catch (e: NullPointerException) {
|
return cfg as Int
|
||||||
// if the config set does not have the key, try for the default config
|
|
||||||
try {
|
|
||||||
cfg = DefaultConfig.fetch().get(key).asInt
|
|
||||||
}
|
|
||||||
catch (e1: NullPointerException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e: TypeCastException) {
|
|
||||||
// if the config set does not have the key, try for the default config
|
|
||||||
try {
|
|
||||||
cfg = DefaultConfig.fetch().get(key).asInt
|
|
||||||
}
|
|
||||||
catch (e1: kotlin.TypeCastException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,21 +300,11 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
* @throws NullPointerException if the specified config simply does not exist.
|
* @throws NullPointerException if the specified config simply does not exist.
|
||||||
*/
|
*/
|
||||||
fun getConfigString(key: String): String {
|
fun getConfigString(key: String): String {
|
||||||
var cfg = ""
|
val cfg = getConfigMaster(key)
|
||||||
try {
|
if (cfg is JsonPrimitive)
|
||||||
cfg = gameConfig.getAsString(key)!!
|
return cfg.asString
|
||||||
}
|
else
|
||||||
catch (e: NullPointerException) {
|
return cfg as String
|
||||||
try {
|
|
||||||
cfg = DefaultConfig.fetch().get(key).asString
|
|
||||||
}
|
|
||||||
catch (e1: NullPointerException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -342,21 +316,31 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
|||||||
* @throws NullPointerException if the specified config simply does not exist.
|
* @throws NullPointerException if the specified config simply does not exist.
|
||||||
*/
|
*/
|
||||||
fun getConfigBoolean(key: String): Boolean {
|
fun getConfigBoolean(key: String): Boolean {
|
||||||
var cfg = false
|
val cfg = getConfigMaster(key)
|
||||||
try {
|
if (cfg is JsonPrimitive)
|
||||||
cfg = gameConfig.getAsBoolean(key)!!
|
return cfg.asBoolean
|
||||||
|
else
|
||||||
|
return cfg as Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getConfigIntArray(key: String): IntArray {
|
||||||
|
val cfg = getConfigMaster(key)
|
||||||
|
if (cfg is JsonArray) {
|
||||||
|
val jsonArray = cfg.asJsonArray
|
||||||
|
return IntArray(jsonArray.size(), { i -> jsonArray[i].asInt })
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return cfg as IntArray
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getConfigMaster(key: String): Any {
|
||||||
|
var cfg: Any? = null
|
||||||
|
try { cfg = gameConfig[key]!! }
|
||||||
catch (e: NullPointerException) {
|
catch (e: NullPointerException) {
|
||||||
try {
|
try { cfg = DefaultConfig.fetch()[key] }
|
||||||
cfg = DefaultConfig.fetch().get(key).asBoolean
|
catch (e1: NullPointerException) { e.printStackTrace() }
|
||||||
}
|
|
||||||
catch (e1: NullPointerException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return cfg!!
|
||||||
return cfg
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,4 +73,8 @@ object AVKey {
|
|||||||
*/
|
*/
|
||||||
const val ARMOURDEFENCE = "armourdefence"
|
const val ARMOURDEFENCE = "armourdefence"
|
||||||
const val ARMOURDEFENCEMULT = "armourdefence$MULT"
|
const val ARMOURDEFENCEMULT = "armourdefence$MULT"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const val _PLAYER_QUICKBARSEL = "__quickbarselection"
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ class ActorInventory() {
|
|||||||
private var capacityMode: Int
|
private var capacityMode: Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ReferenceID, Amounts>
|
* HashMap<ReferenceID, Amounts>
|
||||||
*/
|
*/
|
||||||
private val itemList: HashMap<Int, Int> = HashMap()
|
private val itemList: HashMap<Int, Int> = HashMap()
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,21 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
var veloY: Double
|
var veloY: Double
|
||||||
get() = velocity.y
|
get() = velocity.y
|
||||||
private set(value) { velocity.y = value }
|
private set(value) { velocity.y = value }
|
||||||
var walkX: Double = 0.0
|
|
||||||
var walkY: Double = 0.0
|
|
||||||
val moveDelta = Vector2(0.0, 0.0)
|
val moveDelta = Vector2(0.0, 0.0)
|
||||||
@Transient private val VELO_HARD_LIMIT = 100.0
|
@Transient private val VELO_HARD_LIMIT = 100.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for "Controllable" actors
|
||||||
|
*/
|
||||||
|
var controllerVel: Vector2? = if (this is Controllable) Vector2() else null
|
||||||
|
var walkX: Double
|
||||||
|
get() = controllerVel!!.x
|
||||||
|
internal set(value) { controllerVel!!.x = value }
|
||||||
|
var walkY: Double
|
||||||
|
get() = controllerVel!!.x
|
||||||
|
internal set(value) { controllerVel!!.x = value }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Physical properties.
|
* Physical properties.
|
||||||
* Values derived from ActorValue must be @Transient.
|
* Values derived from ActorValue must be @Transient.
|
||||||
@@ -281,7 +291,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
* Actual physics thing (altering velocity) starts from here
|
* Actual physics thing (altering velocity) starts from here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
applyControllerMovement()
|
applyMovementVelocity()
|
||||||
|
|
||||||
// applyBuoyancy()
|
// applyBuoyancy()
|
||||||
|
|
||||||
@@ -298,13 +308,14 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
// Set 'next' position (hitbox) from canonical and walking velocity
|
// Set 'next' position (hitbox) from canonical and walking velocity
|
||||||
setNewNextHitbox()
|
setNewNextHitbox()
|
||||||
|
|
||||||
|
applyNormalForce()
|
||||||
/**
|
/**
|
||||||
* solveCollision()?
|
* solveCollision()?
|
||||||
* If and only if:
|
* If and only if:
|
||||||
* This body is NON-STATIC and the other body is STATIC
|
* This body is NON-STATIC and the other body is STATIC
|
||||||
*/
|
*/
|
||||||
|
setNewNextHitbox()
|
||||||
displaceByCCD()
|
displaceByCCD()
|
||||||
applyNormalForce()
|
|
||||||
|
|
||||||
setHorizontalFriction()
|
setHorizontalFriction()
|
||||||
if (isPlayerNoClip) // or hanging on the rope, etc.
|
if (isPlayerNoClip) // or hanging on the rope, etc.
|
||||||
@@ -317,25 +328,41 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
clampHitbox()
|
clampHitbox()
|
||||||
}
|
}
|
||||||
|
|
||||||
// useless
|
// cheap solution for sticking into the wall while Left or Right is held
|
||||||
walledLeft = false//isColliding(hitbox, COLLIDING_LEFT)
|
walledLeft = false//isTouchingSide(hitbox, COLLIDING_LEFT)
|
||||||
walledRight = false//isColliding(hitbox, COLLIDING_RIGHT)
|
walledRight = false//isTouchingSide(hitbox, COLLIDING_RIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun applyControllerMovement() {
|
private fun applyMovementVelocity() {
|
||||||
// decide whether ignore walkX
|
if (this is Controllable) {
|
||||||
if (!(isCollidingSide(hitbox, COLLIDING_LEFT) && walkX < 0)
|
// decide whether to ignore walkX
|
||||||
|| !(isCollidingSide(hitbox, COLLIDING_RIGHT) && walkX > 0)
|
if (!(isCollidingSide(hitbox, COLLIDING_LEFT) && walkX < 0)
|
||||||
) {
|
|| !(isCollidingSide(hitbox, COLLIDING_RIGHT) && walkX > 0)
|
||||||
moveDelta.x = veloX + walkX
|
) {
|
||||||
}
|
moveDelta.x = veloX + walkX
|
||||||
|
}
|
||||||
|
|
||||||
// decide whether ignore walkY
|
// decide whether to ignore walkY
|
||||||
if (!(isCollidingSide(hitbox, COLLIDING_TOP) && walkY < 0)
|
if (!(isCollidingSide(hitbox, COLLIDING_TOP) && walkY < 0)
|
||||||
|| !(isCollidingSide(hitbox, COLLIDING_BOTTOM) && walkY > 0)
|
|| !(isCollidingSide(hitbox, COLLIDING_BOTTOM) && walkY > 0)
|
||||||
) {
|
) {
|
||||||
moveDelta.y = veloY + walkY
|
moveDelta.y = veloY + walkY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!isCollidingSide(hitbox, COLLIDING_LEFT)
|
||||||
|
|| !isCollidingSide(hitbox, COLLIDING_RIGHT)
|
||||||
|
) {
|
||||||
|
moveDelta.x = veloX
|
||||||
|
}
|
||||||
|
|
||||||
|
// decide whether to ignore walkY
|
||||||
|
if (!isCollidingSide(hitbox, COLLIDING_TOP)
|
||||||
|
|| !isCollidingSide(hitbox, COLLIDING_BOTTOM)
|
||||||
|
) {
|
||||||
|
moveDelta.y = veloY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,18 +396,21 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME the culprit!
|
* FIXME the culprit!
|
||||||
* (5566 -> no colliiding but player does not "sink")
|
* (5566 -> no collision but player does not "sink")
|
||||||
* (5567 -> colliding)
|
* (5567 -> collision)
|
||||||
* How to fix:
|
* How to fix:
|
||||||
*/
|
*/
|
||||||
private fun applyNormalForce() {
|
private fun applyNormalForce() {
|
||||||
if (!isNoCollideWorld) {
|
if (!isNoCollideWorld) {
|
||||||
// axis Y. Use operand >=
|
// axis Y. Use operand >=
|
||||||
if (moveDelta.y >= 0.0) { // was moving downward?
|
if (moveDelta.y >= 0.0) { // was moving downward?
|
||||||
if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM)) { // actor hit something on its bottom
|
if (isColliding(nextHitbox)) {
|
||||||
hitAndReflectY()
|
hitAndReflectY()
|
||||||
grounded = true
|
grounded = true
|
||||||
}
|
}
|
||||||
|
else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM)) { // actor hit something on its bottom
|
||||||
|
grounded = true
|
||||||
|
}
|
||||||
else { // the actor is not grounded at all
|
else { // the actor is not grounded at all
|
||||||
grounded = false
|
grounded = false
|
||||||
}
|
}
|
||||||
@@ -408,7 +438,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
private fun displaceByCCD() {
|
private fun displaceByCCD() {
|
||||||
if (!isNoCollideWorld){
|
if (!isNoCollideWorld){
|
||||||
// do some CCD between hitbox and nextHitbox
|
// do some CCD between hitbox and nextHitbox
|
||||||
val ccdBox = nextHitbox.clone().snapToPixel()
|
val ccdBox = nextHitbox.clone()//.snapToPixel()
|
||||||
val ccdDelta = nextHitbox.toVector() to hitbox.toVector()
|
val ccdDelta = nextHitbox.toVector() to hitbox.toVector()
|
||||||
val deltaMax = Math.max(ccdDelta.x.abs(), ccdDelta.y.abs())
|
val deltaMax = Math.max(ccdDelta.x.abs(), ccdDelta.y.abs())
|
||||||
// set ccdDelta so that CCD move a pixel per round
|
// set ccdDelta so that CCD move a pixel per round
|
||||||
@@ -418,15 +448,14 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
//println("deltaMax: $deltaMax")
|
//println("deltaMax: $deltaMax")
|
||||||
//println("ccdDelta: $ccdDelta")
|
//println("ccdDelta: $ccdDelta")
|
||||||
|
|
||||||
while (!ccdDelta.isZero && isColliding(ccdBox)) {
|
while (!ccdDelta.isZero && isColliding(ccdBox, COLLIDING_ALLSIDE)) {
|
||||||
nextHitbox.translate(ccdDelta)
|
nextHitbox.translate(ccdDelta)
|
||||||
ccdCollided = true
|
ccdCollided = true
|
||||||
|
|
||||||
ccdBox.reassign(nextHitbox).snapToPixel()
|
//ccdBox.reassign(nextHitbox).snapToPixel()
|
||||||
|
ccdBox.reassign(nextHitbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
nextHitbox.snapToPixel()
|
|
||||||
|
|
||||||
//println("ccdCollided: $ccdCollided")
|
//println("ccdCollided: $ccdCollided")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -437,22 +466,22 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
private fun hitAndReflectX() {
|
private fun hitAndReflectX() {
|
||||||
if ((veloX * elasticity).abs() > Epsilon.E) {
|
if ((veloX * elasticity).abs() > Epsilon.E) {
|
||||||
veloX *= -elasticity
|
veloX *= -elasticity
|
||||||
walkX *= -elasticity
|
if (this is Controllable) walkX *= -elasticity
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
veloX = 0.0
|
veloX = 0.0
|
||||||
walkX = 0.0
|
if (this is Controllable) walkX = 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hitAndReflectY() {
|
private fun hitAndReflectY() {
|
||||||
if ((veloY * elasticity).abs() > Epsilon.E) {
|
if ((veloY * elasticity).abs() > Epsilon.E) {
|
||||||
veloY *= -elasticity
|
veloY *= -elasticity
|
||||||
walkY *= -elasticity
|
if (this is Controllable) walkY *= -elasticity
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
veloY = 0.0
|
veloY = 0.0
|
||||||
walkY *= 0.0
|
if (this is Controllable) walkY *= 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,15 +539,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
val tyStart = y1.div(TSIZE).floorInt()
|
val tyStart = y1.div(TSIZE).floorInt()
|
||||||
val tyEnd = y2.div(TSIZE).floorInt()
|
val tyEnd = y2.div(TSIZE).floorInt()
|
||||||
|
|
||||||
for (y in tyStart..tyEnd) {
|
return isCollidingInternal(txStart, tyStart, txEnd, tyEnd)
|
||||||
for (x in txStart..txEnd) {
|
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
|
||||||
if (TilePropCodex.getProp(tile).isSolid)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isTouchingSide(hitbox: Hitbox, option: Int): Boolean {
|
private fun isTouchingSide(hitbox: Hitbox, option: Int): Boolean {
|
||||||
@@ -549,20 +570,12 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
}
|
}
|
||||||
else throw IllegalArgumentException()
|
else throw IllegalArgumentException()
|
||||||
|
|
||||||
val txStart = x1.plus(1.0).div(TSIZE).floorInt()
|
val txStart = x1.div(TSIZE).floorInt()
|
||||||
val txEnd = x2.plus(1.0).div(TSIZE).floorInt()
|
val txEnd = x2.div(TSIZE).floorInt()
|
||||||
val tyStart = y1.plus(1.0).div(TSIZE).floorInt()
|
val tyStart = y1.div(TSIZE).floorInt()
|
||||||
val tyEnd = y2.plus(1.0).div(TSIZE).floorInt()
|
val tyEnd = y2.div(TSIZE).floorInt()
|
||||||
|
|
||||||
for (y in tyStart..tyEnd) {
|
return isCollidingInternal(txStart, tyStart, txEnd, tyEnd)
|
||||||
for (x in txStart..txEnd) {
|
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
|
||||||
if (TilePropCodex.getProp(tile).isSolid)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -599,7 +612,11 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
val tyStart = y1.div(TSIZE).roundInt()
|
val tyStart = y1.div(TSIZE).roundInt()
|
||||||
val tyEnd = y2.div(TSIZE).roundInt()
|
val tyEnd = y2.div(TSIZE).roundInt()
|
||||||
|
|
||||||
for (y in tyStart..tyEnd) {
|
return isCollidingInternal(txStart, tyStart, txEnd, tyEnd)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isCollidingInternal(txStart: Int, tyStart: Int, txEnd: Int, tyEnd: Int): Boolean {
|
||||||
|
/*for (y in tyStart..tyEnd) {
|
||||||
for (x in txStart..txEnd) {
|
for (x in txStart..txEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world.getTileFromTerrain(x, y)
|
||||||
if (TilePropCodex.getProp(tile).isSolid)
|
if (TilePropCodex.getProp(tile).isSolid)
|
||||||
@@ -607,7 +624,8 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false*/
|
||||||
|
return if (tyEnd <= 347) false else true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
||||||
@@ -653,7 +671,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
val friction = if (isPlayerNoClip)
|
val friction = if (isPlayerNoClip)
|
||||||
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
||||||
else
|
else
|
||||||
BASE_FRICTION * tileFriction.tileFrictionToMult()
|
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
||||||
|
|
||||||
if (veloX < 0) {
|
if (veloX < 0) {
|
||||||
veloX += friction
|
veloX += friction
|
||||||
@@ -664,13 +682,15 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
if (veloX < 0) veloX = 0.0 // compensate overshoot
|
if (veloX < 0) veloX = 0.0 // compensate overshoot
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walkX < 0) {
|
if (this is Controllable) {
|
||||||
walkX += friction
|
if (walkX < 0) {
|
||||||
if (walkX > 0) walkX = 0.0
|
walkX += friction
|
||||||
}
|
if (walkX > 0) walkX = 0.0
|
||||||
else if (walkX > 0) {
|
}
|
||||||
walkX -= friction
|
else if (walkX > 0) {
|
||||||
if (walkX < 0) walkX = 0.0
|
walkX -= friction
|
||||||
|
if (walkX < 0) walkX = 0.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,7 +698,7 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
val friction = if (isPlayerNoClip)
|
val friction = if (isPlayerNoClip)
|
||||||
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
BASE_FRICTION * TilePropCodex.getProp(TileNameCode.STONE).friction.tileFrictionToMult()
|
||||||
else
|
else
|
||||||
BASE_FRICTION * tileFriction.tileFrictionToMult()
|
BASE_FRICTION * bodyFriction.tileFrictionToMult()
|
||||||
|
|
||||||
if (veloY < 0) {
|
if (veloY < 0) {
|
||||||
veloY += friction
|
veloY += friction
|
||||||
@@ -689,13 +709,15 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
if (veloY < 0) veloY = 0.0 // compensate overshoot
|
if (veloY < 0) veloY = 0.0 // compensate overshoot
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walkY < 0) {
|
if (this is Controllable) {
|
||||||
walkY += friction
|
if (walkY < 0) {
|
||||||
if (walkY > 0) walkY = 0.0
|
walkY += friction
|
||||||
}
|
if (walkY > 0) walkY = 0.0
|
||||||
else if (walkY > 0) {
|
}
|
||||||
walkY -= friction
|
else if (walkY > 0) {
|
||||||
if (walkY < 0) walkY = 0.0
|
walkY -= friction
|
||||||
|
if (walkY < 0) walkY = 0.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,9 +752,9 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
* Get highest friction value from feet tiles.
|
* Get highest friction value from feet tiles.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
internal val tileFriction: Int
|
internal val bodyFriction: Int
|
||||||
get() {
|
get() {
|
||||||
var friction = 0
|
/*var friction = 0
|
||||||
|
|
||||||
// take highest value
|
// take highest value
|
||||||
val tilePosXStart = (hitbox.posX / TSIZE).roundInt()
|
val tilePosXStart = (hitbox.posX / TSIZE).roundInt()
|
||||||
@@ -745,9 +767,15 @@ open class ActorWithBody : Actor(), Visible {
|
|||||||
if (thisFriction > friction) friction = thisFriction
|
if (thisFriction > friction) friction = thisFriction
|
||||||
}
|
}
|
||||||
|
|
||||||
return friction
|
return friction*/
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fun Int.tileFrictionToMult(): Double = this / 16.0
|
||||||
|
|
||||||
|
internal val feetFriction: Int
|
||||||
|
get() {
|
||||||
|
return 16
|
||||||
}
|
}
|
||||||
fun Int.tileFrictionToMult() = this / 16.0
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get highest tile density from occupying tiles, fluid only
|
* Get highest tile density from occupying tiles, fluid only
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
|
import org.dyn4j.geometry.Vector2
|
||||||
import org.newdawn.slick.Input
|
import org.newdawn.slick.Input
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Actors that has movement controlled by Keyboard or AI
|
||||||
|
*
|
||||||
* Created by minjaesong on 16-03-14.
|
* Created by minjaesong on 16-03-14.
|
||||||
*/
|
*/
|
||||||
interface Controllable {
|
interface Controllable {
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ object PBSigrid {
|
|||||||
p.actorValue[AVKey.BASEDEFENCE] = 141
|
p.actorValue[AVKey.BASEDEFENCE] = 141
|
||||||
|
|
||||||
p.actorValue["selectedtile"] = 16
|
p.actorValue["selectedtile"] = 16
|
||||||
|
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
||||||
|
|
||||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 10, 0)
|
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 10, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.torvald.terrarum.gamecontroller.EnumKeyFunc
|
|||||||
import net.torvald.terrarum.gamecontroller.KeyMap
|
import net.torvald.terrarum.gamecontroller.KeyMap
|
||||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.ui.UIQuickBar
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import org.lwjgl.input.Controller
|
import org.lwjgl.input.Controller
|
||||||
import org.lwjgl.input.Controllers
|
import org.lwjgl.input.Controllers
|
||||||
@@ -60,6 +61,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L
|
|||||||
|
|
||||||
/** Must be set by PlayerFactory */
|
/** Must be set by PlayerFactory */
|
||||||
override var inventory: ActorInventory = ActorInventory()
|
override var inventory: ActorInventory = ActorInventory()
|
||||||
|
internal val quickBarRegistration = IntArray(UIQuickBar.SLOT_COUNT, { -1 })
|
||||||
|
|
||||||
/** Must be set by PlayerFactory */
|
/** Must be set by PlayerFactory */
|
||||||
override var faction: HashSet<Faction> = HashSet()
|
override var faction: HashSet<Faction> = HashSet()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ object PlayerBuilder {
|
|||||||
// attach sprite
|
// attach sprite
|
||||||
|
|
||||||
// do etc.
|
// do etc.
|
||||||
|
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class BasicDebugInfoWindow:UICanvas {
|
|||||||
override var height: Int = Terrarum.HEIGHT
|
override var height: Int = Terrarum.HEIGHT
|
||||||
|
|
||||||
override var openCloseTime: Int = 0
|
override var openCloseTime: Int = 0
|
||||||
|
override var openCloseTimer: Int = 0
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private var prevPlayerX = 0.0
|
private var prevPlayerX = 0.0
|
||||||
private var prevPlayerY = 0.0
|
private var prevPlayerY = 0.0
|
||||||
|
|||||||
@@ -34,11 +34,13 @@ class ConsoleWindow : UICanvas, UITypable {
|
|||||||
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
|
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
|
||||||
|
|
||||||
override var openCloseTime: Int = 0
|
override var openCloseTime: Int = 0
|
||||||
|
override var openCloseTimer: Int = 0
|
||||||
|
|
||||||
private var drawOffX: Float = 0f
|
private var drawOffX: Float = 0f
|
||||||
private var drawOffY: Float = -height.toFloat()
|
private var drawOffY: Float = -height.toFloat()
|
||||||
private var openingTimeCounter = 0
|
private var openingTimeCounter = 0
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private var historyIndex = -1
|
private var historyIndex = -1
|
||||||
|
|
||||||
@@ -170,7 +172,10 @@ class ConsoleWindow : UICanvas, UITypable {
|
|||||||
commandHistory = HistoryArray<String>(COMMAND_HISTORY_MAX)
|
commandHistory = HistoryArray<String>(COMMAND_HISTORY_MAX)
|
||||||
commandInputPool = StringBuilder()
|
commandInputPool = StringBuilder()
|
||||||
|
|
||||||
if (Terrarum.ingame.auth.b()) sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
if (Terrarum.ingame.auth.b()) {
|
||||||
|
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||||
|
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
|||||||
52
src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.setBlendNormal
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.Image
|
||||||
|
import org.newdawn.slick.SpriteSheet
|
||||||
|
import org.newdawn.slick.SpriteSheetFont
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make item slot image with number on bottom-right
|
||||||
|
*
|
||||||
|
* Created by minjaesong on 16-07-20.
|
||||||
|
*/
|
||||||
|
object ItemSlotImageBuilder {
|
||||||
|
|
||||||
|
const val COLOR_BLACK = 1
|
||||||
|
const val COLOR_WHITE = 2
|
||||||
|
|
||||||
|
private val colourBlack = Color(0x404040)
|
||||||
|
private val colourWhite = Color(0xC0C0C0)
|
||||||
|
|
||||||
|
private val numberFont = SpriteSheetFont(
|
||||||
|
SpriteSheet("./res/graphics/fonts/numeric_small.png", 5, 8),
|
||||||
|
'0'
|
||||||
|
)
|
||||||
|
private val slotImage = Image("./res/graphics/gui/quickbar/item_slot.png")
|
||||||
|
private val canvas = Image(slotImage.width, slotImage.height)
|
||||||
|
|
||||||
|
fun produce(color: Int, number: Int = -1): Image {
|
||||||
|
if (color == COLOR_BLACK)
|
||||||
|
canvas.graphics.drawImage(slotImage, 0f, 0f, colourBlack)
|
||||||
|
else if (color == COLOR_WHITE)
|
||||||
|
canvas.graphics.drawImage(slotImage, 0f, 0f, colourWhite)
|
||||||
|
|
||||||
|
if (number >= 0) {
|
||||||
|
canvas.graphics.font = numberFont
|
||||||
|
|
||||||
|
if (color == COLOR_BLACK)
|
||||||
|
canvas.graphics.color = colourWhite
|
||||||
|
else if (color == COLOR_WHITE)
|
||||||
|
canvas.graphics.color = colourBlack
|
||||||
|
|
||||||
|
canvas.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(),
|
||||||
|
slotImage.width - 6f,
|
||||||
|
slotImage.height - 10f
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return canvas
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,7 +28,9 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
|||||||
override var openCloseTime: Int = OPEN_CLOSE_TIME
|
override var openCloseTime: Int = OPEN_CLOSE_TIME
|
||||||
|
|
||||||
internal var opacity = 0f
|
internal var opacity = 0f
|
||||||
internal var openCloseCounter = 0
|
override var openCloseTimer = 0
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private lateinit var uidrawCanvas: Image // render all the images and fonts here; will be faded
|
private lateinit var uidrawCanvas: Image // render all the images and fonts here; will be faded
|
||||||
|
|
||||||
@@ -85,27 +87,27 @@ constructor(override var width: Int, isBlackVariant: Boolean) : UICanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun doOpening(gc: GameContainer, delta: Int) {
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
openCloseCounter += delta
|
openCloseTimer += delta
|
||||||
opacity = FastMath.interpolateLinear(openCloseCounter.toFloat() / openCloseTime.toFloat(),
|
opacity = FastMath.interpolateLinear(openCloseTimer.toFloat() / openCloseTime.toFloat(),
|
||||||
0f, 1f
|
0f, 1f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doClosing(gc: GameContainer, delta: Int) {
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
openCloseCounter += delta
|
openCloseTimer += delta
|
||||||
opacity = FastMath.interpolateLinear(openCloseCounter.toFloat() / openCloseTime.toFloat(),
|
opacity = FastMath.interpolateLinear(openCloseTimer.toFloat() / openCloseTime.toFloat(),
|
||||||
1f, 0f
|
1f, 0f
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(gc: GameContainer, delta: Int) {
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
opacity = 1f
|
opacity = 1f
|
||||||
openCloseCounter = 0
|
openCloseTimer = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endClosing(gc: GameContainer, delta: Int) {
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
opacity = 0f
|
opacity = 0f
|
||||||
openCloseCounter = 0
|
openCloseTimer = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawSegments(g: Graphics) {
|
private fun drawSegments(g: Graphics) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ constructor() : UICanvas {
|
|||||||
override var width: Int = 0
|
override var width: Int = 0
|
||||||
override var height: Int = 0
|
override var height: Int = 0
|
||||||
internal var visibleTime: Int
|
internal var visibleTime: Int
|
||||||
internal var showupTimeConuter = 0
|
override var openCloseTimer = 0
|
||||||
|
|
||||||
internal var isShowing = false
|
internal var isShowing = false
|
||||||
internal var message: Array<String> = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""})
|
internal var message: Array<String> = Array(MessageWindow.MESSAGES_DISPLAY, { i -> ""})
|
||||||
@@ -24,6 +24,8 @@ constructor() : UICanvas {
|
|||||||
|
|
||||||
override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME
|
override var openCloseTime: Int = MessageWindow.OPEN_CLOSE_TIME
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private val SHOWUP_MAX = 15000
|
private val SHOWUP_MAX = 15000
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -37,7 +39,7 @@ constructor() : UICanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
if (showupTimeConuter >= visibleTime && isShowing) {
|
if (openCloseTimer >= visibleTime && isShowing) {
|
||||||
// invoke closing mode
|
// invoke closing mode
|
||||||
doClosing(gc, delta)
|
doClosing(gc, delta)
|
||||||
// check if msgUI is fully fade out
|
// check if msgUI is fully fade out
|
||||||
@@ -48,7 +50,7 @@ constructor() : UICanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isShowing) {
|
if (isShowing) {
|
||||||
showupTimeConuter += delta
|
openCloseTimer += delta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +84,6 @@ constructor() : UICanvas {
|
|||||||
isShowing = true
|
isShowing = true
|
||||||
this.message = message
|
this.message = message
|
||||||
msgUI.setMessage(this.message)
|
msgUI.setMessage(this.message)
|
||||||
showupTimeConuter = 0
|
openCloseTimer = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ interface UICanvas {
|
|||||||
* In milliseconds
|
* In milliseconds
|
||||||
*/
|
*/
|
||||||
var openCloseTime: Int
|
var openCloseTime: Int
|
||||||
|
var openCloseTimer: Int
|
||||||
|
|
||||||
|
var handler: UIHandler?
|
||||||
|
|
||||||
fun update(gc: GameContainer, delta: Int)
|
fun update(gc: GameContainer, delta: Int)
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ constructor(val UI: UICanvas) {
|
|||||||
private val UIGraphicInstance: Graphics
|
private val UIGraphicInstance: Graphics
|
||||||
private val UIDrawnCanvas: Image
|
private val UIDrawnCanvas: Image
|
||||||
|
|
||||||
private var opening = false
|
var isOpening = false
|
||||||
private var closing = false
|
var isClosing = false
|
||||||
private var opened = false // fully opened
|
var isOpened = false // fully opened
|
||||||
var visible: Boolean = false
|
var isVisible: Boolean = false
|
||||||
get() = if (alwaysVisible) true
|
get() = if (alwaysVisible) true
|
||||||
else field
|
else field
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -48,6 +48,9 @@ constructor(val UI: UICanvas) {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var opacity = 1f
|
||||||
|
var scale = 1f
|
||||||
|
|
||||||
var openCloseCounter = 0
|
var openCloseCounter = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -56,18 +59,19 @@ constructor(val UI: UICanvas) {
|
|||||||
UIDrawnCanvas = Image(
|
UIDrawnCanvas = Image(
|
||||||
//FastMath.nearestPowerOfTwo(UI.width), FastMath.nearestPowerOfTwo(UI.height))
|
//FastMath.nearestPowerOfTwo(UI.width), FastMath.nearestPowerOfTwo(UI.height))
|
||||||
UI.width, UI.height)
|
UI.width, UI.height)
|
||||||
|
UIDrawnCanvas.filter = Image.FILTER_LINEAR
|
||||||
|
|
||||||
UIGraphicInstance = UIDrawnCanvas.graphics
|
UIGraphicInstance = UIDrawnCanvas.graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun update(gc: GameContainer, delta: Int) {
|
fun update(gc: GameContainer, delta: Int) {
|
||||||
if (visible || alwaysVisible) {
|
if (isVisible || alwaysVisible) {
|
||||||
UI.update(gc, delta)
|
UI.update(gc, delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opening) {
|
if (isOpening) {
|
||||||
visible = true
|
isVisible = true
|
||||||
openCloseCounter += delta
|
openCloseCounter += delta
|
||||||
|
|
||||||
// println("UI ${UI.javaClass.simpleName} (open)")
|
// println("UI ${UI.javaClass.simpleName} (open)")
|
||||||
@@ -79,12 +83,12 @@ constructor(val UI: UICanvas) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UI.endOpening(gc, delta)
|
UI.endOpening(gc, delta)
|
||||||
opening = false
|
isOpening = false
|
||||||
opened = true
|
isOpened = true
|
||||||
openCloseCounter = 0
|
openCloseCounter = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (closing) {
|
else if (isClosing) {
|
||||||
openCloseCounter += delta
|
openCloseCounter += delta
|
||||||
|
|
||||||
// println("UI ${UI.javaClass.simpleName} (close)")
|
// println("UI ${UI.javaClass.simpleName} (close)")
|
||||||
@@ -96,32 +100,37 @@ constructor(val UI: UICanvas) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UI.endClosing(gc, delta)
|
UI.endClosing(gc, delta)
|
||||||
closing = false
|
isClosing = false
|
||||||
opened = false
|
isOpened = false
|
||||||
visible = false
|
isVisible = false
|
||||||
openCloseCounter = 0
|
openCloseCounter = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun render(gc: GameContainer, sbg: StateBasedGame, gameGraphicInstance: Graphics) {
|
fun render(gc: GameContainer, sbg: StateBasedGame, ingameGraphics: Graphics) {
|
||||||
if (visible || alwaysVisible) {
|
if (isVisible || alwaysVisible) {
|
||||||
UIGraphicInstance.clear()
|
UIGraphicInstance.clear()
|
||||||
UIGraphicInstance.font = Terrarum.gameFont
|
UIGraphicInstance.font = Terrarum.gameFont
|
||||||
|
|
||||||
|
UIGraphicInstance.setAntiAlias(true)
|
||||||
|
|
||||||
UI.render(gc, UIGraphicInstance)
|
UI.render(gc, UIGraphicInstance)
|
||||||
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
||||||
gameGraphicInstance.drawImage(UIDrawnCanvas,
|
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||||
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom,
|
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom - (UI.width / 2f * scale.minus(1)),
|
||||||
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom
|
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom - (UI.height / 2f * scale.minus(1)),
|
||||||
|
Color(1f, 1f, 1f, opacity)
|
||||||
)// compensate for screenZoom AND camera translation
|
)// compensate for screenZoom AND camera translation
|
||||||
// (see Game.render -> g.translate())
|
// (see Game.render -> g.translate())
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gameGraphicInstance.drawImage(UIDrawnCanvas,
|
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||||
posX.toFloat(),
|
posX.toFloat() - (UI.width / 2f * scale.minus(1)),
|
||||||
posY.toFloat()
|
posY.toFloat() - (UI.height / 2f * scale.minus(1)),
|
||||||
|
Color(1f, 1f, 1f, opacity)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,10 +142,10 @@ constructor(val UI: UICanvas) {
|
|||||||
|
|
||||||
fun setAsAlwaysVisible() {
|
fun setAsAlwaysVisible() {
|
||||||
alwaysVisible = true
|
alwaysVisible = true
|
||||||
visible = true
|
isVisible = true
|
||||||
opened = true
|
isOpened = true
|
||||||
opening = false
|
isOpening = false
|
||||||
closing = false
|
isClosing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,8 +155,10 @@ constructor(val UI: UICanvas) {
|
|||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'open' constant UI")
|
||||||
}
|
}
|
||||||
opened = false
|
if (!isOpened && !isVisible) {
|
||||||
opening = true
|
isOpened = false
|
||||||
|
isOpening = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,82 +168,82 @@ constructor(val UI: UICanvas) {
|
|||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'close' constant UI")
|
||||||
}
|
}
|
||||||
opened = false
|
isOpened = false
|
||||||
closing = true
|
isClosing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleOpening() {
|
fun toggleOpening() {
|
||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
|
throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI")
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (isVisible) {
|
||||||
if (!closing) {
|
if (!isClosing) {
|
||||||
setAsClosing()
|
setAsClosing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!opening) {
|
if (!isOpening) {
|
||||||
setAsOpening()
|
setAsOpening()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processInput(input: Input) {
|
fun processInput(input: Input) {
|
||||||
if (visible) {
|
if (isVisible) {
|
||||||
UI.processInput(input)
|
UI.processInput(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyPressed(key: Int, c: Char) {
|
fun keyPressed(key: Int, c: Char) {
|
||||||
if (visible && UI is UITypable) {
|
if (isVisible && UI is UITypable) {
|
||||||
UI.keyPressed(key, c)
|
UI.keyPressed(key, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyReleased(key: Int, c: Char) {
|
fun keyReleased(key: Int, c: Char) {
|
||||||
if (visible && UI is UITypable) {
|
if (isVisible && UI is UITypable) {
|
||||||
UI.keyReleased(key, c)
|
UI.keyReleased(key, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.mouseMoved(oldx, oldy, newx, newy)
|
UI.mouseMoved(oldx, oldy, newx, newy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.mouseDragged(oldx, oldy, newx, newy)
|
UI.mouseDragged(oldx, oldy, newx, newy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mousePressed(button: Int, x: Int, y: Int) {
|
fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.mousePressed(button, x, y)
|
UI.mousePressed(button, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseReleased(button: Int, x: Int, y: Int) {
|
fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.mouseReleased(button, x, y)
|
UI.mouseReleased(button, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mouseWheelMoved(change: Int) {
|
fun mouseWheelMoved(change: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.mouseWheelMoved(change)
|
UI.mouseWheelMoved(change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun controllerButtonPressed(controller: Int, button: Int) {
|
fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.controllerButtonPressed(controller, button)
|
UI.controllerButtonPressed(controller, button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun controllerButtonReleased(controller: Int, button: Int) {
|
fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
if (visible && UI is UIClickable) {
|
if (isVisible && UI is UIClickable) {
|
||||||
UI.controllerButtonReleased(controller, button)
|
UI.controllerButtonReleased(controller, button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,6 +254,6 @@ constructor(val UI: UICanvas) {
|
|||||||
if (alwaysVisible) {
|
if (alwaysVisible) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return visible && !opening
|
return isVisible && !isOpening
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
108
src/net/torvald/terrarum/ui/UIPieMenu.kt
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import com.jme3.math.FastMath
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
|
import org.dyn4j.geometry.Vector2
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.Input
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-07-20.
|
||||||
|
*/
|
||||||
|
class UIPieMenu : UICanvas {
|
||||||
|
private val cellSize = 32
|
||||||
|
|
||||||
|
private val slotCount = UIQuickBar.SLOT_COUNT
|
||||||
|
private val roundRectRadius = 6
|
||||||
|
|
||||||
|
override var width: Int = cellSize * 7
|
||||||
|
override var height: Int = width
|
||||||
|
/**
|
||||||
|
* In milliseconds
|
||||||
|
*/
|
||||||
|
override var openCloseTime: Int = 160
|
||||||
|
override var openCloseTimer: Int = 0
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
|
private val smallenSize = 0.93f
|
||||||
|
|
||||||
|
var menuSelection: Int = -1
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
if (menuSelection >= 0)
|
||||||
|
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
||||||
|
menuSelection % quickbarSlots
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
val centrePoint = Vector2(width / 2.0, height / 2.0)
|
||||||
|
|
||||||
|
// draw radial thingies
|
||||||
|
for (i in 0..slotCount - 1) {
|
||||||
|
// set position
|
||||||
|
val angle = Math.PI * 2.0 * (i.toDouble() / slotCount) + Math.PI // 180 deg monitor-wise
|
||||||
|
val slotCentrePoint = Vector2(0.0, cellSize * 3.0).setDirection(angle) + centrePoint
|
||||||
|
|
||||||
|
// draw cells
|
||||||
|
g.color = if (menuSelection == i) Color(0xC0C0C0) else Color(0x404040)
|
||||||
|
g.drawImage(ItemSlotImageBuilder.produce(
|
||||||
|
if (menuSelection == i)
|
||||||
|
ItemSlotImageBuilder.COLOR_WHITE
|
||||||
|
else
|
||||||
|
ItemSlotImageBuilder.COLOR_BLACK,
|
||||||
|
i + 1
|
||||||
|
),
|
||||||
|
slotCentrePoint.x.toFloat() - (cellSize / 2f),
|
||||||
|
slotCentrePoint.y.toFloat() - (cellSize / 2f)
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO draw item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processInput(input: Input) {
|
||||||
|
if (handler!!.isOpened || handler!!.isOpening) {
|
||||||
|
val cursorPos = Vector2(input.mouseX.toDouble(), input.mouseY.toDouble())
|
||||||
|
val centre = Vector2(Terrarum.WIDTH / 2.0, Terrarum.HEIGHT / 2.0)
|
||||||
|
val deg = (centre - cursorPos).direction.toFloat()
|
||||||
|
|
||||||
|
menuSelection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
||||||
|
if (menuSelection < 0) menuSelection += 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
if (openCloseTimer < openCloseTime) {
|
||||||
|
openCloseTimer += delta
|
||||||
|
|
||||||
|
handler!!.opacity = openCloseTimer.toFloat() / openCloseTime
|
||||||
|
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
|
if (openCloseTimer < openCloseTime) {
|
||||||
|
openCloseTimer += delta
|
||||||
|
handler!!.isOpened = false
|
||||||
|
|
||||||
|
handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime
|
||||||
|
handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
|
openCloseTimer = 0
|
||||||
|
handler!!.opacity = 1f
|
||||||
|
handler!!.scale = 1f
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
|
openCloseTimer = 0
|
||||||
|
handler!!.opacity = 0f
|
||||||
|
handler!!.scale = 1f
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/net/torvald/terrarum/ui/UIQuickBar.kt
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
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) {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* In milliseconds
|
||||||
|
*/
|
||||||
|
override var openCloseTime: Int
|
||||||
|
get() = throw UnsupportedOperationException()
|
||||||
|
set(value) {
|
||||||
|
}
|
||||||
|
override var openCloseTimer: Int
|
||||||
|
get() = throw UnsupportedOperationException()
|
||||||
|
set(value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SLOT_COUNT = 10
|
||||||
|
}
|
||||||
|
}
|
||||||