diff --git a/GameEngine/src/main/java/gameEngine/GameEditor.java b/GameEngine/src/main/java/gameEngine/GameEditor.java index f18278a..3aa20bf 100644 --- a/GameEngine/src/main/java/gameEngine/GameEditor.java +++ b/GameEngine/src/main/java/gameEngine/GameEditor.java @@ -21,22 +21,14 @@ private Sprite[] EditorFrameSprite = new Sprite[4]; private Button dtramButton; - private Text dtramButtonText; - private Button playButton; - private Text playButtonText; private Button createMeshComponentViewButton; - private Text createMeshComponentViewButtonText; - private Button createMoveImageComponentViewButton; - private Text createMoveImageComponentViewButtonText; - private Button createMoveStraightComponentViewButton; - private Text createMoveStraightComponentViewButtonText; private Button createEntityViewButton; - private Text createEntityViewButtonText; + public InputField[][] inspectorInputFields; public GameEditor(Scene scene, float windowWidth, float windowHeight) { @@ -49,23 +41,14 @@ private void initializeEditorComponents() { createFrame(); - playButton = new Button(windowWidth/ 2 -16 , 3, 1, 0.4f); - playButtonText = new Text(windowWidth/ 2 - 10, 1, "Play", 24); + playButton = new Button(windowWidth/ 2 -16 , 3, 1, 0.4f,"Play"); + dtramButton = new Button(100 - 16 , 3, 2.5f, 0.4f,"Play DTRAM"); - dtramButton = new Button(100 - 16 , 3, 2.5f, 0.4f); - dtramButtonText = new Text(100 - 10, 1, "Play DTRAM", 24); + createMeshComponentViewButton = new Button(20, 33, 3.2f, 0.5f, "Add Mesh"); + createMoveImageComponentViewButton = new Button(20, 73, 3.2f, 0.5f, "Add MoveImage"); + createMoveStraightComponentViewButton = new Button(20, 113, 3.2f, 0.5f, "Add MoveStraight"); - createMeshComponentViewButton = new Button(20, 33, 3.2f, 0.5f); - createMeshComponentViewButtonText = new Text(20 +5.25f, 30.4f, "Add Mesh", 24); - - createMoveImageComponentViewButton = new Button(20, 73, 3.2f, 0.5f); - createMoveImageComponentViewButtonText = new Text(20 +5.25f, 70.4f, "Add MoveImage", 24); - - createMoveStraightComponentViewButton = new Button(20, 113, 3.2f, 0.5f); - createMoveStraightComponentViewButtonText = new Text(20 +5.25f, 113.4f, "Add MoveStraight", 24); - - createEntityViewButton = new Button(240, 33, 3.2f, 0.5f); - createEntityViewButtonText = new Text(240 +5.25f, 30.4f, "Add Entity", 24); + createEntityViewButton = new Button(240, 33, 3.2f, 0.5f, "Add Entity"); setButtonListeners(); setInspector(); @@ -177,10 +160,7 @@ createEntityViewButton.clearListeners(); createEntityViewButton.addListener(scene::addNewEntity); - registerUpdatable(playButton, playButtonText, dtramButton, dtramButtonText, - createMeshComponentViewButton, createMeshComponentViewButtonText, - createMoveImageComponentViewButton, createMoveImageComponentViewButtonText, - createEntityViewButton, createEntityViewButtonText, createMoveStraightComponentViewButton, createMoveStraightComponentViewButtonText); + registerUpdatable(playButton, dtramButton, createMeshComponentViewButton, createMoveImageComponentViewButton, createEntityViewButton, createMoveStraightComponentViewButton); } public void setScene(Scene newScene) { diff --git a/GameEngine/src/main/java/gameEngine/views/Button.java b/GameEngine/src/main/java/gameEngine/views/Button.java index 4efe82d..a318927 100644 --- a/GameEngine/src/main/java/gameEngine/views/Button.java +++ b/GameEngine/src/main/java/gameEngine/views/Button.java @@ -8,28 +8,36 @@ public class Button implements IUpdatable { private Sprite buttonSprite; + private Text buttonText; private List onClickListeners = new ArrayList<>(); private boolean isPressed = false; private Color normalColor = new Color(1f, 1f, 1f, 1f); private Color pressedColor = new Color(0.5f, 0.5f, 0.5f, 1f); - public Button(float x, float y, Sprite sprite) { + public Button(float x, float y, Sprite sprite, Text text) { buttonSprite = sprite; buttonSprite.setPosition(x, y); + buttonText = text; + } + + public Button(float posX, float posY, float scaleX, float scaleY, String text){ + this(posX, posY, new Sprite(Window.resourcePath + "button.png") , new Text(posX + 5.25f, posY- 2.6f, text, 24)); + buttonSprite.setScale(scaleX, scaleY); } public Button(float posX, float posY, float scaleX, float scaleY){ - this(posX, posY, new Sprite(Window.resourcePath + "button.png")); + this(posX, posY, new Sprite(Window.resourcePath + "button.png") , new Text(posX + 5.25f, posY - 2.6f, "", 24)); buttonSprite.setScale(scaleX, scaleY); } public Button(){ - this(0,0, new Sprite(Window.resourcePath + "button.png")); + this(0,0, new Sprite(Window.resourcePath + "button.png"), new Text(5.25f, -2.6f, "", 24)); } public void update() { buttonSprite.update(); + buttonText.update(); float mouseX = MouseInput.getX(); float mouseY = MouseInput.getY(); @@ -72,4 +80,6 @@ public void setScale(float x, float y){ buttonSprite.setScale(x,y); } + + public void setButtonText(String text) { buttonText.setText(text);} } \ No newline at end of file