Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

save sprite name empty if it's empty #524

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/painteditor/Paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,8 @@ export default class Paint {

static nameBlur (e) {
ScratchJr.activeFocus = undefined;
var spr = ScratchJr.getSprite();
var ti = e.target;
var val = ScratchJr.validate(ti.value, spr.name);
var val = ScratchJr.validate(ti.value, '');
ti.value = val.substring(0, ti.maxLength);
ScratchJr.storyStart('Paint.nameBlur');
}
Expand Down Expand Up @@ -1331,7 +1330,7 @@ export default class Paint {
Paint.addOrModifySprite(str, fcn);
});
} else {
var type = Paint.getLoadType(spriteId, cname);
var type = Paint.getLoadType(spriteId);
if ((cname != currentName) && (type == 'modify')) {
ScratchJr.stage.currentPage.modifySpriteName(cname, spriteId);
} else if (currentMd5 && (type == 'add')) {
Expand Down Expand Up @@ -1402,7 +1401,7 @@ export default class Paint {
static changePageSprite () {
Paint.close();
var cname = document.forms.spriteform.name.value;
var type = Paint.getLoadType(spriteId, cname);
var type = Paint.getLoadType(spriteId);
switch (type) {
case 'modify':
ScratchJr.stage.currentPage.modifySprite(saveMD5, cname, spriteId);
Expand All @@ -1416,11 +1415,8 @@ export default class Paint {
}
}

static getLoadType (sid, cid) {
if (!cid) {
return 'none';
}
if (sid && cid) {
static getLoadType (sid) {
if (sid) {
return 'modify';
}
return 'add';
Expand Down