Skip to content

Commit e9bfd51

Browse files
committed
Fixed stop block label for "other scripts in sprite/stage" when dragging between a sprite and the stage and between the backpack and a sprite or the stage
1 parent ab25a08 commit e9bfd51

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/blocks/Block.as

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ import flash.display.*;
3737
import flash.events.*;
3838
import flash.filters.GlowFilter;
3939
import flash.geom.*;
40-
import flash.net.URLLoader;
41-
import flash.text.*;
40+
import flash.net.URLLoader;
41+
import flash.text.*;
4242
import assets.Resources;
4343
import translation.Translator;
4444
import util.*;
4545
import uiwidgets.*;
46+
import scratch.ScratchStage;
4647

4748
public class Block extends Sprite {
4849

@@ -453,13 +454,21 @@ public class Block extends Sprite {
453454

454455
public function duplicate(forClone:Boolean, forStage:Boolean = false):Block {
455456
var newSpec:String = spec;
456-
if(forStage && op == 'whenClicked') newSpec = 'when Stage clicked';
457+
if (forStage && op == 'whenClicked') newSpec = 'when Stage clicked';
457458
var dup:Block = new Block(newSpec, type, (int)(forClone ? -1 : base.color), op);
458459
dup.isRequester = isRequester;
459460
dup.parameterNames = parameterNames;
460461
dup.defaultArgValues = defaultArgValues;
461462
dup.warpProcFlag = warpProcFlag;
462-
if (forClone) dup.copyArgsForClone(args); else dup.copyArgs(args);
463+
if (forClone) {
464+
dup.copyArgsForClone(args);
465+
} else {
466+
dup.copyArgs(args);
467+
if (op == 'stopScripts' && args[0] is BlockArg) {
468+
if (forStage && args[0].argValue == 'other scripts in sprite') dup.args[0].setArgValue('other scripts in stage');
469+
if (!forStage && args[0].argValue == 'other scripts in stage') dup.args[0].setArgValue('other scripts in sprite');
470+
}
471+
}
463472
if (nextBlock != null) dup.addChild(dup.nextBlock = nextBlock.duplicate(forClone, forStage));
464473
if (subStack1 != null) dup.addChild(dup.subStack1 = subStack1.duplicate(forClone, forStage));
465474
if (subStack2 != null) dup.addChild(dup.subStack2 = subStack2.duplicate(forClone, forStage));
@@ -749,7 +758,7 @@ public class Block extends Sprite {
749758
/* Dragging */
750759

751760
public function objToGrab(evt:MouseEvent):Block {
752-
if (isEmbeddedParameter() || isInPalette()) return duplicate(false);
761+
if (isEmbeddedParameter() || isInPalette()) return duplicate(false, Scratch.app.viewedObj() is ScratchStage);
753762
return this;
754763
}
755764

src/blocks/BlockIO.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class BlockIO {
9393

9494
if (cmd[0] == 'getUserName') Scratch.app.usesUserNameBlock = true;
9595

96-
var special:Block = specialCmd(cmd);
96+
var special:Block = specialCmd(cmd, forStage);
9797
if (special) { special.fixArgLayout(); return special }
9898

9999
var b:Block;
@@ -177,7 +177,7 @@ public class BlockIO {
177177

178178
private static const controlColor:int = Specs.blockColor(Specs.controlCategory);
179179

180-
private static function specialCmd(cmd:Array):Block {
180+
private static function specialCmd(cmd:Array, forStage:Boolean):Block {
181181
// If the given command is special (e.g. a reporter or old-style a hat blocK), return a block for it.
182182
// Otherwise, return null.
183183
var b:Block;
@@ -227,6 +227,8 @@ public class BlockIO {
227227
case 'stopScripts':
228228
var type:String = (cmd[1].indexOf('other scripts') == 0) ? ' ' : 'f'; // block type depends on menu arg
229229
b = new Block('stop %m.stop', type, controlColor, 'stopScripts');
230+
if (forStage && b.op == 'stopScripts' && cmd[1] == 'other scripts in sprite') cmd[1] = 'other scripts in stage';
231+
if (!forStage && b.op == 'stopScripts' && cmd[1] != 'other scripts in stage') cmd[1] = 'other scripts in sprite';
230232
b.setArg(0, cmd[1]);
231233
return b;
232234
}

0 commit comments

Comments
 (0)