mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Added ability to track loading amount through event.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.toop;
|
||||
import org.toop.app.gui.LocalServerSelector;
|
||||
import org.toop.framework.asset.AssetLoader;
|
||||
import org.toop.framework.asset.AssetManager;
|
||||
import org.toop.framework.asset.events.AssetEvents;
|
||||
import org.toop.framework.asset.resources.TextAsset;
|
||||
import org.toop.framework.audio.SoundManager;
|
||||
import org.toop.framework.audio.events.AudioEvents;
|
||||
@@ -10,22 +11,27 @@ import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.networking.NetworkingClientManager;
|
||||
import org.toop.framework.networking.NetworkingInitializationException;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.NotDirectoryException;
|
||||
|
||||
public class Main {
|
||||
static void main(String[] args) {
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(LocalServerSelector::new);
|
||||
|
||||
new EventFlow().listen(Main::loadingHandler);
|
||||
|
||||
AssetManager.loadAssets(new AssetLoader("app/src/main/resources/assets"));
|
||||
var text = AssetManager.getAllOfType(TextAsset.class).getFirst().getResource();
|
||||
var jpg = AssetManager.getByName("background.jpg");
|
||||
|
||||
System.out.println(jpg.getResource().getFile());
|
||||
|
||||
text.load();
|
||||
|
||||
IO.println(text.getContent());
|
||||
|
||||
var b = new NetworkingClientManager();
|
||||
var c = new SoundManager();
|
||||
new Thread(NetworkingClientManager::new).start();
|
||||
new Thread(SoundManager::new).start();
|
||||
|
||||
new EventFlow().addPostEvent(new AudioEvents.PlayAudio("mainmenu.wav", true)).asyncPostEvent();
|
||||
// new EventFlow().addPostEvent(new AudioEvents.PlayAudio("sadtrombone.wav", false)).asyncPostEvent();
|
||||
@@ -35,8 +41,12 @@ public class Main {
|
||||
// Thread.sleep(200);
|
||||
// new EventFlow().addPostEvent(new AudioEvents.PlayAudio("mainmenu.wav", false)).asyncPostEvent();
|
||||
// new EventFlow().addPostEvent(new AudioEvents.PlayAudio("sadtrombone.wav", false)).asyncPostEvent();
|
||||
}
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(LocalServerSelector::new);
|
||||
private static void loadingHandler(AssetEvents.LoadingProgressUpdate update) {
|
||||
int loaded = update.hasLoadedAmount();
|
||||
int total = update.isLoadingAmount();
|
||||
double percent = (total == 0) ? 100.0 : (loaded * 100.0 / total);
|
||||
}
|
||||
|
||||
private static void initSystems() throws NetworkingInitializationException, NotDirectoryException {
|
||||
|
||||
Reference in New Issue
Block a user