@@ -28,6 +28,7 @@ import flixel.util.FlxColor;
2828class Charter extends UIState {
2929 public static var __song : String ;
3030 static var __diff : String ;
31+ static var __variant : String ;
3132 static var __reload : Bool ;
3233
3334 var chart (get , never ): ChartData ;
@@ -114,11 +115,12 @@ class Charter extends UIState {
114115 private var SONGPOSINFO_BPM = TU .getRaw (" songPosInfo.bpm" );
115116 private var SONGPOSINFO_TIMESIGNATURE = TU .getRaw (" songPosInfo.timeSignature" );
116117
117- public function new (song : String , diff : String , reload : Bool = true ) {
118+ public function new (song : String , diff : String , variant : String , reload : Bool = true ) {
118119 super ();
119120 if (song != null ) {
120121 __song = song ;
121122 __diff = diff ;
123+ __variant = variant ;
122124 __reload = reload ;
123125 }
124126 }
@@ -578,7 +580,7 @@ class Charter extends UIState {
578580 dataDisplay.screenCenter(Y);
579581 dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);*/
580582
581- DiscordUtil .call (" onEditorLoaded" , [" Chart Editor" , __song + " (" + __diff + " )" ]);
583+ DiscordUtil .call (" onEditorLoaded" , [" Chart Editor" , __song + " (" + __diff + " )" + ( __variant != null && __variant != " " ? " ( " + __variant + " ) " : " " ) ]);
582584 }
583585
584586 override function destroy () {
@@ -595,7 +597,7 @@ class Charter extends UIState {
595597 public function loadSong () {
596598 if (__reload ) {
597599 EventsData .reloadEvents ();
598- PlayState .loadSong (__song , __diff , false , false );
600+ PlayState .loadSong (__song , __diff , __variant , false , false );
599601 __resetStatics ();
600602 }
601603 Conductor .setupSong (PlayState .SONG );
@@ -788,12 +790,13 @@ class Charter extends UIState {
788790 autoSaveTimer = Options .charterAutoSaveTime ;
789791 if (! autoSaveNotif .cancelled ) {
790792 buildChart ();
791- var songPath : String = ' ${Paths .getAssetsRoot ()}/songs/ ${__song .toLowerCase ()}' ;
792793
793794 if (Options .charterAutoSavesSeparateFolder )
794- Chart .save (songPath , PlayState .SONG , __autoSaveLocation , {saveMetaInChart : true , saveLocalEvents : true , saveGlobalEvents : true , folder : " autosaves" , prettyPrint : Options .editorCharterPrettyPrint });
795- else // These two chart saves are particular, to avoid any kind of loss, stuff like meta, global and local events will be save all together - Nex
796- Chart .save (songPath , PlayState .SONG , __diff .toLowerCase (), {saveMetaInChart : true , saveLocalEvents : true , saveGlobalEvents : true , prettyPrint : Options .editorCharterPrettyPrint });
795+ Chart .save (PlayState .SONG , __diff .toLowerCase (), __autoSaveLocation , {saveMetaInChart : true , saveLocalEvents : true , seperateGlobalEvents : true , folder : ' autosaves' , prettyPrint : Options .editorCharterPrettyPrint });
796+ else
797+ Chart .save (PlayState .SONG , __diff .toLowerCase (), __variant , {saveMetaInChart : true , saveLocalEvents : true , seperateGlobalEvents : true , prettyPrint : Options .editorCharterPrettyPrint });
798+
799+ FlxG .sound .play (Paths .sound (' editors/save' ));
797800 undos .save ();
798801 }
799802 autoSaveNotif .cancelled = false ;
@@ -1476,8 +1479,8 @@ class Charter extends UIState {
14761479
14771480 public static function saveChart (shouldBuild : Bool = true , withEvents : Bool = true ) {
14781481 #if sys
1479- FlxG . sound . play ( Paths . sound ( ' editors/save ' ) );
1480- saveTo ( ' ${ Paths . getAssetsRoot ()} /songs/ ${ __song . toLowerCase ()} ' , ! withEvents , shouldBuild );
1482+ if ( shouldBuild && instance != null ) instance . buildChart ( );
1483+ Chart . save ( PlayState . SONG , __diff . toLowerCase (), __variant , { saveMetaInChart : false , saveLocalEvents : withEvents , prettyPrint : Options . editorCharterPrettyPrint } );
14811484 if (undos != null ) undos .save ();
14821485 #else
14831486 saveChartAs (shouldBuild , withEvents );
@@ -1493,21 +1496,17 @@ class Charter extends UIState {
14931496
14941497 public static function saveEvents (shouldBuild : Bool = true ) {
14951498 #if sys
1496- FlxG .sound .play (Paths .sound (' editors/save' ));
14971499 if (shouldBuild && instance != null ) instance .buildChart ();
1498- var data = {events : Chart .filterChartForSaving (PlayState .SONG , false , false , true ).events };
1499-
1500- var path = ' ${Paths .getAssetsRoot ()}/songs/ ${__song .toLowerCase ()}/events.json' ;
1501- if (data .events != null && data .events .length > 0 ) CoolUtil .safeSaveFile (path , Json .stringify (data , null , Options .editorCharterPrettyPrint ? Flags .JSON_PRETTY_PRINT : null ));
1502- else if (FileSystem .exists (path )) FileSystem .deleteFile (path ); // Instead of replacing with a useless empty file, deletes the file directly - Nex
1500+ Chart .save (PlayState .SONG , __diff .toLowerCase (), __variant , {saveChart : false , seperateGlobalEvents : true , prettyPrint : Options .editorCharterPrettyPrint });
1501+ if (undos != null ) undos .save ();
15031502 #else
15041503 saveEventsAs (shouldBuild );
15051504 #end
15061505 }
15071506
15081507 public static function saveEventsAs (shouldBuild : Bool = true ) {
15091508 if (shouldBuild && instance != null ) instance .buildChart ();
1510- var data = {events : Chart .filterChartForSaving (PlayState .SONG , false , false , true ). events };
1509+ var data = {events : Chart .filterEventsForSaving (PlayState .SONG . events , false , true )};
15111510
15121511 saveAs (data , null , Options .editorCharterPrettyPrint ? Flags .JSON_PRETTY_PRINT : null , {
15131512 defaultSaveFile : ' events.json'
@@ -1516,12 +1515,8 @@ class Charter extends UIState {
15161515
15171516 public static function saveMeta (shouldBuild : Bool = true ) {
15181517 #if sys
1519- FlxG .sound .play (Paths .sound (' editors/save' ));
15201518 if (shouldBuild && instance != null ) instance .buildChart ();
1521- CoolUtil .safeSaveFile (
1522- ' ${Paths .getAssetsRoot ()}/songs/ ${__song .toLowerCase ()}/meta.json' ,
1523- Json .stringify (PlayState .SONG .meta == null ? {} : Chart .filterChartForSaving (PlayState .SONG , true , false , false ).meta , null , Flags .JSON_PRETTY_PRINT )
1524- );
1519+ Chart .save (PlayState .SONG , __diff .toLowerCase (), __variant , {saveChart : false , overrideExistingMeta : true , prettyPrint : true });
15251520 #else
15261521 saveMetaAs (shouldBuild );
15271522 #end
@@ -1545,9 +1540,7 @@ class Charter extends UIState {
15451540 }, null , shouldBuild );
15461541 }
15471542
1548- public static function saveAs (data : Dynamic , ? replacer : (key : Dynamic , value : Dynamic ) -> Dynamic , ? space : String , ? options : SaveSubstate . SaveSubstateData , ? saveOptions : Map <String , Bool >, shouldBuild : Bool = true ) {
1549- FlxG .sound .play (Paths .sound (' editors/save' ));
1550- if (shouldBuild && instance != null ) instance .buildChart ();
1543+ public static function saveAs (data : Dynamic , ? replacer : (key : Dynamic , value : Dynamic ) -> Dynamic , ? space : String , ? options : SaveSubstate . SaveSubstateData , ? saveOptions : Map <String , Bool >, shouldBuild : Bool = true ) { if (shouldBuild && instance != null ) instance .buildChart ();
15511544 var cur = FlxG .state ;
15521545 while (true ) {
15531546 if (instance != null || cur .subState == null ) return cur .openSubState (new SaveSubstate (Json .stringify (data , replacer , space ), options , saveOptions ));
@@ -1558,7 +1551,7 @@ class Charter extends UIState {
15581551 #if sys
15591552 public static function saveTo (path : String , separateEvents : Bool = false , shouldBuild : Bool = true ) {
15601553 if (shouldBuild && instance != null ) instance .buildChart ();
1561- Chart .save (path , PlayState .SONG , __diff .toLowerCase (), {saveMetaInChart : false , saveLocalEvents : ! separateEvents , prettyPrint : Options .editorCharterPrettyPrint });
1554+ Chart .save (PlayState .SONG , __diff .toLowerCase (), __variant , {saveMetaInChart : false , saveLocalEvents : ! separateEvents , songFolder : path , prettyPrint : Options .editorCharterPrettyPrint });
15621555 }
15631556 #end
15641557 #end
@@ -1570,17 +1563,17 @@ class Charter extends UIState {
15701563 else {undos = null ; FlxG .switchState (new CharterSelection ()); Charter .instance .__clearStatics ();}
15711564 }
15721565
1573- function _file_save_all (_ ) saveEverything ();
1574- function _file_save (_ ) saveChart ();
1575- function _file_saveas (_ ) saveChartAs ();
1576- function _file_events_save (_ ) saveEvents ();
1577- function _file_events_saveas (_ ) saveEventsAs ();
1578- function _file_save_no_events (_ ) saveChart (true , false );
1579- function _file_saveas_no_events (_ ) saveChartAs (true , false );
1580- function _file_meta_save (_ ) saveMeta ();
1581- function _file_meta_saveas (_ ) saveMetaAs ();
1582- function _file_saveas_fnflegacy (_ ) saveLegacyChartAs ();
1583- function _file_saveas_psych (_ ) savePsychChartAs ();
1566+ function _file_save_all (_ ) { saveEverything (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1567+ function _file_save (_ ) { saveChart (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1568+ function _file_saveas (_ ) { saveChartAs (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1569+ function _file_events_save (_ ) { saveEvents (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1570+ function _file_events_saveas (_ ) { saveEventsAs (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1571+ function _file_save_no_events (_ ) { saveChart (true , false ); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1572+ function _file_saveas_no_events (_ ) { saveChartAs (true , false ); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1573+ function _file_meta_save (_ ) { saveMeta (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1574+ function _file_meta_saveas (_ ) { saveMetaAs (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1575+ function _file_saveas_fnflegacy (_ ) { saveLegacyChartAs (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
1576+ function _file_saveas_psych (_ ) { savePsychChartAs (); FlxG . sound . play ( Paths . sound ( ' editors/save ' ));}
15841577
15851578 function _edit_copy (_ , playSFX = true ) {
15861579 if (playSFX ) FlxG .sound .play (Paths .sound (Flags .DEFAULT_EDITOR_COPY_SOUND ));
0 commit comments