ui work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-04-10 23:30:12 -04:00
parent 4aae7b68b8
commit 5c6dbe8f1b
5 changed files with 196 additions and 117 deletions

View File

@ -1456,6 +1456,9 @@ Script cache busting on file modification
Block cursor
Rename editor enum to prevent type conflict
(04/10/2025)
UI work

View File

@ -35,18 +35,33 @@ import electrosphere.renderer.ui.events.NavigationEvent;
import electrosphere.renderer.ui.events.ValueChangeEvent;
import electrosphere.server.saves.SaveUtils;
/**
* Menu generators for in game menus
*/
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
* @return The window for the menu
*/
public static Window createInGameMainMenu(){
// int screenTop = Globals.WINDOW_HEIGHT - 150;
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;
Window rVal = Window.createExpandableCenterAligned(Globals.renderingEngine.getOpenGLState(), WINDOW_WIDTH, WINDOW_HEIGHT);
Div div = Div.createDiv();
rVal.addChild(div);
div.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
@ -62,42 +77,70 @@ public class MenuGeneratorsInGame {
}});
//Back
div.addChild(Button.createButton("Back", () -> {
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(Globals.cameraHandler.getTrackPlayerEntity()){
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
} else {
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_FREE_CAMERA);
}
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
}));
{
Button button = Button.createButton("Back", () -> {
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(Globals.cameraHandler.getTrackPlayerEntity()){
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
} else {
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_FREE_CAMERA);
}
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
});
button.setMarginTop(BUTTON_MARGIN);
button.setMarginLeft(BUTTON_MARGIN);
div.addChild(button);
}
//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
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
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
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()){
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());
}));
});
button.setMarginTop(BUTTON_MARGIN);
button.setMarginLeft(BUTTON_MARGIN);
div.addChild(button);
}
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
@ -105,29 +148,28 @@ public class MenuGeneratorsInGame {
return rVal;
}
/**
* Creates the debug menu
* @return
*/
public static Window createInGameDebugMainMenu(){
// int screenTop = Globals.WINDOW_HEIGHT - 150;
int width = 500;
int height = 500;
Window rVal = Window.create(Globals.renderingEngine.getOpenGLState(), 0, 0, width, height, true);
Window rVal = Window.createExpandableCenterAligned(Globals.renderingEngine.getOpenGLState(), WINDOW_WIDTH, WINDOW_HEIGHT);
VirtualScrollable scrollable = new VirtualScrollable(width, height);
VirtualScrollable scrollable = new VirtualScrollable(WINDOW_WIDTH, WINDOW_HEIGHT);
rVal.addChild(scrollable);
// scrollable.addChild(div);
rVal.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
return false;
}});
//label 1 (back)
Button backButton = new Button();
Label backLabel = Label.createLabel("Back");
backButton.addChild(backLabel);
scrollable.addChild(backButton);
backButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button backButton = Button.createButton("Back", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameMainMenu());
return false;
}});
backButton.setMarginTop(BUTTON_MARGIN);
backButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(backButton);
//text entry (port)
@ -136,11 +178,7 @@ public class MenuGeneratorsInGame {
modelDebugInput.setText("Model path goes here");
//label 3 (load model and debug)
Button debugModelButton = new Button();
Label debugModelLabel = Label.createLabel("Print Model Debug Info");
debugModelButton.addChild(debugModelLabel);
scrollable.addChild(debugModelButton);
debugModelButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button debugModelButton = Button.createButton("Print Model Debug Info", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Model targetModel = null;
if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){
@ -154,35 +192,32 @@ public class MenuGeneratorsInGame {
}
return false;
}});
debugModelButton.setMarginTop(BUTTON_MARGIN);
debugModelButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(debugModelButton);
//label 4 (reload all shaders)
Button reloadShaderButton = new Button();
Label reloadShaderLabel = Label.createLabel("Reload all shaders");
reloadShaderButton.addChild(reloadShaderLabel);
scrollable.addChild(reloadShaderButton);
reloadShaderButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button reloadShaderButton = Button.createButton("Reload all shaders", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.assetManager.forceReloadAllShaders();
return false;
}});
reloadShaderButton.setMarginTop(BUTTON_MARGIN);
reloadShaderButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(reloadShaderButton);
//reload all models
Button reloadModelButton = new Button();
Label reloadModelLabel = Label.createLabel("Reload all models");
reloadModelButton.addChild(reloadModelLabel);
scrollable.addChild(reloadModelButton);
reloadModelButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button reloadModelButton = Button.createButton("Reload all models", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.assetManager.forceReloadAllModels();
return false;
}});
reloadModelButton.setMarginTop(BUTTON_MARGIN);
reloadModelButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(reloadModelButton);
//disable drawing player character
Button toggleDrawPlayerButton = new Button();
Label toggleDrawPlayerLabel = Label.createLabel("Toggle draw character");
toggleDrawPlayerButton.addChild(toggleDrawPlayerLabel);
scrollable.addChild(toggleDrawPlayerButton);
toggleDrawPlayerButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button toggleDrawPlayerButton = Button.createButton("Toggle draw character", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
if(Globals.playerEntity != null){
if(Globals.playerEntity.containsKey(EntityDataStrings.DATA_STRING_DRAW)){
@ -196,88 +231,88 @@ public class MenuGeneratorsInGame {
}
return false;
}});
toggleDrawPlayerButton.setMarginTop(BUTTON_MARGIN);
toggleDrawPlayerButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(toggleDrawPlayerButton);
//pull up character editor
Button characterSliderMenuButton = new Button();
Label characterSliderMenuLabel = Label.createLabel("Character slider menu");
characterSliderMenuButton.addChild(characterSliderMenuLabel);
scrollable.addChild(characterSliderMenuButton);
characterSliderMenuButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button characterSliderMenuButton = Button.createButton("Character slider menu", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
WindowUtils.replaceWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, createInGameCharacterSliderMenu());
return false;
}});
characterSliderMenuButton.setMarginTop(BUTTON_MARGIN);
characterSliderMenuButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(characterSliderMenuButton);
//label (switch framebuffer)
Button switchFramebufferButton = new Button();
Label switchFramebufferLabel = Label.createLabel("Switch Active Framebuffer");
switchFramebufferButton.addChild(switchFramebufferLabel);
scrollable.addChild(switchFramebufferButton);
switchFramebufferButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button switchFramebufferButton = Button.createButton("Switch Active Framebuffer", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
RenderingEngine.incrementOutputFramebuffer();
return false;
}});
switchFramebufferButton.setMarginTop(BUTTON_MARGIN);
switchFramebufferButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(switchFramebufferButton);
//label (toggle draw client collision spheres)
Button toggleClientCollisionSpheresButton = new Button();
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){
Button toggleClientCollisionSpheresButton = Button.createButton("Toggle draw client collision spheres", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresClient(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresClient());
return false;
}});
toggleClientCollisionSpheresButton.setMarginTop(BUTTON_MARGIN);
toggleClientCollisionSpheresButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(toggleClientCollisionSpheresButton);
//label (toggle draw server collision spheres)
Button toggleServerCollisionSpheresButton = new Button();
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){
Button toggleServerCollisionSpheresButton = Button.createButton("Toggle draw server collision spheres", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.userSettings.setGraphicsDebugDrawCollisionSpheresServer(!Globals.userSettings.getGraphicsDebugDrawCollisionSpheresServer());
return false;
}});
toggleServerCollisionSpheresButton.setMarginTop(BUTTON_MARGIN);
toggleServerCollisionSpheresButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(toggleServerCollisionSpheresButton);
//label (toggle draw physics objects)
Button togglePhysicsObjectsButton = new Button();
Label togglePhysicsObjectsLabel = Label.createLabel("Toggle draw physics objects");
togglePhysicsObjectsButton.addChild(togglePhysicsObjectsLabel);
scrollable.addChild(togglePhysicsObjectsButton);
togglePhysicsObjectsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button togglePhysicsObjectsButton = Button.createButton("Toggle draw physics objects", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.userSettings.setGraphicsDebugDrawPhysicsObjects(!Globals.userSettings.graphicsDebugDrawPhysicsObjects());
return false;
}});
togglePhysicsObjectsButton.setMarginTop(BUTTON_MARGIN);
togglePhysicsObjectsButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(togglePhysicsObjectsButton);
//label (toggle draw movement vectors)
Button toggleMovementVectorsButton = new Button();
Label toggleMovementVectorsLabel = Label.createLabel("Toggle draw movement vectors");
toggleMovementVectorsButton.addChild(toggleMovementVectorsLabel);
scrollable.addChild(toggleMovementVectorsButton);
toggleMovementVectorsButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button toggleMovementVectorsButton = Button.createButton("Toggle draw movement vectors", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.userSettings.setGraphicsDebugDrawMovementVectors(!Globals.userSettings.graphicsDebugDrawMovementVectors());
return false;
}});
toggleMovementVectorsButton.setMarginTop(BUTTON_MARGIN);
toggleMovementVectorsButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(toggleMovementVectorsButton);
//label (toggle draw navmesh)
Button toggleNavmeshButton = new Button();
Label toggleNavmeshLabel = Label.createLabel("Toggle draw navmesh");
toggleNavmeshButton.addChild(toggleNavmeshLabel);
scrollable.addChild(toggleNavmeshButton);
toggleNavmeshButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Button toggleNavmeshButton = Button.createButton("Toggle draw navmesh", new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
// Main.running = false;
Globals.userSettings.setGraphicsDebugDrawNavmesh(!Globals.userSettings.graphicsDebugDrawNavmesh());
return false;
}});
toggleNavmeshButton.setMarginTop(BUTTON_MARGIN);
toggleNavmeshButton.setMarginLeft(BUTTON_MARGIN);
scrollable.addChild(toggleNavmeshButton);
Globals.signalSystem.post(SignalType.YOGA_APPLY,rVal);
return rVal;
}
/**
* Creates the in-game character appearance slider menu
* @return
*/
public static Window createInGameCharacterSliderMenu(){
int width = 500;
int height = 500;

View File

@ -25,10 +25,30 @@ import electrosphere.renderer.ui.frame.UIFrameUtils;
*/
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
@ -88,8 +108,13 @@ public class Button extends StandardContainerElement implements DrawableElement,
*/
public static Button createButton(String text, ClickableElement.ClickEventCallback callback){
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);
rValLabel.setText(text);
rValLabel.setColor(rVal.color);
rVal.addChild(rValLabel);
rVal.setOnClick(callback);
rVal.setAlignSelf(YogaAlignment.Start);
@ -110,6 +135,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
rVal.setPaddingBottom(DEFAULT_PADDING);
Label rValLabel = Label.createLabel(text);
rValLabel.setText(text);
rValLabel.setColor(rVal.color);
rVal.addChild(rValLabel);
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
callback.run();
@ -136,6 +162,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
rVal.setPaddingBottom(DEFAULT_PADDING);
Label rValLabel = Label.createLabel(text);
rValLabel.setText(text);
rValLabel.setColor(rVal.color);
rVal.addChild(rValLabel);
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
callback.run();
@ -163,6 +190,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
rVal.setPaddingBottom(DEFAULT_PADDING);
Label rValLabel = Label.createLabel(text, fontSize);
rValLabel.setText(text);
rValLabel.setColor(rVal.color);
rVal.addChild(rValLabel);
rVal.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
callback.run();
@ -188,14 +216,14 @@ public class Button extends StandardContainerElement implements DrawableElement,
return focused;
}
void onFocus(FocusEvent event) {
private void onFocus(FocusEvent event) {
if(onFocusCallback != null){
onFocusCallback.execute(event);
} else {
for(Element child : childList){
if(child instanceof Label){
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){
if(child instanceof Label){
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
* @param event the hover event
*/
void onHoverEvent(HoverEvent event){
private void onHoverEvent(HoverEvent event){
if(event.isHovered()){
for(Element child : childList){
if(child instanceof Label){
Label childLabel = (Label) child;
childLabel.setColor(new Vector3f(1,0,0));
childLabel.setColor(new Vector3f(COLOR_FOCUSED));
}
}
} else {
for(Element child : childList){
if(child instanceof Label){
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;
if(focusEvent.isFocused()){
this.focused = true;
onFocus(focusEvent);
this.onFocus(focusEvent);
} else {
this.focused = false;
onLoseFocus(focusEvent);
this.onLoseFocus(focusEvent);
}
return false;
}
@ -333,7 +361,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
hoverEventCallback.execute((HoverEvent)event);
} else {
//default hover handling
onHoverEvent((HoverEvent)event);
this.onHoverEvent((HoverEvent)event);
}
}
return true;

View File

@ -31,6 +31,11 @@ import java.util.regex.Pattern;
*/
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 boxPosition = new Vector3f();
@ -87,7 +92,6 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
this.color = new Vector3f(1,1,1);
this.setHeight((int)(font.getFontHeight() * fontSize));
Yoga.YGNodeStyleSetFlexDirection(this.yogaNode, Yoga.YGFlexDirectionRow);
Yoga.YGNodeStyleSetMinHeight(this.yogaNode, font.getFontHeight() * fontSize);
Yoga.YGNodeStyleSetMinWidth(this.yogaNode, 1);
}
@ -99,13 +103,16 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
Globals.signalSystem.post(SignalType.YOGA_DESTROY, el);
}
this.clearChildren();
int accumulatingWidth = 0;
for(int i = 0; i < text.length(); i++){
char toDraw = text.charAt(i);
Vector3f bitMapDimension = this.font.getDimensionOfCharacterDiscrete(toDraw);
BitmapCharacter newLetter = new BitmapCharacter(this.font,(int)(bitMapDimension.x * fontSize), this.getHeight(), fontSize, toDraw);
accumulatingWidth += bitMapDimension.x * fontSize;
newLetter.setColor(color);
this.addChild(newLetter);
}
Yoga.YGNodeStyleSetWidth(yogaNode, accumulatingWidth);
}
public void setText(String text){

View File

@ -26,6 +26,7 @@ import electrosphere.renderer.ui.elementtypes.Element;
import electrosphere.renderer.ui.elementtypes.NavigableElement;
import electrosphere.renderer.ui.events.Event;
import electrosphere.renderer.ui.events.NavigationEvent;
import electrosphere.renderer.ui.frame.UIFrameUtils;
/**
* A window
@ -35,7 +36,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
/**
* The color of the window
*/
Vector3f color = new Vector3f(1.0f);
Vector3f color = new Vector3f(0.1f);
/**
* The child elements of this window
@ -240,14 +241,19 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
//render background of window
if(planeModel != null && windowFrame != null && showDecorations){
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
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.drawUI();
UIFrameUtils.drawFrame(
AssetDataStrings.UI_FRAME_TEXTURE_DEFAULT_3, color, 48, 12,
this.getAbsoluteX(), this.getAbsoluteY(), this.getWidth(), this.getHeight(),
framebuffer, framebufferPosX, framebufferPosY
);
// planeModel.prawUI(ushUniformToMesh("plane", "mPosition", boxPosition);
// planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
// 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