diff --git a/.gitignore b/.gitignore index 737b5c9..e8c5d69 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ build /data /backup /output -*.zip \ No newline at end of file +*.zip + +.idea diff --git a/build.gradle b/build.gradle index bdff74b..69db43f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,8 @@ plugins { archivesBaseName = "Mario Kart World Tracker" version = '1.0.1' +var mainClassName = 'speiger.src.ui.MapPanel' + repositories { mavenCentral() } @@ -13,7 +15,7 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co jar { manifest { - attributes "Main-Class": 'speiger.src.ui.MapPanel' + attributes "Main-Class": mainClassName } from { duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -27,7 +29,7 @@ task baseJar(type: Jar) { exclude('assets/images/images.zip') duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { - attributes "Main-Class": 'speiger.src.ui.MapPanel' + attributes "Main-Class": mainClassName } from { duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -35,6 +37,11 @@ task baseJar(type: Jar) { } } +task run(type: JavaExec) { + classpath = sourceSets.main.runtimeClasspath + mainClass.set(mainClassName) +} + dependencies { implementation 'com.google.code.gson:gson:2.8.6' diff --git a/src/main/java/speiger/src/data/Registry.java b/src/main/java/speiger/src/data/Registry.java index a81fa11..3021e6d 100644 --- a/src/main/java/speiger/src/data/Registry.java +++ b/src/main/java/speiger/src/data/Registry.java @@ -52,6 +52,7 @@ public class Registry { Map collectables = new LinkedHashMap<>(); Set completed = new HashSet<>(); Object syncObj = new Object(); + boolean bulkOperationActive = false; public void load() { parseRegistry("/assets/data/medals.json", CollectableType.MEDAL); @@ -202,14 +203,22 @@ public class Registry { public void markComplete(UUID id) { completed.add(id); - save(); + if (bulkOperationActive) save(); } public void unmarkComplete(UUID id) { completed.remove(id); - save(); + if (bulkOperationActive) save(); } + public void setBulkOperation(boolean bulk) { + bulkOperationActive = bulk; + + if (!bulk) { + save(); + } + } + public boolean isCompleted(UUID id) { return completed.contains(id); } diff --git a/src/main/java/speiger/src/ui/MapPanel.java b/src/main/java/speiger/src/ui/MapPanel.java index 5d2042e..069ebfc 100644 --- a/src/main/java/speiger/src/ui/MapPanel.java +++ b/src/main/java/speiger/src/ui/MapPanel.java @@ -157,7 +157,7 @@ public class MapPanel extends JPanel { panel.setCompletionState(true); }, null)); bulk.add(item("Uncomplete Visible", T -> { - panel.setCompletionState(false); + panel.setCompletionState(false); }, null)); bar.add(bulk); JMenu fuckups = new JMenu("I Fucked up"); @@ -345,7 +345,11 @@ public class MapPanel extends JPanel { } public void setCompletionState(boolean value) { + Registry.INSTANCE.setBulkOperation(true); visibleMarkers.forEach(T -> T.setCompletion(value)); + Registry.INSTANCE.setBulkOperation(false); + EventQueue.invokeLater(this::repaint); + if(progressUpdate != null) progressUpdate.run(); } @Override