mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
preliminary gui thing for teleportation
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"GAME_32BIT_WARNING1": "It looks like you’re running a 32-Bit version of Java.",
|
"GAME_32BIT_WARNING1": "32비트 버전의 Java를 사용중인 것 같습니다.",
|
||||||
"GAME_32BIT_WARNING2": "Please download and install the latest 64-Bit Java at:",
|
"GAME_32BIT_WARNING2": "아래 링크에서 최신 64비트 Java를 내려받아 설치해주세요.",
|
||||||
"GAME_32BIT_WARNING3": "https://www.java.com/en/download/",
|
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
|
||||||
"GAME_APPLE_ROSETTA_WARNING1": "It seems you are using a Mac with Apple Silicon but running the x86 build of the game.",
|
"GAME_APPLE_ROSETTA_WARNING1": "Apple Silicon이 탑재된 Mac을 사용 중이지만 x86 빌드의 게임을 실행 중입니다.",
|
||||||
"GAME_APPLE_ROSETTA_WARNING2": "Please use the native build for improved performance and gameplay experiences.",
|
"GAME_APPLE_ROSETTA_WARNING2": "최적의 성능과 게임 경험을 위해 Apple Silicon용 빌드의 게임을 이용해 주십시오.",
|
||||||
"APP_NOMODULE_1": "No Module is currently loaded.",
|
"APP_NOMODULE_1": "현재 불러와진 모듈이 없습니다.",
|
||||||
"APP_NOMODULE_2": "Please configure your Load Order and restart:",
|
"APP_NOMODULE_2": "다음의 파일에서 불러오기 순서를 설정하고 게임을 재시작하십시오.",
|
||||||
"MENU_LABEL_KEYCONFIG_HELP1": "Click On the Keycap to Assign Actions",
|
"MENU_LABEL_KEYCONFIG_HELP1": "키캡을 클릭해 컨트롤을 배정하십시오",
|
||||||
"GAME_PREV_SAVE_WAS_LOADED1": "The most recently saved game was corrupted.",
|
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
|
||||||
"GAME_PREV_SAVE_WAS_LOADED2": "The previously saved game was loaded.",
|
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
|
||||||
"GAME_MORE_RECENT_AUTOSAVE1": "The Autosave is more recent than the manual save.",
|
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
|
||||||
"GAME_MORE_RECENT_AUTOSAVE2": "Please select the saved game you wish to play:",
|
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해 주십시오.",
|
||||||
"MENU_LABEL_SAVE_WILL_BE_DELETED": "The selected save file will be deleted."
|
"MENU_LABEL_SAVE_WILL_BE_DELETED": "선택된 세이브가 삭제됩니다.",
|
||||||
|
"MENU_LABEL_UNSAVED_PROGRESSES_WILL_BE_LOST": "저장하지 않은 변동사항을 잃게 됩니다."
|
||||||
}
|
}
|
||||||
@@ -13,10 +13,20 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as construction markers and fixture ghost images
|
* Used as construction markers and fixture ghost images.
|
||||||
|
*
|
||||||
|
* `isVisible` behaves differently by `markerMode`.
|
||||||
|
* - FIXTURE_GHOST: `isVisible` toggles if the ghost is being updated. FALSE - will not be updated and also not visible
|
||||||
|
* - BLOCK_MARKER: `isVisible` controls the visibility. FALSE - invisible, TRUE - always visible
|
||||||
|
*
|
||||||
|
* MarkerMode must be set manually after calling `setGhost` -- the `unsetGhost` will not reset the field.
|
||||||
*/
|
*/
|
||||||
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT), NoSerialise {
|
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT), NoSerialise {
|
||||||
|
|
||||||
|
enum class MarkerMode {
|
||||||
|
FIXTURE_GHOST, BLOCK_MARKER
|
||||||
|
}
|
||||||
|
|
||||||
private val defaultSize = 16.0
|
private val defaultSize = 16.0
|
||||||
|
|
||||||
override var referenceID: ActorID = 2147483647 // custom refID
|
override var referenceID: ActorID = 2147483647 // custom refID
|
||||||
@@ -29,7 +39,7 @@ class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = Phy
|
|||||||
get() = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common")
|
get() = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common")
|
||||||
|
|
||||||
private var ghost: SpriteAnimation? = null
|
private var ghost: SpriteAnimation? = null
|
||||||
private var hasGhost = false
|
var markerMode: MarkerMode = MarkerMode.FIXTURE_GHOST
|
||||||
var ghostColour = Color.WHITE
|
var ghostColour = Color.WHITE
|
||||||
|
|
||||||
|
|
||||||
@@ -38,9 +48,10 @@ class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = Phy
|
|||||||
renderOrder = Actor.RenderOrder.OVERLAY // for some reason the constructor didn't work
|
renderOrder = Actor.RenderOrder.OVERLAY // for some reason the constructor didn't work
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun drawBody(batch: SpriteBatch) {
|
override fun drawBody(batch: SpriteBatch) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
if (hasGhost) {
|
if (markerMode == MarkerMode.FIXTURE_GHOST) {
|
||||||
if (INGAME.actorNowPlaying != null) {
|
if (INGAME.actorNowPlaying != null) {
|
||||||
mouseInInteractableRange(INGAME.actorNowPlaying!!) {
|
mouseInInteractableRange(INGAME.actorNowPlaying!!) {
|
||||||
batch.shader = App.shaderGhastlyWhite
|
batch.shader = App.shaderGhastlyWhite
|
||||||
@@ -59,7 +70,7 @@ class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = Phy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (markerMode == MarkerMode.BLOCK_MARKER) {
|
||||||
batch.shader = null
|
batch.shader = null
|
||||||
batch.color = markerColour
|
batch.color = markerColour
|
||||||
batch.draw(blockMarkings.get(markerShape, 0), hitbox.startX.toFloat(), hitbox.startY.toFloat())
|
batch.draw(blockMarkings.get(markerShape, 0), hitbox.startX.toFloat(), hitbox.startY.toFloat())
|
||||||
@@ -91,13 +102,12 @@ class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = Phy
|
|||||||
|
|
||||||
fun setGhost(actor: ActorWithBody) {
|
fun setGhost(actor: ActorWithBody) {
|
||||||
ghost = actor.sprite
|
ghost = actor.sprite
|
||||||
hasGhost = true
|
markerMode = MarkerMode.FIXTURE_GHOST
|
||||||
hitbox.setDimension(actor.baseHitboxW.toDouble(), actor.baseHitboxH.toDouble())
|
hitbox.setDimension(actor.baseHitboxW.toDouble(), actor.baseHitboxH.toDouble())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unsetGhost() {
|
fun unsetGhost() {
|
||||||
ghost = null
|
ghost = null
|
||||||
hasGhost = false
|
|
||||||
setGhostColourNone()
|
setGhostColourNone()
|
||||||
hitbox.setDimension(TILE_SIZED, TILE_SIZED)
|
hitbox.setDimension(TILE_SIZED, TILE_SIZED)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IngameRenderer.setRenderedWorld(world)
|
IngameRenderer.setRenderedWorld(world)
|
||||||
|
blockMarkingActor.isVisible = true
|
||||||
|
|
||||||
super.show() // this function sets gameInitialised = true
|
super.show() // this function sets gameInitialised = true
|
||||||
}
|
}
|
||||||
@@ -863,7 +863,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
//notifier.update(delta)
|
//notifier.update(delta)
|
||||||
// open/close fake blur UI according to what's opened
|
// open/close fake blur UI according to what's opened
|
||||||
if (uiInventoryPlayer.isVisible ||
|
if (uiInventoryPlayer.isVisible ||
|
||||||
getUIFixture.get()?.isVisible == true) {
|
getUIFixture.get()?.isVisible == true || worldTransitionOngoing) {
|
||||||
uiBlur.setAsOpen()
|
uiBlur.setAsOpen()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -880,16 +880,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
|
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
|
||||||
|
|
||||||
if (saveRequested) {
|
|
||||||
saveRequested = false
|
|
||||||
doForceSave()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doThingsAfterSave) {
|
if (doThingsAfterSave) {
|
||||||
saveRequested = false
|
saveRequested2 = false
|
||||||
doThingsAfterSave = false
|
doThingsAfterSave = false
|
||||||
saveCallback!!()
|
saveCallback!!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saveRequested2) {
|
||||||
|
saveRequested2 = false
|
||||||
|
doForceSave()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldTransitionPauseRequested > 0) { // let a frame to update before locking (=pausing) entirely
|
||||||
|
worldTransitionPauseRequested -= 1
|
||||||
|
}
|
||||||
|
else if (worldTransitionPauseRequested == 0) {
|
||||||
|
paused = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -926,29 +935,36 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var saveRequested = false
|
private var worldTransitionOngoing = false
|
||||||
|
private var worldTransitionPauseRequested = -1
|
||||||
|
private var saveRequested2 = false
|
||||||
private var saveCallback: (() -> Unit)? = null
|
private var saveCallback: (() -> Unit)? = null
|
||||||
private var doThingsAfterSave = false
|
private var doThingsAfterSave = false
|
||||||
|
|
||||||
override fun requestForceSave(callback: () -> Unit) {
|
override fun requestForceSave(callback: () -> Unit) {
|
||||||
saveCallback = callback
|
saveCallback = callback
|
||||||
saveRequested = true
|
worldTransitionOngoing = true
|
||||||
|
saveRequested2 = true
|
||||||
|
worldTransitionPauseRequested = 1
|
||||||
|
blockMarkingActor.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun doForceSave() {
|
internal fun doForceSave() {
|
||||||
// TODO show appropriate UI
|
// TODO show appropriate UI
|
||||||
|
// uiBlur.setAsOpen()
|
||||||
|
|
||||||
saveTheGame({ // onSuccessful
|
saveTheGame({ // onSuccessful
|
||||||
System.gc()
|
System.gc()
|
||||||
autosaveTimer = 0f
|
autosaveTimer = 0f
|
||||||
|
|
||||||
// TODO hide appropriate UI
|
// TODO hide appropriate UI
|
||||||
|
uiBlur.setAsClose()
|
||||||
doThingsAfterSave = true
|
doThingsAfterSave = true
|
||||||
}, { // onError
|
}, { // onError
|
||||||
// TODO show failure message
|
// TODO show failure message
|
||||||
|
|
||||||
// TODO hide appropriate UI
|
// TODO hide appropriate UI
|
||||||
|
uiBlur.setAsClose()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
|||||||
|
|
||||||
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
||||||
it.setGhost(ghostItem.get())
|
it.setGhost(ghostItem.get())
|
||||||
it.isVisible = true
|
|
||||||
it.update(delta)
|
it.update(delta)
|
||||||
it.setGhostColourBlock()
|
it.setGhostColourBlock()
|
||||||
mouseInInteractableRange(actor) { it.setGhostColourAllow(); 0L }
|
mouseInInteractableRange(actor) { it.setGhostColourAllow(); 0L }
|
||||||
@@ -80,7 +79,6 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
|||||||
|
|
||||||
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
(INGAME as TerrarumIngame).blockMarkingActor.let {
|
||||||
it.unsetGhost()
|
it.unsetGhost()
|
||||||
it.isVisible = false
|
|
||||||
it.setGhostColourNone()
|
it.setGhostColourNone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import net.torvald.terrarum.itemproperties.CraftingCodex
|
|||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||||
import net.torvald.terrarum.modulebasegame.ui.*
|
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
@@ -387,7 +386,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonCraft.isActive = itemCraftable
|
buttonCraft.isEnabled = itemCraftable
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset whatever player has selected to null and bring UI to its initial state
|
// reset whatever player has selected to null and bring UI to its initial state
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
)
|
||||||
private val areYouSureMainMenuButtons = UIItemTextButtonList(
|
private val areYouSureMainMenuButtons = UIItemTextButtonList(
|
||||||
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_QUIT_CONFIRM", "MENU_LABEL_QUIT", "MENU_LABEL_CANCEL"),
|
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_QUIT_CONFIRM", "MENU_LABEL_UNSAVED_PROGRESSES_WILL_BE_LOST", "MENU_LABEL_QUIT", "MENU_LABEL_CANCEL"),
|
||||||
(width - gameMenuListWidth) / 2,
|
(width - gameMenuListWidth) / 2,
|
||||||
INVENTORY_CELLS_OFFSET_Y() + (INVENTORY_CELLS_UI_HEIGHT - (DEFAULT_LINE_HEIGHT * 3)) / 2,
|
INVENTORY_CELLS_OFFSET_Y() + (INVENTORY_CELLS_UI_HEIGHT - (DEFAULT_LINE_HEIGHT * 3)) / 2,
|
||||||
gameMenuListWidth, DEFAULT_LINE_HEIGHT * 3,
|
gameMenuListWidth, DEFAULT_LINE_HEIGHT * 3,
|
||||||
@@ -60,7 +60,12 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
highlightBackCol = Color(0),
|
highlightBackCol = Color(0),
|
||||||
inactiveCol = Color.WHITE,
|
inactiveCol = Color.WHITE,
|
||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
).also {
|
||||||
|
listOf(it.buttons[0], it.buttons[1]).forEach {
|
||||||
|
it.skipUpdate = true
|
||||||
|
it.isActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
/*private val areYouSureQuitButtons = UIItemTextButtonList(
|
/*private val areYouSureQuitButtons = UIItemTextButtonList(
|
||||||
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_DESKTOP_QUESTION", "MENU_LABEL_DESKTOP", "MENU_LABEL_CANCEL"),
|
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_DESKTOP_QUESTION", "MENU_LABEL_DESKTOP", "MENU_LABEL_CANCEL"),
|
||||||
(width - gameMenuListWidth) / 2,
|
(width - gameMenuListWidth) / 2,
|
||||||
@@ -155,11 +160,11 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
}
|
}
|
||||||
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
1 -> {
|
2 -> {
|
||||||
areYouSureMainMenuButtons.deselect()
|
areYouSureMainMenuButtons.deselect()
|
||||||
App.setScreen(TitleScreen(App.batch))
|
App.setScreen(TitleScreen(App.batch))
|
||||||
}
|
}
|
||||||
2 -> {
|
3 -> {
|
||||||
screen = 0; areYouSureMainMenuButtons.deselect()
|
screen = 0; areYouSureMainMenuButtons.deselect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun disableListEditButtons() {
|
private fun disableListEditButtons() {
|
||||||
buttonRename.isActive = false
|
buttonRename.isEnabled = false
|
||||||
buttonDelete.isActive = false
|
buttonDelete.isEnabled = false
|
||||||
buttonTeleport.isActive = false
|
buttonTeleport.isEnabled = false
|
||||||
currentWorldSelected = false
|
currentWorldSelected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,9 +147,9 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
|
|
||||||
if (info == null) disableListEditButtons()
|
if (info == null) disableListEditButtons()
|
||||||
else {
|
else {
|
||||||
buttonRename.isActive = true
|
buttonRename.isEnabled = true
|
||||||
buttonDelete.isActive = info.uuid != INGAME.world.worldIndex
|
buttonDelete.isEnabled = info.uuid != INGAME.world.worldIndex
|
||||||
buttonTeleport.isActive = info.uuid != INGAME.world.worldIndex
|
buttonTeleport.isEnabled = info.uuid != INGAME.world.worldIndex
|
||||||
currentWorldSelected = info.uuid == INGAME.world.worldIndex
|
currentWorldSelected = info.uuid == INGAME.world.worldIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ConsoleWindow : UICanvas() {
|
|||||||
init {
|
init {
|
||||||
reset()
|
reset()
|
||||||
addUIitem(textinput)
|
addUIitem(textinput)
|
||||||
textinput.isActive = false
|
textinput.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private val lb = ArrayList<String>()
|
private val lb = ArrayList<String>()
|
||||||
@@ -99,7 +99,7 @@ class ConsoleWindow : UICanvas() {
|
|||||||
clickLatched = false
|
clickLatched = false
|
||||||
}
|
}
|
||||||
|
|
||||||
textinput.isActive = (isOpened && !isClosing)
|
textinput.isEnabled = (isOpened && !isClosing)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
@@ -269,14 +269,14 @@ class ConsoleWindow : UICanvas() {
|
|||||||
drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(),
|
drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(),
|
||||||
0f, -height.toFloat()
|
0f, -height.toFloat()
|
||||||
)*/
|
)*/
|
||||||
textinput.isActive = false
|
textinput.isEnabled = false
|
||||||
textinput.mouseoverUpdateLatch = false
|
textinput.mouseoverUpdateLatch = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endOpening(delta: Float) {
|
override fun endOpening(delta: Float) {
|
||||||
drawOffY = 0f
|
drawOffY = 0f
|
||||||
openingTimeCounter = 0f
|
openingTimeCounter = 0f
|
||||||
textinput.isActive = true
|
textinput.isEnabled = true
|
||||||
textinput.mouseoverUpdateLatch = true
|
textinput.mouseoverUpdateLatch = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,11 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
/**
|
/**
|
||||||
* Whether the button is "available" or not to the player
|
* Whether the button is "available" or not to the player
|
||||||
*/
|
*/
|
||||||
|
open var isEnabled = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the button should receive updates
|
||||||
|
*/
|
||||||
open var isActive = true
|
open var isActive = true
|
||||||
|
|
||||||
|
|
||||||
@@ -140,9 +145,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) {
|
||||||
updateListener.invoke(delta)
|
if (isActive) {
|
||||||
|
updateListener.invoke(delta)
|
||||||
|
|
||||||
// if (isActive) {
|
|
||||||
mouseOverCall?.update(delta)
|
mouseOverCall?.update(delta)
|
||||||
|
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
@@ -158,9 +163,9 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
mouseOverCall?.setAsClose()
|
mouseOverCall?.setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
if (!mouseUp) mouseLatched = false
|
if (!mouseUp) mouseLatched = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +186,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
|
|
||||||
// keyboard controlled
|
// keyboard controlled
|
||||||
open fun keyDown(keycode: Int): Boolean {
|
open fun keyDown(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && isActive) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyDownListener.invoke(keycode)
|
keyDownListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -189,7 +194,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyUp(keycode: Int): Boolean {
|
open fun keyUp(keycode: Int): Boolean {
|
||||||
if (parentUI.isVisible && isActive) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyUpListener.invoke(keycode)
|
keyUpListener.invoke(keycode)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -197,7 +202,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun keyTyped(character: Char): Boolean {
|
open fun keyTyped(character: Char): Boolean {
|
||||||
if (parentUI.isVisible && isActive) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
keyTypedListener.invoke(character)
|
keyTypedListener.invoke(character)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -207,7 +212,7 @@ 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 && isActive) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -217,7 +222,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
var actionDone = false
|
var actionDone = false
|
||||||
|
|
||||||
if (parentUI.isVisible && isActive) {
|
if (parentUI.isVisible && isEnabled) {
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
touchDownListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
touchDownListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
|
||||||
actionDone = true
|
actionDone = true
|
||||||
@@ -242,7 +247,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
open fun scrolled(amountX: Float, amountY: Float): Boolean {
|
open fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (parentUI.isVisible && mouseUp && isActive) {
|
if (parentUI.isVisible && mouseUp && isEnabled) {
|
||||||
scrolledListener.invoke(amountX, amountY)
|
scrolledListener.invoke(amountX, amountY)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,21 +23,21 @@ open class UIItemTextButton(
|
|||||||
val readFromLang: Boolean = false,
|
val readFromLang: Boolean = false,
|
||||||
|
|
||||||
/** Colour when mouse is over */
|
/** Colour when mouse is over */
|
||||||
val activeCol: Color = Toolkit.Theme.COL_MOUSE_UP,
|
var activeCol: Color = Toolkit.Theme.COL_MOUSE_UP,
|
||||||
/** Colour when mouse is over */
|
/** Colour when mouse is over */
|
||||||
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
var activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
|
||||||
/** Colour when mouse is over */
|
/** Colour when mouse is over */
|
||||||
val activeBackBlendMode: String = BlendMode.NORMAL,
|
var activeBackBlendMode: String = BlendMode.NORMAL,
|
||||||
/** Colour when clicked/selected */
|
/** Colour when clicked/selected */
|
||||||
val highlightCol: Color = Toolkit.Theme.COL_SELECTED,
|
var highlightCol: Color = Toolkit.Theme.COL_SELECTED,
|
||||||
/** Colour when clicked/selected */
|
/** Colour when clicked/selected */
|
||||||
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
var highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
|
||||||
/** Colour when clicked/selected */
|
/** Colour when clicked/selected */
|
||||||
val highlightBackBlendMode: String = BlendMode.NORMAL,
|
var highlightBackBlendMode: String = BlendMode.NORMAL,
|
||||||
/** Colour on normal status */
|
/** Colour on normal status */
|
||||||
val inactiveCol: Color = Toolkit.Theme.COL_LIST_DEFAULT,
|
var inactiveCol: Color = Toolkit.Theme.COL_LIST_DEFAULT,
|
||||||
|
|
||||||
val disabledCol: Color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER,
|
var disabledCol: Color = Toolkit.Theme.COL_INVENTORY_CELL_BORDER,
|
||||||
|
|
||||||
val hasBorder: Boolean = false,
|
val hasBorder: Boolean = false,
|
||||||
|
|
||||||
@@ -59,6 +59,8 @@ open class UIItemTextButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var skipUpdate = false
|
||||||
|
|
||||||
/** Actually displayed text (changes with the app language) */
|
/** Actually displayed text (changes with the app language) */
|
||||||
val label: String
|
val label: String
|
||||||
get() = if (readFromLang) Lang[labelText] else labelText
|
get() = if (readFromLang) Lang[labelText] else labelText
|
||||||
@@ -70,8 +72,6 @@ open class UIItemTextButton(
|
|||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
super.update(delta)
|
super.update(delta)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
@@ -110,7 +110,8 @@ open class UIItemTextButton(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
batch.color = if (!isActive) disabledCol
|
batch.color = if (skipUpdate) inactiveCol
|
||||||
|
else if (!isEnabled) disabledCol
|
||||||
else if (highlighted) highlightCol
|
else if (highlighted) highlightCol
|
||||||
else if (mouseUp) activeCol
|
else if (mouseUp) activeCol
|
||||||
else inactiveCol
|
else inactiveCol
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class UIItemTextLineInput(
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
override var isActive: Boolean = false // keep it false by default!
|
override var isEnabled: Boolean = false // keep it false by default!
|
||||||
set(value) {
|
set(value) {
|
||||||
if (field && !value) endComposing(true)
|
if (field && !value) endComposing(true)
|
||||||
field = value
|
field = value
|
||||||
@@ -132,7 +132,7 @@ class UIItemTextLineInput(
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
mouseLatched = false
|
mouseLatched = false
|
||||||
fboUpdateLatch = false
|
fboUpdateLatch = false
|
||||||
isActive = false
|
isEnabled = false
|
||||||
cursorOn = false
|
cursorOn = false
|
||||||
cursorBlinkCounter = 0f
|
cursorBlinkCounter = 0f
|
||||||
}
|
}
|
||||||
@@ -251,10 +251,10 @@ class UIItemTextLineInput(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun inputStrobed(e: TerrarumKeyboardEvent) {
|
override fun inputStrobed(e: TerrarumKeyboardEvent) {
|
||||||
val oldActive = isActive
|
val oldActive = isEnabled
|
||||||
|
|
||||||
// process keypresses
|
// process keypresses
|
||||||
if (isActive) {
|
if (isEnabled) {
|
||||||
|
|
||||||
val (eventType, char, headkey, repeatCount, keycodes) = e
|
val (eventType, char, headkey, repeatCount, keycodes) = e
|
||||||
|
|
||||||
@@ -416,12 +416,12 @@ class UIItemTextLineInput(
|
|||||||
val mouseDown = Terrarum.mouseDown
|
val mouseDown = Terrarum.mouseDown
|
||||||
|
|
||||||
if (mouseDown) {
|
if (mouseDown) {
|
||||||
isActive = mouseUp
|
isEnabled = mouseUp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.getConfigString("inputmethod") == "none") imeOn = false
|
if (App.getConfigString("inputmethod") == "none") imeOn = false
|
||||||
|
|
||||||
if (isActive) {
|
if (isEnabled) {
|
||||||
cursorBlinkCounter += delta
|
cursorBlinkCounter += delta
|
||||||
|
|
||||||
while (cursorBlinkCounter >= CURSOR_BLINK_TIME) {
|
while (cursorBlinkCounter >= CURSOR_BLINK_TIME) {
|
||||||
@@ -553,7 +553,7 @@ class UIItemTextLineInput(
|
|||||||
Toolkit.drawBoxBorder(batch, btn1PosX - 1, posY - 1, WIDTH_ONEBUTTON + 2, height + 2)
|
Toolkit.drawBoxBorder(batch, btn1PosX - 1, posY - 1, WIDTH_ONEBUTTON + 2, height + 2)
|
||||||
|
|
||||||
// text area border (pop-up for isActive)
|
// text area border (pop-up for isActive)
|
||||||
if (isActive) {
|
if (isEnabled) {
|
||||||
batch.color = Toolkit.Theme.COL_SELECTED
|
batch.color = Toolkit.Theme.COL_SELECTED
|
||||||
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2) // this is a full border, not a text area
|
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, width + 2, height + 2) // this is a full border, not a text area
|
||||||
}
|
}
|
||||||
@@ -567,7 +567,7 @@ class UIItemTextLineInput(
|
|||||||
batch.color = if (mouseDown) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_MOUSE_UP
|
batch.color = if (mouseDown) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_MOUSE_UP
|
||||||
Toolkit.drawBoxBorder(batch, btn1PosX - 1, posY - 1, WIDTH_ONEBUTTON + 2, height + 2)
|
Toolkit.drawBoxBorder(batch, btn1PosX - 1, posY - 1, WIDTH_ONEBUTTON + 2, height + 2)
|
||||||
}
|
}
|
||||||
else if (mouseUpOnTextArea && !isActive) {
|
else if (mouseUpOnTextArea && !isEnabled) {
|
||||||
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
||||||
Toolkit.drawBoxBorder(batch, inputPosX - 1, posY - 1, fbo.width + 2 * UI_TEXT_MARGIN+ 2, height + 2)
|
Toolkit.drawBoxBorder(batch, inputPosX - 1, posY - 1, fbo.width + 2 * UI_TEXT_MARGIN+ 2, height + 2)
|
||||||
}
|
}
|
||||||
@@ -579,7 +579,7 @@ class UIItemTextLineInput(
|
|||||||
|
|
||||||
// draw text cursor
|
// draw text cursor
|
||||||
val cursorXOnScreen = inputPosX + cursorDrawX + 2 + textDrawOffset
|
val cursorXOnScreen = inputPosX + cursorDrawX + 2 + textDrawOffset
|
||||||
if (isActive && cursorOn) {
|
if (isEnabled && cursorOn) {
|
||||||
val baseCol = if (maxLen.exceeds(textbuf, listOf(32))) TEXTINPUT_COL_TEXT_NOMORE else TEXTINPUT_COL_TEXT
|
val baseCol = if (maxLen.exceeds(textbuf, listOf(32))) TEXTINPUT_COL_TEXT_NOMORE else TEXTINPUT_COL_TEXT
|
||||||
|
|
||||||
batch.color = baseCol.cpy().mul(0.5f,0.5f,0.5f,1f)
|
batch.color = baseCol.cpy().mul(0.5f,0.5f,0.5f,1f)
|
||||||
|
|||||||
Reference in New Issue
Block a user