From d5af9b1ad428c99ccb414ba79f009d91f5339a86 Mon Sep 17 00:00:00 2001 From: austin Date: Mon, 27 Jun 2022 17:38:16 -0400 Subject: [PATCH] Add user setting for fullscreen --- assets/Config/settings.json | 1 + .../electrosphere/engine/LoadingThread.java | 75 ++++--------------- .../game/config/UserSettings.java | 10 +++ .../game/server/saves/SaveUtils.java | 8 +- .../renderer/RenderingEngine.java | 11 ++- 5 files changed, 37 insertions(+), 68 deletions(-) diff --git a/assets/Config/settings.json b/assets/Config/settings.json index e6dfc60a..7dab4193 100644 --- a/assets/Config/settings.json +++ b/assets/Config/settings.json @@ -4,6 +4,7 @@ "displayWidth" : 1920, "displayHeight" : 1080, + "displayFullscreen" : false, "graphicsFOV" : 100.0, diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index 1868bb51..fae3c994 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -1,43 +1,32 @@ package electrosphere.engine; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; + +import org.joml.Quaternionf; +import org.joml.Vector2i; +import org.joml.Vector3d; +import org.joml.Vector3f; + import electrosphere.auth.AuthenticationManager; -import electrosphere.collision.dispatch.CollisionObject; import electrosphere.controls.ControlHandler; import electrosphere.entity.Entity; -import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; -import electrosphere.entity.state.BehaviorTree; -import electrosphere.entity.state.collidable.Impulse; import electrosphere.entity.state.movement.ApplyRotationTree; -import electrosphere.game.collision.CollisionEngine; -import electrosphere.entity.types.creature.CreatureUtils; -import electrosphere.entity.types.debug.DebugVisualizerUtils; +import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.object.ObjectUtils; import electrosphere.game.client.cells.DrawCellManager; -import electrosphere.game.client.player.ClientPlayerData; +import electrosphere.game.client.targeting.crosshair.Crosshair; import electrosphere.game.client.terrain.manager.ClientTerrainManager; -import electrosphere.game.client.world.ClientWorldData; import electrosphere.game.collision.CommonWorldData; -import electrosphere.game.simulation.MacroSimulation; -import electrosphere.game.server.terrain.manager.ServerTerrainManager; -import electrosphere.game.server.world.ServerWorldData; -import electrosphere.entity.types.attach.AttachUtils; -import electrosphere.entity.types.camera.CameraEntityUtils; -import electrosphere.entity.types.particle.ParticleUtils; -import electrosphere.entity.types.collision.CollisionObjUtils; -import electrosphere.entity.types.foliage.FoliageUtils; -import electrosphere.entity.types.structure.StructureUtils; -import electrosphere.game.collision.PhysicsUtils; -import electrosphere.game.collision.collidable.Collidable; -import electrosphere.game.server.ai.creature.MindlessAttacker; -import electrosphere.game.server.effects.ParticleEffects; +import electrosphere.game.server.datacell.DataCellManager; import electrosphere.game.server.saves.SaveUtils; -import electrosphere.game.server.terrain.models.TerrainModification; +import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.town.Town; import electrosphere.game.server.world.MacroData; -import electrosphere.game.server.datacell.DataCellManager; -import electrosphere.game.server.db.DatabaseUtils; +import electrosphere.game.server.world.ServerWorldData; +import electrosphere.game.simulation.MacroSimulation; import electrosphere.game.simulation.MicroSimulation; import electrosphere.logger.LoggerInterface; import electrosphere.main.Globals; @@ -48,42 +37,8 @@ import electrosphere.menu.WindowUtils; import electrosphere.net.NetUtils; import electrosphere.net.client.ClientNetworking; import electrosphere.net.server.Server; -import electrosphere.renderer.Mesh; -import electrosphere.renderer.Model; -import electrosphere.renderer.ModelUtils; -import electrosphere.renderer.RenderUtils; -import electrosphere.renderer.RenderingEngine; -import electrosphere.renderer.actor.Actor; -import electrosphere.renderer.actor.ActorTextureMask; -import electrosphere.renderer.actor.ActorUtils; -import electrosphere.renderer.texture.Texture; -import electrosphere.engine.assetmanager.AssetDataStrings; -import electrosphere.game.client.targeting.crosshair.Crosshair; -import electrosphere.game.server.ai.creature.OpportunisticAttacker; -import electrosphere.game.server.pathfinding.NavMeshPathfinder; -import electrosphere.game.server.pathfinding.navmesh.NavCube; -import electrosphere.game.server.pathfinding.navmesh.NavMesh; -import electrosphere.game.server.unit.UnitUtils; -import electrosphere.renderer.ui.DrawableElement; -import electrosphere.renderer.ui.WidgetUtils; import electrosphere.renderer.ui.Window; import electrosphere.util.FileUtils; -import electrosphere.util.Utilities; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.joml.Quaternionf; -import org.joml.Vector2i; -import org.joml.Vector3d; -import org.joml.Vector3f; /** * @@ -190,7 +145,7 @@ public class LoadingThread extends Thread { //init data cell manager initDataCellManager(); //for testing purposes - FileUtils.recursivelyDelete("/home/satellite/temp/saves/arena"); + FileUtils.recursivelyDelete("/Users/satellite/temp/saves/arena"); //init database connection SaveUtils.initSave("arena"); //connect to database diff --git a/src/main/java/electrosphere/game/config/UserSettings.java b/src/main/java/electrosphere/game/config/UserSettings.java index 94fbf29f..13781e6e 100644 --- a/src/main/java/electrosphere/game/config/UserSettings.java +++ b/src/main/java/electrosphere/game/config/UserSettings.java @@ -23,6 +23,7 @@ public class UserSettings { // int displayWidth; int displayHeight; + boolean displayFullscreen; // @@ -100,6 +101,10 @@ public class UserSettings { public boolean graphicsDebugDrawNavmesh() { return graphicsDebugDrawNavmesh; } + + public boolean displayFullscreen(){ + return displayFullscreen; + } public void setGraphicsDebugDrawCollisionSpheres(boolean draw){ @@ -121,6 +126,10 @@ public class UserSettings { public void setGraphicsViewRange(float range){ graphicsViewRange = range; } + + public void setDisplayFullscreen(boolean fullscreen){ + this.displayFullscreen = fullscreen; + } @@ -138,6 +147,7 @@ public class UserSettings { //display settings rVal.displayHeight = 1080; rVal.displayWidth = 1920; + rVal.displayFullscreen = true; //gameplay settings rVal.gameplayGenerateWorld = true; diff --git a/src/main/java/electrosphere/game/server/saves/SaveUtils.java b/src/main/java/electrosphere/game/server/saves/SaveUtils.java index 0a638282..81dc6ed2 100644 --- a/src/main/java/electrosphere/game/server/saves/SaveUtils.java +++ b/src/main/java/electrosphere/game/server/saves/SaveUtils.java @@ -1,14 +1,14 @@ package electrosphere.game.server.saves; +import java.util.List; + +import electrosphere.game.server.datacell.DataCellManager; import electrosphere.game.server.db.DatabaseUtils; import electrosphere.game.server.terrain.manager.ServerTerrainManager; import electrosphere.game.server.world.ServerWorldData; import electrosphere.logger.LoggerInterface; -import electrosphere.game.server.datacell.DataCellManager; import electrosphere.main.Globals; import electrosphere.util.FileUtils; -import java.util.LinkedList; -import java.util.List; /** * @@ -17,7 +17,7 @@ import java.util.List; public class SaveUtils { static String deriveSaveDirectoryPath(String saveName){ - String path = "/home/satellite/temp/saves/" + saveName; + String path = "/Users/satellite/temp/saves/" + saveName; return path; } diff --git a/src/main/java/electrosphere/renderer/RenderingEngine.java b/src/main/java/electrosphere/renderer/RenderingEngine.java index 8bd62cd8..0582fee9 100644 --- a/src/main/java/electrosphere/renderer/RenderingEngine.java +++ b/src/main/java/electrosphere/renderer/RenderingEngine.java @@ -219,10 +219,13 @@ public class RenderingEngine { // glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); Allows you to make the background transparent // glfwWindowHint(GLFW_OPACITY, 23); //Creates the window reference object - // Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", NULL, NULL); - //below line is for fullscreen - Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", glfwGetPrimaryMonitor(), NULL); - //Errors for failure to create window (IE: No GUI mode on linux ?) + if(Globals.userSettings.displayFullscreen()){ + //below line is for fullscreen + Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", glfwGetPrimaryMonitor(), NULL); + } else { + Globals.window = glfwCreateWindow(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, "ORPG", NULL, NULL); + } + // Errors for failure to create window (IE: No GUI mode on linux ?) if (Globals.window == NULL) { LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure")); glfwTerminate();