mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
confirmation added for exit game and return to main menu
This commit is contained in:
@@ -57,6 +57,8 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
||||
abstract val width: Int
|
||||
abstract val height: Int
|
||||
|
||||
private val mouseButton = App.getConfigInt("config_mouseprimary")
|
||||
|
||||
/** This variable is NOT updated on its own.
|
||||
* ```
|
||||
* val posXDelta = posX - oldPosX
|
||||
@@ -88,9 +90,20 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
open val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(mouseButton)
|
||||
/** If mouse is just pushed */
|
||||
open val mouseJustPushed: Boolean
|
||||
get() {
|
||||
if (mouseUp && !mouseLatched && Gdx.input.isButtonJustPressed(mouseButton)) {
|
||||
mouseLatched = true
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
private var mouseLatched = false
|
||||
|
||||
/** UI to call (show up) while mouse is up */
|
||||
open val mouseOverCall: UICanvas? = null
|
||||
|
||||
@@ -139,6 +152,8 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
||||
if (mouseOverCall?.isVisible ?: false) {
|
||||
mouseOverCall?.setAsClose()
|
||||
}
|
||||
|
||||
mouseLatched = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.BlendMode
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.toInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-03-13.
|
||||
@@ -186,7 +188,7 @@ class UIItemTextButtonList(
|
||||
btn.update(delta)
|
||||
|
||||
|
||||
if (btn.mousePushed && index != selectedIndex) {
|
||||
if (btn.mouseJustPushed && index != selectedIndex) {
|
||||
val oldIndex = selectedIndex
|
||||
|
||||
if (kinematic) {
|
||||
|
||||
Reference in New Issue
Block a user