Start widget rework
This commit is contained in:
parent
f0803a5c5d
commit
3267e52a4d
@ -89,7 +89,7 @@
|
||||
{
|
||||
"type" : "GROUND",
|
||||
"acceleration" : 0.15,
|
||||
"maxVelocity" : 1
|
||||
"maxVelocity" : 1.5
|
||||
}
|
||||
],
|
||||
"physicsObject" : {
|
||||
|
||||
@ -24,6 +24,7 @@ public class MenuUtils {
|
||||
rVal.addOption( WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 200, "MULTIPLAYER", true));
|
||||
rVal.addOption( WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 275, "ARENA", true));
|
||||
rVal.addOption( WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 350, "OPTIONS", true));
|
||||
rVal.addOption( WidgetUtils.createVerticallyAlignedMinSizeTextBoxFromCharCount(40, 40, screenTop - 350, "UI TESTING", true));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,6 @@ package electrosphere.renderer.ui;
|
||||
*/
|
||||
public abstract class Widget {
|
||||
|
||||
public enum WidgetType {
|
||||
TEXT_BOX,
|
||||
}
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@ -18,15 +14,12 @@ public abstract class Widget {
|
||||
|
||||
boolean draw;
|
||||
|
||||
WidgetType type;
|
||||
|
||||
public Widget(int positionX, int positionY, int width, int height, boolean draw, WidgetType type) {
|
||||
public Widget(int positionX, int positionY, int width, int height, boolean draw) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.positionX = positionX;
|
||||
this.positionY = positionY;
|
||||
this.draw = draw;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
@ -69,10 +62,6 @@ public abstract class Widget {
|
||||
this.draw = draw;
|
||||
}
|
||||
|
||||
public WidgetType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public abstract void draw();
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public class TextBox extends Widget{
|
||||
Vector3f color = new Vector3f(0,0,0);
|
||||
|
||||
public TextBox(int positionX, int positionY, int width, int height, int rows, int cols, String text, boolean render, boolean editable) {
|
||||
super(positionX,positionY,width,height,render,Widget.WidgetType.TEXT_BOX);
|
||||
super(positionX,positionY,width,height,render);
|
||||
this.positionX = positionX;
|
||||
this.positionY = positionY;
|
||||
this.width = width;
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package electrosphere.renderer.ui.layout;
|
||||
|
||||
import electrosphere.renderer.ui.Widget;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public abstract interface LayoutScheme {
|
||||
|
||||
public abstract void pack();
|
||||
|
||||
public abstract void addWidget(Widget widget);
|
||||
|
||||
public abstract List<Widget> getWidgets();
|
||||
|
||||
public abstract void destroy();
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package electrosphere.renderer.ui.layout;
|
||||
|
||||
import electrosphere.renderer.ui.Widget;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class LayoutSchemeList extends Widget implements LayoutScheme {
|
||||
|
||||
List<Widget> widgetList = new LinkedList();
|
||||
|
||||
public LayoutSchemeList(int positionX, int positionY, int width, int height, boolean draw){
|
||||
super(positionX,positionY,width,height,draw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
for(Widget child : widgetList){
|
||||
child.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidget(Widget widget) {
|
||||
widgetList.add(widget);
|
||||
widget.setDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Widget> getWidgets() {
|
||||
return widgetList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package electrosphere.renderer.ui.layout;
|
||||
|
||||
import electrosphere.renderer.ui.Widget;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class LayoutSchemeListScrollable extends Widget implements LayoutScheme {
|
||||
|
||||
List<Widget> widgetList = new LinkedList();
|
||||
|
||||
public LayoutSchemeListScrollable(int positionX, int positionY, int width, int height, boolean draw){
|
||||
super(positionX,positionY,width,height,draw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
for(Widget child : widgetList){
|
||||
child.draw();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidget(Widget widget) {
|
||||
widgetList.add(widget);
|
||||
widget.setDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Widget> getWidgets() {
|
||||
return widgetList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
@ -20,7 +20,7 @@ public class TextBox extends Widget{
|
||||
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);
|
||||
super(positionX,positionY,width,height,render);
|
||||
this.positionX = positionX;
|
||||
this.positionY = positionY;
|
||||
this.width = width;
|
||||
@ -30,7 +30,7 @@ public class TextBox extends Widget{
|
||||
}
|
||||
|
||||
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);
|
||||
super(positionX,positionY,width,height,render);
|
||||
this.positionX = positionX;
|
||||
this.positionY = positionY;
|
||||
this.width = width;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user