mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 16:46:07 +09:00
jukebox ui wont pause the game AND not allow inventory to open
This commit is contained in:
@@ -77,6 +77,7 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
|
|||||||
open var consoleHandler: ConsoleWindow = ConsoleWindow()
|
open var consoleHandler: ConsoleWindow = ConsoleWindow()
|
||||||
|
|
||||||
var paused: Boolean = false; protected set
|
var paused: Boolean = false; protected set
|
||||||
|
var playerControlDisabled = false; protected set
|
||||||
val consoleOpened: Boolean
|
val consoleOpened: Boolean
|
||||||
get() = consoleHandler.isOpened || consoleHandler.isOpening
|
get() = consoleHandler.isOpened || consoleHandler.isOpening
|
||||||
|
|
||||||
@@ -200,6 +201,14 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
|
|||||||
paused = false
|
paused = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun disablePlayerControl() {
|
||||||
|
playerControlDisabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun resumePlayerControl() {
|
||||||
|
playerControlDisabled = false
|
||||||
|
}
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
|
|
||||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||||
if (!terrarumIngame.paused && terrarumIngame.uiContainer.hasNoUIsUnderMouse) {
|
if (!terrarumIngame.paused && !terrarumIngame.playerControlDisabled && terrarumIngame.uiContainer.hasNoUIsUnderMouse) {
|
||||||
val actor = terrarumIngame.actorNowPlaying
|
val actor = terrarumIngame.actorNowPlaying
|
||||||
val itemOnGrip = terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
@@ -166,8 +166,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
private var f12Down = false
|
private var f12Down = false
|
||||||
|
|
||||||
private fun tKeyDown(keycode: Int): Boolean {
|
private fun tKeyDown(keycode: Int): Boolean {
|
||||||
|
if (!terrarumIngame.paused && !terrarumIngame.playerControlDisabled) {
|
||||||
if (!terrarumIngame.paused) {
|
|
||||||
terrarumIngame.actorNowPlaying?.keyDown(keycode)
|
terrarumIngame.actorNowPlaying?.keyDown(keycode)
|
||||||
|
|
||||||
// quickslot by number keys
|
// quickslot by number keys
|
||||||
@@ -245,7 +244,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
|
|
||||||
private fun tTouchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
private fun tTouchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||||
if (!terrarumIngame.paused) {
|
if (!terrarumIngame.paused && !terrarumIngame.playerControlDisabled) {
|
||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
if (terrarumIngame.uiContainer.map { if ((it?.isOpening == true || it?.isOpened == true) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
if (terrarumIngame.uiContainer.map { if ((it?.isOpening == true || it?.isOpened == true) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
||||||
|
|
||||||
@@ -272,7 +271,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (!terrarumIngame.paused && terrarumIngame.uiContainer.hasNoUIsUnderMouse) {
|
if (!terrarumIngame.paused && !terrarumIngame.playerControlDisabled && terrarumIngame.uiContainer.hasNoUIsUnderMouse) {
|
||||||
// quickslot by wheel
|
// quickslot by wheel
|
||||||
terrarumIngame.actorNowPlaying?.let {
|
terrarumIngame.actorNowPlaying?.let {
|
||||||
var selection = it.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)!!
|
var selection = it.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)!!
|
||||||
|
|||||||
@@ -994,6 +994,14 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uiContainer.forEach {
|
uiContainer.forEach {
|
||||||
|
|
||||||
|
// suppress inventory opening if fixture inventory is opened
|
||||||
|
if (uiFixture?.isClosed == false)
|
||||||
|
uiInventoryPlayer.handler.lockToggle()
|
||||||
|
else
|
||||||
|
uiInventoryPlayer.handler.unlockToggle()
|
||||||
|
|
||||||
|
|
||||||
when (it) {
|
when (it) {
|
||||||
is Id_UICanvasNullable -> it.get()?.update(Gdx.graphics.deltaTime)
|
is Id_UICanvasNullable -> it.get()?.update(Gdx.graphics.deltaTime)
|
||||||
is UICanvas -> it.update(Gdx.graphics.deltaTime)
|
is UICanvas -> it.update(Gdx.graphics.deltaTime)
|
||||||
|
|||||||
@@ -181,7 +181,10 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
var isJumpDown = false; protected set
|
var isJumpDown = false; protected set
|
||||||
var isJumpJustDown = false; protected set // TODO if jump key is held in current update frame
|
var isJumpJustDown = false; protected set // TODO if jump key is held in current update frame
|
||||||
protected inline val isGamer: Boolean
|
protected inline val isGamer: Boolean
|
||||||
get() = if (Terrarum.ingame == null) false else this == INGAME.actorNowPlaying
|
get() = if (Terrarum.ingame?.playerControlDisabled != false) // if (ingame is null) or (playerControlDisabled is true)
|
||||||
|
false
|
||||||
|
else
|
||||||
|
(this == INGAME.actorNowPlaying)
|
||||||
|
|
||||||
private var jumpJustPressedLatched = false
|
private var jumpJustPressedLatched = false
|
||||||
|
|
||||||
|
|||||||
@@ -115,13 +115,13 @@ class UIJukebox : UICanvas(
|
|||||||
|
|
||||||
override fun doOpening(delta: Float) {
|
override fun doOpening(delta: Float) {
|
||||||
super.doOpening(delta)
|
super.doOpening(delta)
|
||||||
INGAME.pause()
|
INGAME.disablePlayerControl()
|
||||||
INGAME.setTooltipMessage(null)
|
INGAME.setTooltipMessage(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doClosing(delta: Float) {
|
override fun doClosing(delta: Float) {
|
||||||
super.doClosing(delta)
|
super.doClosing(delta)
|
||||||
INGAME.resume()
|
INGAME.resumePlayerControl()
|
||||||
INGAME.setTooltipMessage(null)
|
INGAME.setTooltipMessage(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user