Menü Buttons angepasst, Screenshot Funktion optimiert
This commit is contained in:
@@ -1477,6 +1477,7 @@ public class EditorApp extends Application {
|
||||
saveItem.setAccelerator(javafx.scene.input.KeyCombination.keyCombination("Ctrl+S"));
|
||||
saveItem.setOnAction(e -> { input.saveRequested = true; setStatus("Speichern…"); });
|
||||
MenuItem screenshotItem = new MenuItem("Screenshot");
|
||||
screenshotItem.setAccelerator(javafx.scene.input.KeyCombination.keyCombination("Ctrl+F12"));
|
||||
screenshotItem.setOnAction(e -> takeEditorScreenshot());
|
||||
MenuItem settingsItem = new MenuItem("Einstellungen…");
|
||||
settingsItem.setOnAction(e -> openSettings());
|
||||
@@ -6442,6 +6443,7 @@ public class EditorApp extends Application {
|
||||
}
|
||||
|
||||
private void takeEditorScreenshot() {
|
||||
playScreenshotClick();
|
||||
WritableImage image = primaryStage.getScene().snapshot(null);
|
||||
String timestamp = java.time.LocalDateTime.now()
|
||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"));
|
||||
@@ -6456,6 +6458,34 @@ public class EditorApp extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
private void playScreenshotClick() {
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
int sr = 44100;
|
||||
int frames = (int) (sr * 0.08);
|
||||
byte[] buf = new byte[frames * 2];
|
||||
java.util.Random rng = new java.util.Random();
|
||||
for (int i = 0; i < frames; i++) {
|
||||
double env = Math.exp(-i / (sr * 0.012));
|
||||
double s = (rng.nextGaussian() * 0.55 + Math.sin(2 * Math.PI * 3200.0 * i / sr) * 0.45) * env * 0.85;
|
||||
short val = (short) Math.max(-32767, Math.min(32767, s * 32767));
|
||||
buf[i * 2] = (byte) (val & 0xff);
|
||||
buf[i * 2 + 1] = (byte) ((val >> 8) & 0xff);
|
||||
}
|
||||
javax.sound.sampled.AudioFormat fmt = new javax.sound.sampled.AudioFormat(sr, 16, 1, true, false);
|
||||
javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax.sound.sampled.SourceDataLine.class, fmt);
|
||||
javax.sound.sampled.SourceDataLine line = (javax.sound.sampled.SourceDataLine) javax.sound.sampled.AudioSystem.getLine(info);
|
||||
line.open(fmt);
|
||||
line.start();
|
||||
line.write(buf, 0, buf.length);
|
||||
line.drain();
|
||||
line.close();
|
||||
} catch (Exception ignored) {}
|
||||
}, "screenshot-click");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void handleTextureImport(javafx.stage.Window owner) {
|
||||
FileChooser fc = new FileChooser();
|
||||
fc.setTitle("Texturen importieren (nicht-PNG wird automatisch konvertiert)");
|
||||
|
||||
Reference in New Issue
Block a user