diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2024-10-01 23:55:55 -0400 | 
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2024-10-01 23:55:55 -0400 | 
| commit | f48b8c837db34878b1ce500dc1f3dd0cf162a97c (patch) | |
| tree | 078b072b98ba9396ee68ff3e093914d00e63a985 /src/main/java/net/sowgro/npehero/levelapi | |
| parent | df63dff96de7b53fcbb7e766096dc97f22a8a798 (diff) | |
| download | NPEhero-f48b8c837db34878b1ce500dc1f3dd0cf162a97c.tar.gz NPEhero-f48b8c837db34878b1ce500dc1f3dd0cf162a97c.tar.bz2 NPEhero-f48b8c837db34878b1ce500dc1f3dd0cf162a97c.zip  | |
Improve Splash screen
Diffstat (limited to '')
| -rwxr-xr-x | src/main/java/net/sowgro/npehero/levelapi/Levels.java | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/net/sowgro/npehero/levelapi/Levels.java b/src/main/java/net/sowgro/npehero/levelapi/Levels.java index f4cdc1d..7a89ed1 100755 --- a/src/main/java/net/sowgro/npehero/levelapi/Levels.java +++ b/src/main/java/net/sowgro/npehero/levelapi/Levels.java @@ -18,6 +18,14 @@ import net.sowgro.npehero.Driver;   */  public class Levels { +    public interface MessageUpdaterLambda { +        void updateMessage(String message); +    } + +    public interface ProgressUpdaterLambda { +        void updateProgress(double workDone, double progress); +    } +      public static final ObservableList<Level> list = FXCollections.observableArrayList();      public static final HashMap<String, Exception> problems = new HashMap<>(); @@ -31,18 +39,26 @@ public class Levels {       * @throws IOException If there is a problem reading in the levels.       */      public static void readData() throws IOException { +        readData(_ -> {}, (_, _) -> {}); +    } +    public static void readData(MessageUpdaterLambda mu, ProgressUpdaterLambda pu) throws IOException {          list.clear();          File[] fileList = dir.listFiles();          if (fileList == null) {              throw new FileNotFoundException();          } +        int i = 0; +        int max = fileList.length;          for (File file: fileList) {              try {                  Level level = new Level(file);                  list.add(level); +                i++; +                mu.updateMessage("Loaded " + i + " Levels");              } catch (Exception e) {                  problems.put("Failed to load load level in folder '" + file.getName() + "'", e);              } +            pu.updateProgress(i, max);          }          list.sort(Comparator.naturalOrder());      }  | 
