UIInputList proto
This commit is contained in:
parent
ff16ea1ae9
commit
2b193c50f3
@ -186,6 +186,10 @@ public class Engine {
|
||||
this.objectsGl.remove(obj);
|
||||
}
|
||||
|
||||
public void remove_objectsGl(List<ObjectGl> obj) {
|
||||
this.objectsGl.removeAll(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
UIElement Management
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ import engine.Engine;
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.Letter;
|
||||
import engine.object.ObjectGl;
|
||||
import engine.object.Text;
|
||||
import engine.object_wrapper.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
116
src/engine/gui/UIInputList.java
Normal file
116
src/engine/gui/UIInputList.java
Normal file
@ -0,0 +1,116 @@
|
||||
package engine.gui;
|
||||
|
||||
import engine.Engine;
|
||||
import engine.loader.ControllerPromptTextureLoader;
|
||||
import engine.object.ObjectGl;
|
||||
import gameplay.input.InputBuffer;
|
||||
import gameplay.input.Inputs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UIInputList extends UIDummy{
|
||||
|
||||
private InputBuffer inputBuffer;
|
||||
private int posBuffer;
|
||||
private int sizeBuffer;
|
||||
private List<ObjectGl> listIcon;
|
||||
private ControllerPromptTextureLoader tex;
|
||||
|
||||
public UIInputList(InputBuffer inputBuffer, float size, float posX, float posY, float posZ, Engine engine){
|
||||
this.engine = engine;
|
||||
this.camera = engine.getCamera();
|
||||
this.scalingFactor = size;
|
||||
this.xPos = posX;
|
||||
this.yPos = posY;
|
||||
this.zPos = posZ;
|
||||
this.inputBuffer = inputBuffer;
|
||||
this.tex = new ControllerPromptTextureLoader();
|
||||
}
|
||||
|
||||
public void init(){
|
||||
this.posBuffer = this.inputBuffer.getPos();
|
||||
this.sizeBuffer = this.inputBuffer.getSize();
|
||||
this.listIcon = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected void getObjInPosition(){
|
||||
}
|
||||
|
||||
public void createNextButton(int i){
|
||||
boolean[] input = inputBuffer.getInputList()[i].getTab();
|
||||
if (input[0]) {
|
||||
// UP
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.up);
|
||||
listIcon.add(obj);
|
||||
} if (input[1]){
|
||||
// DOWN
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.down);
|
||||
listIcon.add(obj);
|
||||
} if (input[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche
|
||||
// BACK
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.left);
|
||||
listIcon.add(obj);
|
||||
} if (input[3]){
|
||||
// FORWARD
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.right);
|
||||
listIcon.add(obj);
|
||||
} if (input[4]){
|
||||
// A
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.X);
|
||||
listIcon.add(obj);
|
||||
} if (input[5]){
|
||||
// B
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.A);
|
||||
listIcon.add(obj);
|
||||
} if (input[6]){
|
||||
// C
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.Y);
|
||||
listIcon.add(obj);
|
||||
} if (input[7]){
|
||||
// D
|
||||
ObjectGl obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
|
||||
obj.setTexture(tex.B);
|
||||
listIcon.add(obj);
|
||||
}
|
||||
for (ObjectGl obj : listIcon){
|
||||
obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl");
|
||||
}
|
||||
}
|
||||
|
||||
public void createButtonList(){
|
||||
|
||||
engine.remove_objectsGl(listIcon);
|
||||
listIcon = new ArrayList<>();
|
||||
|
||||
int count = 0;
|
||||
int index = this.posBuffer;
|
||||
do {
|
||||
createNextButton(index);
|
||||
index --;
|
||||
count ++;
|
||||
if (index < 0){
|
||||
index = this.sizeBuffer - 1;
|
||||
}
|
||||
} while(count < 30);
|
||||
|
||||
engine.add_objectsGl(listIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encules les perfs :( le problème c'est forcement le chargement des textures
|
||||
*/
|
||||
public void update(){
|
||||
this.posBuffer = this.inputBuffer.getPos();
|
||||
createButtonList();
|
||||
// Mettre à la bonne position
|
||||
this.getObjInPosition();
|
||||
}
|
||||
}
|
26
src/engine/loader/ControllerPromptTextureLoader.java
Normal file
26
src/engine/loader/ControllerPromptTextureLoader.java
Normal file
@ -0,0 +1,26 @@
|
||||
package engine.loader;
|
||||
|
||||
import engine.graphics.Texture;
|
||||
|
||||
public class ControllerPromptTextureLoader {
|
||||
|
||||
public Texture up;
|
||||
public Texture down;
|
||||
public Texture left;
|
||||
public Texture right;
|
||||
public Texture X;
|
||||
public Texture A;
|
||||
public Texture Y;
|
||||
public Texture B;
|
||||
|
||||
public ControllerPromptTextureLoader(){
|
||||
up = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_Dpad_Up.png", 0);
|
||||
down = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_Dpad_Down.png", 0);
|
||||
left = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_Dpad_Left.png", 0);
|
||||
right = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_Dpad_Right.png", 0);
|
||||
A = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_A.png", 0);
|
||||
B = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_B.png", 0);
|
||||
X = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_X.png", 0);
|
||||
Y = new Texture("textures/keyboard_pad_glyphs/xbox/XboxOne_Y.png", 0);
|
||||
}
|
||||
}
|
@ -154,6 +154,14 @@ public class ObjectGl {
|
||||
this.texture = new Texture(texPath, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new texture to be used
|
||||
* @param texture already loaded Texture
|
||||
*/
|
||||
public void setTexture(Texture texture) {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the wrapping coordinate, beware every sprite have to be of the same size if you don't want strange behavior
|
||||
* @param x starting wrapping on the horizontal axis
|
||||
|
@ -1,8 +1,10 @@
|
||||
package engine.object;
|
||||
package engine.object_wrapper;
|
||||
|
||||
import engine.Engine;
|
||||
import engine.gui.UIElement;
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.Letter;
|
||||
import engine.object.ObjectGl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -99,7 +99,7 @@ public class HitBox {
|
||||
}
|
||||
|
||||
public void reverseHorizontally() {
|
||||
this.position_x = 138*4 - position_x; //Il faut la largeur de la sprite
|
||||
this.position_x = 138*4 - position_x;
|
||||
this.size_x = -this.size_x;
|
||||
}
|
||||
}
|
@ -149,5 +149,17 @@ public class InputBuffer {
|
||||
}
|
||||
this.pos = 0;
|
||||
}
|
||||
|
||||
public Inputs[] getInputList(){
|
||||
return inputList;
|
||||
}
|
||||
|
||||
public int getPos(){
|
||||
return pos;
|
||||
}
|
||||
|
||||
public int getSize(){
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,5 +126,9 @@ public class Inputs {
|
||||
this.tab[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean[] getTab(){
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package gameplay.match;
|
||||
import engine.Engine;
|
||||
import engine.gui.UIElement;
|
||||
import engine.gui.UIElementText;
|
||||
import engine.gui.UIInputList;
|
||||
import engine.input.Button;
|
||||
import engine.input.GamepadInput;
|
||||
import engine.math.Vector3f;
|
||||
@ -77,10 +78,11 @@ public class match {
|
||||
private static HorizontalProgressBar healthBarP1Obj;
|
||||
private static HorizontalProgressBar healthBarP2Obj;
|
||||
private static UIElementText timerUI;
|
||||
private static UIInputList inputListP1;
|
||||
|
||||
// Debug
|
||||
private static boolean showP1Hitbox = true; // TODO modifier pour le rendre activable
|
||||
private static boolean showP2Hitbox = false;
|
||||
private static boolean showP2Hitbox = true;
|
||||
private static List<Hitbox> listHitboxObj = new ArrayList<>();
|
||||
|
||||
private static Sprite objP1,objP2;
|
||||
@ -103,6 +105,10 @@ public class match {
|
||||
// TODO meilleur implémentation possible
|
||||
objP1.getShadow().translate(new Vector3f(0f,p1.getPosY(),0));
|
||||
objP2.getShadow().translate(new Vector3f(0f,p2.getPosY(),0));
|
||||
// Crée l'InputList
|
||||
inputListP1 = new UIInputList(inputsP1, 10f, 0f, 0.3f, 110f, engine);
|
||||
engine.add_uiElement(inputListP1);
|
||||
inputListP1.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user