markluffel / Corkbird (http://corkbird.org/)
Corkbird is a library for Processing that saves snapshots of a Processing sketch in JSON format and can reload these JSON snapshots in a running sketch. The library integrates with the corkbird.org website so that users can share and continue to interact with the snapshots.
Clone this repository (size: 491.7 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/markluffel/corkbird/
| commit 33: | 10b3470c861c |
| parent 32: | b7096e95eac6 |
| branch: | default |
fixing bugs with domain, and saving looping
11 months ago
Changed (Δ364 bytes):
raw changeset »
src/corkbird/Corkbird.java (9 lines added, 4 lines removed)
src/corkbird/CorkbirdUI.java (4 lines added, 1 lines removed)
Up to file-list src/corkbird/Corkbird.java:
| … | … | @@ -39,8 +39,9 @@ public class Corkbird { |
39 |
39 |
this.parent = sketch; |
40 |
40 |
this.metadata = new DoodleMetadata(); // TODO: load from the page, or locally from... directory path? |
41 |
41 |
if(sketch.online || true) { |
42 |
storage = new RemoteStorage("localhost:8080"); |
|
43 |
//storage = new RemoteStorage("corkbird.org"); |
|
42 |
//storage = new RemoteStorage("localhost:8080"); |
|
43 |
// TODO: pull this from params or something instead |
|
44 |
storage = new RemoteStorage("corkbird.org"); |
|
44 |
45 |
} else { |
45 |
46 |
storage = new LocalStorage(sketch); |
46 |
47 |
} |
| … | … | @@ -74,12 +75,16 @@ public class Corkbird { |
74 |
75 |
*/ |
75 |
76 |
public void draw() { |
76 |
77 |
if(shouldSaveNow) { |
78 |
// set false first so that if an error occurs, we don't loop indefinitely |
|
79 |
shouldSaveNow = false; |
|
77 |
80 |
_save(); |
78 |
shouldSaveNow = false; |
|
79 |
81 |
} |
80 |
82 |
if(shouldLoadIdNow != null) { |
81 |
|
|
83 |
String loadId = shouldLoadIdNow; |
|
84 |
// null out first so that errors don't loop indefinitely |
|
82 |
85 |
shouldLoadIdNow = null; |
86 |
_load(loadId); |
|
87 |
parent.requestFocus(); |
|
83 |
88 |
} |
84 |
89 |
} |
85 |
90 |
Up to file-list src/corkbird/CorkbirdUI.java:
| … | … | @@ -51,7 +51,10 @@ public class CorkbirdUI { |
51 |
51 |
} |
52 |
52 |
PApplet s = sketch; |
53 |
53 |
|
54 |
|
|
54 |
boolean hovering = s.mouseX < UI_WIDTH && s.mouseY > uiTop |
|
55 |
&& s.mouseX >= 0 && s.mouseY <= sketchHeight; |
|
56 |
||
57 |
if(hovering) { |
|
55 |
58 |
s.cursor(PConstants.HAND); |
56 |
59 |
if(s.mousePressed) { |
57 |
60 |
s.image(savePressed, 0, uiTop); |
