Development #34
@@ -45,7 +45,7 @@ public class MdgaApp extends SimpleApplication {
|
|||||||
private MdgaState state = null;
|
private MdgaState state = null;
|
||||||
|
|
||||||
/** Scale for rendering images. */
|
/** Scale for rendering images. */
|
||||||
private float imageScale = prefs.getInt("scale", 1);
|
private final float imageScale = prefs.getInt("scale", 1);
|
||||||
|
|
||||||
/** The main menu view. */
|
/** The main menu view. */
|
||||||
private MdgaView mainView;
|
private MdgaView mainView;
|
||||||
@@ -82,6 +82,7 @@ public static void main(String[] args) {
|
|||||||
settings.setSamples(128);
|
settings.setSamples(128);
|
||||||
settings.setWidth(prefs.getInt("width", 1280));
|
settings.setWidth(prefs.getInt("width", 1280));
|
||||||
settings.setHeight(prefs.getInt("height", 720));
|
settings.setHeight(prefs.getInt("height", 720));
|
||||||
|
settings.setFullscreen(prefs.getBoolean("fullscreen", false));
|
||||||
settings.setCenterWindow(true);
|
settings.setCenterWindow(true);
|
||||||
settings.setVSync(false);
|
settings.setVSync(false);
|
||||||
settings.setTitle("MDGA");
|
settings.setTitle("MDGA");
|
||||||
@@ -252,30 +253,43 @@ public ServerConnection getNetworkSupport(){
|
|||||||
return networkConnection;
|
return networkConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateResolution(int width, int height, float imageFactor) {
|
public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
|
||||||
|
if(isFullscreen) {
|
||||||
|
int baseWidth = 1280;
|
||||||
|
int baseHeight = 720;
|
||||||
|
float baseAspectRatio = (float) baseWidth / baseHeight;
|
||||||
|
float newAspectRatio = (float) width / height;
|
||||||
|
|
||||||
|
float scaleFactor = Math.max((float) width / baseWidth, (float) height / baseHeight);
|
||||||
|
|
||||||
|
settings.setFullscreen(true);
|
||||||
|
|
||||||
|
prefs.putFloat("scale", scaleFactor);
|
||||||
|
prefs.putBoolean("fullscreen", true);
|
||||||
|
}
|
||||||
|
|
||||||
prefs.putInt("width", width);
|
prefs.putInt("width", width);
|
||||||
prefs.putInt("height", height);
|
prefs.putInt("height", height);
|
||||||
prefs.putFloat("scale", imageFactor);
|
prefs.putFloat("scale", imageFactor);
|
||||||
|
prefs.putBoolean("fullscreen", false);
|
||||||
try {
|
|
||||||
restartApp();
|
|
||||||
} catch (Exception e) {
|
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void restartApp() throws IOException {
|
public static void restartApp() {
|
||||||
String javaBin = System.getProperty("java.home") + "/bin/java";
|
try {
|
||||||
String classPath = System.getProperty("java.class.path");
|
String javaBin = System.getProperty("java.home") + "/bin/java";
|
||||||
String className = System.getProperty("sun.java.command");
|
String classPath = System.getProperty("java.class.path");
|
||||||
|
String className = System.getProperty("sun.java.command");
|
||||||
|
|
||||||
ProcessBuilder builder = new ProcessBuilder(
|
ProcessBuilder builder = new ProcessBuilder(
|
||||||
javaBin, "-cp", classPath, className
|
javaBin, "-cp", classPath, className
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.start();
|
builder.start();
|
||||||
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("restart failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,16 @@
|
|||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.client.button.AbstractButton;
|
||||||
import pp.mdga.client.button.ButtonLeft;
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
import pp.mdga.client.button.ButtonRight;
|
import pp.mdga.client.button.ButtonRight;
|
||||||
import pp.mdga.client.button.MenuButton;
|
import pp.mdga.client.button.MenuButton;
|
||||||
import pp.mdga.client.view.MdgaView;
|
import pp.mdga.client.view.MdgaView;
|
||||||
|
|
||||||
public class VideoSettingsDialog extends Dialog {
|
public class VideoSettingsDialog extends Dialog {
|
||||||
|
private ButtonRight fullscreenButton;
|
||||||
private MenuButton backButton;
|
private MenuButton backButton;
|
||||||
|
private ButtonRight restartButton;
|
||||||
|
|
||||||
private ButtonLeft hdButton9;
|
private ButtonLeft hdButton9;
|
||||||
private ButtonLeft fullHdButton9;
|
private ButtonLeft fullHdButton9;
|
||||||
@@ -27,22 +30,25 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
|
|||||||
|
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
|
fullscreenButton = new ButtonRight(app, node, () -> app.updateResolution(0, 0, 0, true), "Vollbild", 1);
|
||||||
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
backButton = new MenuButton(app, node, view::leaveVideoSettings, "Zurück");
|
||||||
|
|
||||||
// MenuButton für verschiedene Auflösungen erstellen
|
restartButton = new ButtonRight(app, node, MdgaApp::restartApp, "Neustart", 1);
|
||||||
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f), "hd 16:9", 10);
|
|
||||||
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f), "full hd 16:9", 10);
|
hdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1280, 720, 1.0f, false), "hd 16:9", 10);
|
||||||
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f), "wqhd 16:9", 10);
|
fullHdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(1920, 1080, 2.25f, false), "full hd 16:9", 10);
|
||||||
|
wqhdButton9 = new ButtonLeft(app, node, () -> app.updateResolution(2560, 1440, 4.0f, false), "wqhd 16:9", 10);
|
||||||
|
|
||||||
|
|
||||||
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f), "hd 16:10", 10);
|
hdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1280, 800, 1.0f, false), "hd 16:10", 10);
|
||||||
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f), "full hd 16:10", 10);
|
fullHdButton10 = new ButtonRight(app, node, () -> app.updateResolution(1920, 1200, 2.25f, false), "full hd 16:10", 10);
|
||||||
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f), "wqhd 16:10", 10);
|
wqhdButton10 = new ButtonRight(app, node, () -> app.updateResolution(2560, 1600, 4.0f, false), "wqhd 16:10", 10);
|
||||||
|
|
||||||
float offset = 2.8f;
|
float offset = 2.8f;
|
||||||
|
|
||||||
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
hdButton9.setPos(new Vector2f(hdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
hdButton10.setPos(new Vector2f(hdButton10.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
|
fullscreenButton.setPos(new Vector2f(fullscreenButton.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
offset += 1.5f;
|
offset += 1.5f;
|
||||||
|
|
||||||
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
fullHdButton9.setPos(new Vector2f(fullHdButton9.getPos().x, MenuButton.VERTICAL - offset));
|
||||||
@@ -68,7 +74,9 @@ protected void onShow() {
|
|||||||
fullHdButton10.show();
|
fullHdButton10.show();
|
||||||
wqhdButton10.show();
|
wqhdButton10.show();
|
||||||
|
|
||||||
|
fullscreenButton.show();
|
||||||
backButton.show();
|
backButton.show();
|
||||||
|
restartButton.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,7 +91,9 @@ protected void onHide() {
|
|||||||
fullHdButton10.hide();
|
fullHdButton10.hide();
|
||||||
wqhdButton10.hide();
|
wqhdButton10.hide();
|
||||||
|
|
||||||
|
fullscreenButton.hide();
|
||||||
backButton.hide();
|
backButton.hide();
|
||||||
|
restartButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|||||||
Reference in New Issue
Block a user