Fix singleplayer loading flow
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
9c672af15f
commit
460989eeab
@ -1183,6 +1183,7 @@ Remove explicit garbage collection call
|
||||
Actor panel additional functionality
|
||||
Better style for character creation menu
|
||||
Fix AABB calculation from assimp-loaded models
|
||||
Fix singleplayer launching at all
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -12,7 +12,6 @@ import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
@ -26,7 +25,6 @@ import electrosphere.renderer.ui.elements.Slider;
|
||||
import electrosphere.renderer.ui.elements.StringCarousel;
|
||||
import electrosphere.renderer.ui.elementtypes.Element;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
/**
|
||||
* Panel to customize a character
|
||||
@ -176,7 +174,6 @@ public class CharacterCustomizer {
|
||||
createButtonContainer.setMarginLeft(CONTROL_CONTAINER_MARGIN);
|
||||
createButtonContainer.setMarginRight(CONTROL_CONTAINER_MARGIN);
|
||||
createButtonContainer.addChild(Button.createButton("Create", () -> {
|
||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
|
||||
onConfirm.accept(template);
|
||||
}));
|
||||
|
||||
|
||||
@ -55,12 +55,10 @@ public class MenuGenerators {
|
||||
//need to log client in
|
||||
Globals.clientUsername = "username";
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("password");
|
||||
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
|
||||
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME, saveName, Globals.clientUsername, Globals.clientPassword);
|
||||
Globals.RUN_CLIENT = true;
|
||||
Globals.RUN_SERVER = true;
|
||||
Globals.threadManager.start(serverThread);
|
||||
Globals.threadManager.start(clientThread);
|
||||
} else {
|
||||
SaveUtils.loadSave(saveName.toLowerCase(), false);
|
||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createSaveCreationMenu());
|
||||
|
||||
@ -4,11 +4,13 @@ import electrosphere.client.ui.components.CharacterCustomizer;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
import electrosphere.renderer.ui.elements.Button;
|
||||
import electrosphere.renderer.ui.elements.FormElement;
|
||||
import electrosphere.renderer.ui.elements.StringCarousel;
|
||||
import electrosphere.renderer.ui.elementtypes.Element;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
/**
|
||||
* The menu for character creation
|
||||
@ -64,7 +66,9 @@ public class MenuCharacterCreation {
|
||||
public static Element createCharacterCustomizationMenu(){
|
||||
FormElement rVal = new FormElement();
|
||||
|
||||
rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {}));
|
||||
rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {
|
||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
|
||||
}));
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
import electrosphere.renderer.ui.elements.Button;
|
||||
import electrosphere.renderer.ui.elements.FormElement;
|
||||
import electrosphere.renderer.ui.elements.Label;
|
||||
@ -14,6 +15,7 @@ import electrosphere.renderer.ui.elementtypes.Element;
|
||||
import electrosphere.renderer.ui.elementtypes.ValueElement.ValueChangeEventCallback;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
public class MenuGeneratorsMultiplayer {
|
||||
|
||||
@ -53,7 +55,9 @@ public class MenuGeneratorsMultiplayer {
|
||||
createButton.addChild(createLabel);
|
||||
rVal.addChild(createButton);
|
||||
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {}));
|
||||
WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (CreatureTemplate template) -> {
|
||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
|
||||
}));
|
||||
return false;
|
||||
}});
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ import electrosphere.client.ui.menu.mainmenu.MenuCharacterCreation;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.assetmanager.queue.QueuedModel;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.DrawableUtils;
|
||||
@ -31,10 +30,6 @@ import electrosphere.net.NetUtils;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorTextureMask;
|
||||
import electrosphere.renderer.meshgen.GeometryMeshGen;
|
||||
import electrosphere.renderer.model.Mesh;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.renderer.shader.VisualShader;
|
||||
|
||||
public class ClientLoading {
|
||||
|
||||
@ -56,6 +51,12 @@ public class ClientLoading {
|
||||
* @param params no params
|
||||
*/
|
||||
protected static void loadCharacterServer(Object[] params){
|
||||
if(params.length < 1){
|
||||
throw new Error("Expected 1 params!");
|
||||
}
|
||||
|
||||
boolean useLocalConnection = (boolean)params[0];
|
||||
|
||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING), true);
|
||||
@ -63,7 +64,11 @@ public class ClientLoading {
|
||||
//disable menu input
|
||||
Globals.controlHandler.hintUpdateControlState(ControlHandler.ControlsState.NO_INPUT);
|
||||
//initialize the client thread (client)
|
||||
initClientThread();
|
||||
if(useLocalConnection){
|
||||
LoadingUtils.initLocalConnection(true);
|
||||
} else {
|
||||
ClientLoading.initClientThread();
|
||||
}
|
||||
//while we don't know what races are playable, wait
|
||||
while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){
|
||||
try {
|
||||
@ -108,6 +113,8 @@ public class ClientLoading {
|
||||
initArenaGraphicalEntities();
|
||||
//sets micro and macro sims to ready if they exist
|
||||
setSimulationsToReady();
|
||||
//set simulations to ready if they exist
|
||||
LoadingUtils.setSimulationsToReady();
|
||||
//make loading window disappear
|
||||
Globals.signalSystem.post(SignalType.UI_MODIFICATION, () -> {
|
||||
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_LOADING, false);
|
||||
|
||||
@ -199,8 +199,13 @@ public class LoadingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server simulations to ready
|
||||
*/
|
||||
static void setSimulationsToReady(){
|
||||
if(Globals.microSimulation != null){
|
||||
Globals.microSimulation.setReady(true);
|
||||
}
|
||||
if(Globals.macroSimulation != null){
|
||||
Globals.macroSimulation.setReady(true);
|
||||
}
|
||||
|
||||
@ -1,41 +1,68 @@
|
||||
package electrosphere.engine.loadingthreads;
|
||||
|
||||
import electrosphere.client.ui.menu.MenuGenerators;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.entity.scene.SceneGenerator;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.ui.elements.Window;
|
||||
import electrosphere.server.saves.SaveUtils;
|
||||
|
||||
public class ServerLoading {
|
||||
|
||||
|
||||
protected static void loadMainGameServer(Object[] params){
|
||||
//initialize the terrain manager (server only)
|
||||
// if(Globals.RUN_SERVER){
|
||||
// initServerGameTerrainManager();
|
||||
// }
|
||||
if(params.length < 3){
|
||||
throw new Error("Invalid number of parameters!");
|
||||
}
|
||||
|
||||
String saveName = (String)params[0];
|
||||
String username = (String)params[1];
|
||||
String password = (String)params[2];
|
||||
|
||||
//setup ui for loading
|
||||
Globals.signalSystem.post(SignalType.UI_MODIFICATION, ()->{
|
||||
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
|
||||
//show loading
|
||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||
loadingWindow.setVisible(true);
|
||||
});
|
||||
|
||||
//load the server
|
||||
if(!SaveUtils.getSaves().contains(saveName)){
|
||||
//
|
||||
//the juicy server GENERATION part
|
||||
//
|
||||
//init save structure
|
||||
SaveUtils.createOrOverwriteSave(saveName, SceneGenerator.createProceduralSceneFile(saveName));
|
||||
}
|
||||
//load just-created save
|
||||
SaveUtils.loadSave(saveName, false);
|
||||
//initialize the "virtual" objects simulation
|
||||
LoadingUtils.initMacroSimulation();
|
||||
|
||||
|
||||
//TODO: Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,randomDampener,0);
|
||||
// Globals.serverTerrainManager = new ServerTerrainManager(2000,50,0.0f,0, new OverworldChunkGenerator());
|
||||
// SaveUtils.loadSave(Globals.currentSaveName);
|
||||
// LoadingUtils.initTerrainDataCellManager();
|
||||
//TODO: set spawnpoint
|
||||
//TODO: Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||
//TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||
// Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||
// Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT);
|
||||
//init authentication
|
||||
LoadingUtils.initAuthenticationManager(false);
|
||||
//initialize the server thread (server only)
|
||||
LoadingUtils.initServerThread();
|
||||
//initialize the "virtual" objects simulation
|
||||
LoadingUtils.initMacroSimulation();
|
||||
//initialize the local connection
|
||||
Globals.clientUsername = username;
|
||||
Globals.clientPassword = password;
|
||||
//initialize the "real" objects simulation
|
||||
LoadingUtils.initMicroSimulation();
|
||||
//init game specific stuff (ie different skybox colors)
|
||||
LoadingUtils.initGameGraphicalEntities();
|
||||
//set simulations to ready if they exist
|
||||
LoadingUtils.setSimulationsToReady();
|
||||
//log
|
||||
LoggerInterface.loggerEngine.INFO("[Server]Finished loading main world");
|
||||
|
||||
//load client side
|
||||
Object[] subParams = new Object[]{
|
||||
true
|
||||
};
|
||||
ClientLoading.loadCharacterServer(subParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user