()
| 60 | // /** @return true if the sketchbook file did not exist */ |
| 61 | // static public boolean init() { |
| 62 | static public void init() { |
| 63 | // start by loading the defaults, in case something |
| 64 | // important was deleted from the user prefs |
| 65 | try { |
| 66 | // Name changed for 2.1b2 to avoid problems with users modifying or |
| 67 | // replacing the file after doing a search for "preferences.txt". |
| 68 | load(Base.getLibStream(DEFAULTS_FILE)); |
| 69 | } catch (Exception e) { |
| 70 | Messages.showError(null, "Could not read default settings.\n" + |
| 71 | "You'll need to reinstall Processing.", e); |
| 72 | } |
| 73 | |
| 74 | // Clone the defaults, then override any them with the user's preferences. |
| 75 | // This ensures that any new/added preference will be present. |
| 76 | defaults = new HashMap<>(table); |
| 77 | |
| 78 | // other things that have to be set explicitly for the defaults |
| 79 | setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$ |
| 80 | |
| 81 | // For CJK users, enable IM support by default |
| 82 | if (Language.useInputMethod()) { |
| 83 | setBoolean("editor.input_method_support", true); |
| 84 | } |
| 85 | |
| 86 | // next load user preferences file |
| 87 | preferencesFile = Base.getSettingsFile(PREFS_FILE); |
| 88 | boolean firstRun = !preferencesFile.exists(); |
| 89 | if (!firstRun) { |
| 90 | try { |
| 91 | load(new FileInputStream(preferencesFile)); |
| 92 | |
| 93 | } catch (Exception ex) { |
| 94 | Messages.showError("Error reading preferences", |
| 95 | "Error reading the preferences file. " + |
| 96 | "Please delete (or move)\n" + |
| 97 | preferencesFile.getAbsolutePath() + |
| 98 | " and restart Processing.", ex); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | if (checkSketchbookPref() || firstRun) { |
| 103 | // if (firstRun) { |
| 104 | // create a new preferences file if none exists |
| 105 | // saves the defaults out to the file |
| 106 | save(); |
| 107 | } |
| 108 | |
| 109 | PApplet.useNativeSelect = |
| 110 | Preferences.getBoolean("chooser.files.native"); //$NON-NLS-1$ |
| 111 | |
| 112 | // Adding option to disable this in case it's getting in the way |
| 113 | if (get("proxy.system").equals("true")) { |
| 114 | // Use the system proxy settings by default |
| 115 | // https://github.com/processing/processing/issues/2643 |
| 116 | System.setProperty("java.net.useSystemProxies", "true"); |
| 117 | } |
| 118 | |
| 119 | // Set HTTP, HTTPS, and SOCKS proxies for individuals |
no test coverage detected