mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 02:44:50 +00:00
Updated assetmanager to now load assets with an assetloader
This commit is contained in:
@@ -10,14 +10,13 @@ import org.toop.framework.networking.NetworkingClientManager;
|
||||
import org.toop.framework.networking.NetworkingInitializationException;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.NotDirectoryException;
|
||||
|
||||
public class Main {
|
||||
static void main(String[] args) throws IOException, UnsupportedAudioFileException, LineUnavailableException, InterruptedException {
|
||||
|
||||
AssetManager.initializeLoader(new File("app/src/main/resources/assets"));
|
||||
AssetManager.loadAssets(new AssetLoader("app/src/main/resources/assets"));
|
||||
var b = new NetworkingClientManager();
|
||||
var c = new SoundManager();
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ public class AssetLoader {
|
||||
fileSearcher(rootFolder);
|
||||
}
|
||||
|
||||
public AssetLoader(String rootFolder) {
|
||||
this.rootFolder = new File(rootFolder);
|
||||
fileSearcher(this.rootFolder);
|
||||
}
|
||||
|
||||
public File getRootFolder() {
|
||||
return this.rootFolder;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package org.toop.framework.asset;
|
||||
|
||||
import org.toop.framework.asset.resources.*;
|
||||
|
||||
import javax.sound.sampled.LineUnavailableException;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class AssetManager {
|
||||
private static AssetLoader loader = null;
|
||||
private static final AssetManager INSTANCE = new AssetManager();
|
||||
private static final Map<String, Asset<? extends BaseResource>> assets = new HashMap<>();
|
||||
|
||||
@@ -16,9 +18,9 @@ public class AssetManager {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void initializeLoader(File rootFolder) {
|
||||
if (loader == null) {
|
||||
loader = new AssetLoader(rootFolder);
|
||||
public static void loadAssets(AssetLoader loader) {
|
||||
for (var asset : loader.getAssets()) {
|
||||
assets.put(asset.getName(), asset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user