evil-inside/src/ei/game/scene/SelectBox.java

78 lines
1.9 KiB
Java
Raw Normal View History

2007-04-17 12:51:26 +00:00
package ei.game.scene;
2007-04-23 15:13:23 +00:00
import ei.engine.effects.ProgressBar;
2007-04-17 12:51:26 +00:00
import ei.engine.math.Vector2f;
import ei.engine.math.Vector4f;
import ei.engine.scene.Box;
import ei.engine.scene.Node;
import ei.engine.texture.Texture;
public class SelectBox {
public static final int COLOR_GREEN = 0;
public static final int COLOR_RED = 1;
2007-04-23 19:33:27 +00:00
private static final float height = 3;
2007-04-17 12:51:26 +00:00
private Node selectNode;
2007-04-18 16:06:44 +00:00
private Node mouseOverNode;
2007-04-23 15:13:23 +00:00
private ProgressBar bar;
2007-04-17 12:51:26 +00:00
/**
* Creates a selection box with health bar
*
* @param x The size of the selection box
* @param y The size of the selection box
* @param max The max health of the object
*/
public SelectBox(int color, float x, float y, int max){
2007-04-17 12:51:26 +00:00
selectNode = new Node("SelectionNode");
2007-04-18 16:06:44 +00:00
mouseOverNode = new Node("MouseOverNode");
2007-04-17 12:51:26 +00:00
Texture tex = new Texture();
if(color == COLOR_RED){
tex.setColor(new Vector4f(1.0f, 0.5f, 0.5f,1));
}
else{
tex.setColor(new Vector4f(0.5f, 1.0f, 0.5f,1));
}
2007-04-17 12:51:26 +00:00
2007-04-23 19:33:27 +00:00
bar = new ProgressBar("Health",x,height,max);
2007-04-23 15:13:23 +00:00
bar.getNode().setLocation(new Vector2f(0,-x/2+height/2));
bar.setValueColor(25, new Vector4f(1.0f, 0f, 0f, 1f));
bar.setValueColor(50, new Vector4f(1.0f, .95f, 0, 1f));
bar.setValueColor(100, new Vector4f(0.3f, 1.0f, 0.3f, 1f));
2007-04-23 15:13:23 +00:00
selectNode.add(bar.getNode());
mouseOverNode.add(bar.getNode());
2007-04-17 12:51:26 +00:00
Box select = new Box("select",tex);
select.setSize(new Vector2f(x,y));
selectNode.add(select);
2007-04-17 12:51:26 +00:00
}
/**
* Returns the node of the selection
*
* @return The node of the selection
*/
2007-04-18 16:06:44 +00:00
public Node getSelectNode(){
2007-04-17 12:51:26 +00:00
return selectNode;
}
2007-04-18 16:06:44 +00:00
/**
* Returns the node of the selection
*
* @return The node of the selection
*/
public Node getMouseOverNode(){
return mouseOverNode;
}
2007-04-17 12:51:26 +00:00
/**
* Sets the value of the health bar
*
* @param v The value of the health bar
*/
public void setValue(int v){
2007-04-23 15:13:23 +00:00
bar.setValue(v);
2007-04-17 12:51:26 +00:00
}
}