From f9e12553c98ff32bacf47e5d8cd77dd32b800bbe Mon Sep 17 00:00:00 2001 From: austin Date: Thu, 27 Mar 2025 16:26:21 -0400 Subject: [PATCH] single player save file filtering --- docs/src/progress/renderertodo.md | 1 + .../ui/menu/mainmenu/MenuWorldSelect.java | 2 +- .../electrosphere/server/saves/SaveUtils.java | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index adc199d4..60b126af 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1338,6 +1338,7 @@ Disable fluid sim for performance Increase fall delay Rearchitect foliage rendering to combat grass pop-in/pop-out Increase sim range to fight game object pop-in +Filter select-able saves on singleplayer screen to full game saves diff --git a/src/main/java/electrosphere/client/ui/menu/mainmenu/MenuWorldSelect.java b/src/main/java/electrosphere/client/ui/menu/mainmenu/MenuWorldSelect.java index 64c4451b..04b08526 100644 --- a/src/main/java/electrosphere/client/ui/menu/mainmenu/MenuWorldSelect.java +++ b/src/main/java/electrosphere/client/ui/menu/mainmenu/MenuWorldSelect.java @@ -31,7 +31,7 @@ public class MenuWorldSelect { saveButtonContainer.setMarginRight(50); List saveNames = SaveUtils.getSaves(); for(String saveName : saveNames){ - if(!saveName.startsWith(".")){ + if(!saveName.startsWith(".") && SaveUtils.isProcedural(saveName)){ Div spacer = Div.createDiv(); spacer.addChild(Button.createButton(saveName.toUpperCase(), () -> { diff --git a/src/main/java/electrosphere/server/saves/SaveUtils.java b/src/main/java/electrosphere/server/saves/SaveUtils.java index c1b14a9b..b1c51688 100644 --- a/src/main/java/electrosphere/server/saves/SaveUtils.java +++ b/src/main/java/electrosphere/server/saves/SaveUtils.java @@ -236,9 +236,25 @@ public class SaveUtils { * @return true if the world file exists, false otherwise */ public static boolean saveHasWorldFile(String saveName){ - String dirPath = deriveSaveDirectoryPath(saveName) + "/world.json"; + String dirPath = SaveUtils.deriveSaveDirectoryPath(saveName) + "/world.json"; LoggerInterface.loggerEngine.DEBUG("Exists? " + dirPath); return FileUtils.checkFileExists(dirPath); } + + /** + * Checks if the save is a procedural world + * @param saveName The name of the save + * @return true if the world is procedural, false otherwise + */ + public static boolean isProcedural(String saveName){ + if(!FileUtils.checkFileExists(SaveUtils.deriveSaveDirectoryPath(saveName) + "scene.json")){ + return false; + } + SceneFile sceneFile = FileUtils.loadObjectFromSavePath(saveName, "scene.json", SceneFile.class); + if(sceneFile == null){ + return false; + } + return sceneFile.getRealmDescriptor().getType().equals(RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL); + } }