UIInputList affiche mtn seulement les nouvelles touches enfoncées cette frame

This commit is contained in:
Antoine 2021-06-19 14:39:36 +02:00
parent 631437a1e9
commit ec37cab5ef
2 changed files with 16 additions and 13 deletions

View File

@ -19,6 +19,8 @@ public class UIInputList extends UIDummy{
private List<ObjectGl> listIcon; private List<ObjectGl> listIcon;
private ControllerPromptTextureLoader tex; private ControllerPromptTextureLoader tex;
private boolean[] tab;
public UIInputList(InputBuffer inputBuffer, float size, float posX, float posY, float posZ, Engine engine){ public UIInputList(InputBuffer inputBuffer, float size, float posX, float posY, float posZ, Engine engine){
this.engine = engine; this.engine = engine;
this.camera = engine.getCamera(); this.camera = engine.getCamera();
@ -28,6 +30,7 @@ public class UIInputList extends UIDummy{
this.zPos = posZ; this.zPos = posZ;
this.inputBuffer = inputBuffer; this.inputBuffer = inputBuffer;
this.tex = new ControllerPromptTextureLoader(); this.tex = new ControllerPromptTextureLoader();
this.tab = new boolean[8];
} }
public void init(){ public void init(){
@ -57,39 +60,42 @@ public class UIInputList extends UIDummy{
public void createNextButton(int i){ public void createNextButton(int i){
boolean[] input = inputBuffer.getInputList()[i].getTab(); boolean[] input = inputBuffer.getInputList()[i].getTab();
ObjectGl obj = null; ObjectGl obj = null;
if (input[0]) { if (input[0] && !tab[0]) {
// UP // UP
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.up); obj.setTexture(tex.up);
} if (input[1]){ } if (input[1] && !tab[1]){
// DOWN // DOWN
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.down); obj.setTexture(tex.down);
} if (input[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche } if (input[2] && !tab[2]){ //Pour l'instant on fait comme si l'avant était toujours à droite donc arrière à gauche
// BACK // BACK
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.left); obj.setTexture(tex.left);
} if (input[3]){ } if (input[3] && !tab[3]){
// FORWARD // FORWARD
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.right); obj.setTexture(tex.right);
} if (input[4]){ } if (input[4] && !tab[4]){
// A // A
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.X); obj.setTexture(tex.X);
} if (input[5]){ } if (input[5] && !tab[5]){
// B // B
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.A); obj.setTexture(tex.A);
} if (input[6]){ } if (input[6] && !tab[6]){
// C // C
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.Y); obj.setTexture(tex.Y);
} if (input[7]){ } if (input[7] && !tab[7]){
// D // D
obj = new ObjectGl(100f, 10f, 10f, 10f, null, null); obj = new ObjectGl(100f, 10f, 10f, 10f, null, null);
obj.setTexture(tex.B); obj.setTexture(tex.B);
} }
for (int k = 0; k < 8; k++){
tab[k] = input[k];
}
if (obj != null){ if (obj != null){
listIcon.add(obj); listIcon.add(obj);
obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl"); obj.setShader("shaders/ObjectGlTex/vert.glsl", "shaders/ObjectGlTex/frag.glsl");
@ -101,15 +107,12 @@ public class UIInputList extends UIDummy{
createNextButton(this.posBuffer); createNextButton(this.posBuffer);
if(listIcon.size() > 30){ if(listIcon.size() > 15){
engine.remove_objectGl(listIcon.get(0)); engine.remove_objectGl(listIcon.get(0));
listIcon.remove(listIcon.get(0)); listIcon.remove(listIcon.get(0));
} }
} }
/**
* Encules les perfs :( le problème c'est forcement le chargement des textures
*/
public void update(){ public void update(){
this.posBuffer = this.inputBuffer.getPos(); this.posBuffer = this.inputBuffer.getPos();
createButtonList(); createButtonList();

View File

@ -106,7 +106,7 @@ public class match {
objP1.getShadow().translate(new Vector3f(0f,p1.getPosY(),0)); objP1.getShadow().translate(new Vector3f(0f,p1.getPosY(),0));
objP2.getShadow().translate(new Vector3f(0f,p2.getPosY(),0)); objP2.getShadow().translate(new Vector3f(0f,p2.getPosY(),0));
// Crée l'InputList // Crée l'InputList
inputListP1 = new UIInputList(inputsP1, 10f, 0f, 0.3f, 110f, engine); inputListP1 = new UIInputList(inputsP1, 10f, 0f, 0.85f, 110f, engine);
engine.add_uiElement(inputListP1); engine.add_uiElement(inputListP1);
inputListP1.init(); inputListP1.init();
} }