Add settings to enable failsafe exceptions, improve settings dialog with automatic restart
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
Submodule hyperlap2d-common-api updated: fe8ed39c65...b93fef7549
+5
@@ -41,4 +41,9 @@ public class SkinComposerSettings extends SettingsNodeValue<SkinComposerVO> {
|
||||
public boolean validateSettings() {
|
||||
return loaded && getSettings().alwaysCheckUpdates != alwaysCheckUpdates.isChecked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class Main {
|
||||
}
|
||||
|
||||
Thread.currentThread().setUncaughtExceptionHandler(new CustomExceptionHandler());
|
||||
Facade.getInstance().setUncaughtExceptionHandler(new FacadeExceptionHandler());
|
||||
//Increase default lwjgl stack size
|
||||
System.setProperty("org.lwjgl.system.stackSize", "256");
|
||||
|
||||
@@ -53,6 +52,8 @@ public class Main {
|
||||
config.setWindowIcon("hyperlap_icon_96.png");
|
||||
if (settingsManager.editorConfigVO.useANGLEGLES2)
|
||||
config.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.ANGLE_GLES20, 3, 2);
|
||||
if (settingsManager.editorConfigVO.failSafeException)
|
||||
Facade.getInstance().setUncaughtExceptionHandler(new FacadeExceptionHandler());
|
||||
config.setBackBufferConfig(8,8,8,8,16,8, settingsManager.editorConfigVO.msaaSamples);
|
||||
|
||||
new Lwjgl3ApplicationGLESFix(HyperLap2DApp.initInstance(dm.width, dm.height, settingsManager), config);
|
||||
@@ -144,4 +145,44 @@ public class Main {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getMainClassName() {
|
||||
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
||||
if (trace.length > 0) {
|
||||
return trace[trace.length - 1].getClassName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void restartJVM() {
|
||||
// restart jvm with -XstartOnFirstThread
|
||||
String separator = System.getProperty("file.separator");
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
String mainClass = getMainClassName();
|
||||
String jvmPath = System.getProperty("java.home") + separator + "bin" + separator + "java";
|
||||
|
||||
List<String> inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
|
||||
ArrayList<String> jvmArgs = new ArrayList<>();
|
||||
|
||||
jvmArgs.add(jvmPath);
|
||||
if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC)
|
||||
jvmArgs.add("-XstartOnFirstThread");
|
||||
jvmArgs.add("-Djava.awt.headless=true");
|
||||
jvmArgs.addAll(inputArguments);
|
||||
jvmArgs.add("-cp");
|
||||
jvmArgs.add(classpath);
|
||||
jvmArgs.add(mainClass);
|
||||
|
||||
// if you don't need console output, just enable these two lines
|
||||
// and delete bits after it. This JVM will then terminate.
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(jvmArgs);
|
||||
try {
|
||||
processBuilder.start();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tree;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import com.kotcrab.vis.ui.widget.*;
|
||||
import games.rednblack.editor.Main;
|
||||
import games.rednblack.h2d.common.H2DDialog;
|
||||
import games.rednblack.h2d.common.view.SettingsNodeValue;
|
||||
import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
@@ -103,18 +105,29 @@ public class SettingsDialog extends H2DDialog {
|
||||
}
|
||||
|
||||
private void applyAllSettings() {
|
||||
boolean askToRestart = false;
|
||||
for (SettingsNode node : settingsTree.getRootNodes()) {
|
||||
if (node.getValue().validateSettings()) {
|
||||
if (node.getValue().requireRestart()) askToRestart = true;
|
||||
node.getValue().translateViewToSettings();
|
||||
}
|
||||
if (node.getChildren().size > 0) {
|
||||
for (SettingsNode child : node.getChildren()) {
|
||||
if (child.getValue().validateSettings()) {
|
||||
if (child.getValue().requireRestart()) askToRestart = true;
|
||||
child.getValue().translateViewToSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (askToRestart) {
|
||||
Dialogs.showConfirmDialog(getStage(), "Restart is required", "Some changes needs to restart the editor,\nwould you like to do it now?",
|
||||
new String[]{"Yes, restart now", "Cancel"}, new Integer[]{0, 1}, r -> {
|
||||
if (r == 0) {
|
||||
Main.restartJVM();
|
||||
}
|
||||
}).padBottom(20).pack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
|
||||
private final VisCheckBox autoSaving, useANGLEGLES2;
|
||||
private final VisCheckBox autoSaving, useANGLEGLES2, failSafeException;
|
||||
private final VisCheckBox enablePlugins;
|
||||
private VisSelectBox<String> filterKeyMapping;
|
||||
private VisSlider uiScaleDensity, msaaSamples, fpsLimit;
|
||||
@@ -27,13 +27,16 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
autoSaving = StandardWidgetsFactory.createCheckBox("Save changes automatically [EXPERIMENTAL]");
|
||||
getContentTable().add(autoSaving).left().padTop(5).padLeft(8).row();
|
||||
|
||||
failSafeException = StandardWidgetsFactory.createCheckBox("Keep alive on exceptions [EXPERIMENTAL]");
|
||||
getContentTable().add(failSafeException).left().padTop(5).padLeft(8).row();
|
||||
|
||||
getContentTable().add(getKeyMappingTable()).left().padTop(5).row();
|
||||
|
||||
getContentTable().add(getUiScaleDensityTable()).left().padTop(5).row();
|
||||
|
||||
getContentTable().add("Plugins").left().padTop(10).row();
|
||||
getContentTable().addSeparator();
|
||||
enablePlugins = StandardWidgetsFactory.createCheckBox("Enable plugins [Require restart]");
|
||||
enablePlugins = StandardWidgetsFactory.createCheckBox("Enable plugins");
|
||||
getContentTable().add(enablePlugins).left().padTop(5).padLeft(8).row();
|
||||
|
||||
getContentTable().add("Performance").left().padTop(10).row();
|
||||
@@ -41,7 +44,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
getContentTable().add(getMassSamplesTable()).left().padTop(5).row();
|
||||
getContentTable().add(getFPSLimitTable()).left().padTop(5).row();
|
||||
|
||||
useANGLEGLES2 = StandardWidgetsFactory.createCheckBox("Use ANGLE OpenGL ES 2 API [Require restart]");
|
||||
useANGLEGLES2 = StandardWidgetsFactory.createCheckBox("Use ANGLE OpenGL ES 2 API");
|
||||
getContentTable().add(useANGLEGLES2).left().padTop(5).padLeft(8).row();
|
||||
}
|
||||
|
||||
@@ -53,7 +56,6 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
filterKeyMapping = StandardWidgetsFactory.createSelectBox(String.class);
|
||||
filterKeyMapping.setItems(settingsManager.getKeyMappingFiles());
|
||||
mappingTable.add(filterKeyMapping).padLeft(8);
|
||||
mappingTable.add("[Require restart]").padLeft(8);
|
||||
|
||||
return mappingTable;
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
msaaSamples.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
labelFactor.setText(getMsaaSamples() + " [Require restart]");
|
||||
labelFactor.setText(getMsaaSamples());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -111,7 +113,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
if (getFPSLimit() == 0)
|
||||
labelFactor.setText("Unlimited");
|
||||
else
|
||||
labelFactor.setText(getFPSLimit() + " [Require restart]");
|
||||
labelFactor.setText(getFPSLimit());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -134,6 +136,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
public void translateSettingsToView() {
|
||||
autoSaving.setChecked(getSettings().autoSave);
|
||||
useANGLEGLES2.setChecked(getSettings().useANGLEGLES2);
|
||||
failSafeException.setChecked(getSettings().failSafeException);
|
||||
enablePlugins.setChecked(getSettings().enablePlugins);
|
||||
filterKeyMapping.setSelected(getSettings().keyBindingLayout);
|
||||
uiScaleDensity.setValue(getSettings().uiScaleDensity);
|
||||
@@ -145,6 +148,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
public void translateViewToSettings() {
|
||||
getSettings().autoSave = autoSaving.isChecked();
|
||||
getSettings().useANGLEGLES2 = useANGLEGLES2.isChecked();
|
||||
getSettings().failSafeException = failSafeException.isChecked();
|
||||
getSettings().enablePlugins = enablePlugins.isChecked();
|
||||
getSettings().keyBindingLayout = filterKeyMapping.getSelected();
|
||||
getSettings().uiScaleDensity = getUIScaleDensity();
|
||||
@@ -157,10 +161,21 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
public boolean validateSettings() {
|
||||
return getSettings().autoSave != autoSaving.isChecked()
|
||||
|| getSettings().useANGLEGLES2 != useANGLEGLES2.isChecked()
|
||||
|| getSettings().failSafeException != failSafeException.isChecked()
|
||||
|| getSettings().enablePlugins != enablePlugins.isChecked()
|
||||
|| !getSettings().keyBindingLayout.equals(filterKeyMapping.getSelected())
|
||||
|| getSettings().uiScaleDensity != getUIScaleDensity()
|
||||
|| getSettings().msaaSamples != getMsaaSamples()
|
||||
|| getSettings().fpsLimit != getFPSLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return getSettings().useANGLEGLES2 != useANGLEGLES2.isChecked()
|
||||
|| getSettings().failSafeException != failSafeException.isChecked()
|
||||
|| getSettings().enablePlugins != enablePlugins.isChecked()
|
||||
|| !getSettings().keyBindingLayout.equals(filterKeyMapping.getSelected())
|
||||
|| getSettings().msaaSamples != getMsaaSamples()
|
||||
|| getSettings().fpsLimit != getFPSLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,4 +97,9 @@ public class LivePreviewSettings extends SettingsNodeValue<ProjectVO> {
|
||||
public boolean validateSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,9 @@ public class PluginsSettings extends SettingsNodeValue<String> {
|
||||
public boolean validateSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,4 +152,9 @@ public class ProjectExportSettings extends SettingsNodeValue<ProjectVO> {
|
||||
public boolean validateSettings() {
|
||||
return exportSettingsInputFileWidget.getValue() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,4 +101,9 @@ public class SandboxSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
public boolean validateSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireRestart() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user