Load saves in parallel
This commit is contained in:
@@ -17,6 +17,7 @@ import mindustry.type.*;
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -47,11 +48,24 @@ public class Saves{
|
||||
public void load(){
|
||||
saves.clear();
|
||||
|
||||
//read saves in parallel
|
||||
Seq<Future<SaveSlot>> futures = new Seq<>();
|
||||
|
||||
for(Fi file : saveDirectory.list()){
|
||||
if(!file.name().contains("backup") && SaveIO.isSaveValid(file)){
|
||||
SaveSlot slot = new SaveSlot(file);
|
||||
saves.add(slot);
|
||||
slot.meta = SaveIO.getMeta(file);
|
||||
futures.add(mainExecutor.submit(() -> {
|
||||
SaveSlot slot = new SaveSlot(file);
|
||||
slot.meta = SaveIO.getMeta(file);
|
||||
return slot;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
for(var future : futures){
|
||||
try{
|
||||
saves.add(future.get());
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -772,8 +772,10 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public void panCamera(Vec2 position){
|
||||
panning = true;
|
||||
camera.position.set(position);
|
||||
if(!locked()){
|
||||
panning = true;
|
||||
camera.position.set(position);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateMovement(Unit unit){
|
||||
|
||||
@@ -1484,7 +1484,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
/** Forces the camera to a position and enables panning on desktop. */
|
||||
public void panCamera(Vec2 position){
|
||||
camera.position.set(position);
|
||||
if(!locked()){
|
||||
camera.position.set(position);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean selectedBlock(){
|
||||
|
||||
@@ -224,13 +224,13 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
server.content.background(Tex.whitePane).setColor(Pal.gray);
|
||||
|
||||
server.content.label(() -> Core.bundle.get("server.refreshing") + Strings.animated(Time.time, 4, 11, ".")).padBottom(4);
|
||||
server.content.label(() -> Core.bundle.get("server.refreshing") + Strings.animated(Time.time, 4, 11, ".")).grow().center().labelAlign(Align.center).padBottom(4);
|
||||
|
||||
net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
|
||||
server.content.clear();
|
||||
|
||||
server.content.background(Tex.whitePane).setColor(Pal.gray);
|
||||
server.content.add("@host.invalid");
|
||||
server.content.add("@host.invalid").grow().center().labelAlign(Align.center);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user