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

test

parent a7ebaf5b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ 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.Screen.MainMenu;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI;
/**
......@@ -18,7 +19,7 @@ public class OptionButton extends ImButton{
*/
private Sound clickSound;
private PauseMenuUI ui;
private OptionUI optionUI;
/** Menu object */
private MainMenu mainMenu;
......@@ -27,14 +28,14 @@ public class OptionButton extends ImButton{
* Constructor
*
*/
public OptionButton(float x, float y, float width, float height, PauseMenuUI ui) {
public OptionButton(float x, float y, float width, float height, OptionUI ui) {
super(new Texture("escape_options_on.png"), x, y, width, height);
this.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
leftClick();
}
});
this.ui = ui;
this.optionUI = ui;
}
/**
......@@ -42,7 +43,7 @@ public class OptionButton extends ImButton{
*/
public void leftClick()
{
ui.render();
optionUI.render();
}
}
......
......@@ -6,6 +6,7 @@ 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.Screen.MainMenu;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI;
/**
......@@ -18,7 +19,9 @@ public class OptionButton extends ImButton{
*/
private Sound clickSound;
private PauseMenuUI ui;
private PauseMenuUI pauseMenuUI;
private OptionUI optionUI;
/** Menu object */
private MainMenu mainMenu;
......@@ -34,7 +37,7 @@ public class OptionButton extends ImButton{
leftClick();
}
});
this.ui = ui;
this.pauseMenuUI = ui;
}
/**
......
......@@ -24,6 +24,7 @@ import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.EventGUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.GameOver;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.ShopUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.EnemyShip;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.ShipView;
......@@ -90,7 +91,7 @@ public class GamePlay implements Screen {
/**
* the ingame options ui, if existing
*/
private PauseMenuUI optionsUI;
private OptionUI optionUI;
/**
* the main game class
......@@ -107,7 +108,9 @@ public class GamePlay implements Screen {
/**
* Pausemenu Object.
*/
PauseMenu pauseMenu;
private PauseMenu pauseMenu;
private PauseMenuUI pauseMenuUI;
/**
* Constructor
......@@ -192,7 +195,8 @@ public class GamePlay implements Screen {
if(shopUI != null) { shopUI.render(); }
else if(eventGUI != null) { eventGUI.render(); }
else if(gameOverUI != null) { gameOverUI.render(); }
else if(optionsUI != null) { optionsUI.render(); }
else if(pauseMenuUI != null) { pauseMenuUI.render(); }
else if(optionUI != null) { optionUI.render(); }
stage.draw();
}
......@@ -204,7 +208,8 @@ public class GamePlay implements Screen {
if(shopUI != null) { shopUI.disposeShopUI(); }
if(eventGUI != null) { eventGUI.disposeEventGUI(); }
if(gameOverUI != null) { gameOverUI.disposeGameoverUI(); }
if(optionsUI != null) { optionsUI.disposePauseMenuUI(); }
if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); }
if(optionUI != null) { optionUI.disposeOptionsUI(); }
stage.dispose();
}
......@@ -215,6 +220,7 @@ public class GamePlay implements Screen {
System.out.println("touched");
if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
System.out.println("Where");
createPauseMenu();
createOptions();
}
if(Gdx.input.isKeyPressed(Input.Keys.P)) {
......@@ -260,13 +266,21 @@ public class GamePlay implements Screen {
* opens in game options
* called by controller
*/
public void createOptions() {
optionsUI = new PauseMenuUI(main, stage, this);
public void createPauseMenu() {
pauseMenuUI = new PauseMenuUI(main, stage, this);
//TODO controller sagen dass spiel "pausiert"?
}
public void deleteOptions() {
optionsUI = null;
public void deletePauseMenu() {
pauseMenuUI = null;
}
public void createOptions() {
optionUI = new OptionUI(main, stage, this, pauseMenuUI);
}
public void removeOptions() {
optionUI = null;
}
public void createShip() {
......
......@@ -7,6 +7,7 @@ import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.Contin
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.MainMenuButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.PauseMenu;
/**
* Ingame Option screen
......@@ -41,7 +42,7 @@ public class OptionUI {
*
* @param main - main class
*/
public OptionUI(Main main, Stage stage, GamePlay game) {
public OptionUI(Main main, Stage stage, GamePlay game, PauseMenuUI pauseMenuUI) {
this.main = main;
this.game = game;
......@@ -50,7 +51,9 @@ public class OptionUI {
x = main.WIDTH/2 - optionsBackgroundTexture.getWidth()/2;
y = main.HEIGHT/2 - optionsBackgroundTexture.getHeight()/2;
continueButton = new ContinueButton(x+220, y+220, 128, 24, pauseMenuUI);
stage.addActor(continueButton);
}
/**
......@@ -71,7 +74,7 @@ public class OptionUI {
continueButton.remove();
mainMenuButton.remove();
optionButton.remove();
game.deleteOptions();
game.deletePauseMenu();
}
/**
......
package com.galaxytrucker.galaxytruckerreloaded.View.UI.Options;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.galaxytrucker.galaxytruckerreloaded.Main;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.ContinueButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.MainMenuButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay;
import org.graalvm.compiler.nodes.calc.IntegerDivRemNode;
/**
* Ingame options UI
......@@ -36,6 +32,11 @@ public class PauseMenuUI {
private GamePlay game;
private OptionUI optionUI;
/**
* Options button
*/
private OptionButton optionButton;
private float x, y;
......@@ -56,7 +57,7 @@ public class PauseMenuUI {
continueButton = new ContinueButton(x+220, y+220, 128, 24, this);
mainMenuButton = new MainMenuButton(x+220, y+270, 128, 24, main);
optionButton = new OptionButton(x+220,y+320,128,24, this);
optionButton = new OptionButton(x+220,y+320,128,24, optionUI);
stage.addActor(continueButton);
stage.addActor(mainMenuButton);
......@@ -81,7 +82,8 @@ public class PauseMenuUI {
continueButton.remove();
mainMenuButton.remove();
optionButton.remove();
game.deleteOptions();
optionsBackgroundTexture.dispose();
game.deletePauseMenu();
}
/**
......
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