@@ -18,6 +18,7 @@ package {
18
18
19
19
import scratch.ScratchObj ;
20
20
21
+ import ui.parts.DesignTabPart ;
21
22
import ui.parts.GlobalTabPart ;
22
23
23
24
import uiwidgets.DialogBox ;
@@ -31,6 +32,7 @@ public class Designer extends Scratch {
31
32
protected var lastViewedObject: ScratchObj = null ;
32
33
33
34
protected var globalTabPart: GlobalTabPart;
35
+ public var designTabPart: DesignTabPart;
34
36
35
37
protected var displayFPSCounter: Boolean = false ; // Tracks displaying the FPS counter
36
38
@@ -69,7 +71,7 @@ public class Designer extends Scratch {
69
71
debugTextBox. text = text ;
70
72
}
71
73
}
72
-
74
+
73
75
override protected function addFileMenuItems (b :* , m :Menu ):void {
74
76
m. addItem ('Open' , runtime. selectProjectFile);
75
77
m. addItem ('Save' , exportProjectToFile);
@@ -110,13 +112,16 @@ public class Designer extends Scratch {
110
112
m. addLine();
111
113
m. addItem ('Edit block colors' , editBlockColors);
112
114
115
+ m. addLine();
116
+ m. addItem ('Toggle Template Sprites Tab' , toggleTemplateSpritesTab);
117
+ m. addItem ('Toggle Global Tab' , toggleGlobalTab);
118
+ m. addItem ('Toggle Access Data By Strings blocks' , toggleAccessDataByStrings);
119
+
113
120
if (b . lastEvent. shiftKey ) {
114
121
m. addLine();
115
122
m. addItem ('Toggle FPS Counter' , toggleFPSCounter);
116
123
117
124
m. addItem ('Toggle Focus Area blocks' , toggleFocusAreaBlocks);
118
-
119
- m. addItem ('Toggle Global Tab' , toggleGlobalTab);
120
125
}
121
126
}
122
127
@@ -140,14 +145,28 @@ public class Designer extends Scratch {
140
145
Scratch. app. translationChanged();
141
146
}
142
147
148
+ protected function toggleAccessDataByStrings ():void {
149
+ if (app. showDataByStringBlocks) {
150
+ app. showDataByStringBlocks = false ;
151
+ } else {
152
+ app. showDataByStringBlocks = true ;
153
+ }
154
+
155
+ Scratch. app. translationChanged();
156
+ }
157
+
143
158
protected function toggleGlobalTab ():void {
144
159
tabsPart. toggleGlobalTab();
145
160
}
161
+
162
+ protected function toggleTemplateSpritesTab ():void {
163
+ libraryPart. toggleSpriteTemplateTabs();
164
+ }
146
165
147
166
override public function showAboutMenu (b :* ):void {
148
167
// Just display a dialog
149
168
DialogBox. notify(
150
- 'DevPro Game Snap v0.0.3 ' ,
169
+ 'DevPro Game Stack v0.8.0 ' ,
151
170
'\n Copyright © 2015 GarageGames LLC' +
152
171
'\n\n Based on Scratch from the MIT Media Laboratory' +
153
172
'\n under the GPL 2 license.' , stage );
@@ -182,14 +201,48 @@ public class Designer extends Scratch {
182
201
183
202
override protected function exportProjectToFile (fromJS :Boolean = false ):void {
184
203
function squeakSoundsConverted(): void {
204
+ // For Game Snap
205
+ function saveZipData(event: Event ): void {
206
+ var ext: String = '.stack' ;
207
+
208
+ //var newFile:File = event.target as File;
209
+ var tempArray: Array = File(event. target ). nativePath. split (File. separator);
210
+ var fileName: String = tempArray. pop (); // Remove last array item, which should be the file name
211
+ if (fileName. lastIndexOf (ext) == - 1 ) {
212
+ fileName += ext;
213
+ }
214
+
215
+ // Add back the file name
216
+ tempArray. push (fileName);
217
+
218
+ // Write!
219
+ var fs: FileStream = new FileStream();
220
+ var newFile: File = new File(tempArray. join (File. separator));
221
+ fs. open (newFile, FileMode. WRITE );
222
+ fs. writeBytes (zipData);
223
+ fs. close ();
224
+
225
+ if (! fromJS) setProjectName(fileName);
226
+
227
+ // Store the project's path
228
+ setProjectPath(event. target . nativePath);
229
+
230
+ clearSaveNeeded();
231
+
232
+ if (postExportAction != null ) {
233
+ postExportAction();
234
+ postExportAction = null ;
235
+ }
236
+ }
237
+
185
238
// Make sure everything is saved
186
239
scriptsPane. saveScripts(false );
187
240
188
241
// Make the default name
189
242
var projName: String = projectName();
190
243
projName = projName. replace (/ ^\s +|\s +$/ g , '' ); // Remove whitespace
191
244
//var defaultName:String = (projName.length > 0) ? projName + '.sb2' : 'project.sb2';
192
- var defaultName: String = (projName. length > 0 ) ? projName + '.snap ' : 'project.snap ' ;
245
+ var defaultName: String = (projName. length > 0 ) ? projName + '.stack ' : 'project.stack ' ;
193
246
194
247
// Get the project's binary file
195
248
var zipData: ByteArray = projIO. encodeProjectAsZipFile(stagePane);
@@ -215,11 +268,15 @@ public class Designer extends Scratch {
215
268
//showDebugDialog("exportProjectToFile", "Save File path: " + getProjectPath());
216
269
} else {
217
270
// Need to ask for a filename and path
218
- var file : File = new File();
219
- file . addEventListener (Event . COMPLETE , fileSaved);
220
- file . addEventListener (Event . CANCEL , fileError);
221
- file . addEventListener (flash. events . IOErrorEvent . IO_ERROR , fileError);
222
- file . save (zipData, fixFileName(defaultName));
271
+ //var file:File = new File();
272
+ //file.addEventListener(Event.COMPLETE, fileSaved);
273
+ //file.addEventListener(Event.CANCEL, fileError);
274
+ //file.addEventListener(flash.events.IOErrorEvent.IO_ERROR, fileError);
275
+ //file.save(zipData, fixFileName(defaultName));
276
+ var file : File = File. applicationStorageDirectory;
277
+ file = file . resolvePath(fixFileName(defaultName));
278
+ file . addEventListener (Event . SELECT , saveZipData);
279
+ file . browseForSave("Save As" );
223
280
}
224
281
}
225
282
function fileSaved(e: Event ): void {
@@ -282,6 +339,7 @@ public class Designer extends Scratch {
282
339
super . addParts();
283
340
284
341
//globalTabPart = new GlobalTabPart(this);
342
+ designTabPart = new DesignTabPart(this );
285
343
286
344
}
287
345
@@ -327,6 +385,9 @@ public class Designer extends Scratch {
327
385
} else if (tabName == 'sounds' ) {
328
386
soundsPart. refresh ();
329
387
show (soundsPart);
388
+ } else if (tabName == 'design' ) {
389
+ //designTabPart.refresh();
390
+ show (designTabPart);
330
391
} else if (tabName == 'global' ) {
331
392
scriptsPart. setGlobalTab(true );
332
393
@@ -367,6 +428,14 @@ public class Designer extends Scratch {
367
428
if (saveNeeded) setSaveNeeded(true ); // save project when switching tabs, if needed (but NOT while loading!)
368
429
}
369
430
431
+
432
+ override protected function updateContentArea (contentX :int , contentY :int , contentW :int , contentH :int , fullH :int ):void {
433
+ super . updateContentArea(contentX, contentY, contentW, contentH, fullH);
434
+ designTabPart. x = contentX;
435
+ designTabPart. y = contentY;
436
+ designTabPart. setWidthHeight(contentW, contentH);
437
+ }
438
+
370
439
// Get the project's native file path (including file name)
371
440
public function getProjectPath ():String {
372
441
return projectPath;
@@ -425,10 +494,12 @@ public class Designer extends Scratch {
425
494
// arguments and the current application path.
426
495
private function onAppInvoke ( event :InvokeEvent ):void {
427
496
var fileName: String , data : ByteArray ;
428
- function projectLoadComplete(event: Event ): void {
497
+ var filePath: String ;
498
+ function projectLoadComplete(fevent: Event ): void {
429
499
// File has been loaded and we have the data
430
500
data = invokedFile. data ;
431
- runtime. installProjectFromFile(fileName, data );
501
+ filePath = fevent. target . nativePath;
502
+ runtime. installProjectFromFile(fileName, filePath, data );
432
503
invokedFile = null ;
433
504
}
434
505
function projectLoadError(event: Event ): void {
@@ -447,7 +518,7 @@ public class Designer extends Scratch {
447
518
invokedFile = dir. resolvePath(event. arguments [ 0 ] );
448
519
var extension : String = invokedFile. extension ;
449
520
450
- if (extension == 'snap' || extension == 'sb2' || extension == 'sb' ) {
521
+ if (extension == 'stack' || extension == ' snap' || extension == 'sb2' || extension == 'sb' ) {
451
522
fileName = invokedFile. name ;
452
523
453
524
// We need to load in the file to retrieve its data
0 commit comments