mirror of
https://github.com/processing/processing4.git
synced 2026-02-10 00:59:40 +01:00
move location of prefs and sketchbook, fixed nasty bugs
This commit is contained in:
@@ -56,7 +56,7 @@ public class PdePreferences extends JComponent {
|
||||
|
||||
// what to call the feller
|
||||
|
||||
static final String PREFS_FILE = "Processing Preferences.txt";
|
||||
static final String PREFS_FILE = "preferences.txt";
|
||||
|
||||
// prompt text stuff
|
||||
|
||||
@@ -143,8 +143,10 @@ public class PdePreferences extends JComponent {
|
||||
|
||||
// next load user preferences file
|
||||
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
preferencesFile = new File(home, PREFS_FILE);
|
||||
//File home = new File(System.getProperty("user.home"));
|
||||
//File processingHome = new File(home, "Processing");
|
||||
//preferencesFile = new File(home, PREFS_FILE);
|
||||
preferencesFile = new File(getProcessingHome(), PREFS_FILE);
|
||||
|
||||
if (!preferencesFile.exists()) {
|
||||
// create a new preferences file if none exists
|
||||
@@ -512,6 +514,26 @@ public class PdePreferences extends JComponent {
|
||||
// .................................................................
|
||||
|
||||
|
||||
static public File getProcessingHome() {
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
// on macosx put the sketchbook in the "Documents" folder
|
||||
return new File(home, "Documents" + File.separator + "Processing");
|
||||
|
||||
} else if (PdeBase.platform == PdeBase.WINDOWS) {
|
||||
// on windows put the sketchbook in the "My Documents" folder
|
||||
return new File(home, "My Documents" + File.separator + "Processing");
|
||||
}
|
||||
|
||||
// all others, just say home directory
|
||||
return new File(home, "processing");
|
||||
}
|
||||
|
||||
|
||||
// .................................................................
|
||||
|
||||
|
||||
// all the information from preferences.txt
|
||||
|
||||
//static public String get(String attribute) {
|
||||
|
||||
@@ -262,7 +262,11 @@ public class PdePreprocessor {
|
||||
|
||||
if (programType == STATIC) {
|
||||
// now that size() and background() can go inside of draw()
|
||||
out.print("public void draw() {");
|
||||
// actually, use setup(), because when running externally
|
||||
// the applet size needs to be set before the window is drawn,
|
||||
// meaning that after setup() things need to be ducky.
|
||||
//out.print("public void draw() {");
|
||||
out.print("public void setup() {");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
windowLocation.x + "," + windowLocation.y) :
|
||||
(PApplet.EXT_LOCATION + x1 + "," + y1);
|
||||
|
||||
//java "-Djava.library.path=C:\Documents and Settings\fry\My Documents\sketchbook\image_loading_problems\code" -cp "lib\build;java\lib\rt.jar;lib;lib\build;lib\pde.jar;lib\core.jar;lib\mrj.jar;lib\antlr.jar;lib\oro.jar;C:\WINDOWS\system32\QTJava.zip;;C:\Documents and Settings\fry\My Documents\sketchbook\image_loading_problems\code" processing.core.PApplet --location=710,61 "--sketch-folder=C:\Documents and Settings\fry\My Documents\sketchbook\image_loading_problems" Temporary_6879_7583
|
||||
String command[] = new String[] {
|
||||
"java",
|
||||
"-Djava.library.path=" + sketch.libraryPath, // might be ""
|
||||
@@ -130,6 +129,10 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
}
|
||||
applet.start();
|
||||
|
||||
/*
|
||||
// appears to be no longer necessary now that draw()
|
||||
// is gonna be run inside of setup()
|
||||
|
||||
// check to see if it's a draw mode applet
|
||||
boolean drawMode = false;
|
||||
try {
|
||||
@@ -152,6 +155,7 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (editor.presenting) {
|
||||
//window = new Window(new Frame());
|
||||
|
||||
@@ -74,6 +74,8 @@ public class PdeSketchbook {
|
||||
if (PdePreferences.get("sketchbook.path") == null) {
|
||||
// by default, set default sketchbook path to the user's
|
||||
// home folder with 'sketchbook' as a subdirectory of that
|
||||
|
||||
/*
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
|
||||
if (PdeBase.platform == PdeBase.MACOSX) {
|
||||
@@ -84,6 +86,8 @@ public class PdeSketchbook {
|
||||
// on windows put the sketchbook in the "My Documents" folder
|
||||
home = new File(home, "My Documents");
|
||||
}
|
||||
*/
|
||||
File home = PdePreferences.getProcessingHome();
|
||||
|
||||
String folderName = PdePreferences.get("sketchbook.name.default");
|
||||
//System.out.println("home = " + home);
|
||||
|
||||
@@ -147,6 +147,7 @@ public class PApplet extends Applet
|
||||
static public final String EXTERNAL_MOVE = "__MOVE__";
|
||||
//boolean externalRuntime;
|
||||
|
||||
//static boolean setupComplete = false;
|
||||
|
||||
public void init() {
|
||||
//checkParams();
|
||||
@@ -199,6 +200,8 @@ public class PApplet extends Applet
|
||||
this.height = g.height;
|
||||
//g.applet = this;
|
||||
|
||||
//setupComplete = true;
|
||||
|
||||
try {
|
||||
getAppletContext();
|
||||
online = true;
|
||||
@@ -297,6 +300,8 @@ public class PApplet extends Applet
|
||||
|
||||
|
||||
public void size(int iwidth, int iheight) {
|
||||
//width = iwidth;
|
||||
//height = iheight;
|
||||
//if (g != null) return; // would this ever happen? is this a good idea?
|
||||
g.resize(iwidth, iheight);
|
||||
|
||||
@@ -1545,16 +1550,15 @@ public class PApplet extends Applet
|
||||
gimmeImage(getClass().getResource("data/" + filename), force);
|
||||
}
|
||||
if (awtimage == null) {
|
||||
/*
|
||||
try {
|
||||
//FileInputStream fis =
|
||||
//new FileInputStream(folder + "data/" + filename);
|
||||
URL url = new URL("file:/" + folder + "data/" + filename);
|
||||
awtimage = gimmeImage(url, force);
|
||||
String url = "file:/" + folder + "/data/" + filename;
|
||||
//URL url = new URL("file:/" + folder + "data/" + filename);
|
||||
awtimage = gimmeImage(new URL(url), force);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (awtimage == null) {
|
||||
@@ -2856,7 +2860,7 @@ public class PApplet extends Applet
|
||||
} else if (args[argIndex].indexOf(EXT_EXACT_LOCATION) == 0) {
|
||||
external = true;
|
||||
String locationStr =
|
||||
args[argIndex].substring(EXT_LOCATION.length());
|
||||
args[argIndex].substring(EXT_EXACT_LOCATION.length());
|
||||
location = toInt(split(locationStr, ','));
|
||||
exactLocation = true;
|
||||
|
||||
@@ -2871,13 +2875,13 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
Frame frame = new Frame();
|
||||
frame.pack(); // maybe get insets
|
||||
frame.pack(); // get insets. get more.
|
||||
Class c = Class.forName(name);
|
||||
PApplet applet = (PApplet) c.newInstance();
|
||||
|
||||
// these are needed before init/start
|
||||
applet.folder = folder;
|
||||
int argc = args.length - argIndex;
|
||||
int argc = args.length - (argIndex+1);
|
||||
applet.args = new String[argc];
|
||||
System.arraycopy(args, argc, applet.args, 0, argc);
|
||||
|
||||
@@ -2887,21 +2891,14 @@ public class PApplet extends Applet
|
||||
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
|
||||
if (external) {
|
||||
/*
|
||||
String argh = args[0].substring(EXTERNAL_FLAG.length());
|
||||
boolean exact = argh.charAt(0) == EXTERNAL_EXACT_LOCATION;
|
||||
if (exact) argh = argh.substring(1);
|
||||
int location[] = toInt(split(argh, ','));
|
||||
int locationX = location[0] - 20;
|
||||
int locationY = location[1];
|
||||
*/
|
||||
|
||||
Insets insets = frame.getInsets(); // pack() first?
|
||||
Insets insets = frame.getInsets(); // does pack() first above
|
||||
//System.out.println(insets);
|
||||
|
||||
int locationX = location[0] - 20;
|
||||
int locationY = location[1];
|
||||
//System.out.println("x,y " + locationX + " " + locationY);
|
||||
|
||||
//frame.setTitle(str(setupComplete));
|
||||
int minW = 120;
|
||||
int minH = 120;
|
||||
int windowW =
|
||||
@@ -2909,10 +2906,11 @@ public class PApplet extends Applet
|
||||
int windowH =
|
||||
Math.max(applet.height, minH) + insets.top + insets.bottom;
|
||||
frame.setSize(windowW, windowH);
|
||||
//frame.setTitle(windowW + " " + windowH);
|
||||
|
||||
if (exactLocation) {
|
||||
frame.setLocation(location[0], location[1]);
|
||||
|
||||
|
||||
} else {
|
||||
if (locationX - windowW > 10) {
|
||||
// if it fits to the left of the window
|
||||
|
||||
9
todo.txt
9
todo.txt
@@ -8,10 +8,11 @@ X was this the big one? a big one?
|
||||
X threading issues resolved
|
||||
X fixed bug with errors not coming through
|
||||
X fixed bug with errors not being recognized amonst exceptions
|
||||
|
||||
_ moving p5 prefs on mac into documents? or inside sketchbook?
|
||||
_ Documents -> Processing -> preferences.txt
|
||||
_ do the same for windows, with sketchbook as a subfolder
|
||||
X fixed bug with draw mode apps, they now run inside setup
|
||||
X width/height wasn't getting set during setup(), so window bad
|
||||
X moving p5 prefs on mac into documents? or inside sketchbook?
|
||||
X Documents -> Processing -> preferences.txt
|
||||
X do the same for windows, with sketchbook as a subfolder
|
||||
|
||||
_ don't exit p5 if platform is unknown
|
||||
|
||||
|
||||
Reference in New Issue
Block a user