prevent "run sketches on display" message from showing up on startup

This commit is contained in:
Ben Fry
2017-05-04 11:29:12 -04:00
parent 10bd76d099
commit d960fd1cba
3 changed files with 38 additions and 33 deletions

View File

@@ -376,7 +376,9 @@ public class Runner implements MessageConsumer {
} else {
params.append("processing.core.PApplet");
// get the stored device index (starts at 1)
// Get the stored device index (starts at 1)
// By default, set to -1, meaning 'the default display',
// which is the same display as the one being used by the Editor.
int runDisplay = Preferences.getInteger("run.display");
// If there was a saved location (this guy has been run more than once)
@@ -395,23 +397,26 @@ public class Runner implements MessageConsumer {
// Make sure the display set in Preferences actually exists
GraphicsDevice runDevice = editorDevice;
if (runDisplay > 0 && runDisplay <= devices.length) {
runDevice = devices[runDisplay-1];
} else {
// If a bad display is selected, use the same display as the editor
if (runDisplay > 0) { // don't complain about -1 or 0
System.err.println("Display " + runDisplay + " not available.");
}
runDevice = editorDevice;
for (int i = 0; i < devices.length; i++) {
if (devices[i] == runDevice) {
// Wasn't setting the pref to avoid screwing things up with
// something temporary. But not setting it makes debugging one's
// setup just too damn weird, so changing that behavior.
runDisplay = i + 1;
System.err.println("Setting 'Run Sketches on Display' preference to display " + runDisplay);
Preferences.setInteger("run.display", runDisplay);
break;
if (runDisplay > 0) {
if (runDisplay <= devices.length) {
runDevice = devices[runDisplay-1];
} else {
// If a bad display is selected, use the same display as the editor
if (runDisplay > 0) { // don't complain about -1 or 0
System.err.println("Display " + runDisplay + " not available.");
}
runDevice = editorDevice;
for (int i = 0; i < devices.length; i++) {
if (devices[i] == runDevice) {
// Wasn't setting the pref to avoid screwing things up with
// something temporary. But not setting it makes debugging one's
// setup just too damn weird, so changing that behavior.
runDisplay = i + 1;
System.err.println("Setting 'Run Sketches on Display' preference to display " + runDisplay);
Preferences.setInteger("run.display", runDisplay);
break;
}
}
}
}