window modification signal

This commit is contained in:
austin 2024-09-05 17:46:47 -04:00
parent b9ccf5990c
commit 3db24ef6c7
5 changed files with 38 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import electrosphere.client.targeting.crosshair.Crosshair;
import electrosphere.client.terrain.cells.DrawCellManager; import electrosphere.client.terrain.cells.DrawCellManager;
import electrosphere.controls.ControlHandler; import electrosphere.controls.ControlHandler;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.engine.threads.LabeledThread.ThreadLabel; import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.DrawableUtils; import electrosphere.entity.DrawableUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
@ -62,10 +63,10 @@ public class ClientLoading {
protected static void loadClientWorld(Object[] params){ protected static void loadClientWorld(Object[] params){
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING); Globals.signalSystem.post(SignalType.UI_MODIFICATION, () -> {
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false); WindowUtils.closeWindow(WindowStrings.WINDOW_MENU_MAIN);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu()); WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_LOADING, true);
loadingWindow.setVisible(true); });
//disable menu input //disable menu input
Globals.controlHandler.hintUpdateControlState(ControlHandler.ControlsState.NO_INPUT); Globals.controlHandler.hintUpdateControlState(ControlHandler.ControlsState.NO_INPUT);
//initialize the "real" objects simulation //initialize the "real" objects simulation
@ -83,7 +84,9 @@ public class ClientLoading {
//sets micro and macro sims to ready if they exist //sets micro and macro sims to ready if they exist
setSimulationsToReady(); setSimulationsToReady();
//make loading window disappear //make loading window disappear
loadingWindow.setVisible(false); Globals.signalSystem.post(SignalType.UI_MODIFICATION, () -> {
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_LOADING, false);
});
//recapture screen //recapture screen
Globals.controlHandler.setRecapture(true); Globals.controlHandler.setRecapture(true);
//set rendering flags to main game mode //set rendering flags to main game mode
@ -102,10 +105,10 @@ public class ClientLoading {
* Loads the viewport * Loads the viewport
*/ */
protected static void loadViewport(Object[] params){ protected static void loadViewport(Object[] params){
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING); Globals.signalSystem.post(SignalType.UI_MODIFICATION, () -> {
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu()); WindowUtils.closeWindow(WindowStrings.WINDOW_MENU_MAIN);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false); WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_LOADING, true);
loadingWindow.setVisible(true); });
//disable menu input //disable menu input
Globals.controlHandler.hintUpdateControlState(ControlHandler.ControlsState.NO_INPUT); Globals.controlHandler.hintUpdateControlState(ControlHandler.ControlsState.NO_INPUT);
@ -124,7 +127,9 @@ public class ClientLoading {
//sets micro and macro sims to ready if they exist //sets micro and macro sims to ready if they exist
setSimulationsToReady(); setSimulationsToReady();
//make loading window disappear //make loading window disappear
loadingWindow.setVisible(false); Globals.signalSystem.post(SignalType.UI_MODIFICATION, () -> {
WindowUtils.recursiveSetVisible(WindowStrings.WINDOW_LOADING, false);
});
//recapture screen //recapture screen
Globals.controlHandler.setRecapture(true); Globals.controlHandler.setRecapture(true);
//set rendering flags to main game mode //set rendering flags to main game mode

View File

@ -22,6 +22,7 @@ public class Signal {
// //
YOGA_APPLY, YOGA_APPLY,
YOGA_DESTROY, YOGA_DESTROY,
UI_MODIFICATION,
} }

View File

@ -112,4 +112,12 @@ public class SignalSystem implements Service {
this.post(type,null); this.post(type,null);
} }
/**
* Posts a signal
* @param type The type of signal
*/
public void post(SignalType type, Runnable runnable){
this.post(type,(Object)runnable);
}
} }

View File

@ -56,6 +56,15 @@ public class WindowUtils {
} }
} }
/**
* Recursively sets a window as visible or not
* @param topLevelMenu The window string
* @param visible true for visible, false for invisible
*/
public static void recursiveSetVisible(String windowString, boolean visible){
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(windowString), visible);
}
/** /**
* Checks if the window string is visible * Checks if the window string is visible
* @param windowString The window string * @param windowString The window string

View File

@ -523,6 +523,11 @@ public class ElementService extends SignalServiceImpl {
target.destroy(); target.destroy();
rVal = true; rVal = true;
} break; } break;
case UI_MODIFICATION: {
Runnable modificationCallback = (Runnable)signal.getData();
modificationCallback.run();
rVal = true;
} break;
default: { default: {
} break; } break;
} }