char origins

This commit is contained in:
Sen 2025-03-28 14:30:37 +01:00
parent 3316c42ed8
commit e9ede99d84
14 changed files with 516 additions and 373 deletions

View file

@ -427,6 +427,7 @@ public class Game implements IThreadListener {
private String buffer = "";
private boolean crashed;
private boolean waitingForFile;
private boolean refreshing;
private final int[] tickTimes = new int[240];
private final long[] frames = new long[240];
@ -1152,7 +1153,8 @@ public class Game implements IThreadListener {
public void displayGuiScreen(Gui gui)
{
this.waitingForFile = false;
if(!this.refreshing)
this.waitingForFile = false;
if(this.thePlayer != null)
this.thePlayer.setScreenClosed();
if (this.open != null)
@ -1870,9 +1872,9 @@ public class Game implements IThreadListener {
fb_x = x;
fb_y = y;
if(this.open != null) {
boolean flag = this.waitingForFile;
this.refreshing = true;
this.displayGuiScreen(this.open);
this.waitingForFile = flag;
this.refreshing = false;
}
if(!fullscreen) {
xsize = x;
@ -1976,9 +1978,9 @@ public class Game implements IThreadListener {
private void redraw() {
if(this.open != null) {
boolean flag = this.waitingForFile;
this.refreshing = true;
this.displayGuiScreen(this.open);
this.waitingForFile = flag;
this.refreshing = false;
}
}
@ -2410,6 +2412,11 @@ public class Game implements IThreadListener {
// if(server != null) {
// }
}
public void waitForServer() {
if(this.server != null)
this.displayGuiScreen(GuiLoading.makeIntermittentTask(this.server));
}
private void startSound(boolean load) {
if(load)
@ -3331,7 +3338,7 @@ public class Game implements IThreadListener {
FILE_SAVE;
}
public void showDirDialog(final FileMode mode, final String title, final File def, final FileCallback callback) {
public void showFileDialog(final FileMode mode, final String title, final File def, final FileCallback callback) {
if(this.waitingForFile)
return;
this.waitingForFile = true;
@ -3372,57 +3379,72 @@ public class Game implements IThreadListener {
}
}
catch(Throwable e) {
Log.SYSTEM.error(e, "Konnte Zenity nicht starten");
Game.this.logFeed(TextColor.RED + "Konnte Dateibrowser nicht öffnen");
Game.this.waitingForFile = false;
return;
}
if(output != null) {
if(mode == FileMode.FILE_LOAD_MULTI) {
final List<File> files = Lists.newArrayList();
for(String out : output.split(":")) {
File file = new File(out);
if(file.isFile())
files.add(file);
}
if(files.isEmpty())
return;
Game.this.schedule(new Runnable() {
public void run() {
if(Game.this.waitingForFile) {
for(File file : files) {
callback.selected(file);
}
}
Game.this.waitingForFile = false;
}
});
if(output == null) {
Game.this.waitingForFile = false;
return;
}
if(mode == FileMode.FILE_LOAD_MULTI) {
final List<File> files = Lists.newArrayList();
for(String out : output.split(":")) {
File file = new File(out);
if(file.isFile())
files.add(file);
}
else {
File file = new File(output);
switch(mode) {
case DIRECTORY_LOAD:
if(!file.isDirectory())
return;
break;
case DIRECTORY_SAVE:
if(file.exists() && !file.isDirectory())
return;
break;
case FILE_LOAD:
if(!file.isFile())
return;
break;
case FILE_SAVE:
if(file.exists() && !file.isFile())
return;
break;
}
Game.this.schedule(new Runnable() {
public void run() {
if(Game.this.waitingForFile)
if(files.isEmpty()) {
Game.this.waitingForFile = false;
return;
}
Game.this.schedule(new Runnable() {
public void run() {
if(Game.this.waitingForFile) {
for(File file : files) {
callback.selected(file);
Game.this.waitingForFile = false;
}
}
});
Game.this.waitingForFile = false;
}
});
}
else {
File file = new File(output);
switch(mode) {
case DIRECTORY_LOAD:
if(!file.isDirectory()) {
Game.this.waitingForFile = false;
return;
}
break;
case DIRECTORY_SAVE:
if(file.exists() && !file.isDirectory()) {
Game.this.waitingForFile = false;
return;
}
break;
case FILE_LOAD:
if(!file.isFile()) {
Game.this.waitingForFile = false;
return;
}
break;
case FILE_SAVE:
if(file.exists() && !file.isFile()) {
Game.this.waitingForFile = false;
return;
}
break;
}
Game.this.schedule(new Runnable() {
public void run() {
if(Game.this.waitingForFile)
callback.selected(file);
Game.this.waitingForFile = false;
}
});
}
}
}, "Zenity listener").start();