delete world progress, pointer lock fixes
This commit is contained in:
parent
da198ea1c3
commit
7a3989e88e
17855
javascript/classes.js
17855
javascript/classes.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -99,8 +99,8 @@ public class EaglercraftSaveManager implements ISaveFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteWorldByDirectory(String s) {
|
public void deleteWorldByDirectory(String s, IProgressUpdate progress) {
|
||||||
FilesystemUtils.recursiveDeleteDirectory(directory + "/" + s);
|
FilesystemUtils.recursiveDeleteDirectoryWithProgress(directory + "/" + s, "Deleting World", "%i chunks", progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,27 +5,45 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
||||||
|
import net.minecraft.src.IProgressUpdate;
|
||||||
|
|
||||||
public class FilesystemUtils {
|
public class FilesystemUtils {
|
||||||
|
|
||||||
public static void recursiveDeleteDirectory(String dir) {
|
public static void recursiveDeleteDirectory(String dir) {
|
||||||
Collection<FileEntry> lst = EaglerAdapter.listFiles(dir, true, true);
|
Collection<FileEntry> lst = EaglerAdapter.listFiles(dir, true, true);
|
||||||
lst.forEach(new Consumer<FileEntry>() {
|
for(FileEntry t : lst) {
|
||||||
@Override
|
|
||||||
public void accept(FileEntry t) {
|
|
||||||
if(!t.isDirectory) {
|
if(!t.isDirectory) {
|
||||||
EaglerAdapter.deleteFile(t.path);
|
EaglerAdapter.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
for(FileEntry t : lst) {
|
||||||
lst.forEach(new Consumer<FileEntry>() {
|
if(t.isDirectory) {
|
||||||
@Override
|
EaglerAdapter.deleteFile(t.path);
|
||||||
public void accept(FileEntry t) {
|
}
|
||||||
|
}
|
||||||
|
EaglerAdapter.deleteFile(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void recursiveDeleteDirectoryWithProgress(String dir, String title, String subText, IProgressUpdate progress) {
|
||||||
|
progress.displayLoadingString(title, "(please wait)");
|
||||||
|
Collection<FileEntry> lst = EaglerAdapter.listFiles(dir, true, true);
|
||||||
|
int totalDeleted = 0;
|
||||||
|
int lastTotalDeleted = 0;
|
||||||
|
for(FileEntry t : lst) {
|
||||||
|
if(!t.isDirectory) {
|
||||||
|
EaglerAdapter.deleteFile(t.path);
|
||||||
|
++totalDeleted;
|
||||||
|
if(totalDeleted - lastTotalDeleted >= 10) {
|
||||||
|
lastTotalDeleted = totalDeleted;
|
||||||
|
progress.displayLoadingString(title, subText.replace("%i", "" + totalDeleted));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(FileEntry t : lst) {
|
||||||
if(t.isDirectory) {
|
if(t.isDirectory) {
|
||||||
EaglerAdapter.deleteFile(t.path);
|
EaglerAdapter.deleteFile(t.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
EaglerAdapter.deleteFile(dir);
|
EaglerAdapter.deleteFile(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -889,7 +889,10 @@ public abstract class Minecraft implements Runnable {
|
||||||
world.func_651_a(loadingScreen);
|
world.func_651_a(loadingScreen);
|
||||||
}
|
}
|
||||||
field_22009_h = thePlayer;
|
field_22009_h = thePlayer;
|
||||||
|
field_6289_L = true;
|
||||||
|
mouseHelper.func_774_a();
|
||||||
} else {
|
} else {
|
||||||
|
ungrabMouseCursor();
|
||||||
thePlayer = null;
|
thePlayer = null;
|
||||||
}
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class GuiSelectWorld extends GuiScreen {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
ISaveFormat isaveformat = mc.func_22004_c();
|
ISaveFormat isaveformat = mc.func_22004_c();
|
||||||
isaveformat.flushCache();
|
isaveformat.flushCache();
|
||||||
isaveformat.deleteWorldByDirectory(func_22091_c(i));
|
isaveformat.deleteWorldByDirectory(func_22091_c(i), mc.loadingScreen);
|
||||||
func_22084_k();
|
func_22084_k();
|
||||||
}
|
}
|
||||||
mc.displayGuiScreen(this);
|
mc.displayGuiScreen(this);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public interface ISaveFormat {
|
||||||
|
|
||||||
public abstract WorldInfo getWorldInfoForWorld(String s);
|
public abstract WorldInfo getWorldInfoForWorld(String s);
|
||||||
|
|
||||||
public abstract void deleteWorldByDirectory(String s);
|
public abstract void deleteWorldByDirectory(String s, IProgressUpdate progress);
|
||||||
|
|
||||||
public abstract void renameWorldData(String s, String s1);
|
public abstract void renameWorldData(String s, String s1);
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,7 @@ public class EaglerAdapterImpl2 {
|
||||||
mouseEvents.add(evt);
|
mouseEvents.add(evt);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
forceMouseGrabbed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
canvas.addEventListener("mouseup", mouseup = new EventListener<MouseEvent>() {
|
canvas.addEventListener("mouseup", mouseup = new EventListener<MouseEvent>() {
|
||||||
|
@ -266,6 +267,7 @@ public class EaglerAdapterImpl2 {
|
||||||
keyEvents.add(evt);
|
keyEvents.add(evt);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
forceMouseGrabbed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
win.addEventListener("keyup", keyup = new EventListener<KeyboardEvent>() {
|
win.addEventListener("keyup", keyup = new EventListener<KeyboardEvent>() {
|
||||||
|
@ -304,6 +306,7 @@ public class EaglerAdapterImpl2 {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(WheelEvent evt) {
|
public void handleEvent(WheelEvent evt) {
|
||||||
isWindowFocused = true;
|
isWindowFocused = true;
|
||||||
|
forceMouseGrabbed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
onBeforeCloseRegister();
|
onBeforeCloseRegister();
|
||||||
|
@ -916,7 +919,9 @@ public class EaglerAdapterImpl2 {
|
||||||
}
|
}
|
||||||
private static long mouseUngrabTimer = 0l;
|
private static long mouseUngrabTimer = 0l;
|
||||||
private static int mouseUngrabTimeout = 0;
|
private static int mouseUngrabTimeout = 0;
|
||||||
|
private static boolean needsPointerLock = false;
|
||||||
public static final void mouseSetGrabbed(boolean grabbed) {
|
public static final void mouseSetGrabbed(boolean grabbed) {
|
||||||
|
needsPointerLock = grabbed;
|
||||||
if(grabbed) {
|
if(grabbed) {
|
||||||
canvas.requestPointerLock();
|
canvas.requestPointerLock();
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
|
@ -935,6 +940,17 @@ public class EaglerAdapterImpl2 {
|
||||||
doc.exitPointerLock();
|
doc.exitPointerLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void forceMouseGrabbed() {
|
||||||
|
long t = System.currentTimeMillis();
|
||||||
|
if(t - mouseUngrabTimer > 3000l) {
|
||||||
|
if(needsPointerLock && !isPointerLocked()) {
|
||||||
|
canvas.requestPointerLock();
|
||||||
|
if(isPointerLocked()) {
|
||||||
|
needsPointerLock = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public static final int mouseGetDX() {
|
public static final int mouseGetDX() {
|
||||||
double dx = mouseDX;
|
double dx = mouseDX;
|
||||||
mouseDX = 0.0D;
|
mouseDX = 0.0D;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user