Merge work #7
@@ -49,6 +49,7 @@ public void simpleInitApp() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleUpdate(float tpf) {
|
public void simpleUpdate(float tpf) {
|
||||||
|
view.update();
|
||||||
acousticHandler.update();
|
acousticHandler.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package pp.mdga.client.dialog;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class PercentRunnable {
|
||||||
|
private final Consumer<Float> action;
|
||||||
|
|
||||||
|
public PercentRunnable(Consumer<Float> action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(float percent) {
|
||||||
|
action.accept(percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,15 +3,25 @@
|
|||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.simsilica.lemur.*;
|
import com.simsilica.lemur.*;
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
import com.simsilica.lemur.component.QuadBackgroundComponent;
|
||||||
import com.simsilica.lemur.component.SpringGridLayout;
|
import com.simsilica.lemur.component.SpringGridLayout;
|
||||||
|
import com.simsilica.lemur.event.CursorListener;
|
||||||
|
import com.simsilica.lemur.event.CursorMotionEvent;
|
||||||
|
import com.simsilica.lemur.event.MouseEventControl;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import com.simsilica.lemur.*;
|
||||||
|
import com.simsilica.lemur.style.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class SettingsDialog extends Dialog {
|
public class SettingsDialog extends Dialog {
|
||||||
private TextField nameInput;
|
private TextField nameInput;
|
||||||
|
|
||||||
|
private HashMap<Slider, PercentRunnable> map = new HashMap<Slider, PercentRunnable>();
|
||||||
|
|
||||||
public SettingsDialog(MdgaApp app, Node node, String path) {
|
public SettingsDialog(MdgaApp app, Node node, String path) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
@@ -29,7 +39,7 @@ public SettingsDialog(MdgaApp app, Node node, String path) {
|
|||||||
container.addChild(imagePanel).setPreferredSize(new Vector3f((texture.getImage().getWidth() / 2) * app.getResolutionFactor(), (texture.getImage().getHeight() / 2) * app.getResolutionFactor(), 0));
|
container.addChild(imagePanel).setPreferredSize(new Vector3f((texture.getImage().getWidth() / 2) * app.getResolutionFactor(), (texture.getImage().getHeight() / 2) * app.getResolutionFactor(), 0));
|
||||||
|
|
||||||
//abstandshalter
|
//abstandshalter
|
||||||
container.addChild(new Panel(100 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
container.addChild(new Panel(80 * app.getResolutionFactor(), 50 * app.getResolutionFactor(), ColorRGBA.Gray));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,4 +61,43 @@ public void hide() {
|
|||||||
public void addButton(String label, Runnable action, Vector3f size) {
|
public void addButton(String label, Runnable action, Vector3f size) {
|
||||||
createButton(label, action, size);
|
createButton(label, action, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSlider(String label, PercentRunnable action, Vector3f size, int start) {
|
||||||
|
Container subContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
|
|
||||||
|
Slider slider = new Slider("slider");
|
||||||
|
|
||||||
|
QuadBackgroundComponent background = new QuadBackgroundComponent(ColorRGBA.DarkGray);
|
||||||
|
slider.setBackground(background);
|
||||||
|
|
||||||
|
slider.setPreferredSize(size);
|
||||||
|
slider.setModel(new DefaultRangedValueModel(0, 10, start));
|
||||||
|
slider.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 30 * app.getResolutionFactor(), 0));
|
||||||
|
slider.getDecrementButton().setText(" - ");
|
||||||
|
slider.getIncrementButton().setText(" + ");
|
||||||
|
slider.getDecrementButton().setFontSize(25 * app.getResolutionFactor());
|
||||||
|
slider.getIncrementButton().setFontSize(25 * app.getResolutionFactor());
|
||||||
|
|
||||||
|
Label nameLabel = new Label(label);
|
||||||
|
nameLabel.setFontSize(fontSize);
|
||||||
|
nameLabel.setColor(ColorRGBA.Black);
|
||||||
|
nameLabel.setPreferredSize(new Vector3f(150 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), 0));
|
||||||
|
|
||||||
|
subContainer.addChild(nameLabel);
|
||||||
|
subContainer.addChild(slider);
|
||||||
|
|
||||||
|
container.addChild(subContainer);
|
||||||
|
|
||||||
|
map.put(slider, action);
|
||||||
|
|
||||||
|
//abstandshalter
|
||||||
|
container.addChild(new Panel(20 * app.getResolutionFactor(), 10 * app.getResolutionFactor(), ColorRGBA.Gray));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
map.forEach((slider, runnable) -> {
|
||||||
|
float val = (float) slider.getModel().getPercent();
|
||||||
|
runnable.run(val);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.shape.Quad;
|
import com.jme3.scene.shape.Quad;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
|
import pp.mdga.client.dialog.PercentRunnable;
|
||||||
import pp.mdga.client.dialog.SettingsButtonDialog;
|
import pp.mdga.client.dialog.SettingsButtonDialog;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.dialog.SettingsDialog;
|
import pp.mdga.client.dialog.SettingsDialog;
|
||||||
@@ -56,8 +57,9 @@ public MdgaView(MdgaApp app) {
|
|||||||
this.settings.addButton("Zurück", () -> leaveSettings(false), size);
|
this.settings.addButton("Zurück", () -> leaveSettings(false), size);
|
||||||
|
|
||||||
this.audio = new SettingsDialog(app, audioNode, "audio_icon.png");
|
this.audio = new SettingsDialog(app, audioNode, "audio_icon.png");
|
||||||
this.audio.addButton("A", () -> System.out.println("A"), size);
|
this.audio.addSlider("Lautstärke", new PercentRunnable(app.getAcousticHandler()::setMainVolume), size, 5);
|
||||||
this.audio.addButton("B", () -> System.out.println("B"), size);
|
this.audio.addSlider("Musik", new PercentRunnable(app.getAcousticHandler()::setMusicVolume), size, 10);
|
||||||
|
this.audio.addSlider("Sound", new PercentRunnable(app.getAcousticHandler()::setSoundVolume), size, 10);
|
||||||
this.audio.addButton("Zurück", () -> leaveAudio(), size);
|
this.audio.addButton("Zurück", () -> leaveAudio(), size);
|
||||||
|
|
||||||
this.video = new SettingsDialog(app, videoNode, "monitor.png");
|
this.video = new SettingsDialog(app, videoNode, "monitor.png");
|
||||||
@@ -82,6 +84,10 @@ public void leave() {
|
|||||||
app.getGuiNode().detachChild(node);
|
app.getGuiNode().detachChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
audio.update();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void onEnter();
|
protected abstract void onEnter();
|
||||||
protected abstract void onLeave();
|
protected abstract void onLeave();
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 44 KiB |
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 |
Reference in New Issue
Block a user