mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
gui for load savegame
This commit is contained in:
@@ -44,5 +44,6 @@
|
|||||||
"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 wish to play:",
|
"GAME_MORE_RECENT_AUTOSAVE2": "Please select the saved game you wish to play:",
|
||||||
"MENU_IO_MANUAL_SAVE": "Manual Save",
|
"MENU_IO_MANUAL_SAVE": "Manual Save",
|
||||||
"MENU_IO_AUTOSAVE": "Autosave"
|
"MENU_IO_AUTOSAVE": "Autosave",
|
||||||
|
"MENU_LABEL_SAVE_WILL_BE_DELETED": "The selected save file will be deleted."
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,8 @@
|
|||||||
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
|
"GAME_PREV_SAVE_WAS_LOADED1": "가장 최근에 저장된 게임이 손상되었습니다.",
|
||||||
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
|
"GAME_PREV_SAVE_WAS_LOADED2": "이전에 저장된 게임을 불러왔습니다.",
|
||||||
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
|
"GAME_MORE_RECENT_AUTOSAVE1": "자동 저장된 게임이 수동으로 저장한 게임보다 더 최신입니다.",
|
||||||
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해주십시오.",
|
"GAME_MORE_RECENT_AUTOSAVE2": "불러올 게임을 선택해 주십시오.",
|
||||||
"MENU_IO_MANUAL_SAVE": "수동 저장",
|
"MENU_IO_MANUAL_SAVE": "수동 저장",
|
||||||
"MENU_IO_AUTOSAVE": "자동 저장"
|
"MENU_IO_AUTOSAVE": "자동 저장",
|
||||||
|
"MENU_LABEL_SAVE_WILL_BE_DELETED": "선택된 세이브가 삭제됩니다."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import kotlin.io.path.Path
|
|||||||
class SavegameCollection(files0: List<DiskSkimmer>) {
|
class SavegameCollection(files0: List<DiskSkimmer>) {
|
||||||
|
|
||||||
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
||||||
val files = files0.sortedByDescending { it.getLastModifiedTime() }
|
val files = files0.sortedByDescending { it.getLastModifiedTime().shl(1) or it.diskFile.extension.matches(Regex("^[abc]\$")).toLong() }
|
||||||
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
||||||
val autoSaves = files.filter { it.diskFile.extension.matches(Regex("[a-z]")) }
|
val autoSaves = files.filter { it.diskFile.extension.matches(Regex("[a-z]")) }
|
||||||
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
|
||||||
|
|||||||
@@ -630,6 +630,7 @@ fun Float.sqrt() = FastMath.sqrt(this)
|
|||||||
fun Int.abs() = this.absoluteValue
|
fun Int.abs() = this.absoluteValue
|
||||||
fun Double.bipolarClamp(limit: Double) = this.coerceIn(-limit, limit)
|
fun Double.bipolarClamp(limit: Double) = this.coerceIn(-limit, limit)
|
||||||
fun Boolean.toInt(shift: Int = 0) = if (this) 1.shl(shift) else 0
|
fun Boolean.toInt(shift: Int = 0) = if (this) 1.shl(shift) else 0
|
||||||
|
fun Boolean.toLong(shift: Int = 0) = if (this) 1L.shl(shift) else 0L
|
||||||
fun Int.bitCount() = java.lang.Integer.bitCount(this)
|
fun Int.bitCount() = java.lang.Integer.bitCount(this)
|
||||||
fun Long.bitCount() = java.lang.Long.bitCount(this)
|
fun Long.bitCount() = java.lang.Long.bitCount(this)
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
private val goButtonWidth = 180
|
private val goButtonWidth = 180
|
||||||
private val drawX = (Toolkit.drawWidth - 480) / 2
|
private val drawX = (Toolkit.drawWidth - 480) / 2
|
||||||
private val drawY = (App.scr.height - 480) / 2
|
private val drawY = (App.scr.height - 480) / 2
|
||||||
private val confirmBackButton = UIItemTextButton(this, "MENU_LABEL_BACK", drawX + (240 - goButtonWidth) / 2, drawY + 480 - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
private val corruptedBackButton = UIItemTextButton(this, "MENU_LABEL_BACK", (Toolkit.drawWidth - goButtonWidth) / 2, drawY + 480 - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
|
private val confirmCancelButton = UIItemTextButton(this, "MENU_LABEL_CANCEL", drawX + (240 - goButtonWidth) / 2, drawY + 480 - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||||
private val confirmDeleteButton = UIItemTextButton(this, "MENU_LABEL_DELETE", drawX + 240 + (240 - goButtonWidth) / 2, drawY + 480- 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD)
|
private val confirmDeleteButton = UIItemTextButton(this, "MENU_LABEL_DELETE", drawX + 240 + (240 - goButtonWidth) / 2, drawY + 480- 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD)
|
||||||
|
|
||||||
private lateinit var loadables: SavegameCollectionPair
|
private lateinit var loadables: SavegameCollectionPair
|
||||||
@@ -171,9 +172,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
confirmBackButton.clickOnceListener = { _,_ ->
|
corruptedBackButton.clickOnceListener = { _,_ -> remoCon.openUI(UILoadSavegame(remoCon)) }
|
||||||
remoCon.openUI(UILoadSavegame(remoCon))
|
confirmCancelButton.clickOnceListener = { _, _ -> remoCon.openUI(UILoadSavegame(remoCon)) }
|
||||||
}
|
|
||||||
confirmDeleteButton.clickOnceListener = { _,_ ->
|
confirmDeleteButton.clickOnceListener = { _,_ ->
|
||||||
val pu = buttonSelectedForDeletion!!.playerUUID
|
val pu = buttonSelectedForDeletion!!.playerUUID
|
||||||
val wu = buttonSelectedForDeletion!!.worldUUID
|
val wu = buttonSelectedForDeletion!!.worldUUID
|
||||||
@@ -182,11 +182,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
App.savegamePlayers.remove(pu)
|
App.savegamePlayers.remove(pu)
|
||||||
App.savegamePlayersName.remove(pu)
|
App.savegamePlayersName.remove(pu)
|
||||||
}
|
}
|
||||||
App.savegameWorlds[wu]?.moveToRecycle(App.recycledWorldsDir)?.let {
|
// don't delete the world please
|
||||||
App.sortedSavegameWorlds.remove(wu)
|
|
||||||
App.savegameWorlds.remove(wu)
|
|
||||||
App.savegameWorldsName.remove(wu)
|
|
||||||
}
|
|
||||||
remoCon.openUI(UILoadSavegame(remoCon))
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,13 +370,14 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
|
|
||||||
private val deleteCharacterButton = UIItemTextButton(
|
private val deleteCharacterButton = UIItemTextButton(
|
||||||
this, "CONTEXT_CHARACTER_DELETE",
|
this, "CONTEXT_CHARACTER_DELETE",
|
||||||
UIRemoCon.menubarOffX - UIRemoCon.UIRemoConElement.paddingLeft + 11,
|
UIRemoCon.menubarOffX - UIRemoCon.UIRemoConElement.paddingLeft + 72,
|
||||||
UIRemoCon.menubarOffY - UIRemoCon.UIRemoConElement.lineHeight * 3 + 16,
|
UIRemoCon.menubarOffY - UIRemoCon.UIRemoConElement.lineHeight * 3 + 16,
|
||||||
remoCon.width + UIRemoCon.UIRemoConElement.paddingLeft,
|
remoCon.width + UIRemoCon.UIRemoConElement.paddingLeft,
|
||||||
true,
|
true,
|
||||||
inactiveCol = Toolkit.Theme.COL_RED,
|
inactiveCol = Toolkit.Theme.COL_RED,
|
||||||
activeCol = Toolkit.Theme.COL_REDD,
|
activeCol = Toolkit.Theme.COL_REDD,
|
||||||
hitboxSize = UIRemoCon.UIRemoConElement.lineHeight - 2
|
hitboxSize = UIRemoCon.UIRemoConElement.lineHeight - 2,
|
||||||
|
alignment = UIItemTextButton.Companion.Alignment.LEFT
|
||||||
).also {
|
).also {
|
||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
mode = MODE_SAVE_DELETE
|
mode = MODE_SAVE_DELETE
|
||||||
@@ -553,34 +550,40 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
}
|
}
|
||||||
else if (mode == MODE_SAVE_MULTIPLE_CHOICES) {
|
else if (mode == MODE_SAVE_MULTIPLE_CHOICES) {
|
||||||
// "The Autosave is more recent than the manual save"
|
// "The Autosave is more recent than the manual save"
|
||||||
val tw1 = App.fontGame.getWidth(Lang["GAME_MORE_RECENT_AUTOSAVE1"])
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE1"], Toolkit.drawWidth, 0, altSelDrawY)
|
||||||
val tw2 = App.fontGame.getWidth(Lang["GAME_MORE_RECENT_AUTOSAVE2"])
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE2"], Toolkit.drawWidth, 0, altSelDrawY + 24)
|
||||||
App.fontGame.draw(batch, Lang["GAME_MORE_RECENT_AUTOSAVE1"], ((Toolkit.drawWidth - tw1)/2).toFloat(), altSelDrawY + 0f)
|
// Manual Save Autosave
|
||||||
App.fontGame.draw(batch, Lang["GAME_MORE_RECENT_AUTOSAVE2"], ((Toolkit.drawWidth - tw2)/2).toFloat(), altSelDrawY + 24f)
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_MANUAL_SAVE"], altSelHdrawW, (Toolkit.drawWidth - altSelDrawW)/2, altSelDrawY + 80)
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_AUTOSAVE"], altSelHdrawW, Toolkit.drawWidth/2, altSelDrawY + 80)
|
||||||
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
|
// draw thumbnail-buttons
|
||||||
loadAutoThumbButton.render(batch, camera)
|
loadAutoThumbButton.render(batch, camera)
|
||||||
loadManualThumbButton.render(batch, camera)
|
loadManualThumbButton.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
else if (mode == MODE_SAVE_DAMAGED) {
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["ERROR_SAVE_CORRUPTED"], Toolkit.drawWidth, 0, App.scr.height / 2 - 42)
|
||||||
|
|
||||||
|
corruptedBackButton.render(batch, camera)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE || mode == MODE_SAVE_DELETE_CONFIRM) {
|
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE || mode == MODE_SAVE_DELETE_CONFIRM) {
|
||||||
deleteCharacterButton.render(batch, camera)
|
deleteCharacterButton.render(batch, camera)
|
||||||
}
|
}
|
||||||
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
||||||
// do transitional moving stuff
|
|
||||||
|
|
||||||
buttonSelectedForDeletion?.render(batch, camera)
|
buttonSelectedForDeletion?.render(batch, camera)
|
||||||
confirmBackButton.render(batch, camera)
|
confirmCancelButton.render(batch, camera)
|
||||||
confirmDeleteButton.render(batch, camera)
|
confirmDeleteButton.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
||||||
|
batch.color = Color.WHITE
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_SAVE_WILL_BE_DELETED"], Toolkit.drawWidth, 0, titleTopGradEnd + cellInterval - 46)
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_ARE_YOU_SURE"], Toolkit.drawWidth, 0, titleTopGradEnd + cellInterval + SAVE_CELL_HEIGHT + 36)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
@@ -607,9 +610,10 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchDown(screenX, screenY, pointer, button) }
|
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchDown(screenX, screenY, pointer, button) }
|
||||||
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchDown(screenX, screenY, pointer, button)
|
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchDown(screenX, screenY, pointer, button)
|
||||||
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
||||||
confirmBackButton.touchDown(screenX, screenY, pointer, button)
|
confirmCancelButton.touchDown(screenX, screenY, pointer, button)
|
||||||
confirmDeleteButton.touchDown(screenX, screenY, pointer, button)
|
confirmDeleteButton.touchDown(screenX, screenY, pointer, button)
|
||||||
}
|
}
|
||||||
|
if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchDown(screenX, screenY, pointer, button)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -618,11 +622,12 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
|
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
|
||||||
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchUp(screenX, screenY, pointer, button) }
|
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchUp(screenX, screenY, pointer, button) }
|
||||||
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchUp(screenX, screenY, pointer, button) }
|
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchUp(screenX, screenY, pointer, button) }
|
||||||
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchDown(screenX, screenY, pointer, button)
|
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchUp(screenX, screenY, pointer, button)
|
||||||
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
if (mode == MODE_SAVE_DELETE_CONFIRM) {
|
||||||
confirmBackButton.touchUp(screenX, screenY, pointer, button)
|
confirmCancelButton.touchUp(screenX, screenY, pointer, button)
|
||||||
confirmDeleteButton.touchUp(screenX, screenY, pointer, button)
|
confirmDeleteButton.touchUp(screenX, screenY, pointer, button)
|
||||||
}
|
}
|
||||||
|
if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchUp(screenX, screenY, pointer, button)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.*
|
import com.badlogic.gdx.graphics.*
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
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.FloatFrameBuffer
|
import com.badlogic.gdx.graphics.glutils.FloatFrameBuffer
|
||||||
@@ -9,6 +10,7 @@ import com.badlogic.gdx.utils.Disposable
|
|||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -120,6 +122,11 @@ object Toolkit : Disposable {
|
|||||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun drawTextCentered(batch: SpriteBatch, font: TerrarumSansBitmap, text: String, tbw: Int, tbx: Int, tby: Int) {
|
||||||
|
val tw = font.getWidth(text)
|
||||||
|
font.draw(batch, text, tbx + (tbw - tw) / 2, tby)
|
||||||
|
}
|
||||||
|
|
||||||
fun fillArea(batch: SpriteBatch, x: Int, y: Int, w: Int, h: Int) {
|
fun fillArea(batch: SpriteBatch, x: Int, y: Int, w: Int, h: Int) {
|
||||||
batch.draw(textureWhiteSquare, x.toFloat(), y.toFloat(), w.toFloat(), h.toFloat())
|
batch.draw(textureWhiteSquare, x.toFloat(), y.toFloat(), w.toFloat(), h.toFloat())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user