Skip to content

Commit 1eefbe0

Browse files
committed
workaround for 2.x sketches that used Tweak Mode (fixes #415)
1 parent 17f5364 commit 1eefbe0

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

app/src/processing/app/Base.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ private static ModeInfo modeInfoFor(final File sketch) {
10701070
*/
10711071

10721072

1073+
/*
10731074
private Mode promptForMode(final File passedFile) {
10741075
final String filename = passedFile.getName();
10751076
final String extension =
@@ -1080,13 +1081,6 @@ private Mode promptForMode(final File passedFile) {
10801081
possibleModes.add(mode);
10811082
}
10821083
}
1083-
/*
1084-
if (possibleModes.size() == 1 &&
1085-
possibleModes.get(0).getIdentifier().equals(getDefaultModeIdentifier())) {
1086-
// If default mode can open it, then do so without prompting.
1087-
return possibleModes.get(0);
1088-
}
1089-
*/
10901084
if (possibleModes.size() == 0) {
10911085
final String msg =
10921086
"I don't know how to open a sketch with the \"" + extension + "\"\n" +
@@ -1111,6 +1105,7 @@ private Mode promptForMode(final File passedFile) {
11111105
null, modes, modes[0]);
11121106
}
11131107
}
1108+
*/
11141109

11151110

11161111
/*
@@ -1398,12 +1393,7 @@ private boolean smellsLikeSketchFolder(File folder) {
13981393

13991394

14001395
private File moveLikeSketchFolder(File pdeFile, String baseName) throws IOException {
1401-
// final String properParent =
1402-
// file.getName().substring(0, file.getName().lastIndexOf('.'));
1403-
14041396
Object[] options = {
1405-
//Language.text("prompt.ok"),
1406-
//Language.text("prompt.cancel")
14071397
"Keep", "Move", "Cancel"
14081398
};
14091399
String prompt =
@@ -1494,14 +1484,27 @@ public Editor handleOpen(String path) {
14941484
// First check for the Mode, because it may not even be available
14951485
String modeIdentifier = props.get("mode.id");
14961486
if (modeIdentifier != null) {
1497-
Mode mode = findMode(modeIdentifier);
1498-
if (mode != null) {
1499-
nextMode = mode;
1487+
if (modeIdentifier.equals("galsasson.mode.tweak.TweakMode")) {
1488+
// Tweak Mode has been built into Processing since 2015,
1489+
// but there are some old sketch.properties files out there.
1490+
// https://github.com/processing/processing4/issues/415
1491+
nextMode = getDefaultMode();
1492+
1493+
// Clean up sketch.properties and re-save or remove if necessary
1494+
props.remove("mode");
1495+
props.remove("mode.id");
1496+
props.reckon();
1497+
15001498
} else {
1501-
ContributionManager.openModes();
1502-
Messages.showWarning("Missing Mode",
1503-
"You must first install " + props.get("mode") + " Mode to use this sketch.");
1504-
return null;
1499+
Mode mode = findMode(modeIdentifier);
1500+
if (mode != null) {
1501+
nextMode = mode;
1502+
} else {
1503+
ContributionManager.openModes();
1504+
Messages.showWarning("Missing Mode",
1505+
"You must first install " + props.get("mode") + " Mode to use this sketch.");
1506+
return null;
1507+
}
15051508
}
15061509
}
15071510

todo.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
1282 (4.0b7)
22
X Bring back getMainProgram() for Python Mode
33
X https://github.com/processing/processing4/issues/409
4-
_ You must first install tweak Mode to use this sketch
5-
_ https://github.com/processing/processing4/issues/415
4+
X You must first install tweak Mode to use this sketch
5+
X https://github.com/processing/processing4/issues/415
66

77
_ deleting sketch removed contents of Download folder
88
_ https://github.com/processing/processing4/issues/424

0 commit comments

Comments
 (0)