mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Merge pull request #187 from nathan/stop-stage-sprite
Fixed stop block label for "other scripts in sprite/stage"
This commit is contained in:
commit
2fb909d39e
2 changed files with 18 additions and 7 deletions
|
@ -37,12 +37,13 @@ import flash.display.*;
|
|||
import flash.events.*;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.geom.*;
|
||||
import flash.net.URLLoader;
|
||||
import flash.text.*;
|
||||
import flash.net.URLLoader;
|
||||
import flash.text.*;
|
||||
import assets.Resources;
|
||||
import translation.Translator;
|
||||
import util.*;
|
||||
import uiwidgets.*;
|
||||
import scratch.ScratchStage;
|
||||
|
||||
public class Block extends Sprite {
|
||||
|
||||
|
@ -453,13 +454,21 @@ public class Block extends Sprite {
|
|||
|
||||
public function duplicate(forClone:Boolean, forStage:Boolean = false):Block {
|
||||
var newSpec:String = spec;
|
||||
if(forStage && op == 'whenClicked') newSpec = 'when Stage clicked';
|
||||
if (forStage && op == 'whenClicked') newSpec = 'when Stage clicked';
|
||||
var dup:Block = new Block(newSpec, type, (int)(forClone ? -1 : base.color), op);
|
||||
dup.isRequester = isRequester;
|
||||
dup.parameterNames = parameterNames;
|
||||
dup.defaultArgValues = defaultArgValues;
|
||||
dup.warpProcFlag = warpProcFlag;
|
||||
if (forClone) dup.copyArgsForClone(args); else dup.copyArgs(args);
|
||||
if (forClone) {
|
||||
dup.copyArgsForClone(args);
|
||||
} else {
|
||||
dup.copyArgs(args);
|
||||
if (op == 'stopScripts' && args[0] is BlockArg) {
|
||||
if (forStage && args[0].argValue == 'other scripts in sprite') dup.args[0].setArgValue('other scripts in stage');
|
||||
if (!forStage && args[0].argValue == 'other scripts in stage') dup.args[0].setArgValue('other scripts in sprite');
|
||||
}
|
||||
}
|
||||
if (nextBlock != null) dup.addChild(dup.nextBlock = nextBlock.duplicate(forClone, forStage));
|
||||
if (subStack1 != null) dup.addChild(dup.subStack1 = subStack1.duplicate(forClone, forStage));
|
||||
if (subStack2 != null) dup.addChild(dup.subStack2 = subStack2.duplicate(forClone, forStage));
|
||||
|
@ -749,7 +758,7 @@ public class Block extends Sprite {
|
|||
/* Dragging */
|
||||
|
||||
public function objToGrab(evt:MouseEvent):Block {
|
||||
if (isEmbeddedParameter() || isInPalette()) return duplicate(false);
|
||||
if (isEmbeddedParameter() || isInPalette()) return duplicate(false, Scratch.app.viewedObj() is ScratchStage);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class BlockIO {
|
|||
|
||||
if (cmd[0] == 'getUserName') Scratch.app.usesUserNameBlock = true;
|
||||
|
||||
var special:Block = specialCmd(cmd);
|
||||
var special:Block = specialCmd(cmd, forStage);
|
||||
if (special) { special.fixArgLayout(); return special }
|
||||
|
||||
var b:Block;
|
||||
|
@ -178,7 +178,7 @@ public class BlockIO {
|
|||
|
||||
private static const controlColor:int = Specs.blockColor(Specs.controlCategory);
|
||||
|
||||
private static function specialCmd(cmd:Array):Block {
|
||||
private static function specialCmd(cmd:Array, forStage:Boolean):Block {
|
||||
// If the given command is special (e.g. a reporter or old-style a hat blocK), return a block for it.
|
||||
// Otherwise, return null.
|
||||
var b:Block;
|
||||
|
@ -228,6 +228,8 @@ public class BlockIO {
|
|||
case 'stopScripts':
|
||||
var type:String = (cmd[1].indexOf('other scripts') == 0) ? ' ' : 'f'; // block type depends on menu arg
|
||||
b = new Block('stop %m.stop', type, controlColor, 'stopScripts');
|
||||
if (forStage && b.op == 'stopScripts' && cmd[1] == 'other scripts in sprite') cmd[1] = 'other scripts in stage';
|
||||
if (!forStage && b.op == 'stopScripts' && cmd[1] != 'other scripts in stage') cmd[1] = 'other scripts in sprite';
|
||||
b.setArg(0, cmd[1]);
|
||||
return b;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue