Coverage Summary for Class: GameOverScreen (io.github.unisim.ui)

Class Method, % Line, %
GameOverScreen 0% (0/8) 0% (0/47)
GameOverScreen$1 0% (0/2) 0% (0/2)
GameOverScreen$2 0% (0/2) 0% (0/4)
GameOverScreen$3 0% (0/2) 0% (0/4)
Total 0% (0/14) 0% (0/57)


 package io.github.unisim.ui;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.Screen;
 import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.g2d.BitmapFont;
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.scenes.scene2d.Stage;
 import com.badlogic.gdx.scenes.scene2d.ui.Image;
 import com.badlogic.gdx.scenes.scene2d.ui.Label;
 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.utils.ClickListener;
 import io.github.unisim.GameState;
 
 /**
  * GameOverScreen displays data such as buildings placed, score and buttons to
  * see the leaderboard, achievements or go back to main menu
  * 
  */
 public class GameOverScreen implements Screen {
     private Stage stage;
     private Skin altskin = GameState.altSkin;
     private SpriteBatch batch;
     private BitmapFont titleFont;
     private BitmapFont dataFont;
     private Label titleLabel;
     private Label dataLabel;
 
     private TextButton MainMenuButton;
     private TextButton LeaderboardButton;
     private TextButton AchievementButton;
 
     /**
      * Constructor: Initialises the GameOverScreen UI elements.
      */
     public GameOverScreen() {
         batch = new SpriteBatch();
         titleFont = new BitmapFont(Gdx.files.internal("ui/score.fnt"));
         dataFont = new BitmapFont(Gdx.files.internal("ui/score.fnt"));
 
         stage = new Stage();
 
         // Create an Image for the background
         Image backgroundImage = new Image(new Texture(Gdx.files.internal("ui/gameoverbackground.png")));
         backgroundImage.setFillParent(true); // Fill the screen with image
         stage.addActor(backgroundImage); // Add the background to the stage
 
         Label.LabelStyle titleStyle = new Label.LabelStyle(titleFont, null);
         Label.LabelStyle dataStyle = new Label.LabelStyle(dataFont, null);
         titleLabel = new Label("Game Over", titleStyle);
         titleLabel.setFontScale(2.0f);
         dataLabel = new Label("", dataStyle);
         dataLabel.setFontScale(0.8f);
 
         MainMenuButton = new TextButton("Main Menu", altskin);
         AchievementButton = new TextButton("Achievements", altskin);
         LeaderboardButton = new TextButton("Leaderboard", altskin);
 
         // Adds listeners to all of the buttons
         MainMenuButton.addListener(new ClickListener() {
             @Override
             public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
                 // Change to start screen
                 GameState.currentScreen = GameState.startScreen;
             }
 
         });
 
         AchievementButton.addListener(new ClickListener() {
             @Override
             public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
                 // Change to achievement screen
                 GameState.achievementScreen = new AchievementScreen(); // Refresh achievements
                 GameState.pushScreen(GameState.achievementScreen);
                 GameState.currentScreen = GameState.achievementScreen;
             }
         });
         LeaderboardButton.addListener(new ClickListener() {
             @Override
             public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
                 // Change to leaderboard screen
                 GameState.leaderboardScreen = new LeaderboardScreen(); // Refresh leaderboard
                 GameState.pushScreen(GameState.leaderboardScreen);
                 GameState.currentScreen = GameState.leaderboardScreen;
             }
         });
 
         // Adding UI elements to the table and then the stage
         Table table = new Table();
         table.setFillParent(true);
         table.center().center();
 
         table.add(titleLabel).padBottom(120).padTop(160);
         table.row();
 
         table.add(MainMenuButton).center().width(275).height(50).padBottom(20);
         table.row();
         table.add(AchievementButton).center().width(275).height(50).padBottom(20);
         table.row();
         table.add(LeaderboardButton).center().width(275).height(50);
         table.row();
         table.add(dataLabel).left().padTop(30).padRight(850);
 
         stage.addActor(table);
 
         Gdx.input.setInputProcessor(stage);
 
     }
 
     @Override
     public void show() {
         Gdx.input.setInputProcessor(stage);
     }
 
     @Override
     public void render(float delta) {
         // Clear screen
         Gdx.gl.glClearColor(0, 0, 0, 1);
         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 
         // Update data label with game over data
         dataLabel.setText(GameState.gameOverData.getData());
 
         // Draws the stage
         stage.act(delta);
         stage.draw();
 
     }
 
     @Override
     public void resize(int width, int height) {
         stage.getViewport().update(width, height, true);
 
     }
 
     @Override
     public void pause() {
 
     }
 
     @Override
     public void resume() {
         Gdx.input.setInputProcessor(stage);
 
     }
 
     @Override
     public void hide() {
 
     }
 
     @Override
     public void dispose() {
         stage.dispose();
         batch.dispose();
 
     }
 }