making sure everything gets saved
did i just see a fucking indiecross bf uploaded😭
This commit is contained in:
@@ -118,7 +118,7 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
WindowUtils.suffix = " (Chart Editor)";
|
WindowUtils.suffix = " (Chart Editor)";
|
||||||
SaveWarning.selectionClass = CharterSelection;
|
SaveWarning.selectionClass = CharterSelection;
|
||||||
SaveWarning.saveFunc = () -> _file_save_all(null);
|
SaveWarning.saveFunc = () -> saveEverything();
|
||||||
|
|
||||||
topMenu = [
|
topMenu = [
|
||||||
{
|
{
|
||||||
@@ -137,49 +137,49 @@ class Charter extends UIState {
|
|||||||
{
|
{
|
||||||
label: "Save chart",
|
label: "Save chart",
|
||||||
keybind: [CONTROL, SHIFT, S],
|
keybind: [CONTROL, SHIFT, S],
|
||||||
onSelect: (_) -> _file_save(),
|
onSelect: _file_save,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save chart as...",
|
label: "Save chart as...",
|
||||||
onSelect: (_) -> _file_saveas(),
|
onSelect: _file_saveas,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
label: "Save global events",
|
label: "Save global events",
|
||||||
keybind: [CONTROL, B, S],
|
keybind: [CONTROL, B, S],
|
||||||
onSelect: (_) -> _file_events_save(),
|
onSelect: _file_events_save,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save global events as...",
|
label: "Save global events as...",
|
||||||
onSelect: (_) -> _file_events_saveas(),
|
onSelect: _file_events_saveas,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save chart without local events",
|
label: "Save chart without local events",
|
||||||
keybind: [CONTROL, ALT, S],
|
keybind: [CONTROL, ALT, S],
|
||||||
onSelect: (_) -> _file_save_no_events(),
|
onSelect: _file_save_no_events,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save chart without local events as...",
|
label: "Save chart without local events as...",
|
||||||
onSelect: (_) -> _file_saveas_no_events(),
|
onSelect: _file_saveas_no_events,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
label: "Save meta",
|
label: "Save meta",
|
||||||
keybind: [CONTROL, M, S],
|
keybind: [CONTROL, M, S],
|
||||||
onSelect: (_) -> _file_meta_save(),
|
onSelect: _file_meta_save,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save meta as...",
|
label: "Save meta as...",
|
||||||
onSelect: (_) -> _file_meta_saveas(),
|
onSelect: _file_meta_saveas,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
label: "Export for FNF Legacy as...",
|
label: "Export for FNF Legacy as...",
|
||||||
onSelect: (_) -> _file_saveas_fnflegacy(),
|
onSelect: _file_saveas_fnflegacy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Export for Psych Engine as...",
|
label: "Export for Psych Engine as...",
|
||||||
onSelect: (_) -> _file_saveas_psych(),
|
onSelect: _file_saveas_psych,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
@@ -708,7 +708,7 @@ class Charter extends UIState {
|
|||||||
name: 'Voices${strumLine.strumLine.vocalsSuffix}.ogg',
|
name: 'Voices${strumLine.strumLine.vocalsSuffix}.ogg',
|
||||||
sound: strumLine.vocals
|
sound: strumLine.vocals
|
||||||
});
|
});
|
||||||
|
|
||||||
return wavesToGenerate;
|
return wavesToGenerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1460,51 +1460,46 @@ class Charter extends UIState {
|
|||||||
return sideScroll = FlxMath.bound(val, -(40*strumLines.totalKeyCount) / 2, (40*strumLines.totalKeyCount) / 2);
|
return sideScroll = FlxMath.bound(val, -(40*strumLines.totalKeyCount) / 2, (40*strumLines.totalKeyCount) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOP MENU OPTIONS
|
// SAVE FUNCS
|
||||||
#if REGION
|
#if REGION
|
||||||
function _file_exit(_) {
|
public static function saveEverything(shouldBuild:Bool = true) {
|
||||||
if (undos.unsaved) SaveWarning.triggerWarning();
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();}
|
saveChart(false);
|
||||||
|
saveEvents(false);
|
||||||
|
saveMeta(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_save_all(_) {
|
public static function saveChart(shouldBuild:Bool = true, withEvents:Bool = true) {
|
||||||
buildChart();
|
|
||||||
_file_save(false);
|
|
||||||
_file_events_save(false);
|
|
||||||
_file_meta_save(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _file_save(shouldBuild:Bool = true) {
|
|
||||||
#if sys
|
#if sys
|
||||||
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', false, shouldBuild);
|
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', !withEvents, shouldBuild);
|
||||||
undos.save();
|
if (undos != null) undos.save();
|
||||||
#else
|
#else
|
||||||
_file_saveas(shouldBuild);
|
saveChartAs(shouldBuild, withEvents);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas(shouldBuild:Bool = true) {
|
public static function saveChartAs(shouldBuild:Bool = true, withEvents:Bool = true) {
|
||||||
saveAs(Chart.filterChartForSaving(PlayState.SONG, false, true, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
saveAs(Chart.filterChartForSaving(PlayState.SONG, false, withEvents, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
||||||
}, null, shouldBuild);
|
}, null, shouldBuild);
|
||||||
undos.save();
|
if (undos != null) undos.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_events_save(shouldBuild:Bool = true) {
|
public static function saveEvents(shouldBuild:Bool = true) {
|
||||||
#if sys
|
#if sys
|
||||||
if (shouldBuild) buildChart();
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
||||||
|
|
||||||
var path = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json';
|
var path = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json';
|
||||||
if (FileSystem.exists(path) && (data.events == null || data.events.length == 0)) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex
|
if (data.events != null && data.events.length > 0) CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null));
|
||||||
else CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null));
|
else if (FileSystem.exists(path)) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex
|
||||||
#else
|
#else
|
||||||
_file_events_saveas(shouldBuild);
|
saveEventsAs(shouldBuild);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_events_saveas(shouldBuild:Bool = true) {
|
public static function saveEventsAs(shouldBuild:Bool = true) {
|
||||||
if (shouldBuild) buildChart();
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
||||||
|
|
||||||
saveAs(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
saveAs(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
@@ -1512,63 +1507,71 @@ class Charter extends UIState {
|
|||||||
}, null, false);
|
}, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_save_no_events(shouldBuild:Bool = true) {
|
public static function saveMeta(shouldBuild:Bool = true) {
|
||||||
#if sys
|
#if sys
|
||||||
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', true, shouldBuild);
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
undos.save();
|
|
||||||
#else
|
|
||||||
_file_saveas(shouldBuild);
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
function _file_saveas_no_events(shouldBuild:Bool = true) {
|
|
||||||
saveAs(Chart.filterChartForSaving(PlayState.SONG, false, false, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
|
||||||
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
|
||||||
}, null, shouldBuild);
|
|
||||||
undos.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _file_meta_save(shouldBuild:Bool = true) {
|
|
||||||
#if sys
|
|
||||||
if (shouldBuild) buildChart();
|
|
||||||
CoolUtil.safeSaveFile(
|
CoolUtil.safeSaveFile(
|
||||||
'${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json',
|
'${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json',
|
||||||
Json.stringify(PlayState.SONG.meta == null ? {} : Chart.filterChartForSaving(PlayState.SONG, true, false, false).meta, null, Flags.JSON_PRETTY_PRINT)
|
Json.stringify(PlayState.SONG.meta == null ? {} : Chart.filterChartForSaving(PlayState.SONG, true, false, false).meta, null, Flags.JSON_PRETTY_PRINT)
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
_file_meta_saveas(shouldBuild);
|
saveMetaAs(shouldBuild);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_meta_saveas(shouldBuild:Bool = true) {
|
public static function saveMetaAs(shouldBuild:Bool = true) {
|
||||||
saveAs(PlayState.SONG.meta == null ? {} : Chart.filterChartForSaving(PlayState.SONG, true, false, false).meta, null, Flags.JSON_PRETTY_PRINT, { // always pretty print meta
|
saveAs(PlayState.SONG.meta == null ? {} : Chart.filterChartForSaving(PlayState.SONG, true, false, false).meta, null, Flags.JSON_PRETTY_PRINT, { // always pretty print meta
|
||||||
defaultSaveFile: 'meta.json'
|
defaultSaveFile: 'meta.json'
|
||||||
}, null, shouldBuild);
|
}, null, shouldBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas_fnflegacy(shouldBuild:Bool = true) {
|
public static function saveLegacyChartAs(shouldBuild:Bool = true) {
|
||||||
saveAs(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
saveAs(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json',
|
defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json',
|
||||||
}, null, shouldBuild);
|
}, null, shouldBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas_psych(shouldBuild:Bool = true) {
|
public static function savePsychChartAs(shouldBuild:Bool = true) {
|
||||||
saveAs(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
saveAs(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json',
|
defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == Flags.DEFAULT_DIFFICULTY ? "" : '-${__diff.toLowerCase()}'}.json',
|
||||||
}, null, shouldBuild);
|
}, null, shouldBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveAs(data:Dynamic, ?replacer:(key:Dynamic, value:Dynamic) -> Dynamic, ?space:String, ?options:SaveSubstate.SaveSubstateData, ?saveOptions:Map<String, Bool>, shouldBuild:Bool = true) {
|
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) buildChart();
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
openSubState(new SaveSubstate(Json.stringify(data, replacer, space), options, saveOptions));
|
var cur = FlxG.state;
|
||||||
|
while(true) {
|
||||||
|
if (cur.subState != null) cur = cur.subState;
|
||||||
|
else return cur.openSubState(new SaveSubstate(Json.stringify(data, replacer, space), options, saveOptions));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if sys
|
#if sys
|
||||||
function saveTo(path:String, separateEvents:Bool = false, shouldBuild:Bool = true) {
|
public static function saveTo(path:String, separateEvents:Bool = false, shouldBuild:Bool = true) {
|
||||||
if (shouldBuild) buildChart();
|
if (shouldBuild && instance != null) instance.buildChart();
|
||||||
Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveLocalEvents: !separateEvents, prettyPrint: Options.editorPrettyPrint});
|
Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveLocalEvents: !separateEvents, prettyPrint: Options.editorPrettyPrint});
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
// TOP MENU OPTIONS
|
||||||
|
#if REGION
|
||||||
|
function _file_exit(_) {
|
||||||
|
if (undos.unsaved) SaveWarning.triggerWarning();
|
||||||
|
else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _file_save_all(_) saveEverything();
|
||||||
|
function _file_save(_) saveChart();
|
||||||
|
function _file_saveas(_) saveChartAs();
|
||||||
|
function _file_events_save(_) saveEvents();
|
||||||
|
function _file_events_saveas(_) saveEventsAs();
|
||||||
|
function _file_save_no_events(_) saveChart(true, false);
|
||||||
|
function _file_saveas_no_events(_) saveChartAs(true, false);
|
||||||
|
function _file_meta_save(_) saveMeta();
|
||||||
|
function _file_meta_saveas(_) saveMetaAs();
|
||||||
|
function _file_saveas_fnflegacy(_) saveLegacyChartAs();
|
||||||
|
function _file_saveas_psych(_) savePsychChartAs();
|
||||||
|
|
||||||
function _edit_copy(_) {
|
function _edit_copy(_) {
|
||||||
if(selection.length == 0) return;
|
if(selection.length == 0) return;
|
||||||
|
|||||||
@@ -826,10 +826,7 @@ class PlayState extends MusicBeatState
|
|||||||
SaveWarning.showWarning = Charter.undos.unsaved;
|
SaveWarning.showWarning = Charter.undos.unsaved;
|
||||||
SaveWarning.selectionClass = CharterSelection;
|
SaveWarning.selectionClass = CharterSelection;
|
||||||
SaveWarning.warningFunc = saveWarn;
|
SaveWarning.warningFunc = saveWarn;
|
||||||
SaveWarning.saveFunc = () -> {
|
SaveWarning.saveFunc = () -> Charter.saveEverything(false);
|
||||||
@:privateAccess Chart.save('${Paths.getAssetsRoot()}/songs/${Charter.__song.toLowerCase()}',
|
|
||||||
SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user