mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
making a complete mess of preferences
This commit is contained in:
@@ -277,101 +277,6 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
// load the last program that was in use
|
||||
|
||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
int windowX = -1, windowY = 0, windowW = 0, windowH = 0;
|
||||
|
||||
Properties skprops = new Properties();
|
||||
try {
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
//String pkg = "Proce55ing.app/Contents/Resources/Java/";
|
||||
//skprops.load(new FileInputStream(pkg + "sketch.properties"));
|
||||
skprops.load(new FileInputStream("lib/sketch.properties"));
|
||||
|
||||
} else if (PdeBase.platform == PdeBase.MACOS9) {
|
||||
skprops.load(new FileInputStream("lib/sketch.properties"));
|
||||
|
||||
} else {
|
||||
skprops.load(getClass().getResource("sketch.properties").openStream());
|
||||
}
|
||||
|
||||
windowX = Integer.parseInt(skprops.getProperty("window.x", "-1"));
|
||||
windowY = Integer.parseInt(skprops.getProperty("window.y", "-1"));
|
||||
windowW = Integer.parseInt(skprops.getProperty("window.w", "-1"));
|
||||
windowH = Integer.parseInt(skprops.getProperty("window.h", "-1"));
|
||||
|
||||
// if screen size has changed, the window coordinates no longer
|
||||
// make sense, so don't use them unless they're identical
|
||||
int screenW = Integer.parseInt(skprops.getProperty("screen.w", "-1"));
|
||||
int screenH = Integer.parseInt(skprops.getProperty("screen.h", "-1"));
|
||||
|
||||
if ((screen.width != screenW) || (screen.height != screenH)) {
|
||||
// probably not valid for this machine, so invalidate sizing
|
||||
windowX = -1;
|
||||
}
|
||||
|
||||
String name = skprops.getProperty("sketch.name");
|
||||
String path = skprops.getProperty("sketch.directory");
|
||||
String user = skprops.getProperty("user.name");
|
||||
|
||||
String what = path + File.separator + name + ".pde";
|
||||
|
||||
if (windowX != -1) {
|
||||
String dividerLocation =
|
||||
skprops.getProperty("editor.divider.location");
|
||||
if (dividerLocation != null) {
|
||||
splitPane.setDividerLocation(Integer.parseInt(dividerLocation));
|
||||
}
|
||||
}
|
||||
|
||||
if (new File(what).exists()) {
|
||||
userName = user;
|
||||
skOpen(path, name);
|
||||
|
||||
} else {
|
||||
userName = "default";
|
||||
skNew();
|
||||
}
|
||||
|
||||
String serialPort = skprops.getProperty("serial.port");
|
||||
if (serialPort != null) {
|
||||
PdeBase.properties.put("serial.port", serialPort);
|
||||
}
|
||||
|
||||
boolean ee = new Boolean(skprops.getProperty("editor.external", "false")).booleanValue();
|
||||
setExternalEditor(ee);
|
||||
|
||||
} catch (Exception e) {
|
||||
// this exception doesn't matter, it's just the normal course of things
|
||||
// the app reaches here when no sketch.properties file exists
|
||||
//e.printStackTrace();
|
||||
|
||||
// indicator that this is the first time this feller has used p5
|
||||
PdeBase.firstTime = true;
|
||||
|
||||
// even if folder for 'default' user doesn't exist, or
|
||||
// sketchbook itself is missing, mkdirs() will make it happy
|
||||
userName = "default";
|
||||
|
||||
// doesn't exist, not available, make my own
|
||||
skNew();
|
||||
}
|
||||
|
||||
if (windowX == -1) {
|
||||
//System.out.println("using defaults for window size");
|
||||
windowW = PdeBase.getInteger("window.width", 500);
|
||||
windowH = PdeBase.getInteger("window.height", 500);
|
||||
windowX = (screen.width - windowW) / 2;
|
||||
windowY = (screen.height - windowH) / 2;
|
||||
}
|
||||
//PdeBase.frame.setBounds(windowX, windowY, windowW, windowH);
|
||||
base.setBounds(windowX, windowY, windowW, windowH);
|
||||
//rebuildSketchbookMenu(PdeBase.sketchbookMenu);
|
||||
}
|
||||
|
||||
|
||||
protected void changeText(String what, boolean emptyUndo) {
|
||||
textarea.setText(what);
|
||||
|
||||
@@ -1896,7 +1801,7 @@ public class PdeEditor extends JPanel {
|
||||
//System.out.println("setting ee to " + externalEditor);
|
||||
|
||||
textarea.setEditable(!external);
|
||||
base.externalEditorItem.setState(external);
|
||||
//base.externalEditorItem.setState(external);
|
||||
base.saveMenuItem.setEnabled(!external);
|
||||
base.saveAsMenuItem.setEnabled(!external);
|
||||
base.beautifyMenuItem.setEnabled(!external);
|
||||
|
||||
Reference in New Issue
Block a user