DEADSOFTWARE

Add my repo for automultibind
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / CaveGame.java
index 885149f199376119967558384d442f9c02ab979e..9ca34b8e0507a5a42523accf769469847185661a 100644 (file)
@@ -3,9 +3,11 @@ package ru.deadsoftware.cavedroid;
 import com.badlogic.gdx.Application;
 import com.badlogic.gdx.Game;
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Graphics;
 import ru.deadsoftware.cavedroid.game.GameScreen;
 import ru.deadsoftware.cavedroid.misc.Assets;
 import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
+import ru.deadsoftware.cavedroid.prefs.PreferencesStore;
 
 import javax.annotation.Nullable;
 
@@ -13,7 +15,7 @@ public class CaveGame extends Game {
 
     private static final String TAG = "CaveGame";
 
-    public static final String VERSION = "alpha 0.6.1";
+    public static final String VERSION = "alpha 0.9.2";
 
     private final MainConfig mMainConfig;
     private final MainComponent mMainComponent;
@@ -26,12 +28,19 @@ public class CaveGame extends Game {
     @Nullable
     private final String mAssetsPackPath;
 
-    public CaveGame(String gameFolder, boolean touch, @Nullable String assetsPackPath) {
+    public CaveGame(String gameFolder,
+                    boolean touch,
+                    PreferencesStore preferencesStore,
+                    @Nullable String assetsPackPath) {
         mGameFolder = gameFolder;
         mTouch = touch;
         mAssetsPackPath = assetsPackPath;
 
-        mMainComponent = DaggerMainComponent.builder().caveGame(this).build();
+        mMainComponent = DaggerMainComponent
+                .builder()
+                .caveGame(this)
+                .preferencesStore(preferencesStore)
+                .build();
 
         mMainConfig = mMainComponent.getMainConfig();
         mAssetLoader = mMainComponent.getAssetLoader();
@@ -42,7 +51,7 @@ public class CaveGame extends Game {
     }
 
     private void initConfig() {
-        int width = mTouch ? 320 : 480;
+        int width = 480;
         int height = (int) (width * ((float) Gdx.graphics.getHeight() / Gdx.graphics.getWidth()));
 
         mMainConfig.setMainComponent(mMainComponent);
@@ -58,6 +67,14 @@ public class CaveGame extends Game {
         } else {
             Gdx.app.setLogLevel(Application.LOG_ERROR);
         }
+
+        mMainConfig.setFullscreenToggleListener((value) -> {
+            if (value) {
+                Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
+            } else {
+                Gdx.graphics.setWindowedMode(width, height);
+            }
+        });
     }
 
     public void newGame(int gameMode) {