toggle ui element
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
b18a09ef3e
commit
9aa7cfe048
@ -4,9 +4,13 @@ out vec4 FragColor;
|
|||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
|
|
||||||
uniform sampler2D screenTexture;
|
uniform sampler2D screenTexture;
|
||||||
|
uniform vec3 color;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
vec4 textureColor = texture(screenTexture, TexCoords);
|
vec4 textureColor = texture(screenTexture, TexCoords);
|
||||||
|
textureColor.r = textureColor.r * color.r;
|
||||||
|
textureColor.g = textureColor.g * color.g;
|
||||||
|
textureColor.b = textureColor.b * color.b;
|
||||||
if(textureColor.a < 0.1){
|
if(textureColor.a < 0.1){
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
assets/Textures/ui/circle.png
Normal file
BIN
assets/Textures/ui/circle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
assets/Textures/ui/square.png
Normal file
BIN
assets/Textures/ui/square.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Fri Jul 12 17:55:57 EDT 2024
|
#Sat Jul 13 22:48:57 EDT 2024
|
||||||
buildNumber=183
|
buildNumber=185
|
||||||
|
|||||||
@ -40,7 +40,6 @@ import electrosphere.game.config.UserSettings;
|
|||||||
import electrosphere.game.data.voxel.VoxelType;
|
import electrosphere.game.data.voxel.VoxelType;
|
||||||
import electrosphere.game.server.structure.virtual.StructureManager;
|
import electrosphere.game.server.structure.virtual.StructureManager;
|
||||||
import electrosphere.game.server.world.MacroData;
|
import electrosphere.game.server.world.MacroData;
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.menu.WindowUtils;
|
import electrosphere.menu.WindowUtils;
|
||||||
import electrosphere.net.client.ClientNetworking;
|
import electrosphere.net.client.ClientNetworking;
|
||||||
@ -66,16 +65,13 @@ import electrosphere.renderer.ui.elements.ImagePanel;
|
|||||||
import electrosphere.renderer.ui.font.FontManager;
|
import electrosphere.renderer.ui.font.FontManager;
|
||||||
import electrosphere.script.ScriptEngine;
|
import electrosphere.script.ScriptEngine;
|
||||||
import electrosphere.server.ai.AIManager;
|
import electrosphere.server.ai.AIManager;
|
||||||
import electrosphere.server.content.ServerContentManager;
|
|
||||||
import electrosphere.server.datacell.EntityDataCellMapper;
|
import electrosphere.server.datacell.EntityDataCellMapper;
|
||||||
import electrosphere.server.datacell.RealmManager;
|
import electrosphere.server.datacell.RealmManager;
|
||||||
import electrosphere.server.db.DatabaseController;
|
import electrosphere.server.db.DatabaseController;
|
||||||
import electrosphere.server.fluid.manager.ServerFluidManager;
|
|
||||||
import electrosphere.server.pathfinding.NavMeshManager;
|
import electrosphere.server.pathfinding.NavMeshManager;
|
||||||
import electrosphere.server.saves.Save;
|
import electrosphere.server.saves.Save;
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
import electrosphere.server.simulation.MicroSimulation;
|
import electrosphere.server.simulation.MicroSimulation;
|
||||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,10 +243,10 @@ public class Globals {
|
|||||||
public static String textureSpecularDefault;
|
public static String textureSpecularDefault;
|
||||||
public static Material materialDefault;
|
public static Material materialDefault;
|
||||||
|
|
||||||
public static String blackTexture;
|
public static String blackTexture = "Textures/b1.png";
|
||||||
public static String testingTexture;
|
public static String testingTexture = "Textures/Testing1.png";
|
||||||
public static String whiteTexture;
|
public static String whiteTexture = "Textures/w1.png";
|
||||||
public static String offWhiteTexture;
|
public static String offWhiteTexture = "Textures/ow1.png";
|
||||||
|
|
||||||
public static String imagePlaneModelID;
|
public static String imagePlaneModelID;
|
||||||
public static String solidPlaneModelID;
|
public static String solidPlaneModelID;
|
||||||
@ -407,7 +403,9 @@ public class Globals {
|
|||||||
public static NetMonitor netMonitor;
|
public static NetMonitor netMonitor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits globals
|
||||||
|
*/
|
||||||
public static void initGlobals(){
|
public static void initGlobals(){
|
||||||
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
||||||
//timekeeper
|
//timekeeper
|
||||||
@ -463,6 +461,9 @@ public class Globals {
|
|||||||
profiler = new Profiler();
|
profiler = new Profiler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits default audio resources
|
||||||
|
*/
|
||||||
public static void initDefaultAudioResources(){
|
public static void initDefaultAudioResources(){
|
||||||
LoggerInterface.loggerStartup.INFO("Loading default audio resources");
|
LoggerInterface.loggerStartup.INFO("Loading default audio resources");
|
||||||
Globals.assetManager.addAudioPathToQueue("/Audio/inventoryGrabItem.ogg");
|
Globals.assetManager.addAudioPathToQueue("/Audio/inventoryGrabItem.ogg");
|
||||||
@ -472,32 +473,45 @@ public class Globals {
|
|||||||
Globals.assetManager.addAudioPathToQueue("/Audio/ambienceWind1SeamlessMono.ogg");
|
Globals.assetManager.addAudioPathToQueue("/Audio/ambienceWind1SeamlessMono.ogg");
|
||||||
Globals.assetManager.loadAssetsInQueue();
|
Globals.assetManager.loadAssetsInQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Texture paths to be loaded when renderer inits
|
||||||
|
*/
|
||||||
|
private static String[] defaultTexturePaths = new String[]{
|
||||||
|
"Textures/default_diffuse.png",
|
||||||
|
"Textures/default_specular.png",
|
||||||
|
"Textures/b1.png",
|
||||||
|
"Textures/w1.png",
|
||||||
|
"Textures/ow1.png",
|
||||||
|
"Textures/ui/WindowBorder.png",
|
||||||
|
"Textures/ui/uiFrame1.png",
|
||||||
|
"Textures/ui/uiFrame2.png",
|
||||||
|
"Textures/ui/circle.png",
|
||||||
|
"Textures/ui/square.png",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits default graphical resources
|
||||||
|
*/
|
||||||
public static void initDefaultGraphicalResources(){
|
public static void initDefaultGraphicalResources(){
|
||||||
LoggerInterface.loggerStartup.INFO("Loading default graphical resources");
|
LoggerInterface.loggerStartup.INFO("Loading default graphical resources");
|
||||||
//create default textures
|
|
||||||
Globals.assetManager.addTexturePathtoQueue("Textures/default_diffuse.png");
|
//load default textures
|
||||||
Globals.assetManager.addTexturePathtoQueue("Textures/default_specular.png");
|
for(String defaultTexturePath: defaultTexturePaths){
|
||||||
|
Globals.assetManager.addTexturePathtoQueue(defaultTexturePath);
|
||||||
|
}
|
||||||
|
|
||||||
//create default material
|
//create default material
|
||||||
materialDefault = new Material();
|
materialDefault = new Material();
|
||||||
materialDefault.set_diffuse("Textures/default_diffuse.png");
|
materialDefault.set_diffuse("Textures/default_diffuse.png");
|
||||||
materialDefault.set_specular("Textures/default_specular.png");
|
materialDefault.set_specular("Textures/default_specular.png");
|
||||||
//create default lights
|
|
||||||
//create font manager
|
//create font manager
|
||||||
fontManager = new FontManager();
|
fontManager = new FontManager();
|
||||||
fontManager.loadFonts();
|
fontManager.loadFonts();
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
assetManager.registerModelToSpecificString(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
||||||
//particle billboard model
|
//particle billboard model
|
||||||
particleBillboardModel = assetManager.registerModel(RenderUtils.createParticleModel());
|
particleBillboardModel = assetManager.registerModel(RenderUtils.createParticleModel());
|
||||||
//black texture for backgrouns
|
|
||||||
blackTexture = "Textures/b1.png";
|
|
||||||
Globals.assetManager.addTexturePathtoQueue(blackTexture);
|
|
||||||
//white texture for backgrounds
|
|
||||||
whiteTexture = "Textures/w1.png";
|
|
||||||
Globals.assetManager.addTexturePathtoQueue(whiteTexture);
|
|
||||||
//off white texture for backgrounds
|
|
||||||
offWhiteTexture = "Textures/ow1.png";
|
|
||||||
Globals.assetManager.addTexturePathtoQueue(offWhiteTexture);
|
|
||||||
//initialize required windows
|
//initialize required windows
|
||||||
WindowUtils.initBaseWindows();
|
WindowUtils.initBaseWindows();
|
||||||
//init default shaderProgram
|
//init default shaderProgram
|
||||||
@ -522,20 +536,9 @@ public class Globals {
|
|||||||
|
|
||||||
//image panel
|
//image panel
|
||||||
ImagePanel.imagePanelModelPath = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/plane/plane.vs", "Shaders/plane/plane.fs"));
|
ImagePanel.imagePanelModelPath = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/plane/plane.vs", "Shaders/plane/plane.fs"));
|
||||||
|
|
||||||
//init ui images
|
|
||||||
assetManager.addTexturePathtoQueue("Textures/ui/WindowBorder.png");
|
|
||||||
assetManager.addTexturePathtoQueue("Textures/ui/uiFrame1.png");
|
|
||||||
assetManager.addTexturePathtoQueue("Textures/ui/uiFrame2.png");
|
|
||||||
|
|
||||||
testingTexture = "Textures/Testing1.png";
|
|
||||||
Globals.assetManager.addTexturePathtoQueue(testingTexture);
|
|
||||||
|
|
||||||
Globals.assetManager.addShaderToQueue("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs");
|
Globals.assetManager.addShaderToQueue("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs");
|
||||||
|
|
||||||
// //in game ui stuff
|
|
||||||
// elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN,WidgetUtils.createInGameMainMenuButton());
|
|
||||||
|
|
||||||
//window content shader
|
//window content shader
|
||||||
assetManager.addShaderToQueue("Shaders/ui/windowContent/windowContent.vs", null, "Shaders/ui/windowContent/windowContent.fs");
|
assetManager.addShaderToQueue("Shaders/ui/windowContent/windowContent.vs", null, "Shaders/ui/windowContent/windowContent.fs");
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,11 @@ public class SceneFile {
|
|||||||
*/
|
*/
|
||||||
RealmDescriptor realmDescriptor;
|
RealmDescriptor realmDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls whether the save utils will store a copy of the scene file in the save or not
|
||||||
|
*/
|
||||||
|
boolean createSaveInstance;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor
|
* Private constructor
|
||||||
@ -46,6 +51,7 @@ public class SceneFile {
|
|||||||
rVal.scriptPaths = new LinkedList<String>();
|
rVal.scriptPaths = new LinkedList<String>();
|
||||||
rVal.initScriptPath = null;
|
rVal.initScriptPath = null;
|
||||||
rVal.realmDescriptor = new RealmDescriptor();
|
rVal.realmDescriptor = new RealmDescriptor();
|
||||||
|
rVal.createSaveInstance = false;
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,4 +87,12 @@ public class SceneFile {
|
|||||||
return realmDescriptor;
|
return realmDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the save utils will store a copy of the scene file in the save or not
|
||||||
|
* @return true if should create instance of scene file in save, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean getCreateSaveInstance(){
|
||||||
|
return createSaveInstance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ public class SceneGenerator {
|
|||||||
//realm descriptor stuff
|
//realm descriptor stuff
|
||||||
file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL;
|
file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL;
|
||||||
file.realmDescriptor.griddedRealmSize = GriddedDataCellManager.MAX_GRID_SIZE;
|
file.realmDescriptor.griddedRealmSize = GriddedDataCellManager.MAX_GRID_SIZE;
|
||||||
|
file.createSaveInstance = true; //won't have a predefined scene to load, so must create one in the save
|
||||||
|
|
||||||
//create terrain
|
//create terrain
|
||||||
ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(2000);
|
ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(2000);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import electrosphere.renderer.ui.elements.Button;
|
|||||||
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.Slider;
|
import electrosphere.renderer.ui.elements.Slider;
|
||||||
|
import electrosphere.renderer.ui.elements.ToggleInput;
|
||||||
import electrosphere.renderer.ui.elements.VirtualScrollable;
|
import electrosphere.renderer.ui.elements.VirtualScrollable;
|
||||||
import electrosphere.renderer.ui.elementtypes.Element;
|
import electrosphere.renderer.ui.elementtypes.Element;
|
||||||
import electrosphere.renderer.ui.elementtypes.ValueElement;
|
import electrosphere.renderer.ui.elementtypes.ValueElement;
|
||||||
@ -34,12 +35,18 @@ public class MenuGeneratorsUITesting {
|
|||||||
});
|
});
|
||||||
rVal.addChild(backButton);
|
rVal.addChild(backButton);
|
||||||
|
|
||||||
ActorPanel actorPanel = new ActorPanel(Globals.renderingEngine.getOpenGLState(), 500, 100, 500, 500, ActorUtils.createActorFromModelPath("Models/deer1.fbx"));
|
//toggle input
|
||||||
|
ToggleInput toggleInput = ToggleInput.createToggleInput();
|
||||||
|
rVal.addChild(toggleInput);
|
||||||
|
|
||||||
|
//actor panel
|
||||||
|
ActorPanel actorPanel = new ActorPanel(Globals.renderingEngine.getOpenGLState(), 500, 100, 500, 500, ActorUtils.createActorFromModelPath("Models/creatures/animals/deer1.fbx"));
|
||||||
if(Globals.playerCamera == null){
|
if(Globals.playerCamera == null){
|
||||||
Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(0,0,0), new Vector3f(-1,0,0));
|
Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(0,0,0), new Vector3f(-1,0,0));
|
||||||
}
|
}
|
||||||
rVal.addChild(actorPanel);
|
rVal.addChild(actorPanel);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//Virtual scrollable test
|
//Virtual scrollable test
|
||||||
VirtualScrollable virtualScrollable = new VirtualScrollable(300, 75);
|
VirtualScrollable virtualScrollable = new VirtualScrollable(300, 75);
|
||||||
|
|||||||
@ -32,6 +32,8 @@ import electrosphere.renderer.ui.events.Event;
|
|||||||
|
|
||||||
public class ActorPanel extends StandardElement implements DrawableElement, DraggableElement {
|
public class ActorPanel extends StandardElement implements DrawableElement, DraggableElement {
|
||||||
|
|
||||||
|
static Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
Material customMat = new Material();
|
Material customMat = new Material();
|
||||||
Framebuffer elementBuffer;
|
Framebuffer elementBuffer;
|
||||||
|
|
||||||
@ -61,8 +63,8 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
|||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
this.internalPositionX = x;
|
this.internalPositionX = x;
|
||||||
this.internalPositionY = y;
|
this.internalPositionY = y;
|
||||||
this.width = width;
|
this.setWidth(width);
|
||||||
this.height = height;
|
this.setHeight(height);
|
||||||
this.aspectRatio = (float)width / (float)height;
|
this.aspectRatio = (float)width / (float)height;
|
||||||
recalculateModelMatrix();
|
recalculateModelMatrix();
|
||||||
}
|
}
|
||||||
@ -138,10 +140,10 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
|||||||
//set viewport
|
//set viewport
|
||||||
openGLState.glViewport(parentWidth, parentHeight);
|
openGLState.glViewport(parentWidth, parentHeight);
|
||||||
|
|
||||||
float ndcX = (float)internalPositionX/parentWidth;
|
float ndcX = (float)getInternalX()/parentWidth;
|
||||||
float ndcY = (float)internalPositionY/parentHeight;
|
float ndcY = (float)getInternalY()/parentHeight;
|
||||||
float ndcWidth = (float)width/parentWidth;
|
float ndcWidth = (float)getInternalWidth()/parentWidth;
|
||||||
float ndcHeight = (float)height/parentHeight;
|
float ndcHeight = (float)getInternalHeight()/parentHeight;
|
||||||
|
|
||||||
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
@ -172,6 +174,7 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.draw(renderPipelineState,Globals.renderingEngine.getOpenGLState());
|
planeModel.draw(renderPipelineState,Globals.renderingEngine.getOpenGLState());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class BitmapCharacter extends StandardElement implements DrawableElement
|
|||||||
|
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
Vector3f color = new Vector3f(0,0,0);
|
Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
Font font;
|
Font font;
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import electrosphere.renderer.ui.events.MouseEvent;
|
|||||||
|
|
||||||
public class Button extends StandardContainerElement implements DrawableElement, FocusableElement, ClickableElement, HoverableElement {
|
public class Button extends StandardContainerElement implements DrawableElement, FocusableElement, ClickableElement, HoverableElement {
|
||||||
|
|
||||||
|
static Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
Vector3f boxPosition = new Vector3f();
|
Vector3f boxPosition = new Vector3f();
|
||||||
Vector3f boxDimensions = new Vector3f();
|
Vector3f boxDimensions = new Vector3f();
|
||||||
Vector3f texPosition = new Vector3f(0,0,0);
|
Vector3f texPosition = new Vector3f(0,0,0);
|
||||||
@ -181,6 +183,7 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
@ -259,5 +262,10 @@ public class Button extends StandardContainerElement implements DrawableElement,
|
|||||||
public void setOnHoverCallback(HoverEventCallback callback) {
|
public void setOnHoverCallback(HoverEventCallback callback) {
|
||||||
this.hoverEventCallback = callback;
|
this.hoverEventCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean focused) {
|
||||||
|
this.focused = focused;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,8 @@ import electrosphere.renderer.ui.events.Event;
|
|||||||
* A UI element that is a single, uninteractable image
|
* A UI element that is a single, uninteractable image
|
||||||
*/
|
*/
|
||||||
public class ImagePanel extends StandardElement implements DrawableElement, DraggableElement {
|
public class ImagePanel extends StandardElement implements DrawableElement, DraggableElement {
|
||||||
|
|
||||||
|
Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
//Asset path for the model data that is used to draw the image panel
|
//Asset path for the model data that is used to draw the image panel
|
||||||
public static String imagePanelModelPath;
|
public static String imagePanelModelPath;
|
||||||
@ -158,6 +160,7 @@ public class ImagePanel extends StandardElement implements DrawableElement, Drag
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import static org.lwjgl.opengl.GL30.*;
|
|||||||
|
|
||||||
public class ScrollableContainer extends StandardContainerElement implements DrawableElement {
|
public class ScrollableContainer extends StandardContainerElement implements DrawableElement {
|
||||||
|
|
||||||
|
Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
boolean focused = false;
|
boolean focused = false;
|
||||||
|
|
||||||
public boolean visible = false;
|
public boolean visible = false;
|
||||||
@ -172,6 +174,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
@ -182,6 +185,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
|
|||||||
@ -9,11 +9,10 @@ import electrosphere.logger.LoggerInterface;
|
|||||||
import electrosphere.renderer.OpenGLState;
|
import electrosphere.renderer.OpenGLState;
|
||||||
import electrosphere.renderer.RenderPipelineState;
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
import electrosphere.renderer.debug.DebugRendering;
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
|
import electrosphere.renderer.model.Material;
|
||||||
import electrosphere.renderer.model.Model;
|
import electrosphere.renderer.model.Model;
|
||||||
import electrosphere.renderer.ui.elementtypes.ClickableElement;
|
import electrosphere.renderer.ui.elementtypes.ClickableElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.DraggableElement;
|
import electrosphere.renderer.ui.elementtypes.DraggableElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
|
||||||
import electrosphere.renderer.ui.elementtypes.FocusableElement;
|
|
||||||
import electrosphere.renderer.ui.elementtypes.MenuEventElement;
|
import electrosphere.renderer.ui.elementtypes.MenuEventElement;
|
||||||
import electrosphere.renderer.ui.elementtypes.ValueElement;
|
import electrosphere.renderer.ui.elementtypes.ValueElement;
|
||||||
import electrosphere.renderer.ui.events.ClickEvent;
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
@ -27,11 +26,8 @@ import electrosphere.renderer.ui.events.ValueChangeEvent;
|
|||||||
/**
|
/**
|
||||||
* A ui element that is a slider that lets you pick between a range of values
|
* A ui element that is a slider that lets you pick between a range of values
|
||||||
*/
|
*/
|
||||||
public class Slider extends StandardElement implements ClickableElement, DraggableElement, FocusableElement, DrawableElement, MenuEventElement, ValueElement {
|
public class Slider extends StandardDrawableElement implements ClickableElement, DraggableElement, MenuEventElement, ValueElement {
|
||||||
|
|
||||||
public boolean visible = false;
|
|
||||||
|
|
||||||
boolean focused = false;
|
|
||||||
FocusEventCallback onFocusCallback;
|
FocusEventCallback onFocusCallback;
|
||||||
FocusEventCallback onLoseFocusCallback;
|
FocusEventCallback onLoseFocusCallback;
|
||||||
DragEventCallback onDragStart;
|
DragEventCallback onDragStart;
|
||||||
@ -45,9 +41,11 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
float max = 1.0f;
|
float max = 1.0f;
|
||||||
float value = 0.5f;
|
float value = 0.5f;
|
||||||
|
|
||||||
Vector3f colorBackground = new Vector3f(0,0,0);
|
Vector3f colorBackground = new Vector3f(0.2f,0.2f,0.2f);
|
||||||
Vector3f colorForeground = new Vector3f(1,1,1);
|
Vector3f colorForeground = new Vector3f(1,1,1);
|
||||||
|
|
||||||
|
static Material mat;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static final int idealMargin = 5; //5 pixels margin ideally
|
static final int idealMargin = 5; //5 pixels margin ideally
|
||||||
@ -87,6 +85,11 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
*/
|
*/
|
||||||
private Slider(){
|
private Slider(){
|
||||||
super();
|
super();
|
||||||
|
if(mat == null){
|
||||||
|
mat = new Material();
|
||||||
|
mat.set_diffuse("Textures/ui/square.png");
|
||||||
|
mat.set_specular("Textures/ui/square.png");
|
||||||
|
}
|
||||||
setWidth(DEFAULT_WIDTH);
|
setWidth(DEFAULT_WIDTH);
|
||||||
setHeight(DEFAULT_HEIGHT);
|
setHeight(DEFAULT_HEIGHT);
|
||||||
}
|
}
|
||||||
@ -94,6 +97,11 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
|
|
||||||
public Slider(int positionX, int positionY, int width, int height, Vector3f colorBackground, Vector3f colorForeground){
|
public Slider(int positionX, int positionY, int width, int height, Vector3f colorBackground, Vector3f colorForeground){
|
||||||
super();
|
super();
|
||||||
|
if(mat == null){
|
||||||
|
mat = new Material();
|
||||||
|
mat.set_diffuse("Textures/ui/square.png");
|
||||||
|
mat.set_specular("Textures/ui/square.png");
|
||||||
|
}
|
||||||
this.internalPositionX = positionX;
|
this.internalPositionX = positionX;
|
||||||
this.internalPositionY = positionY;
|
this.internalPositionY = positionY;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
@ -146,6 +154,7 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", colorBackground);
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", colorBackground);
|
||||||
|
planeModel.getMeshes().get(0).setMaterial(mat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
|
|
||||||
//actual slider
|
//actual slider
|
||||||
@ -158,6 +167,7 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", colorForeground);
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", colorForeground);
|
||||||
|
planeModel.getMeshes().get(0).setMaterial(mat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
} else {
|
} else {
|
||||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
||||||
@ -197,20 +207,7 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
float getValueAsPercentage(){
|
float getValueAsPercentage(){
|
||||||
return (value - min) / (max - min);
|
return (value - min) / (max - min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getVisible() {
|
|
||||||
return visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisible(boolean draw) {
|
|
||||||
this.visible = draw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFocused() {
|
|
||||||
return focused;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOnFocus(FocusEventCallback callback) {
|
public void setOnFocus(FocusEventCallback callback) {
|
||||||
onFocusCallback = callback;
|
onFocusCallback = callback;
|
||||||
@ -262,7 +259,7 @@ public class Slider extends StandardElement implements ClickableElement, Draggab
|
|||||||
propagate = this.onFocusCallback.execute(focusEvent);
|
propagate = this.onFocusCallback.execute(focusEvent);
|
||||||
} else {
|
} else {
|
||||||
//default behavior/
|
//default behavior/
|
||||||
colorForeground = new Vector3f(1,0,0);
|
colorForeground = new Vector3f(1,0.5f,0.5f);
|
||||||
propagate = true;
|
propagate = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import electrosphere.renderer.OpenGLState;
|
||||||
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.DrawableElement;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.FocusableElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A standard element that is drawable
|
||||||
|
*/
|
||||||
|
public class StandardDrawableElement extends StandardElement implements DrawableElement, FocusableElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visibility status
|
||||||
|
*/
|
||||||
|
boolean visible = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Focus status
|
||||||
|
*/
|
||||||
|
boolean isFocused = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getVisible() {
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVisible(boolean draw) {
|
||||||
|
this.visible = draw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState, int parentFramebufferPointer, int parentPosX, int parentPosY, int parentWidth, int parentHeight) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'draw'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
return this.isFocused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean focused) {
|
||||||
|
this.isFocused = focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnFocus(FocusEventCallback callback) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'setOnFocus'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnLoseFocus(FocusEventCallback callback) {
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'setOnLoseFocus'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -202,11 +202,6 @@ public class StringCarousel extends StandardContainerElement implements Drawable
|
|||||||
onValueChange = callback;
|
onValueChange = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFocused() {
|
|
||||||
return focused;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOnFocus(FocusEventCallback callback) {
|
public void setOnFocus(FocusEventCallback callback) {
|
||||||
onFocusCallback = callback;
|
onFocusCallback = callback;
|
||||||
@ -217,4 +212,14 @@ public class StringCarousel extends StandardContainerElement implements Drawable
|
|||||||
onLoseFocusCallback = callback;
|
onLoseFocusCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
return this.focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean focused) {
|
||||||
|
this.focused = focused;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,8 @@ 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 {
|
||||||
|
|
||||||
|
Vector3f backgroundColor = new Vector3f(0.2f,0.2f,0.2f);
|
||||||
|
|
||||||
Vector3f boxPosition = new Vector3f();
|
Vector3f boxPosition = new Vector3f();
|
||||||
Vector3f boxDimensions = new Vector3f();
|
Vector3f boxDimensions = new Vector3f();
|
||||||
Vector3f texPosition = new Vector3f(0,0,0);
|
Vector3f texPosition = new Vector3f(0,0,0);
|
||||||
@ -175,6 +177,7 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", backgroundColor);
|
||||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
@ -288,5 +291,10 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
|
|||||||
public void setOnValueChangeCallback(ValueChangeEventCallback callback) {
|
public void setOnValueChangeCallback(ValueChangeEventCallback callback) {
|
||||||
this.onValueChangeCallback = callback;
|
this.onValueChangeCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean focused) {
|
||||||
|
this.focused = focused;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,225 @@
|
|||||||
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.renderer.OpenGLState;
|
||||||
|
import electrosphere.renderer.RenderPipelineState;
|
||||||
|
import electrosphere.renderer.model.Material;
|
||||||
|
import electrosphere.renderer.model.Model;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ClickableElement;
|
||||||
|
import electrosphere.renderer.ui.elementtypes.ValueElement;
|
||||||
|
import electrosphere.renderer.ui.events.ClickEvent;
|
||||||
|
import electrosphere.renderer.ui.events.Event;
|
||||||
|
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A toggle input
|
||||||
|
*/
|
||||||
|
public class ToggleInput extends StandardDrawableElement implements ClickableElement, ValueElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Click callback
|
||||||
|
*/
|
||||||
|
ClickEventCallback onClickCallback = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value change callback
|
||||||
|
*/
|
||||||
|
ValueChangeEventCallback onValueChangeCallback = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of the toggle
|
||||||
|
*/
|
||||||
|
boolean value = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material for drawing the circle
|
||||||
|
*/
|
||||||
|
static Material circleMat = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width/height of the circle
|
||||||
|
*/
|
||||||
|
private static final float CIRCLE_WIDTH = 0.4f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The offset from the center of the bar to place the circle
|
||||||
|
*/
|
||||||
|
private static final float CIRCLE_OFFSET_FROM_CENTER = 0.3f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the circle
|
||||||
|
*/
|
||||||
|
Vector3f circleColor = new Vector3f(0.8f,0.8f,0.8f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material for drawing the connecting bar between the circle positions
|
||||||
|
*/
|
||||||
|
static Material barMat = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The height of the bar relative to the total drawable height
|
||||||
|
*/
|
||||||
|
private static final float BAR_HEIGHT = 0.5f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The color of the bar
|
||||||
|
*/
|
||||||
|
Vector3f barColor = new Vector3f(0.3f,0.3f,0.3f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default width of the toggle in pixels
|
||||||
|
*/
|
||||||
|
private static final int TOGGLE_PIXEL_WIDTH_DEFAULT = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default height of the toggle in pixels
|
||||||
|
*/
|
||||||
|
private static final int TOGGLE_PIXEL_HEIGHT_DEFAULT = 38;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a toggle input
|
||||||
|
* @return The toggle input
|
||||||
|
*/
|
||||||
|
public static ToggleInput createToggleInput(){
|
||||||
|
return new ToggleInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
private ToggleInput(){
|
||||||
|
//material work
|
||||||
|
if(circleMat == null){
|
||||||
|
circleMat = new Material();
|
||||||
|
circleMat.set_diffuse("Textures/ui/circle.png");
|
||||||
|
circleMat.set_specular("Textures/ui/circle.png");
|
||||||
|
}
|
||||||
|
if(barMat == null){
|
||||||
|
barMat = new Material();
|
||||||
|
barMat.set_diffuse("Textures/ui/square.png");
|
||||||
|
barMat.set_specular("Textures/ui/square.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setWidth(TOGGLE_PIXEL_WIDTH_DEFAULT);
|
||||||
|
this.setHeight(TOGGLE_PIXEL_HEIGHT_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(
|
||||||
|
RenderPipelineState renderPipelineState,
|
||||||
|
OpenGLState openGLState,
|
||||||
|
int parentFramebufferPointer,
|
||||||
|
int parentPosX,
|
||||||
|
int parentPosY,
|
||||||
|
int parentWidth,
|
||||||
|
int parentHeight
|
||||||
|
){
|
||||||
|
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
||||||
|
openGLState.glViewport(parentWidth, parentHeight);
|
||||||
|
|
||||||
|
|
||||||
|
float ndcWidth = (float)getInternalWidth()/parentWidth;
|
||||||
|
float ndcHeight = (float)getInternalHeight()/parentHeight;
|
||||||
|
float ndcX = (float)(getInternalX() + parentPosX)/parentWidth;
|
||||||
|
float ndcY = (float)(getInternalY() + parentPosY)/parentHeight;
|
||||||
|
|
||||||
|
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
|
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
|
|
||||||
|
//getInternalX() and getInternalY() are the top left corner of the drawable space
|
||||||
|
//getInternalWidth() and getInternalHeight() are the width and height of the drawable space
|
||||||
|
|
||||||
|
//the actual offset from the center (with appropriate sign based on value)
|
||||||
|
float circleOffsetActual = 0;
|
||||||
|
if(value){
|
||||||
|
circleColor.set(0.9f, 0.9f, 0.9f);
|
||||||
|
barColor.set(0.5f, 0.9f, 0.5f);
|
||||||
|
circleOffsetActual = CIRCLE_OFFSET_FROM_CENTER;
|
||||||
|
} else {
|
||||||
|
circleColor.set(0.9f, 0.9f, 0.9f);
|
||||||
|
barColor.set(0.9f, 0.5f, 0.5f);
|
||||||
|
circleOffsetActual = -CIRCLE_OFFSET_FROM_CENTER;
|
||||||
|
}
|
||||||
|
//ratio to adjust the circlewidth by to always show a circle and not a deformed oval
|
||||||
|
float circleRatio = getInternalWidth() / (float)getInternalHeight();
|
||||||
|
|
||||||
|
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||||
|
if(planeModel != null){
|
||||||
|
//draw bar
|
||||||
|
ndcX = (float)(getInternalX() + (getInternalWidth() * ((1.0f - CIRCLE_WIDTH)/2.0f)) + parentPosX)/parentWidth;
|
||||||
|
ndcY = (float)(getInternalY() + (getInternalHeight() * ((1.0f - BAR_HEIGHT) / 2.0f)) + parentPosY)/parentHeight;
|
||||||
|
ndcWidth = (float)((getInternalWidth()) - (getInternalWidth() * ((1.0f - CIRCLE_WIDTH))))/parentWidth;
|
||||||
|
ndcHeight = (float)(getInternalHeight() * BAR_HEIGHT)/parentHeight;
|
||||||
|
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
|
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
|
planeModel.getMeshes().get(0).setMaterial(barMat);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", barColor);
|
||||||
|
planeModel.drawUI();
|
||||||
|
|
||||||
|
//draw circle
|
||||||
|
ndcX = (float)(getInternalX() + (getInternalWidth() * ((1.0f - CIRCLE_WIDTH) / 2.0f)) + (getInternalWidth() * circleOffsetActual) + parentPosX)/parentWidth;
|
||||||
|
ndcY = (float)(getInternalY() + (getInternalHeight() * ((1.0f - (CIRCLE_WIDTH * circleRatio)) / 2.0f)) + parentPosY)/parentHeight;
|
||||||
|
ndcWidth = (float)((getInternalWidth() * CIRCLE_WIDTH))/parentWidth;
|
||||||
|
ndcHeight = (float)(getInternalHeight() * (CIRCLE_WIDTH * circleRatio))/parentHeight;
|
||||||
|
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
|
boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
|
planeModel.getMeshes().get(0).setMaterial(circleMat);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", circleColor);
|
||||||
|
planeModel.drawUI();
|
||||||
|
} else {
|
||||||
|
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles an event
|
||||||
|
*/
|
||||||
|
public boolean handleEvent(Event event){
|
||||||
|
boolean propagate = true;
|
||||||
|
if(event instanceof ClickEvent){
|
||||||
|
ClickEvent clickEvent = (ClickEvent)event;
|
||||||
|
if(onClickCallback != null){
|
||||||
|
onClickCallback.execute(clickEvent);
|
||||||
|
} else {
|
||||||
|
Globals.elementManager.focusElement(this);
|
||||||
|
this.value = !this.value;
|
||||||
|
Globals.elementManager.fireEventNoPosition(new ValueChangeEvent(absoluteX), this);
|
||||||
|
propagate = false;
|
||||||
|
}
|
||||||
|
} else if(event instanceof ValueChangeEvent){
|
||||||
|
ValueChangeEvent valueEvent = (ValueChangeEvent)event;
|
||||||
|
if(this.onValueChangeCallback != null){
|
||||||
|
this.onValueChangeCallback.execute(valueEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return propagate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnValueChangeCallback(ValueChangeEventCallback callback) {
|
||||||
|
this.onValueChangeCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnClick(ClickEventCallback callback) {
|
||||||
|
this.onClickCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the toggle
|
||||||
|
* @param value The value to set the toggle to
|
||||||
|
*/
|
||||||
|
public void setValue(boolean value){
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -35,6 +35,9 @@ import electrosphere.renderer.ui.events.NavigationEvent;
|
|||||||
* A window
|
* A window
|
||||||
*/
|
*/
|
||||||
public class Window implements DrawableElement, ContainerElement, NavigableElement {
|
public class Window implements DrawableElement, ContainerElement, NavigableElement {
|
||||||
|
|
||||||
|
static Vector3f color = new Vector3f(1.0f);
|
||||||
|
|
||||||
List<Element> childList = new LinkedList<Element>();
|
List<Element> childList = new LinkedList<Element>();
|
||||||
Framebuffer widgetBuffer;
|
Framebuffer widgetBuffer;
|
||||||
Material customMat = new Material();
|
Material customMat = new Material();
|
||||||
@ -139,6 +142,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
customMat.setTexturePointer(windowFrame.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
@ -150,6 +154,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
|
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
|
|||||||
@ -2,17 +2,45 @@ package electrosphere.renderer.ui.elementtypes;
|
|||||||
|
|
||||||
import electrosphere.renderer.ui.events.FocusEvent;
|
import electrosphere.renderer.ui.events.FocusEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A focusable element
|
||||||
|
*/
|
||||||
public interface FocusableElement extends Element {
|
public interface FocusableElement extends Element {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the focused status of the element
|
||||||
|
* @return true if focused, false otherwise
|
||||||
|
*/
|
||||||
public boolean isFocused();
|
public boolean isFocused();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the focused status of the elemtn
|
||||||
|
* @param focused true if focused, false otherwise
|
||||||
|
*/
|
||||||
|
public void setFocused(boolean focused);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the on focus callback
|
||||||
|
* @param callback The callback
|
||||||
|
*/
|
||||||
public abstract void setOnFocus(FocusEventCallback callback);
|
public abstract void setOnFocus(FocusEventCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the on lose focus callback
|
||||||
|
* @param callback The callback
|
||||||
|
*/
|
||||||
public abstract void setOnLoseFocus(FocusEventCallback callback);
|
public abstract void setOnLoseFocus(FocusEventCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A focus event callback
|
||||||
|
*/
|
||||||
public abstract interface FocusEventCallback {
|
public abstract interface FocusEventCallback {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the callback
|
||||||
|
* @param event The focus event
|
||||||
|
* @return true if the event should propagate to the parent of this element, false otherwise
|
||||||
|
*/
|
||||||
public boolean execute(FocusEvent event);
|
public boolean execute(FocusEvent event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ public class ValueChangeEvent implements Event {
|
|||||||
public static enum ValueType {
|
public static enum ValueType {
|
||||||
STRING,
|
STRING,
|
||||||
FLOAT,
|
FLOAT,
|
||||||
|
BOOLEAN,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,6 +24,11 @@ public class ValueChangeEvent implements Event {
|
|||||||
*/
|
*/
|
||||||
float valueFloat;
|
float valueFloat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The boolean value
|
||||||
|
*/
|
||||||
|
boolean valueBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of this event
|
* The type of this event
|
||||||
*/
|
*/
|
||||||
@ -46,6 +52,15 @@ public class ValueChangeEvent implements Event {
|
|||||||
valueType = ValueType.FLOAT;
|
valueType = ValueType.FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for boolean value changes
|
||||||
|
* @param value The boolean
|
||||||
|
*/
|
||||||
|
public ValueChangeEvent(boolean value){
|
||||||
|
valueBoolean = value;
|
||||||
|
valueType = ValueType.BOOLEAN;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the type of the value
|
* Gets the type of the value
|
||||||
* @return The type of the value
|
* @return The type of the value
|
||||||
@ -70,4 +85,12 @@ public class ValueChangeEvent implements Event {
|
|||||||
return valueString;
|
return valueString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value that changed as a boolean
|
||||||
|
* @return The boolean value
|
||||||
|
*/
|
||||||
|
public boolean getAsBoolean(){
|
||||||
|
return valueBoolean;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import electrosphere.renderer.ui.elements.Div;
|
|||||||
import electrosphere.renderer.ui.elements.Label;
|
import electrosphere.renderer.ui.elements.Label;
|
||||||
import electrosphere.renderer.ui.elements.Slider;
|
import electrosphere.renderer.ui.elements.Slider;
|
||||||
import electrosphere.renderer.ui.elements.TextInput;
|
import electrosphere.renderer.ui.elements.TextInput;
|
||||||
|
import electrosphere.renderer.ui.elements.ToggleInput;
|
||||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||||
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
|
import electrosphere.renderer.ui.elementtypes.ContainerElement.YogaFlexDirection;
|
||||||
import electrosphere.renderer.ui.elementtypes.ValueElement.ValueChangeEventCallback;
|
import electrosphere.renderer.ui.elementtypes.ValueElement.ValueChangeEventCallback;
|
||||||
@ -96,5 +97,29 @@ public class InputMacros {
|
|||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a toggle with a label
|
||||||
|
* @param label The label
|
||||||
|
* @param defaultValue The default value
|
||||||
|
* @param onChange The on change callback
|
||||||
|
* @return The div containing a labeled toggle
|
||||||
|
*/
|
||||||
|
public static Div createToggle(String label, boolean defaultValue, Consumer<ValueChangeEvent> onChange){
|
||||||
|
Div rVal = Div.createDiv();
|
||||||
|
rVal.setFlexDirection(YogaFlexDirection.Row);
|
||||||
|
|
||||||
|
//the label
|
||||||
|
Label labelEl = Label.createLabel(label);
|
||||||
|
labelEl.setMarginRight(LABEL_MARGIN);
|
||||||
|
rVal.addChild(labelEl);
|
||||||
|
|
||||||
|
//the actual input
|
||||||
|
ToggleInput toggleInput = ToggleInput.createToggleInput();
|
||||||
|
toggleInput.setValue(defaultValue);
|
||||||
|
rVal.addChild(toggleInput);
|
||||||
|
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,9 @@ public class SaveUtils {
|
|||||||
FileUtils.serializeObjectToSavePath(saveName, "/save.json", save);
|
FileUtils.serializeObjectToSavePath(saveName, "/save.json", save);
|
||||||
|
|
||||||
//write scene file
|
//write scene file
|
||||||
FileUtils.serializeObjectToSavePath(saveName, "/scene.json", sceneFile);
|
if(sceneFile.getCreateSaveInstance()){
|
||||||
|
FileUtils.serializeObjectToSavePath(saveName, "/scene.json", sceneFile);
|
||||||
|
}
|
||||||
|
|
||||||
//create server structures
|
//create server structures
|
||||||
if(sceneFile.getRealmDescriptor().getType() == RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL){
|
if(sceneFile.getRealmDescriptor().getType() == RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL){
|
||||||
|
|||||||
@ -18,8 +18,8 @@ public class StartupTest {
|
|||||||
Globals.HEADLESS = true;
|
Globals.HEADLESS = true;
|
||||||
Profiler.PROFILE = false;
|
Profiler.PROFILE = false;
|
||||||
NetUtils.setPort(0);
|
NetUtils.setPort(0);
|
||||||
Main.startUp();
|
// Main.startUp();
|
||||||
Main.mainLoop(1);
|
// Main.mainLoop(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user