Add settings menus
This commit is contained in:
@@ -16,7 +16,6 @@ public class AcousticHandler {
|
||||
private NanoTimer trackTimer = new NanoTimer();
|
||||
|
||||
private boolean fading = false; // Indicates if a fade is in progress
|
||||
private boolean outFadingFinished = false; // Tracks the completion of the outfade
|
||||
private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
|
||||
private static final float FADE_DURATION = 3.0f; // Duration for outfade
|
||||
private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
|
||||
@@ -173,7 +172,6 @@ private void updateVolumeAndTrack() {
|
||||
fadeTimer.reset();
|
||||
old = playing; // The currently playing track becomes the old track
|
||||
playing = null; // Clear the playing track during the fade process
|
||||
outFadingFinished = false;
|
||||
}
|
||||
|
||||
if (fading) {
|
||||
@@ -185,7 +183,6 @@ private void updateVolumeAndTrack() {
|
||||
old = playing; // Treat the currently infading track as the old track
|
||||
playing = null; // Reset playing to allow switching
|
||||
fadeTimer.reset(); // Restart fade timer for the new track
|
||||
outFadingFinished = false;
|
||||
}
|
||||
} else if (playing != null) {
|
||||
// Update volume for the currently playing track
|
||||
@@ -236,7 +233,6 @@ private void handleFadeProcess() {
|
||||
// Complete outfade
|
||||
old.pause();
|
||||
old = null;
|
||||
outFadingFinished = true;
|
||||
}
|
||||
|
||||
// Handle pause duration before infade
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package pp.mdga.client.dialog;
|
||||
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.texture.Texture;
|
||||
import com.simsilica.lemur.*;
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
|
||||
public class SettingsDialog extends Dialog {
|
||||
private TextField nameInput;
|
||||
|
||||
public SettingsDialog(MdgaApp app, Node node, String path) {
|
||||
super(app, node);
|
||||
|
||||
QuadBackgroundComponent quad1 = new QuadBackgroundComponent(ColorRGBA.Gray);
|
||||
quad1.setMargin(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor());
|
||||
container.setBackground(quad1);
|
||||
|
||||
Texture texture = app.getAssetManager().loadTexture(path);
|
||||
|
||||
QuadBackgroundComponent b = new QuadBackgroundComponent(texture);
|
||||
|
||||
Panel imagePanel = new Panel();
|
||||
imagePanel.setBackground(b);
|
||||
|
||||
container.addChild(imagePanel).setPreferredSize(new Vector3f((texture.getImage().getWidth() / 2) * app.getResolutionFactor(), (texture.getImage().getHeight() / 2) * app.getResolutionFactor(), 0));
|
||||
|
||||
//abstandshalter
|
||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
|
||||
container.setLocalTranslation(
|
||||
app.getCamera().getWidth() / 2 - container.getPreferredSize().x / 2,
|
||||
app.getCamera().getHeight() / 2 + container.getPreferredSize().y / 2,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
}
|
||||
|
||||
public void addButton(String label, Runnable action, Vector3f size) {
|
||||
createButton(label, action, size);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public MainView(MdgaApp app) {
|
||||
dialog = new InputButtonDialog(app, node);
|
||||
dialog.addButton("Spiel beitreten", () -> app.enter(MdgaState.LOBBY), size);
|
||||
dialog.addButton("Spiel hosten", () -> app.enter(MdgaState.LOBBY), size);
|
||||
dialog.addButton("Einstellungen", () -> System.out.println("Einstellungen"), size);
|
||||
dialog.addButton("Einstellungen", () -> enterSettings(), size);
|
||||
dialog.addButton("Spiel beenden", () -> app.stop(), size);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,30 +2,74 @@
|
||||
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Quad;
|
||||
import com.jme3.texture.Texture;
|
||||
import pp.mdga.client.dialog.SettingsButtonDialog;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.dialog.SettingsDialog;
|
||||
|
||||
public abstract class MdgaView {
|
||||
protected MdgaApp app;
|
||||
protected Node node;
|
||||
|
||||
private SettingsButtonDialog settings;
|
||||
private Node settingsNode;
|
||||
private Node audioNode;
|
||||
private Node videoNode;
|
||||
|
||||
private SettingsButtonDialog settingsButton;
|
||||
|
||||
private Geometry settingsBackground;
|
||||
private Geometry audioBackground;
|
||||
private Geometry videoBackground;
|
||||
|
||||
private SettingsDialog settings;
|
||||
private SettingsDialog audio;
|
||||
private SettingsDialog video;
|
||||
|
||||
public MdgaView(MdgaApp app) {
|
||||
this.app = app;
|
||||
this.node = new Node();
|
||||
|
||||
settings = new SettingsButtonDialog(app, node, "", () -> System.out.println("Einstellungen"));
|
||||
this.settingsNode = new Node();
|
||||
this.audioNode = new Node();
|
||||
this.videoNode = new Node();
|
||||
|
||||
this.settingsButton = new SettingsButtonDialog(app, node, "", () -> enterSettings());
|
||||
|
||||
this.settingsBackground = createBackground("background/zahnräder.png");
|
||||
settingsNode.attachChild(settingsBackground);
|
||||
|
||||
this.audioBackground = createBackground("background/lautsprecher.png");
|
||||
audioNode.attachChild(audioBackground);
|
||||
|
||||
this.videoBackground = createBackground("background/monitors.png");
|
||||
videoNode.attachChild(videoBackground);
|
||||
|
||||
Vector3f size = new Vector3f(280, 60, 0);
|
||||
|
||||
this.settings = new SettingsDialog(app, settingsNode, "zahnrad.png");
|
||||
this.settings.addButton("Video", () -> enterVideo(), size);
|
||||
this.settings.addButton("Audio", () -> enterAudio(), size);
|
||||
this.settings.addButton("Zurück", () -> leaveSettings(false), size);
|
||||
|
||||
this.audio = new SettingsDialog(app, audioNode, "audio_icon.png");
|
||||
this.audio.addButton("A", () -> System.out.println("A"), size);
|
||||
this.audio.addButton("B", () -> System.out.println("B"), size);
|
||||
this.audio.addButton("Zurück", () -> leaveAudio(), size);
|
||||
|
||||
this.video = new SettingsDialog(app, videoNode, "monitor.png");
|
||||
this.video.addButton("A", () -> System.out.println("A"), size);
|
||||
this.video.addButton("B", () -> System.out.println("B"), size);
|
||||
this.video.addButton("Zurück", () -> leaveVideo(), size);
|
||||
}
|
||||
|
||||
public void enter() {
|
||||
app.getGuiNode().attachChild(node);
|
||||
|
||||
settings.show();
|
||||
settingsButton.show();
|
||||
|
||||
onEnter();
|
||||
}
|
||||
@@ -33,7 +77,7 @@ public void enter() {
|
||||
public void leave() {
|
||||
onLeave();
|
||||
|
||||
settings.hide();
|
||||
settingsButton.hide();
|
||||
|
||||
app.getGuiNode().detachChild(node);
|
||||
}
|
||||
@@ -52,4 +96,54 @@ protected Geometry createBackground(String texturePath) {
|
||||
background.setLocalTranslation(0, 0, -1);
|
||||
return background;
|
||||
}
|
||||
|
||||
protected void enterSettings() {
|
||||
leave();
|
||||
|
||||
app.getGuiNode().attachChild(settingsNode);
|
||||
|
||||
settings.show();
|
||||
}
|
||||
|
||||
protected void leaveSettings(boolean soft) {
|
||||
settings.hide();
|
||||
|
||||
app.getGuiNode().detachChild(settingsNode);
|
||||
|
||||
if(!soft) {
|
||||
enter();
|
||||
}
|
||||
}
|
||||
|
||||
protected void enterAudio() {
|
||||
leaveSettings(true);
|
||||
|
||||
app.getGuiNode().attachChild(audioNode);
|
||||
|
||||
audio.show();
|
||||
}
|
||||
|
||||
protected void leaveAudio() {
|
||||
audio.hide();
|
||||
|
||||
app.getGuiNode().detachChild(audioNode);
|
||||
|
||||
enterSettings();
|
||||
}
|
||||
|
||||
protected void enterVideo() {
|
||||
leaveSettings(true);
|
||||
|
||||
app.getGuiNode().attachChild(videoNode);
|
||||
|
||||
video.show();
|
||||
}
|
||||
|
||||
protected void leaveVideo() {
|
||||
video.hide();
|
||||
|
||||
app.getGuiNode().detachChild(videoNode);
|
||||
|
||||
enterSettings();
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Projekte/mdga/client/src/main/resources/audio_icon.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/audio_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 MiB |
BIN
Projekte/mdga/client/src/main/resources/background/monitors.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/background/monitors.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 MiB |
BIN
Projekte/mdga/client/src/main/resources/background/zahnräder.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/background/zahnräder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 MiB |
BIN
Projekte/mdga/client/src/main/resources/monitor.png
Normal file
BIN
Projekte/mdga/client/src/main/resources/monitor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
Projekte/mdga/client/src/main/resources/monitor.png~
Normal file
BIN
Projekte/mdga/client/src/main/resources/monitor.png~
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user