Skip to content

Commit

Permalink
Pause menu buttons are now oriented from the center of the screen ins…
Browse files Browse the repository at this point in the history
…tead of the edge, so they should stop departing from the pause menu when the screen size changes.
  • Loading branch information
AlasdairS4698737 committed Oct 12, 2023
1 parent 1df6c4b commit 7d2fe30
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.GdxGame;
import com.csse3200.game.ui.ButtonFactory;
Expand All @@ -15,6 +16,9 @@ public class PauseMenuButtonComponent extends UIComponent {
private static final Logger logger = LoggerFactory.getLogger(PauseMenuButtonComponent.class);
private static final float Z_INDEX = 2f;
private Table table;
private Table table2;
private Table table3;
private Table table4;
private final GdxGame game;

public PauseMenuButtonComponent(GdxGame screenSwitchHandle) {
Expand All @@ -32,14 +36,19 @@ public void create() {
* Positions them on the stage using a table
*/
private void addActors() {
//window = new Window("",);
table = new Table();
table.top().right();
table.setFillParent(true);
ButtonFactory buttonFactory = new ButtonFactory();
TextButton continueBtn = buttonFactory.createButton("Continue");
TextButton settingsBtn = buttonFactory.createButton("Settings");
TextButton planetSelectBtn = buttonFactory.createButton("Planet Select");
TextButton mainMenuBtn = buttonFactory.createButton("Main Menu");
table2 = new Table();
table2.setFillParent(true);
table3 = new Table();
table3.setFillParent(true);
table4 = new Table();
table4.setFillParent(true);
TextButton continueBtn = ButtonFactory.createButton("Continue");
TextButton settingsBtn = ButtonFactory.createButton("Settings");
TextButton planetSelectBtn = ButtonFactory.createButton("Planet Select");
TextButton mainMenuBtn = ButtonFactory.createButton("Main Menu");
continueBtn.addListener(
new ChangeListener() {
@Override
Expand Down Expand Up @@ -72,12 +81,15 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
game.setScreen(GdxGame.ScreenType.MAIN_MENU);
}
});
table.add(continueBtn).padTop(300f).padRight(700f);
table.add(settingsBtn).padTop(300f).padRight(500f);
table.add(planetSelectBtn).padTop(400f).padRight(675f);
table.add(mainMenuBtn).padTop(400f).padRight(490f);
table.add(continueBtn).padBottom(50f).padRight(200f);
table2.add(settingsBtn).padBottom(50f).padLeft(200f);
table3.add(planetSelectBtn).padTop(50f).padRight(200f);
table4.add(mainMenuBtn).padTop(50f).padLeft(200f);

stage.addActor(table);
stage.addActor(table2);
stage.addActor(table3);
stage.addActor(table4);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ public static Entity createPauseMenu(GdxGame game) {

Entity pauseMenu = new Entity()
.addComponent(new PauseMenuTimeStopComponent())
.addComponent(new PauseMenuContinueButton())
.addComponent(new PauseMenuSettingsButton(game))
.addComponent(new PauseMenuPlanetSelectButton(game))
.addComponent(new PauseMenuMainMenuButton(game))
.addComponent(new PauseMenuButtonComponent(game))
.addComponent(new TextureRenderComponent("images/ui/Sprites/UI_Glass_Toggle_Bar_01a.png"));
pauseMenu.setScale(8, 8);
pauseMenu.setPosition(6.3f, 2f);
pauseMenu.setPosition(6f, 2f);
ServiceLocator.getEntityService().register(pauseMenu);
lastPauseMenuID = pauseMenu.getId();
return pauseMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ void createsEntity() {
@Test
void entityHasRequiredComponents() {
assertNotNull(entity.getComponent(PauseMenuTimeStopComponent.class));
assertNotNull(entity.getComponent(PauseMenuContinueButton.class));
assertNotNull(entity.getComponent(PauseMenuSettingsButton.class));
assertNotNull(entity.getComponent(PauseMenuPlanetSelectButton.class));
assertNotNull(entity.getComponent(PauseMenuMainMenuButton.class));
assertNotNull(entity.getComponent(PauseMenuButtonComponent.class));
assertNotNull(entity.getComponent(TextureRenderComponent.class));
}

Expand Down

0 comments on commit 7d2fe30

Please sign in to comment.