fix engine quitting, refactor buttons in menu
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-24 18:08:24 -04:00
parent 337da83070
commit 3682497060
2 changed files with 21 additions and 59 deletions

View File

@ -432,6 +432,8 @@ public class Main {
if(!Globals.HEADLESS && Globals.RUN_CLIENT){
glfwTerminate();
}
//reset globals
Globals.resetGlobals();
//used to signal threads to stop
Globals.threadManager.close();
//shut down audio engine
@ -444,8 +446,6 @@ public class Main {
}
//shutdown ode
OdeHelper.closeODE();
//reset globals
Globals.resetGlobals();
}
static void sleep(int i) {

View File

@ -61,20 +61,8 @@ public class MenuGeneratorsInGame {
return false;
}});
//black texture background
// ImagePanel imagePanel = new ImagePanel(0,0,width,height,Globals.blackTexture);
// imagePanel.setWidth(width);
// imagePanel.setHeight(height);
// imagePanel.setTexture(Globals.assetManager.fetchTexture(Globals.blackTexture));
// div.addChild(imagePanel);
//label 1 (back)
Button backButton = new Button();
Label backLabel = new Label(1.0f);
backLabel.setText("Back");
backButton.addChild(backLabel);
div.addChild(backButton);
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
//Back
div.addChild(Button.createButton("Back", () -> {
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(Globals.cameraHandler.getTrackPlayerEntity()){
@ -82,47 +70,28 @@ public class MenuGeneratorsInGame {
} else {
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_FREE_CAMERA);
}
return false;
}});
}));
//label 2 (quit)
Button saveButton = new Button();
Label saveLabel = new Label(1.0f);
saveLabel.setText("Save");
saveButton.addChild(saveLabel);
div.addChild(saveButton);
saveButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Main.running = false;
//save terrain
saveWorld();
return false;
}});
//label 3 (quit)
Button quitButton = new Button();
Label quitLabel = new Label(1.0f);
quitLabel.setText("Quit");
quitButton.addChild(quitLabel);
div.addChild(quitButton);
quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
//Return to main menu
div.addChild(Button.createButton("Return To Main Menu", () -> {
Globals.threadManager.start(new LoadingThread(LoadingThreadType.RETURN_TITLE_MENU));
return false;
}});
}));
//Save
div.addChild(Button.createButton("Save", () -> {
SaveUtils.overwriteSave(Globals.currentSave.getName());
}));
//Quit
div.addChild(Button.createButton("Quit", () -> {
Main.running = false;
}));
//checking macro data is a poor man's check for whether we're arena or full gamemode
// if(Globals.server != null && Globals.macroData == null){
//label 4 (debug)
Button debugButton = new Button();
Label debugLabel = new Label(1.0f);
debugLabel.setText("Debug");
debugButton.addChild(debugLabel);
div.addChild(debugButton);
debugButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
div.addChild(Button.createButton("Debug", () -> {
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameDebugMainMenu());
return false;
}});
// }
}));
if(MenuGeneratorsInGame.shouldShowLevelEditor()){
div.addChild(Button.createButton("Open Level Editor Tools", () -> {
@ -135,13 +104,6 @@ public class MenuGeneratorsInGame {
return rVal;
}
/**
* Saves the world
*/
static void saveWorld(){
SaveUtils.overwriteSave(Globals.currentSave.getName());
}
public static Window createInGameDebugMainMenu(){
// int screenTop = Globals.WINDOW_HEIGHT - 150;
int width = 500;