ui work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-03-27 19:33:46 -04:00
parent d7329210b0
commit 72915798b3
9 changed files with 220 additions and 169 deletions

View File

@ -1344,7 +1344,8 @@ Fix audio engine not cleaning up audio sources
More accurate block test types More accurate block test types
Block meshgen work Block meshgen work
Delete deprecated foliage manager Delete deprecated foliage manager
Title menu navigation work
Fix UI Testing debug menu
# TODO # TODO

View File

@ -1,18 +1,6 @@
package electrosphere.client.ui.menu; package electrosphere.client.ui.menu;
import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.components.InputMacros;
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsKeybind;
import electrosphere.client.ui.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.net.NetUtils;
import electrosphere.renderer.ui.elements.Button;
import electrosphere.renderer.ui.elements.Div; import electrosphere.renderer.ui.elements.Div;
import electrosphere.renderer.ui.elements.FormElement;
import electrosphere.renderer.ui.elements.Label;
import electrosphere.renderer.ui.elements.TextInput;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
/** /**
@ -28,158 +16,6 @@ public class MenuGenerators {
Div rVal = Div.createDiv(); Div rVal = Div.createDiv();
return rVal; return rVal;
} }
public static Element createCharacterCreationMenu(){
FormElement rVal = new FormElement();
//TODO: add text input to name world
//button (create)
rVal.addChild(Button.createButton("Create World", () -> {
throw new UnsupportedOperationException("Unimplemented");
}));
return rVal;
}
public static Element createFinalizeSaveCreationMenu(){
FormElement rVal = new FormElement();
//TODO: add text input to name world
//button (create)
rVal.addChild(Button.createButton("Create World", () -> {
throw new UnsupportedOperationException("Unimplemented");
}));
return rVal;
}
public static Element createMultiplayerMenu(){
FormElement rVal = new FormElement();
//button (host)
rVal.addChild(Button.createButton("Host", () -> {
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = true;
Globals.threadManager.start(serverThread);
Globals.threadManager.start(clientThread);
}));
//button (join)
rVal.addChild(Button.createButton("Join", () -> {
WindowUtils.replaceMainMenuContents(MenuGenerators.createIPMenu());
}));
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
}));
return rVal;
}
public static Element createIPMenu(){
FormElement rVal = new FormElement();
//
//Address input
//
String ipAddress = "";
if(Globals.netConfig != null && Globals.netConfig.getAddress() != null){
ipAddress = Globals.netConfig.getAddress();
} else {
ipAddress = NetUtils.getAddress();
}
Div addressControl = InputMacros.createTextInputVertical("IP Address", ipAddress);
TextInput addressInput = (TextInput)addressControl.getChildren().get(1);
rVal.addChild(addressControl);
//
//Port input
//
String port = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
port = Globals.netConfig.getPort();
} else {
port = NetUtils.getPort() + "";
}
Div portControl = InputMacros.createTextInputVertical("Port", port);
TextInput portInput = (TextInput)portControl.getChildren().get(1);
rVal.addChild(portControl);
//
//Username input
//
String username = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
username = Globals.netConfig.getUsername();
} else {
username = "";
}
Div usernameControl = InputMacros.createTextInputVertical("Username", username);
TextInput usernameInput = (TextInput)usernameControl.getChildren().get(1);
rVal.addChild(usernameControl);
//
//Password input
//
String password = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
password = Globals.netConfig.getPassword();
} else {
password = "";
}
Div passwordControl = InputMacros.createTextInputVertical("Password", password);
TextInput passwordInput = (TextInput)passwordControl.getChildren().get(1);
rVal.addChild(passwordControl);
//button (connect)
rVal.addChild(Button.createButton("Connect", () -> {
NetUtils.setAddress(addressInput.getText());
NetUtils.setPort(Integer.parseInt(portInput.getText()));
Globals.clientUsername = usernameInput.getText();
Globals.clientPassword = AuthenticationManager.getHashedString(passwordInput.getText());
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = false;
Globals.threadManager.start(clientThread);
}));
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGenerators.createMultiplayerMenu());
}));
return rVal;
}
public static Element createOptionsMainMenu(){
FormElement rVal = new FormElement();
//label (options)
Label optionsLabel = Label.createLabel("Options");
rVal.addChild(optionsLabel);
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
}));
//button to open rebind controls window
Button rebindControlsButton = Button.createButton("Controls", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsKeybind.createControlsRebindMenu());
});
rVal.addChild(rebindControlsButton);
return rVal;
}

View File

@ -14,6 +14,7 @@ import electrosphere.renderer.ui.elements.Window;
import electrosphere.renderer.ui.elementtypes.ContainerElement; import electrosphere.renderer.ui.elementtypes.ContainerElement;
import electrosphere.renderer.ui.elementtypes.DrawableElement; import electrosphere.renderer.ui.elementtypes.DrawableElement;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.elementtypes.NavigableElement.NavigationEventCallback;
/** /**
* Utils for native windowing framework * Utils for native windowing framework
@ -151,6 +152,15 @@ public class WindowUtils {
Globals.elementService.focusFirstElement(); Globals.elementService.focusFirstElement();
} }
/**
* Sets the backout callback for the main menu window
* @param onNav The callback
*/
public static void setMainMenuBackoutCallback(NavigationEventCallback onNav){
Window mainMenu = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN);
mainMenu.setOnNavigationCallback(onNav);
}
/** /**
* Cleans up a window visually and removes it from the element manager * Cleans up a window visually and removes it from the element manager
* @param window the window to clean up * @param window the window to clean up

View File

@ -20,6 +20,7 @@ import electrosphere.renderer.ui.elements.Label;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
import electrosphere.renderer.ui.events.NavigationEvent;
import electrosphere.renderer.ui.events.ValueChangeEvent; import electrosphere.renderer.ui.events.ValueChangeEvent;
import electrosphere.server.datacell.GriddedDataCellManager; import electrosphere.server.datacell.GriddedDataCellManager;
import electrosphere.server.saves.SaveUtils; import electrosphere.server.saves.SaveUtils;
@ -50,6 +51,12 @@ public class MenuGeneratorsLevelEditor {
//left-right //left-right
rVal.setAlignItems(YogaAlignment.Center); rVal.setAlignItems(YogaAlignment.Center);
rVal.setAlignContent(YogaAlignment.Center); rVal.setAlignContent(YogaAlignment.Center);
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
return false;
});
// //
@ -135,6 +142,13 @@ public class MenuGeneratorsLevelEditor {
*/ */
public static Element createLevelEditorCreationMenu(){ public static Element createLevelEditorCreationMenu(){
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsLevelEditor.createLevelEditorTopMenu());
return false;
});
//values to creat the level with //values to creat the level with
LevelDescription inFlightLevel = new LevelDescription(); LevelDescription inFlightLevel = new LevelDescription();
SceneFile sceneFile = SceneFile.createSceneFile(); SceneFile sceneFile = SceneFile.createSceneFile();

View File

@ -1,18 +1,26 @@
package electrosphere.client.ui.menu.mainmenu; package electrosphere.client.ui.menu.mainmenu;
import electrosphere.auth.AuthenticationManager;
import electrosphere.client.ui.components.CharacterCustomizer; import electrosphere.client.ui.components.CharacterCustomizer;
import electrosphere.client.ui.components.InputMacros;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.net.NetUtils;
import electrosphere.net.parser.net.message.CharacterMessage; import electrosphere.net.parser.net.message.CharacterMessage;
import electrosphere.renderer.ui.elements.Button; import electrosphere.renderer.ui.elements.Button;
import electrosphere.renderer.ui.elements.Div;
import electrosphere.renderer.ui.elements.FormElement; import electrosphere.renderer.ui.elements.FormElement;
import electrosphere.renderer.ui.elements.Label; import electrosphere.renderer.ui.elements.Label;
import electrosphere.renderer.ui.elements.StringCarousel; import electrosphere.renderer.ui.elements.StringCarousel;
import electrosphere.renderer.ui.elements.TextInput;
import electrosphere.renderer.ui.elementtypes.ClickableElement; import electrosphere.renderer.ui.elementtypes.ClickableElement;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.elementtypes.ValueElement.ValueChangeEventCallback; import electrosphere.renderer.ui.elementtypes.ValueElement.ValueChangeEventCallback;
import electrosphere.renderer.ui.events.ClickEvent; import electrosphere.renderer.ui.events.ClickEvent;
import electrosphere.renderer.ui.events.NavigationEvent;
import electrosphere.renderer.ui.events.ValueChangeEvent; import electrosphere.renderer.ui.events.ValueChangeEvent;
import electrosphere.util.Utilities; import electrosphere.util.Utilities;
@ -63,4 +71,127 @@ public class MenuGeneratorsMultiplayer {
return rVal; return rVal;
} }
/**
* The multiplayer mode selection menu
* @return The element containing the menu
*/
public static Element createMultiplayerMenu(){
FormElement rVal = new FormElement();
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
return false;
});
//button (host)
rVal.addChild(Button.createButton("Host", () -> {
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
LoadingThread serverThread = new LoadingThread(LoadingThreadType.MAIN_GAME);
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = true;
Globals.threadManager.start(serverThread);
Globals.threadManager.start(clientThread);
}));
//button (join)
rVal.addChild(Button.createButton("Join", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsMultiplayer.createIPMenu());
}));
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
}));
return rVal;
}
/**
* The ip input menu
* @return The element containing the menu
*/
public static Element createIPMenu(){
FormElement rVal = new FormElement();
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsMultiplayer.createMultiplayerMenu());
return false;
});
//
//Address input
//
String ipAddress = "";
if(Globals.netConfig != null && Globals.netConfig.getAddress() != null){
ipAddress = Globals.netConfig.getAddress();
} else {
ipAddress = NetUtils.getAddress();
}
Div addressControl = InputMacros.createTextInputVertical("IP Address", ipAddress);
TextInput addressInput = (TextInput)addressControl.getChildren().get(1);
rVal.addChild(addressControl);
//
//Port input
//
String port = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
port = Globals.netConfig.getPort();
} else {
port = NetUtils.getPort() + "";
}
Div portControl = InputMacros.createTextInputVertical("Port", port);
TextInput portInput = (TextInput)portControl.getChildren().get(1);
rVal.addChild(portControl);
//
//Username input
//
String username = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
username = Globals.netConfig.getUsername();
} else {
username = "";
}
Div usernameControl = InputMacros.createTextInputVertical("Username", username);
TextInput usernameInput = (TextInput)usernameControl.getChildren().get(1);
rVal.addChild(usernameControl);
//
//Password input
//
String password = "";
if(Globals.netConfig != null && Globals.netConfig.getPort() != null){
password = Globals.netConfig.getPassword();
} else {
password = "";
}
Div passwordControl = InputMacros.createTextInputVertical("Password", password);
TextInput passwordInput = (TextInput)passwordControl.getChildren().get(1);
rVal.addChild(passwordControl);
//button (connect)
rVal.addChild(Button.createButton("Connect", () -> {
NetUtils.setAddress(addressInput.getText());
NetUtils.setPort(Integer.parseInt(portInput.getText()));
Globals.clientUsername = usernameInput.getText();
Globals.clientPassword = AuthenticationManager.getHashedString(passwordInput.getText());
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CHARACTER_SERVER);
Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = false;
Globals.threadManager.start(clientThread);
}));
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsMultiplayer.createMultiplayerMenu());
}));
return rVal;
}
} }

View File

@ -1,6 +1,5 @@
package electrosphere.client.ui.menu.mainmenu; package electrosphere.client.ui.menu.mainmenu;
import electrosphere.client.ui.menu.MenuGenerators;
import electrosphere.client.ui.menu.WindowUtils; import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
@ -14,6 +13,7 @@ import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.events.NavigationEvent;
/** /**
* Menu generators for the title menu * Menu generators for the title menu
@ -25,6 +25,12 @@ public class MenuGeneratorsTitleMenu {
* @return The menu element * @return The menu element
*/ */
public static Element createTitleMenu(){ public static Element createTitleMenu(){
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
return false;
});
Div rVal = Div.createDiv(); Div rVal = Div.createDiv();
//top-bottom //top-bottom
rVal.setJustifyContent(YogaJustification.Between); rVal.setJustifyContent(YogaJustification.Between);
@ -53,7 +59,7 @@ public class MenuGeneratorsTitleMenu {
//button (multiplayer) //button (multiplayer)
optionPanel.addChild(Button.createButtonCentered("Multiplayer", 1.0f, () -> { optionPanel.addChild(Button.createButtonCentered("Multiplayer", 1.0f, () -> {
WindowUtils.replaceMainMenuContents(MenuGenerators.createMultiplayerMenu()); WindowUtils.replaceMainMenuContents(MenuGeneratorsMultiplayer.createMultiplayerMenu());
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE)); }).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE));
//button (static level) //button (static level)
@ -63,7 +69,7 @@ public class MenuGeneratorsTitleMenu {
//button (options) //button (options)
optionPanel.addChild(Button.createButtonCentered("Options", 1.0f, () -> { optionPanel.addChild(Button.createButtonCentered("Options", 1.0f, () -> {
WindowUtils.replaceMainMenuContents(MenuGenerators.createOptionsMainMenu()); WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleOptions.createOptionsMainMenu());
}).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE)); }).setOnClickAudio(AssetDataStrings.UI_TONE_BUTTON_TITLE));
//button (sp debug) //button (sp debug)

View File

@ -0,0 +1,46 @@
package electrosphere.client.ui.menu.mainmenu;
import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.renderer.ui.elements.Button;
import electrosphere.renderer.ui.elements.FormElement;
import electrosphere.renderer.ui.elements.Label;
import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.events.NavigationEvent;
/**
* Functions for generating the options menu ui
*/
public class MenuGeneratorsTitleOptions {
/**
* Generates the main options page
* @return The element containing the main options page
*/
public static Element createOptionsMainMenu(){
FormElement rVal = new FormElement();
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
return false;
});
//label (options)
Label optionsLabel = Label.createLabel("Options");
rVal.addChild(optionsLabel);
//button (back)
rVal.addChild(Button.createButton("Back", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
}));
//button to open rebind controls window
Button rebindControlsButton = Button.createButton("Controls", () -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsKeybind.createControlsRebindMenu());
});
rVal.addChild(rebindControlsButton);
return rVal;
}
}

View File

@ -97,10 +97,10 @@ public class MenuGeneratorsUITesting {
formEl.addChild(InputMacros.createToggle("Test Toggle", false, null)); formEl.addChild(InputMacros.createToggle("Test Toggle", false, null));
//actor panel //actor panel
ActorPanel actorPanel = ActorPanel.create(ActorUtils.createActorFromModelPath(AssetDataStrings.UNITCUBE));
if(Globals.playerCamera == null){ if(Globals.playerCamera == null){
Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3d(0,0,0), new Vector3d(-1,0,0)); Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3d(0,0,0), new Vector3d(-1,0,0));
} }
ActorPanel actorPanel = ActorPanel.create(ActorUtils.createActorFromModelPath(AssetDataStrings.UNITCUBE));
formEl.addChild(actorPanel); formEl.addChild(actorPanel);

View File

@ -15,6 +15,7 @@ import electrosphere.renderer.ui.elements.TextInput;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaAlignment;
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification; import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaJustification;
import electrosphere.renderer.ui.elementtypes.Element; import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.events.NavigationEvent;
import electrosphere.server.saves.SaveUtils; import electrosphere.server.saves.SaveUtils;
public class MenuWorldSelect { public class MenuWorldSelect {
@ -26,6 +27,12 @@ public class MenuWorldSelect {
public static Element createWorldSelectMenu(){ public static Element createWorldSelectMenu(){
FormElement rVal = new FormElement(); FormElement rVal = new FormElement();
//set nav callback
WindowUtils.setMainMenuBackoutCallback((NavigationEvent event) -> {
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
return false;
});
//create save button column //create save button column
Div saveButtonContainer = Div.createCol(); Div saveButtonContainer = Div.createCol();
saveButtonContainer.setMarginRight(50); saveButtonContainer.setMarginRight(50);