working on threading for char creation
This commit is contained in:
parent
0bd0c00f27
commit
c7760d5d7b
@ -86,6 +86,8 @@ public class LoadingThread extends Thread {
|
|||||||
public static final int LOAD_TITLE_MENU = 0;
|
public static final int LOAD_TITLE_MENU = 0;
|
||||||
public static final int LOAD_MAIN_GAME = 1;
|
public static final int LOAD_MAIN_GAME = 1;
|
||||||
public static final int LOAD_ARENA = 2;
|
public static final int LOAD_ARENA = 2;
|
||||||
|
public static final int LOAD_CHARACTER_SERVER = 3;
|
||||||
|
public static final int LOAD_CLIENT_WORLD = 4;
|
||||||
|
|
||||||
int threadType;
|
int threadType;
|
||||||
|
|
||||||
@ -124,100 +126,42 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
|
|
||||||
case LOAD_MAIN_GAME:
|
case LOAD_MAIN_GAME:
|
||||||
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
|
||||||
loadingWindow.setVisible(true);
|
|
||||||
|
|
||||||
//disable menu input
|
|
||||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.NO_INPUT);
|
|
||||||
|
|
||||||
//initialize the terrain manager (server only)
|
//initialize the terrain manager (server only)
|
||||||
// if(Globals.RUN_SERVER){
|
// if(Globals.RUN_SERVER){
|
||||||
// initServerGameTerrainManager();
|
// initServerGameTerrainManager();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(Globals.RUN_SERVER){
|
//TODO: Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,randomDampener,0);
|
||||||
//TODO: Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,randomDampener,0);
|
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
||||||
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
SaveUtils.loadSave(Globals.currentSaveName);
|
||||||
SaveUtils.loadSave(Globals.currentSaveName);
|
Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||||
Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
//TODO: set spawnpoint
|
||||||
//TODO: set spawnpoint
|
//TODO: Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||||
//TODO: Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
//TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||||
//TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
|
||||||
// Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
// Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||||
// Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
// Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||||
}
|
|
||||||
|
|
||||||
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT);
|
LoggerInterface.loggerEngine.INFO("run server: " + Globals.RUN_SERVER + " run client: " + Globals.RUN_CLIENT);
|
||||||
|
|
||||||
//init the data of the world
|
//init the data of the world
|
||||||
if(Globals.RUN_SERVER){
|
|
||||||
// initServerGameWorldData();
|
// initServerGameWorldData();
|
||||||
initDataCellManager();
|
initDataCellManager();
|
||||||
}
|
//init authentication
|
||||||
|
initAuthenticationManager();
|
||||||
//initialize the server thread (server only)
|
//initialize the server thread (server only)
|
||||||
if(Globals.RUN_SERVER){
|
initServerThread();
|
||||||
initServerThread();
|
|
||||||
initAuthenticationManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
//initialize the "virtual" objects simulation
|
//initialize the "virtual" objects simulation
|
||||||
if(Globals.RUN_SERVER){
|
initMacroSimulation();
|
||||||
initMacroSimulation();
|
|
||||||
}
|
|
||||||
|
|
||||||
//initialize the "real" objects simulation
|
//initialize the "real" objects simulation
|
||||||
initMicroSimulation();
|
initMicroSimulation();
|
||||||
|
|
||||||
//initialize the client thread (client)
|
|
||||||
if(Globals.RUN_CLIENT){
|
|
||||||
initClientThread();
|
|
||||||
stallForClientPlayerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
//init client terrain manager
|
|
||||||
initClientTerrainManager();
|
|
||||||
|
|
||||||
//collision engine
|
//collision engine
|
||||||
initCommonWorldData(Globals.RUN_SERVER);
|
initCommonWorldData(Globals.RUN_SERVER);
|
||||||
|
|
||||||
//initialize the cell manager (client)
|
|
||||||
initDrawCellManager();
|
|
||||||
|
|
||||||
//initialize the basic graphical entities of the world (skybox, camera)
|
|
||||||
initWorldBaseGraphicalEntities();
|
|
||||||
//init game specific stuff (ie different skybox colors)
|
//init game specific stuff (ie different skybox colors)
|
||||||
initGameGraphicalEntities();
|
initGameGraphicalEntities();
|
||||||
|
//set simulations to ready if they exist
|
||||||
|
|
||||||
// while(Globals.clientConnection.getClientProtocol().isLoading()){
|
|
||||||
// try {
|
|
||||||
// TimeUnit.MILLISECONDS.sleep(5);
|
|
||||||
// } catch (InterruptedException ex) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
setSimulationsToReady();
|
setSimulationsToReady();
|
||||||
|
//log
|
||||||
//hide cursor
|
LoggerInterface.loggerEngine.INFO("[Server]Finished loading");
|
||||||
Globals.controlHandler.hideMouse();
|
|
||||||
|
|
||||||
|
|
||||||
loadingWindow.setVisible(false);
|
|
||||||
|
|
||||||
Globals.controlHandler.setShouldRecapture(true);
|
|
||||||
|
|
||||||
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
|
||||||
Globals.RENDER_FLAG_RENDER_UI = true;
|
|
||||||
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
|
||||||
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
|
||||||
|
|
||||||
LoggerInterface.loggerEngine.INFO("Finished loading");
|
|
||||||
|
|
||||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -229,97 +173,101 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
|
|
||||||
case LOAD_ARENA:
|
case LOAD_ARENA:
|
||||||
if(Globals.RUN_CLIENT){
|
|
||||||
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
|
||||||
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
|
||||||
loadingWindow.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//disable menu 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();
|
||||||
|
|
||||||
//init the data of the world
|
//init the data of the world
|
||||||
initServerArenaWorldData();
|
initServerArenaWorldData();
|
||||||
|
|
||||||
//init data cell manager
|
//init data cell manager
|
||||||
if(Globals.RUN_SERVER){
|
initDataCellManager();
|
||||||
initDataCellManager();
|
//init authentication
|
||||||
}
|
initAuthenticationManager();
|
||||||
|
|
||||||
//initialize the server thread (server only)
|
//initialize the server thread (server only)
|
||||||
if(Globals.RUN_SERVER){
|
initServerThread();
|
||||||
initServerThread();
|
|
||||||
initAuthenticationManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
//collision engine
|
//collision engine
|
||||||
initCommonWorldData(Globals.RUN_SERVER);
|
initCommonWorldData(Globals.RUN_SERVER);
|
||||||
|
|
||||||
//initialize the "virtual" objects simulation
|
//initialize the "virtual" objects simulation
|
||||||
//not really relevant in arena mode
|
//not really relevant in arena mode
|
||||||
// initMacroSimulation();
|
// initMacroSimulation();
|
||||||
|
|
||||||
//initialize the "real" objects simulation
|
//initialize the "real" objects simulation
|
||||||
initMicroSimulation();
|
initMicroSimulation();
|
||||||
|
//init arena specific stuff (ie different skybox colors)
|
||||||
|
initArenaGraphicalEntities();
|
||||||
|
//create arena entities
|
||||||
|
creatingRandomEntities();
|
||||||
|
//set simulations to ready if they exist
|
||||||
|
setSimulationsToReady();
|
||||||
|
LoggerInterface.loggerEngine.INFO("[Server]Finished loading");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LOAD_CHARACTER_SERVER:
|
||||||
|
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||||
|
loadingWindow.setVisible(true);
|
||||||
|
//disable menu input
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.NO_INPUT);
|
||||||
//initialize the client thread (client)
|
//initialize the client thread (client)
|
||||||
if(Globals.RUN_CLIENT){
|
initClientThread();
|
||||||
initClientThread();
|
//init character creation window
|
||||||
stallForClientPlayerData();
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||||
}
|
//make loading dialog disappear
|
||||||
|
loadingWindow.setVisible(false);
|
||||||
|
//make character creation window visible
|
||||||
|
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), true);
|
||||||
|
//recapture window
|
||||||
|
Globals.controlHandler.setShouldRecapture(true);
|
||||||
|
//set rendering flags
|
||||||
|
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
||||||
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
||||||
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
||||||
|
Globals.RENDER_FLAG_RENDER_UI = true;
|
||||||
|
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
||||||
|
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
||||||
|
//log
|
||||||
|
LoggerInterface.loggerEngine.INFO("[Client]Finished loading");
|
||||||
|
//set controls state
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LOAD_CLIENT_WORLD:
|
||||||
|
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
|
||||||
|
loadingWindow.setVisible(true);
|
||||||
|
//disable menu input
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.NO_INPUT);
|
||||||
|
//collision engine
|
||||||
|
if(!Globals.RUN_SERVER){
|
||||||
|
initCommonWorldData(Globals.RUN_SERVER);
|
||||||
|
}
|
||||||
|
//initialize the "real" objects simulation
|
||||||
|
initMicroSimulation();
|
||||||
//init client terrain manager
|
//init client terrain manager
|
||||||
if(Globals.RUN_CLIENT){
|
initClientTerrainManager();
|
||||||
initClientTerrainManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
//initialize the cell manager (client)
|
//initialize the cell manager (client)
|
||||||
if(Globals.RUN_CLIENT){
|
initDrawCellManager();
|
||||||
initDrawCellManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
//initialize the basic graphical entities of the world (skybox, camera)
|
//initialize the basic graphical entities of the world (skybox, camera)
|
||||||
initWorldBaseGraphicalEntities();
|
initWorldBaseGraphicalEntities();
|
||||||
//init arena specific stuff (ie different skybox colors)
|
//init arena specific stuff (ie different skybox colors)
|
||||||
initArenaGraphicalEntities();
|
initArenaGraphicalEntities();
|
||||||
|
//sets micro and macro sims to ready if they exist
|
||||||
creatingRandomEntities();
|
if(!Globals.RUN_SERVER){
|
||||||
|
setSimulationsToReady();
|
||||||
// while(Globals.clientConnection.getClientProtocol().isLoading()){
|
}
|
||||||
// try {
|
|
||||||
// TimeUnit.MILLISECONDS.sleep(5);
|
|
||||||
// } catch (InterruptedException ex) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
setSimulationsToReady();
|
|
||||||
|
|
||||||
//hide cursor
|
//hide cursor
|
||||||
if(Globals.RUN_CLIENT){
|
Globals.controlHandler.hideMouse();
|
||||||
Globals.controlHandler.hideMouse();
|
//make loading window disappear
|
||||||
|
loadingWindow.setVisible(false);
|
||||||
loadingWindow.setVisible(false);
|
//recapture screen
|
||||||
|
Globals.controlHandler.setShouldRecapture(true);
|
||||||
Globals.controlHandler.setShouldRecapture(true);
|
//set rendering flags to main game mode
|
||||||
|
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
||||||
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = true;
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = true;
|
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
||||||
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = true;
|
Globals.RENDER_FLAG_RENDER_UI = true;
|
||||||
Globals.RENDER_FLAG_RENDER_UI = true;
|
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
||||||
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = false;
|
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
||||||
Globals.RENDER_FLAG_RENDER_WHITE_BACKGROUND = false;
|
LoggerInterface.loggerEngine.INFO("[Client]Finished loading");
|
||||||
}
|
//set controls state
|
||||||
|
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
||||||
LoggerInterface.loggerEngine.INFO("Finished loading");
|
|
||||||
|
|
||||||
if(Globals.RUN_CLIENT){
|
|
||||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -328,7 +276,6 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
lock.release();
|
lock.release();
|
||||||
}
|
}
|
||||||
@ -415,17 +362,19 @@ public class LoadingThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void initCommonWorldData(boolean FLAG_INIT_SERVER){
|
static void initCommonWorldData(boolean FLAG_INIT_SERVER){
|
||||||
if(FLAG_INIT_SERVER){
|
if(Globals.commonWorldData == null){
|
||||||
Globals.commonWorldData = new CommonWorldData(Globals.serverWorldData, Globals.serverTerrainManager);
|
if(FLAG_INIT_SERVER){
|
||||||
if(Globals.macroSimulation != null){
|
Globals.commonWorldData = new CommonWorldData(Globals.serverWorldData, Globals.serverTerrainManager);
|
||||||
Town startTown = Globals.macroData.getTowns().get(0);
|
if(Globals.macroSimulation != null){
|
||||||
Vector2i firstPos = startTown.getPositions().get(0);
|
Town startTown = Globals.macroData.getTowns().get(0);
|
||||||
double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
Vector2i firstPos = startTown.getPositions().get(0);
|
||||||
double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth();
|
double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
||||||
Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
|
double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth();
|
||||||
|
Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Globals.commonWorldData = new CommonWorldData(Globals.clientWorldData, Globals.clientTerrainManager);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Globals.commonWorldData = new CommonWorldData(Globals.clientWorldData, Globals.clientTerrainManager);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,17 +413,6 @@ public class LoadingThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void stallForClientPlayerData(){
|
|
||||||
// while(!Globals.clientPlayerData.hasLoaded()){
|
|
||||||
// try {
|
|
||||||
// TimeUnit.MILLISECONDS.sleep(5);
|
|
||||||
// } catch (InterruptedException ex) {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void initDrawCellManager(){
|
static void initDrawCellManager(){
|
||||||
Globals.drawCellManager = new DrawCellManager(
|
Globals.drawCellManager = new DrawCellManager(
|
||||||
Globals.clientWorldData,
|
Globals.clientWorldData,
|
||||||
@ -612,7 +550,9 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
|
|
||||||
static void initMicroSimulation(){
|
static void initMicroSimulation(){
|
||||||
Globals.microSimulation = new MicroSimulation();
|
if(Globals.microSimulation == null){
|
||||||
|
Globals.microSimulation = new MicroSimulation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setSimulationsToReady(){
|
static void setSimulationsToReady(){
|
||||||
|
|||||||
@ -286,7 +286,7 @@ public class Globals {
|
|||||||
public static ArrayList<Vector3f> skyboxColors;
|
public static ArrayList<Vector3f> skyboxColors;
|
||||||
|
|
||||||
//thread for loading different game states
|
//thread for loading different game states
|
||||||
public static LoadingThread loadingThread;
|
public static List<LoadingThread> loadingThreadsList = new LinkedList<LoadingThread>();
|
||||||
|
|
||||||
//manager for all widgets currently being drawn to screen
|
//manager for all widgets currently being drawn to screen
|
||||||
public static ElementManager elementManager;
|
public static ElementManager elementManager;
|
||||||
|
|||||||
@ -191,11 +191,14 @@ public class Main {
|
|||||||
//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");
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_TITLE_MENU);
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_TITLE_MENU);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
|
serverThread.start();
|
||||||
} else {
|
} else {
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
|
clientThread.start();
|
||||||
}
|
}
|
||||||
Globals.loadingThread.start();
|
|
||||||
|
|
||||||
//recapture the screen for rendering
|
//recapture the screen for rendering
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
|
|||||||
@ -74,10 +74,11 @@ public class MenuGenerators {
|
|||||||
singleplayerButton.addChild(singleplayerLabel);
|
singleplayerButton.addChild(singleplayerLabel);
|
||||||
rVal.addChild(singleplayerButton);
|
rVal.addChild(singleplayerButton);
|
||||||
singleplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
singleplayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.loadingThread.start();
|
clientThread.start();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -99,10 +100,14 @@ public class MenuGenerators {
|
|||||||
arenaButton.addChild(arenaLabel);
|
arenaButton.addChild(arenaLabel);
|
||||||
rVal.addChild(arenaButton);
|
rVal.addChild(arenaButton);
|
||||||
arenaButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
arenaButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CLIENT_WORLD);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_ARENA);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.loadingThread.start();
|
clientThread.start();
|
||||||
|
serverThread.start();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -131,6 +136,7 @@ public class MenuGenerators {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Used when we're displaying loading window to make main menu invisible
|
||||||
public static Element createEmptyMainMenu(){
|
public static Element createEmptyMainMenu(){
|
||||||
Div rVal = new Div();
|
Div rVal = new Div();
|
||||||
return rVal;
|
return rVal;
|
||||||
@ -152,10 +158,14 @@ public class MenuGenerators {
|
|||||||
rVal.addChild(selectButton);
|
rVal.addChild(selectButton);
|
||||||
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
|
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CHARACTER_SERVER);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.loadingThread.start();
|
clientThread.start();
|
||||||
|
serverThread.start();
|
||||||
} else {
|
} else {
|
||||||
Globals.currentSaveName = saveName.toLowerCase();
|
Globals.currentSaveName = saveName.toLowerCase();
|
||||||
SaveUtils.loadTerrainAndCreateWorldData();
|
SaveUtils.loadTerrainAndCreateWorldData();
|
||||||
@ -282,10 +292,14 @@ public class MenuGenerators {
|
|||||||
hostButton.addChild(hostLabel);
|
hostButton.addChild(hostLabel);
|
||||||
rVal.addChild(hostButton);
|
rVal.addChild(hostButton);
|
||||||
hostButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
hostButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CHARACTER_SERVER);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = true;
|
Globals.RUN_SERVER = true;
|
||||||
Globals.loadingThread.start();
|
clientThread.start();
|
||||||
|
serverThread.start();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@ -348,10 +362,11 @@ public class MenuGenerators {
|
|||||||
connectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
connectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
NetUtils.setAddress(addressInput.getText());
|
NetUtils.setAddress(addressInput.getText());
|
||||||
NetUtils.setPort(Integer.parseInt(portInput.getText()));
|
NetUtils.setPort(Integer.parseInt(portInput.getText()));
|
||||||
Globals.loadingThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
Globals.RUN_CLIENT = true;
|
Globals.RUN_CLIENT = true;
|
||||||
Globals.RUN_SERVER = false;
|
Globals.RUN_SERVER = false;
|
||||||
Globals.loadingThread.start();
|
clientThread.start();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,60 @@
|
|||||||
|
package electrosphere.menu;
|
||||||
|
|
||||||
|
import electrosphere.renderer.ui.Element;
|
||||||
|
import electrosphere.renderer.ui.form.FormElement;
|
||||||
|
|
||||||
|
public class MenuGeneratorsMultiplayer {
|
||||||
|
|
||||||
|
|
||||||
|
public static Element createMultiplayerCharacterCreationWindow(){
|
||||||
|
FormElement rVal = new FormElement();
|
||||||
|
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
||||||
|
List<String> saveNames = SaveUtils.getSaves();
|
||||||
|
int verticalPosition = 125;
|
||||||
|
for(String saveName : saveNames){
|
||||||
|
if(!saveName.startsWith(".")){
|
||||||
|
|
||||||
|
//button (select save)
|
||||||
|
Button selectButton = new Button();
|
||||||
|
Label selectLabel = new Label(100,125 + verticalPosition,1.0f);
|
||||||
|
selectLabel.setText(saveName.toUpperCase());
|
||||||
|
selectButton.addChild(selectLabel);
|
||||||
|
rVal.addChild(selectButton);
|
||||||
|
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
if(SaveUtils.worldHasSave(saveName.toLowerCase())){
|
||||||
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CHARACTER_SERVER);
|
||||||
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
|
LoadingThread serverThread = new LoadingThread(LoadingThread.LOAD_MAIN_GAME);
|
||||||
|
Globals.loadingThreadsList.add(serverThread);
|
||||||
|
Globals.RUN_CLIENT = true;
|
||||||
|
Globals.RUN_SERVER = true;
|
||||||
|
clientThread.start();
|
||||||
|
serverThread.start();
|
||||||
|
} else {
|
||||||
|
Globals.currentSaveName = saveName.toLowerCase();
|
||||||
|
SaveUtils.loadTerrainAndCreateWorldData();
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createSaveCreationMenu());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
verticalPosition = verticalPosition + 75;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//button (create)
|
||||||
|
Button createButton = new Button();
|
||||||
|
Label createLabel = new Label(100,125 + verticalPosition + 200,1.0f);
|
||||||
|
createLabel.setText("Create World");
|
||||||
|
createButton.addChild(createLabel);
|
||||||
|
rVal.addChild(createButton);
|
||||||
|
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
|
WindowUtils.replaceMainMenuContents(MenuGenerators.createWorldCreationMenu());
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user