save manage scr

This commit is contained in:
minjaesong
2023-07-08 16:12:15 +09:00
parent 1f6fa49d19
commit 211f936bd3
6 changed files with 114 additions and 54 deletions

View File

@@ -564,7 +564,7 @@ class UIItemPlayerCells(
highlightTextCol = if (mouseUp && !forceMouseDown) litCol else Toolkit.Theme.COL_LIST_DEFAULT highlightTextCol = if (mouseUp && !forceMouseDown) litCol else Toolkit.Theme.COL_LIST_DEFAULT
} }
override fun render(batch: SpriteBatch, camera: Camera) { fun render(batch: SpriteBatch, camera: Camera, offX: Int, offY: Int) {
// try to generate a texture // try to generate a texture
if (!hasTexture) { if (!hasTexture) {
val skimmer = App.savegamePlayers[playerUUID]!!.loadable() val skimmer = App.savegamePlayers[playerUUID]!!.loadable()
@@ -636,20 +636,20 @@ class UIItemPlayerCells(
hasTexture = true hasTexture = true
} }
val x = posX.toFloat() val x = posX + offX
val y = posY.toFloat() val y = posY + offY
// draw box backgrounds // draw box backgrounds
batch.color = cellCol batch.color = cellCol
Toolkit.fillArea(batch, posX, posY, 106, height) Toolkit.fillArea(batch, x, y, 106, height)
Toolkit.fillArea(batch, posX + 116, posY + 34, width - 116, 86) Toolkit.fillArea(batch, x + 116, y + 34, width - 116, 86)
// draw borders // draw borders
batch.color = highlightCol batch.color = highlightCol
// avatar border // avatar border
Toolkit.drawBoxBorder(batch, posX - 1, posY - 1, 106 + 2, height + 2) Toolkit.drawBoxBorder(batch, x - 1, y - 1, 106 + 2, height + 2)
// infocell border // infocell border
Toolkit.drawBoxBorder(batch, posX + 115, posY + 33, width - 114, 88) Toolkit.drawBoxBorder(batch, x + 115, y + 33, width - 114, 88)
// texts // texts
batch.color = highlightTextCol batch.color = highlightTextCol
@@ -666,19 +666,23 @@ class UIItemPlayerCells(
// infocell divider // infocell divider
batch.color = if (mouseUp) hruleColLit else hruleCol batch.color = if (mouseUp) hruleColLit else hruleCol
Toolkit.fillArea(batch, posX + 118, posY + 62, width - 120, 1) Toolkit.fillArea(batch, x + 118, y + 62, width - 120, 1)
Toolkit.fillArea(batch, posX + 118, posY + 91, width - 120, 1) Toolkit.fillArea(batch, x + 118, y + 91, width - 120, 1)
// player avatar // player avatar
batch.color = Color.WHITE batch.color = Color.WHITE
this.sprite?.let { this.sprite?.let {
batch.draw(it, batch.draw(it,
x + FastMath.ceil((106f - it.regionWidth) / 2f) + EXTRA_HEADROOM_X / 2, x.toFloat() + FastMath.ceil((106f - it.regionWidth) / 2f) + EXTRA_HEADROOM_X / 2,
y + FastMath.ceil((height - it.regionHeight) / 2f) - EXTRA_HEADROOM_Y / 2 y.toFloat() + FastMath.ceil((height - it.regionHeight) / 2f) - EXTRA_HEADROOM_Y / 2
) )
} }
} }
override fun render(batch: SpriteBatch, camera: Camera) {
render(batch, camera, 0, 0)
}
override fun dispose() { override fun dispose() {
sprite?.texture?.dispose() sprite?.texture?.dispose()
} }

View File

@@ -109,6 +109,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
mode1Node.parent = full.remoCon.treeRoot mode1Node.parent = full.remoCon.treeRoot
mode1Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadSavegame" mode1Node.data = "MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UILoadSavegame"
full.remoCon.setNewRemoConContents(mode1Node) full.remoCon.setNewRemoConContents(mode1Node)
playerCells.forEach { it.dispose() }
playerCells.clear() playerCells.clear()
try { try {
@@ -264,6 +265,8 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
} }
override fun dispose() { override fun dispose() {
playerCells.forEach { it.dispose() }
playerCells.clear()
} }
override fun keyDown(keycode: Int): Boolean { override fun keyDown(keycode: Int): Boolean {
@@ -313,8 +316,6 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
} }
override fun hide() { override fun hide() {
playerCells.forEach { it.dispose() }
playerCells.clear()
showCalled = false showCalled = false
cellLoadThread.interrupt() cellLoadThread.interrupt()
} }

View File

@@ -1,13 +1,15 @@
package net.torvald.terrarum.modulebasegame.ui package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App import net.torvald.terrarum.App
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.round
import net.torvald.terrarum.ui.Movement
import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.Toolkit
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButton import net.torvald.terrarum.ui.UIItemTextButton
import kotlin.math.roundToInt
/** /**
* Created by minjaesong on 2023-07-05. * Created by minjaesong on 2023-07-05.
@@ -17,24 +19,45 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
override var width: Int = Toolkit.drawWidth override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height override var height: Int = App.scr.height
private val goButtonWidth = 180 private val buttonHeight = 24
private val buttonGap = 10
private val buttonWidth = 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 buttonRowY = drawY + 480 - 24 private val hx = Toolkit.hdrawWidth
private val confirmCancelButton = UIItemTextButton(this, "MENU_LABEL_CANCEL", drawX + (240 - goButtonWidth) / 2, buttonRowY, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
private val confirmDeleteButton = UIItemTextButton(this, "MENU_LABEL_DELETE", drawX + 240 + (240 - goButtonWidth) / 2, buttonRowY, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD)
private var mode = 0 private val buttonX1third = hx - (buttonWidth * 1.5).toInt() - buttonGap
private val buttonXcentre = hx - (buttonWidth / 2)
private val buttonX3third = hx + (buttonWidth / 2) + buttonGap
private val MODE_INIT = 0 private val buttonXleft = drawX + (240 - buttonWidth) / 2
private val MODE_DELETE = 16 // are you sure? private val buttonXright = drawX + 240 + (240 - buttonWidth) / 2
private val MODE_RENAME = 32 // show rename dialogue
init { private val buttonRowY = drawY + 480 - buttonHeight
confirmCancelButton.clickOnceListener = { _,_ -> full.remoCon.openUI(UILoadSavegame(full.remoCon)) } private val buttonRowY2 = buttonRowY - buttonHeight - buttonGap
confirmDeleteButton.clickOnceListener = { _,_ ->
val pu = full.buttonSelectedForDeletion!!.playerUUID private val mainGoButton = UIItemTextButton(this, "MENU_IO_LOAD_GAME", buttonX1third, buttonRowY2, buttonWidth * 3 + buttonGap * 2, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
val wu = full.buttonSelectedForDeletion!!.worldUUID
}
private val mainReturnButton = UIItemTextButton(this, "MENU_LABEL_RETURN", buttonX1third, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
it.clickOnceListener = { _,_ ->
full.changePanelTo(0)
}
}
private val mainRenameButton = UIItemTextButton(this, "MENU_LABEL_RENAME", buttonXcentre, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
}
private val mainDeleteButton = UIItemTextButton(this, "CONTEXT_CHARACTER_DELETE", buttonX3third, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
}
private val confirmCancelButton = UIItemTextButton(this, "MENU_LABEL_CANCEL", buttonXleft, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
it.clickOnceListener = { _,_ -> full.remoCon.openUI(UILoadSavegame(full.remoCon)) }
}
private val confirmDeleteButton = UIItemTextButton(this, "MENU_LABEL_DELETE", buttonXright, buttonRowY, buttonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
it.clickOnceListener = { _,_ ->
val pu = full.playerButtonSelected!!.playerUUID
val wu = full.playerButtonSelected!!.worldUUID
App.savegamePlayers[pu]?.moveToRecycle(App.recycledPlayersDir)?.let { App.savegamePlayers[pu]?.moveToRecycle(App.recycledPlayersDir)?.let {
App.sortedPlayers.remove(pu) App.sortedPlayers.remove(pu)
App.savegamePlayers.remove(pu) App.savegamePlayers.remove(pu)
@@ -43,26 +66,52 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
// don't delete the world please // don't delete the world please
full.remoCon.openUI(UILoadSavegame(full.remoCon)) full.remoCon.openUI(UILoadSavegame(full.remoCon))
} }
addUIitem(confirmCancelButton)
addUIitem(confirmDeleteButton)
} }
private var mode = 0
private var mainButtons = listOf(mainGoButton, mainReturnButton, mainRenameButton, mainDeleteButton)
private var delButtons = listOf(confirmCancelButton, confirmDeleteButton)
private val MODE_INIT = 0
private val MODE_DELETE = 16 // are you sure?
private val MODE_RENAME = 32 // show rename dialogue
init {
}
override fun doOpening(delta: Float) {
full.playerButtonSelected?.forceMouseDown = true
}
override fun doClosing(delta: Float) {
full.playerButtonSelected?.forceMouseDown = false
}
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
confirmCancelButton.update(delta) when (mode) {
confirmDeleteButton.update(delta) MODE_INIT -> {
mainButtons.forEach { it.update(delta) }
}
MODE_DELETE -> {
delButtons.forEach { it.update(delta) }
}
}
} }
override fun renderUI(batch: SpriteBatch, camera: Camera) { override fun renderUI(batch: SpriteBatch, camera: Camera) {
val buttonYdelta = (full.titleTopGradEnd + full.cellInterval) - full.playerButtonSelected!!.posY
full.playerButtonSelected!!.render(batch, camera, 0, buttonYdelta)
if (mode == MODE_DELETE) { if (mode == MODE_DELETE) {
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_SAVE_WILL_BE_DELETED"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval - 46) Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_SAVE_WILL_BE_DELETED"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval - 46)
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_ARE_YOU_SURE"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval + SAVE_CELL_HEIGHT + 36) Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_LABEL_ARE_YOU_SURE"], Toolkit.drawWidth, 0, full.titleTopGradEnd + full.cellInterval + SAVE_CELL_HEIGHT + 36)
full.buttonSelectedForDeletion!!.render(batch, camera) delButtons.forEach { it.render(batch, camera) }
}
confirmCancelButton.render(batch, camera) else if (mode == MODE_INIT) {
confirmDeleteButton.render(batch, camera) mainButtons.forEach { it.render(batch, camera) }
} }
} }
@@ -70,15 +119,27 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
} }
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
confirmCancelButton.touchDown(screenX, screenY, pointer, button) when (mode) {
confirmDeleteButton.touchDown(screenX, screenY, pointer, button) MODE_INIT -> {
mainButtons.forEach { it.touchDown(screenX, screenY, pointer, button) }
}
MODE_DELETE -> {
delButtons.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 {
confirmCancelButton.touchUp(screenX, screenY, pointer, button) when (mode) {
confirmDeleteButton.touchUp(screenX, screenY, pointer, button) MODE_INIT -> {
mainButtons.forEach { it.touchDown(screenX, screenY, pointer, button) }
}
MODE_DELETE -> {
delButtons.forEach { it.touchDown(screenX, screenY, pointer, button) }
}
}
return true return true
} }

View File

@@ -21,14 +21,13 @@ class UILoadSaveDamaged(val full: UILoadSavegame) : UICanvas() {
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 buttonRowY = drawY + 480 - 24 private val buttonRowY = drawY + 480 - 24
private val corruptedBackButton = UIItemTextButton(this, "MENU_LABEL_BACK", (Toolkit.drawWidth - goButtonWidth) / 2, buttonRowY, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true) private val corruptedBackButton = UIItemTextButton(this, "MENU_LABEL_BACK", (Toolkit.drawWidth - goButtonWidth) / 2, buttonRowY, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
it.clickOnceListener = { _,_ ->
full.changePanelTo(0)
}
}
init { init {
corruptedBackButton.clickOnceListener = { _,_ ->
full.changePanelTo(0)
println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
}
addUIitem(corruptedBackButton) addUIitem(corruptedBackButton)
} }

View File

@@ -5,19 +5,13 @@ 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.utils.GdxRuntimeException
import net.torvald.unicode.getKeycapConsole
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.modulebasegame.serialise.LoadSavegame
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.internalWidth
import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.*
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.util.* import java.util.*
import kotlin.math.roundToInt
/** /**
@@ -77,7 +71,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
private val scrollAnimLen = 0.1f private val scrollAnimLen = 0.1f
private var sliderFBO = FrameBuffer(Pixmap.Format.RGBA8888, uiWidth + 10, height, false) private var sliderFBO = FrameBuffer(Pixmap.Format.RGBA8888, uiWidth + 10, height, false)
internal var buttonSelectedForDeletion: UIItemPlayerCells? = null internal var playerButtonSelected: UIItemPlayerCells? = null
private val goButtonWidth = 180 private val goButtonWidth = 180
private val drawX = (Toolkit.drawWidth - 480) / 2 private val drawX = (Toolkit.drawWidth - 480) / 2
@@ -130,6 +124,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
if (button.javaClass.simpleName == "UIItemPlayerCells") { if (button.javaClass.simpleName == "UIItemPlayerCells") {
transitionalListing.advanceMode() transitionalListing.advanceMode()
playerButtonSelected = button as UIItemPlayerCells
} }
} }

View File

@@ -28,7 +28,7 @@ open class UIItemTransitionContainer(
private val epsilon = 0.001f private val epsilon = 0.001f
private fun timeToUpdate(index: Int) = true//(currentPosition > index - 1 + epsilon && currentPosition < index + 1 - epsilon) private fun timeToUpdate(index: Int) = (currentPosition > index - 1 + epsilon && currentPosition < index + 1 - epsilon)
fun requestTransition(target: Int) { fun requestTransition(target: Int) {
if (!transitionOngoing) { if (!transitionOngoing) {