Post-constructor setup for the editor area. Loads the last sketch that was used (if any), and restores other Editor settings. The complement to "storePreferences", this is called when the application is first launched. @throws Exception
()
| 528 | * @throws Exception |
| 529 | */ |
| 530 | protected boolean restoreSketches() throws Exception { |
| 531 | // Iterate through all sketches that were open last time p5 was running. |
| 532 | // If !windowPositionValid, then ignore the coordinates found for each. |
| 533 | |
| 534 | // Save the sketch path and window placement for each open sketch |
| 535 | int count = PreferencesData.getInteger("last.sketch.count"); |
| 536 | int opened = 0; |
| 537 | for (int i = count - 1; i >= 0; i--) { |
| 538 | String path = PreferencesData.get("last.sketch" + i + ".path"); |
| 539 | if (path == null) { |
| 540 | continue; |
| 541 | } |
| 542 | if (BaseNoGui.getPortableFolder() != null && !new File(path).isAbsolute()) { |
| 543 | File absolute = new File(BaseNoGui.getPortableFolder(), path); |
| 544 | try { |
| 545 | path = absolute.getCanonicalPath(); |
| 546 | } catch (IOException e) { |
| 547 | // path unchanged. |
| 548 | } |
| 549 | } |
| 550 | int[] location = retrieveSketchLocation("" + i); |
| 551 | // If file did not exist, null will be returned for the Editor |
| 552 | if (handleOpen(new File(path), location, nextEditorLocation(), false, false) != null) { |
| 553 | opened++; |
| 554 | } |
| 555 | } |
| 556 | return (opened > 0); |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Store screen dimensions on last close |
no test coverage detected