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