mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Merge branch 'rename-sprite-update-refs'
Conflicts: src/scratch/ScratchRuntime.as
This commit is contained in:
commit
24082315f2
2 changed files with 31 additions and 5 deletions
|
@ -685,6 +685,21 @@ public class ScratchRuntime {
|
|||
app.setSaveNeeded();
|
||||
}
|
||||
|
||||
public function renameSprite(newName:String):void {
|
||||
var obj:ScratchObj = app.viewedObj();
|
||||
var oldName:String = obj.objName;
|
||||
obj.objName = '';
|
||||
newName = app.stagePane.unusedSpriteName(newName || 'Sprite1');
|
||||
obj.objName = newName;
|
||||
for each (var lw:ListWatcher in app.viewedObj().lists) {
|
||||
lw.updateTitle();
|
||||
}
|
||||
for each (var a:BlockArg in allUsesOfSprite(oldName)) {
|
||||
a.setArgValue(newName);
|
||||
}
|
||||
app.setSaveNeeded();
|
||||
}
|
||||
|
||||
public function clearRunFeedback():void {
|
||||
if(app.editMode) {
|
||||
for each (var stack:Block in allStacks()) {
|
||||
|
@ -765,6 +780,20 @@ public class ScratchRuntime {
|
|||
return result;
|
||||
}
|
||||
|
||||
public function allUsesOfSprite(spriteName:String):Array {
|
||||
var spriteMenus:Array = ["spriteOnly", "spriteOrMouse", "spriteOrStage", "touching"];
|
||||
var result:Array = [];
|
||||
for each (var stack:Block in allStacks()) {
|
||||
// for each block in stack
|
||||
stack.allBlocksDo(function (b:Block):void {
|
||||
for each (var a:BlockArg in b.args) {
|
||||
if (spriteMenus.indexOf(a.menuName) != -1 && a.argValue == spriteName) result.push(a);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public function allUsesOfVariable(varName:String, owner:ScratchObj):Array {
|
||||
var variableBlocks:Array = [Specs.SET_VAR, Specs.CHANGE_VAR, "showVariable:", "hideVariable:"];
|
||||
var result:Array = [];
|
||||
|
|
|
@ -340,11 +340,8 @@ public class SpriteInfoPart extends UIPart implements DragClient {
|
|||
}
|
||||
|
||||
private function nameChanged():void {
|
||||
app.viewedObj().objName = spriteName.contents();
|
||||
for each (var lw:ListWatcher in app.viewedObj().lists) {
|
||||
lw.updateTitle();
|
||||
}
|
||||
app.setSaveNeeded();
|
||||
app.runtime.renameSprite(spriteName.contents());
|
||||
spriteName.setContents(app.viewedObj().objName);
|
||||
}
|
||||
|
||||
public function updateThumbnail():void {
|
||||
|
|
Loading…
Reference in a new issue