summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/kz/ilotterytea/maxon/assets/AssetUtils.java69
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/SplashScreen.java6
-rw-r--r--core/src/kz/ilotterytea/maxon/utils/AssetLoading.java73
3 files changed, 72 insertions, 76 deletions
diff --git a/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java b/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java
new file mode 100644
index 0000000..ae3598e
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java
@@ -0,0 +1,69 @@
+package kz.ilotterytea.maxon.assets;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.assets.AssetManager;
+import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
+import com.badlogic.gdx.audio.Music;
+import com.badlogic.gdx.files.FileHandle;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import com.badlogic.gdx.scenes.scene2d.ui.Skin;
+import kz.ilotterytea.maxon.assets.loaders.Text;
+import kz.ilotterytea.maxon.assets.loaders.TextLoader;
+import net.mgsx.gltf.loaders.glb.GLBAssetLoader;
+import net.mgsx.gltf.scene3d.scene.SceneAsset;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class AssetUtils {
+ public static void setup(AssetManager assetManager) {
+ assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
+ assetManager.setLoader(Text.class, new TextLoader(new InternalFileHandleResolver()));
+ }
+
+ public static void queue(AssetManager assetManager) {
+ FileHandle assetsFile = Gdx.files.internal("assets.txt");
+ String contents = assetsFile.readString();
+ List<String> filePaths = contents.lines().collect(Collectors.toList());
+
+ for (String filePath : filePaths) {
+ System.out.println(filePath);
+ String[] splitFilePath = filePath.split("/");
+ String[] splitFileName = splitFilePath[splitFilePath.length - 1].split("\\.");
+ String extension = splitFileName[splitFileName.length - 1];
+
+ Class<?> type = null;
+
+ switch (extension) {
+ case "png":
+ type = Texture.class;
+ break;
+ case "atlas":
+ type = TextureAtlas.class;
+ break;
+ case "skin":
+ type = Skin.class;
+ break;
+ case "json":
+ case "txt":
+ type = Text.class;
+ break;
+ case "glb":
+ type = SceneAsset.class;
+ break;
+ case "ogg":
+ type = Music.class;
+ break;
+ default:
+ break;
+ }
+
+ if (type == null) {
+ continue;
+ }
+
+ assetManager.load(filePath, type);
+ }
+ }
+} \ No newline at end of file
diff --git a/core/src/kz/ilotterytea/maxon/screens/SplashScreen.java b/core/src/kz/ilotterytea/maxon/screens/SplashScreen.java
index 9a1cc85..bbb9db9 100644
--- a/core/src/kz/ilotterytea/maxon/screens/SplashScreen.java
+++ b/core/src/kz/ilotterytea/maxon/screens/SplashScreen.java
@@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
-import kz.ilotterytea.maxon.utils.AssetLoading;
+import kz.ilotterytea.maxon.assets.AssetUtils;
import kz.ilotterytea.maxon.MaxonGame;
public class SplashScreen implements Screen {
@@ -48,8 +48,8 @@ public class SplashScreen implements Screen {
stage.addActor(logoTable);
- AssetLoading.setup(game.assetManager);
- AssetLoading.queue(game.assetManager);
+ AssetUtils.setup(game.assetManager);
+ AssetUtils.queue(game.assetManager);
}
@Override public void show() {
diff --git a/core/src/kz/ilotterytea/maxon/utils/AssetLoading.java b/core/src/kz/ilotterytea/maxon/utils/AssetLoading.java
deleted file mode 100644
index 885f032..0000000
--- a/core/src/kz/ilotterytea/maxon/utils/AssetLoading.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package kz.ilotterytea.maxon.utils;
-
-import com.badlogic.gdx.assets.AssetManager;
-import com.badlogic.gdx.assets.loaders.SkinLoader;
-import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
-import com.badlogic.gdx.audio.Music;
-import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g2d.TextureAtlas;
-import com.badlogic.gdx.scenes.scene2d.ui.Skin;
-import kz.ilotterytea.maxon.assets.loaders.Text;
-import kz.ilotterytea.maxon.assets.loaders.TextLoader;
-import net.mgsx.gltf.loaders.glb.GLBAssetLoader;
-import net.mgsx.gltf.scene3d.scene.SceneAsset;
-
-public class AssetLoading {
- public static void setup(AssetManager am) {
- am.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
- am.setLoader(Text.class, new TextLoader(new InternalFileHandleResolver()));
- }
-
- public static void queue(AssetManager am) {
- // Texture atlases:
- am.load("sprites/env/environment.atlas", TextureAtlas.class);
- am.load("sprites/gui/brand.atlas", TextureAtlas.class);
- am.load("sprites/gui/icons.atlas", TextureAtlas.class);
- am.load("sprites/gui/ilotterytea.atlas", TextureAtlas.class);
- am.load("sprites/gui/widgets.atlas", TextureAtlas.class);
- am.load("sprites/gui/widgets.skin", Skin.class, new SkinLoader.SkinParameter("sprites/gui/widgets.atlas"));
-
- am.load("sprites/gui/widgeticons.atlas", TextureAtlas.class);
- am.load("sprites/gui/friends.atlas", TextureAtlas.class);
- am.load("sprites/gui/friends.skin", Skin.class, new SkinLoader.SkinParameter("sprites/gui/friends.atlas"));
-
- am.load("MainSpritesheet.atlas", TextureAtlas.class);
- am.load("MainSpritesheet.skin", Skin.class, new SkinLoader.SkinParameter("MainSpritesheet.atlas"));
-
- am.load("sprites/gui/ui.atlas", TextureAtlas.class);
- am.load("sprites/gui/ui.skin", Skin.class, new SkinLoader.SkinParameter("sprites/gui/ui.atlas"));
-
- am.load("sprites/gui/player_icons.atlas", TextureAtlas.class);
-
- // Models:
- am.load("models/scenes/living_room.glb", SceneAsset.class);
- am.load("models/props/box.glb", SceneAsset.class);
-
- // Cat item textures:
- am.load("sprites/sheet/loadingCircle.png", Texture.class);
- am.load("sprites/sheet/bror.png", Texture.class);
- am.load("sprites/sheet/manlooshka.png", Texture.class);
- am.load("sprites/sheet/furios_cat.png", Texture.class);
- am.load("sprites/sheet/sandwich_cat.png", Texture.class);
- am.load("sprites/sheet/thirsty_cat.png", Texture.class);
- am.load("sprites/sheet/tvcat.png", Texture.class);
- am.load("sprites/sheet/progcat.png", Texture.class);
- am.load("sprites/sheet/screamcat.png", Texture.class);
- am.load("sprites/sheet/hellcat.png", Texture.class);
- am.load("sprites/sheet/lurker.png", Texture.class);
- am.load("sprites/sheet/piano_cat.png", Texture.class);
- am.load("sprites/sheet/bee_cat.png", Texture.class);
- am.load("sprites/sheet/busy.png", Texture.class);
- am.load("sprites/sheet/aeae.png", Texture.class);
- am.load("sprites/sheet/succat.png", Texture.class);
-
- // Music:
- am.load("mus/menu/mus_menu_intro.ogg", Music.class);
- am.load("mus/menu/mus_menu_loop.ogg", Music.class);
- am.load("mus/game/onwards.wav", Music.class);
- am.load("mus/game/paris.wav", Music.class);
- am.load("mus/game/adieu.wav", Music.class);
- am.load("mus/game/shopping_spree.wav", Music.class);
- // Sounds:
- }
-} \ No newline at end of file