Skip to content

Commit 857b3b3

Browse files
committed
April 2015 release
1 parent 0110c57 commit 857b3b3

13 files changed

+519
-82
lines changed

src/Designer-app.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
2828
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
2929
An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . -->
30-
<versionNumber>0.0.1</versionNumber>
30+
<versionNumber>0.0.3</versionNumber>
3131

3232
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
3333
<!-- <versionLabel></versionLabel> -->

src/Designer.as

+120-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
package {
66
import flash.desktop.NativeApplication;
7-
import flash.events.*;
7+
import flash.events.Event;
8+
import flash.events.IOErrorEvent;
9+
import flash.events.InvokeEvent;
810
import flash.filesystem.File;
911
import flash.filesystem.FileMode;
1012
import flash.filesystem.FileStream;
@@ -14,6 +16,10 @@ package {
1416
import flash.text.TextFormat;
1517
import flash.utils.ByteArray;
1618

19+
import scratch.ScratchObj;
20+
21+
import ui.parts.GlobalTabPart;
22+
1723
import uiwidgets.DialogBox;
1824
import uiwidgets.Menu;
1925

@@ -22,6 +28,10 @@ package {
2228
public class Designer extends Scratch {
2329
public static var dapp:Designer; // static reference to the app, used for debugging
2430

31+
protected var lastViewedObject:ScratchObj = null;
32+
33+
protected var globalTabPart:GlobalTabPart;
34+
2535
protected var displayFPSCounter:Boolean = false; // Tracks displaying the FPS counter
2636

2737
public var projectPath:String = ''; // The OS path to the save file, including name
@@ -103,6 +113,10 @@ public class Designer extends Scratch {
103113
if (b.lastEvent.shiftKey) {
104114
m.addLine();
105115
m.addItem('Toggle FPS Counter', toggleFPSCounter);
116+
117+
m.addItem('Toggle Focus Area blocks', toggleFocusAreaBlocks);
118+
119+
m.addItem('Toggle Global Tab', toggleGlobalTab);
106120
}
107121
}
108122

@@ -115,11 +129,25 @@ public class Designer extends Scratch {
115129
addFrameRateReadout(10, 29);
116130
}
117131
}
132+
133+
protected function toggleFocusAreaBlocks():void {
134+
if (app.canAddFocusAreaBlocks) {
135+
app.canAddFocusAreaBlocks = false;
136+
} else {
137+
app.canAddFocusAreaBlocks = true;
138+
}
139+
140+
Scratch.app.translationChanged();
141+
}
142+
143+
protected function toggleGlobalTab():void {
144+
tabsPart.toggleGlobalTab();
145+
}
118146

119147
override public function showAboutMenu(b:*):void {
120148
// Just display a dialog
121149
DialogBox.notify(
122-
'DevPro Game Snap',
150+
'DevPro Game Snap v0.0.3',
123151
'\nCopyright © 2015 GarageGames LLC' +
124152
'\n\nBased on Scratch from the MIT Media Laboratory' +
125153
'\nunder the GPL 2 license.', stage);
@@ -249,6 +277,96 @@ public class Designer extends Scratch {
249277
stage);
250278
}
251279

280+
// Override the Scratch.as version
281+
override protected function addParts():void {
282+
super.addParts();
283+
284+
//globalTabPart = new GlobalTabPart(this);
285+
286+
}
287+
288+
// Copied from Scratch.as
289+
override public function selectSprite(obj:ScratchObj):void {
290+
if (isShowing(imagesPart)) imagesPart.editor.shutdown();
291+
if (isShowing(soundsPart)) soundsPart.editor.shutdown();
292+
viewedObject = obj;
293+
libraryPart.refresh();
294+
tabsPart.refresh();
295+
if (isShowing(imagesPart)) {
296+
imagesPart.refresh();
297+
}
298+
if (isShowing(soundsPart)) {
299+
soundsPart.currentIndex = 0;
300+
soundsPart.refresh();
301+
}
302+
if (isShowing(scriptsPart)) {
303+
if(scriptsPart.isViewingGlobalTab()) {
304+
// Force a change to the Scripts tabs when switching sprites
305+
setTab("scripts");
306+
}
307+
else {
308+
scriptsPart.updatePalette();
309+
scriptsPane.viewScriptsFor(obj);
310+
scriptsPart.updateSpriteWatermark();
311+
}
312+
}
313+
}
314+
315+
// Copied from Scratch.as
316+
override public function setTab(tabName:String):void {
317+
if (isShowing(imagesPart)) imagesPart.editor.shutdown();
318+
if (isShowing(soundsPart)) soundsPart.editor.shutdown();
319+
hide(scriptsPart);
320+
hide(imagesPart);
321+
hide(soundsPart);
322+
//hide(globalTabPart);
323+
if (!editMode) return;
324+
if (tabName == 'images') {
325+
show(imagesPart);
326+
imagesPart.refresh();
327+
} else if (tabName == 'sounds') {
328+
soundsPart.refresh();
329+
show(soundsPart);
330+
} else if (tabName == 'global') {
331+
scriptsPart.setGlobalTab(true);
332+
333+
if(viewedObject != stagePane.globalObjSprite()) {
334+
lastViewedObject = viewedObject;
335+
}
336+
337+
viewedObject = stagePane.globalObjSprite();// Try and present only the global sprite
338+
libraryPart.refresh();
339+
tabsPart.refresh();
340+
341+
scriptsPart.updatePalette();
342+
scriptsPane.viewScriptsFor(viewedObject);
343+
//scriptsPart.updateSpriteWatermark();
344+
scriptsPart.clearSpriteWatermark();
345+
show(scriptsPart);
346+
} else if (tabName && (tabName.length > 0)) {
347+
tabName = 'scripts';
348+
scriptsPart.setGlobalTab(false);
349+
350+
// Do we need to switchto the last viewed object?
351+
if(viewedObject == stagePane.globalObjSprite() && lastViewedObject != null) {
352+
viewedObject = lastViewedObject;
353+
lastViewedObject = null;
354+
libraryPart.refresh();
355+
tabsPart.refresh();
356+
}
357+
358+
scriptsPart.updatePalette();
359+
scriptsPane.viewScriptsFor(viewedObject);
360+
scriptsPart.updateSpriteWatermark();
361+
show(scriptsPart);
362+
}
363+
show(tabsPart);
364+
show(stagePart); // put stage in front
365+
tabsPart.selectTab(tabName);
366+
lastTab = tabName;
367+
if (saveNeeded) setSaveNeeded(true); // save project when switching tabs, if needed (but NOT while loading!)
368+
}
369+
252370
// Get the project's native file path (including file name)
253371
public function getProjectPath():String {
254372
return projectPath;

src/Scratch.as

+8-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class Scratch extends Sprite {
7171
public var render3D:IRenderIn3D;
7272
public var isArmCPU:Boolean;
7373
public var jsEnabled:Boolean = false; // true when the SWF can talk to the webpage
74+
75+
// For Game Snap
76+
public static const gameSnapFileVersion:int = 1; // The current Game Snap file version
77+
public var gameSnapLastReadFileVersion:int = 0; // The last read Game Snap file version
78+
public var canAddFocusAreaBlocks:Boolean = false; // Determines whether Focus Area blocks can be added from the More Blocks category
7479

7580
// Runtime
7681
public var runtime:ScratchRuntime;
@@ -87,8 +92,8 @@ public class Scratch extends Sprite {
8792
public var debugOpCmd:String = '';
8893

8994
protected var autostart:Boolean;
90-
private var viewedObject:ScratchObj;
91-
private var lastTab:String = 'scripts';
95+
protected var viewedObject:ScratchObj;
96+
protected var lastTab:String = 'scripts';
9297
protected var wasEdited:Boolean; // true if the project was edited and autosaved
9398
private var _usesUserNameBlock:Boolean = false;
9499
protected var languageChanged:Boolean; // set when language changed
@@ -106,7 +111,7 @@ public class Scratch extends Sprite {
106111
public var libraryPart:LibraryPart;
107112
protected var topBarPart:TopBarPart;
108113
protected var stagePart:StagePart;
109-
private var tabsPart:TabsPart;
114+
protected var tabsPart:TabsPart;
110115
protected var scriptsPart:ScriptsPart;
111116
public var imagesPart:ImagesPart;
112117
public var soundsPart:SoundsPart;

src/Specs.as

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
package {
2929
import flash.display.Bitmap;
30+
3031
import assets.Resources;
3132

3233
public class Specs {
@@ -47,14 +48,16 @@ public class Specs {
4748
public static const dataCategory:int = 9;
4849
public static const myBlocksCategory:int = 10;
4950
public static const listCategory:int = 12;
51+
public static const focusAreaCategory:int = 13;
5052
public static const extensionsCategory:int = 20;
5153

5254
public static var variableColor:int = 0xEE7D16; // Scratch 1.4: 0xF3761D
5355
public static var listColor:int = 0xCC5B22; // Scratch 1.4: 0xD94D11
5456
public static var procedureColor:int = 0x632D99; // 0x531E99;
5557
public static var parameterColor:int = 0x5947B1;
58+
public static var focusAreaColor:int = 0x000;
5659
public static var extensionsColor:int = 0x4B4A60; // 0x72228C; // 0x672D79;
57-
60+
5861
private static const undefinedColor:int = 0xD42828;
5962

6063
public static const categories:Array = [
@@ -72,6 +75,7 @@ public class Specs {
7275
[10, "More Blocks", procedureColor],
7376
[11, "Parameter", parameterColor],
7477
[12, "List", listColor],
78+
[13, "Focus Area", focusAreaColor],
7579
[20, "Extension", extensionsColor],
7680
];
7781

@@ -359,6 +363,9 @@ public class Specs {
359363
["-"],
360364
["show list %m.list", " ", 12, "showList:"],
361365
["hide list %m.list", " ", 12, "hideList:"],
366+
367+
// DevPro blocks
368+
["Focus Area %n", "c", 13, "focusArea", 1],
362369

363370
// obsolete blocks from Scratch 1.4 that may be used in older projects
364371
["play drum %n for %n beats", " ", 98, "drum:duration:elapsed:from:", 1, 0.25], // Scratch 1.4 MIDI drum

src/blocks/Block.as

+32-11
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,33 @@
3131
// sequence from a specification string (e.g. "%n + %n") and type (e.g. reporter).
3232

3333
package blocks {
34+
import flash.display.DisplayObject;
35+
import flash.display.DisplayObjectContainer;
36+
import flash.display.Sprite;
37+
import flash.events.FocusEvent;
38+
import flash.events.MouseEvent;
39+
import flash.filters.GlowFilter;
40+
import flash.geom.Point;
41+
import flash.net.URLLoader;
42+
import flash.text.AntiAliasType;
43+
import flash.text.TextField;
44+
import flash.text.TextFieldAutoSize;
45+
import flash.text.TextFormat;
46+
import flash.text.TextLineMetrics;
47+
48+
import assets.Resources;
49+
3450
import extensions.ExtensionManager;
3551

36-
import flash.display.*;
37-
import flash.events.*;
38-
import flash.filters.GlowFilter;
39-
import flash.geom.*;
40-
import flash.net.URLLoader;
41-
import flash.text.*;
42-
import assets.Resources;
43-
import translation.Translator;
44-
import util.*;
45-
import uiwidgets.*;
46-
import scratch.*;
52+
import scratch.ScratchComment;
53+
import scratch.ScratchStage;
54+
55+
import translation.Translator;
56+
57+
import uiwidgets.DialogBox;
58+
import uiwidgets.ScriptsPane;
59+
60+
import util.ReadStream;
4761

4862
public class Block extends Sprite {
4963

@@ -105,6 +119,9 @@ public class Block extends Sprite {
105119

106120
private var originalParent:DisplayObjectContainer, originalRole:int, originalIndex:int, originalPosition:Point;
107121

122+
// For Game Snap
123+
public var isGlobal:Boolean = false;
124+
108125
public function Block(spec:String, type:String = " ", color:int = 0xD00000, op:* = 0, defaultArgs:Array = null) {
109126
this.spec = Translator.map(spec);
110127
this.type = type;
@@ -539,6 +556,10 @@ public class Block extends Sprite {
539556
dup.parameterNames = parameterNames;
540557
dup.defaultArgValues = defaultArgValues;
541558
dup.warpProcFlag = warpProcFlag;
559+
560+
// For Game Snap
561+
dup.isGlobal = isGlobal;
562+
542563
if (forClone) {
543564
dup.copyArgsForClone(args);
544565
} else {

src/blocks/BlockIO.as

+20-4
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public class BlockIO {
7070
if (b.op == Specs.GET_LIST) return [Specs.GET_LIST, b.spec]; // list reporter
7171
if (b.op == Specs.GET_PARAM) return [Specs.GET_PARAM, b.spec, b.type]; // parameter reporter
7272
if (b.op == Specs.PROCEDURE_DEF) // procedure definition
73-
return [Specs.PROCEDURE_DEF, b.spec, b.parameterNames, b.defaultArgValues, b.warpProcFlag];
74-
if (b.op == Specs.CALL) result = [Specs.CALL, b.spec]; // procedure call - arguments follow spec
73+
return [Specs.PROCEDURE_DEF, b.spec, b.parameterNames, b.defaultArgValues, b.warpProcFlag, b.isGlobal]; // For Game Snap, isGlobal added with file version 1
74+
if (b.op == Specs.CALL) result = [Specs.CALL, b.isGlobal, b.spec]; // procedure call - arguments follow spec. For Game Snap, isGlobal added with file version 1
7575
for each (var a:* in b.normalizedArgs()) {
7676
// Note: arguments are always saved in normalized (i.e. left-to-right) order
7777
if (a is Block) result.push(blockToArray(a));
@@ -102,8 +102,18 @@ public class BlockIO {
102102
if (b) { b.fixArgLayout(); return b }
103103

104104
if (cmd[0] == Specs.CALL) {
105-
b = new Block(cmd[1], '', Specs.procedureColor, Specs.CALL);
106-
cmd.splice(0, 1);
105+
// Modified for Game Snap
106+
if(Scratch.app.gameSnapLastReadFileVersion >= 1) {
107+
// Read in the block while taking into account the isGlobal property
108+
b = new Block(cmd[2], '', Specs.procedureColor, Specs.CALL);
109+
b.isGlobal = cmd[1];
110+
cmd.splice(0, 2);
111+
}
112+
else {
113+
// This is the original code that was here. It allows for reading of non-Game Snap files
114+
b = new Block(cmd[1], '', Specs.procedureColor, Specs.CALL);
115+
cmd.splice(0, 1);
116+
}
107117
} else {
108118
var spec:Array = specForCmd(cmd, undefinedBlockType);
109119
var label:String = spec[0];
@@ -192,6 +202,12 @@ public class BlockIO {
192202
b.parameterNames = cmd[2];
193203
b.defaultArgValues = cmd[3];
194204
if (cmd.length > 4) b.warpProcFlag = cmd[4];
205+
206+
// For Game Snap
207+
if(Scratch.app.gameSnapLastReadFileVersion >=1 ) {
208+
b.isGlobal = cmd[5]; // Defined in blockToArray()
209+
}
210+
195211
b.setSpec(cmd[1]);
196212
b.fixArgLayout();
197213
return b;

0 commit comments

Comments
 (0)