mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-08-20 07:25:59 +00:00
Merge remote-tracking branch 'origin/rewrite/master' into feature/chart-waveform
This commit is contained in:
commit
42d070922b
|
@ -117,6 +117,7 @@ import openfl.display.BitmapData;
|
|||
import funkin.audio.visualize.PolygonSpectogram;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import funkin.audio.visualize.PolygonVisGroup;
|
||||
import flixel.text.FlxText;
|
||||
|
||||
using Lambda;
|
||||
|
||||
|
@ -736,7 +737,23 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
/**
|
||||
* The notes which are currently in the user's selection.
|
||||
*/
|
||||
var currentNoteSelection:Array<SongNoteData> = [];
|
||||
var currentNoteSelection(default, set):Array<SongNoteData> = [];
|
||||
|
||||
function set_currentNoteSelection(value:Array<SongNoteData>):Array<SongNoteData>
|
||||
{
|
||||
currentNoteSelection = value;
|
||||
|
||||
if (currentNoteSelection.length > 0)
|
||||
{
|
||||
notePreview.addNotes(currentNoteSelection, Std.int(songLengthInMs), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
notePreviewDirty = true;
|
||||
}
|
||||
|
||||
return currentNoteSelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* The events which are currently in the user's selection.
|
||||
|
@ -1645,6 +1662,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
*/
|
||||
var healthIconBF:Null<HealthIcon> = null;
|
||||
|
||||
/**
|
||||
* The text that pop's up when copying something
|
||||
*/
|
||||
var txtCopyNotif:Null<FlxText> = null;
|
||||
|
||||
/**
|
||||
* The purple background sprite.
|
||||
*/
|
||||
|
@ -2305,6 +2327,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
|
||||
add(playbarHeadLayout);
|
||||
|
||||
txtCopyNotif = new FlxText(0, 0, 0, '', 24);
|
||||
txtCopyNotif.setBorderStyle(OUTLINE, 0xFF074809, 1);
|
||||
txtCopyNotif.color = 0xFF52FF77;
|
||||
txtCopyNotif.zIndex = 120;
|
||||
add(txtCopyNotif);
|
||||
|
||||
if (!Preferences.debugDisplay) menubar.paddingLeft = null;
|
||||
|
||||
this.setupNotifications();
|
||||
|
@ -4476,7 +4504,48 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
// CTRL + C = Copy
|
||||
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C)
|
||||
{
|
||||
// Copy selected notes.
|
||||
if (currentNoteSelection.length > 0)
|
||||
{
|
||||
txtCopyNotif.visible = true;
|
||||
txtCopyNotif.text = "Copied " + currentNoteSelection.length + " notes to clipboard";
|
||||
txtCopyNotif.x = FlxG.mouse.x - (txtCopyNotif.width / 2);
|
||||
txtCopyNotif.y = FlxG.mouse.y - 16;
|
||||
FlxTween.tween(txtCopyNotif, {y: txtCopyNotif.y - 32}, 0.5,
|
||||
{
|
||||
type: FlxTween.ONESHOT,
|
||||
ease: FlxEase.quadOut,
|
||||
onComplete: function(_) {
|
||||
txtCopyNotif.visible = false;
|
||||
}
|
||||
});
|
||||
|
||||
for (note in renderedNotes.members)
|
||||
{
|
||||
if (isNoteSelected(note.noteData))
|
||||
{
|
||||
FlxTween.globalManager.cancelTweensOf(note);
|
||||
FlxTween.globalManager.cancelTweensOf(note.scale);
|
||||
note.playNoteAnimation();
|
||||
var prevX:Float = note.scale.x;
|
||||
var prevY:Float = note.scale.y;
|
||||
|
||||
note.scale.x *= 1.2;
|
||||
note.scale.y *= 1.2;
|
||||
|
||||
note.angle = FlxG.random.bool() ? -10 : 10;
|
||||
FlxTween.tween(note, {"angle": 0}, 0.8, {ease: FlxEase.elasticOut});
|
||||
|
||||
FlxTween.tween(note.scale, {"y": prevX, "x": prevY}, 0.7,
|
||||
{
|
||||
ease: FlxEase.elasticOut,
|
||||
onComplete: function(_) {
|
||||
note.playNoteAnimation();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need a command for this since we can't undo it.
|
||||
SongDataUtils.writeItemsToClipboard(
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ class ChartEditorNotePreview extends FlxSprite
|
|||
static final UP_COLOR:FlxColor = 0xFF00CC00;
|
||||
static final RIGHT_COLOR:FlxColor = 0xFFCC1111;
|
||||
static final EVENT_COLOR:FlxColor = 0xFF111111;
|
||||
static final SELECTED_COLOR:FlxColor = 0xFFFFFF00;
|
||||
|
||||
var previewHeight:Int;
|
||||
|
||||
|
@ -57,11 +58,11 @@ class ChartEditorNotePreview extends FlxSprite
|
|||
* @param note The data for the note.
|
||||
* @param songLengthInMs The total length of the song in milliseconds.
|
||||
*/
|
||||
public function addNote(note:SongNoteData, songLengthInMs:Int):Void
|
||||
public function addNote(note:SongNoteData, songLengthInMs:Int, ?isSelection:Bool = false):Void
|
||||
{
|
||||
var noteDir:Int = note.getDirection();
|
||||
var mustHit:Bool = note.getStrumlineIndex() == 0;
|
||||
drawNote(noteDir, mustHit, Std.int(note.time), songLengthInMs);
|
||||
drawNote(noteDir, mustHit, Std.int(note.time), songLengthInMs, isSelection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,11 +80,11 @@ class ChartEditorNotePreview extends FlxSprite
|
|||
* @param notes The data for the notes.
|
||||
* @param songLengthInMs The total length of the song in milliseconds.
|
||||
*/
|
||||
public function addNotes(notes:Array<SongNoteData>, songLengthInMs:Int):Void
|
||||
public function addNotes(notes:Array<SongNoteData>, songLengthInMs:Int, ?isSelection:Bool = false):Void
|
||||
{
|
||||
for (note in notes)
|
||||
{
|
||||
addNote(note, songLengthInMs);
|
||||
addNote(note, songLengthInMs, isSelection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +107,9 @@ class ChartEditorNotePreview extends FlxSprite
|
|||
* @param mustHit False if opponent, true if player.
|
||||
* @param strumTimeInMs Time in milliseconds to strum the note.
|
||||
* @param songLengthInMs Length of the song in milliseconds.
|
||||
* @param isSelection If current note is selected note, which then it's forced to be green
|
||||
*/
|
||||
function drawNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int):Void
|
||||
public function drawNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int, ?isSelection:Bool = false):Void
|
||||
{
|
||||
var color:FlxColor = switch (dir)
|
||||
{
|
||||
|
@ -118,13 +120,20 @@ class ChartEditorNotePreview extends FlxSprite
|
|||
default: EVENT_COLOR;
|
||||
};
|
||||
|
||||
var noteHeight:Int = NOTE_HEIGHT;
|
||||
|
||||
if (isSelection != null && isSelection)
|
||||
{
|
||||
color = SELECTED_COLOR;
|
||||
noteHeight += 1;
|
||||
}
|
||||
|
||||
var noteX:Float = NOTE_WIDTH * dir;
|
||||
if (mustHit) noteX += NOTE_WIDTH * 4;
|
||||
if (dir == -1) noteX = NOTE_WIDTH * 8;
|
||||
|
||||
var noteY:Float = FlxMath.remapToRange(strumTimeInMs, 0, songLengthInMs, 0, previewHeight);
|
||||
|
||||
drawRect(noteX, noteY, NOTE_WIDTH, NOTE_HEIGHT, color);
|
||||
drawRect(noteX, noteY, NOTE_WIDTH, noteHeight, color);
|
||||
}
|
||||
|
||||
function eraseNote(dir:Int, mustHit:Bool, strumTimeInMs:Int, songLengthInMs:Int):Void
|
||||
|
|
|
@ -113,41 +113,17 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
|
|||
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, path.toString());
|
||||
if (result != null)
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Success',
|
||||
body: result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}',
|
||||
type: result.length == 0 ? NotificationType.Success : NotificationType.Warning,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.success('Loaded Chart', result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}');
|
||||
this.hideDialog(DialogButton.APPLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Failure',
|
||||
body: 'Failed to load chart (${path.toString()})',
|
||||
type: NotificationType.Error,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()})');
|
||||
}
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Failure',
|
||||
body: 'Failed to load chart (${path.toString()}): ${err}',
|
||||
type: NotificationType.Error,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()}): ${err}');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,15 +141,8 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
|
|||
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFC(state, selectedFile.bytes);
|
||||
if (result != null)
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Success',
|
||||
body: 'Loaded chart (${selectedFile.name})',
|
||||
type: NotificationType.Success,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.success('Loaded Chart',
|
||||
result.length == 0 ? 'Loaded chart (${selectedFile.name})' : 'Loaded chart (${selectedFile.name})\n${result.join("\n")}');
|
||||
|
||||
if (selectedFile.fullPath != null) state.currentWorkingFilePath = selectedFile.fullPath;
|
||||
this.hideDialog(DialogButton.APPLY);
|
||||
|
@ -181,15 +150,7 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
|
|||
}
|
||||
catch (err)
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Failure',
|
||||
body: 'Failed to load chart (${selectedFile.name}): ${err}',
|
||||
type: NotificationType.Error,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.failure('Failed to Load Chart', 'Failed to load chart (${selectedFile.name}): ${err}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,27 +102,12 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
|
|||
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath);
|
||||
if (result != null)
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Success',
|
||||
body: result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}',
|
||||
type: result.length == 0 ? NotificationType.Success : NotificationType.Warning,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.success('Loaded Chart',
|
||||
result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}');
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !mac
|
||||
NotificationManager.instance.addNotification(
|
||||
{
|
||||
title: 'Failure',
|
||||
body: 'Failed to load chart (${chartPath.toString()})',
|
||||
type: NotificationType.Error,
|
||||
expiryMs: Constants.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
state.error('Failed to Load Chart', 'Failed to load chart (${chartPath.toString()})');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@ class ChartEditorNotificationHandler
|
|||
|
||||
static function sendNotification(state:ChartEditorState, title:String, body:String, ?type:NotificationType, ?actions:Array<NotificationAction>):Notification
|
||||
{
|
||||
#if !mac
|
||||
var actionNames:Array<String> = actions == null ? [] : actions.map(action -> action.text);
|
||||
|
||||
var notif = NotificationManager.instance.addNotification(
|
||||
|
@ -138,7 +137,7 @@ class ChartEditorNotificationHandler
|
|||
}
|
||||
|
||||
return notif;
|
||||
#else
|
||||
#if false
|
||||
// TODO: Implement notifications on Mac OS OR... make sure the null is handled properly on mac?
|
||||
return null;
|
||||
trace('WARNING: Notifications are not supported on Mac OS.');
|
||||
|
|
Loading…
Reference in a new issue