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_MAIN_GAME = 1;
|
||||
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;
|
||||
|
||||
@ -124,100 +126,42 @@ public class LoadingThread extends Thread {
|
||||
|
||||
|
||||
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)
|
||||
// if(Globals.RUN_SERVER){
|
||||
// initServerGameTerrainManager();
|
||||
// }
|
||||
|
||||
if(Globals.RUN_SERVER){
|
||||
//TODO: Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,randomDampener,0);
|
||||
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
||||
SaveUtils.loadSave(Globals.currentSaveName);
|
||||
Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||
//TODO: set spawnpoint
|
||||
//TODO: Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager);
|
||||
//TODO: Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||
//TODO: Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,randomDampener,0);
|
||||
Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0);
|
||||
SaveUtils.loadSave(Globals.currentSaveName);
|
||||
Globals.dataCellManager = new DataCellManager(Globals.serverWorldData);
|
||||
//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 the data of the world
|
||||
if(Globals.RUN_SERVER){
|
||||
// initServerGameWorldData();
|
||||
initDataCellManager();
|
||||
}
|
||||
|
||||
initDataCellManager();
|
||||
//init authentication
|
||||
initAuthenticationManager();
|
||||
//initialize the server thread (server only)
|
||||
if(Globals.RUN_SERVER){
|
||||
initServerThread();
|
||||
initAuthenticationManager();
|
||||
}
|
||||
|
||||
initServerThread();
|
||||
//initialize the "virtual" objects simulation
|
||||
if(Globals.RUN_SERVER){
|
||||
initMacroSimulation();
|
||||
}
|
||||
|
||||
initMacroSimulation();
|
||||
//initialize the "real" objects simulation
|
||||
initMicroSimulation();
|
||||
|
||||
//initialize the client thread (client)
|
||||
if(Globals.RUN_CLIENT){
|
||||
initClientThread();
|
||||
stallForClientPlayerData();
|
||||
}
|
||||
|
||||
//init client terrain manager
|
||||
initClientTerrainManager();
|
||||
|
||||
//collision engine
|
||||
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)
|
||||
initGameGraphicalEntities();
|
||||
|
||||
|
||||
// while(Globals.clientConnection.getClientProtocol().isLoading()){
|
||||
// try {
|
||||
// TimeUnit.MILLISECONDS.sleep(5);
|
||||
// } catch (InterruptedException ex) {
|
||||
// }
|
||||
// }
|
||||
|
||||
//set simulations to ready if they exist
|
||||
setSimulationsToReady();
|
||||
|
||||
//hide cursor
|
||||
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);
|
||||
//log
|
||||
LoggerInterface.loggerEngine.INFO("[Server]Finished loading");
|
||||
break;
|
||||
|
||||
|
||||
@ -229,97 +173,101 @@ public class LoadingThread extends Thread {
|
||||
|
||||
|
||||
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
|
||||
initServerArenaTerrainManager();
|
||||
|
||||
//init the data of the world
|
||||
initServerArenaWorldData();
|
||||
|
||||
//init data cell manager
|
||||
if(Globals.RUN_SERVER){
|
||||
initDataCellManager();
|
||||
}
|
||||
|
||||
initDataCellManager();
|
||||
//init authentication
|
||||
initAuthenticationManager();
|
||||
//initialize the server thread (server only)
|
||||
if(Globals.RUN_SERVER){
|
||||
initServerThread();
|
||||
initAuthenticationManager();
|
||||
}
|
||||
|
||||
initServerThread();
|
||||
//collision engine
|
||||
initCommonWorldData(Globals.RUN_SERVER);
|
||||
|
||||
//initialize the "virtual" objects simulation
|
||||
//not really relevant in arena mode
|
||||
// initMacroSimulation();
|
||||
|
||||
//initialize the "real" objects simulation
|
||||
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)
|
||||
if(Globals.RUN_CLIENT){
|
||||
initClientThread();
|
||||
stallForClientPlayerData();
|
||||
}
|
||||
initClientThread();
|
||||
//init character creation window
|
||||
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
|
||||
if(Globals.RUN_CLIENT){
|
||||
initClientTerrainManager();
|
||||
}
|
||||
|
||||
initClientTerrainManager();
|
||||
//initialize the cell manager (client)
|
||||
if(Globals.RUN_CLIENT){
|
||||
initDrawCellManager();
|
||||
}
|
||||
|
||||
initDrawCellManager();
|
||||
//initialize the basic graphical entities of the world (skybox, camera)
|
||||
initWorldBaseGraphicalEntities();
|
||||
//init arena specific stuff (ie different skybox colors)
|
||||
initArenaGraphicalEntities();
|
||||
|
||||
creatingRandomEntities();
|
||||
|
||||
// while(Globals.clientConnection.getClientProtocol().isLoading()){
|
||||
// try {
|
||||
// TimeUnit.MILLISECONDS.sleep(5);
|
||||
// } catch (InterruptedException ex) {
|
||||
// }
|
||||
// }
|
||||
|
||||
setSimulationsToReady();
|
||||
|
||||
//sets micro and macro sims to ready if they exist
|
||||
if(!Globals.RUN_SERVER){
|
||||
setSimulationsToReady();
|
||||
}
|
||||
//hide cursor
|
||||
if(Globals.RUN_CLIENT){
|
||||
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");
|
||||
|
||||
if(Globals.RUN_CLIENT){
|
||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
||||
}
|
||||
Globals.controlHandler.hideMouse();
|
||||
//make loading window disappear
|
||||
loadingWindow.setVisible(false);
|
||||
//recapture screen
|
||||
Globals.controlHandler.setShouldRecapture(true);
|
||||
//set rendering flags to main game mode
|
||||
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("[Client]Finished loading");
|
||||
//set controls state
|
||||
Globals.controlHandler.setHandlerState(ControlHandler.ControlsState.MAIN_GAME);
|
||||
break;
|
||||
|
||||
|
||||
@ -328,7 +276,6 @@ public class LoadingThread extends Thread {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
lock.release();
|
||||
}
|
||||
@ -415,17 +362,19 @@ public class LoadingThread extends Thread {
|
||||
}
|
||||
|
||||
static void initCommonWorldData(boolean FLAG_INIT_SERVER){
|
||||
if(FLAG_INIT_SERVER){
|
||||
Globals.commonWorldData = new CommonWorldData(Globals.serverWorldData, Globals.serverTerrainManager);
|
||||
if(Globals.macroSimulation != null){
|
||||
Town startTown = Globals.macroData.getTowns().get(0);
|
||||
Vector2i firstPos = startTown.getPositions().get(0);
|
||||
double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
||||
double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth();
|
||||
Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
|
||||
if(Globals.commonWorldData == null){
|
||||
if(FLAG_INIT_SERVER){
|
||||
Globals.commonWorldData = new CommonWorldData(Globals.serverWorldData, Globals.serverTerrainManager);
|
||||
if(Globals.macroSimulation != null){
|
||||
Town startTown = Globals.macroData.getTowns().get(0);
|
||||
Vector2i firstPos = startTown.getPositions().get(0);
|
||||
double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth();
|
||||
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(){
|
||||
Globals.drawCellManager = new DrawCellManager(
|
||||
Globals.clientWorldData,
|
||||
@ -612,7 +550,9 @@ public class LoadingThread extends Thread {
|
||||
|
||||
|
||||
static void initMicroSimulation(){
|
||||
Globals.microSimulation = new MicroSimulation();
|
||||
if(Globals.microSimulation == null){
|
||||
Globals.microSimulation = new MicroSimulation();
|
||||
}
|
||||
}
|
||||
|
||||
static void setSimulationsToReady(){
|
||||
|
||||
@ -286,7 +286,7 @@ public class Globals {
|
||||
public static ArrayList<Vector3f> skyboxColors;
|
||||
|
||||
//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
|
||||
public static ElementManager elementManager;
|
||||
|
||||
@ -191,11 +191,14 @@ public class Main {
|
||||
//fire off a loading thread for the title menus/screen
|
||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||
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 {
|
||||
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
|
||||
if(Globals.RUN_CLIENT){
|
||||
|
||||
@ -74,10 +74,11 @@ public class MenuGenerators {
|
||||
singleplayerButton.addChild(singleplayerLabel);
|
||||
rVal.addChild(singleplayerButton);
|
||||
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_SERVER = true;
|
||||
Globals.loadingThread.start();
|
||||
clientThread.start();
|
||||
return false;
|
||||
}});
|
||||
|
||||
@ -99,10 +100,14 @@ public class MenuGenerators {
|
||||
arenaButton.addChild(arenaLabel);
|
||||
rVal.addChild(arenaButton);
|
||||
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_SERVER = true;
|
||||
Globals.loadingThread.start();
|
||||
clientThread.start();
|
||||
serverThread.start();
|
||||
return false;
|
||||
}});
|
||||
|
||||
@ -131,6 +136,7 @@ public class MenuGenerators {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
//Used when we're displaying loading window to make main menu invisible
|
||||
public static Element createEmptyMainMenu(){
|
||||
Div rVal = new Div();
|
||||
return rVal;
|
||||
@ -152,10 +158,14 @@ public class MenuGenerators {
|
||||
rVal.addChild(selectButton);
|
||||
selectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
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_SERVER = true;
|
||||
Globals.loadingThread.start();
|
||||
clientThread.start();
|
||||
serverThread.start();
|
||||
} else {
|
||||
Globals.currentSaveName = saveName.toLowerCase();
|
||||
SaveUtils.loadTerrainAndCreateWorldData();
|
||||
@ -282,10 +292,14 @@ public class MenuGenerators {
|
||||
hostButton.addChild(hostLabel);
|
||||
rVal.addChild(hostButton);
|
||||
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_SERVER = true;
|
||||
Globals.loadingThread.start();
|
||||
clientThread.start();
|
||||
serverThread.start();
|
||||
return false;
|
||||
}});
|
||||
|
||||
@ -348,10 +362,11 @@ public class MenuGenerators {
|
||||
connectButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
NetUtils.setAddress(addressInput.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_SERVER = false;
|
||||
Globals.loadingThread.start();
|
||||
clientThread.start();
|
||||
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