diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 6d01275325..a73db1295d 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -507,6 +507,11 @@ public class NetClient implements ApplicationListener{ } } + /** Resets the world data timeout counter. */ + public void resetTimeout(){ + timeoutTime = 0f; + } + public boolean isConnecting(){ return connecting; } diff --git a/core/src/mindustry/net/Net.java b/core/src/mindustry/net/Net.java index 0dc711ea3d..9081b194f4 100644 --- a/core/src/mindustry/net/Net.java +++ b/core/src/mindustry/net/Net.java @@ -272,6 +272,10 @@ public class Net{ throw new RuntimeException("Received stream chunk without a StreamBegin beforehand!"); } builder.add(c.data); + + ui.loadfrag.setProgress(builder.progress()); + netClient.resetTimeout(); + if(builder.isDone()){ streams.remove(builder.id); handleClientReceived(builder.build()); diff --git a/core/src/mindustry/ui/fragments/LoadingFragment.java b/core/src/mindustry/ui/fragments/LoadingFragment.java index a5ab8eeff7..fcd18dfcbe 100644 --- a/core/src/mindustry/ui/fragments/LoadingFragment.java +++ b/core/src/mindustry/ui/fragments/LoadingFragment.java @@ -17,6 +17,7 @@ public class LoadingFragment extends Fragment{ private TextButton button; private Bar bar; private Label nameLabel; + private float progValue; @Override public void build(Group parent){ @@ -55,6 +56,13 @@ public class LoadingFragment extends Fragment{ bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent); } + public void setProgress(float progress){ + progValue = progress; + if(!bar.visible){ + setProgress(() -> progValue); + } + } + public void setButton(Runnable listener){ button.visible = true; button.getListeners().remove(button.getListeners().size - 1);