92 lines
3.6 KiB
Java
92 lines
3.6 KiB
Java
package electrosphere.renderer.ui.transparenttextbox;
|
|
|
|
import electrosphere.main.Globals;
|
|
import electrosphere.renderer.Model;
|
|
import electrosphere.renderer.assetmanager.AssetDataStrings;
|
|
import electrosphere.renderer.ui.Widget;
|
|
import electrosphere.renderer.ui.font.FontUtils;
|
|
import org.joml.Vector3f;
|
|
|
|
public class TextBox extends Widget{
|
|
|
|
|
|
int positionX;
|
|
int positionY;
|
|
int width;
|
|
int height;
|
|
String text;
|
|
boolean editable;
|
|
|
|
Vector3f scalar;
|
|
|
|
public TextBox(int positionX, int positionY, int width, int height, String text, boolean render, boolean editable) {
|
|
super(positionX,positionY,width,height,render,Widget.WidgetType.TEXT_BOX);
|
|
this.positionX = positionX;
|
|
this.positionY = positionY;
|
|
this.width = width;
|
|
this.height = height;
|
|
this.text = text;
|
|
scalar = new Vector3f(1,1,1);
|
|
}
|
|
|
|
public TextBox(int positionX, int positionY, int width, int height, String text, boolean render, boolean editable, Vector3f scalar) {
|
|
super(positionX,positionY,width,height,render,Widget.WidgetType.TEXT_BOX);
|
|
this.positionX = positionX;
|
|
this.positionY = positionY;
|
|
this.width = width;
|
|
this.height = height;
|
|
this.text = text;
|
|
this.scalar = scalar;
|
|
}
|
|
|
|
public String getText() {
|
|
return text;
|
|
}
|
|
|
|
public void setText(String text) {
|
|
this.text = text;
|
|
}
|
|
|
|
public boolean isEditable() {
|
|
return editable;
|
|
}
|
|
|
|
public void setEditable(boolean editable) {
|
|
this.editable = editable;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void draw(){
|
|
throw new UnsupportedOperationException("Transparent Text box draw function not implemented yet oop");
|
|
// float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
|
|
// float ndcY = (float)positionY/Globals.WINDOW_HEIGHT;
|
|
// float ndcWidth = (float)width/Globals.WINDOW_WIDTH;
|
|
// float ndcHeight = (float)height/Globals.WINDOW_HEIGHT;
|
|
// //monowidth for the moment
|
|
// float charWidth = ndcWidth/cols;
|
|
// float charHeight = ndcHeight/rows;
|
|
// for(int y = 0; y < rows; y++){
|
|
// for(int x = 0; x < cols; x++){
|
|
// char toDraw = ' ';
|
|
// if(x + y * cols < text.length()){
|
|
// toDraw = text.charAt(x + y * cols);
|
|
// }
|
|
// Vector3f characterPosition = new Vector3f(ndcX + x * charWidth,ndcY + y * charHeight,0);
|
|
// Vector3f characterDimensions = new Vector3f(charWidth,charHeight,0);
|
|
// Vector3f bitMapPosition = FontUtils.getPositionOfCharacter(toDraw);
|
|
// Vector3f bitMapDimension = FontUtils.getDimensionOfCharacter(toDraw);
|
|
// Model charModel = Globals.assetManager.fetchModel(AssetDataStrings.ASSET_STRING_BITMAP_FONT);
|
|
// if(charModel != null && toDraw != ' '){
|
|
// charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "mPosition", characterPosition);
|
|
// charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "mDimension", characterDimensions);
|
|
// charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "tPosition", bitMapPosition);
|
|
// charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "tDimension", bitMapDimension);
|
|
// charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "color", color);
|
|
// charModel.drawUI();
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
}
|