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

@@ -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
}
}