Skip to content

Commit

Permalink
Merge pull request #255 from UQcsse3200/team-2-ui-Alasdair
Browse files Browse the repository at this point in the history
Team 2 UI alasdair
  • Loading branch information
The-AhmadAA authored Oct 14, 2023
2 parents b616de7 + 49551bc commit f843056
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 125 deletions.
Binary file removed source/core/assets/images/ui/Logo2.png
Binary file not shown.
Binary file removed source/core/assets/images/ui/MainLogo.png
Binary file not shown.
99 changes: 0 additions & 99 deletions source/core/assets/images/ui/font.fnt

This file was deleted.

Binary file removed source/core/assets/images/ui/font.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.csse3200.game.GdxGame;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.ui.ButtonFactory;
import com.csse3200.game.ui.UIComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -19,6 +20,10 @@ public class PauseMenuButtonComponent extends UIComponent {
private static final float Z_INDEX = 2f;
private Window window;
private final GdxGame game;
private static final float windowSizeX = 300;
private static final float windowSizeY = 400;
// private static float padScaleFactorY;
// private static float padScaleFactorX;

public PauseMenuButtonComponent(GdxGame screenSwitchHandle) {
game = screenSwitchHandle;
Expand All @@ -28,20 +33,27 @@ public PauseMenuButtonComponent(GdxGame screenSwitchHandle) {
public void create() {
super.create();
addActors();
// padScaleFactorX = ServiceLocator.getRenderService().getStage().getWidth();
// padScaleFactorY = ServiceLocator.getRenderService().getStage().getHeight();
}

/**
* 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("",);

window = new Window("Game Paused", new Skin(Gdx.files.internal("images/ui/buttons/glass.json")));

TextButton continueBtn = new TextButton("Continue", skin);
TextButton settingsBtn = new TextButton("Settings", skin);
TextButton planetSelectBtn = new TextButton("Planet Select", skin);
TextButton mainMenuBtn = new TextButton("Main Menu", skin);
TextButton continueBtn = ButtonFactory.createButton("Continue");
continueBtn.pad(20f);
TextButton settingsBtn = ButtonFactory.createButton("Settings");
settingsBtn.pad(20f);
TextButton planetSelectBtn = ButtonFactory.createButton("Planet Select");
planetSelectBtn.pad(20f);
TextButton mainMenuBtn = ButtonFactory.createButton("Main Menu");
mainMenuBtn.pad(20f);

continueBtn.addListener(
new ChangeListener() {
@Override
Expand Down Expand Up @@ -89,10 +101,10 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
window.add(planetSelectBtn).center();
window.row();
window.add(mainMenuBtn).center();
window.setHeight(300f);
window.setWidth(250f);
window.setX((ServiceLocator.getRenderService().getStage().getWidth() / 2) - 125f);
window.setY((ServiceLocator.getRenderService().getStage().getHeight() / 2) - 150f);
window.setWidth(windowSizeX);
window.setHeight(windowSizeY);
window.setX((ServiceLocator.getRenderService().getStage().getWidth() / 2) - (windowSizeX / 2));
window.setY((ServiceLocator.getRenderService().getStage().getHeight() / 2) - (windowSizeY / 2));

stage.addActor(window);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void addActors() {
table.top().right();
table.setFillParent(true);
TextButton pauseMenuBtn = ButtonFactory.createButton("Main Menu");
pauseMenuBtn.setScale(2f);

// Triggers an event when the button is pressed.
pauseMenuBtn.addListener(
new ChangeListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ 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));
pauseMenu.setScale(8, 8);
pauseMenu.setPosition(6.3f, 2f);
pauseMenu.setPosition(6f, 2f);
ServiceLocator.getEntityService().register(pauseMenu);
lastPauseMenuID = pauseMenu.getId();
return pauseMenu;
Expand Down
15 changes: 10 additions & 5 deletions source/core/src/main/com/csse3200/game/ui/ButtonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
public class ButtonFactory {
private static Skin defaultSkin;

// Static initializer block to initialize the default skin
// This is handled by UIComponent
// Static initializer block to initialize the default skin -- THIS IS HANDLED BY UICOMPONENT
// static {
// defaultSkin = new
// defaultSkin = createDefaultSkin();
// }

//
// private static Skin createDefaultSkin() {
// Skin skin = new Skin(Gdx.files.internal("images/ui/buttons/glass.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;
// }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.csse3200.game.entities.EntityService;
import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.rendering.RenderService;
import com.csse3200.game.rendering.TextureRenderComponent;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import org.junit.jupiter.api.*;
Expand Down Expand Up @@ -48,10 +47,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));
}

@Test
Expand Down

0 comments on commit f843056

Please sign in to comment.