summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: 59ff932)
raw | patch | inline | side by side (from parent 1: 59ff932)
author | fredboy <fredboy@protonmail.com> | |
Tue, 16 Apr 2024 16:03:16 +0000 (23:03 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Tue, 16 Apr 2024 16:03:16 +0000 (23:03 +0700) |
14 files changed:
diff --git a/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java b/android/src/ru/deadsoftware/cavedroid/AndroidLauncher.java
index 88b62619bd1aebbc267b64bc45982bf540fc3808..e7aad50df8c3df8deab19206bf22d5fee456f3ef 100644 (file)
e.printStackTrace();
exit();
}
e.printStackTrace();
exit();
}
- CaveGame caveGame = new CaveGame(gameFolder, true);
+ CaveGame caveGame = new CaveGame(gameFolder, true, null);
caveGame.setDebug(BuildConfig.DEBUG);
initialize(caveGame, config);
}
caveGame.setDebug(BuildConfig.DEBUG);
initialize(caveGame, config);
}
diff --git a/core/src/ru/deadsoftware/cavedroid/CaveGame.java b/core/src/ru/deadsoftware/cavedroid/CaveGame.java
index 1f628a92fe68a6a960cfa4cc955a5633ecdfd8ed..287b67dbf5eb355a0c81a2048387e3c7ff9d6fef 100644 (file)
import ru.deadsoftware.cavedroid.game.GameItems;
import ru.deadsoftware.cavedroid.game.GameScreen;
import ru.deadsoftware.cavedroid.misc.Assets;
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 {
public class CaveGame extends Game {
private final MainConfig mMainConfig;
private final MainComponent mMainComponent;
private final MainConfig mMainConfig;
private final MainComponent mMainComponent;
+ private final AssetLoader mAssetLoader;
private final String mGameFolder;
private final boolean mTouch;
private boolean mDebug;
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;
mGameFolder = gameFolder;
mTouch = touch;
+ mAssetsPackPath = assetsPackPath;
mMainComponent = DaggerMainComponent.builder().caveGame(this).build();
mMainComponent = DaggerMainComponent.builder().caveGame(this).build();
+
mMainConfig = mMainComponent.getMainConfig();
mMainConfig = mMainComponent.getMainConfig();
+ mAssetLoader = mMainComponent.getAssetLoader();
}
public void setDebug(boolean debug) {
}
public void setDebug(boolean debug) {
mMainConfig.setWidth(width);
mMainConfig.setHeight(height);
mMainConfig.setShowInfo(mDebug);
mMainConfig.setWidth(width);
mMainConfig.setHeight(height);
mMainConfig.setShowInfo(mDebug);
+ mMainConfig.setAssetsPackPath(mAssetsPackPath);
}
public void newGame() {
}
public void newGame() {
Gdx.app.log(TAG, mGameFolder);
Gdx.files.absolute(mGameFolder).mkdirs();
Gdx.app.log(TAG, mGameFolder);
Gdx.files.absolute(mGameFolder).mkdirs();
- Assets.load();
- GameItems.load();
-
initConfig();
initConfig();
+ Assets.load(mAssetLoader);
+ GameItems.load(mAssetLoader);
+
setScreen(mMainComponent.getMenuScreen());
}
setScreen(mMainComponent.getMenuScreen());
}
diff --git a/core/src/ru/deadsoftware/cavedroid/MainComponent.java b/core/src/ru/deadsoftware/cavedroid/MainComponent.java
index d8a05da03fbdeda134cc144a6af804f881ff48d9..c640fb6c2abae2e5b5d12bc4574622419ab2e9b1 100644 (file)
import dagger.Component;
import ru.deadsoftware.cavedroid.game.GameScreen;
import ru.deadsoftware.cavedroid.menu.MenuScreen;
import dagger.Component;
import ru.deadsoftware.cavedroid.game.GameScreen;
import ru.deadsoftware.cavedroid.menu.MenuScreen;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
import javax.inject.Singleton;
import javax.inject.Singleton;
MenuScreen getMenuScreen();
MainConfig getMainConfig();
MenuScreen getMenuScreen();
MainConfig getMainConfig();
+
+ AssetLoader getAssetLoader();
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/MainConfig.java b/core/src/ru/deadsoftware/cavedroid/MainConfig.java
index 8cd0ffdac6920e2977f46ac10c156e8be4f4ac7f..ff077ee8a64933dc9e1346efbecf6cbccf4e23f5 100644 (file)
import ru.deadsoftware.cavedroid.game.GameUiWindow;
import javax.annotation.CheckForNull;
import ru.deadsoftware.cavedroid.game.GameUiWindow;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.inject.Inject;
import javax.inject.Singleton;
private float mWidth;
private float mHeight;
private float mWidth;
private float mHeight;
+ @Nullable
+ private String mAssetsPackPath = null;
+
@Inject
public MainConfig(CaveGame caveGame) {
mCaveGame = caveGame;
@Inject
public MainConfig(CaveGame caveGame) {
mCaveGame = caveGame;
public void setShowMap(boolean showMap) {
mShowMap = showMap;
}
public void setShowMap(boolean showMap) {
mShowMap = showMap;
}
+
+ @Nullable
+ public String getAssetsPackPath() {
+ return mAssetsPackPath;
+ }
+
+ public void setAssetsPackPath(@Nullable String assetsPackPath) {
+ mAssetsPackPath = assetsPackPath;
+ }
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInputProcessor.java b/core/src/ru/deadsoftware/cavedroid/game/GameInputProcessor.java
index 5d86b2e5c5db5e5db2a5aaffc69711e085658490..7eb35bd0c45b8a1b9c5811cc356ae2e889e42991 100644 (file)
import ru.deadsoftware.cavedroid.MainConfig;
import ru.deadsoftware.cavedroid.game.objects.TouchButton;
import ru.deadsoftware.cavedroid.misc.Assets;
import ru.deadsoftware.cavedroid.MainConfig;
import ru.deadsoftware.cavedroid.game.objects.TouchButton;
import ru.deadsoftware.cavedroid.misc.Assets;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
import javax.inject.Inject;
import javax.inject.Inject;
private final GameInput mGameInput;
private final GameRenderer mGameRenderer;
private final MainConfig mMainConfig;
private final GameInput mGameInput;
private final GameRenderer mGameRenderer;
private final MainConfig mMainConfig;
+ private final AssetLoader mAssetLoader;
@Inject
public GameInputProcessor(GameInput gameInput,
GameRenderer gameRenderer,
@Inject
public GameInputProcessor(GameInput gameInput,
GameRenderer gameRenderer,
- MainConfig mainConfig) {
+ MainConfig mainConfig,
+ AssetLoader assetLoader) {
mGameInput = gameInput;
mGameRenderer = gameRenderer;
mMainConfig = mainConfig;
mGameInput = gameInput;
mGameRenderer = gameRenderer;
mMainConfig = mainConfig;
+ mAssetLoader = assetLoader;
loadTouchButtonsFromJSON();
}
loadTouchButtonsFromJSON();
}
}
private void loadTouchButtonsFromJSON() {
}
private void loadTouchButtonsFromJSON() {
- JsonValue json = Assets.jsonReader.parse(Gdx.files.internal("json/touch_buttons.json"));
+ JsonValue json = Assets.jsonReader.parse(mAssetLoader.getAssetHandle("json/touch_buttons.json"));
for (JsonValue key = json.child(); key != null; key = key.next()) {
float x = key.getFloat("x");
float y = key.getFloat("y");
for (JsonValue key = json.child(); key != null; key = key.next()) {
float x = key.getFloat("x");
float y = key.getFloat("y");
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java
index 1cebf860ac5f0be1f9a03c2763969d31c0b43c1a..7a619b30748da834cdd003dcf4a7da2362b94979 100644 (file)
import ru.deadsoftware.cavedroid.game.objects.Block;
import ru.deadsoftware.cavedroid.game.objects.Item;
import ru.deadsoftware.cavedroid.misc.Assets;
import ru.deadsoftware.cavedroid.game.objects.Block;
import ru.deadsoftware.cavedroid.game.objects.Item;
import ru.deadsoftware.cavedroid.misc.Assets;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
import java.util.HashMap;
import java.util.HashMap;
return items.getValueAt(id).getType().equals("block") ? getBlockTex(id) : getItem(id).getTexture();
}
return items.getValueAt(id).getType().equals("block") ? getBlockTex(id) : getItem(id).getTexture();
}
- public static void load() {
- JsonValue json = Assets.jsonReader.parse(Gdx.files.internal("json/game_items.json"));
+ public static void load(AssetLoader assetLoader) {
+ JsonValue json = Assets.jsonReader.parse(assetLoader.getAssetHandle("json/game_items.json"));
for (JsonValue block = json.get("blocks").child(); block != null; block = block.next()) {
try {
String key = block.name();
for (JsonValue block = json.get("blocks").child(); block != null; block = block.next()) {
try {
String key = block.name();
String meta = Assets.getStringFromJson(block, "meta", "");
String tex = Assets.getStringFromJson(block, "texture", key);
Texture texture = tex.equals("none") ? null :
String meta = Assets.getStringFromJson(block, "meta", "");
String tex = Assets.getStringFromJson(block, "texture", key);
Texture texture = tex.equals("none") ? null :
- new Texture(Gdx.files.internal("textures/blocks/" + tex + ".png"));
+ new Texture(assetLoader.getAssetHandle("textures/blocks/" + tex + ".png"));
boolean animated = Assets.getBooleanFromJson(block, "animated", false);
int frames = Assets.getIntFromJson(block, "frames", 0);
boolean animated = Assets.getBooleanFromJson(block, "animated", false);
int frames = Assets.getIntFromJson(block, "frames", 0);
String type = Assets.getStringFromJson(item, "type", "item");
String texture = Assets.getStringFromJson(item, "texture", key);
Sprite sprite = type.equals("block") ? null :
String type = Assets.getStringFromJson(item, "type", "item");
String texture = Assets.getStringFromJson(item, "texture", key);
Sprite sprite = type.equals("block") ? null :
- new Sprite(new Texture(Gdx.files.internal("textures/items/" + texture + ".png")));
+ new Sprite(new Texture(assetLoader.getAssetHandle("textures/items/" + texture + ".png")));
itemsIds.put(key, items.size);
items.put(key, new Item(name, type, sprite));
} catch (GdxRuntimeException e) {
itemsIds.put(key, items.size);
items.put(key, new Item(name, type, sprite));
} catch (GdxRuntimeException e) {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Pig.java
index 376c68bf641bb0581d280802995ff49f9f52a0e8..22903876fd393dd01469d1cad38355927e8c66a2 100644 (file)
changeDir();
}
}
changeDir();
}
}
-
- if (mVelocity.x != 0f) {
- mAnim += mAnimDelta * delta;
- } else {
- mAnim = 0;
- }
-
- if (mAnim >= 60 || mAnim <= -60) {
- mAnimDelta = -mAnimDelta;
- }
}
@Override
}
@Override
diff --git a/core/src/ru/deadsoftware/cavedroid/menu/MenuProc.java b/core/src/ru/deadsoftware/cavedroid/menu/MenuProc.java
index f96d4d42756545c2d13cfc20de9a74655f986c15..2b645207cd010c0f197694457abb59bbe6556f0b 100644 (file)
private Menu mCurrentMenu;
@Inject
private Menu mCurrentMenu;
@Inject
- public MenuProc(MainConfig mainConfig) {
+ public MenuProc(
+ MainConfig mainConfig,
+ MenuMain.Factory menuMainFactory,
+ MenuNewGame.Factory menuNewGameFactory
+ ) {
super(mainConfig.getWidth(), mainConfig.getHeight());
mMainConfig = mainConfig;
Input menuInput = new Input();
super(mainConfig.getWidth(), mainConfig.getHeight());
mMainConfig = mainConfig;
Input menuInput = new Input();
- mMenuMain = new MenuMain(getWidth(), getHeight(), this::drawButton, mainConfig, menuInput);
- mMenuNewGame = new MenuNewGame(getWidth(), getHeight(), this::drawButton, mainConfig, menuInput);
+ mMenuMain = menuMainFactory.get(getWidth(), getHeight(), this::drawButton, menuInput);
+ mMenuNewGame = menuNewGameFactory.get(getWidth(), getHeight(), this::drawButton, menuInput);
mCurrentMenu = mMenuMain;
}
mCurrentMenu = mMenuMain;
}
diff --git a/core/src/ru/deadsoftware/cavedroid/menu/submenus/Menu.java b/core/src/ru/deadsoftware/cavedroid/menu/submenus/Menu.java
index 9f8df4c25d96d498c6019c1e123ef99a61e05c6e..587d0f622ebbc5df347d482734e75996bc006c3a 100644 (file)
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
import ru.deadsoftware.cavedroid.misc.Assets;
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
import ru.deadsoftware.cavedroid.misc.Assets;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
import java.util.HashMap;
import java.util.HashMap;
protected final MainConfig mMainConfig;
protected final MenuProc.Input mMenuInput;
protected final MainConfig mMainConfig;
protected final MenuProc.Input mMenuInput;
+ protected final AssetLoader mAssetLoader;
private final ButtonRenderer mButtonRenderer;
private final ButtonRenderer mButtonRenderer;
* @param height Viewport height
* @param buttonRenderer {@link ButtonRenderer} that will draw the buttons of this menu
*/
* @param height Viewport height
* @param buttonRenderer {@link ButtonRenderer} that will draw the buttons of this menu
*/
- Menu(float width, float height, ButtonRenderer buttonRenderer, MainConfig mainConfig, MenuProc.Input menuInput) {
+ Menu(float width,
+ float height,
+ ButtonRenderer buttonRenderer,
+ MainConfig mainConfig,
+ MenuProc.Input menuInput,
+ AssetLoader assetLoader) {
mWidth = width;
mHeight = height;
mButtonRenderer = buttonRenderer;
mMainConfig = mainConfig;
mMenuInput = menuInput;
mWidth = width;
mHeight = height;
mButtonRenderer = buttonRenderer;
mMainConfig = mainConfig;
mMenuInput = menuInput;
+ mAssetLoader = assetLoader;
initButtons();
}
initButtons();
}
diff --git a/core/src/ru/deadsoftware/cavedroid/menu/submenus/MenuMain.java b/core/src/ru/deadsoftware/cavedroid/menu/submenus/MenuMain.java
index d2dedd23c351f3fc8e91626375e55a0f3b3fd90d..f71183a0583ce95b4c78fa760cb081e5323188e0 100644 (file)
import ru.deadsoftware.cavedroid.menu.objects.Button;
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
import ru.deadsoftware.cavedroid.menu.objects.Button;
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
+import javax.inject.Inject;
import java.util.HashMap;
public class MenuMain extends Menu {
import java.util.HashMap;
public class MenuMain extends Menu {
- public MenuMain(float width, float height, ButtonRenderer buttonRenderer, MainConfig mainConfig, MenuProc.Input menuInput) {
- super(width, height, buttonRenderer, mainConfig, menuInput);
+ public MenuMain(float width,
+ float height,
+ ButtonRenderer buttonRenderer,
+ MainConfig mainConfig,
+ MenuProc.Input menuInput,
+ AssetLoader assetLoader) {
+ super(width, height, buttonRenderer, mainConfig, menuInput, assetLoader);
}
@Override
}
@Override
@Override
protected void initButtons() {
@Override
protected void initButtons() {
- loadButtonsFromJson(Gdx.files.internal("json/menu_main_buttons.json"));
+ loadButtonsFromJson(mAssetLoader.getAssetHandle("json/menu_main_buttons.json"));
if (GameSaver.exists(mMainConfig)) {
getButtons().get("load_game").setType(Button.NORMAL);
}
}
if (GameSaver.exists(mMainConfig)) {
getButtons().get("load_game").setType(Button.NORMAL);
}
}
+
+ public static class Factory {
+
+ private final MainConfig mMainConfig;
+ private final AssetLoader mAssetLoader;
+
+ @Inject
+ public Factory(MainConfig mainConfig, AssetLoader assetLoader) {
+ mMainConfig = mainConfig;
+ mAssetLoader = assetLoader;
+ }
+
+ public MenuMain get(float width, float height, ButtonRenderer buttonRenderer, MenuProc.Input menuInput) {
+ return new MenuMain(width, height, buttonRenderer, mMainConfig, menuInput, mAssetLoader);
+ }
+
+ }
+
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/menu/submenus/MenuNewGame.java b/core/src/ru/deadsoftware/cavedroid/menu/submenus/MenuNewGame.java
index 2c3b38bee9b041a5ae16fd4e2e5a4d1d707aacad..33985ff8206d395939c21c54d474e0017e26c5a3 100644 (file)
package ru.deadsoftware.cavedroid.menu.submenus;
package ru.deadsoftware.cavedroid.menu.submenus;
-import com.badlogic.gdx.Gdx;
import ru.deadsoftware.cavedroid.MainConfig;
import ru.deadsoftware.cavedroid.menu.MenuProc;
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
import ru.deadsoftware.cavedroid.MainConfig;
import ru.deadsoftware.cavedroid.menu.MenuProc;
import ru.deadsoftware.cavedroid.menu.objects.ButtonEventListener;
import ru.deadsoftware.cavedroid.menu.objects.ButtonRenderer;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
+import javax.inject.Inject;
import java.util.HashMap;
public class MenuNewGame extends Menu {
import java.util.HashMap;
public class MenuNewGame extends Menu {
- public MenuNewGame(float width, float height, ButtonRenderer buttonRenderer, MainConfig mainConfig, MenuProc.Input menuInput) {
- super(width, height, buttonRenderer, mainConfig, menuInput);
+ public MenuNewGame(float width,
+ float height,
+ ButtonRenderer buttonRenderer,
+ MainConfig mainConfig,
+ MenuProc.Input menuInput,
+ AssetLoader assetLoader) {
+ super(width, height, buttonRenderer, mainConfig, menuInput, assetLoader);
}
@Override
}
@Override
@Override
protected void initButtons() {
@Override
protected void initButtons() {
- loadButtonsFromJson(Gdx.files.internal("json/menu_new_game_buttons.json"));
+ loadButtonsFromJson(mAssetLoader.getAssetHandle("json/menu_new_game_buttons.json"));
+ }
+
+ public static class Factory {
+
+ private final MainConfig mMainConfig;
+ private final AssetLoader mAssetLoader;
+
+ @Inject
+ public Factory(MainConfig mainConfig, AssetLoader assetLoader) {
+ mMainConfig = mainConfig;
+ mAssetLoader = assetLoader;
+ }
+
+ public MenuNewGame get(float width, float height, ButtonRenderer buttonRenderer, MenuProc.Input menuInput) {
+ return new MenuNewGame(width, height, buttonRenderer, mMainConfig, menuInput, mAssetLoader);
+ }
+
}
}
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java
index 90a7ec1bec4c818a12286161603d751152586f7e..7055a73cfaa3b7a9b3ed1269f0ba123d980b23d3 100644 (file)
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import ru.deadsoftware.cavedroid.game.objects.TouchButton;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import ru.deadsoftware.cavedroid.game.objects.TouchButton;
+import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
import java.util.HashMap;
import java.util.HashMap;
return sprite;
}
return sprite;
}
- private static void loadMob(Sprite[][] sprite, String mob) {
+ private static void loadMob(AssetLoader assetLoader, Sprite[][] sprite, String mob) {
for (int i = 0; i < sprite.length; i++) {
for (int j = 0; j < sprite[i].length; j++) {
sprite[i][j] = flippedSprite(new Texture(
for (int i = 0; i < sprite.length; i++) {
for (int j = 0; j < sprite[i].length; j++) {
sprite[i][j] = flippedSprite(new Texture(
- Gdx.files.internal("mobs/" + mob + "/" + i + "_" + j + ".png")));
+ assetLoader.getAssetHandle("mobs/" + mob + "/" + i + "_" + j + ".png")));
sprite[i][j].setOrigin(sprite[i][j].getWidth() / 2, 0);
}
}
sprite[i][j].setOrigin(sprite[i][j].getWidth() / 2, 0);
}
}
* Loads texture names and sizes from <b>json/texture_regions.json</b>, cuts them to TextureRegions
* and puts to {@link #textureRegions} HashMap
*/
* Loads texture names and sizes from <b>json/texture_regions.json</b>, cuts them to TextureRegions
* and puts to {@link #textureRegions} HashMap
*/
- private static void loadJSON() {
- JsonValue json = jsonReader.parse(Gdx.files.internal("json/texture_regions.json"));
+ private static void loadJSON(AssetLoader assetLoader) {
+ JsonValue json = jsonReader.parse(assetLoader.getAssetHandle("json/texture_regions.json"));
for (JsonValue file = json.child(); file != null; file = file.next()) {
for (JsonValue file = json.child(); file != null; file = file.next()) {
- Texture texture = new Texture(Gdx.files.internal(file.name() + ".png"));
+ Texture texture = new Texture(assetLoader.getAssetHandle(file.name() + ".png"));
if (file.size == 0) {
textureRegions.put(file.name(),
flippedRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()));
if (file.size == 0) {
textureRegions.put(file.name(),
flippedRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()));
}
}
}
}
- public static void load() {
- loadMob(playerSprite, "char");
- loadMob(pigSprite, "pig");
- loadJSON();
+ public static void load(final AssetLoader assetLoader) {
+ loadMob(assetLoader, playerSprite, "char");
+ loadMob(assetLoader, pigSprite, "pig");
+ loadJSON(assetLoader);
setPlayerHeadOrigin();
setPlayerHeadOrigin();
- minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
+ minecraftFont = new BitmapFont(assetLoader.getAssetHandle("font.fnt"), true);
minecraftFont.getData().setScale(.375f);
}
minecraftFont.getData().setScale(.375f);
}
diff --git a/core/src/ru/deadsoftware/cavedroid/misc/utils/AssetLoader.kt b/core/src/ru/deadsoftware/cavedroid/misc/utils/AssetLoader.kt
--- /dev/null
@@ -0,0 +1,24 @@
+package ru.deadsoftware.cavedroid.misc.utils
+
+import com.badlogic.gdx.Gdx
+import com.badlogic.gdx.files.FileHandle
+import ru.deadsoftware.cavedroid.MainConfig
+import java.io.File
+import javax.inject.Inject
+
+class AssetLoader @Inject constructor(
+ private val mainConfig: MainConfig,
+) {
+
+ fun getAssetHandle(path: String): FileHandle {
+ val texturePackPath =
+ mainConfig.assetsPackPath?.let { if (!it.endsWith(File.separator)) "$it${File.separator}" else it }
+
+ return if (texturePackPath == null) {
+ Gdx.files.internal(path)
+ } else {
+ Gdx.files.absolute("$texturePackPath$path")
+ }
+ }
+
+}
diff --git a/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java b/desktop/src/ru/deadsoftware/cavedroid/desktop/DesktopLauncher.java
index c30a617f94a6ca016e5029cccb2279d85837657e..025beb484ed0e573abf795d267d3705feac6ee7b 100644 (file)
config.useVsync(true);
boolean touch = false;
config.useVsync(true);
boolean touch = false;
+ String assetsPath = null;
+
for (String anArg : arg) {
if (anArg.equals("--touch")) {
touch = true;
for (String anArg : arg) {
if (anArg.equals("--touch")) {
touch = true;
- break;
}
}
+
+ if (anArg.startsWith("--assets")) {
+ String[] splitArg = anArg.split("=");
+ if (splitArg.length >= 2) {
+ assetsPath = splitArg[1];
+ }
+ }
}
}
- new Lwjgl3Application(new CaveGame(System.getProperty("user.home") + "/.cavedroid", touch), config);
+
+ new Lwjgl3Application(
+ new CaveGame(
+ System.getProperty("user.home") + "/.cavedroid",
+ touch,
+ assetsPath),
+ config
+ );
}
}
}
}