From 0ce57f4bf1d6d4aa6f69589f4517db92b9c78d0e Mon Sep 17 00:00:00 2001 From: Shivam Date: Mon, 2 Oct 2023 02:04:35 +1000 Subject: [PATCH] removed redundant code from UIElementsDisplay, added the required buttons in the same table --- .../maingame/UIElementsDisplay.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java b/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java index c9d530ce4..bbcc06b35 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java @@ -21,8 +21,7 @@ public class UIElementsDisplay extends UIComponent { private static final Logger logger = LoggerFactory.getLogger(MainGameExitDisplay.class); private static final float Z_INDEX = 2f; - private final Table mobsButtonTable = new Table(); - private final Table timerTable = new Table(); + private final Table buttonTable = new Table(); private final Table towerTable = new Table(); Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json")); private TextButton remainingMobsButton = new ButtonFactory().createButton("Mobs left:"); @@ -38,12 +37,10 @@ public void create() { * This method creates the buttons, adds them to the respective tables and draws them on the screen. */ private void addActors() { - mobsButtonTable.top().right(); - timerTable.top().right(); + buttonTable.top().right(); towerTable.top(); - mobsButtonTable.setFillParent(true); - timerTable.setFillParent(true); + buttonTable.setFillParent(true); towerTable.setFillParent(true); towerTable.setDebug(true); @@ -66,8 +63,9 @@ private void addActors() { // } // }); - mobsButtonTable.add(remainingMobsButton).padTop(20f).padRight(10f); - timerTable.add(timerButton).padTop(70f).padRight(10f); + buttonTable.add(remainingMobsButton).padTop(10f).padRight(10f); + buttonTable.row(); + buttonTable.add(timerButton).padRight(10f); towerTable.add(tower1).padRight(10f); towerTable.add(tower2).padRight(10f); @@ -75,8 +73,7 @@ private void addActors() { towerTable.add(tower4).padRight(10f); towerTable.add(tower5).padRight(10f); - stage.addActor(mobsButtonTable); - stage.addActor(timerTable); + stage.addActor(buttonTable); stage.addActor(towerTable); } @@ -106,7 +103,7 @@ public float getZIndex() { @Override public void dispose() { super.dispose(); - mobsButtonTable.clear(); - timerTable.clear(); + buttonTable.clear(); + towerTable.clear(); } }