Mercurial > MadButterfly
annotate inkscape/firefox/content/inkscape.js @ 1265:ca301f6abef7
Support undo for insert key frame/rm keyframe. We will refresh all layers and scenes since it is not feasible to collect these changes and update the layers and scenes. We may scan two level only in the future to improve the performance.
author | wycc |
---|---|
date | Wed, 12 Jan 2011 15:01:14 +0800 |
parents | ebf83a50e1e1 |
children |
rev | line source |
---|---|
288 | 1 var isInProgress=0; |
2 | |
3 var MAX_DUMP_DEPTH = 10; | |
4 var inkscape; | |
5 | |
362 | 6 |
7 function endsWith(str, s){ | |
8 var reg = new RegExp (s + "$"); | |
9 return reg.test(str); | |
10 } | |
288 | 11 |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
12 function dumpXML(xml) |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
13 { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
14 return (new XMLSerializer()).serializeToString(xml); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
15 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
16 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
17 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
18 function showInWindow(content) |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
19 { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
20 $('#debug').append("<pre>"+content+"</pre>"); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
21 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
22 |
288 | 23 function dumpObj(obj, name, indent, depth) { |
24 if (depth > MAX_DUMP_DEPTH) { | |
25 return indent + name + ": <Maximum Depth Reached>\n"; | |
26 } | |
27 if (typeof obj == "object") { | |
28 var child = null; | |
29 var output = indent + name + "\n"; | |
30 indent += "\t"; | |
31 for (var item in obj) | |
32 { | |
33 try { | |
34 child = obj[item]; | |
35 } catch (e) { | |
36 child = "<Unable to Evaluate>"; | |
37 } | |
38 if (typeof child == "object") { | |
39 output += dumpObj(child, item, indent, depth + 1); | |
40 } else { | |
41 output += indent + item + ": " + child + "\n"; | |
42 } | |
43 } | |
44 return output; | |
45 } else { | |
46 return obj; | |
47 } | |
48 } | |
49 function dumpObjItem(obj, name, indent, depth) { | |
50 if (depth > MAX_DUMP_DEPTH) { | |
51 return indent + name + ": <Maximum Depth Reached>\n"; | |
52 } | |
53 if (typeof obj == "object") { | |
54 var child = null; | |
55 var output = indent + name + "\n"; | |
56 indent += "\t"; | |
57 for (var item in obj) | |
58 { | |
59 try { | |
60 child = obj[item]; | |
61 } catch (e) { | |
62 child = "<Unable to Evaluate>"; | |
63 } | |
64 if (typeof child == "object") { | |
65 output += dumpObjItem(child, item, indent, depth + 1); | |
66 } else { | |
67 output += indent + item + ":\n"; | |
68 } | |
69 } | |
70 return output; | |
71 } else { | |
72 return obj; | |
73 } | |
74 } | |
361
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
75 |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
76 /** |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
77 * TextEditor class |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
78 * |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
79 */ |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
80 |
362 | 81 function TextEditor(file) |
361
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
82 { |
362 | 83 var editor = document.getElementById('inkscape'); |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
84 editor.innerHTML = "<embed src="+file+" width=900 height=700 />"; |
361
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
85 this.isInProgress = 0; |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
86 } |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
87 |
288 | 88 /** |
89 * Inkscape class | |
90 * | |
91 */ | |
92 function Inkscape(file) | |
93 { | |
94 var ink = document.getElementById('inkscape'); | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
95 ink.innerHTML = "<embed src="+file+" width=900 height=700 />"; |
288 | 96 this.isInProgress = 0; |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
97 this.callback = null; |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
98 this.animation = new MadSwatter(this); |
288 | 99 |
392 | 100 setTimeout("inkscape.fetchDocument()",3000); |
288 | 101 } |
102 | |
103 Inkscape.prototype.gotoScene = function (n) | |
104 { | |
105 nextScene = n; | |
106 var soapBody = new SOAPObject("START"); | |
107 var sr = new SOAPRequest("START", soapBody); | |
108 SOAPClient.Proxy = "http://localhost:19192/"; | |
109 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene1(resp);},this); | |
110 this.isInProgress++; | |
111 } | |
112 Inkscape.prototype.gotoScene1 = function (resp,n) | |
113 { | |
114 var soapBody = new SOAPObject("SCENE"); | |
115 var v1 = new SOAPObject("v1"); | |
116 v1.val(nextScene); | |
117 soapBody.appendChild(v1); | |
118 var sr = new SOAPRequest("SCENE", soapBody); | |
119 SOAPClient.Proxy = "http://localhost:19192/"; | |
120 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene2(resp);},this); | |
121 } | |
122 Inkscape.prototype.gotoScene2 = function (resp) | |
123 { | |
124 var soapBody = new SOAPObject("PUBLISH"); | |
125 var sr = new SOAPRequest("PUBLISH", soapBody); | |
126 SOAPClient.Proxy = "http://localhost:19192/"; | |
127 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene3(resp);},this); | |
128 } | |
129 | |
130 Inkscape.prototype.gotoScene3 = function (resp) | |
131 { | |
132 this.isInProgress--; | |
133 } | |
134 Inkscape.prototype.publishDocument= function(resp) | |
135 { | |
136 mbsvg = new MBSVGString(resp.Body[0].GETDOCResponse[0].Result[0].Text); | |
137 mbsvg.renderUI(); | |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
138 this.mbsvg = mbsvg; |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
139 if (this.callback) |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
140 this.callback(mbsvg); |
288 | 141 |
142 var soapBody = new SOAPObject("PUBLISH"); | |
143 var sr = new SOAPRequest("PUBLISH", soapBody); | |
144 SOAPClient.Proxy = "http://localhost:19192/"; | |
145 SOAPClient.SendRequest(sr, function(resp,arg) {arg.operationDone(resp);},this); | |
146 } | |
147 | |
148 Inkscape.prototype.refreshDocument = function(resp) | |
149 { | |
150 var soapBody = new SOAPObject("GETDOC"); | |
151 var sr = new SOAPRequest("GETDOC", soapBody); | |
152 SOAPClient.Proxy = "http://localhost:19192/"; | |
153 SOAPClient.SendRequest(sr, function(resp,arg) { arg.publishDocument(resp);},this); | |
154 } | |
155 | |
156 Inkscape.prototype.operationDone = function (res) | |
157 { | |
158 this.isInProgress--; | |
159 } | |
160 Inkscape.prototype.insertKey= function(n) | |
161 { | |
162 nextScene = n; | |
163 var soapBody = new SOAPObject("START"); | |
164 var sr = new SOAPRequest("START", soapBody); | |
165 SOAPClient.Proxy = "http://localhost:19192/"; | |
166 SOAPClient.SendRequest(sr, function (resp,arg) {arg.insertKey1(resp);},this); | |
167 this.isInProgress++; | |
168 } | |
169 Inkscape.prototype.insertKey1 = function(resp) | |
170 { | |
171 var soapBody = new SOAPObject("INSERTKEY"); | |
172 var v1 = new SOAPObject("v1"); | |
173 v1.attr('type','string'); | |
174 v1.val(currentLayer); | |
175 soapBody.appendChild(v1); | |
176 var v2 = new SOAPObject("v2"); | |
177 v2.val(nextScene); | |
178 soapBody.appendChild(v2); | |
179 var sr = new SOAPRequest("INSERTKEY", soapBody); | |
180 SOAPClient.Proxy = "http://localhost:19192/"; | |
181 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this); | |
182 } | |
183 | |
184 Inkscape.prototype.extendScene=function() | |
185 { | |
186 var soapBody = new SOAPObject("START"); | |
187 var sr = new SOAPRequest("START", soapBody); | |
188 SOAPClient.Proxy = "http://localhost:19192/"; | |
189 SOAPClient.SendRequest(sr, function (resp,arg) {arg.extendScene1(resp);},this); | |
190 this.isInProgress++; | |
191 } | |
192 | |
193 | |
194 Inkscape.prototype.extendScene1 = function(resp) | |
195 { | |
196 var soapBody = new SOAPObject("EXTENDSCENE"); | |
197 var v1 = new SOAPObject("v1"); | |
198 v1.attr('type','string'); | |
199 v1.val(currentLayer); | |
200 soapBody.appendChild(v1); | |
201 var v2 = new SOAPObject("v2"); | |
202 v2.val(currentScene); | |
203 soapBody.appendChild(v2); | |
204 var sr = new SOAPRequest("EXTENDSCENE", soapBody); | |
205 SOAPClient.Proxy = "http://localhost:19192/"; | |
206 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this); | |
207 } | |
208 | |
209 | |
210 Inkscape.prototype.deleteScene=function() | |
211 { | |
212 var soapBody = new SOAPObject("START"); | |
213 var sr = new SOAPRequest("START", soapBody); | |
214 SOAPClient.Proxy = "http://localhost:19192/"; | |
215 SOAPClient.SendRequest(sr, function (resp,arg) {arg.deleteScene1(resp);},this); | |
216 this.isInProgress++; | |
217 } | |
218 | |
219 Inkscape.prototype.deleteScene1=function(resp) | |
220 { | |
221 var soapBody = new SOAPObject("DELETESCENE"); | |
222 var v1 = new SOAPObject("v1"); | |
223 v1.attr('type','string'); | |
224 v1.val(currentLayer); | |
225 soapBody.appendChild(v1); | |
226 var v2 = new SOAPObject("v2"); | |
227 v2.val(currentScene); | |
228 soapBody.appendChild(v2); | |
229 var sr = new SOAPRequest("EXTENDSCENE", soapBody); | |
230 SOAPClient.Proxy = "http://localhost:19192/"; | |
231 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this); | |
232 } | |
233 | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
234 Inkscape.prototype.fetchDocument = function(callback) |
288 | 235 { |
236 var soapBody = new SOAPObject("START"); | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
237 this.callback = callback |
288 | 238 var sr = new SOAPRequest("START", soapBody); |
239 SOAPClient.Proxy = "http://localhost:19192/"; | |
240 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this); | |
241 this.isInProgress++; | |
242 } | |
243 | |
381 | 244 Inkscape.prototype.changeSymbolName_cb = function(callback) |
245 { | |
246 var soapBody = new SOAPObject("CHANGESYMBOL"); | |
247 var v1 = new SOAPObject("v1"); | |
248 v1.attr('type','string'); | |
249 v1.val(this.v1); | |
250 soapBody.appendChild(v1); | |
251 var v2 = new SOAPObject("v2"); | |
252 v2.val(this.v2); | |
253 soapBody.appendChild(v2); | |
254 var sr = new SOAPRequest("CHANGESYMBOL", soapBody); | |
255 SOAPClient.Proxy = "http://localhost:19192/"; | |
256 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this); | |
257 this.inProgress--; | |
258 } | |
259 | |
260 Inkscape.prototype.changeSymbolName = function(id,newname,callback) | |
261 { | |
262 var soapBody = new SOAPObject("START"); | |
263 this.callback = callback | |
264 var sr = new SOAPRequest("START", soapBody); | |
265 SOAPClient.Proxy = "http://localhost:19192/"; | |
266 this.v1 = id; | |
267 this.v2 = newname; | |
268 SOAPClient.SendRequest(sr,function(resp,arg) {arg.changeSymbolName_cb(resp);},this); | |
269 this.isInProgress++; | |
270 } | |
271 | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
272 /* |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
273 * This module is used to define a symbol for the MadButterfly. This function will search for symbol which is defined in the current select object. We will list all SVG elements |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
274 * in the left side, multiple variables can be defined at one time. When any element is selected, the defined symbol will be listed in the right side. |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
275 * |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
276 */ |
288 | 277 |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
278 Inkscape.prototype.MakeSymbol=function() |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
279 { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
280 function callback(mbsvg) { |
381 | 281 inkscape.loadSymbolScreen(mbsvg); |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
282 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
283 inkscape.fetchDocument(callback); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
284 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
285 |
381 | 286 |
287 Inkscape.prototype.onChangeSymbolName=function() | |
288 { | |
289 inkscape.changeSymbolName(inkscape.current_symbol, $('#newsymbolname').val()); | |
290 symboldialog.dialog('close') | |
291 } | |
292 | |
293 Inkscape.prototype.refreshSymbolPanel=function(node) | |
294 { | |
384 | 295 var reg = new RegExp('(.*)\\((.*)\\)'); |
296 var m = reg.exec(node.textContent); | |
297 var val = m[2]; | |
381 | 298 inkscape.current_symbol = node.textContent; |
384 | 299 $('#newsymbolname').val(val); |
381 | 300 } |
301 | |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
302 Inkscape.prototype.editAnimation=function () { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
303 inkscape.fetchDocument(inkscape.editAnimationCallback); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
304 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
305 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
306 Inkscape.prototype.editAnimationCallback=function(mbsvg) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
307 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
308 inkscape.animation.edit(mbsvg); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
309 return; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
310 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
311 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
312 var sodi = mbsvg.getElementsByTag('sodipodi:namedview')[0]; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
313 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
314 var layer=sodi.getAttribute('inkscape:current-layer'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
315 var animation = mbsvg.getElementsByTag('animationlist')[0]; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
316 var alist = animation.getElementsByTag('animation'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
317 var len = alist.length; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
318 var dialog = $('animation'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
319 dialog.dialog('open'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
320 var html = new Array(); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
321 html.append('<ul>'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
322 for(i=0;i<alist.len;i++) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
323 html.append('<li><a href="#" onClick="">'+alist[i].getAttribute('name')+"</a></li>"); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
324 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
325 html.append('</ul>'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
326 $('animation_list').html(html.join("\n")); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
327 dialog.show(); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
328 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
329 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
330 |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
331 Inkscape.prototype.loadSymbolScreen=function (mbsvg) { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
332 // Swap the left side to be the SVG element tree. |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
333 var i,l; |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
334 |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
335 symboldialog.dialog('open'); |
384 | 336 this.mbsvg = mbsvg; |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
337 l = mbsvg.selected_objects.length; |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
338 var jsonobj = [] |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
339 for(i=0;i<l;i++) { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
340 // Add symbol into the tree |
384 | 341 var name = mbsvg.findSymbolName(mbsvg.selected_objects[i]); |
342 var title=mbsvg.selected_objects[i]+"("+name+")"; | |
343 var obj = { attributes: {id: 'sym'+i}, data : title}; | |
344 if (i == 0) { | |
345 this.current_symbol = mbsvg.selected_objects[i]; | |
346 $('#newsymbolname').val(name); | |
347 } | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
348 jsonobj.push(obj); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
349 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
350 this.symboltree = $.tree_create(); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
351 this.symboltree.init($("#symbollist"), { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
352 data: { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
353 type: "json", |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
354 json : jsonobj |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
355 }, |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
356 callback : { |
384 | 357 ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE);} |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
358 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
359 |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
360 }); |
381 | 361 var s = $('#changename'); |
362 s.click(this.onChangeSymbolName); | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
363 // Swap the right side to be the symbol editor screen. |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
364 symboldialog.show(); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
365 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
366 |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
367 jQuery(document).ready(function() { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
368 symboldialog = jQuery('#symboldialog'); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
369 symboldialog.dialog({width:500, |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
370 modal: true, |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
371 autoOpen:false, |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
372 title:'Please select a file'}); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
373 symboldialog.hide(); |
381 | 374 symboldialog.append("<div id='symbollist'/>"); |
384 | 375 symboldialog.append("<div id='symbol'><input type='text' id='newsymbolname'> <input type='submit' value='change' id='changename'></div> "); |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
376 }); |
288 | 377 |
378 function MBSVG(file) | |
379 { | |
380 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null); | |
381 xmlDoc.async=false; | |
382 xmlDoc.load(file); | |
383 MBSVG_loadFromDoc(this,xmlDoc); | |
384 | |
385 } | |
386 function MBSVGString(xml) | |
387 { | |
388 var xmlParser = new DOMParser(); | |
389 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml'); | |
390 MBSVG_loadFromDoc(this,xmlDoc); | |
391 } | |
392 | |
393 | |
394 | |
395 function MBSVG_loadFromDoc(self,xmlDoc) | |
396 { | |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
397 var top = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scenes")[0]; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
398 self.current = top.getAttribute("current"); |
288 | 399 var scenesNode = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scene"); |
400 if (scenesNode == null) { | |
401 alert('This is not a valid scene file'); | |
402 } | |
403 var len = scenesNode.length; | |
404 var i,j; | |
405 var max = 0; | |
406 var scenes = new Array(); | |
407 | |
408 // Get the length of scenes | |
409 for(i=0;i<len;i++) { | |
410 var s = scenesNode[i]; | |
411 var start = s.getAttribute("start"); | |
412 var end = s.getAttribute("end"); | |
413 var ref = s.getAttribute("ref"); | |
414 var ss = new Object(); | |
415 | |
416 if (end == null) end = start | |
417 if (max <end) max = end; | |
418 ss.node = s; | |
419 ss.start = start; | |
420 ss.end = end; | |
421 ss.ref = ref; | |
422 ss.layer = null; | |
423 scenes.push(ss); | |
424 } | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
425 if (max < 20) max = 30; |
288 | 426 // Collect all layers |
427 var nodes = xmlDoc.getElementsByTagNameNS("http://www.w3.org/2000/svg","svg")[0].childNodes; | |
428 var layers = new Array(); | |
429 len = nodes.length; | |
430 for(i=0;i<len;i++) { | |
431 if (nodes[i].localName == 'g') { | |
432 var subnodes = nodes[i].childNodes; | |
433 for(j=0;j<subnodes.length;j++) { | |
434 if (subnodes[j].localName == 'g') { | |
435 for(var k=0;k<scenes.length;k++) { | |
436 if (scenes[k].ref == subnodes[j].getAttribute('id')) { | |
437 scenes[k].layer = nodes[i].getAttribute('id'); | |
438 break; | |
439 } | |
440 } | |
441 } | |
442 } | |
443 layers.push(nodes[i]); | |
444 } | |
445 } | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
446 var select = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","select"); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
447 len = select.length; |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
448 selectobjs = []; |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
449 for(i=0;i<len;i++) { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
450 selectobjs.push(select[i].getAttribute('ref')); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
451 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
452 self.selected_objects = selectobjs; |
288 | 453 self.layers = layers; |
454 self.scenes = scenes; | |
455 self.maxframe = max; | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
456 self.doc = xmlDoc; |
288 | 457 } |
458 | |
459 MBSVGString.prototype=MBSVG.prototype; | |
460 MBSVG.prototype.renderUI=function() | |
461 { | |
462 var layers = this.layers; | |
463 var scenes = this.scenes; | |
464 var max = this.maxframe; | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
465 var cmd = "<table border=0>\n"; |
288 | 466 cmd = cmd + "<tr><td></td>"; |
467 for(var j=1;j<=max;j++) | |
468 cmd = cmd + "<td>"+j+"</td>"; | |
469 | |
470 for(var i=layers.length-1;i>=0;i--) { | |
471 var l = layers[i]; | |
472 var id = l.getAttribute('id'); | |
473 var label = l.getAttribute('inkscape:label'); | |
474 cmd = cmd + "<tr><td>"+label+"</td>"; | |
475 for(j=0;j<max;j++) { | |
476 var empty = 1; | |
477 var n = j +1; | |
478 var id_str = id+"#"+n | |
479 for(var k=0;k<scenes.length;k++) { | |
480 if (id != scenes[k].layer) continue; | |
481 if (n == scenes[k].start) { | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
482 cmd = cmd + "<td><img class='normal' width='16' src=start.png id='"+id_str+"' onClick='selectCell(this)' /></td>"; |
288 | 483 empty = 0; |
484 break; | |
485 } else if ((n>scenes[k].start)&&(n <= scenes[k].end)) { | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
486 cmd = cmd + "<td><img class='normal' width='16' src=fill.png id='"+id_str+"' onClick='selectCell(this)' /></td>"; |
288 | 487 empty = 0; |
488 break; | |
489 } | |
490 } | |
491 if (empty) { | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
492 cmd = cmd + "<td><img class='normal' width='16' src=empty.png id='"+id_str+"'onClick='selectCell(this)' /></td>"; |
288 | 493 } |
494 | |
495 } | |
496 cmd = cmd + "</tr>\n"; | |
497 } | |
498 cmd = cmd + "</table>\n"; | |
499 var frame = document.getElementById('frame'); | |
500 frame.innerHTML=cmd; | |
501 } | |
502 | |
503 | |
384 | 504 MBSVG.prototype.findSymbolName=function(id) |
505 { | |
506 var obj = this.doc.getElementById(id); | |
507 var name = obj.getAttribute('mbname'); | |
508 return name; | |
509 | |
510 } | |
288 | 511 |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
512 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
513 /** |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
514 * Return a new XML document that all objects which is not in the current scene are deleted. |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
515 * |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
516 * This function will traverse all scenes. For each scene which is not in the current scene, we will delete the reference group. |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
517 */ |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
518 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
519 function deepcopy(obj) |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
520 { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
521 var seenObjects = []; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
522 var mappingArray = []; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
523 var f = function(simpleObject) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
524 var indexOf = seenObjects.indexOf(simpleObject); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
525 if (indexOf == -1) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
526 switch (Ext.type(simpleObject)) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
527 case 'object': |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
528 seenObjects.push(simpleObject); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
529 var newObject = {}; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
530 mappingArray.push(newObject); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
531 for (var p in simpleObject) |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
532 newObject[p] = f(simpleObject[p]); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
533 newObject.constructor = simpleObject.constructor; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
534 return newObject; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
535 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
536 case 'array': |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
537 seenObjects.push(simpleObject); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
538 var newArray = []; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
539 mappingArray.push(newArray); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
540 for(var i=0,len=simpleObject.length; i<len; i++) |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
541 newArray.push(f(simpleObject[i])); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
542 return newArray; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
543 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
544 default: |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
545 return simpleObject; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
546 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
547 } else { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
548 return mappingArray[indexOf]; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
549 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
550 }; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
551 return f(obj); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
552 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
553 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
554 MBSVG.prototype.generateCurrentSVG=function() |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
555 { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
556 var i; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
557 var scenes = this.scenes; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
558 var len = scenes.length; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
559 var newcopy = $(this.doc).clone(); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
560 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
561 for(i=0;i<len;i++) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
562 if (scenes[i].start > this.current || scenes[i].end < this.current) { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
563 var obj = newcopy.find('#'+scenes[i].ref); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
564 obj.remove(); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
565 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
566 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
567 return newcopy; |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
568 } |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
569 |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
570 |
288 | 571 /** |
572 * UI for madbuilder.html to build the scene editor | |
573 */ | |
574 | |
575 function selectCell(obj) | |
576 { | |
577 var id = obj.getAttribute('id'); | |
578 var layer,n; | |
579 var f = id.split('#'); | |
580 layer=f[0]; | |
581 n = f[1]; | |
582 var img = obj.getAttribute('src'); | |
583 var f = img.split('-'); | |
584 | |
585 if (f[0] == 'active') | |
586 return; | |
587 else { | |
588 obj.setAttribute('src', 'active-'+img); | |
589 } | |
590 | |
591 if (last_select != null) { | |
592 f = last_select.getAttribute('src').split('-'); | |
593 last_select.setAttribute('src', f[1]); | |
594 } | |
595 last_select = obj; | |
596 currentScene = n; | |
597 currentLayer = layer; | |
598 } | |
599 | |
600 | |
601 function onButtonClick(obj) | |
602 { | |
603 var id = obj.getAttribute('id'); | |
604 if (id == 'Jump') { | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
605 if (inkscape.isInProgress != 0) return; |
288 | 606 if (currentScene != 0) |
607 inkscape.gotoScene(currentScene); | |
608 } else if (id == 'InsertKey') { | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
609 if (inkscape.isInProgress != 0) return; |
288 | 610 inkscape.insertKey(currentScene); |
611 } else if (id == 'ExtendScene') { | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
612 if (inkscape.isInProgress != 0) return; |
288 | 613 inkscape.extendScene(currentScene); |
614 } else if (id == 'DeleteScene') { | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
615 if (inkscape.isInProgress != 0) return; |
288 | 616 inkscape.deleteScene(currentScene); |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
617 } else if (id == 'MakeSymbol') { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
618 if (inkscape.isInProgress != 0) return; |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
619 inkscape.MakeSymbol(); |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
620 } else if (id == 'Save') { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
621 project_save(); |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
622 } else if (id == 'Test') { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
623 if (project_compile()) { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
624 project_run(); |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
625 } else { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
626 } |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
627 } else if (id == 'Open') { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
628 filedialog = jQuery('#filedialog'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
629 filedialog.dialog({width:500, |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
630 modal: true, |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
631 autoOpen:false, |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
632 title:'Please select a file'}); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
633 filedialog.show(); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
634 filedialog.html('Please select the project file<br>'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
635 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
636 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">'); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
637 filedialog.dialog("open"); |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
638 } else if (id == 'EditAnimation') { |
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
639 inkscape.editAnimation(); |
288 | 640 } else { |
641 alert(id+' has not been implemented yet'); | |
642 } | |
643 } | |
644 | |
645 function gotoScene_cb(resObj) | |
646 { | |
647 | |
648 } | |
649 var nextScene; | |
650 var currentScene = 0; | |
651 var currentLayer = ''; | |
652 | |
357 | 653 |
654 function dump(n) | |
655 { | |
656 cmd = ""; | |
657 for(k in n) { | |
658 cmd = cmd + k+"="+n[k]+"\n"; | |
659 } | |
660 alert(cmd); | |
661 } | |
288 | 662 |
663 | |
358 | 664 |
357 | 665 |
666 | |
667 | |
358 | 668 function loadInkscapeFile() |
357 | 669 { |
670 ele = $('#mbsvg'); | |
671 file = ele.attr('value'); | |
672 inkscape = new Inkscape("file://"+file); | |
673 | |
352 | 674 file1_animation = [ |
675 { | |
676 attributes: {id:"an1-1"}, | |
677 data: "animation1" | |
678 }, | |
679 { | |
680 attributes: {id:"an1-2"}, | |
681 data: "animation2" | |
682 } | |
683 ]; | |
684 file1 = { | |
685 attributes:{id:"file1"}, | |
686 data: "scene1.mbsvg", | |
687 children: file1_animation | |
688 }; | |
689 file2 = { | |
690 attributes:{id:"file2"}, | |
691 data: "scene2.mbsvg", | |
692 }; | |
693 file3 = { | |
694 attributes:{id:"file3"}, | |
695 data: "scene3.mbsvg", | |
696 }; | |
697 | |
698 scenes = [ file1,file2,file3]; | |
699 src1 = {attributes:{id:"src1"},data:"src1.c"}; | |
700 src2 = {attributes:{id:"src1"},data:"src2.c"}; | |
701 src3 = {attributes:{id:"src1"},data:"src3.c"}; | |
702 | |
703 sources = [src1,src2,src3]; | |
704 | |
358 | 705 } |
706 | |
376
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
707 function project_compile() |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
708 { |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
709 } |
7d244a85dd68
Change the screen layout to make it more like an usual IDE.
wycc
parents:
371
diff
changeset
|
710 |
358 | 711 |
362 | 712 function project_showFile(node) |
713 { | |
714 var file = node.textContent; | |
715 if (endsWith(file,"mbsvg")) { | |
716 project_loadScene(node); | |
717 } else { | |
718 project_loadEditor(node); | |
719 } | |
720 | |
721 } | |
359 | 722 function project_loadScene(node) |
723 { | |
724 var file = node.textContent; | |
371 | 725 if (file.substr(0,1) == '/') |
726 inkscape = new Inkscape("file://"+file); | |
727 else | |
728 inkscape = new Inkscape("file://"+project_dir+'/'+file); | |
361
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
729 } |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
730 |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
731 |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
732 function project_loadEditor(node) |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
733 { |
8c4456190d9a
Add text editor support to edit C source file inside the MadBuilder
wycc
parents:
359
diff
changeset
|
734 var file = node.textContent; |
371 | 735 if (file.substr(0,1) == '/') |
736 editor = new TextEditor("file://"+file); | |
737 else | |
738 editor = new TextEditor("file://"+project_dir+'/'+file); | |
359 | 739 } |
740 | |
358 | 741 function project_parse(xml) |
742 { | |
743 | |
744 var xmlParser = new DOMParser(); | |
745 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml'); | |
746 var scenesNode = xmlDoc.getElementsByTagName("scene"); | |
747 if (scenesNode == null) { | |
748 alert('This is not a valid scene file'); | |
749 } | |
750 var len = scenesNode.length; | |
751 var i,j; | |
752 var max = 0; | |
753 var scenes = new Array(); | |
754 | |
755 // Get the length of scenes | |
756 for(i=0;i<len;i++) { | |
757 var n = scenesNode[i]; | |
758 var s = new Object(); | |
759 s.attributes = new Object(); | |
760 s.attributes.id = "scene"+i; | |
761 s.state = "open"; | |
762 s.data = n.getAttribute("src"); | |
763 scenes.push(s); | |
764 } | |
765 | |
766 var nodes = xmlDoc.getElementsByTagName("source"); | |
767 var len = nodes.length; | |
768 var i,j; | |
769 var max = 0; | |
770 var sources = []; | |
771 | |
772 // Get the length of scenes | |
773 for(i=0;i<len;i++) { | |
774 var n = nodes[i]; | |
775 var s = new Object(); | |
776 s.attributes = new Object(); | |
777 s.attributes.id = "sources"+i; | |
778 s.state = "open"; | |
779 s.data = n.getAttribute("src"); | |
780 sources.push(s); | |
781 } | |
782 | |
783 var tree = $.tree_create(); | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
784 project_tree = tree; |
358 | 785 tree.init($("#filelist"), { |
786 data: { | |
787 type: "json", | |
788 json : [ | |
789 { | |
790 attributes: {id: "prj"}, | |
791 state: "open", | |
792 data: "Project", | |
793 children: [ | |
794 { attributes:{id:"scenes"}, data:"scene", children: scenes}, | |
795 { attributes:{id:"sources"},data:"sources",children: sources} | |
796 ] | |
797 } | |
798 ], | |
799 }, | |
359 | 800 callback : { |
362 | 801 ondblclk : function(NODE,TREE_OBJ) { project_showFile(NODE); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);} |
359 | 802 }, |
358 | 803 ui : { |
357 | 804 context : [ |
805 { | |
806 id: "Open", | |
807 label: "Open", | |
808 icon: "open.png", | |
364
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
809 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return true;}, |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
810 action: function(NODE,TREE_OBJ) { onTree_openFile(NODE,TREE_OBJ);} |
357 | 811 }, |
812 { | |
813 id: "New", | |
814 label: "New", | |
815 icon: "create.png", | |
816 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return NODE[0].id == "prj";}, | |
817 action: function(NODE,TREE_OBJ) { alert("open is not support yet");} | |
818 }, | |
819 { | |
820 id: "Rename", | |
821 label: "Rename", | |
822 icon: "rename.png", | |
823 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return NODE[0].id == "prj";}, | |
824 action: function(NODE,TREE_OBJ) { alert("open is not support yet");} | |
358 | 825 } |
357 | 826 ] |
358 | 827 } |
828 | |
829 }); | |
830 } | |
357 | 831 |
364
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
832 function fileDialog_cb() |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
833 { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
834 var file = $('#filedialogsrc').attr('value'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
835 filedialog.dialog('close'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
836 filedialog_cb(file,filedialog_arg); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
837 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
838 |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
839 function openFileDialog(callback,arg) |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
840 { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
841 filedialog_cb = callback; |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
842 filedialog_arg = arg; |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
843 filedialog.html('Please select the scene file<br>'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
844 filedialog.append('<input type=file value="Select the scene file" id="filedialogsrc">'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
845 filedialog.append('<input type=button value="Load" onclick="fileDialog_cb()">'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
846 filedialog.show(); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
847 filedialog.dialog('open'); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
848 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
849 |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
850 |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
851 function project_addScene(file,treeobj) |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
852 { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
853 if (file == '') { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
854 return; |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
855 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
856 treeobj.create(false,treeobj.selected,file); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
857 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
858 |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
859 function onTree_addSceneFile(node,treeobj) |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
860 { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
861 openFileDialog(project_addScene,treeobj); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
862 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
863 |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
864 function project_addSource(file,treeobj) |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
865 { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
866 treeobj.create(false,treeobj.selected,file); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
867 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
868 |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
869 function onTree_addSourceFile(node,treeobj) |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
870 { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
871 openFileDialog(project_addSource,treeobj); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
872 } |
364
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
873 |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
874 function onTree_openFile(node,treeobj) |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
875 { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
876 if (node[0].id == "scenes") { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
877 onTree_addSceneFile(node,treeobj); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
878 } else if (node[0].id == "sources") { |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
879 onTree_addSourceFile(node,treeobj); |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
880 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
881 } |
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
882 |
367 | 883 function system_open_read(fname) { |
884 try { | |
885 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); | |
886 } catch (e) { | |
887 alert("Permission to read file was denied."); | |
888 } | |
889 var file = Components.classes["@mozilla.org/file/local;1"] | |
890 .createInstance(Components.interfaces.nsILocalFile); | |
891 try { | |
892 file.initWithPath( fname ); | |
893 if ( file.exists() == false ) { | |
894 alert("File does not exist"); | |
895 } | |
896 var is = Components.classes["@mozilla.org/network/file-input-stream;1"] | |
897 .createInstance( Components.interfaces.nsIFileInputStream ); | |
898 is.init( file,0x01, 00004, null); | |
899 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"] | |
900 .createInstance( Components.interfaces.nsIScriptableInputStream ); | |
901 sis.init( is ); | |
902 } catch(e) { | |
903 alert(fname+" does not exist"); | |
904 } | |
905 return sis; | |
906 } | |
364
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
907 |
358 | 908 function system_read(fname) { |
909 try { | |
910 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); | |
911 } catch (e) { | |
912 alert("Permission to read file was denied."); | |
913 } | |
914 var file = Components.classes["@mozilla.org/file/local;1"] | |
915 .createInstance(Components.interfaces.nsILocalFile); | |
916 try { | |
917 file.initWithPath( fname ); | |
918 if ( file.exists() == false ) { | |
919 alert("File does not exist"); | |
920 } | |
921 var is = Components.classes["@mozilla.org/network/file-input-stream;1"] | |
922 .createInstance( Components.interfaces.nsIFileInputStream ); | |
923 is.init( file,0x01, 00004, null); | |
924 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"] | |
925 .createInstance( Components.interfaces.nsIScriptableInputStream ); | |
926 sis.init( is ); | |
927 var output = sis.read( sis.available() ); | |
928 sis.close(); | |
929 } catch(e) { | |
930 alert(fname+" does not exist"); | |
931 } | |
932 return output; | |
357 | 933 } |
367 | 934 function system_open_write(fname) { |
935 try { | |
936 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); | |
937 } catch (e) { | |
938 alert("Permission to read file was denied."); | |
939 } | |
940 var file = Components.classes["@mozilla.org/file/local;1"] | |
941 .createInstance(Components.interfaces.nsILocalFile); | |
942 try { | |
943 file.initWithPath( fname ); | |
944 var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"] | |
945 .createInstance( Components.interfaces.nsIFileOutputStream ); | |
946 fostream.init( file,0x02|0x8|0x20, 0666,0); | |
947 } catch(e) { | |
371 | 948 alert('can not create '+fname); |
367 | 949 } |
950 return fostream; | |
951 } | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
952 function system_write(fname,xml) { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
953 try { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
954 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
955 } catch (e) { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
956 alert("Permission to read file was denied."); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
957 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
958 var file = Components.classes["@mozilla.org/file/local;1"] |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
959 .createInstance(Components.interfaces.nsILocalFile); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
960 try { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
961 file.initWithPath( fname ); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
962 var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"] |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
963 .createInstance( Components.interfaces.nsIFileOutputStream ); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
964 fostream.init( file,0x02|0x8|0x20, 0666,0); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
965 fostream.write( xml,xml.length ); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
966 fostream.close(); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
967 } catch(e) { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
968 alert(fname+" does not exist"); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
969 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
970 } |
358 | 971 |
371 | 972 function system_mkdir(path) |
973 { | |
974 try { | |
975 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); | |
976 } catch (e) { | |
977 alert("Permission to read file was denied."); | |
978 } | |
979 var file = Components.classes["@mozilla.org/file/local;1"] | |
980 .createInstance(Components.interfaces.nsILocalFile); | |
981 try { | |
982 file.initWithPath(path); | |
983 if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create | |
984 file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777); | |
985 } | |
986 } catch(e) { | |
987 alert('Failed to create directopry '+path+e); | |
988 } | |
989 } | |
990 | |
991 function getPathDirectory(path) | |
992 { | |
993 var s = path.lastIndexOf('/'); | |
994 if (s == -1) | |
995 return ''; | |
996 else | |
997 return path.substr(0,s); | |
998 } | |
999 | |
358 | 1000 function project_loadFile() |
1001 { | |
1002 prjname = $('#mbsvg').attr('value'); | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1003 project_name = prjname; |
371 | 1004 project_dir = getPathDirectory(prjname); |
388 | 1005 var f = system_open_write("/tmp/madbuilder.ws"); |
1006 var s = "last="+prjname; | |
1007 f.write(s,s.length); | |
1008 f.close(); | |
358 | 1009 var prj = system_read(prjname); |
1010 project_parse(prj); | |
364
a373b4743e63
Add file dialog to add a new scene file into the project.
wycc
parents:
362
diff
changeset
|
1011 filedialog.dialog('close'); |
358 | 1012 } |
1013 | |
365
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1014 |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1015 function project_save() |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1016 { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1017 var i; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1018 |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1019 var xml = "<project>\n"; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1020 var scenes = $('#scenes'); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1021 var sources = $('#sources'); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1022 var list = project_tree.getJSON(scenes); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1023 var len = list.children.length; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1024 |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1025 for(i=0;i<len;i++) { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1026 xml = xml + "\t<scene src='"+list.children[i].data+"' />\n"; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1027 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1028 list = project_tree.getJSON(sources); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1029 len = list.children.length; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1030 for(i=0;i<len;i++) { |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1031 xml = xml + "\t<source src='"+list.children[i].data+"' />\n"; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1032 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1033 xml = xml + "</project>\n"; |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1034 system_write(project_name,xml); |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1035 |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1036 } |
6adb28388132
Add capability to add new scene and source into the project
wycc
parents:
364
diff
changeset
|
1037 |
367 | 1038 |
1039 function onLoadProject(path) | |
1040 { | |
1041 project_name = path; | |
371 | 1042 project_dir = getPathDirectory(project_name); |
367 | 1043 var prj = system_read(project_name); |
1044 project_parse(prj); | |
1045 } | |
1046 | |
388 | 1047 function loadOldProject() |
1048 { | |
389
45e04408fc19
Implement stub functions for the MadSwatter integration.
wycc
parents:
388
diff
changeset
|
1049 return -1; |
388 | 1050 var f = system_open_read("/tmp/madbuilder.ws"); |
1051 if (f == null) return -1; | |
1052 var s = f.read(f.available()); | |
1053 f.close(); | |
1054 | |
1055 var pos = s.indexOf("last="); | |
1056 if (pos == -1) return -1; | |
1057 var m = s.match("last=([^\s]*)"); | |
1058 if (m[1]) { | |
1059 var prj = system_read(m[1]); | |
1060 project_dir = getPathDirectory(m[1]); | |
1061 project_parse(prj); | |
1062 $('#filedialog').dialog("close"); | |
1063 } | |
1064 return 0; | |
1065 | |
1066 } | |
1067 |