savegames are finally sorted

This commit is contained in:
minjaesong
2022-01-12 11:59:10 +09:00
parent 9797094cae
commit b0cf37250f
3 changed files with 18 additions and 8 deletions

View File

@@ -200,10 +200,13 @@ public class App implements ApplicationListener {
/**
* Sorted by the lastplaytime, in reverse order (index 0 is the most recent game played)
*/
public static TreeMap<UUID, DiskSkimmer> savegameWorlds = new TreeMap<>();
public static TreeMap<UUID, String> savegameWorldsName = new TreeMap<>();
public static TreeMap<UUID, DiskSkimmer> savegamePlayers = new TreeMap<>();
public static TreeMap<UUID, String> savegamePlayersName = new TreeMap<>();
public static ArrayList<UUID> sortedSavegameWorlds = new ArrayList();
public static HashMap<UUID, DiskSkimmer> savegameWorlds = new HashMap<>(); // UNSORTED even with the TreeMap
public static HashMap<UUID, String> savegameWorldsName = new HashMap<>();
public static ArrayList<UUID> sortedPlayers = new ArrayList();
public static HashMap<UUID, DiskSkimmer> savegamePlayers = new HashMap<>();
public static HashMap<UUID, String> savegamePlayersName = new HashMap<>();
public static void updateListOfSavegames() {
AppUpdateListOfSavegames();

View File

@@ -672,10 +672,12 @@ class Codex : KVHashMap() {
}
fun AppUpdateListOfSavegames() {
App.savegamePlayers.clear()
App.savegamePlayersName.clear()
App.sortedSavegameWorlds.clear()
App.savegameWorlds.clear()
App.savegameWorldsName.clear()
App.sortedPlayers.clear()
App.savegamePlayers.clear()
App.savegamePlayersName.clear()
println("Listing saved worlds...")
@@ -699,9 +701,11 @@ fun AppUpdateListOfSavegames() {
val worldUUID = UUID.fromString(json.getString("worldIndex"))
App.savegameWorlds[worldUUID] = it
App.savegameWorldsName[worldUUID] = it.getDiskName(Common.CHARSET)
App.sortedSavegameWorlds.add(worldUUID)
}
println("Listing saved players...")
// create list of players
@@ -724,6 +728,7 @@ fun AppUpdateListOfSavegames() {
val playerUUID = UUID.fromString(json.getString("uuid"))
App.savegamePlayers[playerUUID] = it
App.savegamePlayersName[playerUUID] = it.getDiskName(Common.CHARSET)
App.sortedPlayers.add(playerUUID)
}
}

View File

@@ -168,7 +168,8 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
Thread {
// read savegames
var savegamesCount = 0
App.savegameWorlds.forEach { (_, skimmer) ->
App.sortedSavegameWorlds.forEach { uuid ->
val skimmer = App.savegameWorlds[uuid]!!
val x = uiX
val y = titleTopGradEnd + cellInterval * savegamesCount
try {
@@ -182,7 +183,8 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
}
savegamesCount = 0
App.savegamePlayers.forEach { (_, skimmer) ->
App.sortedPlayers.forEach { uuid ->
val skimmer = App.savegamePlayers[uuid]!!
val x = uiX
val y = titleTopGradEnd + cellInterval * savegamesCount
try {