preliminary gui thing for teleportation

This commit is contained in:
minjaesong
2023-07-03 17:46:57 +09:00
parent fcaf4c97f1
commit 13185f0565
11 changed files with 113 additions and 78 deletions

View File

@@ -1,15 +1,16 @@
{
"GAME_32BIT_WARNING1": "It looks like youre running a 32-Bit version of Java.",
"GAME_32BIT_WARNING2": "Please download and install the latest 64-Bit Java at:",
"GAME_32BIT_WARNING3": "https://www.java.com/en/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_WARNING2": "Please use the native build for improved performance and gameplay experiences.",
"APP_NOMODULE_1": "No Module is currently loaded.",
"APP_NOMODULE_2": "Please configure your Load Order and restart:",
"MENU_LABEL_KEYCONFIG_HELP1": "Click On the Keycap to Assign Actions",
"GAME_PREV_SAVE_WAS_LOADED1": "The most recently saved game was corrupted.",
"GAME_PREV_SAVE_WAS_LOADED2": "The previously saved game was loaded.",
"GAME_MORE_RECENT_AUTOSAVE1": "The Autosave is more recent than the manual save.",
"GAME_MORE_RECENT_AUTOSAVE2": "Please select the saved game you wish to play:",
"MENU_LABEL_SAVE_WILL_BE_DELETED": "The selected save file will be deleted."
}
"GAME_32BIT_WARNING1": "32비트 버전의 Java를 사용중인 것 같습니다.",
"GAME_32BIT_WARNING2": "아래 링크에서 최신 64비트 Java를 내려받아 설치해주세요.",
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
"GAME_APPLE_ROSETTA_WARNING1": "Apple Silicon이 탑재된 Mac을 사용 중이지만 x86 빌드의 게임을 실행 중입니다.",
"GAME_APPLE_ROSETTA_WARNING2": "최적의 성능과 게임 경험을 위해 Apple Silicon용 빌드의 게임을 이용해 주십시오.",
"APP_NOMODULE_1": "현재 불러와진 모듈이 없습니다.",
"APP_NOMODULE_2": "다음의 파일에서 불러오기 순서를 설정하고 게임을 재시작하십시오.",
"MENU_LABEL_KEYCONFIG_HELP1": "키캡을 클릭해 컨트롤을 배정하십시오",
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해 주십시오.",
"MENU_LABEL_SAVE_WILL_BE_DELETED": "선택된 세이브가 삭제됩니다.",
"MENU_LABEL_UNSAVED_PROGRESSES_WILL_BE_LOST": "저장하지 않은 변동사항을 잃게 됩니다."
}

View File

@@ -13,10 +13,20 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
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 {
enum class MarkerMode {
FIXTURE_GHOST, BLOCK_MARKER
}
private val defaultSize = 16.0
override var referenceID: ActorID = 2147483647 // custom refID
@@ -29,7 +39,7 @@ class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = Phy
get() = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common")
private var ghost: SpriteAnimation? = null
private var hasGhost = false
var markerMode: MarkerMode = MarkerMode.FIXTURE_GHOST
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
}
override fun drawBody(batch: SpriteBatch) {
if (isVisible) {
if (hasGhost) {
if (markerMode == MarkerMode.FIXTURE_GHOST) {
if (INGAME.actorNowPlaying != null) {
mouseInInteractableRange(INGAME.actorNowPlaying!!) {
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.color = markerColour
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) {
ghost = actor.sprite
hasGhost = true
markerMode = MarkerMode.FIXTURE_GHOST
hitbox.setDimension(actor.baseHitboxW.toDouble(), actor.baseHitboxH.toDouble())
}
fun unsetGhost() {
ghost = null
hasGhost = false
setGhostColourNone()
hitbox.setDimension(TILE_SIZED, TILE_SIZED)
}

View File

@@ -262,7 +262,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
}
IngameRenderer.setRenderedWorld(world)
blockMarkingActor.isVisible = true
super.show() // this function sets gameInitialised = true
}
@@ -863,7 +863,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
//notifier.update(delta)
// open/close fake blur UI according to what's opened
if (uiInventoryPlayer.isVisible ||
getUIFixture.get()?.isVisible == true) {
getUIFixture.get()?.isVisible == true || worldTransitionOngoing) {
uiBlur.setAsOpen()
}
else {
@@ -880,16 +880,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
if (saveRequested) {
saveRequested = false
doForceSave()
}
if (doThingsAfterSave) {
saveRequested = false
saveRequested2 = false
doThingsAfterSave = false
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 doThingsAfterSave = false
override fun requestForceSave(callback: () -> Unit) {
saveCallback = callback
saveRequested = true
worldTransitionOngoing = true
saveRequested2 = true
worldTransitionPauseRequested = 1
blockMarkingActor.isVisible = false
}
internal fun doForceSave() {
// TODO show appropriate UI
// uiBlur.setAsOpen()
saveTheGame({ // onSuccessful
System.gc()
autosaveTimer = 0f
// TODO hide appropriate UI
uiBlur.setAsClose()
doThingsAfterSave = true
}, { // onError
// TODO show failure message
// TODO hide appropriate UI
uiBlur.setAsClose()
})
}

View File

@@ -68,7 +68,6 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
(INGAME as TerrarumIngame).blockMarkingActor.let {
it.setGhost(ghostItem.get())
it.isVisible = true
it.update(delta)
it.setGhostColourBlock()
mouseInInteractableRange(actor) { it.setGhostColourAllow(); 0L }
@@ -80,7 +79,6 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
(INGAME as TerrarumIngame).blockMarkingActor.let {
it.unsetGhost()
it.isVisible = false
it.setGhostColourNone()
}
}

View File

@@ -14,7 +14,6 @@ import net.torvald.terrarum.itemproperties.CraftingCodex
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
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.ui.Toolkit
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

View File

@@ -50,7 +50,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
defaultSelection = null
)
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,
INVENTORY_CELLS_OFFSET_Y() + (INVENTORY_CELLS_UI_HEIGHT - (DEFAULT_LINE_HEIGHT * 3)) / 2,
gameMenuListWidth, DEFAULT_LINE_HEIGHT * 3,
@@ -60,7 +60,12 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
highlightBackCol = Color(0),
inactiveCol = Color.WHITE,
defaultSelection = null
)
).also {
listOf(it.buttons[0], it.buttons[1]).forEach {
it.skipUpdate = true
it.isActive = false
}
}
/*private val areYouSureQuitButtons = UIItemTextButtonList(
this, DEFAULT_LINE_HEIGHT, arrayOf("MENU_LABEL_DESKTOP_QUESTION", "MENU_LABEL_DESKTOP", "MENU_LABEL_CANCEL"),
(width - gameMenuListWidth) / 2,
@@ -155,11 +160,11 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
}
areYouSureMainMenuButtons.selectionChangeListener = { _, new ->
when (new) {
1 -> {
2 -> {
areYouSureMainMenuButtons.deselect()
App.setScreen(TitleScreen(App.batch))
}
2 -> {
3 -> {
screen = 0; areYouSureMainMenuButtons.deselect()
}
}

View File

@@ -136,9 +136,9 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
}
private fun disableListEditButtons() {
buttonRename.isActive = false
buttonDelete.isActive = false
buttonTeleport.isActive = false
buttonRename.isEnabled = false
buttonDelete.isEnabled = false
buttonTeleport.isEnabled = false
currentWorldSelected = false
}
@@ -147,9 +147,9 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
if (info == null) disableListEditButtons()
else {
buttonRename.isActive = true
buttonDelete.isActive = info.uuid != INGAME.world.worldIndex
buttonTeleport.isActive = info.uuid != INGAME.world.worldIndex
buttonRename.isEnabled = true
buttonDelete.isEnabled = info.uuid != INGAME.world.worldIndex
buttonTeleport.isEnabled = info.uuid != INGAME.world.worldIndex
currentWorldSelected = info.uuid == INGAME.world.worldIndex
}
}

View File

@@ -64,7 +64,7 @@ class ConsoleWindow : UICanvas() {
init {
reset()
addUIitem(textinput)
textinput.isActive = false
textinput.isEnabled = false
}
private val lb = ArrayList<String>()
@@ -99,7 +99,7 @@ class ConsoleWindow : UICanvas() {
clickLatched = false
}
textinput.isActive = (isOpened && !isClosing)
textinput.isEnabled = (isOpened && !isClosing)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
@@ -269,14 +269,14 @@ class ConsoleWindow : UICanvas() {
drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(),
0f, -height.toFloat()
)*/
textinput.isActive = false
textinput.isEnabled = false
textinput.mouseoverUpdateLatch = false
}
override fun endOpening(delta: Float) {
drawOffY = 0f
openingTimeCounter = 0f
textinput.isActive = true
textinput.isEnabled = true
textinput.mouseoverUpdateLatch = true
}

View File

@@ -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
*/
open var isEnabled = true
/**
* Whether the button should receive updates
*/
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) {
if (parentUI.isVisible) {
updateListener.invoke(delta)
if (isActive) {
updateListener.invoke(delta)
// if (isActive) {
mouseOverCall?.update(delta)
if (mouseUp) {
@@ -158,9 +163,9 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
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
open fun keyDown(keycode: Int): Boolean {
if (parentUI.isVisible && isActive) {
if (parentUI.isVisible && isEnabled) {
keyDownListener.invoke(keycode)
return true
}
@@ -189,7 +194,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
return false
}
open fun keyUp(keycode: Int): Boolean {
if (parentUI.isVisible && isActive) {
if (parentUI.isVisible && isEnabled) {
keyUpListener.invoke(keycode)
return true
}
@@ -197,7 +202,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
return false
}
open fun keyTyped(character: Char): Boolean {
if (parentUI.isVisible && isActive) {
if (parentUI.isVisible && isEnabled) {
keyTypedListener.invoke(character)
return true
}
@@ -207,7 +212,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
// mouse controlled
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
if (parentUI.isVisible && isActive) {
if (parentUI.isVisible && isEnabled) {
touchDraggedListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer)
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 {
var actionDone = false
if (parentUI.isVisible && isActive) {
if (parentUI.isVisible && isEnabled) {
if (mouseUp) {
touchDownListener.invoke(itemRelativeMouseX, itemRelativeMouseY, pointer, button)
actionDone = true
@@ -242,7 +247,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
return false
}
open fun scrolled(amountX: Float, amountY: Float): Boolean {
if (parentUI.isVisible && mouseUp && isActive) {
if (parentUI.isVisible && mouseUp && isEnabled) {
scrolledListener.invoke(amountX, amountY)
return true
}

View File

@@ -23,21 +23,21 @@ open class UIItemTextButton(
val readFromLang: Boolean = false,
/** 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 */
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
var activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
/** Colour when mouse is over */
val activeBackBlendMode: String = BlendMode.NORMAL,
var activeBackBlendMode: String = BlendMode.NORMAL,
/** Colour when clicked/selected */
val highlightCol: Color = Toolkit.Theme.COL_SELECTED,
var highlightCol: Color = Toolkit.Theme.COL_SELECTED,
/** Colour when clicked/selected */
val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
var highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
/** Colour when clicked/selected */
val highlightBackBlendMode: String = BlendMode.NORMAL,
var highlightBackBlendMode: String = BlendMode.NORMAL,
/** 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,
@@ -59,6 +59,8 @@ open class UIItemTextButton(
}
}
var skipUpdate = false
/** Actually displayed text (changes with the app language) */
val label: String
get() = if (readFromLang) Lang[labelText] else labelText
@@ -70,8 +72,6 @@ open class UIItemTextButton(
override fun update(delta: Float) {
super.update(delta)
}
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 (mouseUp) activeCol
else inactiveCol

View File

@@ -101,7 +101,7 @@ class UIItemTextLineInput(
false
)
override var isActive: Boolean = false // keep it false by default!
override var isEnabled: Boolean = false // keep it false by default!
set(value) {
if (field && !value) endComposing(true)
field = value
@@ -132,7 +132,7 @@ class UIItemTextLineInput(
if (!value) {
mouseLatched = false
fboUpdateLatch = false
isActive = false
isEnabled = false
cursorOn = false
cursorBlinkCounter = 0f
}
@@ -251,10 +251,10 @@ class UIItemTextLineInput(
}
override fun inputStrobed(e: TerrarumKeyboardEvent) {
val oldActive = isActive
val oldActive = isEnabled
// process keypresses
if (isActive) {
if (isEnabled) {
val (eventType, char, headkey, repeatCount, keycodes) = e
@@ -416,12 +416,12 @@ class UIItemTextLineInput(
val mouseDown = Terrarum.mouseDown
if (mouseDown) {
isActive = mouseUp
isEnabled = mouseUp
}
if (App.getConfigString("inputmethod") == "none") imeOn = false
if (isActive) {
if (isEnabled) {
cursorBlinkCounter += delta
while (cursorBlinkCounter >= CURSOR_BLINK_TIME) {
@@ -553,7 +553,7 @@ class UIItemTextLineInput(
Toolkit.drawBoxBorder(batch, btn1PosX - 1, posY - 1, WIDTH_ONEBUTTON + 2, height + 2)
// text area border (pop-up for isActive)
if (isActive) {
if (isEnabled) {
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
}
@@ -567,7 +567,7 @@ class UIItemTextLineInput(
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)
}
else if (mouseUpOnTextArea && !isActive) {
else if (mouseUpOnTextArea && !isEnabled) {
batch.color = Toolkit.Theme.COL_MOUSE_UP
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
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
batch.color = baseCol.cpy().mul(0.5f,0.5f,0.5f,1f)