groundwork for headless server
This commit is contained in:
parent
c94ad0911c
commit
8ec6388477
@ -229,12 +229,16 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
|
|
||||||
case LOAD_ARENA:
|
case LOAD_ARENA:
|
||||||
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
if(Globals.RUN_CLIENT){
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
||||||
loadingWindow.setVisible(true);
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||||
|
loadingWindow.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
//disable menu input
|
//disable menu input
|
||||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.NO_INPUT);
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.NO_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
//init server arena terrain manager separately
|
//init server arena terrain manager separately
|
||||||
initServerArenaTerrainManager();
|
initServerArenaTerrainManager();
|
||||||
@ -270,10 +274,14 @@ public class LoadingThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//init client terrain manager
|
//init client terrain manager
|
||||||
initClientTerrainManager();
|
if(Globals.RUN_CLIENT){
|
||||||
|
initClientTerrainManager();
|
||||||
|
}
|
||||||
|
|
||||||
//initialize the cell manager (client)
|
//initialize the cell manager (client)
|
||||||
initDrawCellManager();
|
if(Globals.RUN_CLIENT){
|
||||||
|
initDrawCellManager();
|
||||||
|
}
|
||||||
|
|
||||||
//initialize the basic graphical entities of the world (skybox, camera)
|
//initialize the basic graphical entities of the world (skybox, camera)
|
||||||
initWorldBaseGraphicalEntities();
|
initWorldBaseGraphicalEntities();
|
||||||
@ -292,22 +300,26 @@ public class LoadingThread extends Thread {
|
|||||||
setSimulationsToReady();
|
setSimulationsToReady();
|
||||||
|
|
||||||
//hide cursor
|
//hide cursor
|
||||||
Globals.controlHandler.hideMouse();
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.controlHandler.hideMouse();
|
||||||
loadingWindow.setVisible(false);
|
|
||||||
|
loadingWindow.setVisible(false);
|
||||||
Globals.controlHandler.setShouldRecapture(true);
|
|
||||||
|
Globals.controlHandler.setShouldRecapture(true);
|
||||||
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
||||||
Globals.RENDER_FLAG_RENDER_UI = true;
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
||||||
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
Globals.RENDER_FLAG_RENDER_UI = true;
|
||||||
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
||||||
|
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
||||||
|
}
|
||||||
|
|
||||||
LoggerInterface.loggerEngine.INFO("Finished loading");
|
LoggerInterface.loggerEngine.INFO("Finished loading");
|
||||||
|
|
||||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -123,9 +123,13 @@ public class Main {
|
|||||||
|
|
||||||
//load user settings
|
//load user settings
|
||||||
UserSettings.loadUserSettings();
|
UserSettings.loadUserSettings();
|
||||||
|
|
||||||
|
// Globals.RUN_CLIENT = false;
|
||||||
|
|
||||||
//controls
|
//controls
|
||||||
initControlHandler();
|
if(Globals.RUN_CLIENT){
|
||||||
|
initControlHandler();
|
||||||
|
}
|
||||||
|
|
||||||
//init global variables
|
//init global variables
|
||||||
Globals.initGlobals();
|
Globals.initGlobals();
|
||||||
@ -174,8 +178,10 @@ public class Main {
|
|||||||
// TerrainViewer.runViewer();
|
// TerrainViewer.runViewer();
|
||||||
|
|
||||||
//create the drawing context
|
//create the drawing context
|
||||||
Globals.renderingEngine = new RenderingEngine();
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.renderingEngine.createOpenglContext();
|
Globals.renderingEngine = new RenderingEngine();
|
||||||
|
Globals.renderingEngine.createOpenglContext();
|
||||||
|
}
|
||||||
|
|
||||||
//uncomment to test loading a model into engine
|
//uncomment to test loading a model into engine
|
||||||
// if(1==1){
|
// if(1==1){
|
||||||
@ -199,22 +205,32 @@ public class Main {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//create the audio context
|
//create the audio context
|
||||||
Globals.audioEngine = new AudioEngine();
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.audioEngine.init();
|
Globals.audioEngine = new AudioEngine();
|
||||||
Globals.audioEngine.setGain(0.1f);
|
Globals.audioEngine.init();
|
||||||
|
Globals.audioEngine.setGain(0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
//init default resources
|
//init default resources
|
||||||
Globals.initDefaultGraphicalResources();
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.initDefaultAudioResources();
|
Globals.initDefaultGraphicalResources();
|
||||||
|
Globals.initDefaultAudioResources();
|
||||||
|
}
|
||||||
|
|
||||||
//fire off a loading thread for the title menus/screen
|
//fire off a loading thread for the title menus/screen
|
||||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_TITLE_MENU);
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_TITLE_MENU);
|
||||||
|
} else {
|
||||||
|
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
||||||
|
}
|
||||||
Globals.loadingThread.start();
|
Globals.loadingThread.start();
|
||||||
|
|
||||||
//recapture the screen for rendering
|
//recapture the screen for rendering
|
||||||
LoggerInterface.loggerStartup.INFO("Recapture screen");
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.controlHandler.setShouldRecapture(true);
|
LoggerInterface.loggerStartup.INFO("Recapture screen");
|
||||||
|
Globals.controlHandler.setShouldRecapture(true);
|
||||||
|
}
|
||||||
// RenderUtils.recaptureScreen();
|
// RenderUtils.recaptureScreen();
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -237,7 +253,9 @@ public class Main {
|
|||||||
///
|
///
|
||||||
/// A S S E T M A N A G E R S T U F F
|
/// A S S E T M A N A G E R S T U F F
|
||||||
///
|
///
|
||||||
Globals.assetManager.loadAssetsInQueue();
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.assetManager.loadAssetsInQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -256,19 +274,25 @@ public class Main {
|
|||||||
/// I N P U T C O N T R O L S
|
/// I N P U T C O N T R O L S
|
||||||
///
|
///
|
||||||
//Poll controls
|
//Poll controls
|
||||||
Globals.controlHandler.pollControls();
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.controlHandler.recaptureIfNecessary();
|
Globals.controlHandler.pollControls();
|
||||||
|
Globals.controlHandler.recaptureIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// C L I E N T S I M U L A T I O N S T U F F
|
/// C L I E N T S I M U L A T I O N S T U F F
|
||||||
///
|
///
|
||||||
ClientFunctions.runBeforeSimulationFunctions();
|
if(Globals.RUN_CLIENT){
|
||||||
|
ClientFunctions.runBeforeSimulationFunctions();
|
||||||
|
}
|
||||||
if(Globals.microSimulation != null && Globals.microSimulation.isReady()){
|
if(Globals.microSimulation != null && Globals.microSimulation.isReady()){
|
||||||
Globals.microSimulation.simulate();
|
Globals.microSimulation.simulate();
|
||||||
}
|
}
|
||||||
ClientFunctions.runClientFunctions();
|
if(Globals.RUN_CLIENT){
|
||||||
|
ClientFunctions.runClientFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// M A C R O S I M U L A T I O N S T U F F
|
/// M A C R O S I M U L A T I O N S T U F F
|
||||||
@ -278,11 +302,11 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.renderingEngine.drawScreen();
|
||||||
|
}
|
||||||
|
|
||||||
Globals.renderingEngine.drawScreen();
|
if(Globals.ENGINE_SHUTDOWN_FLAG || (Globals.RUN_CLIENT && glfwWindowShouldClose(Globals.window))){
|
||||||
|
|
||||||
|
|
||||||
if(glfwWindowShouldClose(Globals.window) || Globals.ENGINE_SHUTDOWN_FLAG){
|
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +323,9 @@ public class Main {
|
|||||||
// S H U T D O W N
|
// S H U T D O W N
|
||||||
//
|
//
|
||||||
//Terminate the program.
|
//Terminate the program.
|
||||||
glfwTerminate();
|
if(Globals.RUN_CLIENT){
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
//used to signal threads to stop
|
//used to signal threads to stop
|
||||||
running = false;
|
running = false;
|
||||||
if(Globals.server != null){
|
if(Globals.server != null){
|
||||||
@ -307,7 +333,9 @@ public class Main {
|
|||||||
Globals.serverThread.interrupt();
|
Globals.serverThread.interrupt();
|
||||||
}
|
}
|
||||||
//shut down audio engine
|
//shut down audio engine
|
||||||
Globals.audioEngine.shutdown();
|
if(Globals.RUN_CLIENT){
|
||||||
|
Globals.audioEngine.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user