diff --git a/core/src/ru/deadsoftware/cavedroid/CaveGame.java b/core/src/ru/deadsoftware/cavedroid/CaveGame.java
index 031b6135ae3fb58153427d52e76814d598898124..14ea70533cf4cfadfea87ff4cdf9028468730567 100644 (file)
package ru.deadsoftware.cavedroid;
+import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
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.8.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) {
}
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);
mMainConfig.setWidth(width);
mMainConfig.setHeight(height);
mMainConfig.setShowInfo(mDebug);
+ mMainConfig.setAssetsPackPath(mAssetsPackPath);
+
+ if (mDebug) {
+ Gdx.app.setLogLevel(Application.LOG_DEBUG);
+ } else {
+ Gdx.app.setLogLevel(Application.LOG_ERROR);
+ }
}
- public void newGame() {
+ public void newGame(int gameMode) {
GameScreen gameScreen = mMainComponent.getGameScreen();
- gameScreen.newGame();
+ gameScreen.newGame(gameMode);
setScreen(gameScreen);
}
}
public void quitGame() {
+ if (screen != null) {
+ screen.dispose();
+ }
setScreen(mMainComponent.getMenuScreen());
}
@Override
public void create() {
- Gdx.app.log(TAG, mGameFolder);
Gdx.files.absolute(mGameFolder).mkdirs();
-
- Assets.load();
- GameItems.load();
-
initConfig();
+ Gdx.app.debug(TAG, mGameFolder);
+ Assets.load(mAssetLoader);
setScreen(mMainComponent.getMenuScreen());
}
+ @Override
+ public void dispose() {
+ if (screen != null) {
+ screen.dispose();
+ }
+ Assets.dispose();
+ }
}