ui work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4aae7b68b8
commit
5c6dbe8f1b
@ -1456,6 +1456,9 @@ Script cache busting on file modification
|
|||||||
Block cursor
|
Block cursor
|
||||||
Rename editor enum to prevent type conflict
|
Rename editor enum to prevent type conflict
|
||||||
|
|
||||||
|
(04/10/2025)
|
||||||
|
UI work
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,18 +35,33 @@ import electrosphere.renderer.ui.events.NavigationEvent;
|
|||||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu generators for in game menus
|
||||||
|
*/
|
||||||
public class MenuGeneratorsInGame {
|
public class MenuGeneratorsInGame {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Margin for buttons
|
||||||
|
*/
|
||||||
|
static final int BUTTON_MARGIN = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Width of window
|
||||||
|
*/
|
||||||
|
static final int WINDOW_WIDTH = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height of window
|
||||||
|
*/
|
||||||
|
static final int WINDOW_HEIGHT = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the main in game menu that shows up when you (typically) hit the escape key
|
* Creates the main in game menu that shows up when you (typically) hit the escape key
|
||||||
* @return The window for the menu
|
* @return The window for the menu
|
||||||
*/
|
*/
|
||||||
public static Window createInGameMainMenu(){
|
public static Window createInGameMainMenu(){
|
||||||
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
Window rVal = Window.createExpandableCenterAligned(Globals.renderingEngine.getOpenGLState(), WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
int width = 500;
|
|
||||||
int height = 500;
|
|
||||||
Window rVal = Window.create(Globals.renderingEngine.getOpenGLState(), 0, 0, width, height, true);
|
|
||||||
// int screenLeft = (Globals.WINDOW_WIDTH - width)/2;
|
|
||||||
Div div = Div.createDiv();
|
Div div = Div.createDiv();
|
||||||
rVal.addChild(div);
|
rVal.addChild(div);
|
||||||
div.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
|
div.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
|
||||||
@ -62,42 +77,70 @@ public class MenuGeneratorsInGame {
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
//Back
|
//Back
|
||||||
div.addChild(Button.createButton("Back", () -> {
|
{
|
||||||
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
|
Button button = Button.createButton("Back", () -> {
|
||||||
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
|
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
|
||||||
if(Globals.cameraHandler.getTrackPlayerEntity()){
|
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
|
||||||
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
|
if(Globals.cameraHandler.getTrackPlayerEntity()){
|
||||||
} else {
|
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
|
||||||
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_FREE_CAMERA);
|
} else {
|
||||||
}
|
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_FREE_CAMERA);
|
||||||
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
|
}
|
||||||
}));
|
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
|
||||||
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
//Return to main menu
|
//Return to main menu
|
||||||
div.addChild(Button.createButton("Return To Main Menu", () -> {
|
{
|
||||||
Globals.signalSystem.post(SignalType.ENGINE_RETURN_TO_TITLE);
|
Button button = Button.createButton("Return To Main Menu", () -> {
|
||||||
}));
|
Globals.signalSystem.post(SignalType.ENGINE_RETURN_TO_TITLE);
|
||||||
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
div.addChild(Button.createButton("Save", () -> {
|
{
|
||||||
SaveUtils.overwriteSave(Globals.currentSave.getName());
|
Button button = Button.createButton("Save", () -> {
|
||||||
}));
|
SaveUtils.overwriteSave(Globals.currentSave.getName());
|
||||||
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
//Quit
|
//Quit
|
||||||
div.addChild(Button.createButton("Quit", () -> {
|
{
|
||||||
Main.running = false;
|
Button button = Button.createButton("Quit", () -> {
|
||||||
}));
|
Main.running = false;
|
||||||
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
//checking macro data is a poor man's check for whether we're arena or full gamemode
|
//checking macro data is a poor man's check for whether we're arena or full gamemode
|
||||||
div.addChild(Button.createButton("Debug", () -> {
|
{
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameDebugMainMenu());
|
Button button = Button.createButton("Debug", () -> {
|
||||||
}));
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameDebugMainMenu());
|
||||||
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
if(MenuGeneratorsInGame.shouldShowLevelEditor()){
|
if(MenuGeneratorsInGame.shouldShowLevelEditor()){
|
||||||
div.addChild(Button.createButton("Open Level Editor Tools", () -> {
|
Button button = Button.createButton("Open Level Editor Tools", () -> {
|
||||||
WindowUtils.replaceWindow(WindowStrings.LEVEL_EDTIOR_SIDE_PANEL,MenuGeneratorsLevelEditor.createLevelEditorSidePanel());
|
WindowUtils.replaceWindow(WindowStrings.LEVEL_EDTIOR_SIDE_PANEL,MenuGeneratorsLevelEditor.createLevelEditorSidePanel());
|
||||||
}));
|
});
|
||||||
|
button.setMarginTop(BUTTON_MARGIN);
|
||||||
|
button.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
div.addChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||||
@ -105,29 +148,28 @@ public class MenuGeneratorsInGame {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the debug menu
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Window createInGameDebugMainMenu(){
|
public static Window createInGameDebugMainMenu(){
|
||||||
// int screenTop = Globals.WINDOW_HEIGHT - 150;
|
Window rVal = Window.createExpandableCenterAligned(Globals.renderingEngine.getOpenGLState(), WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
int width = 500;
|
|
||||||
int height = 500;
|
|
||||||
Window rVal = Window.create(Globals.renderingEngine.getOpenGLState(), 0, 0, width, height, true);
|
|
||||||
|
|
||||||
VirtualScrollable scrollable = new VirtualScrollable(width, height);
|
VirtualScrollable scrollable = new VirtualScrollable(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
rVal.addChild(scrollable);
|
rVal.addChild(scrollable);
|
||||||
// scrollable.addChild(div);
|
|
||||||
rVal.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
|
rVal.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
//label 1 (back)
|
//label 1 (back)
|
||||||
Button backButton = new Button();
|
Button backButton = Button.createButton("Back", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label backLabel = Label.createLabel("Back");
|
|
||||||
backButton.addChild(backLabel);
|
|
||||||
scrollable.addChild(backButton);
|
|
||||||
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
backButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
backButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(backButton);
|
||||||
|
|
||||||
|
|
||||||
//text entry (port)
|
//text entry (port)
|
||||||
@ -136,11 +178,7 @@ public class MenuGeneratorsInGame {
|
|||||||
modelDebugInput.setText("Model path goes here");
|
modelDebugInput.setText("Model path goes here");
|
||||||
|
|
||||||
//label 3 (load model and debug)
|
//label 3 (load model and debug)
|
||||||
Button debugModelButton = new Button();
|
Button debugModelButton = Button.createButton("Print Model Debug Info", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label debugModelLabel = Label.createLabel("Print Model Debug Info");
|
|
||||||
debugModelButton.addChild(debugModelLabel);
|
|
||||||
scrollable.addChild(debugModelButton);
|
|
||||||
debugModelButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Model targetModel = null;
|
Model targetModel = null;
|
||||||
if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){
|
if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){
|
||||||
@ -154,35 +192,32 @@ public class MenuGeneratorsInGame {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
debugModelButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
debugModelButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(debugModelButton);
|
||||||
|
|
||||||
//label 4 (reload all shaders)
|
//label 4 (reload all shaders)
|
||||||
Button reloadShaderButton = new Button();
|
Button reloadShaderButton = Button.createButton("Reload all shaders", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label reloadShaderLabel = Label.createLabel("Reload all shaders");
|
|
||||||
reloadShaderButton.addChild(reloadShaderLabel);
|
|
||||||
scrollable.addChild(reloadShaderButton);
|
|
||||||
reloadShaderButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.assetManager.forceReloadAllShaders();
|
Globals.assetManager.forceReloadAllShaders();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
reloadShaderButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
reloadShaderButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(reloadShaderButton);
|
||||||
|
|
||||||
//reload all models
|
//reload all models
|
||||||
Button reloadModelButton = new Button();
|
Button reloadModelButton = Button.createButton("Reload all models", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label reloadModelLabel = Label.createLabel("Reload all models");
|
|
||||||
reloadModelButton.addChild(reloadModelLabel);
|
|
||||||
scrollable.addChild(reloadModelButton);
|
|
||||||
reloadModelButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.assetManager.forceReloadAllModels();
|
Globals.assetManager.forceReloadAllModels();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
reloadModelButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
reloadModelButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(reloadModelButton);
|
||||||
|
|
||||||
//disable drawing player character
|
//disable drawing player character
|
||||||
Button toggleDrawPlayerButton = new Button();
|
Button toggleDrawPlayerButton = Button.createButton("Toggle draw character", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label toggleDrawPlayerLabel = Label.createLabel("Toggle draw character");
|
|
||||||
toggleDrawPlayerButton.addChild(toggleDrawPlayerLabel);
|
|
||||||
scrollable.addChild(toggleDrawPlayerButton);
|
|
||||||
toggleDrawPlayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
if(Globals.playerEntity != null){
|
if(Globals.playerEntity != null){
|
||||||
if(Globals.playerEntity.containsKey(EntityDataStrings.DATA_STRING_DRAW)){
|
if(Globals.playerEntity.containsKey(EntityDataStrings.DATA_STRING_DRAW)){
|
||||||
@ -196,88 +231,88 @@ public class MenuGeneratorsInGame {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
toggleDrawPlayerButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
toggleDrawPlayerButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(toggleDrawPlayerButton);
|
||||||
|
|
||||||
//pull up character editor
|
//pull up character editor
|
||||||
Button characterSliderMenuButton = new Button();
|
Button characterSliderMenuButton = Button.createButton("Character slider menu", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label characterSliderMenuLabel = Label.createLabel("Character slider menu");
|
|
||||||
characterSliderMenuButton.addChild(characterSliderMenuLabel);
|
|
||||||
scrollable.addChild(characterSliderMenuButton);
|
|
||||||
characterSliderMenuButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameCharacterSliderMenu());
|
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameCharacterSliderMenu());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
characterSliderMenuButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
characterSliderMenuButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(characterSliderMenuButton);
|
||||||
|
|
||||||
//label (switch framebuffer)
|
//label (switch framebuffer)
|
||||||
Button switchFramebufferButton = new Button();
|
Button switchFramebufferButton = Button.createButton("Switch Active Framebuffer", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label switchFramebufferLabel = Label.createLabel("Switch Active Framebuffer");
|
|
||||||
switchFramebufferButton.addChild(switchFramebufferLabel);
|
|
||||||
scrollable.addChild(switchFramebufferButton);
|
|
||||||
switchFramebufferButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
RenderingEngine.incrementOutputFramebuffer();
|
RenderingEngine.incrementOutputFramebuffer();
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
switchFramebufferButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
switchFramebufferButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(switchFramebufferButton);
|
||||||
|
|
||||||
//label (toggle draw client collision spheres)
|
//label (toggle draw client collision spheres)
|
||||||
Button toggleClientCollisionSpheresButton = new Button();
|
Button toggleClientCollisionSpheresButton = Button.createButton("Toggle draw client collision spheres", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label toggleClientCollisionSpheresLabel = Label.createLabel("Toggle draw client collision spheres");
|
|
||||||
toggleClientCollisionSpheresButton.addChild(toggleClientCollisionSpheresLabel);
|
|
||||||
scrollable.addChild(toggleClientCollisionSpheresButton);
|
|
||||||
toggleClientCollisionSpheresButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresClient(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresClient());
|
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresClient(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresClient());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
toggleClientCollisionSpheresButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
toggleClientCollisionSpheresButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(toggleClientCollisionSpheresButton);
|
||||||
|
|
||||||
//label (toggle draw server collision spheres)
|
//label (toggle draw server collision spheres)
|
||||||
Button toggleServerCollisionSpheresButton = new Button();
|
Button toggleServerCollisionSpheresButton = Button.createButton("Toggle draw server collision spheres", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label toggleServerCollisionSpheresLabel = Label.createLabel("Toggle draw server collision spheres");
|
|
||||||
toggleServerCollisionSpheresButton.addChild(toggleServerCollisionSpheresLabel);
|
|
||||||
scrollable.addChild(toggleServerCollisionSpheresButton);
|
|
||||||
toggleServerCollisionSpheresButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresServer(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresServer());
|
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresServer(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresServer());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
toggleServerCollisionSpheresButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
toggleServerCollisionSpheresButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(toggleServerCollisionSpheresButton);
|
||||||
|
|
||||||
//label (toggle draw physics objects)
|
//label (toggle draw physics objects)
|
||||||
Button togglePhysicsObjectsButton = new Button();
|
Button togglePhysicsObjectsButton = Button.createButton("Toggle draw physics objects", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label togglePhysicsObjectsLabel = Label.createLabel("Toggle draw physics objects");
|
|
||||||
togglePhysicsObjectsButton.addChild(togglePhysicsObjectsLabel);
|
|
||||||
scrollable.addChild(togglePhysicsObjectsButton);
|
|
||||||
togglePhysicsObjectsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.userSettings.setGraphicsDebugDrawPhysicsObjects(!Globals.userSettings.graphicsDebugDrawPhysicsObjects());
|
Globals.userSettings.setGraphicsDebugDrawPhysicsObjects(!Globals.userSettings.graphicsDebugDrawPhysicsObjects());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
togglePhysicsObjectsButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
togglePhysicsObjectsButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(togglePhysicsObjectsButton);
|
||||||
|
|
||||||
//label (toggle draw movement vectors)
|
//label (toggle draw movement vectors)
|
||||||
Button toggleMovementVectorsButton = new Button();
|
Button toggleMovementVectorsButton = Button.createButton("Toggle draw movement vectors", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label toggleMovementVectorsLabel = Label.createLabel("Toggle draw movement vectors");
|
|
||||||
toggleMovementVectorsButton.addChild(toggleMovementVectorsLabel);
|
|
||||||
scrollable.addChild(toggleMovementVectorsButton);
|
|
||||||
toggleMovementVectorsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.userSettings.setGraphicsDebugDrawMovementVectors(!Globals.userSettings.graphicsDebugDrawMovementVectors());
|
Globals.userSettings.setGraphicsDebugDrawMovementVectors(!Globals.userSettings.graphicsDebugDrawMovementVectors());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
toggleMovementVectorsButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
toggleMovementVectorsButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(toggleMovementVectorsButton);
|
||||||
|
|
||||||
//label (toggle draw navmesh)
|
//label (toggle draw navmesh)
|
||||||
Button toggleNavmeshButton = new Button();
|
Button toggleNavmeshButton = Button.createButton("Toggle draw navmesh", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
Label toggleNavmeshLabel = Label.createLabel("Toggle draw navmesh");
|
|
||||||
toggleNavmeshButton.addChild(toggleNavmeshLabel);
|
|
||||||
scrollable.addChild(toggleNavmeshButton);
|
|
||||||
toggleNavmeshButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
Globals.userSettings.setGraphicsDebugDrawNavmesh(!Globals.userSettings.graphicsDebugDrawNavmesh());
|
Globals.userSettings.setGraphicsDebugDrawNavmesh(!Globals.userSettings.graphicsDebugDrawNavmesh());
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
toggleNavmeshButton.setMarginTop(BUTTON_MARGIN);
|
||||||
|
toggleNavmeshButton.setMarginLeft(BUTTON_MARGIN);
|
||||||
|
scrollable.addChild(toggleNavmeshButton);
|
||||||
|
|
||||||
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the in-game character appearance slider menu
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Window createInGameCharacterSliderMenu(){
|
public static Window createInGameCharacterSliderMenu(){
|
||||||
int width = 500;
|
int width = 500;
|
||||||
int height = 500;
|
int height = 500;
|
||||||
|
|||||||
@ -25,10 +25,30 @@ import electrosphere.renderer.ui.frame.UIFrameUtils;
|
|||||||
*/
|
*/
|
||||||
public class Button extends StandardContainerElement implements DrawableElement, FocusableElement, ClickableElement, HoverableElement {
|
public class Button extends StandardContainerElement implements DrawableElement, FocusableElement, ClickableElement, HoverableElement {
|
||||||
|
|
||||||
static Vector3f COLOR_DEFAULT = new Vector3f(1.0f);
|
/**
|
||||||
|
* Color for when the button is focused
|
||||||
|
*/
|
||||||
|
static Vector3f COLOR_FOCUSED = new Vector3f(0.97f,0.97f,0.98f);
|
||||||
|
|
||||||
static float COLOR_FRAME_FOCUSED_DEFAULT = 0.1f;
|
/**
|
||||||
static float COLOR_FRAME_UNFOCUSED_DEFAULT = 0.01f;
|
* Color for when the button is unfocused
|
||||||
|
*/
|
||||||
|
static Vector3f COLOR_UNFOCUSED = new Vector3f(0.42f,0.46f,0.49f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default button color
|
||||||
|
*/
|
||||||
|
static Vector3f COLOR_DEFAULT = new Vector3f(COLOR_UNFOCUSED);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default color for focused frame
|
||||||
|
*/
|
||||||
|
static Vector3f COLOR_FRAME_FOCUSED_DEFAULT = new Vector3f(0.914f, 0.925f, 0.937f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default color for unfocused frame
|
||||||
|
*/
|
||||||
|
static Vector3f COLOR_FRAME_UNFOCUSED_DEFAULT = new Vector3f(0.089f, 0.105f, 0.121f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default padding applied to buttons
|
* Default padding applied to buttons
|
||||||
@ -88,8 +108,13 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
*/
|
*/
|
||||||
public static Button createButton(String text, ClickableElement.ClickEventCallback callback){
|
public static Button createButton(String text, ClickableElement.ClickEventCallback callback){
|
||||||
Button rVal = new Button();
|
Button rVal = new Button();
|
||||||
|
rVal.setPaddingTop(DEFAULT_PADDING);
|
||||||
|
rVal.setPaddingRight(DEFAULT_PADDING);
|
||||||
|
rVal.setPaddingLeft(DEFAULT_PADDING);
|
||||||
|
rVal.setPaddingBottom(DEFAULT_PADDING);
|
||||||
Label rValLabel = Label.createLabel(text);
|
Label rValLabel = Label.createLabel(text);
|
||||||
rValLabel.setText(text);
|
rValLabel.setText(text);
|
||||||
|
rValLabel.setColor(rVal.color);
|
||||||
rVal.addChild(rValLabel);
|
rVal.addChild(rValLabel);
|
||||||
rVal.setOnClick(callback);
|
rVal.setOnClick(callback);
|
||||||
rVal.setAlignSelf(YogaAlignment.Start);
|
rVal.setAlignSelf(YogaAlignment.Start);
|
||||||
@ -110,6 +135,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
rVal.setPaddingBottom(DEFAULT_PADDING);
|
rVal.setPaddingBottom(DEFAULT_PADDING);
|
||||||
Label rValLabel = Label.createLabel(text);
|
Label rValLabel = Label.createLabel(text);
|
||||||
rValLabel.setText(text);
|
rValLabel.setText(text);
|
||||||
|
rValLabel.setColor(rVal.color);
|
||||||
rVal.addChild(rValLabel);
|
rVal.addChild(rValLabel);
|
||||||
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
callback.run();
|
callback.run();
|
||||||
@ -136,6 +162,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
rVal.setPaddingBottom(DEFAULT_PADDING);
|
rVal.setPaddingBottom(DEFAULT_PADDING);
|
||||||
Label rValLabel = Label.createLabel(text);
|
Label rValLabel = Label.createLabel(text);
|
||||||
rValLabel.setText(text);
|
rValLabel.setText(text);
|
||||||
|
rValLabel.setColor(rVal.color);
|
||||||
rVal.addChild(rValLabel);
|
rVal.addChild(rValLabel);
|
||||||
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
callback.run();
|
callback.run();
|
||||||
@ -163,6 +190,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
rVal.setPaddingBottom(DEFAULT_PADDING);
|
rVal.setPaddingBottom(DEFAULT_PADDING);
|
||||||
Label rValLabel = Label.createLabel(text, fontSize);
|
Label rValLabel = Label.createLabel(text, fontSize);
|
||||||
rValLabel.setText(text);
|
rValLabel.setText(text);
|
||||||
|
rValLabel.setColor(rVal.color);
|
||||||
rVal.addChild(rValLabel);
|
rVal.addChild(rValLabel);
|
||||||
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
callback.run();
|
callback.run();
|
||||||
@ -188,14 +216,14 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
return focused;
|
return focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onFocus(FocusEvent event) {
|
private void onFocus(FocusEvent event) {
|
||||||
if(onFocusCallback != null){
|
if(onFocusCallback != null){
|
||||||
onFocusCallback.execute(event);
|
onFocusCallback.execute(event);
|
||||||
} else {
|
} else {
|
||||||
for(Element child : childList){
|
for(Element child : childList){
|
||||||
if(child instanceof Label){
|
if(child instanceof Label){
|
||||||
Label childLabel = (Label) child;
|
Label childLabel = (Label) child;
|
||||||
childLabel.setColor(new Vector3f(1,0,0));
|
childLabel.setColor(new Vector3f(COLOR_UNFOCUSED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +236,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
for(Element child : childList){
|
for(Element child : childList){
|
||||||
if(child instanceof Label){
|
if(child instanceof Label){
|
||||||
Label childLabel = (Label) child;
|
Label childLabel = (Label) child;
|
||||||
childLabel.setColor(new Vector3f(1,1,1));
|
childLabel.setColor(new Vector3f(COLOR_UNFOCUSED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,19 +246,19 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
* Default hover event handling
|
* Default hover event handling
|
||||||
* @param event the hover event
|
* @param event the hover event
|
||||||
*/
|
*/
|
||||||
void onHoverEvent(HoverEvent event){
|
private void onHoverEvent(HoverEvent event){
|
||||||
if(event.isHovered()){
|
if(event.isHovered()){
|
||||||
for(Element child : childList){
|
for(Element child : childList){
|
||||||
if(child instanceof Label){
|
if(child instanceof Label){
|
||||||
Label childLabel = (Label) child;
|
Label childLabel = (Label) child;
|
||||||
childLabel.setColor(new Vector3f(1,0,0));
|
childLabel.setColor(new Vector3f(COLOR_FOCUSED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(Element child : childList){
|
for(Element child : childList){
|
||||||
if(child instanceof Label){
|
if(child instanceof Label){
|
||||||
Label childLabel = (Label) child;
|
Label childLabel = (Label) child;
|
||||||
childLabel.setColor(new Vector3f(1,1,1));
|
childLabel.setColor(new Vector3f(COLOR_UNFOCUSED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,10 +344,10 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
FocusEvent focusEvent = (FocusEvent) event;
|
FocusEvent focusEvent = (FocusEvent) event;
|
||||||
if(focusEvent.isFocused()){
|
if(focusEvent.isFocused()){
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
onFocus(focusEvent);
|
this.onFocus(focusEvent);
|
||||||
} else {
|
} else {
|
||||||
this.focused = false;
|
this.focused = false;
|
||||||
onLoseFocus(focusEvent);
|
this.onLoseFocus(focusEvent);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -333,7 +361,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
hoverEventCallback.execute((HoverEvent)event);
|
hoverEventCallback.execute((HoverEvent)event);
|
||||||
} else {
|
} else {
|
||||||
//default hover handling
|
//default hover handling
|
||||||
onHoverEvent((HoverEvent)event);
|
this.onHoverEvent((HoverEvent)event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -31,6 +31,11 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class TextInput extends StandardContainerElement implements DrawableElement, FocusableElement, KeyEventElement, ClickableElement, ValueElement {
|
public class TextInput extends StandardContainerElement implements DrawableElement, FocusableElement, KeyEventElement, ClickableElement, ValueElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default padding applied to text inputs
|
||||||
|
*/
|
||||||
|
static final int DEFAULT_PADDING = Button.DEFAULT_PADDING;
|
||||||
|
|
||||||
Vector3f backgroundColor = new Vector3f(0.2f,0.2f,0.2f);
|
Vector3f backgroundColor = new Vector3f(0.2f,0.2f,0.2f);
|
||||||
|
|
||||||
Vector3f boxPosition = new Vector3f();
|
Vector3f boxPosition = new Vector3f();
|
||||||
@ -87,7 +92,6 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
|||||||
this.color = new Vector3f(1,1,1);
|
this.color = new Vector3f(1,1,1);
|
||||||
this.setHeight((int)(font.getFontHeight() * fontSize));
|
this.setHeight((int)(font.getFontHeight() * fontSize));
|
||||||
Yoga.YGNodeStyleSetFlexDirection(this.yogaNode, Yoga.YGFlexDirectionRow);
|
Yoga.YGNodeStyleSetFlexDirection(this.yogaNode, Yoga.YGFlexDirectionRow);
|
||||||
Yoga.YGNodeStyleSetMinHeight(this.yogaNode, font.getFontHeight() * fontSize);
|
|
||||||
Yoga.YGNodeStyleSetMinWidth(this.yogaNode, 1);
|
Yoga.YGNodeStyleSetMinWidth(this.yogaNode, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,13 +103,16 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
|||||||
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
|
||||||
}
|
}
|
||||||
this.clearChildren();
|
this.clearChildren();
|
||||||
|
int accumulatingWidth = 0;
|
||||||
for(int i = 0; i < text.length(); i++){
|
for(int i = 0; i < text.length(); i++){
|
||||||
char toDraw = text.charAt(i);
|
char toDraw = text.charAt(i);
|
||||||
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);
|
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);
|
||||||
BitmapCharacter newLetter = new BitmapCharacter(this.font,(int)(bitMapDimension.x * fontSize), this.getHeight(), fontSize, toDraw);
|
BitmapCharacter newLetter = new BitmapCharacter(this.font,(int)(bitMapDimension.x * fontSize), this.getHeight(), fontSize, toDraw);
|
||||||
|
accumulatingWidth += bitMapDimension.x * fontSize;
|
||||||
newLetter.setColor(color);
|
newLetter.setColor(color);
|
||||||
this.addChild(newLetter);
|
this.addChild(newLetter);
|
||||||
}
|
}
|
||||||
|
Yoga.YGNodeStyleSetWidth(yogaNode, accumulatingWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String text){
|
public void setText(String text){
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import electrosphere.renderer.ui.elementtypes.Element;
|
|||||||
import electrosphere.renderer.ui.elementtypes.NavigableElement;
|
import electrosphere.renderer.ui.elementtypes.NavigableElement;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
import electrosphere.renderer.ui.events.NavigationEvent;
|
import electrosphere.renderer.ui.events.NavigationEvent;
|
||||||
|
import electrosphere.renderer.ui.frame.UIFrameUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A window
|
* A window
|
||||||
@ -35,7 +36,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
/**
|
/**
|
||||||
* The color of the window
|
* The color of the window
|
||||||
*/
|
*/
|
||||||
Vector3f color = new Vector3f(1.0f);
|
Vector3f color = new Vector3f(0.1f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The child elements of this window
|
* The child elements of this window
|
||||||
@ -240,14 +241,19 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
|
|
||||||
//render background of window
|
//render background of window
|
||||||
if(planeModel != null && windowFrame != null && showDecorations){
|
if(planeModel != null && windowFrame != null && showDecorations){
|
||||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
UIFrameUtils.drawFrame(
|
||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, color, 48, 12,
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
framebuffer, framebufferPosX, framebufferPosY
|
||||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
);
|
||||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
// planeModel.prawUI(ushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
// planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.drawUI();
|
// planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
|
// planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
// planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
|
// customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||||
|
// planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
|
// planeModel.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
//render content of window
|
//render content of window
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user