kopia lustrzana https://github.com/backface/turtlestitch
support inheritance for sounds
rodzic
7b8602e367
commit
ebc08a1f73
|
@ -730,10 +730,11 @@ SyntaxElementMorph.prototype.definesScriptVariable = function (name) {
|
||||||
// SyntaxElementMorph copy-on-write support:
|
// SyntaxElementMorph copy-on-write support:
|
||||||
|
|
||||||
SyntaxElementMorph.prototype.selectForEdit = function () {
|
SyntaxElementMorph.prototype.selectForEdit = function () {
|
||||||
var ide = this.parentThatIsA(IDE_Morph),
|
var scripts = this.parentThatIsA(ScriptsMorph),
|
||||||
|
ide = this.parentThatIsA(IDE_Morph),
|
||||||
rcvr = ide ? ide.currentSprite : null,
|
rcvr = ide ? ide.currentSprite : null,
|
||||||
selected;
|
selected;
|
||||||
if (rcvr && rcvr.inheritsAttribute('scripts')) {
|
if (scripts && rcvr && rcvr.inheritsAttribute('scripts')) {
|
||||||
// copy on write:
|
// copy on write:
|
||||||
this.selectionID = true;
|
this.selectionID = true;
|
||||||
rcvr.shadowAttribute('scripts');
|
rcvr.shadowAttribute('scripts');
|
||||||
|
|
23
gui.js
23
gui.js
|
@ -7761,6 +7761,7 @@ SoundIconMorph.prototype.renameSound = function () {
|
||||||
var sound = this.object,
|
var sound = this.object,
|
||||||
ide = this.parentThatIsA(IDE_Morph),
|
ide = this.parentThatIsA(IDE_Morph),
|
||||||
myself = this;
|
myself = this;
|
||||||
|
this.disinherit();
|
||||||
(new DialogBoxMorph(
|
(new DialogBoxMorph(
|
||||||
null,
|
null,
|
||||||
function (answer) {
|
function (answer) {
|
||||||
|
@ -7791,9 +7792,21 @@ SoundIconMorph.prototype.createBackgrounds
|
||||||
SoundIconMorph.prototype.createLabel
|
SoundIconMorph.prototype.createLabel
|
||||||
= SpriteIconMorph.prototype.createLabel;
|
= SpriteIconMorph.prototype.createLabel;
|
||||||
|
|
||||||
|
// SoundIconMorph inheritance
|
||||||
|
|
||||||
|
SoundIconMorph.prototype.disinherit = function () {
|
||||||
|
var jukebox = this.parentThatIsA(JukeboxMorph),
|
||||||
|
idx = this.parent.children.indexOf(this);
|
||||||
|
if (jukebox.sprite.inheritsAttribute('sounds')) {
|
||||||
|
jukebox.sprite.shadowAttribute('sounds');
|
||||||
|
this.object = jukebox.sprite.sounds.at(idx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// SoundIconMorph drag & drop
|
// SoundIconMorph drag & drop
|
||||||
|
|
||||||
SoundIconMorph.prototype.prepareToBeGrabbed = function () {
|
SoundIconMorph.prototype.prepareToBeGrabbed = function () {
|
||||||
|
this.disinherit();
|
||||||
this.removeSound();
|
this.removeSound();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7816,7 +7829,7 @@ function JukeboxMorph(aSprite, sliderColor) {
|
||||||
JukeboxMorph.prototype.init = function (aSprite, sliderColor) {
|
JukeboxMorph.prototype.init = function (aSprite, sliderColor) {
|
||||||
// additional properties
|
// additional properties
|
||||||
this.sprite = aSprite || new SpriteMorph();
|
this.sprite = aSprite || new SpriteMorph();
|
||||||
this.costumesVersion = null;
|
this.soundsVersion = null;
|
||||||
this.spriteVersion = null;
|
this.spriteVersion = null;
|
||||||
|
|
||||||
// initialize inherited properties
|
// initialize inherited properties
|
||||||
|
@ -7867,6 +7880,7 @@ JukeboxMorph.prototype.updateList = function () {
|
||||||
myself.addContents(icon);
|
myself.addContents(icon);
|
||||||
y = icon.bottom() + padding;
|
y = icon.bottom() + padding;
|
||||||
});
|
});
|
||||||
|
this.soundsVersion = this.sprite.costumes.lastChanged;
|
||||||
|
|
||||||
Morph.prototype.trackChanges = oldFlag;
|
Morph.prototype.trackChanges = oldFlag;
|
||||||
this.changed();
|
this.changed();
|
||||||
|
@ -7883,13 +7897,14 @@ JukeboxMorph.prototype.updateSelection = function () {
|
||||||
|
|
||||||
// Jukebox stepping
|
// Jukebox stepping
|
||||||
|
|
||||||
/*
|
|
||||||
JukeboxMorph.prototype.step = function () {
|
JukeboxMorph.prototype.step = function () {
|
||||||
|
if (this.soundsVersion !== this.sprite.sounds.lastChanged) {
|
||||||
|
this.updateList();
|
||||||
|
}
|
||||||
if (this.spriteVersion !== this.sprite.version) {
|
if (this.spriteVersion !== this.sprite.version) {
|
||||||
this.updateSelection();
|
this.updateSelection();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
// Jukebox ops
|
// Jukebox ops
|
||||||
|
|
||||||
|
@ -7915,6 +7930,8 @@ JukeboxMorph.prototype.reactToDropOf = function (icon) {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.sprite.shadowAttribute('sounds');
|
||||||
this.sprite.sounds.add(costume, idx);
|
this.sprite.sounds.add(costume, idx);
|
||||||
this.updateList();
|
this.updateList();
|
||||||
};
|
};
|
||||||
|
|
|
@ -3476,12 +3476,13 @@ Fixes:
|
||||||
------
|
------
|
||||||
* Objects, Blocks, Threads, Tables, Store: First-Class Sounds
|
* Objects, Blocks, Threads, Tables, Store: First-Class Sounds
|
||||||
* Block: new musical “notes” symbol
|
* Block: new musical “notes” symbol
|
||||||
|
* Objects, Blocks, Threads, GUI: inheritance support for sounds
|
||||||
|
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* polymorphic sprite-local custom blocks
|
* polymorphic sprite-local custom blocks
|
||||||
* inheritance of sprite-local custom blocks
|
* inheritance of sprite-local custom blocks
|
||||||
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, scripts)
|
* inheritance of sprite attributes (x, y, direction, size, costumes, costume #, sounds, scripts)
|
||||||
* first-class costumes and sounds
|
* first-class costumes and sounds
|
||||||
* localization support when typing expressions
|
* localization support when typing expressions
|
||||||
* support for user-forced line-breaks in custom block labels
|
* support for user-forced line-breaks in custom block labels
|
||||||
|
|
12
objects.js
12
objects.js
|
@ -122,6 +122,7 @@ SpriteMorph.prototype.attributes =
|
||||||
'size',
|
'size',
|
||||||
'costumes',
|
'costumes',
|
||||||
'costume #',
|
'costume #',
|
||||||
|
'sounds',
|
||||||
'scripts'
|
'scripts'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -3030,6 +3031,7 @@ SpriteMorph.prototype.reportCostumes = function () {
|
||||||
// SpriteMorph sound management
|
// SpriteMorph sound management
|
||||||
|
|
||||||
SpriteMorph.prototype.addSound = function (audio, name) {
|
SpriteMorph.prototype.addSound = function (audio, name) {
|
||||||
|
this.shadowAttribute('sounds');
|
||||||
this.sounds.add(new Sound(audio, name));
|
this.sounds.add(new Sound(audio, name));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5185,7 +5187,7 @@ SpriteMorph.prototype.shadowedAttributes = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
SpriteMorph.prototype.shadowAttribute = function (aName) {
|
SpriteMorph.prototype.shadowAttribute = function (aName) {
|
||||||
var ide, wardrobe,
|
var ide, wardrobe, jukebox,
|
||||||
myself = this,
|
myself = this,
|
||||||
pos;
|
pos;
|
||||||
if (!this.inheritsAttribute(aName)) {
|
if (!this.inheritsAttribute(aName)) {
|
||||||
|
@ -5205,6 +5207,12 @@ SpriteMorph.prototype.shadowAttribute = function (aName) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.costumes = wardrobe;
|
this.costumes = wardrobe;
|
||||||
|
} else if (aName === 'sounds') {
|
||||||
|
jukebox = new List();
|
||||||
|
this.sounds.asArray().forEach(function (sound) {
|
||||||
|
jukebox.add(sound.copy());
|
||||||
|
});
|
||||||
|
this.sounds = jukebox;
|
||||||
} else if (aName === 'scripts') {
|
} else if (aName === 'scripts') {
|
||||||
ide.stage.threads.stopAllForReceiver(this);
|
ide.stage.threads.stopAllForReceiver(this);
|
||||||
pos = this.scripts.position();
|
pos = this.scripts.position();
|
||||||
|
@ -5236,6 +5244,8 @@ SpriteMorph.prototype.inheritAttribute = function (aName) {
|
||||||
this.inheritedAttributes.push(aName);
|
this.inheritedAttributes.push(aName);
|
||||||
if (aName === 'costumes') {
|
if (aName === 'costumes') {
|
||||||
this.costumes = this.exemplar.costumes;
|
this.costumes = this.exemplar.costumes;
|
||||||
|
} else if (aName === 'sounds') {
|
||||||
|
this.sounds = this.exemplar.sounds;
|
||||||
} else {
|
} else {
|
||||||
this.refreshInheritedAttribute(aName);
|
this.refreshInheritedAttribute(aName);
|
||||||
if (ide) {
|
if (ide) {
|
||||||
|
|
Ładowanie…
Reference in New Issue