finished global/local events + HUGE SAVES FIX
HOW DID WE NEVER NOTICE?? anyways im really happy on how everything came out :D more than a fix it also ended up like a rewrite!
This commit is contained in:
@@ -134,6 +134,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
|||||||
{
|
{
|
||||||
frames = Paths.getFrames(path, true);
|
frames = Paths.getFrames(path, true);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPropertySet(property:String, value:Dynamic) {
|
public function onPropertySet(property:String, value:Dynamic) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import funkin.backend.scripting.events.ResizeEvent;
|
|||||||
import funkin.backend.scripting.events.TransitionCreationEvent;
|
import funkin.backend.scripting.events.TransitionCreationEvent;
|
||||||
import funkin.backend.utils.FunkinParentDisabler;
|
import funkin.backend.utils.FunkinParentDisabler;
|
||||||
import funkin.editors.ui.UIState;
|
import funkin.editors.ui.UIState;
|
||||||
|
|
||||||
class MusicBeatTransition extends MusicBeatSubstate {
|
class MusicBeatTransition extends MusicBeatSubstate {
|
||||||
public static var script:String = Flags.DEFAULT_TRANSITION_SCRIPT;
|
public static var script:String = Flags.DEFAULT_TRANSITION_SCRIPT;
|
||||||
public var transitionScript:Script;
|
public var transitionScript:Script;
|
||||||
@@ -55,8 +56,7 @@ class MusicBeatTransition extends MusicBeatSubstate {
|
|||||||
|
|
||||||
add(blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1));
|
add(blackSpr = new FlxSprite(0, transOut ? -transitionCamera.height : transitionCamera.height).makeGraphic(1, 1, -1));
|
||||||
blackSpr.color = 0xFF000000;
|
blackSpr.color = 0xFF000000;
|
||||||
add(transitionSprite = new FunkinSprite());
|
add(transitionSprite = new FunkinSprite().loadSprite(Paths.image('menus/transitionSpr')));
|
||||||
transitionSprite.loadSprite(Paths.image('menus/transitionSpr'));
|
|
||||||
resizeDefaultSprites();
|
resizeDefaultSprites();
|
||||||
|
|
||||||
transitionCamera.flipY = !transOut;
|
transitionCamera.flipY = !transOut;
|
||||||
|
|||||||
@@ -77,9 +77,8 @@ class Chart {
|
|||||||
if (Assets.exists(path)) {
|
if (Assets.exists(path)) {
|
||||||
try {
|
try {
|
||||||
data = Json.parse(Assets.getText(path)).events;
|
data = Json.parse(Assets.getText(path)).events;
|
||||||
} catch(e) {
|
for (event in data) event.global = true;
|
||||||
Logs.trace('Failed to load song event data for ${songName} ($path): ${Std.string(e)}', ERROR);
|
} catch(e) Logs.trace('Failed to load song event data for ${songName} ($path): ${Std.string(e)}', ERROR);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -259,9 +258,10 @@ class Chart {
|
|||||||
if (saveSettings == null) saveSettings = {};
|
if (saveSettings == null) saveSettings = {};
|
||||||
|
|
||||||
if (saveSettings.saveMetaInChart == null) saveSettings.saveMetaInChart = true;
|
if (saveSettings.saveMetaInChart == null) saveSettings.saveMetaInChart = true;
|
||||||
if (saveSettings.saveEventsInChart == null) saveSettings.saveEventsInChart = true;
|
if (saveSettings.saveLocalEvents == null) saveSettings.saveLocalEvents = true;
|
||||||
|
if (saveSettings.saveGlobalEvents == null) saveSettings.saveGlobalEvents = false;
|
||||||
|
|
||||||
var filteredChart = filterChartForSaving(chart, saveSettings.saveMetaInChart, saveSettings.saveEventsInChart);
|
var filteredChart = filterChartForSaving(chart, saveSettings.saveMetaInChart, saveSettings.saveLocalEvents, saveSettings.saveGlobalEvents);
|
||||||
var meta = filteredChart.meta;
|
var meta = filteredChart.meta;
|
||||||
|
|
||||||
#if sys
|
#if sys
|
||||||
@@ -282,16 +282,26 @@ class Chart {
|
|||||||
return filteredChart;
|
return filteredChart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function filterChartForSaving(chart:ChartData, ?saveMetaInChart:Null<Bool>, ?saveEventsInChart:Null<Bool>):ChartData {
|
public static function filterChartForSaving(chart:ChartData, ?saveMetaInChart:Bool, ?saveLocalEvents:Bool, ?saveGlobalEvents:Bool):ChartData {
|
||||||
var data = Reflect.copy(chart); // make a copy of the chart to leave the OG intact
|
var data = Reflect.copy(chart); // make a copy of the chart to leave the OG intact
|
||||||
if (saveMetaInChart != true) {
|
if (saveMetaInChart != true) {
|
||||||
data.meta = null;
|
data.meta = null;
|
||||||
} else {
|
} else {
|
||||||
data.meta = Reflect.copy(chart.meta); // also make a copy of the metadata to leave the OG intact.
|
data.meta = Reflect.copy(chart.meta); // also make a copy of the metadata to leave the OG intact.
|
||||||
if(data.meta != null && Reflect.hasField(data.meta, "parsedColor")) Reflect.deleteField(data.meta, "parsedColor");
|
if (data.meta != null && Reflect.hasField(data.meta, "parsedColor")) Reflect.deleteField(data.meta, "parsedColor");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveLocalEvents != true && saveGlobalEvents != true) data.events = null;
|
||||||
|
else {
|
||||||
|
data.events = [];
|
||||||
|
for (event in chart.events) if ((saveLocalEvents == true && event.global != true) || (saveGlobalEvents == true && event.global == true)) {
|
||||||
|
var copy = Reflect.copy(event);
|
||||||
|
if (saveLocalEvents == true ? event.global != true : event.global == true) Reflect.deleteField(copy, "global"); // should NOT delete the field when saving with the local events and the event should have been global - Nex
|
||||||
|
data.events.push(copy);
|
||||||
|
}
|
||||||
|
if (data.events.length == 0) data.events = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.events = saveEventsInChart != true ? null : Reflect.copy(chart.events); // same here once again
|
|
||||||
data.fromMods = null;
|
data.fromMods = null;
|
||||||
|
|
||||||
var sortedData:Dynamic = {};
|
var sortedData:Dynamic = {};
|
||||||
@@ -307,7 +317,8 @@ class Chart {
|
|||||||
typedef ChartSaveSettings = {
|
typedef ChartSaveSettings = {
|
||||||
var ?overrideExistingMeta:Bool;
|
var ?overrideExistingMeta:Bool;
|
||||||
var ?saveMetaInChart:Bool;
|
var ?saveMetaInChart:Bool;
|
||||||
var ?saveEventsInChart:Bool;
|
var ?saveLocalEvents:Bool;
|
||||||
|
var ?saveGlobalEvents:Bool;
|
||||||
var ?prettyPrint:Bool;
|
var ?prettyPrint:Bool;
|
||||||
var ?folder:String;
|
var ?folder:String;
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,7 @@ typedef ChartEvent = {
|
|||||||
var name:String;
|
var name:String;
|
||||||
var time:Float;
|
var time:Float;
|
||||||
var params:Array<Dynamic>;
|
var params:Array<Dynamic>;
|
||||||
|
var ?global:Bool; // If its from a global event file like events.json; this field might be saved rarely in the chart json directly but modders can mess with this for messing with the saving funcs too - Nex
|
||||||
}
|
}
|
||||||
|
|
||||||
enum abstract ChartStrumLineType(Int) from Int to Int {
|
enum abstract ChartStrumLineType(Int) from Int to Int {
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
package funkin.editors.charter;
|
package funkin.editors.charter;
|
||||||
// ! FUCK YOU CHUF (your biggest fan -lunar) <3
|
// ! FUCK YOU CHUF (your biggest fan -lunar) <3
|
||||||
|
|
||||||
//import flixel.FlxLayer;
|
// import flixel.FlxLayer;
|
||||||
import funkin.editors.charter.CharterEvent;
|
|
||||||
import funkin.editors.extra.CameraHoverDummy;
|
|
||||||
import flixel.input.keyboard.FlxKey;
|
import flixel.input.keyboard.FlxKey;
|
||||||
import flixel.math.FlxPoint;
|
import flixel.math.FlxPoint;
|
||||||
import flixel.sound.FlxSound;
|
import flixel.sound.FlxSound;
|
||||||
|
import flixel.util.FlxSort;
|
||||||
import funkin.backend.chart.*;
|
import funkin.backend.chart.*;
|
||||||
import funkin.backend.chart.ChartData;
|
import funkin.backend.chart.ChartData;
|
||||||
import funkin.backend.system.Conductor;
|
import funkin.backend.system.Conductor;
|
||||||
import funkin.backend.system.framerate.Framerate;
|
import funkin.backend.system.framerate.Framerate;
|
||||||
import funkin.editors.charter.CharterBackdropGroup.EventBackdrop;
|
import funkin.editors.charter.CharterBackdropGroup.EventBackdrop;
|
||||||
|
import funkin.editors.charter.CharterEvent;
|
||||||
import funkin.editors.charter.CharterStrumline;
|
import funkin.editors.charter.CharterStrumline;
|
||||||
|
import funkin.editors.extra.CameraHoverDummy;
|
||||||
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
|
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
|
||||||
import funkin.editors.ui.UIContextMenu.UIContextMenuOptionSpr;
|
import funkin.editors.ui.UIContextMenu.UIContextMenuOptionSpr;
|
||||||
import funkin.editors.ui.UIState;
|
import funkin.editors.ui.UIState;
|
||||||
import funkin.editors.ui.UITopMenu.UITopMenuButton;
|
import funkin.editors.ui.UITopMenu.UITopMenuButton;
|
||||||
import haxe.Json;
|
import haxe.Json;
|
||||||
|
#if sys
|
||||||
|
import sys.FileSystem;
|
||||||
|
#end
|
||||||
|
|
||||||
class Charter extends UIState {
|
class Charter extends UIState {
|
||||||
public static var __song:String;
|
public static var __song:String;
|
||||||
@@ -110,7 +114,7 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
WindowUtils.suffix = " (Chart Editor)";
|
WindowUtils.suffix = " (Chart Editor)";
|
||||||
SaveWarning.selectionClass = CharterSelection;
|
SaveWarning.selectionClass = CharterSelection;
|
||||||
SaveWarning.saveFunc = () -> {_file_save(null);};
|
SaveWarning.saveFunc = () -> _file_save_all(null);
|
||||||
|
|
||||||
topMenu = [
|
topMenu = [
|
||||||
{
|
{
|
||||||
@@ -121,55 +125,57 @@ class Charter extends UIState {
|
|||||||
},
|
},
|
||||||
null,*/
|
null,*/
|
||||||
{
|
{
|
||||||
label: "Save",
|
label: "Save everything",
|
||||||
keybind: [CONTROL, S],
|
keybind: [CONTROL, S],
|
||||||
onSelect: _file_save,
|
onSelect: _file_save_all,
|
||||||
},
|
},
|
||||||
|
null,
|
||||||
{
|
{
|
||||||
label: "Save As...",
|
label: "Save chart",
|
||||||
keybind: [CONTROL, SHIFT, S],
|
keybind: [CONTROL, SHIFT, S],
|
||||||
onSelect: _file_saveas,
|
onSelect: (_) -> _file_save(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Save chart as...",
|
||||||
|
onSelect: (_) -> _file_saveas(),
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
label: "Save Without Events",
|
label: "Save global events",
|
||||||
keybind: [CONTROL, ALT, TAB, S],
|
keybind: [CONTROL, B, S],
|
||||||
onSelect: _file_save_no_events,
|
onSelect: (_) -> _file_events_save(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save Without Events As...",
|
label: "Save global events as...",
|
||||||
keybind: [CONTROL, SHIFT, ALT, TAB, S],
|
onSelect: (_) -> _file_events_saveas(),
|
||||||
onSelect: _file_saveas_no_events,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save Events Separately",
|
label: "Save chart without local events",
|
||||||
keybind: [CONTROL, TAB, S],
|
|
||||||
onSelect: _file_events_save,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Save Events Separately As...",
|
|
||||||
keybind: [CONTROL, SHIFT, TAB, S],
|
|
||||||
onSelect: _file_events_saveas,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
{
|
|
||||||
label: "Save Meta",
|
|
||||||
keybind: [CONTROL, ALT, S],
|
keybind: [CONTROL, ALT, S],
|
||||||
onSelect: _file_meta_save,
|
onSelect: (_) -> _file_save_no_events(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Save Meta As...",
|
label: "Save chart without local events as...",
|
||||||
keybind: [CONTROL, ALT ,SHIFT, S],
|
onSelect: (_) -> _file_saveas_no_events(),
|
||||||
onSelect: _file_meta_saveas,
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
label: "Export For FNF Legacy...",
|
label: "Save meta",
|
||||||
onSelect: _file_saveas_fnflegacy,
|
keybind: [CONTROL, M, S],
|
||||||
|
onSelect: (_) -> _file_meta_save(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Export For Psych Engine...",
|
label: "Save meta as...",
|
||||||
onSelect: _file_saveas_psych,
|
onSelect: (_) -> _file_meta_saveas(),
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
label: "Export for FNF Legacy as...",
|
||||||
|
onSelect: (_) -> _file_saveas_fnflegacy(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Export for Psych Engine as...",
|
||||||
|
onSelect: (_) -> _file_saveas_psych(),
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
@@ -433,7 +439,7 @@ class Charter extends UIState {
|
|||||||
// thank you neo for pointing out im stupid -lunar
|
// thank you neo for pointing out im stupid -lunar
|
||||||
localEventsBackdrop.cameras = localEventsGroup.cameras = [charterCamera];
|
localEventsBackdrop.cameras = localEventsGroup.cameras = [charterCamera];
|
||||||
localEventsGroup.eventsBackdrop = localEventsBackdrop;
|
localEventsGroup.eventsBackdrop = localEventsBackdrop;
|
||||||
|
|
||||||
globalEventsBackdrop = new EventBackdrop(true);
|
globalEventsBackdrop = new EventBackdrop(true);
|
||||||
globalEventsBackdrop.x = 0;
|
globalEventsBackdrop.x = 0;
|
||||||
// thank you neo for pointing out im stupid -lunar
|
// thank you neo for pointing out im stupid -lunar
|
||||||
@@ -449,7 +455,7 @@ class Charter extends UIState {
|
|||||||
noteHoverer = new CharterNoteHoverer();
|
noteHoverer = new CharterNoteHoverer();
|
||||||
noteDeleteAnims = new CharterDeleteAnim();
|
noteDeleteAnims = new CharterDeleteAnim();
|
||||||
|
|
||||||
selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras =
|
selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras =
|
||||||
noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera];
|
noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera];
|
||||||
|
|
||||||
topMenuSpr = new UITopMenu(topMenu);
|
topMenuSpr = new UITopMenu(topMenu);
|
||||||
@@ -545,7 +551,7 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
loadSong();
|
loadSong();
|
||||||
|
|
||||||
if(Framerate.isLoaded) {
|
if (Framerate.isLoaded) {
|
||||||
Framerate.fpsCounter.alpha = 0.4;
|
Framerate.fpsCounter.alpha = 0.4;
|
||||||
Framerate.memoryCounter.alpha = 0.4;
|
Framerate.memoryCounter.alpha = 0.4;
|
||||||
Framerate.codenameBuildField.alpha = 0.4;
|
Framerate.codenameBuildField.alpha = 0.4;
|
||||||
@@ -616,25 +622,25 @@ class Charter extends UIState {
|
|||||||
notesGroup.autoSort = true;
|
notesGroup.autoSort = true;
|
||||||
|
|
||||||
// create events
|
// create events
|
||||||
localEventsGroup.autoSort = false;
|
globalEventsGroup.autoSort = localEventsGroup.autoSort = false;
|
||||||
var __last:CharterEvent = null;
|
var __last:CharterEvent = null;
|
||||||
var __lastTime:Float = Math.NaN;
|
var __lastTime:Float = Math.NaN;
|
||||||
for(e in PlayState.SONG.events) {
|
for (e in PlayState.SONG.events) {
|
||||||
if (e == null) continue;
|
if (e == null) continue;
|
||||||
if (__last != null && __lastTime == e.time) {
|
if (__last != null && __lastTime == e.time) {
|
||||||
__last.events.push(e);
|
__last.events.push(e);
|
||||||
} else {
|
} else {
|
||||||
__last = new CharterEvent(Conductor.getStepForTime(e.time), [e]);
|
__last = new CharterEvent(Conductor.getStepForTime(e.time), [e]);
|
||||||
__lastTime = e.time;
|
__lastTime = e.time;
|
||||||
localEventsGroup.add(__last);
|
(__last.global ? globalEventsGroup : localEventsGroup).add(__last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localEventsGroup.sortEvents();
|
for (grp in [localEventsGroup, globalEventsGroup]) {
|
||||||
localEventsGroup.autoSort = true;
|
grp.sortEvents();
|
||||||
|
grp.autoSort = true;
|
||||||
for(e in localEventsGroup.members)
|
for (e in grp.members) e.refreshEventIcons();
|
||||||
e.refreshEventIcons();
|
}
|
||||||
|
|
||||||
buildNoteTypesUI();
|
buildNoteTypesUI();
|
||||||
refreshBPMSensitive();
|
refreshBPMSensitive();
|
||||||
@@ -759,21 +765,21 @@ class Charter extends UIState {
|
|||||||
if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) {
|
if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) {
|
||||||
if (Options.charterAutoSavesSeparateFolder)
|
if (Options.charterAutoSavesSeparateFolder)
|
||||||
__autoSaveLocation = __diff.toLowerCase() + DateTools.format(Date.now(), "%m-%d_%H-%M");
|
__autoSaveLocation = __diff.toLowerCase() + DateTools.format(Date.now(), "%m-%d_%H-%M");
|
||||||
autoSaveNotif.startAutoSave(autoSaveTimer,
|
autoSaveNotif.startAutoSave(autoSaveTimer,
|
||||||
!Options.charterAutoSavesSeparateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' :
|
!Options.charterAutoSavesSeparateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' :
|
||||||
'Saved chart at $__autoSaveLocation.json!'
|
'Saved chart at $__autoSaveLocation.json!'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (autoSaveTimer <= 0) {
|
if (autoSaveTimer <= 0) {
|
||||||
autoSaveTimer = Options.charterAutoSaveTime;
|
autoSaveTimer = Options.charterAutoSaveTime;
|
||||||
if (!autoSaveNotif.cancelled) {
|
if (!autoSaveNotif.cancelled) {
|
||||||
buildChart();
|
buildChart();
|
||||||
var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}';
|
var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}';
|
||||||
|
|
||||||
if (Options.charterAutoSavesSeparateFolder)
|
if (Options.charterAutoSavesSeparateFolder)
|
||||||
Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint});
|
Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, folder: "autosaves", prettyPrint: Options.editorPrettyPrint});
|
||||||
else
|
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
|
||||||
Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint});
|
Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: true, saveLocalEvents: true, saveGlobalEvents: true, prettyPrint: Options.editorPrettyPrint});
|
||||||
undos.save();
|
undos.save();
|
||||||
}
|
}
|
||||||
autoSaveNotif.cancelled = false;
|
autoSaveNotif.cancelled = false;
|
||||||
@@ -1013,8 +1019,8 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
// Event Spr
|
// Event Spr
|
||||||
for (addEventSpr in [localAddEventSpr, globalAddEventSpr]) {
|
for (addEventSpr in [localAddEventSpr, globalAddEventSpr]) {
|
||||||
if ((!addEventSpr.global ? (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth) :
|
if ((!addEventSpr.global ? (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth) :
|
||||||
(mousePos.x > strumLines.totalKeyCount * 40 && mousePos.x < strumLines.totalKeyCount * 40 + addEventSpr.bWidth))
|
(mousePos.x > strumLines.totalKeyCount * 40 && mousePos.x < strumLines.totalKeyCount * 40 + addEventSpr.bWidth))
|
||||||
&& gridActionType == NONE && inBoundsY) {
|
&& gridActionType == NONE && inBoundsY) {
|
||||||
|
|
||||||
addEventSpr.incorporeal = false;
|
addEventSpr.incorporeal = false;
|
||||||
@@ -1022,7 +1028,7 @@ class Charter extends UIState {
|
|||||||
var event = getHoveredEvent(mousePos.y, !addEventSpr.global ? localEventsGroup : globalEventsGroup);
|
var event = getHoveredEvent(mousePos.y, !addEventSpr.global ? localEventsGroup : globalEventsGroup);
|
||||||
if (event != null) addEventSpr.updateEdit(event);
|
if (event != null) addEventSpr.updateEdit(event);
|
||||||
else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40));
|
else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40));
|
||||||
} else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25);
|
} else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
noteHoverer.showHoverer = Charter.instance.gridBackdropDummy.hovered;
|
noteHoverer.showHoverer = Charter.instance.gridBackdropDummy.hovered;
|
||||||
@@ -1422,90 +1428,106 @@ class Charter extends UIState {
|
|||||||
else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();}
|
else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_save(_) {
|
function _file_save_all(_) {
|
||||||
|
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()}');
|
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', false, shouldBuild);
|
||||||
undos.save();
|
undos.save();
|
||||||
return;
|
#else
|
||||||
|
_file_saveas(shouldBuild);
|
||||||
#end
|
#end
|
||||||
_file_saveas(_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas(_) {
|
function _file_saveas(shouldBuild:Bool = true) {
|
||||||
openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null), {
|
saveAs(Chart.filterChartForSaving(PlayState.SONG, false, true, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
||||||
}));
|
}, null, shouldBuild);
|
||||||
undos.save();
|
undos.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_save_no_events(_) {
|
function _file_events_save(shouldBuild:Bool = true) {
|
||||||
#if sys
|
#if sys
|
||||||
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', true);
|
if (shouldBuild) buildChart();
|
||||||
undos.save();
|
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
||||||
return;
|
|
||||||
|
var path = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json';
|
||||||
|
if (data == null || data.events.length == 0) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex
|
||||||
|
else CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null));
|
||||||
|
#else
|
||||||
|
_file_events_saveas(shouldBuild);
|
||||||
#end
|
#end
|
||||||
_file_saveas(_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas_no_events(_) {
|
function _file_events_saveas(shouldBuild:Bool = true) {
|
||||||
openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null), {
|
if (shouldBuild) buildChart();
|
||||||
|
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
|
||||||
|
|
||||||
|
saveAs(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null, {
|
||||||
|
defaultSaveFile: 'events.json'
|
||||||
|
}, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _file_save_no_events(shouldBuild:Bool = true) {
|
||||||
|
#if sys
|
||||||
|
saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', true, shouldBuild);
|
||||||
|
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'
|
defaultSaveFile: '${__diff.toLowerCase()}.json'
|
||||||
}));
|
}, null, shouldBuild);
|
||||||
undos.save();
|
undos.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_meta_save(_) {
|
function _file_meta_save(shouldBuild:Bool = true) {
|
||||||
#if sys
|
#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 ? {} : PlayState.SONG.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(_);
|
_file_meta_saveas(shouldBuild);
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_meta_saveas(_) {
|
function _file_meta_saveas(shouldBuild:Bool = true) {
|
||||||
openSubState(new SaveSubstate(Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas_fnflegacy(_) {
|
function _file_saveas_fnflegacy(shouldBuild:Bool = true) {
|
||||||
openSubState(new SaveSubstate(Json.stringify(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_saveas_psych(_) {
|
function _file_saveas_psych(shouldBuild:Bool = true) {
|
||||||
openSubState(new SaveSubstate(Json.stringify(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _file_events_save(_) {
|
function saveAs(data:Dynamic, ?replacer:(key:Dynamic, value:Dynamic) -> Dynamic, ?space:String, ?options:SaveSubstate.SaveSubstateData, ?saveOptions:Map<String, Bool>, shouldBuild:Bool = true) {
|
||||||
#if sys
|
if (shouldBuild) buildChart();
|
||||||
CoolUtil.safeSaveFile(
|
openSubState(new SaveSubstate(Json.stringify(data, replacer, space), options, saveOptions));
|
||||||
'${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json',
|
|
||||||
Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null)
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
_file_events_saveas(_);
|
|
||||||
#end
|
|
||||||
}
|
|
||||||
|
|
||||||
function _file_events_saveas(_) {
|
|
||||||
#if sys
|
|
||||||
openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null), {
|
|
||||||
defaultSaveFile: 'events.json'
|
|
||||||
}));
|
|
||||||
#end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if sys
|
#if sys
|
||||||
function saveTo(path:String, separateEvents:Bool = false) {
|
function saveTo(path:String, separateEvents:Bool = false, shouldBuild:Bool = true) {
|
||||||
buildChart();
|
if (shouldBuild) buildChart();
|
||||||
Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint});
|
Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveLocalEvents: !separateEvents, prettyPrint: Options.editorPrettyPrint});
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -1657,7 +1679,7 @@ class Charter extends UIState {
|
|||||||
case CEditEventGroups(events):
|
case CEditEventGroups(events):
|
||||||
for (event in events) event.displayGlobal = !event.global;
|
for (event in events) event.displayGlobal = !event.global;
|
||||||
updateEventsGroups(cast events);
|
updateEventsGroups(cast events);
|
||||||
|
|
||||||
case CEditChartData(oldData, newData):
|
case CEditChartData(oldData, newData):
|
||||||
PlayState.SONG.stage = newData.stage;
|
PlayState.SONG.stage = newData.stage;
|
||||||
PlayState.SONG.scrollSpeed = newData.speed;
|
PlayState.SONG.scrollSpeed = newData.speed;
|
||||||
@@ -1976,13 +1998,12 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
public function buildEvents() {
|
public function buildEvents() {
|
||||||
PlayState.SONG.events = [];
|
PlayState.SONG.events = [];
|
||||||
// TODO!!!!
|
|
||||||
localEventsGroup.sortEvents();
|
var events:Array<CharterEvent> = localEventsGroup.members.concat(globalEventsGroup.members);
|
||||||
for(e in localEventsGroup.members) {
|
events.sort(globalEventsGroup.sortEventsFilter.bind(FlxSort.ASCENDING));
|
||||||
for(event in e.events) {
|
for (e in events) for (event in e.events) {
|
||||||
event.time = Conductor.getTimeForStep(e.step);
|
event.time = Conductor.getTimeForStep(e.step);
|
||||||
PlayState.SONG.events.push(event);
|
PlayState.SONG.events.push(event);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,19 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
|
|||||||
public var eventsBackdrop:EventBackdrop;
|
public var eventsBackdrop:EventBackdrop;
|
||||||
public var snappedToGrid:Bool = true;
|
public var snappedToGrid:Bool = true;
|
||||||
|
|
||||||
public var global:Bool = false;
|
|
||||||
public var displayGlobal:Bool = false;
|
public var displayGlobal:Bool = false;
|
||||||
|
public var global(default, set):Bool = false;
|
||||||
|
private function set_global(val:Bool) {
|
||||||
|
for (event in events) event.global = val;
|
||||||
|
return global = val;
|
||||||
|
}
|
||||||
|
|
||||||
public function new(step:Float, ?events:Array<ChartEvent>, ?global:Bool = false) {
|
public function new(step:Float, ?events:Array<ChartEvent>, ?global:Bool) {
|
||||||
super(-100, (step * 40) - 17, 100, 34, 'editors/charter/event-spr');
|
super(-100, (step * 40) - 17, 100, 34, 'editors/charter/event-spr');
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.events = events.getDefault([]);
|
this.events = events.getDefault([]);
|
||||||
|
|
||||||
this.global = displayGlobal = global;
|
this.global = displayGlobal = (global == null ? events[0] != null && events[0].global == true : global);
|
||||||
__redOffset = global ? 20 : 0;
|
__redOffset = global ? 20 : 0;
|
||||||
|
|
||||||
cursor = CLICK;
|
cursor = CLICK;
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ class CharterEventGroup extends FlxTypedGroup<CharterEvent> {
|
|||||||
|
|
||||||
public inline function sortEvents() {
|
public inline function sortEvents() {
|
||||||
__lastSort = members.length;
|
__lastSort = members.length;
|
||||||
this.sort(function(i, e1, e2) {
|
this.sort(sortEventsFilter);
|
||||||
return FlxSort.byValues(FlxSort.ASCENDING, e1.step, e2.step);
|
|
||||||
});
|
|
||||||
updateEventsIDs();
|
updateEventsIDs();
|
||||||
updateEventsBackdrop();
|
updateEventsBackdrop();
|
||||||
}
|
}
|
||||||
@@ -44,7 +42,7 @@ class CharterEventGroup extends FlxTypedGroup<CharterEvent> {
|
|||||||
for (i => n in members) n.ID = i;
|
for (i => n in members) n.ID = i;
|
||||||
|
|
||||||
public inline function updateEventsBackdrop()
|
public inline function updateEventsBackdrop()
|
||||||
for (event in members)
|
for (event in members)
|
||||||
event.eventsBackdrop = eventsBackdrop;
|
event.eventsBackdrop = eventsBackdrop;
|
||||||
|
|
||||||
public inline function filterEvents() {
|
public inline function filterEvents() {
|
||||||
@@ -54,4 +52,7 @@ class CharterEventGroup extends FlxTypedGroup<CharterEvent> {
|
|||||||
event.kill();
|
event.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public dynamic function sortEventsFilter(i:Int, e1:CharterEvent, e2:CharterEvent)
|
||||||
|
return FlxSort.byValues(FlxSort.ASCENDING, e1.step, e2.step);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user