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

Class Method, % Branch, % Line, %
HowToPlayScreen 0% (0/8) 0% (0/2) 0% (0/59)
HowToPlayScreen$1 0% (0/2) 0% (0/2)
HowToPlayScreen$2 0% (0/2) 0% (0/2)
Total 0% (0/12) 0% (0/2) 0% (0/63)


 package io.github.unisim.ui;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.InputMultiplexer;
 import com.badlogic.gdx.Screen;
 import com.badlogic.gdx.files.FileHandle;
 import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.graphics.Texture;
 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.ScrollPane;
 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 com.badlogic.gdx.utils.Align;
 
 import io.github.unisim.GameState;
 
 public class HowToPlayScreen implements Screen {
 
     private Stage stage;
     private Table table;
     private Table table2;
     private Table table3;
     private Skin skin = GameState.defaultSkin;
     private Skin altskin = GameState.altSkin;
     private TextButton backButton;
     private TextButton nextButton;
     private InputMultiplexer inputMultiplexer = new InputMultiplexer();
     private Boolean nextPage = false;
     Image backgroundImage;
 
     public HowToPlayScreen() {
         stage = new Stage();
         table = new Table();
         table2 = new Table();
         table3 = new Table();
 
         // Create an Image for the background
         backgroundImage = new Image(new Texture(Gdx.files.internal("GameScreen.png")));
         backgroundImage.setFillParent(true); // Fill the screen with image
         stage.addActor(backgroundImage); // Add the background to the stage
         backgroundImage.setVisible(false);
 
         // Back button
         backButton = new TextButton("Back to main screen", altskin);
         backButton.addListener(new ClickListener() {
             @Override
             public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
                 // Go back to the start menu
                 GameState.currentScreen = GameState.startScreen;
             }
         });
 
         // Next button
         nextButton = new TextButton("Next Page", altskin);
         nextButton.addListener(new ClickListener() {
             @Override
             public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
                 nextPage = !nextPage;
             }
         });
 
         // Create a label with how to play instructions
         FileHandle file = Gdx.files.internal("HowToPlay.txt");
         String text = file.readString();
         Label howToPlayLabel = new Label(text, altskin);
         howToPlayLabel.setWrap(true); // Enable text wrapping
         howToPlayLabel.setAlignment(Align.left); // Align text to the left
 
         // Create a ScrollPane for the label
         ScrollPane scrollPane = new ScrollPane(howToPlayLabel, skin);
         scrollPane.setScrollingDisabled(true, false); // Only allow vertical scrolling
         scrollPane.setFadeScrollBars(false); // Keep scrollbars visible at all times
 
         // Add UI elements to stage
         table.setFillParent(true);
         table.center().center();
         table.pad(750, 100, 100, 100);
         table.add(backButton).center().width(430).height(40).padRight(580);
         table.add(nextButton).center().width(240).height(40);
         stage.addActor(table);
 
         // Add UI elements to stage
         table2.setFillParent(true);
         table2.center().center();
         table2.add(scrollPane).expand().fill().padTop(50).padBottom(90);
         stage.addActor(table2);
 
         // Add UI elements to stage
         table3.setFillParent(true);
         table3.center().center();
         table3.add(new Label("~How to play~", altskin)).top().padBottom(680);
         stage.addActor(table3);
 
         inputMultiplexer.addProcessor(GameState.fullscreenInputProcessor);
         inputMultiplexer.addProcessor(stage);
     }
 
     @Override
     public void show() {
     }
 
     @Override
     public void render(float delta) {
         // Clear the screen
         Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 
         if (nextPage) {
             backgroundImage.setVisible(true);
             table2.setVisible(false);
             table3.setVisible(false);
         } else {
             backgroundImage.setVisible(false);
             table2.setVisible(true);
             table3.setVisible(true);
         }
 
         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(inputMultiplexer);
     }
 
     @Override
     public void hide() {
     }
 
     @Override
     public void dispose() {
         stage.dispose();
         skin.dispose();
     }
 }