autosave notifier is working but autosave itself is not cued yet

This commit is contained in:
minjaesong
2021-10-02 10:07:07 +09:00
parent 2422dfdeed
commit b6cda92a97
3 changed files with 41 additions and 22 deletions

View File

@@ -35,6 +35,7 @@ import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.serialise.*
import net.torvald.terrarum.tvda.VDUtil
import net.torvald.terrarum.tvda.VirtualDisk
import net.torvald.terrarum.ui.UIAutosaveNotifier
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.utils.RandomWordsName
import net.torvald.terrarum.weather.WeatherMixer
@@ -175,7 +176,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
private lateinit var uiBasicInfo: UICanvas
private lateinit var uiWatchTierOne: UICanvas
lateinit var uiAutosaveNotifier: UIAutosaveNotifier
lateinit var uiCheatMotherfuckerNootNoot: UICheatDetected
@@ -430,6 +431,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
uiBasicInfo.setAsAlwaysVisible()
uiBasicInfo.setPosition((uiQuickBar.posX - uiBasicInfo.width - App.scr.tvSafeActionWidth) / 2 + App.scr.tvSafeActionWidth, uiWatchTierOne.posY)
uiAutosaveNotifier = UIAutosaveNotifier()
uiCheatMotherfuckerNootNoot = UICheatDetected()
@@ -450,6 +452,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// uiBasicInfo, // temporarily commenting out: wouldn't make sense for v 0.3 release
uiWatchTierOne,
UIScreenZoom(),
uiAutosaveNotifier,
uiInventoryPlayer,
getUIFixture,
uiTooltip,
@@ -605,6 +608,14 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
particlesActive = 0
if (KeyToggler.isOn(Input.Keys.SLASH) && !uiAutosaveNotifier.isVisible) {
println("autosave open")
uiAutosaveNotifier.setAsOpen()
}
else if (!KeyToggler.isOn(Input.Keys.SLASH) && uiAutosaveNotifier.isOpened) {
println("autosave close")
uiAutosaveNotifier.setAsClose()
}
// synchronised Ingame Input Updater
// will also queue up the block/wall/wire placed events
@@ -1126,7 +1137,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
((App.scr.width - App.scr.tvSafeGraphicsWidth) - (uiQuickBar.posX + uiQuickBar.width) - uiWatchTierOne.width) / 2 + (uiQuickBar.posX + uiQuickBar.width),
App.scr.tvSafeGraphicsHeight + 8
)
}

View File

@@ -8,8 +8,10 @@ import net.torvald.getKeycapPC
import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumScreenSize
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar.Companion.COMMON_OPEN_CLOSE
import net.torvald.terrarum.ui.Movement
import net.torvald.terrarum.ui.UICanvas
import kotlin.math.roundToInt
/**
* Screen zooms in when the UI is opened; zooms out when being closed.
@@ -25,7 +27,7 @@ class UIScreenZoom : UICanvas(
override var width = App.fontGame.getWidth(zoomText)
override var height = App.fontGame.lineHeight.toInt()
override var openCloseTime = 0.15f
override var openCloseTime = COMMON_OPEN_CLOSE
override val mouseUp = false
@@ -38,11 +40,10 @@ class UIScreenZoom : UICanvas(
override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.color = Color.WHITE
App.fontGame.draw(
batch, zoomText,
(App.scr.width * TerrarumScreenSize.TV_SAFE_GRAPHICS + 1).toInt().toFloat(),
(App.scr.height - height - App.scr.tvSafeGraphicsHeight).toFloat()
)
val offX = (App.scr.tvSafeGraphicsWidth * 1.25f).roundToInt().toFloat()
val offY = App.scr.height - height - App.scr.tvSafeGraphicsHeight - 4f
App.fontGame.draw(batch, zoomText, offX, offY)
}
override fun dispose() {

View File

@@ -1,22 +1,26 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.langpack.Lang
import kotlin.math.roundToInt
/**
* Created by minjaesong on 2021-10-01.
*/
class UIAutosaveNotifier : UICanvas() {
override var width: Int
get() = TODO("Not yet implemented")
set(value) {}
override var height: Int
get() = TODO("Not yet implemented")
set(value) {}
override var openCloseTime = 0.2f
companion object {
const val WIDTH = 240
const val HEIGHT = 24
}
override var width = WIDTH
override var height = HEIGHT
override var openCloseTime = 0.12f //COMMON_OPEN_CLOSE
private val spinner = CommonResourcePool.getAsTextureRegionPack("inline_loading_spinner")
private var spinnerTimer = 0f
@@ -25,7 +29,7 @@ class UIAutosaveNotifier : UICanvas() {
override fun updateUI(delta: Float) {
spinnerTimer += delta
if (spinnerTimer > spinnerInterval) {
while (spinnerTimer > spinnerInterval) {
spinnerFrame = (spinnerFrame + 1) % 32
spinnerTimer -= spinnerInterval
}
@@ -33,24 +37,28 @@ class UIAutosaveNotifier : UICanvas() {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
val spin = spinner.get(spinnerFrame % 8, spinnerFrame / 8)
val inlineOffsetY = if (App.GAME_LOCALE.startsWith("th")) 0f
else if (App.GAME_LOCALE.startsWith("ko")) 0f
else 1f
batch.draw(spin, posX.toFloat(), posY.toFloat())
val offX = (App.scr.tvSafeGraphicsWidth * 1.25f).roundToInt().toFloat()
val offY = App.scr.tvSafeGraphicsHeight + 4f
batch.color = Color.WHITE
batch.draw(spin, offX, offY)
App.fontGame.draw(batch, Lang["MENU_IO_SAVING"], offX + 30f, offY)
}
override fun doOpening(delta: Float) {
doOpeningFade(this, openCloseTime)
}
override fun doClosing(delta: Float) {
doClosingFade(this, openCloseTime)
}
override fun endOpening(delta: Float) {
endOpeningFade(this)
}
override fun endClosing(delta: Float) {
endClosingFade(this)
}
override fun dispose() {