mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -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) {
|
||||
str = str.replace(/>\s*</g, '><');
|
||||
me.setSVG(str);
|
||||
if ((str.indexOf('xlink:href') < 0) && OS.path) {
|
||||
me.setBackgroundImage(url, fcn); // does not have embedded images
|
||||
} else {
|
||||
IO.getImagesInSVG(str, function () {
|
||||
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) {
|
||||
var md5 = this.md5;
|
||||
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;
|
||||
if (md5.indexOf('/') > -1) {
|
||||
IO.requestFromServer(md5, doNext);
|
||||
|
@ -92,14 +89,10 @@ export default class Sprite {
|
|||
function doNext (str) {
|
||||
str = str.replace(/>\s*</g, '><');
|
||||
spr.setSVG(str);
|
||||
if ((str.indexOf('xlink:href') < 0) && OS.path) {
|
||||
whenDone(url); // does not have embedded images
|
||||
} else {
|
||||
IO.getImagesInSVG(str, function () {
|
||||
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
|
||||
return;
|
||||
}
|
||||
if ((IO.getExtension(md5) == 'png') && OS.path) {
|
||||
fcn(OS.path + md5); // only if it is not in debug mode
|
||||
} else {
|
||||
OS.getmedia(md5, nextStep);
|
||||
} // get url contents
|
||||
|
||||
OS.getmedia(md5, nextStep);
|
||||
|
||||
function gotit (str) {
|
||||
var base64 = IO.getImageDataURL(md5, btoa(str));
|
||||
|
|
Loading…
Reference in a new issue