@@ -31,9 +31,7 @@ class AseSyncSprite {
3131 }
3232 return result ;
3333 }
34- public static function sync (asePath : String ) {
35- var name = (new Path (asePath )).file ;
36- Sys .println (' Syncing $name ( $asePath )...' );
34+ static function sync_1 (asePath : String , tmp : String , name : String , aseData : AseData , keys : Array <String >, tmpOffset : Int ) {
3735 var yyDir = ' $projectDir /sprites/ $name ' ;
3836 var yyPath = ' $yyDir / $name .yy' ;
3937 var yyRel = ' sprites/ $name / $name .yy' ;
@@ -95,23 +93,6 @@ class AseSyncSprite {
9593 });
9694 }
9795
98- var tmp = ' tmp/ $name ' ;
99- if (! FileSystem .exists (tmp )) FileSystem .createDirectory (tmp );
100- Sys .command (asepritePath , [
101- " -b" ,
102- " --data" , ' $tmp /data.json' ,
103- asePath ,
104- " --save-as" , ' $tmp /0.png' ,
105- ]);
106-
107- var aseData : AseData = {
108- var _storeKeys = YyJsonParser .storeKeys ;
109- YyJsonParser .storeKeys = true ;
110- var _aseData = YyJsonParser .parse (File .getContent (' $tmp /data.json' ));
111- YyJsonParser .storeKeys = _storeKeys ;
112- _aseData ;
113- };
114- var keys : Array <String > = cast aseData .frames [" __keys__" ];
11596 var aseSize = aseData .frames [keys [0 ]].sourceSize ;
11697 var aseWidth = aseSize .w ;
11798 var aseHeight = aseSize .h ;
@@ -204,7 +185,8 @@ class AseSyncSprite {
204185 kf. Length = dur ;
205186 save = true ;
206187 }
207- var src = ' $tmp / $i .png' ;
188+ var tmpInd = tmpOffset + i ;
189+ var src = ' $tmp / $tmpInd .png' ;
208190 var dstName = sf .compositeImage != null ? sf.compositeImage. FrameId .name : sf .name ;
209191 var dst = yyDir + " /" + dstName + " .png" ;
210192 if (! FileTools .compare (src , dst )) {
@@ -236,5 +218,36 @@ class AseSyncSprite {
236218 File .saveContent (yyPath , YyJson .stringify (spr ));
237219 }
238220 }
221+ public static function sync (asePath : String ) {
222+ var name = (new Path (asePath )).file ;
223+ Sys .println (' Syncing $name ( $asePath )...' );
224+
225+ var tmp = ' tmp/ $name ' ;
226+ if (! FileSystem .exists (tmp )) FileSystem .createDirectory (tmp );
227+ Sys .command (asepritePath , [
228+ " -b" ,
229+ " --list-tags" ,
230+ " --data" , ' $tmp /data.json' ,
231+ asePath ,
232+ " --save-as" , ' $tmp /0.png' ,
233+ ]);
234+
235+ var aseData : AseData = {
236+ var _storeKeys = YyJsonParser .storeKeys ;
237+ YyJsonParser .storeKeys = true ;
238+ var _aseData = YyJsonParser .parse (File .getContent (' $tmp /data.json' ));
239+ YyJsonParser .storeKeys = _storeKeys ;
240+ _aseData ;
241+ };
242+ var keys : Array <String > = cast aseData .frames [" __keys__" ];
243+
244+ var tags = aseData .meta .frameTags ?? [];
245+ if (tags .length == 0 ) {
246+ sync_1 (asePath , tmp , name , aseData , keys , 0 );
247+ } else for (tag in tags ) {
248+ var tname = tag .name == " " ? name : name + " _" + tag .name ;
249+ sync_1 (asePath , tmp , tname , aseData , keys .slice (tag .from , tag .to + 1 ), tag .from );
250+ }
251+ }
239252
240253}
0 commit comments