mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-29 02:25:39 -05:00
asset saving patch
many thanks @yueyuzhao
This commit is contained in:
parent
eb37208424
commit
45b06ee8a6
3 changed files with 8 additions and 22 deletions
|
@ -147,14 +147,10 @@ export default class Page {
|
||||||
function doNext (str) {
|
function doNext (str) {
|
||||||
str = str.replace(/>\s*</g, '><');
|
str = str.replace(/>\s*</g, '><');
|
||||||
me.setSVG(str);
|
me.setSVG(str);
|
||||||
if ((str.indexOf('xlink:href') < 0) && OS.path) {
|
IO.getImagesInSVG(str, function () {
|
||||||
me.setBackgroundImage(url, fcn); // does not have embedded images
|
|
||||||
} else {
|
|
||||||
var base64 = IO.getImageDataURL(me.md5, btoa(str));
|
var base64 = IO.getImageDataURL(me.md5, btoa(str));
|
||||||
IO.getImagesInSVG(str, function () {
|
me.setBackgroundImage(base64, fcn);
|
||||||
me.setBackgroundImage(base64, fcn);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,6 @@ export default class Sprite {
|
||||||
getAsset (whenDone) {
|
getAsset (whenDone) {
|
||||||
var md5 = this.md5;
|
var md5 = this.md5;
|
||||||
var spr = this;
|
var spr = this;
|
||||||
var url = (MediaLib.keys[md5]) ?
|
|
||||||
MediaLib.path + md5 :
|
|
||||||
(md5.indexOf('/') < 0) ? OS.path + md5 : md5;
|
|
||||||
md5 = (MediaLib.keys[md5]) ? MediaLib.path + md5 : md5;
|
md5 = (MediaLib.keys[md5]) ? MediaLib.path + md5 : md5;
|
||||||
if (md5.indexOf('/') > -1) {
|
if (md5.indexOf('/') > -1) {
|
||||||
IO.requestFromServer(md5, doNext);
|
IO.requestFromServer(md5, doNext);
|
||||||
|
@ -92,14 +89,10 @@ export default class Sprite {
|
||||||
function doNext (str) {
|
function doNext (str) {
|
||||||
str = str.replace(/>\s*</g, '><');
|
str = str.replace(/>\s*</g, '><');
|
||||||
spr.setSVG(str);
|
spr.setSVG(str);
|
||||||
if ((str.indexOf('xlink:href') < 0) && OS.path) {
|
IO.getImagesInSVG(str, function () {
|
||||||
whenDone(url); // does not have embedded images
|
|
||||||
} else {
|
|
||||||
var base64 = IO.getImageDataURL(spr.md5, btoa(str));
|
var base64 = IO.getImageDataURL(spr.md5, btoa(str));
|
||||||
IO.getImagesInSVG(str, function () {
|
whenDone(base64);
|
||||||
whenDone(base64);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,8 @@ export default class IO {
|
||||||
IO.requestFromServer(md5, gotit); // get url contents
|
IO.requestFromServer(md5, gotit); // get url contents
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((IO.getExtension(md5) == 'png') && OS.path) {
|
|
||||||
fcn(OS.path + md5); // only if it is not in debug mode
|
OS.getmedia(md5, nextStep);
|
||||||
} else {
|
|
||||||
OS.getmedia(md5, nextStep);
|
|
||||||
} // get url contents
|
|
||||||
|
|
||||||
function gotit (str) {
|
function gotit (str) {
|
||||||
var base64 = IO.getImageDataURL(md5, btoa(str));
|
var base64 = IO.getImageDataURL(md5, btoa(str));
|
||||||
|
|
Loading…
Reference in a new issue