Skip to content
Snippets Groups Projects
Commit b8f9b7bc authored by Samuel Nejati Masouleh's avatar Samuel Nejati Masouleh
Browse files

Pause menu von Options getrennt

parent 847272f1
No related branches found
No related tags found
No related merge requests found
core/assets/options/pause.JPG

37.3 KiB

...@@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent; ...@@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.MainMenu; import com.galaxytrucker.galaxytruckerreloaded.View.Screen.MainMenu;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.PauseMenu;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI;
...@@ -19,7 +20,7 @@ public class OptionButton extends ImButton{ ...@@ -19,7 +20,7 @@ public class OptionButton extends ImButton{
*/ */
private Sound clickSound; private Sound clickSound;
private OptionUI optionUI; private PauseMenuUI pauseMenuUI;
/** Menu object */ /** Menu object */
private MainMenu mainMenu; private MainMenu mainMenu;
...@@ -28,14 +29,14 @@ public class OptionButton extends ImButton{ ...@@ -28,14 +29,14 @@ public class OptionButton extends ImButton{
* Constructor * Constructor
* *
*/ */
public OptionButton(float x, float y, float width, float height, OptionUI ui) { public OptionButton(float x, float y, float width, float height, PauseMenuUI ui) {
super(new Texture("escape_options_on.png"), x, y, width, height); super(new Texture("escape_options_on.png"), x, y, width, height);
this.addListener(new ClickListener() { this.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
leftClick(); leftClick();
} }
}); });
this.optionUI = ui; this.pauseMenuUI = ui;
} }
/** /**
...@@ -43,7 +44,7 @@ public class OptionButton extends ImButton{ ...@@ -43,7 +44,7 @@ public class OptionButton extends ImButton{
*/ */
public void leftClick() public void leftClick()
{ {
optionUI.render(); pauseMenuUI.openOptions();
} }
} }
......
...@@ -195,8 +195,8 @@ public class GamePlay implements Screen { ...@@ -195,8 +195,8 @@ public class GamePlay implements Screen {
if(shopUI != null) { shopUI.render(); } if(shopUI != null) { shopUI.render(); }
else if(eventGUI != null) { eventGUI.render(); } else if(eventGUI != null) { eventGUI.render(); }
else if(gameOverUI != null) { gameOverUI.render(); } else if(gameOverUI != null) { gameOverUI.render(); }
else if(pauseMenuUI != null) { pauseMenuUI.render(); }
else if(optionUI != null) { optionUI.render(); } else if(optionUI != null) { optionUI.render(); }
else if(pauseMenuUI != null) { pauseMenuUI.render(); }
stage.draw(); stage.draw();
} }
...@@ -208,8 +208,8 @@ public class GamePlay implements Screen { ...@@ -208,8 +208,8 @@ public class GamePlay implements Screen {
if(shopUI != null) { shopUI.disposeShopUI(); } if(shopUI != null) { shopUI.disposeShopUI(); }
if(eventGUI != null) { eventGUI.disposeEventGUI(); } if(eventGUI != null) { eventGUI.disposeEventGUI(); }
if(gameOverUI != null) { gameOverUI.disposeGameoverUI(); } if(gameOverUI != null) { gameOverUI.disposeGameoverUI(); }
if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); }
if(optionUI != null) { optionUI.disposeOptionsUI(); } if(optionUI != null) { optionUI.disposeOptionsUI(); }
if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); }
stage.dispose(); stage.dispose();
} }
...@@ -221,7 +221,6 @@ public class GamePlay implements Screen { ...@@ -221,7 +221,6 @@ public class GamePlay implements Screen {
if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
System.out.println("Where"); System.out.println("Where");
createPauseMenu(); createPauseMenu();
createOptions();
} }
if(Gdx.input.isKeyPressed(Input.Keys.P)) { if(Gdx.input.isKeyPressed(Input.Keys.P)) {
//paused //paused
...@@ -276,10 +275,10 @@ public class GamePlay implements Screen { ...@@ -276,10 +275,10 @@ public class GamePlay implements Screen {
} }
public void createOptions() { public void createOptions() {
optionUI = new OptionUI(main, stage, this, pauseMenuUI); optionUI = new OptionUI(main, stage, this);
} }
public void removeOptions() { public void deleteOptions() {
optionUI = null; optionUI = null;
} }
......
...@@ -19,11 +19,6 @@ public class OptionUI { ...@@ -19,11 +19,6 @@ public class OptionUI {
*/ */
private Texture optionsBackgroundTexture; private Texture optionsBackgroundTexture;
/**
* continue button
*/
private ContinueButton continueButton;
/** /**
* main menu button * main menu button
*/ */
...@@ -33,8 +28,6 @@ public class OptionUI { ...@@ -33,8 +28,6 @@ public class OptionUI {
private GamePlay game; private GamePlay game;
private OptionButton optionButton;
private float x, y; private float x, y;
/** /**
...@@ -42,7 +35,7 @@ public class OptionUI { ...@@ -42,7 +35,7 @@ public class OptionUI {
* *
* @param main - main class * @param main - main class
*/ */
public OptionUI(Main main, Stage stage, GamePlay game, PauseMenuUI pauseMenuUI) { public OptionUI(Main main, Stage stage, GamePlay game) {
this.main = main; this.main = main;
this.game = game; this.game = game;
...@@ -51,9 +44,9 @@ public class OptionUI { ...@@ -51,9 +44,9 @@ public class OptionUI {
x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2; x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2;
y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2; y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2;
continueButton = new ContinueButton(x+220, y+220, 128, 24, pauseMenuUI); mainMenuButton = new MainMenuButton(x+220, y+270, 128, 24, main);
stage.addActor(continueButton); stage.addActor(mainMenuButton);
} }
/** /**
...@@ -71,10 +64,8 @@ public class OptionUI { ...@@ -71,10 +64,8 @@ public class OptionUI {
*/ */
public void disposeOptionsUI() { public void disposeOptionsUI() {
optionsBackgroundTexture.dispose(); optionsBackgroundTexture.dispose();
continueButton.remove();
mainMenuButton.remove(); mainMenuButton.remove();
optionButton.remove(); game.deleteOptions();
game.deletePauseMenu();
} }
/** /**
......
...@@ -50,14 +50,14 @@ public class PauseMenuUI { ...@@ -50,14 +50,14 @@ public class PauseMenuUI {
this.main = main; this.main = main;
this.game = game; this.game = game;
optionsBackgroundTexture = new Texture("options/options.png"); optionsBackgroundTexture = new Texture("options/pause.JPG");
x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2; x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2;
y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2; y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2;
continueButton = new ContinueButton(x+220, y+220, 128, 24, this); continueButton = new ContinueButton(x+220, y+220, 128, 24, this);
mainMenuButton = new MainMenuButton(x+220, y+270, 128, 24, main); mainMenuButton = new MainMenuButton(x+220, y+270, 128, 24, main);
optionButton = new OptionButton(x+220,y+320,128,24, optionUI); optionButton = new OptionButton(x+220,y+320,128,24, this);
stage.addActor(continueButton); stage.addActor(continueButton);
stage.addActor(mainMenuButton); stage.addActor(mainMenuButton);
...@@ -103,4 +103,11 @@ public class PauseMenuUI { ...@@ -103,4 +103,11 @@ public class PauseMenuUI {
*/ */
public void hideOptionsUI() { public void hideOptionsUI() {
} }
public void openOptions () {
continueButton.setVisible(false);
mainMenuButton.setVisible(false);
optionButton.setVisible(false);
game.createOptions();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment