Added a WatchService to watch the beatmap directory tree for changes.
Any CREATE and DELETE that occur in the song menu state will now show a notification and modify the behavior of the 'F5' key. Changes that occur in other states will force a reload upon entering the song menu. This is part of osu!, but as it's not incredibly helpful, I've left it disabled by default. It can be enabled in the options menu. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package itdelatrisu.opsu.beatmap;
|
||||
|
||||
import itdelatrisu.opsu.ErrorHandler;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.db.BeatmapDB;
|
||||
import itdelatrisu.opsu.io.MD5InputStreamWrapper;
|
||||
@@ -83,6 +84,10 @@ public class BeatmapParser {
|
||||
// create a new BeatmapSetList
|
||||
BeatmapSetList.create();
|
||||
|
||||
// create a new watch service
|
||||
if (Options.isWatchServiceEnabled())
|
||||
BeatmapWatchService.create();
|
||||
|
||||
// parse all directories
|
||||
parseDirectories(root.listFiles());
|
||||
}
|
||||
@@ -110,6 +115,9 @@ public class BeatmapParser {
|
||||
List<Beatmap> cachedBeatmaps = new LinkedList<Beatmap>(); // loaded from database
|
||||
List<Beatmap> parsedBeatmaps = new LinkedList<Beatmap>(); // loaded from parser
|
||||
|
||||
// watch service
|
||||
BeatmapWatchService ws = (Options.isWatchServiceEnabled()) ? BeatmapWatchService.get() : null;
|
||||
|
||||
// parse directories
|
||||
BeatmapSetNode lastNode = null;
|
||||
for (File dir : dirs) {
|
||||
@@ -162,6 +170,8 @@ public class BeatmapParser {
|
||||
if (!beatmaps.isEmpty()) {
|
||||
beatmaps.trimToSize();
|
||||
allBeatmaps.add(beatmaps);
|
||||
if (ws != null)
|
||||
ws.registerAll(dir.toPath());
|
||||
}
|
||||
|
||||
// stop parsing files (interrupted)
|
||||
|
||||
Reference in New Issue
Block a user