mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
worldportal: showing tooltip to tell why the button is disabled
This commit is contained in:
@@ -17,8 +17,7 @@
|
|||||||
"GAME_ACTION_CRAFT": "Craft",
|
"GAME_ACTION_CRAFT": "Craft",
|
||||||
"GAME_CRAFTING": "Crafting",
|
"GAME_CRAFTING": "Crafting",
|
||||||
"GAME_CRAFTABLE_ITEMS": "Craftable Items",
|
"GAME_CRAFTABLE_ITEMS": "Craftable Items",
|
||||||
"CONTEXT_WORLD_SEARCH": "World Search",
|
|
||||||
"CONTEXT_WORLD_LIST": "Worlds List",
|
|
||||||
"MENU_LABEL_RENAME": "Rename",
|
"MENU_LABEL_RENAME": "Rename",
|
||||||
"GAME_ACTION_TELEPORT": "Teleport"
|
"GAME_ACTION_TELEPORT": "Teleport",
|
||||||
|
"CONTEXT_THIS_IS_A_WORLD_CURRENTLY_PLAYING": "This is a world currently playing."
|
||||||
}
|
}
|
||||||
@@ -17,5 +17,8 @@
|
|||||||
"GAME_ACTION_QUICKSEL": "빠른 선택",
|
"GAME_ACTION_QUICKSEL": "빠른 선택",
|
||||||
"GAME_ACTION_CRAFT": "제작하기",
|
"GAME_ACTION_CRAFT": "제작하기",
|
||||||
"GAME_CRAFTING": "제작",
|
"GAME_CRAFTING": "제작",
|
||||||
"GAME_CRAFTABLE_ITEMS": "제작 가능한 아이템"
|
"GAME_CRAFTABLE_ITEMS": "제작 가능한 아이템",
|
||||||
|
"MENU_LABEL_RENAME": "이름 바꾸기",
|
||||||
|
"GAME_ACTION_TELEPORT": "텔레포트하기",
|
||||||
|
"CONTEXT_THIS_IS_A_WORLD_CURRENTLY_PLAYING": "현재 플레이 중인 월드입니다."
|
||||||
}
|
}
|
||||||
@@ -493,7 +493,7 @@ class UIItemPlayerCells(
|
|||||||
override val width = SAVE_CELL_WIDTH
|
override val width = SAVE_CELL_WIDTH
|
||||||
override val height = SAVE_CELL_HEIGHT
|
override val height = SAVE_CELL_HEIGHT
|
||||||
|
|
||||||
override var clickOnceListener: ((Int, Int) -> Unit)? = { _: Int, _: Int ->
|
override var clickOnceListener: ((Int, Int) -> Unit) = { _: Int, _: Int ->
|
||||||
UILoadGovernor.playerDisk = skimmer
|
UILoadGovernor.playerDisk = skimmer
|
||||||
UILoadGovernor.playerUUID = playerUUID
|
UILoadGovernor.playerUUID = playerUUID
|
||||||
UILoadGovernor.worldUUID = worldUUID
|
UILoadGovernor.worldUUID = worldUUID
|
||||||
@@ -756,7 +756,7 @@ class UIItemWorldCells(
|
|||||||
|
|
||||||
private var highlightCol: Color = Toolkit.Theme.COL_LIST_DEFAULT
|
private var highlightCol: Color = Toolkit.Theme.COL_LIST_DEFAULT
|
||||||
|
|
||||||
override var clickOnceListener: ((Int, Int) -> Unit)? = { _: Int, _: Int ->
|
override var clickOnceListener: ((Int, Int) -> Unit) = { _: Int, _: Int ->
|
||||||
UILoadGovernor.worldDisk = skimmer
|
UILoadGovernor.worldDisk = skimmer
|
||||||
parent.advanceMode(this)
|
parent.advanceMode(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
@@ -94,6 +95,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
selected?.worldInfo?.diskSkimmer, null
|
selected?.worldInfo?.diskSkimmer, null
|
||||||
)
|
)
|
||||||
full.setAsClose()
|
full.setAsClose()
|
||||||
|
printdbg(this, "Teleport target set: ${full.host.teleportRequest}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +139,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
buttonRename.isActive = false
|
buttonRename.isActive = false
|
||||||
buttonDelete.isActive = false
|
buttonDelete.isActive = false
|
||||||
buttonTeleport.isActive = false
|
buttonTeleport.isActive = false
|
||||||
|
currentWorldSelected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun highlightListEditButtons(info: WorldInfo?) {
|
private fun highlightListEditButtons(info: WorldInfo?) {
|
||||||
@@ -147,9 +150,12 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
buttonRename.isActive = true
|
buttonRename.isActive = true
|
||||||
buttonDelete.isActive = info.uuid != INGAME.world.worldIndex
|
buttonDelete.isActive = info.uuid != INGAME.world.worldIndex
|
||||||
buttonTeleport.isActive = info.uuid != INGAME.world.worldIndex
|
buttonTeleport.isActive = info.uuid != INGAME.world.worldIndex
|
||||||
|
currentWorldSelected = info.uuid == INGAME.world.worldIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var currentWorldSelected = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
CommonResourcePool.addToLoadingList("terrarum-basegame-worldportalicons") {
|
CommonResourcePool.addToLoadingList("terrarum-basegame-worldportalicons") {
|
||||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/worldportal_catbar.tga"), 30, 20)
|
TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/worldportal_catbar.tga"), 30, 20)
|
||||||
@@ -296,6 +302,10 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
uiItems.forEach { it.update(delta) }
|
uiItems.forEach { it.update(delta) }
|
||||||
if (::worldCells.isInitialized) worldCells.forEach { it.update(delta) }
|
if (::worldCells.isInitialized) worldCells.forEach { it.update(delta) }
|
||||||
|
|
||||||
|
if (currentWorldSelected) {
|
||||||
|
INGAME.setTooltipMessage(if (buttonTeleport.mouseUp || buttonDelete.mouseUp) Lang["CONTEXT_THIS_IS_A_WORLD_CURRENTLY_PLAYING"] else null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val iconGap = 12f
|
private val iconGap = 12f
|
||||||
|
|||||||
@@ -96,32 +96,33 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
protected var mouseLatched = Terrarum.mouseDown
|
protected var mouseLatched = Terrarum.mouseDown
|
||||||
|
|
||||||
/** UI to call (show up) while mouse is up */
|
/** UI to call (show up) while mouse is up */
|
||||||
open val mouseOverCall: UICanvas? = null
|
open var mouseOverCall: UICanvas? = null
|
||||||
|
|
||||||
|
|
||||||
// kind of listener implementation
|
// kind of listener implementation
|
||||||
/** Fired once for every update
|
/** Fired once for every update
|
||||||
* Parameter: delta */
|
* Parameter: delta */
|
||||||
open var updateListener: ((Float) -> Unit)? = null
|
open var updateListener: ((Float) -> Unit) = {}
|
||||||
/** Parameter: keycode */
|
/** Parameter: keycode */
|
||||||
open var keyDownListener: ((Int) -> Unit)? = null
|
open var keyDownListener: ((Int) -> Unit) = {}
|
||||||
/** Parameter: keycode */
|
/** Parameter: keycode */
|
||||||
open var keyUpListener: ((Int) -> Unit)? = null
|
open var keyUpListener: ((Int) -> Unit) = {}
|
||||||
open var keyTypedListener: ((Char) -> Unit)? = null
|
open var keyTypedListener: ((Char) -> Unit) = {}
|
||||||
open var touchDraggedListener: ((Int, Int, Int) -> Unit)? = null
|
open var touchDraggedListener: ((Int, Int, Int) -> Unit) = { _,_,_ -> }
|
||||||
/** Parameters: screenX, screenY, pointer, button */
|
/** Parameters: screenX, screenY, pointer, button */
|
||||||
@Deprecated("Not really deprecated but you MOST DEFINITELY want to use clickOnceListener(mouseX, mouseY) instead.")
|
@Deprecated("Not really deprecated but you MOST DEFINITELY want to use clickOnceListener(mouseX, mouseY) instead.")
|
||||||
open var touchDownListener: ((Int, Int, Int, Int) -> Unit)? = null
|
open var touchDownListener: ((Int, Int, Int, Int) -> Unit) = { _,_,_,_ -> }
|
||||||
open var touchUpListener: ((Int, Int, Int, Int) -> Unit)? = null
|
open var touchUpListener: ((Int, Int, Int, Int) -> Unit) = { _,_,_,_ -> }
|
||||||
/** Parameters: amountX, amountY */
|
/** Parameters: amountX, amountY */
|
||||||
open var scrolledListener: ((Float, Float) -> Unit)? = null
|
open var scrolledListener: ((Float, Float) -> Unit) = { _,_ -> }
|
||||||
/** Parameters: relative mouseX, relative mouseY
|
/** Parameters: relative mouseX, relative mouseY
|
||||||
* ClickOnce listeners are only fired when clicked with primary mouse button
|
* ClickOnce listeners are only fired when clicked with primary mouse button
|
||||||
* PROTIP: if clickOnceListener does not seem to work, make sure your parent UI is handling touchDown() and touchUp() events!
|
* PROTIP: if clickOnceListener does not seem to work, make sure your parent UI is handling touchDown() and touchUp() events!
|
||||||
*/
|
*/
|
||||||
open var clickOnceListener: ((Int, Int) -> Unit)? = null
|
open var clickOnceListener: ((Int, Int) -> Unit) = { _,_ -> }
|
||||||
open var clickOnceListenerFired = false
|
open var clickOnceListenerFired = false
|
||||||
|
/** Parameters: relative mouseX, mouseY */
|
||||||
|
open var mouseUpListener: ((Int, Int) -> Unit) = { _,_, -> }
|
||||||
|
|
||||||
/** Since gamepads can't just choose which UIItem to control, this variable is used to allow processing of
|
/** Since gamepads can't just choose which UIItem to control, this variable is used to allow processing of
|
||||||
* gamepad button events for one or more UIItems in one or more UICanvases. */
|
* gamepad button events for one or more UIItems in one or more UICanvases. */
|
||||||
@@ -139,11 +140,9 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
open fun update(delta: Float) {
|
open fun update(delta: Float) {
|
||||||
if (parentUI.isVisible) {
|
if (parentUI.isVisible) {
|
||||||
if (updateListener != null) {
|
updateListener.invoke(delta)
|
||||||
updateListener!!.invoke(delta)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isActive) {
|
// if (isActive) {
|
||||||
mouseOverCall?.update(delta)
|
mouseOverCall?.update(delta)
|
||||||
|
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
@@ -152,13 +151,14 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
}
|
}
|
||||||
|
|
||||||
mouseOverCall?.updateUI(delta)
|
mouseOverCall?.updateUI(delta)
|
||||||
|
mouseUpListener.invoke(itemRelativeMouseX, itemRelativeMouseY)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mouseOverCall?.isVisible == true) {
|
if (mouseOverCall?.isVisible == true) {
|
||||||
mouseOverCall?.setAsClose()
|
mouseOverCall?.setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!mouseUp) mouseLatched = false
|
if (!mouseUp) mouseLatched = false
|
||||||
}
|
}
|
||||||
@@ -169,36 +169,36 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
*/
|
*/
|
||||||
open fun render(batch: SpriteBatch, camera: Camera) {
|
open fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
if (parentUI.isVisible) {
|
if (parentUI.isVisible) {
|
||||||
if (isActive) {
|
// if (isActive) {
|
||||||
mouseOverCall?.render(batch, camera)
|
mouseOverCall?.render(batch, camera)
|
||||||
|
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
mouseOverCall?.renderUI(batch, camera)
|
mouseOverCall?.renderUI(batch, camera)
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyboard controlled
|
// keyboard controlled
|
||||||
open fun keyDown(keycode: Int): Boolean {
|
open fun keyDown(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && keyDownListener != null && isActive) {
|
if (parentUI.isVisible && isActive) {
|
||||||
keyDownListener!!.invoke(keycode)
|
keyDownListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyUp(keycode: Int): Boolean {
|
open fun keyUp(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && keyUpListener != null && isActive) {
|
if (parentUI.isVisible && isActive) {
|
||||||
keyUpListener!!.invoke(keycode)
|
keyUpListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyTyped(character: Char): Boolean {
|
open fun keyTyped(character: Char): Boolean {
|
||||||
if (parentUI.isVisible && keyTypedListener != null && isActive) {
|
if (parentUI.isVisible && isActive) {
|
||||||
keyTypedListener!!.invoke(character)
|
keyTypedListener.invoke(character)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,26 +207,24 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
// mouse controlled
|
// mouse controlled
|
||||||
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||||
if (parentUI.isVisible && touchDraggedListener != null && isActive) {
|
if (parentUI.isVisible && isActive) {
|
||||||
touchDraggedListener!!.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
// FIXME does not work with magnified screen
|
|
||||||
|
|
||||||
var actionDone = false
|
var actionDone = false
|
||||||
|
|
||||||
if (parentUI.isVisible && isActive) {
|
if (parentUI.isVisible && isActive) {
|
||||||
if (touchDownListener != null && mouseUp) {
|
if (mouseUp) {
|
||||||
touchDownListener!!.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
touchDownListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
||||||
actionDone = true
|
actionDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clickOnceListener != null && !clickOnceListenerFired && mouseUp && button == App.getConfigInt("config_mouseprimary")) {
|
if (!clickOnceListenerFired && mouseUp && button == App.getConfigInt("config_mouseprimary")) {
|
||||||
clickOnceListener!!.invoke(itemRelativeMouseX, itemRelativeMouseY)
|
clickOnceListener.invoke(itemRelativeMouseX, itemRelativeMouseY)
|
||||||
actionDone = true
|
actionDone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,16 +234,16 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
clickOnceListenerFired = false
|
clickOnceListenerFired = false
|
||||||
|
|
||||||
if (parentUI.isVisible && touchUpListener != null && mouseUp) {
|
if (parentUI.isVisible && mouseUp) {
|
||||||
touchUpListener!!.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
touchUpListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun scrolled(amountX: Float, amountY: Float): Boolean {
|
open fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (parentUI.isVisible && scrolledListener != null && mouseUp && isActive) {
|
if (parentUI.isVisible && mouseUp && isActive) {
|
||||||
scrolledListener!!.invoke(amountX, amountY)
|
scrolledListener.invoke(amountX, amountY)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,45 +85,6 @@ class UIItemIntSlider(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO unimplemented
|
|
||||||
|
|
||||||
|
|
||||||
override val mouseUp: Boolean
|
|
||||||
get() = super.mouseUp
|
|
||||||
override val mousePushed: Boolean
|
|
||||||
get() = super.mousePushed
|
|
||||||
override val mouseOverCall: UICanvas?
|
|
||||||
get() = super.mouseOverCall
|
|
||||||
override var updateListener: ((Float) -> Unit)?
|
|
||||||
get() = super.updateListener
|
|
||||||
set(_) {}
|
|
||||||
override var keyDownListener: ((Int) -> Unit)?
|
|
||||||
get() = super.keyDownListener
|
|
||||||
set(_) {}
|
|
||||||
override var keyUpListener: ((Int) -> Unit)?
|
|
||||||
get() = super.keyUpListener
|
|
||||||
set(_) {}
|
|
||||||
override var touchDraggedListener: ((Int, Int, Int) -> Unit)?
|
|
||||||
get() = super.touchDraggedListener
|
|
||||||
set(_) {}
|
|
||||||
override var touchDownListener: ((Int, Int, Int, Int) -> Unit)?
|
|
||||||
get() = super.touchDownListener
|
|
||||||
set(_) {}
|
|
||||||
override var touchUpListener: ((Int, Int, Int, Int) -> Unit)?
|
|
||||||
get() = super.touchUpListener
|
|
||||||
set(_) {}
|
|
||||||
override var scrolledListener: ((Float, Float) -> Unit)?
|
|
||||||
get() = super.scrolledListener
|
|
||||||
set(_) {}
|
|
||||||
override var clickOnceListener: ((Int, Int) -> Unit)?
|
|
||||||
get() = super.clickOnceListener
|
|
||||||
set(_) {}
|
|
||||||
override var clickOnceListenerFired: Boolean
|
|
||||||
get() = super.clickOnceListenerFired
|
|
||||||
set(_) {}
|
|
||||||
override var controllerInFocus: Boolean
|
|
||||||
get() = super.controllerInFocus
|
|
||||||
set(_) {}
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
|||||||
Reference in New Issue
Block a user