netconfig file support
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
67b8032588
commit
b37ee6c45f
@ -5,8 +5,7 @@
|
||||
+ when you grab the sword, a tutorial popup appears to tell you how to use in
|
||||
+ on clearing the tutorial, continue the game when the sword is equipped, create another popup to teach sword controls. it pauses the game
|
||||
+ when popup is accepted, spawn an enemy with an effect
|
||||
review combat code (lifestate, damage calculation, etc)
|
||||
Maybe a fade-out before deleting entity on death?
|
||||
Script engine ability to spawn entities
|
||||
|
||||
+ rearchitecture
|
||||
Netconf file that pre-populates address, ip, username, password
|
||||
|
||||
@ -598,6 +598,7 @@ Fix physics freakout for vertically aligned entities
|
||||
Fix AI components not resetting on turning off ai manager
|
||||
Fix broken rendering pipeline when creating new level
|
||||
Fix ui alignment for item panels in inventory menus (ie dont have to place in corner)
|
||||
Netconfig file support
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -44,6 +44,7 @@ import electrosphere.game.server.world.MacroData;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.config.NetConfig;
|
||||
import electrosphere.net.monitor.NetMonitor;
|
||||
import electrosphere.net.server.Server;
|
||||
import electrosphere.net.server.player.Player;
|
||||
@ -141,6 +142,7 @@ public class Globals {
|
||||
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
|
||||
public static boolean RUN_AUDIO = true;
|
||||
public static int clientCharacterID;
|
||||
public static NetConfig netConfig = null;
|
||||
|
||||
//
|
||||
//Server manager thing
|
||||
@ -444,6 +446,7 @@ public class Globals {
|
||||
//game config
|
||||
gameConfigDefault = electrosphere.game.data.Config.loadDefaultConfig();
|
||||
gameConfigCurrent = gameConfigDefault;
|
||||
NetConfig.readNetConfig();
|
||||
|
||||
//
|
||||
//Values that depend on the loaded config
|
||||
|
||||
@ -229,7 +229,11 @@ public class MenuGenerators {
|
||||
|
||||
//text entry (address)
|
||||
TextInput addressInput = new TextInput(100,screenTop + 125,1.0f);
|
||||
addressInput.setText(NetUtils.getAddress());
|
||||
if(Globals.netConfig != null && Globals.netConfig.getAddress() != null){
|
||||
addressInput.setText(Globals.netConfig.getAddress());
|
||||
} else {
|
||||
addressInput.setText(NetUtils.getAddress());
|
||||
}
|
||||
rVal.addChild(addressInput);
|
||||
|
||||
//label (port)
|
||||
@ -239,7 +243,11 @@ public class MenuGenerators {
|
||||
|
||||
//text entry (port)
|
||||
TextInput portInput = new TextInput(100,screenTop + 275,1.0f);
|
||||
portInput.setText(NetUtils.getPort() + "");
|
||||
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
|
||||
portInput.setText(Globals.netConfig.getPort());
|
||||
} else {
|
||||
portInput.setText(NetUtils.getPort() + "");
|
||||
}
|
||||
rVal.addChild(portInput);
|
||||
|
||||
//label (address)
|
||||
@ -249,7 +257,11 @@ public class MenuGenerators {
|
||||
|
||||
//text entry (address)
|
||||
TextInput usernameInput = new TextInput(100,screenTop + 425,1.0f);
|
||||
usernameInput.setText("");
|
||||
if(Globals.netConfig != null && Globals.netConfig.getUsername() != null){
|
||||
usernameInput.setText(Globals.netConfig.getUsername());
|
||||
} else {
|
||||
usernameInput.setText("");
|
||||
}
|
||||
rVal.addChild(usernameInput);
|
||||
|
||||
//label (port)
|
||||
@ -259,7 +271,11 @@ public class MenuGenerators {
|
||||
|
||||
//text entry (port)
|
||||
TextInput passwordInput = new TextInput(100,screenTop + 575,1.0f);
|
||||
passwordInput.setText("");
|
||||
if(Globals.netConfig != null && Globals.netConfig.getUsername() != null){
|
||||
passwordInput.setText(Globals.netConfig.getPassword());
|
||||
} else {
|
||||
passwordInput.setText("");
|
||||
}
|
||||
rVal.addChild(passwordInput);
|
||||
|
||||
//button (connect)
|
||||
|
||||
84
src/main/java/electrosphere/net/config/NetConfig.java
Normal file
84
src/main/java/electrosphere/net/config/NetConfig.java
Normal file
@ -0,0 +1,84 @@
|
||||
package electrosphere.net.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
/**
|
||||
* A file that can be included in the root of the engine directory that
|
||||
* will preload inputs for the join game page
|
||||
*/
|
||||
public class NetConfig {
|
||||
|
||||
/**
|
||||
* The address to connect to
|
||||
*/
|
||||
String address;
|
||||
|
||||
/**
|
||||
* The port to use
|
||||
*/
|
||||
String port;
|
||||
|
||||
/**
|
||||
* The username to use
|
||||
*/
|
||||
String username;
|
||||
|
||||
/**
|
||||
* The password to use
|
||||
*/
|
||||
String password;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the address to connect to
|
||||
* @return The address
|
||||
*/
|
||||
public String getAddress(){
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the port to connect to
|
||||
* @return The port
|
||||
*/
|
||||
public String getPort(){
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username to use
|
||||
* @return The username
|
||||
*/
|
||||
public String getUsername(){
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the password to use
|
||||
* @return The password
|
||||
*/
|
||||
public String getPassword(){
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the net config file
|
||||
*/
|
||||
public static void readNetConfig(){
|
||||
File file = new File("./netconfig.json");
|
||||
if(file.exists()){
|
||||
try {
|
||||
Globals.netConfig = Utilities.deserialize(Files.readString(file.toPath()), NetConfig.class);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,43 +1,22 @@
|
||||
package electrosphere.util;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.model.Material;
|
||||
import electrosphere.renderer.model.Mesh;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.renderer.shader.ShaderProgram;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
import electrosphere.renderer.texture.TextureMap;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.joml.Matrix4d;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.assimp.AIMatrix4x4;
|
||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||
import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author awhoove
|
||||
* Generic utilities
|
||||
*/
|
||||
public class Utilities {
|
||||
|
||||
@ -171,10 +150,22 @@ public class Utilities {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes an object to json
|
||||
* @param object The object
|
||||
* @return The corresponding json
|
||||
*/
|
||||
public static String stringify(Object object){
|
||||
return gson.toJson(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an object from json
|
||||
* @param <T> The class of the object
|
||||
* @param object The raw json string
|
||||
* @param className The class to deserialize to
|
||||
* @return The object
|
||||
*/
|
||||
public static <T>T deserialize(String object, Class<T> className){
|
||||
return gson.fromJson(object, className);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user