Add showInfo to MdgaView
This commit is contained in:
@@ -27,6 +27,11 @@ public void addTestNotification(Notification n) {
|
|||||||
public void update() {
|
public void update() {
|
||||||
Notification n = app.getGameLogic().getNotification();
|
Notification n = app.getGameLogic().getNotification();
|
||||||
|
|
||||||
|
if(n instanceof InfoNotification infoNotification) {
|
||||||
|
app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(n != null) {
|
if(n != null) {
|
||||||
switch (app.getState()) {
|
switch (app.getState()) {
|
||||||
case MAIN:
|
case MAIN:
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package pp.mdga.client.view;
|
package pp.mdga.client.view;
|
||||||
|
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
|
import pp.mdga.client.button.AbstractButton;
|
||||||
|
import pp.mdga.client.button.LabelButton;
|
||||||
import pp.mdga.client.dialog.HostDialog;
|
import pp.mdga.client.dialog.HostDialog;
|
||||||
import pp.mdga.client.dialog.JoinDialog;
|
import pp.mdga.client.dialog.JoinDialog;
|
||||||
import pp.mdga.client.dialog.StartDialog;
|
import pp.mdga.client.dialog.StartDialog;
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
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.system.NanoTimer;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
@@ -30,6 +33,9 @@ public enum Overlay {
|
|||||||
private VideoSettingsDialog videoSettingsDialog;
|
private VideoSettingsDialog videoSettingsDialog;
|
||||||
private AudioSettingsDialog audioSettingsDialog;
|
private AudioSettingsDialog audioSettingsDialog;
|
||||||
|
|
||||||
|
protected LabelButton infoLabel = null;
|
||||||
|
protected NanoTimer infoTimer = new NanoTimer();
|
||||||
|
|
||||||
private int settingsDepth = 0;
|
private int settingsDepth = 0;
|
||||||
|
|
||||||
public MdgaView(MdgaApp app) {
|
public MdgaView(MdgaApp app) {
|
||||||
@@ -80,6 +86,11 @@ public void update(float tpf) {
|
|||||||
videoSettingsDialog.update();
|
videoSettingsDialog.update();
|
||||||
audioSettingsDialog.update();
|
audioSettingsDialog.update();
|
||||||
|
|
||||||
|
if (null != infoLabel && infoTimer.getTimeInSeconds() > 7) {
|
||||||
|
infoLabel.hide();
|
||||||
|
infoLabel = null;
|
||||||
|
}
|
||||||
|
|
||||||
onUpdate(tpf);
|
onUpdate(tpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,4 +204,24 @@ public void pressForward() {
|
|||||||
ceremonyView.forward();
|
ceremonyView.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showInfo(String error, boolean isError) {
|
||||||
|
infoTimer.reset();
|
||||||
|
|
||||||
|
if(null != infoLabel) {
|
||||||
|
infoLabel.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
infoLabel = new LabelButton(app, guiNode, error, new Vector2f(5.5f, 2), new Vector2f(0.5f, AbstractButton.VERTICAL - 0.5f), false);
|
||||||
|
|
||||||
|
ColorRGBA color;
|
||||||
|
|
||||||
|
if(isError) {
|
||||||
|
color = ColorRGBA.Red.clone();
|
||||||
|
} else {
|
||||||
|
color = ColorRGBA.Green.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
infoLabel.setColor(ColorRGBA.Black, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user