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

General

parent b125df0e
No related branches found
No related tags found
No related merge requests found
core/assets/options/general.png

219 KiB

File added
package com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.General;
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.GeneralUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.OptionUI;
public class BackButton extends ImButton {
private Sound clickSound;
private OptionUI optionUI;
private GeneralUI generalUI;
public BackButton(float x, float y, float width, float height, OptionUI optionUI, GeneralUI generalUI) {
super(new Texture("options/escape_back_on.png"), x, y, width, height);
this.optionUI = optionUI;
this.generalUI = generalUI;
this.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
leftClick();
}
});
}
@Override
public void leftClick() {
generalUI.disposeGeneralUI();
optionUI.showOptionsUI();
}
}
package com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons;
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 GeneralButton extends ImButton {
private Sound clickSound;
private OptionUI optionUI;
private PauseMenuUI pauseMenuUI;
public GeneralButton(float x, float y, float width, float height, OptionUI optionUI) {
super(new Texture("options/escape_general_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.openGeneral();
}
}
...@@ -4,7 +4,6 @@ import com.badlogic.gdx.audio.Sound; ...@@ -4,7 +4,6 @@ import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent; 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.Main;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton;
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;
......
...@@ -24,6 +24,7 @@ import com.galaxytrucker.galaxytruckerreloaded.Model.Weapons.Weapon; ...@@ -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.EventGUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.GameOver; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.GameOver;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Events.ShopUI; 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.OptionUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Options.PauseMenuUI;
import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.EnemyShip; import com.galaxytrucker.galaxytruckerreloaded.View.UI.Ship.EnemyShip;
...@@ -88,6 +89,19 @@ public class GamePlay implements Screen { ...@@ -88,6 +89,19 @@ public class GamePlay implements Screen {
*/ */
private GameOver gameOverUI; private GameOver gameOverUI;
/**
* in Options the GeneralUI
*/
private GeneralUI generalUI;
/**
* Gets the current open OptionUI
* @return current OptionUI
*/
public OptionUI getOptionUI() {
return optionUI;
}
/** /**
* the ingame options ui, if existing * the ingame options ui, if existing
*/ */
...@@ -111,6 +125,10 @@ public class GamePlay implements Screen { ...@@ -111,6 +125,10 @@ public class GamePlay implements Screen {
private PauseMenu pauseMenu; private PauseMenu pauseMenu;
/**
* Gets the current PauseMenu.
* @return current PauseMenuUI
*/
public PauseMenuUI getPauseMenuUI() { public PauseMenuUI getPauseMenuUI() {
return pauseMenuUI; return pauseMenuUI;
} }
...@@ -200,6 +218,7 @@ public class GamePlay implements Screen { ...@@ -200,6 +218,7 @@ 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(generalUI != null) { generalUI.render(); }
else if(optionUI != null) { optionUI.render(); } else if(optionUI != null) { optionUI.render(); }
else if(pauseMenuUI != null) { pauseMenuUI.render(); } else if(pauseMenuUI != null) { pauseMenuUI.render(); }
...@@ -213,6 +232,7 @@ public class GamePlay implements Screen { ...@@ -213,6 +232,7 @@ 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(generalUI != null) { generalUI.disposeGeneralUI(); }
if(optionUI != null) { optionUI.disposeOptionsUI(); } if(optionUI != null) { optionUI.disposeOptionsUI(); }
if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); } if(pauseMenuUI != null) { pauseMenuUI.disposePauseMenuUI(); }
stage.dispose(); stage.dispose();
...@@ -267,7 +287,7 @@ public class GamePlay implements Screen { ...@@ -267,7 +287,7 @@ public class GamePlay implements Screen {
} }
/** /**
* opens in game options * opens in game pause menu
* called by controller * called by controller
*/ */
public void createPauseMenu() { public void createPauseMenu() {
...@@ -277,18 +297,41 @@ public class GamePlay implements Screen { ...@@ -277,18 +297,41 @@ public class GamePlay implements Screen {
//TODO controller sagen dass spiel "pausiert"? //TODO controller sagen dass spiel "pausiert"?
} }
/**
* closes in game pause menu
*/
public void deletePauseMenu() { public void deletePauseMenu() {
pauseMenuUI = null; pauseMenuUI = null;
} }
/**
* opens in game options
*/
public void createOptions() { public void createOptions() {
optionUI = new OptionUI(main, stage, this); optionUI = new OptionUI(main, stage, this);
} }
/**
* closes in game options
*/
public void deleteOptions() { public void deleteOptions() {
optionUI = null; optionUI = null;
} }
/**
* opens in game general options
*/
public void createGeneralUI() {
generalUI = new GeneralUI(main, stage, this);
}
/**
* closes in game general options
*/
public void deleteGeneralUI() {
generalUI = null;
}
public void createShip() { public void createShip() {
} }
...@@ -388,4 +431,6 @@ public class GamePlay implements Screen { ...@@ -388,4 +431,6 @@ public class GamePlay implements Screen {
this.background = background; this.background = background;
} }
} }
package com.galaxytrucker.galaxytruckerreloaded.View.UI.Options; 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.General.BackButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay;
/**
* ingame options/general screen
*/
public class GeneralUI { public class GeneralUI {
/**
* background
*/
private Texture generalBackgroundTexture;
/**
* 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 GeneralUI (Main main, Stage stage, GamePlay gamePlay) {
this.main = main;
this.gamePlay = gamePlay;
this.optionUI = gamePlay.getOptionUI();
generalBackgroundTexture = new Texture("options/general.png");
x = main.WIDTH / 2 - generalBackgroundTexture.getWidth() / 2;
y = main.HEIGHT / 2 - generalBackgroundTexture.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(generalBackgroundTexture, x, y, 601, 471);
main.batch.end();
}
/**
* Dispose of options ui
*/
public void disposeGeneralUI() {
generalBackgroundTexture.dispose();
backButton.remove();
gamePlay.deleteGeneralUI();
}
/**
* Setup called after initialisation
*/
private void setup() {
}
/**
* Open the options menu
*/
public void showGeneralUI() {
backButton.setVisible(true);
}
/**
* Close the options menu
*/
public void hideGeneralUI() {
backButton.setVisible(false);
}
/**
* handles input to pause game, open options
*/
public void updateInput() {
if(Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
disposeGeneralUI();
optionUI.showOptionsUI();
}
}
} }
...@@ -6,8 +6,10 @@ import com.badlogic.gdx.graphics.Texture; ...@@ -6,8 +6,10 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.Main;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.MainMenuButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.MainMenuButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.GeneralButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.OptionenBackButton; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.InGameButtons.OptionButtons.OptionenBackButton;
import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay; import com.galaxytrucker.galaxytruckerreloaded.View.Screen.GamePlay;
import com.sun.tools.javac.jvm.Gen;
/** /**
* Ingame Option screen * Ingame Option screen
...@@ -26,6 +28,8 @@ public class OptionUI { ...@@ -26,6 +28,8 @@ public class OptionUI {
private OptionenBackButton optionenBackButton; private OptionenBackButton optionenBackButton;
private GeneralButton generalButton;
private Main main; private Main main;
private GamePlay game; private GamePlay game;
...@@ -48,9 +52,11 @@ public class OptionUI { ...@@ -48,9 +52,11 @@ 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;
optionenBackButton = new OptionenBackButton(x+220, y+270, 128, 24, this, pauseMenuUI); optionenBackButton = new OptionenBackButton(x+220, y+220, 128, 24, this, pauseMenuUI);
generalButton = new GeneralButton(x+220, y+270, 128, 24, this);
stage.addActor(optionenBackButton); stage.addActor(optionenBackButton);
stage.addActor(generalButton);
} }
/** /**
...@@ -70,6 +76,7 @@ public class OptionUI { ...@@ -70,6 +76,7 @@ public class OptionUI {
public void disposeOptionsUI() { public void disposeOptionsUI() {
optionsBackgroundTexture.dispose(); optionsBackgroundTexture.dispose();
optionenBackButton.remove(); optionenBackButton.remove();
generalButton.remove();
game.deleteOptions(); game.deleteOptions();
} }
...@@ -83,12 +90,16 @@ public class OptionUI { ...@@ -83,12 +90,16 @@ public class OptionUI {
* Open the options menu * Open the options menu
*/ */
public void showOptionsUI() { public void showOptionsUI() {
generalButton.setVisible(true);
optionenBackButton.setVisible(true);
} }
/** /**
* Close the options menu * Close the options menu
*/ */
public void hideOptionsUI() { public void hideOptionsUI() {
generalButton.setVisible(false);
optionenBackButton.setVisible(false);
} }
/** /**
...@@ -100,4 +111,9 @@ public class OptionUI { ...@@ -100,4 +111,9 @@ public class OptionUI {
pauseMenuUI.showPauseMenuUI(); pauseMenuUI.showPauseMenuUI();
} }
} }
public void openGeneral() {
this.hideOptionsUI();
game.createGeneralUI();
}
} }
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