diff --git a/core/assets/options/escape_video_on.png b/core/assets/options/escape_video_on.png index 3f618f95acdecaafa45f95be5ad34e7acbea8a46..d6fd745a855b3b3bdf90bb833a654d239aedc725 100644 Binary files a/core/assets/options/escape_video_on.png and b/core/assets/options/escape_video_on.png differ diff --git a/core/assets/options/video.png b/core/assets/options/video.png new file mode 100644 index 0000000000000000000000000000000000000000..183e94b33431ee55041b5b044b58d48970036bd5 Binary files /dev/null and b/core/assets/options/video.png differ diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/BackButton.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/BackButton.java index 996546dfa5ee2679ff515e8aa03e5d0651d9909b..6e7f9dc3f4da7c8e182f6bb75f9a84df3eaa0ecd 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/BackButton.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/BackButton.java @@ -30,7 +30,7 @@ public class BackButton extends ImButton { @Override public void leftClick() { - // Einkommentieren wenn disposeVideoUI implementiert// videoUI.disposeVideoUI(); + videoUI.disposeVideoUI(); optionUI.showOptionsUI(); } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/VideoButton.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/VideoButton.java new file mode 100644 index 0000000000000000000000000000000000000000..9f9ef3de07a3df0cd72ef8fbff0825414ce783e6 --- /dev/null +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/VideoButton.java @@ -0,0 +1,33 @@ +package com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.Video; + +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; +import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI; +import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI; + +public class VideoButton extends ImButton { + + private Sound clickSound; + + private OptionUI optionUI; + + private PauseMenuUI pauseMenuUI; + + public VideoButton(float x, float y, float width, float height, OptionUI optionUI) { + super(new Texture("options/escape_video_on.png"), x, y, width, height); + this.optionUI = optionUI; + this.addListener(new ClickListener() { + public void clicked(InputEvent event, float x, float y) { + leftClick(); + } + }); + } + + @Override + public void leftClick() { + optionUI.openVideo(); + } +} diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java index caae8641923675cbd9a4ad81bb4be5e9322ec953..9951dd9061ba09c6e103110ffab29cbf6fe72867 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java @@ -27,6 +27,7 @@ import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.ShopUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.GeneralUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI; +import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.VideoUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.EnemyShip; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.ShipView; @@ -90,10 +91,15 @@ public class GamePlay implements Screen { private GameOver gameOverUI; /** - * in Options the GeneralUI + * ingame general settings */ private GeneralUI generalUI; + /** + * ingame Video settings + */ + private VideoUI videoUI; + /** * Gets the current open OptionUI * @return current OptionUI @@ -218,6 +224,7 @@ public class GamePlay implements Screen { if(shopUI != null) { shopUI.render(); } else if(eventGUI != null) { eventGUI.render(); } else if(gameOverUI != null) { gameOverUI.render(); } + else if(videoUI != null) { videoUI.render(); } else if(generalUI != null) { generalUI.render(); } else if(optionUI != null) { optionUI.render(); } else if(pauseMenuUI != null) { pauseMenuUI.render(); } @@ -232,6 +239,7 @@ public class GamePlay implements Screen { if(shopUI != null) { shopUI.disposeShopUI(); } if(eventGUI != null) { eventGUI.disposeEventGUI(); } if(gameOverUI != null) { gameOverUI.disposeGameoverUI(); } + if(videoUI != null) { videoUI.disposeVideoUI(); } if(generalUI != null) { generalUI.disposeGeneralUI(); } if(optionUI != null) { optionUI.disposeOptionsUI(); } if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); } @@ -332,6 +340,22 @@ public class GamePlay implements Screen { generalUI = null; } + /** + * opens in game video options + */ + public void createVideoUI() { + videoUI = new VideoUI(main, stage, this); + } + + /** + * closes ingame video settings + */ + public void deleteVideoUI() { + videoUI = null; + } + + + public void createShip() { } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/OptionUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/OptionUI.java index 529520887aae241f824012af9dfd263f736f4415..3edf458d5e82a47f0a8cfd1837af93c36b6f1d92 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/OptionUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/OptionUI.java @@ -8,6 +8,7 @@ import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.MainMenuButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.General.GeneralButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.OptionenBackButton; +import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.Video.VideoButton; import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay; /** @@ -20,10 +21,7 @@ public class OptionUI { */ private Texture optionsBackgroundTexture; - /** - * main menu button - */ - private MainMenuButton mainMenuButton; + private VideoButton videoButton; private OptionenBackButton optionenBackButton; @@ -51,11 +49,13 @@ public class OptionUI { x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2; y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2; + videoButton = new VideoButton(x+220, y+270, 128, 24, this); optionenBackButton = new OptionenBackButton(x+220, y+220, 128, 24, this, pauseMenuUI); - generalButton = new GeneralButton(x+220, y+270, 128, 24, this); + generalButton = new GeneralButton(x+220, y+320, 128, 24, this); stage.addActor(optionenBackButton); stage.addActor(generalButton); + stage.addActor(videoButton); } /** @@ -76,6 +76,7 @@ public class OptionUI { optionsBackgroundTexture.dispose(); optionenBackButton.remove(); generalButton.remove(); + videoButton.remove(); game.deleteOptions(); } @@ -91,6 +92,7 @@ public class OptionUI { public void showOptionsUI() { generalButton.setVisible(true); optionenBackButton.setVisible(true); + videoButton.setVisible(true); } /** @@ -99,6 +101,7 @@ public class OptionUI { public void hideOptionsUI() { generalButton.setVisible(false); optionenBackButton.setVisible(false); + videoButton.setVisible(false); } /** @@ -115,4 +118,9 @@ public class OptionUI { this.hideOptionsUI(); game.createGeneralUI(); } + + public void openVideo() { + this.hideOptionsUI(); + game.createVideoUI(); + } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java index e8470a46e75dc412dd55b40b1791faf90c2b9bda..3f64af68118648e4d4c69c779bf7538ccfa1918a 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java @@ -1,4 +1,112 @@ package com.galaxytrucker.galaxytruckerreloaded.View.UI.Options; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.galaxytrucker.galaxytruckerreloaded.Main; +import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.Video.BackButton; +import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay; + public class VideoUI { + + /** + * background + */ + private Texture backgroundTexture; + + /** + * Main instance of the running game. + */ + private Main main; + + /** + * Gameplay instance of the running game; + */ + private GamePlay gamePlay; + + /** + * OptionUI of the running Optionmenu. + */ + private OptionUI optionUI; + + /** + * Position of the Window + */ + private float x, y; + + /** + * Back Button + */ + private BackButton backButton; + + /** + * Constructor + * @param main current Main instance + * @param stage current stage instance + * @param gamePlay current gameplay instance + */ + public VideoUI (Main main, Stage stage, GamePlay gamePlay) { + this.main = main; + this.gamePlay = gamePlay; + this.optionUI = gamePlay.getOptionUI(); + backgroundTexture = new Texture("options/video.png"); + + x = main.WIDTH / 2 - backgroundTexture.getWidth() / 2; + y = main.HEIGHT / 2 - backgroundTexture.getHeight() / 2; + + backButton = new BackButton(x + 220, y + 270, 128, 24, optionUI, this); + + stage.addActor(backButton); + } + + /** + * render + * no stage stuff + */ + public void render() { + updateInput(); + main.batch.begin(); + main.batch.draw(backgroundTexture, x, y, 601, 471); + main.batch.end(); + } + + /** + * Dispose of options ui + */ + public void disposeVideoUI() { + backgroundTexture.dispose(); + backButton.remove(); + gamePlay.deleteVideoUI(); + } + + /** + * Setup called after initialisation + */ + private void setup() { + } + + /** + * Open the options menu + */ + public void showVideoUI() { + backButton.setVisible(true); + } + + /** + * Close the options menu + */ + public void hideVideoUI() { + backButton.setVisible(false); + } + + /** + * handles input to pause game, open options + */ + public void updateInput() { + if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { + disposeVideoUI(); + optionUI.showOptionsUI(); + } + } }