kopia lustrzana https://github.com/backface/turtlestitch
refactored IDE sprite editor and corral
rodzic
9a3e45472e
commit
6b681d131f
36
src/gui.js
36
src/gui.js
|
@ -1496,8 +1496,7 @@ IDE_Morph.prototype.createSpriteBar = function () {
|
||||||
|
|
||||||
IDE_Morph.prototype.createSpriteEditor = function () {
|
IDE_Morph.prototype.createSpriteEditor = function () {
|
||||||
// assumes that the logo pane and the stage have already been created
|
// assumes that the logo pane and the stage have already been created
|
||||||
var scripts = this.currentSprite.scripts,
|
var scripts = this.currentSprite.scripts;
|
||||||
myself = this;
|
|
||||||
|
|
||||||
if (this.spriteEditor) {
|
if (this.spriteEditor) {
|
||||||
this.spriteEditor.destroy();
|
this.spriteEditor.destroy();
|
||||||
|
@ -1550,11 +1549,11 @@ IDE_Morph.prototype.createSpriteEditor = function () {
|
||||||
this.spriteEditor = new Morph();
|
this.spriteEditor = new Morph();
|
||||||
this.spriteEditor.color = this.groupColor;
|
this.spriteEditor.color = this.groupColor;
|
||||||
this.spriteEditor.acceptsDrops = true;
|
this.spriteEditor.acceptsDrops = true;
|
||||||
this.spriteEditor.reactToDropOf = function (droppedMorph) {
|
this.spriteEditor.reactToDropOf = (droppedMorph) => {
|
||||||
if (droppedMorph instanceof DialogBoxMorph) {
|
if (droppedMorph instanceof DialogBoxMorph) {
|
||||||
myself.world().add(droppedMorph);
|
this.world().add(droppedMorph);
|
||||||
} else if (droppedMorph instanceof SpriteMorph) {
|
} else if (droppedMorph instanceof SpriteMorph) {
|
||||||
myself.removeSprite(droppedMorph);
|
this.removeSprite(droppedMorph);
|
||||||
} else {
|
} else {
|
||||||
droppedMorph.destroy();
|
droppedMorph.destroy();
|
||||||
}
|
}
|
||||||
|
@ -1660,7 +1659,7 @@ IDE_Morph.prototype.createCorralBar = function () {
|
||||||
this.corralBar.add(cambutton);
|
this.corralBar.add(cambutton);
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
'cameraDisabled',
|
'cameraDisabled',
|
||||||
function (event) {
|
event => {
|
||||||
cambutton.disable();
|
cambutton.disable();
|
||||||
cambutton.hint =
|
cambutton.hint =
|
||||||
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
CamSnapshotDialogMorph.prototype.notSupportedMessage;
|
||||||
|
@ -1692,17 +1691,14 @@ IDE_Morph.prototype.createCorral = function () {
|
||||||
frame.acceptsDrops = false;
|
frame.acceptsDrops = false;
|
||||||
frame.contents.acceptsDrops = false;
|
frame.contents.acceptsDrops = false;
|
||||||
|
|
||||||
frame.contents.wantsDropOf = function (morph) {
|
frame.contents.wantsDropOf = (morph) => morph instanceof SpriteIconMorph;
|
||||||
return morph instanceof SpriteIconMorph;
|
|
||||||
};
|
|
||||||
|
|
||||||
frame.contents.reactToDropOf = function (spriteIcon) {
|
frame.contents.reactToDropOf = (spriteIcon) =>
|
||||||
myself.corral.reactToDropOf(spriteIcon);
|
this.corral.reactToDropOf(spriteIcon);
|
||||||
};
|
|
||||||
|
|
||||||
frame.alpha = 0;
|
frame.alpha = 0;
|
||||||
|
|
||||||
this.sprites.asArray().forEach(function (morph) {
|
this.sprites.asArray().forEach(morph => {
|
||||||
if (!morph.isTemporary) {
|
if (!morph.isTemporary) {
|
||||||
frame.contents.add(new SpriteIconMorph(morph));
|
frame.contents.add(new SpriteIconMorph(morph));
|
||||||
}
|
}
|
||||||
|
@ -1729,7 +1725,7 @@ IDE_Morph.prototype.createCorral = function () {
|
||||||
max = this.frame.right(),
|
max = this.frame.right(),
|
||||||
start = this.frame.left();
|
start = this.frame.left();
|
||||||
|
|
||||||
this.frame.contents.children.forEach(function (icon) {
|
this.frame.contents.children.forEach(icon => {
|
||||||
var w = icon.width();
|
var w = icon.width();
|
||||||
|
|
||||||
if (x + w > max) {
|
if (x + w > max) {
|
||||||
|
@ -1749,20 +1745,18 @@ IDE_Morph.prototype.createCorral = function () {
|
||||||
|
|
||||||
this.corral.refresh = function () {
|
this.corral.refresh = function () {
|
||||||
this.stageIcon.refresh();
|
this.stageIcon.refresh();
|
||||||
this.frame.contents.children.forEach(function (icon) {
|
this.frame.contents.children.forEach(icon =>
|
||||||
icon.refresh();
|
icon.refresh()
|
||||||
});
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.corral.wantsDropOf = function (morph) {
|
this.corral.wantsDropOf = (morph) => morph instanceof SpriteIconMorph;
|
||||||
return morph instanceof SpriteIconMorph;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.corral.reactToDropOf = function (spriteIcon) {
|
this.corral.reactToDropOf = function (spriteIcon) {
|
||||||
var idx = 1,
|
var idx = 1,
|
||||||
pos = spriteIcon.position();
|
pos = spriteIcon.position();
|
||||||
spriteIcon.destroy();
|
spriteIcon.destroy();
|
||||||
this.frame.contents.children.forEach(function (icon) {
|
this.frame.contents.children.forEach(icon => {
|
||||||
if (pos.gt(icon.position()) || pos.y > icon.bottom()) {
|
if (pos.gt(icon.position()) || pos.y > icon.bottom()) {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue