diff --git a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuButtonComponent.java b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuButtonComponent.java index c081ec8d7..620cc07aa 100644 --- a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuButtonComponent.java +++ b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuButtonComponent.java @@ -19,10 +19,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 Window window; private final GdxGame game; private static final float windowSizeX = 300; private static final float windowSizeY = 400; @@ -46,7 +43,7 @@ public void create() { */ private void addActors() { - Window window = new Window("Game Paused", new Skin(Gdx.files.internal("images/ui/buttons/glass.json"))); + window = new Window("Game Paused", new Skin(Gdx.files.internal("images/ui/buttons/glass.json"))); TextButton continueBtn = ButtonFactory.createButton("Continue"); continueBtn.pad(20f); @@ -124,7 +121,8 @@ public float getZIndex() { @Override public void dispose() { - table.clear(); + window.clear(); + window.remove(); super.dispose(); } } diff --git a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuContinueButton.java b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuContinueButton.java index 1c8ecc4cf..e9e045691 100644 --- a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuContinueButton.java +++ b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuContinueButton.java @@ -39,9 +39,7 @@ private void addActors() { table = new Table(); table.top().right(); table.setFillParent(true); - ButtonFactory buttonFactory = new ButtonFactory(); -// TextButton pauseMenuBtn = buttonFactory.createButton("Continue"); - TextButton pauseMenuBtn = new TextButton("Continue", skin); + TextButton pauseMenuBtn = ButtonFactory.createButton("Continue"); // Triggers an event when the button is pressed. pauseMenuBtn.addListener( diff --git a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuMainMenuButton.java b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuMainMenuButton.java index 56fbcbcf1..27331949d 100644 --- a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuMainMenuButton.java +++ b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuMainMenuButton.java @@ -36,9 +36,7 @@ private void addActors() { table = new Table(); table.top().right(); table.setFillParent(true); - ButtonFactory buttonFactory = new ButtonFactory(); -// TextButton pauseMenuBtn = buttonFactory.createButton("Main Menu"); - TextButton pauseMenuBtn = new TextButton("Main Menu", skin); + TextButton pauseMenuBtn = ButtonFactory.createButton("Main Menu"); // Triggers an event when the button is pressed. pauseMenuBtn.addListener( diff --git a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuPlanetSelectButton.java b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuPlanetSelectButton.java index 31a54cad1..fa56dec88 100644 --- a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuPlanetSelectButton.java +++ b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuPlanetSelectButton.java @@ -36,9 +36,7 @@ private void addActors() { table = new Table(); table.top().right(); table.setFillParent(true); - ButtonFactory buttonFactory = new ButtonFactory(); -// TextButton pauseMenuBtn = buttonFactory.createButton("Planet Select"); - TextButton pauseMenuBtn = new TextButton("Planet Select", skin); + TextButton pauseMenuBtn = ButtonFactory.createButton("Planet Select"); // Triggers an event when the button is pressed. pauseMenuBtn.addListener( diff --git a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuSettingsButton.java b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuSettingsButton.java index 5ad5022af..8c1b61fa6 100644 --- a/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuSettingsButton.java +++ b/source/core/src/main/com/csse3200/game/components/pausemenu/PauseMenuSettingsButton.java @@ -36,9 +36,7 @@ private void addActors() { table = new Table(); table.top().right(); table.setFillParent(true); - ButtonFactory buttonFactory = new ButtonFactory(); -// TextButton pauseMenuBtn = buttonFactory.createButton("Settings"); - TextButton pauseMenuBtn = new TextButton("Settings", skin); + TextButton pauseMenuBtn = ButtonFactory.createButton("Settings"); // Triggers an event when the button is pressed. pauseMenuBtn.addListener( diff --git a/source/core/src/main/com/csse3200/game/entities/factories/PauseMenuFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/PauseMenuFactory.java index 155712f4d..5179b415c 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/PauseMenuFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/PauseMenuFactory.java @@ -23,10 +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 PauseMenuContinueButton()) +// .addComponent(new PauseMenuSettingsButton(game)) +// .addComponent(new PauseMenuPlanetSelectButton(game)) +// .addComponent(new PauseMenuMainMenuButton(game)) .addComponent(new PauseMenuButtonComponent(game)); pauseMenu.setScale(8, 8); pauseMenu.setPosition(6f, 2f); diff --git a/source/core/src/main/com/csse3200/game/ui/ButtonFactory.java b/source/core/src/main/com/csse3200/game/ui/ButtonFactory.java index 073aaa0e9..f02f5bfb0 100644 --- a/source/core/src/main/com/csse3200/game/ui/ButtonFactory.java +++ b/source/core/src/main/com/csse3200/game/ui/ButtonFactory.java @@ -8,28 +8,29 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import static com.csse3200.game.ui.UIComponent.skin; + /** * This class provides static methods for creating various types of TextButtons with different styles. */ public class ButtonFactory { private static Skin defaultSkin; - // Static initializer block to initialize the default skin - static { - defaultSkin = createDefaultSkin(); - } - - private static Skin createDefaultSkin() { - Skin skin = new Skin(Gdx.files.internal("configs/text.json")); - - // Define the button style with the background image - TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(); - style.font = skin.getFont("default"); - style.up = new TextureRegionDrawable(new TextureRegion(new Texture("images/ui/Sprites/UI_Glass_Button_Large_Lock_01a1.png"))); // Set the button background to the loaded image - - skin.add("default", style); - return skin; - } + // Static initializer block to initialize the default skin -- THIS IS HANDLED BY UICOMPONENT +// static { +// defaultSkin = createDefaultSkin(); +// } +// +// private static Skin createDefaultSkin() { +// +// // Define the button style with the background image +// TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(); +// style.font = skin.getFont("default"); +// style.up = new TextureRegionDrawable(new TextureRegion(new Texture("images/ui/Sprites/UI_Glass_Button_Large_Lock_01a1.png"))); // Set the button background to the loaded image +// +// skin.add("default", style); +// return skin; +// } /** * Creates a TextButton with the specified text using the default skin. @@ -38,9 +39,9 @@ private static Skin createDefaultSkin() { * @return The created TextButton. */ public static TextButton createButton(String text) { - TextButton button = new TextButton(text, defaultSkin); - button.getLabel().setFontScale(0.8f); // Adjust text size - button.pad(10f); // Adjust padding + TextButton button = new TextButton(text, skin); +// button.getLabel().setFontScale(0.8f); // Adjust text size + button.pad(20f); // Adjust padding return button; } diff --git a/source/core/src/test/com/csse3200/game/entities/factories/PauseMenuFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/PauseMenuFactoryTest.java index 477624e99..9144aad7f 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/PauseMenuFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/PauseMenuFactoryTest.java @@ -47,16 +47,12 @@ void createsEntity() { @Test void entityHasRequiredComponents() { assertNotNull(entity.getComponent(PauseMenuTimeStopComponent.class)); -<<<<<<< Updated upstream +// assertNotNull(entity.getComponent(PauseMenuButtonComponent.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)); -======= - 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)); ->>>>>>> Stashed changes } @Test