diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Communication/ClientControllerCommunicator.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Communication/ClientControllerCommunicator.java index ded70088f1fdf49728eb0fcf6bc09c67cd1eebc8..4748ce945d4e23898f968b02d5b870019fa54650 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Communication/ClientControllerCommunicator.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Communication/ClientControllerCommunicator.java @@ -87,7 +87,8 @@ public class ClientControllerCommunicator { HangerController.getInstance(); TraderController.getInstance(singleton); TravelController.getInstance(singleton); - AudioController.getInstance(singleton); + AudioController.getInstance(); + VideoController.getInstance(singleton); // TODO CREATE ALL CONTROLLERS HERE, all controllers should be singletons return singleton; } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/AudioController.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/AudioController.java index 22507fbbcf43e3e0225f408942b79a6f3201d773..196c363b9f589223ebe638471c32d168ce5b2d30 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/AudioController.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/AudioController.java @@ -20,18 +20,15 @@ public class AudioController extends Controller /**implements Audio*/ { private static AudioController singleton; - @NonNull - private ClientControllerCommunicator clientControllerCommunicator; - /** * return the instance of this singleton - * @param communicator the communicator + * @ * @return the singleton instance */ - public static AudioController getInstance(ClientControllerCommunicator communicator) { + public static AudioController getInstance() { if(singleton == null) { - singleton = new AudioController(communicator); + singleton = new AudioController(); } return singleton; } @@ -40,7 +37,6 @@ public class AudioController extends Controller /**implements Audio*/ { if(music!= null) { music = Gdx.audio.newMusic(file); music.setLooping(true); - music.setVolume(0.5f); music.play(); } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/VideoController.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/VideoController.java new file mode 100644 index 0000000000000000000000000000000000000000..bde571aecff4e3469f278f103cf5a104d5fff44e --- /dev/null +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Controller/VideoController.java @@ -0,0 +1,57 @@ +package com.galaxytrucker.galaxytruckerreloaded.Controller; +import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; +import com.galaxytrucker.galaxytruckerreloaded.Communication.ClientControllerCommunicator; +import com.galaxytrucker.galaxytruckerreloaded.Main; +import lombok.*; +import org.hibernate.graph.internal.parse.HEGLTokenTypes; + + +@Getter +@Setter + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) + +public class VideoController extends Controller{ + + private static VideoController singleton; + + private Main main; + + + @NonNull + private ClientControllerCommunicator clientControllerCommunicator; + + + /** + * return the instance of this singleton + * @param communicator the communicator + * @return the singleton instance + */ + public static VideoController getInstance(ClientControllerCommunicator communicator) { + if(singleton == null) { + singleton = new VideoController(communicator); + } + return singleton; + } + + private int getHight(Main main){ + return main.HEIGHT; + } + private int getWidth(Main main){ + return main.WIDTH; + } + + public void setResolution(int width, int height, Main main){ + main.HEIGHT = height; + main.WIDTH = width; + } + + public void setFullscreen() { + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + } + + public void setWindowed() { + Gdx.graphics.setWindowedMode(getWidth(main),getHight(main)); + } +} diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java index 1626125cbca3e1215c332d925bf2cf192532a0b3..3c2cbf33918af7c785c33a862ad73c87c25f2959 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/Main.java @@ -2,8 +2,10 @@ package com.galaxytrucker.galaxytruckerreloaded; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.galaxytrucker.galaxytruckerreloaded.Communication.Client; +import com.galaxytrucker.galaxytruckerreloaded.Controller.AudioController; import com.galaxytrucker.galaxytruckerreloaded.Server.Server; import com.galaxytrucker.galaxytruckerreloaded.Server.ServerServiceCommunicator; import com.galaxytrucker.galaxytruckerreloaded.View.Screen.LoginScreen; @@ -16,8 +18,8 @@ public class Main extends Game { /** * Settings */ - public static final int WIDTH = 1920; - public static final int HEIGHT = 1080; + public static int WIDTH = 1920; + public static int HEIGHT = 1080; public static final String TITLE = "Galaxy Trucker"; /** @@ -38,11 +40,12 @@ public class Main extends Game { @Setter private boolean server; + private Music music; /** * start a server, if there isnt one */ public void startServer() { - if(!server) { + if (!server) { Server.runServer(); server = true; } @@ -52,7 +55,7 @@ public class Main extends Game { * start a client, if there isnt already one */ public void startClient() { - if(client == null) { + if (client == null) { client = new Client("localhost", 5050); } } @@ -60,6 +63,7 @@ public class Main extends Game { @Override public void create() { batch = new SpriteBatch(); + AudioController.getInstance().setMusic(Gdx.files.internal("Sounds/Music/bp_MUS_WastelandEXPLORE.ogg")); setScreen(new MainMenu(this)); } @@ -83,12 +87,5 @@ public class Main extends Game { public SpriteBatch getBatch() { return this.batch; } - - public void setFullscreen() { - Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); - } - - public void setWindowed() { - Gdx.graphics.setWindowedMode(WIDTH,HEIGHT); - } } + diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/FullscreenEnableButton.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/FullscreenEnableButton.java index 6c594ece426d667a982276c6e210be9e084332f9..19b94293d536380a2d66c0fe55484829b56afc4e 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/FullscreenEnableButton.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/FullscreenEnableButton.java @@ -4,6 +4,7 @@ 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.Controller.VideoController; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; @@ -25,6 +26,6 @@ public class FullscreenEnableButton extends ImButton { @Override public void leftClick() { - main.setFullscreen(); + VideoController.getInstance(null).setFullscreen(); } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/WindowedButton.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/WindowedButton.java index 30ef43a6574cf19c038999a919d32899859de1a0..e6fc89c394c390f3cd6c771ae954e5113ad40508 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/WindowedButton.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Buttons/InGameButtons/OptionButtons/Video/WindowedButton.java @@ -4,6 +4,7 @@ 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.Controller.VideoController; import com.galaxytrucker.galaxytruckerreloaded.Main; import com.galaxytrucker.galaxytruckerreloaded.View.Buttons.ImButton; @@ -25,6 +26,6 @@ public class WindowedButton extends ImButton { @Override public void leftClick() { - main.setWindowed(); + VideoController.getInstance(null).setWindowed(); } } diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java index a740241e4e33a92684d6c0fa38eeb8c637b1fadc..58b3a825b687f157ec2aef74e943dfb822f0f9dd 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/Screen/GamePlay.java @@ -159,9 +159,6 @@ public class GamePlay implements Screen { pauseStage = new Stage(viewport, main.batch); tileStage = new Stage(viewport, main.batch); - //evtl. an anderer Stelle callen - AudioController.getInstance(null).setMusic(Gdx.files.internal("Sounds/Music/bp_MUS_WastelandEXPLORE.ogg")); - player = new ShipView(main, main.getClient().getMyShip(), stage, tileStage, main.getClient().getOverworld(), this); diff --git a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/AudioUI.java b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/AudioUI.java index 69b0407aa478fb8ebe92cfc8c2cb3518dff46dca..f9a81180809a510172c85fd9c4022d5fb091a330 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/AudioUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/AudioUI.java @@ -112,6 +112,7 @@ public class AudioUI { /** * handles input to pause game, open options + * TODO: funktioniert nicht, ist auch nicht zwingend Nötig */ public void updateInput() { //macht nicht was es soll. im Kern ein Bastard diese Methode 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 4c30ab563794671c350e16260b81860cc684e708..1ef31084fa256a4b3a8a6a7f2f1b6ca6d4bc028a 100644 --- a/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java +++ b/core/src/com/galaxytrucker/galaxytruckerreloaded/View/UI/Options/VideoUI.java @@ -86,6 +86,7 @@ public class VideoUI { /** * render * no stage stuff + * TODO: Absolutwerte durch Realtive Position ersetzen. */ public void render() { updateInput(); @@ -138,6 +139,7 @@ public class VideoUI { /** * handles input to pause game, open options + * TODO: funktioniert nicht, ist auch nicht zwingend Nötig */ public void updateInput() { //macht nicht was es soll. im Kern ein Bastard diese Methode