mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-03 09:04:40 -04:00
Report full sprite info in targetsUpdate
We need more than just the name for the initial render, so send everything consistent with sprite info reports.
This commit is contained in:
parent
adaf2df743
commit
e9da046969
4 changed files with 32 additions and 13 deletions
|
@ -121,13 +121,13 @@ window.onload = function() {
|
|||
// Generate new select box.
|
||||
for (var i = 0; i < data.targetList.length; i++) {
|
||||
var targetOption = document.createElement('option');
|
||||
targetOption.setAttribute('value', data.targetList[i][0]);
|
||||
targetOption.setAttribute('value', data.targetList[i].id);
|
||||
// If target id matches editingTarget id, select it.
|
||||
if (data.targetList[i][0] == data.editingTarget) {
|
||||
if (data.targetList[i].id == data.editingTarget) {
|
||||
targetOption.setAttribute('selected', 'selected');
|
||||
}
|
||||
targetOption.appendChild(
|
||||
document.createTextNode(data.targetList[i][1])
|
||||
document.createTextNode(data.targetList[i].name)
|
||||
);
|
||||
selectedTarget.appendChild(targetOption);
|
||||
}
|
||||
|
|
|
@ -729,15 +729,7 @@ Runtime.prototype.visualReport = function (blockId, value) {
|
|||
Runtime.prototype.spriteInfoReport = function (target) {
|
||||
if (!target.isOriginal) return;
|
||||
|
||||
this.emit(Runtime.SPRITE_INFO_REPORT, {
|
||||
id: target.id,
|
||||
x: target.x,
|
||||
y: target.y,
|
||||
direction: target.direction,
|
||||
costume: target.getCurrentCostume(),
|
||||
visible: target.visible,
|
||||
rotationStyle: target.rotationStyle
|
||||
});
|
||||
this.emit(Runtime.SPRITE_INFO_REPORT, target.toJSON());
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -304,7 +304,7 @@ VirtualMachine.prototype.emitTargetsUpdate = function () {
|
|||
// Don't report clones.
|
||||
return !target.hasOwnProperty('isOriginal') || target.isOriginal;
|
||||
}).map(function (target) {
|
||||
return [target.id, target.getName()];
|
||||
return target.toJSON();
|
||||
}),
|
||||
// Currently editing target id.
|
||||
editingTarget: this.editingTarget ? this.editingTarget.id : null
|
||||
|
|
|
@ -379,6 +379,14 @@ RenderedTarget.prototype.getCurrentCostume = function () {
|
|||
return this.sprite.costumes[this.currentCostume];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get full costume list
|
||||
* @return {object[]} list of costumes
|
||||
*/
|
||||
RenderedTarget.prototype.getCostumes = function () {
|
||||
return this.sprite.costumes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update all drawable properties for this rendered target.
|
||||
* Use when a batch has changed, e.g., when the drawable is first created.
|
||||
|
@ -654,6 +662,25 @@ RenderedTarget.prototype.postSpriteInfo = function (data) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize sprite info, used when emitting events about the sprite
|
||||
* @returns {object} sprite data as a simple object
|
||||
*/
|
||||
RenderedTarget.prototype.toJSON = function () {
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.getName(),
|
||||
isStage: this.isStage,
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
direction: this.direction,
|
||||
costume: this.getCurrentCostume(),
|
||||
costumeCount: this.getCostumes().length,
|
||||
visible: this.visible,
|
||||
rotationStyle: this.rotationStyle
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose, destroying any run-time properties.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue