loading screen

This commit is contained in:
Sen 2025-03-16 23:14:24 +01:00
parent 987ed4059e
commit d4f6d3e4f9
6 changed files with 139 additions and 95 deletions

View file

@ -18,14 +18,27 @@ public class GuiLoading extends Gui {
private Bar progressBar1;
private Bar progressBar2;
public static GuiLoading makeLoadTask(final Server server) {
public static GuiLoading makeLoadTask(final Server server, final String user) {
return new GuiLoading("Lade Welt ...", new Callback() {
boolean started = false;
public void poll(Game gm, GuiLoading gui) {
if(server.isStarted()) {
gm.displayGuiScreen(null);
return;
if(!this.started && server.isStarted()) {
this.started = true;
// gm.displayGuiScreen(null);
server.setVar("viewDistance", "" + gm.renderDistance);
gm.connectToIntegrated(server, user);
// return;
}
int progress = server.getProgress();
if(progress < 0) {
gui.resetBar();
}
else {
gui.setBar(null, "Chunks", Math.max(1, server.getTotal()));
gui.setProgress(progress);
}
gui.setTask(server.getMessage());
}
});
}
@ -37,7 +50,15 @@ public class GuiLoading extends Gui {
gm.displayGuiScreen(GuiMenu.INSTANCE);
return;
}
int progress = server.getProgress();
if(progress < 0) {
gui.resetBar();
}
else {
gui.setBar(null, "Dimensionen", Math.max(1, server.getTotal()));
gui.setProgress(progress);
}
gui.setTask(server.getMessage());
}
});
}
@ -62,7 +83,7 @@ public class GuiLoading extends Gui {
}
public void setTask(String task) {
this.taskLabel.setText(task);
this.taskLabel.setText(task == null ? "" : task);
}
public void setBar(String desc) {

View file

@ -91,8 +91,8 @@ public class GuiMenu extends Gui {
}
this.add(new ActButton(0, 102, 400, 24, new ActButton.Callback() {
public void use(ActButton elem, ActButton.Mode action) {
GuiMenu.this.gm.unload();
GuiMenu.this.gm.displayGuiScreen(INSTANCE);
GuiMenu.this.gm.unload(true);
// GuiMenu.this.gm.displayGuiScreen(INSTANCE);
}
}, this.gm.isRemote() ? "Verbindung trennen" : "Welt schließen"));
this.shift();