From 6f8e44f3255d415ccd27a58d97a6cecb8a927507 Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 24 Mar 2024 13:19:02 -0400 Subject: [PATCH] menu refactoring --- docs/src/architecture/architectureindex.md | 1 + docs/src/architecture/saves/savesindex.md | 1 + .../scenemanagement/entitySerialization.md | 21 ++++++++ .../scenemanagement/serverSceneManagement.md | 5 +- docs/src/progress/renderertodo.md | 9 ++++ .../controls/ControlHandler.java | 6 +-- src/main/java/electrosphere/engine/Main.java | 2 +- .../engine/loadingthreads/ClientLoading.java | 2 +- .../engine/loadingthreads/LoadingUtils.java | 16 ++---- .../entity/EntityDataStrings.java | 10 ++-- .../java/electrosphere/entity/EntityTags.java | 7 ++- .../electrosphere/entity/EntityUtils.java | 52 ++++++++++++++++--- .../entity/types/creature/CreatureUtils.java | 28 +++++++--- .../entity/types/item/ItemUtils.java | 43 ++++++++++----- .../electrosphere/menu/MenuGenerators.java | 5 +- .../java/electrosphere/menu/WindowUtils.java | 2 + .../menu/{ => debug}/ImGuiWindowMacros.java | 3 +- .../{ => ingame}/MenuGeneratorsInGame.java | 4 +- .../{ => ingame}/MenuGeneratorsInventory.java | 4 +- .../{ => mainmenu}/MenuGeneratorsArena.java | 2 +- .../{ => mainmenu}/MenuGeneratorsDebug.java | 4 +- .../MenuGeneratorsMultiplayer.java | 4 +- .../MenuGeneratorsTitleMenu.java | 4 +- .../electrosphere/server/datacell/Realm.java | 2 +- .../java/electrosphere/server/saves/Save.java | 24 ++++++++- .../electrosphere/server/saves/SaveUtils.java | 38 ++++++++++---- 26 files changed, 229 insertions(+), 70 deletions(-) create mode 100644 docs/src/architecture/saves/savesindex.md create mode 100644 docs/src/architecture/scenemanagement/entitySerialization.md rename src/main/java/electrosphere/menu/{ => debug}/ImGuiWindowMacros.java (99%) rename src/main/java/electrosphere/menu/{ => ingame}/MenuGeneratorsInGame.java (99%) rename src/main/java/electrosphere/menu/{ => ingame}/MenuGeneratorsInventory.java (99%) rename src/main/java/electrosphere/menu/{ => mainmenu}/MenuGeneratorsArena.java (98%) rename src/main/java/electrosphere/menu/{ => mainmenu}/MenuGeneratorsDebug.java (96%) rename src/main/java/electrosphere/menu/{ => mainmenu}/MenuGeneratorsMultiplayer.java (98%) rename src/main/java/electrosphere/menu/{ => mainmenu}/MenuGeneratorsTitleMenu.java (97%) diff --git a/docs/src/architecture/architectureindex.md b/docs/src/architecture/architectureindex.md index 16735ac5..92afab5d 100644 --- a/docs/src/architecture/architectureindex.md +++ b/docs/src/architecture/architectureindex.md @@ -8,6 +8,7 @@ - @subpage audioengine - @subpage timekeeper - @subpage archimprovementtargets +- @subpage savesindex # What is this section diff --git a/docs/src/architecture/saves/savesindex.md b/docs/src/architecture/saves/savesindex.md new file mode 100644 index 00000000..5d8da027 --- /dev/null +++ b/docs/src/architecture/saves/savesindex.md @@ -0,0 +1 @@ +@page savesindex Saves diff --git a/docs/src/architecture/scenemanagement/entitySerialization.md b/docs/src/architecture/scenemanagement/entitySerialization.md new file mode 100644 index 00000000..42f9a891 --- /dev/null +++ b/docs/src/architecture/scenemanagement/entitySerialization.md @@ -0,0 +1,21 @@ +@page entitySerialization Entity Serialization + +How are entities load from disk/sent to player + +Entities have a top level 'type', ie 'creature', 'object', 'foliage', etc +Beneath that is the specific subtype, ie 'human', 'elf', 'woodenCrate' + + +Lets say when the client receives the request 'spawn human' it runs the full human-creation macro. What then needs to be updated from the default for the macro? +Visual attributes +Equip state +current animation +movement state +idle state +gravity state +jump state +attack state + + +Specifically when loading files, also need to store server data +Which entity is the player's entity diff --git a/docs/src/architecture/scenemanagement/serverSceneManagement.md b/docs/src/architecture/scenemanagement/serverSceneManagement.md index 6cc422ed..d9be0ccb 100644 --- a/docs/src/architecture/scenemanagement/serverSceneManagement.md +++ b/docs/src/architecture/scenemanagement/serverSceneManagement.md @@ -1,3 +1,6 @@ @page serverSceneManagement Server Scene Management -TODO \ No newline at end of file +TODO + +[TOC] +- @subpage entitySerialization \ No newline at end of file diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 20309d9b..a860d6cb 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -195,6 +195,15 @@ Level loading/saving + Basic Editor - Menu of types of entities to spawn - Button to spawn them at cursor +More Debug menus + - Screen that shows the overall status of client scene + - Number of entities + - Maybe a listing of each one? + - Screen that shows the overall status of draw cell manager + - Screen that shows the overall status of fluid cell manager + - Screen that shows the overall status of realm 0 + - Screen that shows the overall status of realm manager + Revisit first attempt at instancing (its really laggy lol) - Maybe have draw call happen on top level entity and immediately queue all children recursively diff --git a/src/main/java/electrosphere/controls/ControlHandler.java b/src/main/java/electrosphere/controls/ControlHandler.java index e2840c9e..7f6c5acc 100644 --- a/src/main/java/electrosphere/controls/ControlHandler.java +++ b/src/main/java/electrosphere/controls/ControlHandler.java @@ -97,11 +97,11 @@ import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.logger.LoggerInterface; import electrosphere.menu.MenuGenerators; -import electrosphere.menu.MenuGeneratorsDebug; -import electrosphere.menu.MenuGeneratorsInGame; -import electrosphere.menu.MenuGeneratorsInventory; import electrosphere.menu.WindowStrings; import electrosphere.menu.WindowUtils; +import electrosphere.menu.ingame.MenuGeneratorsInGame; +import electrosphere.menu.ingame.MenuGeneratorsInventory; +import electrosphere.menu.mainmenu.MenuGeneratorsDebug; import electrosphere.renderer.ui.Window; import electrosphere.renderer.ui.events.ClickEvent; import electrosphere.renderer.ui.events.KeyboardEvent; diff --git a/src/main/java/electrosphere/engine/Main.java b/src/main/java/electrosphere/engine/Main.java index 92cbbbf9..feeea720 100644 --- a/src/main/java/electrosphere/engine/Main.java +++ b/src/main/java/electrosphere/engine/Main.java @@ -17,7 +17,7 @@ import electrosphere.engine.time.Timekeeper; import electrosphere.game.config.UserSettings; import electrosphere.game.server.world.MacroData; import electrosphere.logger.LoggerInterface; -import electrosphere.menu.ImGuiWindowMacros; +import electrosphere.menu.debug.ImGuiWindowMacros; import electrosphere.renderer.RenderingEngine; import electrosphere.server.simulation.MacroSimulation; diff --git a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java index 7849de46..77d8c86d 100644 --- a/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java +++ b/src/main/java/electrosphere/engine/loadingthreads/ClientLoading.java @@ -31,9 +31,9 @@ import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.tree.ProceduralTree; import electrosphere.logger.LoggerInterface; import electrosphere.menu.MenuGenerators; -import electrosphere.menu.MenuGeneratorsMultiplayer; import electrosphere.menu.WindowStrings; import electrosphere.menu.WindowUtils; +import electrosphere.menu.mainmenu.MenuGeneratorsMultiplayer; import electrosphere.net.NetUtils; import electrosphere.net.client.ClientNetworking; import electrosphere.renderer.ui.Window; diff --git a/src/main/java/electrosphere/engine/loadingthreads/LoadingUtils.java b/src/main/java/electrosphere/engine/loadingthreads/LoadingUtils.java index ff888757..4220128f 100644 --- a/src/main/java/electrosphere/engine/loadingthreads/LoadingUtils.java +++ b/src/main/java/electrosphere/engine/loadingthreads/LoadingUtils.java @@ -49,10 +49,6 @@ import electrosphere.server.terrain.manager.ServerTerrainManager; */ public class LoadingUtils { - // static void initTerrainDataCellManager(){ - // Globals.griddedDataCellManager.init(Globals.serverWorldData); - // } - static void initServerGameTerrainManager(){ @@ -62,13 +58,11 @@ public class LoadingUtils { */ float randomDampener = 0.0f; //0.25f; Globals.serverTerrainManager = new ServerTerrainManager(2000,50,randomDampener,0,new OverworldChunkGenerator()); - if(Globals.RUN_SERVER){ - if(Globals.userSettings.gameplayGenerateWorld()){ - Globals.serverTerrainManager.generate(); - Globals.serverTerrainManager.save("./terrain.json"); - } else { - SaveUtils.loadSave(Globals.currentSaveName); - } + if(Globals.userSettings.gameplayGenerateWorld()){ + Globals.serverTerrainManager.generate(); + Globals.serverTerrainManager.save("./terrain.json"); + } else { + SaveUtils.loadSave(Globals.currentSaveName); } /* diff --git a/src/main/java/electrosphere/entity/EntityDataStrings.java b/src/main/java/electrosphere/entity/EntityDataStrings.java index 0a7d80b4..332578ae 100644 --- a/src/main/java/electrosphere/entity/EntityDataStrings.java +++ b/src/main/java/electrosphere/entity/EntityDataStrings.java @@ -32,6 +32,12 @@ public class EntityDataStrings { public static final String INSTANCED_MODEL_ATTRIBUTE = "instancedModelAttribute"; + /** + * Entity type + */ + public static final String ENTITY_TYPE = "entityType"; //ie "creature", "foliage", "terrain", etc + public static final String ENTITY_SUBTYPE = "entitySubtype"; //ie "human", "woodenCrate", etc + /* Terrain Entity */ @@ -46,8 +52,6 @@ public class EntityDataStrings { /* Creature Entity */ - public static final String DATA_STRING_CREATURE_IS_CREATURE = "isCreature"; - public static final String DATA_STRING_CREATURE_TYPE = "creatureType"; public static final String DATA_STRING_CREATURE_CONTROLLER_PLAYER_ID = "creaturePlayerId"; public static final String CLIENT_MOVEMENT_BT = "clientMovementBT"; public static final String SERVER_MOVEMENT_BT = "serverMovementBT"; @@ -176,8 +180,6 @@ public class EntityDataStrings { /* Item Entity */ - public static final String ITEM_IS_ITEM = "itemIsItem"; - public static final String ITEM_TYPE = "itemType"; public static final String ITEM_IS_WEAPON = "itemIsWeapon"; public static final String ITEM_IS_ARMOR = "itemIsArmor"; public static final String ITEM_EQUIP_WHITELIST = "itemEquipWhitelist"; diff --git a/src/main/java/electrosphere/entity/EntityTags.java b/src/main/java/electrosphere/entity/EntityTags.java index 27389b68..1739f47e 100644 --- a/src/main/java/electrosphere/entity/EntityTags.java +++ b/src/main/java/electrosphere/entity/EntityTags.java @@ -1,5 +1,8 @@ package electrosphere.entity; +/** + * Tags used in scenes to delineate groups of entities + */ public class EntityTags { public static final String BONE_ATTACHED = "boneAttached"; @@ -12,8 +15,8 @@ public class EntityTags { public static final String LIFE_STATE = "lifeState"; public static final String CREATURE = "creature"; public static final String FOLIAGE = "foliage"; - public static final String UI = "ui"; - public static final String DRAWABLE = "drawable"; + public static final String UI = "ui"; //is it a ui entity + public static final String DRAWABLE = "drawable"; //is it drawable public static final String DRAW_INSTANCED = "drawInstanced"; //if it's instanced, but not necessarily managed by a service (ie a tree branch) public static final String DRAW_INSTANCED_MANAGED = "drawInstancedManaged"; //if it's managed by a service (ie foliage manager) public static final String LIGHT = "light"; diff --git a/src/main/java/electrosphere/entity/EntityUtils.java b/src/main/java/electrosphere/entity/EntityUtils.java index 74b04d7d..fdcb4fde 100644 --- a/src/main/java/electrosphere/entity/EntityUtils.java +++ b/src/main/java/electrosphere/entity/EntityUtils.java @@ -118,11 +118,9 @@ public class EntityUtils { */ protected static Entity spawnSpatialEntity(){ Entity rVal = new Entity(); -// rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath); rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0)); rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity()); rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1)); - EntityLookupUtils.registerServerEntity(rVal); return rVal; } @@ -149,14 +147,20 @@ public class EntityUtils { EntityLookupUtils.removeEntity(e); } - // public static void setEntityID(Entity e, int id){ - // Globals.entityManager.mapIdToId(e.getId(), id); - // } - + /** + * Gets the actor on the entity + * @param e The entity + * @return The actor + */ public static Actor getActor(Entity e){ return (Actor)e.getData(EntityDataStrings.DATA_STRING_ACTOR); } + /** + * Gets the pose actor on the entity + * @param e The entity + * @return the pose actor + */ public static PoseActor getPoseActor(Entity e){ return (PoseActor)e.getData(EntityDataStrings.POSE_ACTOR); } @@ -172,5 +176,41 @@ public class EntityUtils { public static boolean getDraw(Entity entity){ return (boolean)entity.getData(EntityDataStrings.DATA_STRING_DRAW); } + + /** + * Gets the type of the entity + * @param entity The entity + * @return The type + */ + public static int getEntityType(Entity entity){ + return (int)entity.getData(EntityDataStrings.ENTITY_TYPE); + } + + /** + * Sets the entity type + * @param entity the entity + * @param type the type + */ + public static void setEntityType(Entity entity, int type){ + entity.putData(EntityDataStrings.ENTITY_TYPE, type); + } + + /** + * Gets the subtype of this entity + * @param entity The entity + * @return The subtype + */ + public static String getEntitySubtype(Entity entity){ + return (String)entity.getData(EntityDataStrings.ENTITY_SUBTYPE); + } + + /** + * Sets the subtype of this entity + * @param entity The entity + * @param subtype The subtype + */ + public static void setEntitySubtype(Entity entity, String subtype){ + entity.putData(EntityDataStrings.ENTITY_SUBTYPE, subtype); + } } diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index c0b68e11..60bb97a9 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -84,6 +84,9 @@ import electrosphere.util.Utilities; * Utilities for creating creatures on the client and server */ public class CreatureUtils { + + //The entity type int for creatures + public static final int ENTITY_TYPE_CREATURE = 0; /** * Spawns a client-side creature entity @@ -371,8 +374,8 @@ public class CreatureUtils { rVal.putData(EntityDataStrings.TREE_IDLE, idleTree); Globals.clientScene.registerBehaviorTree(idleTree); Globals.clientScene.registerEntityToTag(rVal, EntityTags.CREATURE); - rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true); - rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE); + EntityUtils.setEntitySubtype(rVal, type); CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1)); rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); return rVal; @@ -667,8 +670,8 @@ public class CreatureUtils { ServerIdleTree.attachTree(rVal); ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.CREATURE); - rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE, true); - rVal.putData(EntityDataStrings.DATA_STRING_CREATURE_TYPE, type); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_CREATURE); + EntityUtils.setEntitySubtype(rVal, type); CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,1)); rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); return rVal; @@ -755,8 +758,13 @@ public class CreatureUtils { clientGetAttackTree(e).addNetworkMessage(em); } + /** + * Gets the type of creature + * @param e the entity + * @return the type + */ public static String getType(Entity e){ - return (String)e.getData(EntityDataStrings.DATA_STRING_CREATURE_TYPE); + return (String)EntityUtils.getEntitySubtype(e); } public static int getControllerPlayerId(Entity e){ @@ -771,8 +779,16 @@ public class CreatureUtils { return e.containsKey(EntityDataStrings.DATA_STRING_CREATURE_CONTROLLER_PLAYER_ID); } + /** + * Checks if this entity is a creature + * @param e The entity + * @return true if it is a creature, false otherwise + */ public static boolean isCreature(Entity e){ - return e.containsKey(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE); + if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){ + return false; + } + return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE; } public static AttackTree clientGetAttackTree(Entity e){ diff --git a/src/main/java/electrosphere/entity/types/item/ItemUtils.java b/src/main/java/electrosphere/entity/types/item/ItemUtils.java index f2e77b43..35f88f40 100644 --- a/src/main/java/electrosphere/entity/types/item/ItemUtils.java +++ b/src/main/java/electrosphere/entity/types/item/ItemUtils.java @@ -40,11 +40,14 @@ import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils; /** - * - * @author amaterasu + * Utilities for working with items */ public class ItemUtils { + //The item creature type + public static final int ENTITY_TYPE_ITEM = 1; + + //generic item icon filepath static final String genericItemIconPath = "Textures/icons/itemIconItemGeneric.png"; public static Entity clientSpawnBasicItem(String name){ @@ -106,9 +109,9 @@ public class ItemUtils { rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass()); } rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); - rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false); - rVal.putData(EntityDataStrings.ITEM_TYPE, name); + EntityUtils.setEntitySubtype(rVal, name); // rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f)); // rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2))); Globals.clientSceneWrapper.getScene().registerEntityToTag(rVal, EntityTags.ITEM); @@ -176,9 +179,9 @@ public class ItemUtils { rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS,item.getEquipClass()); } rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true); - rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, false); - rVal.putData(EntityDataStrings.ITEM_TYPE, name); + EntityUtils.setEntitySubtype(rVal, name); // rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(0.005f,0.005f,0.005f)); // rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().identity().rotateY((float)(-Math.PI/2)).rotateZ(-(float)(Math.PI/2))); ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ITEM); @@ -234,12 +237,26 @@ public class ItemUtils { player.addMessage(message); } - public static boolean isItem(Entity item){ - return item.containsKey(EntityDataStrings.ITEM_IS_ITEM); + + /** + * Checks if this entity is an item + * @param e the entity + * @return true if it is an item, false otherwise + */ + public static boolean isItem(Entity e){ + if(!e.containsKey(EntityDataStrings.ENTITY_TYPE)){ + return false; + } + return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_ITEM; } + /** + * Gets the type of item + * @param item The entity + * @return The type + */ public static String getType(Entity item){ - return (String)item.getData(EntityDataStrings.ITEM_TYPE); + return EntityUtils.getEntitySubtype(item); } public static boolean isWeapon(Entity item){ @@ -298,10 +315,10 @@ public class ItemUtils { } rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item)); rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS)); - rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true); ItemUtils.setContainingParent(rVal, containingParent); - rVal.putData(EntityDataStrings.ITEM_TYPE, item.getData(EntityDataStrings.ITEM_TYPE)); + EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item)); Globals.clientSceneWrapper.getScene().registerEntity(rVal); return rVal; } else { @@ -323,10 +340,10 @@ public class ItemUtils { } rVal.putData(EntityDataStrings.ITEM_ICON,ItemUtils.getItemIcon(item)); rVal.putData(EntityDataStrings.ITEM_EQUIP_CLASS, item.getData(EntityDataStrings.ITEM_EQUIP_CLASS)); - rVal.putData(EntityDataStrings.ITEM_IS_ITEM, true); + EntityUtils.setEntityType(rVal, ENTITY_TYPE_ITEM); rVal.putData(EntityDataStrings.ITEM_IS_IN_INVENTORY, true); ItemUtils.setContainingParent(rVal, containingParent); - rVal.putData(EntityDataStrings.ITEM_TYPE, item.getData(EntityDataStrings.ITEM_TYPE)); + EntityUtils.setEntitySubtype(rVal, EntityUtils.getEntitySubtype(item)); return rVal; } else { return null; diff --git a/src/main/java/electrosphere/menu/MenuGenerators.java b/src/main/java/electrosphere/menu/MenuGenerators.java index b167e761..4ede78f7 100644 --- a/src/main/java/electrosphere/menu/MenuGenerators.java +++ b/src/main/java/electrosphere/menu/MenuGenerators.java @@ -16,6 +16,7 @@ import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.game.data.creature.type.CreatureType; import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; +import electrosphere.menu.mainmenu.MenuGeneratorsTitleMenu; import electrosphere.net.NetUtils; import electrosphere.renderer.RenderingEngine; import electrosphere.renderer.actor.Actor; @@ -70,7 +71,7 @@ public class MenuGenerators { selectButton.addChild(selectLabel); rVal.addChild(selectButton); selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ - if(SaveUtils.worldHasSave(saveName.toLowerCase())){ + if(SaveUtils.saveHasWorldFile(saveName.toLowerCase())){ //need to log client in Globals.clientUsername = "username"; Globals.clientPassword = AuthenticationManager.getHashedString("password"); @@ -152,7 +153,7 @@ public class MenuGenerators { saveButton.addChild(saveLabel); rVal.addChild(saveButton); saveButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ - SaveUtils.saveWorldDataToSave(Globals.currentSaveName); + SaveUtils.saveWorldData(Globals.currentSaveName); WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldSelectMenu()); return false; }}); diff --git a/src/main/java/electrosphere/menu/WindowUtils.java b/src/main/java/electrosphere/menu/WindowUtils.java index cfece294..5bd6b401 100644 --- a/src/main/java/electrosphere/menu/WindowUtils.java +++ b/src/main/java/electrosphere/menu/WindowUtils.java @@ -4,6 +4,8 @@ import electrosphere.engine.Globals; import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.RelationalInventoryState; import electrosphere.entity.state.inventory.UnrelationalInventoryState; +import electrosphere.menu.ingame.MenuGeneratorsInventory; +import electrosphere.menu.mainmenu.MenuGeneratorsTitleMenu; import electrosphere.renderer.ui.ContainerElement; import electrosphere.renderer.ui.DrawableElement; import electrosphere.renderer.ui.Element; diff --git a/src/main/java/electrosphere/menu/ImGuiWindowMacros.java b/src/main/java/electrosphere/menu/debug/ImGuiWindowMacros.java similarity index 99% rename from src/main/java/electrosphere/menu/ImGuiWindowMacros.java rename to src/main/java/electrosphere/menu/debug/ImGuiWindowMacros.java index 8b15670e..1b1438c7 100644 --- a/src/main/java/electrosphere/menu/ImGuiWindowMacros.java +++ b/src/main/java/electrosphere/menu/debug/ImGuiWindowMacros.java @@ -1,4 +1,4 @@ -package electrosphere.menu; +package electrosphere.menu.debug; import java.util.HashMap; import java.util.Map; @@ -71,6 +71,7 @@ public class ImGuiWindowMacros { initFramerateGraphSeries("clientNetwork"); initFramerateGraphSeries("controls"); globalFrametimeWindow.addElement(globalFrametimePlot); + globalFrametimeWindow.setOpen(false); RenderingEngine.addImGuiWindow(globalFrametimeWindow); } diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsInGame.java b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInGame.java similarity index 99% rename from src/main/java/electrosphere/menu/MenuGeneratorsInGame.java rename to src/main/java/electrosphere/menu/ingame/MenuGeneratorsInGame.java index 48cd48e8..5e729b2c 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsInGame.java +++ b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInGame.java @@ -1,4 +1,4 @@ -package electrosphere.menu; +package electrosphere.menu.ingame; import org.joml.Vector3f; @@ -11,6 +11,8 @@ import electrosphere.entity.EntityUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.game.data.creature.type.CreatureType; import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; +import electrosphere.menu.WindowStrings; +import electrosphere.menu.WindowUtils; import electrosphere.renderer.RenderingEngine; import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.ActorStaticMorph; diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsInventory.java b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java similarity index 99% rename from src/main/java/electrosphere/menu/MenuGeneratorsInventory.java rename to src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java index 04cd7c41..5d3d18f8 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsInventory.java +++ b/src/main/java/electrosphere/menu/ingame/MenuGeneratorsInventory.java @@ -1,4 +1,4 @@ -package electrosphere.menu; +package electrosphere.menu.ingame; import java.util.List; @@ -14,6 +14,8 @@ import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.RelationalInventoryState; import electrosphere.entity.state.inventory.UnrelationalInventoryState; import electrosphere.entity.types.item.ItemUtils; +import electrosphere.menu.WindowStrings; +import electrosphere.menu.WindowUtils; import electrosphere.renderer.ui.DraggableElement.DragEventCallback; import electrosphere.renderer.ui.elements.Div; import electrosphere.renderer.ui.elements.ImagePanel; diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsArena.java b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsArena.java similarity index 98% rename from src/main/java/electrosphere/menu/MenuGeneratorsArena.java rename to src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsArena.java index c0d66ee0..b29558d7 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsArena.java +++ b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsArena.java @@ -1,4 +1,4 @@ -package electrosphere.menu; +package electrosphere.menu.mainmenu; import electrosphere.auth.AuthenticationManager; import electrosphere.engine.Globals; diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsDebug.java b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsDebug.java similarity index 96% rename from src/main/java/electrosphere/menu/MenuGeneratorsDebug.java rename to src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsDebug.java index b785b104..87136a76 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsDebug.java +++ b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsDebug.java @@ -1,9 +1,11 @@ -package electrosphere.menu; +package electrosphere.menu.mainmenu; import java.util.LinkedList; import java.util.List; import electrosphere.engine.Globals; +import electrosphere.menu.WindowStrings; +import electrosphere.menu.WindowUtils; import electrosphere.renderer.debug.DebugRendering; import electrosphere.renderer.ui.ClickableElement; import electrosphere.renderer.ui.ContainerElement; diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsMultiplayer.java b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsMultiplayer.java similarity index 98% rename from src/main/java/electrosphere/menu/MenuGeneratorsMultiplayer.java rename to src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsMultiplayer.java index 931c93f9..6601aaff 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsMultiplayer.java +++ b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsMultiplayer.java @@ -1,4 +1,4 @@ -package electrosphere.menu; +package electrosphere.menu.mainmenu; import java.util.LinkedList; import java.util.List; @@ -12,6 +12,8 @@ import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.game.data.creature.type.CreatureType; import electrosphere.game.data.creature.type.visualattribute.AttributeVariant; import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; +import electrosphere.menu.MenuGenerators; +import electrosphere.menu.WindowUtils; import electrosphere.net.parser.net.message.CharacterMessage; import electrosphere.renderer.RenderingEngine; import electrosphere.renderer.actor.Actor; diff --git a/src/main/java/electrosphere/menu/MenuGeneratorsTitleMenu.java b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsTitleMenu.java similarity index 97% rename from src/main/java/electrosphere/menu/MenuGeneratorsTitleMenu.java rename to src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsTitleMenu.java index c79f4953..9bc345f1 100644 --- a/src/main/java/electrosphere/menu/MenuGeneratorsTitleMenu.java +++ b/src/main/java/electrosphere/menu/mainmenu/MenuGeneratorsTitleMenu.java @@ -1,7 +1,9 @@ -package electrosphere.menu; +package electrosphere.menu.mainmenu; import electrosphere.engine.Globals; import electrosphere.engine.loadingthreads.LoadingThread; +import electrosphere.menu.MenuGenerators; +import electrosphere.menu.WindowUtils; import electrosphere.renderer.ui.ClickableElement; import electrosphere.renderer.ui.Element; import electrosphere.renderer.ui.elements.Button; diff --git a/src/main/java/electrosphere/server/datacell/Realm.java b/src/main/java/electrosphere/server/datacell/Realm.java index d1347ec8..0c76b57b 100644 --- a/src/main/java/electrosphere/server/datacell/Realm.java +++ b/src/main/java/electrosphere/server/datacell/Realm.java @@ -6,7 +6,7 @@ import electrosphere.engine.Main; import electrosphere.entity.Entity; import electrosphere.entity.Scene; import electrosphere.entity.types.hitbox.HitboxManager; -import electrosphere.menu.ImGuiWindowMacros; +import electrosphere.menu.debug.ImGuiWindowMacros; import electrosphere.net.parser.net.message.NetworkMessage; import electrosphere.server.datacell.interfaces.DataCellManager; diff --git a/src/main/java/electrosphere/server/saves/Save.java b/src/main/java/electrosphere/server/saves/Save.java index 2ff293ea..a272cd68 100644 --- a/src/main/java/electrosphere/server/saves/Save.java +++ b/src/main/java/electrosphere/server/saves/Save.java @@ -1,8 +1,11 @@ package electrosphere.server.saves; +import java.util.List; + +import electrosphere.entity.Scene; + /** - * - * @author satellite + * Top level save object that stores information about the save */ public class Save { /* @@ -11,4 +14,21 @@ public class Save { we can put them all in here then serialize this instead or smthn */ + + //the version of the game + String versionString; + + //the time the save was created + String timeCreated; + + //The scenes + List scenes; + + /** + * Constructor + */ + public Save(){ + versionString = "0.0.1"; + timeCreated = System.currentTimeMillis() + ""; + } } diff --git a/src/main/java/electrosphere/server/saves/SaveUtils.java b/src/main/java/electrosphere/server/saves/SaveUtils.java index 38ffde1d..0b235881 100644 --- a/src/main/java/electrosphere/server/saves/SaveUtils.java +++ b/src/main/java/electrosphere/server/saves/SaveUtils.java @@ -15,8 +15,7 @@ import electrosphere.server.terrain.manager.ServerTerrainManager; import electrosphere.util.FileUtils; /** - * - * @author satellite + * Utilities for dealing with saves (init, loading, storing, etc) */ public class SaveUtils { @@ -75,12 +74,7 @@ public class SaveUtils { } - - public static boolean overwriteSave(String saveName){ - boolean rVal = false; - return rVal; - } - + @Deprecated public static boolean loadTerrainAndDB(String saveName){ String dirPath = deriveSaveDirectoryPath(saveName); String dbFilePath = FileUtils.sanitizeFilePath(dirPath) + "/central.db"; @@ -89,6 +83,11 @@ public class SaveUtils { return true; } + /** + * Loads a save into the server + * @param saveName The name of the save + * @return true always + */ public static boolean loadSave(String saveName){ String dirPath = deriveSaveDirectoryPath(saveName); String dbFilePath = FileUtils.sanitizeFilePath(dirPath) + "/central.db"; @@ -101,16 +100,30 @@ public class SaveUtils { return true; } + /** + * Gets the list of all saves by name + * @return The list of all saves + */ public static List getSaves(){ return FileUtils.listDirectory("./saves"); } - public static boolean worldHasSave(String saveName){ + /** + * Checks if the save has a world file + * @param saveName The name of the save + * @return true if the world file exists, false otherwise + */ + public static boolean saveHasWorldFile(String saveName){ String dirPath = deriveSaveDirectoryPath(saveName) + "/world.json"; LoggerInterface.loggerEngine.DEBUG("Exists? " + dirPath); return FileUtils.checkFileExists(dirPath); } + /** + * Loads terrain and creates world data object + * @param currentSaveName The save name + * @return true always + */ public static boolean loadTerrainAndCreateWorldData(String currentSaveName){ Globals.serverTerrainManager = new ServerTerrainManager(2000,50,0.0f,0,new OverworldChunkGenerator()); Globals.serverFluidManager = new ServerFluidManager(Globals.serverTerrainManager, 2000, 50, 0.0f, 0, new ArenaFluidGenerator()); @@ -121,7 +134,12 @@ public class SaveUtils { return true; } - public static boolean saveWorldDataToSave(String saveName){ + /** + * Saves world data file + * @param saveName The name of the save + * @return true always + */ + public static boolean saveWorldData(String saveName){ /* Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager); //TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);