Skip to content

Commit 69999ee

Browse files
committed
customize game startup for macOS platforms
1 parent 971b9c3 commit 69999ee

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

common.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ java {
88
targetCompatibility = JavaVersion.VERSION_11
99
}
1010

11+
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
12+
Boolean isMacOS = DefaultNativePlatform.currentOperatingSystem.isMacOsX()
13+
1114
tasks.withType(JavaExec) { // Java runtime options:
15+
if (isMacOS) {
16+
args '--noDialog'
17+
jvmArgs '-XstartOnFirstThread'
18+
}
1219
enableAssertions = true
1320
}
1421

game/src/main/java/mygame/Main.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,17 @@ public class Main extends GameApplication {
4545

4646
/**
4747
* Start the jMonkeyEngine application
48-
* @param args
48+
*
49+
* @param args might contain "--noDialog"
4950
*/
5051
public static void main(String[] args) {
52+
boolean showSettingsDialog = true;
53+
for (String arg : args) {
54+
if (arg.equals("--noDialog")) {
55+
showSettingsDialog = false;
56+
}
57+
}
58+
5159
// Mute the chatty loggers in certain packages.
5260
Heart.setLoggingLevels(Level.WARNING);
5361

@@ -65,7 +73,7 @@ public static void main(String[] args) {
6573
//settings.setFrameRate(60);
6674

6775
app.setSettings(settings);
68-
app.setShowSettings(true);
76+
app.setShowSettings(showSettingsDialog);
6977
app.setPauseOnLostFocus(false);
7078
app.start();
7179
}

0 commit comments

Comments
 (0)