UIDummy is now an abstract class

This commit is contained in:
Antoine 2021-06-04 23:29:22 +02:00
parent eaeb8ccee7
commit 9ebf04338e
3 changed files with 24 additions and 11 deletions

View File

@ -1,6 +1,11 @@
package engine.gui; package engine.gui;
public class UIDummy { /**
* Classe dont hérite tous les autres élements d'interface
*/
public abstract class UIDummy {
protected float scalingFactor;
public void init(){ public void init(){
} }
@ -8,7 +13,12 @@ public class UIDummy {
private void getObjInPosition(){ private void getObjInPosition(){
} }
/**
* Method pour le moteur ne pas utiliser
* @param scaleFactor
*/
public void updateScalingFactor(float scaleFactor){ public void updateScalingFactor(float scaleFactor){
this.scalingFactor *= scaleFactor;
} }
public void update(){ public void update(){

View File

@ -6,12 +6,14 @@ import engine.math.Vector3f;
import engine.object.Camera; import engine.object.Camera;
import engine.object.ObjectGl; import engine.object.ObjectGl;
/**
* Affiche un seul ObjectGl le lie à une position dans la zone de projection
*/
public class UIElement extends UIDummy{ public class UIElement extends UIDummy{
private final ObjectGl obj; private final ObjectGl obj;
private final Engine engine; private final Engine engine;
private final Camera camera; private final Camera camera;
private float scalingFactor;
private float xPos; private float xPos;
private float yPos; private float yPos;
private float zPos; private float zPos;
@ -52,10 +54,6 @@ public class UIElement extends UIDummy{
obj.translate(new Vector3f(- engine.transformationView.x, engine.transformationView.y)); obj.translate(new Vector3f(- engine.transformationView.x, engine.transformationView.y));
} }
public void updateScalingFactor(float scaleFactor){
this.scalingFactor *= scaleFactor;
}
public void update(){ public void update(){
this.getObjInPosition(); this.getObjInPosition();
} }

View File

@ -10,13 +10,15 @@ import engine.object.Text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* Affiche du texte le lie à une position dans la zone de projection
*/
public class UIElementText extends UIDummy{ public class UIElementText extends UIDummy{
private final List<ObjectGl> objs; private final List<ObjectGl> objs;
private final Engine engine; private final Engine engine;
private final Camera camera; private final Camera camera;
private final Text txt; private final Text txt;
private float scalingFactor;
private float xPos; private float xPos;
private float yPos; private float yPos;
private float zPos; private float zPos;
@ -40,10 +42,17 @@ public class UIElementText extends UIDummy{
this.getObjInPosition(); this.getObjInPosition();
} }
/**
* Ajouter l'element à la liste de rendu du moteur dont il est lié.
*/
public void init(){ public void init(){
this.engine.add_objectsGl(objs); this.engine.add_objectsGl(objs);
} }
/**
* Modifier le texte
* @param txt le nouveau texte
*/
public void setText(String txt){ public void setText(String txt){
this.txt.setNewText(txt); this.txt.setNewText(txt);
} }
@ -66,10 +75,6 @@ public class UIElementText extends UIDummy{
} }
} }
public void updateScalingFactor(float scaleFactor){
this.scalingFactor *= scaleFactor;
}
public void update(){ public void update(){
this.getObjInPosition(); this.getObjInPosition();
} }