initial savefile generation of the newgame

This commit is contained in:
minjaesong
2021-09-29 12:38:08 +09:00
parent f4a4030260
commit 2891d0466e
21 changed files with 1456 additions and 83 deletions

View File

@@ -4,10 +4,7 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.fillRect
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas
@@ -51,7 +48,7 @@ class UICheatDetected : UICanvas() {
}
override fun doOpening(delta: Float) {
Terrarum.ingame?.paused = true
INGAME.pause()
}
override fun doClosing(delta: Float) {

View File

@@ -85,8 +85,13 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
screen = 3; gameMenuButtons.deselect()
full.handler.lockToggle()
full.lockTransition()
// make backup of the old save
File(App.defaultSaveDir, INGAME.savegameNickname).copyTo(
File(App.defaultSaveDir, INGAME.savegameNickname+".1"), // don't use .bak as it's used by the savecracker
true
)
// save the game
WriteSavegame(INGAME.savegameArchive, File(App.defaultSaveDir, "${App.getTIME_T()}"), Terrarum.ingame!! as TerrarumIngame) {
WriteSavegame(INGAME.savegameArchive, File(App.defaultSaveDir, INGAME.savegameNickname), Terrarum.ingame!! as TerrarumIngame) {
// callback:
System.gc()
screen = 0

View File

@@ -275,20 +275,20 @@ class UIInventoryFull(
override fun doOpening(delta: Float) {
Terrarum.ingame?.paused = true
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(null)
INGAME.pause()
INGAME.setTooltipMessage(null)
}
override fun doClosing(delta: Float) {
Terrarum.ingame?.paused = false
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(null)
INGAME.resume()
INGAME.setTooltipMessage(null)
}
override fun endOpening(delta: Float) {
}
override fun endClosing(delta: Float) {
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(null) // required!
INGAME.setTooltipMessage(null) // required!
MinimapComposer.revalidateAll()
}

View File

@@ -374,7 +374,7 @@ class UIItemInventoryItemGrid(
// set tooltip accordingly
if (isCompactMode && it.item != null && it.mouseUp && !tooltipSet) {
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(
INGAME.setTooltipMessage(
if (INVEN_DEBUG_MODE) {
it.item?.name + " (${it.item?.originalID}${if (it.item?.originalID == it.item?.dynamicID) "" else "/${it.item?.dynamicID}"})"
}
@@ -387,7 +387,7 @@ class UIItemInventoryItemGrid(
}
if (!tooltipSet) {
(Terrarum.ingame as? TerrarumIngame)?.setTooltipMessage(null)
INGAME.setTooltipMessage(null)
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
@@ -10,6 +11,7 @@ import net.torvald.getKeycapConsole
import net.torvald.getKeycapPC
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.serialise.Common
import net.torvald.terrarum.serialise.LoadSavegame
import net.torvald.terrarum.serialise.ReadMeta
import net.torvald.terrarum.tvda.ByteArray64InputStream
@@ -27,6 +29,13 @@ import kotlin.math.roundToInt
*/
class UILoadDemoSavefiles : UICanvas() {
init {
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png")))
}
CommonResourcePool.loadAll()
}
override var width: Int
get() = App.scr.width
set(value) {}
@@ -277,7 +286,7 @@ class UIItemDemoSaveCells(
override val height: Int = HEIGHT
private lateinit var thumbPixmap: Pixmap
private lateinit var thumb: TextureRegion
private var thumb: TextureRegion? = null
private val grad = CommonResourcePool.getAsTexture("title_halfgrad")
private val meta = ReadMeta(disk)
@@ -309,7 +318,7 @@ class UIItemDemoSaveCells(
val thumbTex = Texture(thumbPixmap)
thumbTex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
thumb = TextureRegion(thumbTex)
thumb.setRegion(0, (thumbTex.height - 2 * height) / 2, width * 2, height * 2)
thumb!!.setRegion(0, (thumbTex.height - 2 * height) / 2, width * 2, height * 2)
}
catch (e: NullPointerException) {
// use stock texture
@@ -335,7 +344,7 @@ class UIItemDemoSaveCells(
// draw thumbnail
batch.color = Color.WHITE
blendNormal(batch)
batch.draw(thumb, x, y + height, width.toFloat(), -height.toFloat())
batch.draw(thumb ?: CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb"), x, y + height, width.toFloat(), -height.toFloat())
// draw gradient
blendMul(batch)
batch.draw(grad, x + width.toFloat(), y, -width.toFloat(), height.toFloat())
@@ -350,14 +359,14 @@ class UIItemDemoSaveCells(
// file size
App.fontSmallNumbers.draw(batch, "${disk.usedBytes.ushr(10)} KiB", x + 3f, y + height - 16f)
// savegame name
// App.fontGame.draw(batch, disk.getDiskNameString(Common.CHARSET), x + 3f, y + 1f)
App.fontGame.draw(batch, disk.getDiskNameString(Common.CHARSET), x + 3f, y + 1f)
super.render(batch, camera)
batch.color = Color.WHITE
}
override fun dispose() {
thumb.texture.dispose()
thumb?.texture?.dispose()
thumbPixmap.dispose()
}

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.WorldgenLoadScreen
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.utils.RandomWordsName
/**
* Created by minjaesong on 2018-12-08.
@@ -38,7 +39,7 @@ class UIProxyNewRandomGame : UICanvas() {
val ingame = TerrarumIngame(App.batch)
val worldParam = TerrarumIngame.NewWorldParameters(2880, 1350, HQRNG().nextLong())
val worldParam = TerrarumIngame.NewWorldParameters(2880, 1350, HQRNG().nextLong(), RandomWordsName(4))
// val worldParam = TerrarumIngame.NewWorldParameters(2880, 1350, 0x51621D)
// val worldParam = TerrarumIngame.NewWorldParameters(6030, 1800, HQRNG().nextLong()) // small