mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
save deletion works but gui is still wip
This commit is contained in:
@@ -1139,6 +1139,11 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
public static RunningEnvironment environment;
|
public static RunningEnvironment environment;
|
||||||
|
|
||||||
|
/** defaultDir + "/Recycled/Players" */
|
||||||
|
public static String recycledPlayersDir;
|
||||||
|
/** defaultDir + "/Recycled/Worlds" */
|
||||||
|
public static String recycledWorldsDir;
|
||||||
|
|
||||||
private static void getDefaultDirectory() {
|
private static void getDefaultDirectory() {
|
||||||
String OS = OSName.toUpperCase();
|
String OS = OSName.toUpperCase();
|
||||||
if (OS.contains("WIN")) {
|
if (OS.contains("WIN")) {
|
||||||
@@ -1168,6 +1173,8 @@ public class App implements ApplicationListener {
|
|||||||
worldsDir = defaultDir + "/Worlds";
|
worldsDir = defaultDir + "/Worlds";
|
||||||
configDir = defaultDir + "/config.json";
|
configDir = defaultDir + "/config.json";
|
||||||
loadOrderDir = defaultDir + "/LoadOrder.txt";
|
loadOrderDir = defaultDir + "/LoadOrder.txt";
|
||||||
|
recycledPlayersDir = defaultDir + "/Recycled/Players";
|
||||||
|
recycledWorldsDir = defaultDir + "/Recycled/Worlds";
|
||||||
|
|
||||||
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
||||||
System.out.println(String.format("os.version = %s", OSVersion));
|
System.out.println(String.format("os.version = %s", OSVersion));
|
||||||
@@ -1177,10 +1184,12 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
private static void createDirs() {
|
private static void createDirs() {
|
||||||
File[] dirs = {
|
File[] dirs = {
|
||||||
new File(saveDir),
|
// new File(saveDir),
|
||||||
new File(saveSharedDir),
|
new File(saveSharedDir),
|
||||||
new File(playersDir),
|
new File(playersDir),
|
||||||
new File(worldsDir)
|
new File(worldsDir),
|
||||||
|
new File(recycledPlayersDir),
|
||||||
|
new File(recycledWorldsDir),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (File it : dirs) {
|
for (File it : dirs) {
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ package net.torvald.terrarum
|
|||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.savegame.DiskSkimmer
|
import net.torvald.terrarum.savegame.DiskSkimmer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.StandardCopyOption
|
||||||
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2023-06-24.
|
* Created by minjaesong on 2023-06-24.
|
||||||
@@ -35,6 +39,16 @@ class SavegameCollection(files0: List<DiskSkimmer>) {
|
|||||||
return files.first()
|
return files.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun moveToRecycle(basedir: String) {
|
||||||
|
files.forEach {
|
||||||
|
try {
|
||||||
|
Files.move(it.diskFile.toPath(), Path(basedir, it.diskFile.name), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
}
|
||||||
|
catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SavegameCollectionPair(player: SavegameCollection?, world: SavegameCollection?) {
|
class SavegameCollectionPair(player: SavegameCollection?, world: SavegameCollection?) {
|
||||||
|
|||||||
@@ -505,8 +505,8 @@ class UIItemPlayerCells(
|
|||||||
private var lastPlayTime: String = "????-??-?? --:--:--"
|
private var lastPlayTime: String = "????-??-?? --:--:--"
|
||||||
private var totalPlayTime: String = "--h--m--s"
|
private var totalPlayTime: String = "--h--m--s"
|
||||||
|
|
||||||
private lateinit var playerUUID: UUID
|
lateinit var playerUUID: UUID; private set
|
||||||
private lateinit var worldUUID: UUID
|
lateinit var worldUUID: UUID; private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
skimmer.getFile(SAVEGAMEINFO)?.bytes?.let {
|
skimmer.getFile(SAVEGAMEINFO)?.bytes?.let {
|
||||||
|
|||||||
@@ -174,6 +174,21 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
confirmBackButton.clickOnceListener = { _,_ ->
|
confirmBackButton.clickOnceListener = { _,_ ->
|
||||||
remoCon.openUI(UILoadSavegame(remoCon))
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
}
|
}
|
||||||
|
confirmDeleteButton.clickOnceListener = { _,_ ->
|
||||||
|
val pu = buttonSelectedForDeletion!!.playerUUID
|
||||||
|
val wu = buttonSelectedForDeletion!!.worldUUID
|
||||||
|
App.savegamePlayers[pu]?.moveToRecycle(App.recycledPlayersDir)?.let {
|
||||||
|
App.sortedPlayers.remove(pu)
|
||||||
|
App.savegamePlayers.remove(pu)
|
||||||
|
App.savegamePlayersName.remove(pu)
|
||||||
|
}
|
||||||
|
App.savegameWorlds[wu]?.moveToRecycle(App.recycledWorldsDir)?.let {
|
||||||
|
App.sortedSavegameWorlds.remove(wu)
|
||||||
|
App.savegameWorlds.remove(wu)
|
||||||
|
App.savegameWorldsName.remove(wu)
|
||||||
|
}
|
||||||
|
remoCon.openUI(UILoadSavegame(remoCon))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun advanceMode(button: UIItem) {
|
override fun advanceMode(button: UIItem) {
|
||||||
|
|||||||
Reference in New Issue
Block a user