Skip to content

Commit

Permalink
Changed the tables PauseMenuButtonComponent uses into a window, to ai…
Browse files Browse the repository at this point in the history
…d in fixing the pause menu screen sizing bug.
  • Loading branch information
AlasdairS4698737 committed Oct 14, 2023
1 parent 7d2fe30 commit 2ec2a93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
1 change: 0 additions & 1 deletion source/core/assets/images/ui/buttons/glass.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
background: UI_Glass_Frame_Standard_01a
titleFont: font_small
titleFontColor: White
stageBackground: UI_Glass_Frame_Standard_01a
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.csse3200.game.components.pausemenu;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
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.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.csse3200.game.GdxGame;
import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
Expand All @@ -15,10 +22,7 @@
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 Dialog window;
private final GdxGame game;

public PauseMenuButtonComponent(GdxGame screenSwitchHandle) {
Expand All @@ -33,18 +37,9 @@ public void create() {

/**
* Initialises the pause menu buttons
* Positions them on the stage using a table
* Positions them on the stage using a window
*/
private void addActors() {
//window = new Window("",);
table = new Table();
table.setFillParent(true);
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");
Expand Down Expand Up @@ -81,15 +76,17 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
game.setScreen(GdxGame.ScreenType.MAIN_MENU);
}
});
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);
window = new Dialog("Game Paused", new Skin(Gdx.files.internal("images/ui/buttons/glass.json")));
window.setFillParent(false);
window.setModal(true);
window.add(continueBtn);
window.row();
window.add(settingsBtn);
window.row();
window.add(planetSelectBtn);
window.row();
window.add(mainMenuBtn);
stage.addActor(window);
}

@Override
Expand All @@ -104,7 +101,8 @@ public float getZIndex() {

@Override
public void dispose() {
table.clear();
window.remove();
window.clear();
super.dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static Entity createPauseMenu(GdxGame game) {

Entity pauseMenu = new Entity()
.addComponent(new PauseMenuTimeStopComponent())
.addComponent(new PauseMenuButtonComponent(game))
.addComponent(new TextureRenderComponent("images/ui/Sprites/UI_Glass_Toggle_Bar_01a.png"));
.addComponent(new PauseMenuButtonComponent(game));
//.addComponent(new TextureRenderComponent("images/ui/Sprites/UI_Glass_Toggle_Bar_01a.png"));
pauseMenu.setScale(8, 8);
pauseMenu.setPosition(6f, 2f);
ServiceLocator.getEntityService().register(pauseMenu);
Expand Down

0 comments on commit 2ec2a93

Please sign in to comment.