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