DEADSOFTWARE

Update version
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / CaveGame.java
index 031b6135ae3fb58153427d52e76814d598898124..0fdf1ecd1252d8bd526e91d5cbaac59bb9d39953 100644 (file)
@@ -5,26 +5,36 @@ import com.badlogic.gdx.Gdx;
 import ru.deadsoftware.cavedroid.game.GameItems;
 import ru.deadsoftware.cavedroid.game.GameScreen;
 import ru.deadsoftware.cavedroid.misc.Assets;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
+
+import javax.annotation.Nullable;
 
 public class CaveGame extends Game {
 
     private static final String TAG = "CaveGame";
 
-    public static final String VERSION = "alpha 0.4";
+    public static final String VERSION = "alpha 0.5.0";
 
     private final MainConfig mMainConfig;
     private final MainComponent mMainComponent;
+    private final AssetLoader mAssetLoader;
 
     private final String mGameFolder;
     private final boolean mTouch;
     private boolean mDebug;
 
-    public CaveGame(String gameFolder, boolean touch) {
+    @Nullable
+    private final String mAssetsPackPath;
+
+    public CaveGame(String gameFolder, boolean touch, @Nullable String assetsPackPath) {
         mGameFolder = gameFolder;
         mTouch = touch;
+        mAssetsPackPath = assetsPackPath;
 
         mMainComponent = DaggerMainComponent.builder().caveGame(this).build();
+
         mMainConfig = mMainComponent.getMainConfig();
+        mAssetLoader = mMainComponent.getAssetLoader();
     }
 
     public void setDebug(boolean debug) {
@@ -41,6 +51,7 @@ public class CaveGame extends Game {
         mMainConfig.setWidth(width);
         mMainConfig.setHeight(height);
         mMainConfig.setShowInfo(mDebug);
+        mMainConfig.setAssetsPackPath(mAssetsPackPath);
     }
 
     public void newGame() {
@@ -56,6 +67,9 @@ public class CaveGame extends Game {
     }
 
     public void quitGame() {
+        if (screen != null) {
+            screen.dispose();
+        }
         setScreen(mMainComponent.getMenuScreen());
     }
 
@@ -64,11 +78,11 @@ public class CaveGame extends Game {
         Gdx.app.log(TAG, mGameFolder);
         Gdx.files.absolute(mGameFolder).mkdirs();
 
-        Assets.load();
-        GameItems.load();
-
         initConfig();
 
+        Assets.load(mAssetLoader);
+        GameItems.load(mAssetLoader);
+
         setScreen(mMainComponent.getMenuScreen());
     }