mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
manual/auto selection for savegame loading
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"MENU_LABEL_PRESS_START_SYMBOL": "Press >",
|
"MENU_LABEL_PRESS_START_SYMBOL": "Press >",
|
||||||
"MENU_MODULES" : "Modules",
|
"MENU_MODULES" : "Modules",
|
||||||
"MENU_CREDIT_GPL_DNT" : "GPL",
|
"MENU_CREDIT_GPL_DNT" : "GPL",
|
||||||
|
"MENU_LABEL_JVM_DNT" : "JVM",
|
||||||
"GAME_ACTION_MOVE_VERB" : "Move",
|
"GAME_ACTION_MOVE_VERB" : "Move",
|
||||||
"GAME_ACTION_ZOOM" : "Zoom",
|
"GAME_ACTION_ZOOM" : "Zoom",
|
||||||
"MENU_LABEL_RESET" : "Reset",
|
"MENU_LABEL_RESET" : "Reset",
|
||||||
@@ -30,16 +31,18 @@
|
|||||||
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "Paste from Clipboard",
|
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "Paste from Clipboard",
|
||||||
"MENU_OPTIONS_PERFORMANCE": "Performance",
|
"MENU_OPTIONS_PERFORMANCE": "Performance",
|
||||||
"MENU_LABEL_DELETE": "Delete",
|
"MENU_LABEL_DELETE": "Delete",
|
||||||
"MENU_OPTIONS_JVM_HEAP_MAX": "Max JVM Heap Memory",
|
"MENU_OPTIONS_JVM_HEAP_MAX": "Max Heap Memory",
|
||||||
"MENU_OPTIONS_AUTOSAVE": "Autosave",
|
"MENU_OPTIONS_AUTOSAVE": "Autosave",
|
||||||
"CONTEXT_TIME_MINUTE_PLURAL": "Minutes",
|
"CONTEXT_TIME_MINUTE_PLURAL": "Minutes",
|
||||||
"CONTEXT_TIME_SECOND_PLURAL": "Seconds",
|
"CONTEXT_TIME_SECOND_PLURAL": "Seconds",
|
||||||
"MENU_LABEL_SYSTEM_INFO": "System Info",
|
"MENU_LABEL_SYSTEM_INFO": "System Info",
|
||||||
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "Show notification for",
|
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "Show notification for",
|
||||||
"MENU_LABEL_STREAMING": "Livestreaming",
|
"MENU_LABEL_STREAMING": "Livestreaming",
|
||||||
"MENU_LABEL_EXTRA_JVM_ARGUMENTS": "Extra JVM Arguments",
|
"MENU_LABEL_EXTRA_JVM_ARGUMENTS": "Extra Arguments",
|
||||||
"GAME_PREV_SAVE_WAS_LOADED1": "The most recently saved game was corrupted.",
|
"GAME_PREV_SAVE_WAS_LOADED1": "The most recently saved game was corrupted.",
|
||||||
"GAME_PREV_SAVE_WAS_LOADED2": "The previously saved game was loaded.",
|
"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_AUTOSAVE1": "The Autosave is more recent than the manual save.",
|
||||||
"GAME_MORE_RECENT_AUTOSAVE2": "Please select the saved game you want to load:"
|
"GAME_MORE_RECENT_AUTOSAVE2": "Please select the saved game you wish to play:",
|
||||||
|
"MENU_IO_MANUAL_SAVE": "Manual Save",
|
||||||
|
"MENU_IO_AUTOSAVE": "Autosave"
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "Límdu frá klemmuspjald",
|
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "Límdu frá klemmuspjald",
|
||||||
"MENU_OPTIONS_PERFORMANCE": "Afköst",
|
"MENU_OPTIONS_PERFORMANCE": "Afköst",
|
||||||
"MENU_LABEL_DELETE": "Eyða",
|
"MENU_LABEL_DELETE": "Eyða",
|
||||||
"MENU_OPTIONS_JVM_HEAP_MAX": "Hámarks JVM hrúguminni",
|
"MENU_OPTIONS_JVM_HEAP_MAX": "Hámarks hrúguminni",
|
||||||
"MENU_OPTIONS_AUTOSAVE": "Sjálfvirk vistun",
|
"MENU_OPTIONS_AUTOSAVE": "Sjálfvirk vistun",
|
||||||
"CONTEXT_TIME_MINUTE_PLURAL": "Mínútur"
|
"CONTEXT_TIME_MINUTE_PLURAL": "Mínútur"
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
"GAME_32BIT_WARNING1": "32비트 버전의 Java를 사용중인 것 같습니다.",
|
"GAME_32BIT_WARNING1": "32비트 버전의 Java를 사용중인 것 같습니다.",
|
||||||
"GAME_32BIT_WARNING2": "아래 링크에서 최신 64비트 Java를 내려받아 설치해주세요.",
|
"GAME_32BIT_WARNING2": "아래 링크에서 최신 64비트 Java를 내려받아 설치해주세요.",
|
||||||
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
|
"GAME_32BIT_WARNING3": "https://www.java.com/ko/download/",
|
||||||
|
"GAME_APPLE_ROSETTA_WARNING1": "Apple Silicon이 탑재된 Mac을 사용 중이지만 x86 빌드의 게임을 실행 중입니다.",
|
||||||
|
"GAME_APPLE_ROSETTA_WARNING2": "최적의 성능과 게임 경험을 위해 Apple Silicon용 빌드의 게임을 이용해 주십시오.",
|
||||||
"MENU_OPTION_STREAMERS_LAYOUT": "채팅창 오버레이",
|
"MENU_OPTION_STREAMERS_LAYOUT": "채팅창 오버레이",
|
||||||
"MENU_LABEL_RESTART_REQUIRED": "재시작 필요",
|
"MENU_LABEL_RESTART_REQUIRED": "재시작 필요",
|
||||||
"MENU_LABEL_KEYBOARD_LAYOUT": "자판 배열",
|
"MENU_LABEL_KEYBOARD_LAYOUT": "자판 배열",
|
||||||
@@ -27,11 +29,18 @@
|
|||||||
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "복사한 텍스트 붙여넣기",
|
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "복사한 텍스트 붙여넣기",
|
||||||
"MENU_OPTIONS_PERFORMANCE": "성능",
|
"MENU_OPTIONS_PERFORMANCE": "성능",
|
||||||
"MENU_LABEL_DELETE": "삭제",
|
"MENU_LABEL_DELETE": "삭제",
|
||||||
"MENU_OPTIONS_JVM_HEAP_MAX": "최대 JVM 힙 메모리",
|
"MENU_OPTIONS_JVM_HEAP_MAX": "최대 힙 메모리",
|
||||||
"MENU_OPTIONS_AUTOSAVE": "자동 저장",
|
"MENU_OPTIONS_AUTOSAVE": "자동 저장",
|
||||||
"CONTEXT_TIME_MINUTE_PLURAL": "분",
|
"CONTEXT_TIME_MINUTE_PLURAL": "분",
|
||||||
"CONTEXT_TIME_SECOND_PLURAL": "초",
|
"CONTEXT_TIME_SECOND_PLURAL": "초",
|
||||||
"MENU_LABEL_SYSTEM_INFO": "시스템 정보",
|
"MENU_LABEL_SYSTEM_INFO": "시스템 정보",
|
||||||
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "알림 표시 시간",
|
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "알림 표시 시간",
|
||||||
"MENU_LABEL_STREAMING": "실시간 방송"
|
"MENU_LABEL_STREAMING": "실시간 방송",
|
||||||
|
"MENU_LABEL_EXTRA_JVM_ARGUMENTS": "추가 명령 인수",
|
||||||
|
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
|
||||||
|
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
|
||||||
|
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
|
||||||
|
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해주십시오.",
|
||||||
|
"MENU_IO_MANUAL_SAVE": "수동 저장",
|
||||||
|
"MENU_IO_AUTOSAVE": "자동 저장"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,14 +139,15 @@ class SavegameCollectionPair(player: SavegameCollection?, world: SavegameCollect
|
|||||||
fun moreRecentAutosaveAvailable() = (status == 2)
|
fun moreRecentAutosaveAvailable() = (status == 2)
|
||||||
fun saveAvaliable() = (status > 0)
|
fun saveAvaliable() = (status > 0)
|
||||||
|
|
||||||
fun getManualSave(): Pair<DiskSkimmer, DiskSkimmer>? {
|
fun getManualSave(): DiskPair? {
|
||||||
if (status == 0) return null
|
if (status == 0) return null
|
||||||
return manualPlayer to manualWorld
|
return DiskPair(manualPlayer, manualWorld)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAutoSave(): Pair<DiskSkimmer, DiskSkimmer>? {
|
fun getAutoSave(): DiskPair? {
|
||||||
if (status != 2) return null
|
if (status != 2) return null
|
||||||
return autoPlayer to autoWorld
|
return DiskPair(autoPlayer, autoWorld)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
data class DiskPair(val player: DiskSkimmer, val world: DiskSkimmer)
|
||||||
@@ -6,43 +6,23 @@ import com.badlogic.gdx.graphics.*
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||||
import com.badlogic.gdx.utils.JsonReader
|
|
||||||
import com.jme3.math.FastMath
|
|
||||||
import net.torvald.unicode.EMDASH
|
|
||||||
import net.torvald.unicode.getKeycapConsole
|
import net.torvald.unicode.getKeycapConsole
|
||||||
import net.torvald.unicode.getKeycapPC
|
import net.torvald.unicode.getKeycapPC
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
|
|
||||||
import net.torvald.terrarum.savegame.ByteArray64InputStream
|
import net.torvald.terrarum.savegame.ByteArray64InputStream
|
||||||
import net.torvald.terrarum.savegame.ByteArray64Reader
|
|
||||||
import net.torvald.terrarum.savegame.DiskSkimmer
|
|
||||||
import net.torvald.terrarum.savegame.EntryFile
|
import net.torvald.terrarum.savegame.EntryFile
|
||||||
import net.torvald.terrarum.serialise.Common
|
|
||||||
import net.torvald.terrarum.serialise.SaveLoadError
|
|
||||||
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
|
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
|
||||||
import net.torvald.terrarum.savegame.VDFileID.BODYPART_TO_ENTRY_MAP
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.savegame.VDFileID.SAVEGAMEINFO
|
|
||||||
import net.torvald.terrarum.savegame.VDFileID.SPRITEDEF
|
|
||||||
import net.torvald.terrarum.spriteassembler.ADProperties
|
|
||||||
import net.torvald.terrarum.spriteassembler.ADProperties.Companion.EXTRA_HEADROOM_X
|
|
||||||
import net.torvald.terrarum.spriteassembler.ADProperties.Companion.EXTRA_HEADROOM_Y
|
|
||||||
import net.torvald.terrarum.spriteassembler.AssembleFrameBase
|
|
||||||
import net.torvald.terrarum.spriteassembler.AssembleSheetPixmap
|
|
||||||
import net.torvald.terrarum.ui.Movement
|
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
|
||||||
import net.torvald.terrarum.ui.UIItem
|
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
|
||||||
import net.torvald.terrarum.utils.forEachSiblings
|
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.zip.GZIPInputStream
|
import java.util.zip.GZIPInputStream
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
|
||||||
@@ -122,6 +102,63 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
|
|
||||||
var mode = 0; private set// 0: show players, 1: show worlds
|
var mode = 0; private set// 0: show players, 1: show worlds
|
||||||
|
|
||||||
|
private val MODE_SELECT = 0
|
||||||
|
private val MODE_SELECT_AFTER = 1
|
||||||
|
private val MODE_SAVE_MULTIPLE_CHOICES = 2
|
||||||
|
private val MODE_LOAD_DA_SHIT_ALREADY = 255
|
||||||
|
private val MODE_SAVE_DAMAGED = 256
|
||||||
|
|
||||||
|
private lateinit var loadables: SavegameCollectionPair
|
||||||
|
|
||||||
|
private lateinit var loadManualThumbButton: UIItemImageButton
|
||||||
|
private lateinit var loadAutoThumbButton: UIItemImageButton
|
||||||
|
|
||||||
|
private val disposablePool = ArrayList<Disposable>()
|
||||||
|
|
||||||
|
private fun DiskPair.getThumbnail(): TextureRegion {
|
||||||
|
return this.world.requestFile(-2).let { file ->
|
||||||
|
CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb")
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
val zippedTga = (file.contents as EntryFile).bytes
|
||||||
|
val gzin = GZIPInputStream(ByteArray64InputStream(zippedTga))
|
||||||
|
val tgaFileContents = gzin.readAllBytes(); gzin.close()
|
||||||
|
val pixmap = Pixmap(tgaFileContents, 0, tgaFileContents.size)
|
||||||
|
TextureRegion(Texture(pixmap)).also {
|
||||||
|
disposablePool.add(it.texture)
|
||||||
|
// do cropping and resizing
|
||||||
|
it.setRegion(
|
||||||
|
(pixmap.width - imageButtonW*2) / 2,
|
||||||
|
(pixmap.height - imageButtonH*2) / 2,
|
||||||
|
imageButtonW * 2,
|
||||||
|
imageButtonH * 2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val altSelDrawW = 640
|
||||||
|
private val altSelHdrawW = altSelDrawW / 2
|
||||||
|
private val altSelDrawH = 480
|
||||||
|
private val imageButtonW = 300
|
||||||
|
private val imageButtonH = 240
|
||||||
|
private val altSelDrawY = ((App.scr.height - altSelDrawH)/2)
|
||||||
|
private val altSelQdrawW = altSelDrawW / 4
|
||||||
|
private val altSelQQQdrawW = altSelDrawW * 3 / 4
|
||||||
|
|
||||||
|
private fun getDrawTextualInfoFun(disks: DiskPair): (UIItem, SpriteBatch) -> Unit {
|
||||||
|
val lastPlayedStamp = Instant.ofEpochSecond(disks.player.getLastModifiedTime())
|
||||||
|
.atZone(TimeZone.getDefault().toZoneId())
|
||||||
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
return { item: UIItem, batch: SpriteBatch ->
|
||||||
|
App.fontSmallNumbers.draw(batch, lastPlayedStamp, item.posX + 5f, item.posY + 3f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun advanceMode() {
|
override fun advanceMode() {
|
||||||
mode += 1
|
mode += 1
|
||||||
uiScroll = 0f
|
uiScroll = 0f
|
||||||
@@ -133,31 +170,84 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
printdbg(this, "savelist mode: $mode")
|
printdbg(this, "savelist mode: $mode")
|
||||||
|
|
||||||
// look for recently played world
|
// look for recently played world
|
||||||
if (mode == 1) {
|
if (mode == MODE_SELECT_AFTER) {
|
||||||
|
|
||||||
// select the most recent loadable save by comparing manual and autosaves, NOT JUST going with loadable()
|
// select the most recent loadable save by comparing manual and autosaves, NOT JUST going with loadable()
|
||||||
printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||||
val loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
||||||
|
|
||||||
var loadAuto = false
|
mode = if (loadables.moreRecentAutosaveAvailable()) {
|
||||||
if (loadables.moreRecentAutosaveAvailable()) {
|
// make choice for load manual or auto, if available
|
||||||
// TODO make choice for load manual or auto, if available
|
|
||||||
|
|
||||||
|
val autoThumb = loadables.getAutoSave()!!.getThumbnail()
|
||||||
|
val manualThumb = loadables.getManualSave()!!.getThumbnail()
|
||||||
|
|
||||||
|
loadManualThumbButton = UIItemImageButton(this, manualThumb,
|
||||||
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQdrawW - imageButtonW/2,
|
||||||
|
initialY = altSelDrawY + 120,
|
||||||
|
width = imageButtonW,
|
||||||
|
height = imageButtonH,
|
||||||
|
imageDrawWidth = imageButtonW,
|
||||||
|
imageDrawHeight = imageButtonH,
|
||||||
|
highlightable = false,
|
||||||
|
useBorder = true,
|
||||||
|
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
|
||||||
|
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
|
||||||
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
|
||||||
|
initialY = altSelDrawY + 120,
|
||||||
|
width = imageButtonW,
|
||||||
|
height = imageButtonH,
|
||||||
|
imageDrawWidth = imageButtonW,
|
||||||
|
imageDrawHeight = imageButtonH,
|
||||||
|
highlightable = false,
|
||||||
|
useBorder = true,
|
||||||
|
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getAutoSave()!!) }
|
||||||
|
|
||||||
|
MODE_SAVE_MULTIPLE_CHOICES
|
||||||
}
|
}
|
||||||
else if (!loadables.saveAvaliable()) {
|
else if (!loadables.saveAvaliable()) {
|
||||||
// TODO show save is damaged and cannot be loaded
|
// show save is damaged and cannot be loaded
|
||||||
return
|
MODE_SAVE_DAMAGED
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
val (p, w) = loadables.getManualSave()!!
|
||||||
|
UILoadGovernor.playerDisk = p; UILoadGovernor.worldDisk = w
|
||||||
|
|
||||||
val (p, w) = if (loadAuto) loadables.getAutoSave()!! else loadables.getManualSave()!!
|
if (loadables.newerSaveIsDamaged) {
|
||||||
UILoadGovernor.playerDisk = p; UILoadGovernor.worldDisk = w
|
UILoadGovernor.previousSaveWasLoaded = true
|
||||||
|
}
|
||||||
|
|
||||||
if (loadables.newerSaveIsDamaged) {
|
// MODE_LOAD_DA_SHIT_ALREADY
|
||||||
// TODO queue message: GAME_PREV_SAVE_WAS_LOADED
|
|
||||||
|
|
||||||
|
// test codes //
|
||||||
|
|
||||||
|
val autoThumb = loadables.getManualSave()!!.getThumbnail()
|
||||||
|
val manualThumb = loadables.getManualSave()!!.getThumbnail()
|
||||||
|
|
||||||
|
loadManualThumbButton = UIItemImageButton(this, manualThumb,
|
||||||
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQdrawW - imageButtonW/2,
|
||||||
|
initialY = altSelDrawY + 120,
|
||||||
|
width = imageButtonW,
|
||||||
|
height = imageButtonH,
|
||||||
|
imageDrawWidth = imageButtonW,
|
||||||
|
imageDrawHeight = imageButtonH,
|
||||||
|
highlightable = false,
|
||||||
|
useBorder = true,
|
||||||
|
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
|
||||||
|
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
|
||||||
|
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
|
||||||
|
initialY = altSelDrawY + 120,
|
||||||
|
width = imageButtonW,
|
||||||
|
height = imageButtonH,
|
||||||
|
imageDrawWidth = imageButtonW,
|
||||||
|
imageDrawHeight = imageButtonH,
|
||||||
|
highlightable = false,
|
||||||
|
useBorder = true,
|
||||||
|
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
|
||||||
|
|
||||||
|
MODE_SAVE_MULTIPLE_CHOICES
|
||||||
}
|
}
|
||||||
|
|
||||||
mode += 1
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +268,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
savegamesCount += 1
|
savegamesCount += 1
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
System.err.println("[UILoadDemoSavefiles] Error while loading Player '${skimmer.diskFile.absolutePath}'")
|
System.err.println("[UILoadSavegame] Error while loading Player '${skimmer.diskFile.absolutePath}'")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,14 +300,14 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
init {
|
init {
|
||||||
// this UI will NOT persist; the parent of the mode1Node must be set using an absolute value (e.g. treeRoot, not remoCon.currentRemoConContents)
|
// this UI will NOT persist; the parent of the mode1Node must be set using an absolute value (e.g. treeRoot, not remoCon.currentRemoConContents)
|
||||||
|
|
||||||
//printdbg(this, "UILoadDemoSaveFiles called, from:")
|
//printdbg(this, "UILoadSavegame called, from:")
|
||||||
//printStackTrace(this)
|
//printStackTrace(this)
|
||||||
|
|
||||||
mode1Node.parent = remoCon.treeRoot
|
mode1Node.parent = remoCon.treeRoot
|
||||||
mode2Node.parent = mode1Node
|
mode2Node.parent = mode1Node
|
||||||
|
|
||||||
mode1Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles"
|
mode1Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadSavegame"
|
||||||
mode2Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles"
|
mode2Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadSavegame"
|
||||||
|
|
||||||
// printdbg(this, "mode1Node parent: ${mode1Node.parent?.data}") // will be 'null' because the parent is the root node
|
// printdbg(this, "mode1Node parent: ${mode1Node.parent?.data}") // will be 'null' because the parent is the root node
|
||||||
// printdbg(this, "mode1Node data: ${mode1Node.data}")
|
// printdbg(this, "mode1Node data: ${mode1Node.data}")
|
||||||
@@ -229,8 +319,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
|
if (mode == MODE_SELECT) {
|
||||||
if (mode < 2) {
|
|
||||||
|
|
||||||
if (oldMode != mode) {
|
if (oldMode != mode) {
|
||||||
modeChangedHandler(mode)
|
modeChangedHandler(mode)
|
||||||
@@ -270,7 +359,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
|
|
||||||
if (mode == 2) {
|
if (mode == MODE_LOAD_DA_SHIT_ALREADY) {
|
||||||
loadFired += 1
|
loadFired += 1
|
||||||
// to hide the "flipped skybox" artefact
|
// to hide the "flipped skybox" artefact
|
||||||
batch.end()
|
batch.end()
|
||||||
@@ -287,7 +376,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
LoadSavegame(UILoadGovernor.playerDisk!!, UILoadGovernor.worldDisk)
|
LoadSavegame(UILoadGovernor.playerDisk!!, UILoadGovernor.worldDisk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (mode == MODE_SELECT) {
|
||||||
batch.end()
|
batch.end()
|
||||||
|
|
||||||
val cells = getCells()
|
val cells = getCells()
|
||||||
@@ -362,6 +451,24 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
|
|
||||||
batch.begin()
|
batch.begin()
|
||||||
}
|
}
|
||||||
|
else if (mode == MODE_SAVE_MULTIPLE_CHOICES) {
|
||||||
|
// "The Autosave is more recent than the manual save"
|
||||||
|
val tw1 = App.fontGame.getWidth(Lang["GAME_MORE_RECENT_AUTOSAVE1"])
|
||||||
|
val tw2 = App.fontGame.getWidth(Lang["GAME_MORE_RECENT_AUTOSAVE2"])
|
||||||
|
App.fontGame.draw(batch, Lang["GAME_MORE_RECENT_AUTOSAVE1"], ((Toolkit.drawWidth - tw1)/2).toFloat(), altSelDrawY + 0f)
|
||||||
|
App.fontGame.draw(batch, Lang["GAME_MORE_RECENT_AUTOSAVE2"], ((Toolkit.drawWidth - tw2)/2).toFloat(), altSelDrawY + 24f)
|
||||||
|
|
||||||
|
val twm = App.fontGame.getWidth(Lang["MENU_IO_MANUAL_SAVE"])
|
||||||
|
val twa = App.fontGame.getWidth(Lang["MENU_IO_AUTOSAVE"])
|
||||||
|
|
||||||
|
App.fontGame.draw(batch, Lang["MENU_IO_MANUAL_SAVE"], ((Toolkit.drawWidth - altSelDrawW)/2).toFloat() + altSelQdrawW - twm/2, altSelDrawY + 80f)
|
||||||
|
App.fontGame.draw(batch, Lang["MENU_IO_AUTOSAVE"], ((Toolkit.drawWidth - altSelDrawW)/2).toFloat() + altSelQQQdrawW - twa/2, altSelDrawY + 80f)
|
||||||
|
|
||||||
|
|
||||||
|
// draw thumbnail-buttons
|
||||||
|
loadAutoThumbButton.render(batch, camera)
|
||||||
|
loadManualThumbButton.render(batch, camera)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -384,17 +491,17 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
getCells().forEach { it.touchDown(screenX, screenY, pointer, button) }
|
if (mode == MODE_SELECT) getCells().forEach { it.touchDown(screenX, screenY, pointer, button) }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
|
if (mode == MODE_SELECT) getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
override fun scrolled(amountX: Float, amountY: Float): Boolean {
|
||||||
if (this.isVisible) {
|
if (this.isVisible && mode == MODE_SELECT) {
|
||||||
val cells = getCells()
|
val cells = getCells()
|
||||||
|
|
||||||
if (amountY <= -1f && scrollTarget > 0) {
|
if (amountY <= -1f && scrollTarget > 0) {
|
||||||
@@ -421,6 +528,9 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
try { shapeRenderer.dispose() } catch (e: IllegalArgumentException) {}
|
try { shapeRenderer.dispose() } catch (e: IllegalArgumentException) {}
|
||||||
try { sliderFBO.dispose() } catch (e: IllegalArgumentException) {}
|
try { sliderFBO.dispose() } catch (e: IllegalArgumentException) {}
|
||||||
|
disposablePool.forEach {
|
||||||
|
try { it.dispose() } catch (e: GdxRuntimeException) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
|
|||||||
@@ -81,10 +81,13 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
|
|
||||||
|
|
||||||
}, "TerrarumBasegameNewCharcterSaveThread")
|
}, "TerrarumBasegameNewCharcterSaveThread")
|
||||||
savingThread.start()
|
|
||||||
|
// savingThread.join()
|
||||||
|
|
||||||
|
remoCon.openUI(UINewWorld(remoCon, savingThread)) // let UINewWorld handle the character file generation
|
||||||
}
|
}
|
||||||
backButton.clickOnceListener = { _,_ ->
|
backButton.clickOnceListener = { _,_ ->
|
||||||
remoCon.openUI(UILoadDemoSavefiles(remoCon, 0))
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
}
|
}
|
||||||
|
|
||||||
addUIitem(nameInput)
|
addUIitem(nameInput)
|
||||||
@@ -99,7 +102,7 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
|
|
||||||
if (returnedFromChargen) {
|
if (returnedFromChargen) {
|
||||||
returnedFromChargen = false
|
returnedFromChargen = false
|
||||||
remoCon.openUI(UILoadDemoSavefiles(remoCon, 1)) // 0 to go back (Terraria's behav), set variables up and 1 to choose world
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ import net.torvald.terrarum.utils.RandomWordsName
|
|||||||
*/
|
*/
|
||||||
class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||||
|
|
||||||
|
private var newPlayerCreationThread = Thread {}
|
||||||
|
|
||||||
|
constructor(remoCon: UIRemoCon, playerCreationThread: Thread) : this(remoCon) {
|
||||||
|
newPlayerCreationThread = playerCreationThread
|
||||||
|
}
|
||||||
|
|
||||||
private val hugeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/huge.png")))
|
private val hugeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/huge.png")))
|
||||||
private val largeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/large.png")))
|
private val largeTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/large.png")))
|
||||||
private val normalTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/normal.png")))
|
private val normalTex = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/normal.png")))
|
||||||
@@ -87,6 +93,11 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
goButton.clickOnceListener = { _, _ ->
|
goButton.clickOnceListener = { _, _ ->
|
||||||
|
|
||||||
|
// after the save is complete, proceed to new world generation
|
||||||
|
newPlayerCreationThread.join()
|
||||||
|
|
||||||
|
|
||||||
// printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
|
// printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
|
||||||
|
|
||||||
val ingame = TerrarumIngame(App.batch)
|
val ingame = TerrarumIngame(App.batch)
|
||||||
@@ -112,7 +123,7 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
backButton.clickOnceListener = { _, _ ->
|
backButton.clickOnceListener = { _, _ ->
|
||||||
remoCon.openUI(UILoadDemoSavefiles(remoCon, 1))
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
}
|
}
|
||||||
|
|
||||||
addUIitem(sizeSelector)
|
addUIitem(sizeSelector)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"),
|
arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"),
|
||||||
arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,5,120,5,60000"),
|
arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,5,120,5,60000"),
|
||||||
arrayOf("notificationshowuptime", { Lang["MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION"] + " (${Lang["CONTEXT_TIME_SECOND_PLURAL"]})" }, "spinnerimul,2,10,1,1000"),
|
arrayOf("notificationshowuptime", { Lang["MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION"] + " (${Lang["CONTEXT_TIME_SECOND_PLURAL"]})" }, "spinnerimul,2,10,1,1000"),
|
||||||
arrayOf("", { Lang["MENU_OPTIONS_PERFORMANCE"] }, "h1"),
|
arrayOf("", { Lang["MENU_LABEL_JVM_DNT"] }, "h1"),
|
||||||
arrayOf("jvm_xmx", { Lang["MENU_OPTIONS_JVM_HEAP_MAX"] + " (GB)" }, "spinner,2,32,1"),
|
arrayOf("jvm_xmx", { Lang["MENU_OPTIONS_JVM_HEAP_MAX"] + " (GB)" }, "spinner,2,32,1"),
|
||||||
arrayOf("jvm_extra_cmd", { Lang["MENU_LABEL_EXTRA_JVM_ARGUMENTS"] }, "typein"),
|
arrayOf("jvm_extra_cmd", { Lang["MENU_LABEL_EXTRA_JVM_ARGUMENTS"] }, "typein"),
|
||||||
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
|
||||||
@@ -70,7 +70,7 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
|||||||
private val hrule = CommonResourcePool.getAsTextureRegionPack("gui_hrule")
|
private val hrule = CommonResourcePool.getAsTextureRegionPack("gui_hrule")
|
||||||
|
|
||||||
private val spinnerWidth = 140
|
private val spinnerWidth = 140
|
||||||
private val typeinWidth = 320
|
private val typeinWidth = 240
|
||||||
private val drawX = (Toolkit.drawWidth - width) / 2
|
private val drawX = (Toolkit.drawWidth - width) / 2
|
||||||
private val drawY = (App.scr.height - height) / 2
|
private val drawY = (App.scr.height - height) / 2
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
savegamesCount += 1
|
savegamesCount += 1
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
System.err.println("[UILoadDemoSavefiles] Error while loading module info for '$s'")
|
System.err.println("[UITitleModules] Error while loading module info for '$s'")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.BlendMode
|
||||||
|
import net.torvald.terrarum.abs
|
||||||
import net.torvald.terrarum.blendNormalStraightAlpha
|
import net.torvald.terrarum.blendNormalStraightAlpha
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,14 +34,24 @@ open class UIItemImageButton(
|
|||||||
|
|
||||||
initialX: Int,
|
initialX: Int,
|
||||||
initialY: Int,
|
initialY: Int,
|
||||||
|
/** this does NOT resize the image; use imageDrawWidth to actually resize the image */
|
||||||
override val width: Int = image.regionWidth,
|
override val width: Int = image.regionWidth,
|
||||||
|
/** this does NOT resize the image; use imageDrawHeight to actually resize the image */
|
||||||
override val height: Int = image.regionHeight,
|
override val height: Int = image.regionHeight,
|
||||||
|
|
||||||
/** When clicked, toggle its "lit" status */
|
/** When clicked, toggle its "lit" status */
|
||||||
var highlightable: Boolean
|
var highlightable: Boolean,
|
||||||
|
/** Changes the appearance to use a border instead of colour-changing image for highlighter */
|
||||||
|
val useBorder: Boolean = false,
|
||||||
|
|
||||||
|
/** Image won't be place at right position if `image.regionWidth != imageDrawWidth`; define the `width` argument to avoid the issue */
|
||||||
|
val imageDrawWidth: Int = image.regionWidth,
|
||||||
|
/** Image won't be place at right position if `image.regionHeight != imageDrawHeight`; define the `height` argument to avoid the issue */
|
||||||
|
val imageDrawHeight: Int = image.regionHeight,
|
||||||
) : UIItem(parent, initialX, initialY) {
|
) : UIItem(parent, initialX, initialY) {
|
||||||
|
|
||||||
var highlighted = false
|
var highlighted = false
|
||||||
|
var extraDrawOp: (UIItem, SpriteBatch) -> Unit = { _,_ -> }
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
// draw background
|
// draw background
|
||||||
@@ -60,15 +71,22 @@ open class UIItemImageButton(
|
|||||||
Toolkit.fillArea(batch, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
Toolkit.fillArea(batch, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blendNormalStraightAlpha(batch)
|
||||||
|
|
||||||
// draw image
|
// draw image
|
||||||
blendNormalStraightAlpha(batch)
|
batch.color = if (highlighted) highlightCol
|
||||||
|
else if (mouseUp) activeCol
|
||||||
|
else Toolkit.Theme.COL_INACTIVE
|
||||||
|
if (useBorder) {
|
||||||
|
Toolkit.drawBoxBorder(batch, posX - 1f, posY - 1f, width + 2f, height + 2f)
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
}
|
||||||
|
batch.draw(image, (posX + (width - imageDrawWidth) / 2).toFloat(), (posY + (height - imageDrawHeight) / 2).toFloat(), imageDrawWidth.toFloat(), imageDrawHeight.toFloat())
|
||||||
|
|
||||||
batch.color = if (highlighted) highlightCol
|
batch.color = if (highlighted) highlightCol
|
||||||
else if (mouseUp) activeCol
|
else if (mouseUp) activeCol
|
||||||
else inactiveCol
|
else inactiveCol
|
||||||
|
extraDrawOp(this, batch)
|
||||||
batch.draw(image, (posX + (width - image.regionWidth) / 2).toFloat(), (posY + (height - image.regionHeight) / 2).toFloat())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
Reference in New Issue
Block a user