mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-11-28 15:26:12 +00:00
Add , and . hotkeys to chart editor.
This commit is contained in:
parent
656e5e7cf1
commit
b06a35ea2f
|
|
@ -290,6 +290,16 @@ class SongDataUtils
|
||||||
return data.indexOf(note.data) != -1;
|
return data.indexOf(note.data) != -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a list of events to only include events whose kind is one of the given values.
|
||||||
|
*/
|
||||||
|
public static function getEventsWithKind(events:Array<SongEventData>, kinds:Array<String>):Array<SongEventData>
|
||||||
|
{
|
||||||
|
return events.filter(function(event:SongEventData):Bool {
|
||||||
|
return kinds.indexOf(event.eventKind) != -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef SongClipboardItems =
|
typedef SongClipboardItems =
|
||||||
|
|
|
||||||
|
|
@ -5171,6 +5171,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Place events at playhead.
|
||||||
|
if (FlxG.keys.justPressed.COMMA) placeEventAtPlayhead(true);
|
||||||
|
if (FlxG.keys.justPressed.PERIOD) placeEventAtPlayhead(false);
|
||||||
|
|
||||||
updatePlayheadGhostHoldNotes();
|
updatePlayheadGhostHoldNotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5207,6 +5211,41 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function placeEventAtPlayhead(isOpponent:Bool):Void
|
||||||
|
{
|
||||||
|
// SHIFT + press or LEFT_SHOULDER + press to remove events instead of placing them.
|
||||||
|
var removeEventInstead:Bool = FlxG.keys.pressed.SHIFT || (FlxG.gamepads.firstActive?.pressed?.LEFT_SHOULDER ?? false);
|
||||||
|
|
||||||
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
||||||
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
|
||||||
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
||||||
|
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
|
||||||
|
|
||||||
|
// Look for events within 1 step of the playhead.
|
||||||
|
var eventsAtPos:Array<SongEventData> = SongDataUtils.getEventsInTimeRange(currentSongChartEventData, playheadPosSnappedMs,
|
||||||
|
playheadPosSnappedMs + Conductor.instance.stepLengthMs * noteSnapRatio);
|
||||||
|
eventsAtPos = SongDataUtils.getEventsWithKind(eventsAtPos, ['FocusCamera']);
|
||||||
|
|
||||||
|
if (eventsAtPos.length == 0 && !removeEventInstead)
|
||||||
|
{
|
||||||
|
trace('Placing event ${isOpponent}');
|
||||||
|
var newEventData:SongEventData = new SongEventData(playheadPosSnappedMs, 'FocusCamera',
|
||||||
|
{
|
||||||
|
char: isOpponent ? 1 : 0,
|
||||||
|
});
|
||||||
|
performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL));
|
||||||
|
}
|
||||||
|
else if (removeEventInstead)
|
||||||
|
{
|
||||||
|
trace('Removing existing event at position.');
|
||||||
|
performCommand(new RemoveEventsCommand(eventsAtPos));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trace('Already an event there.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updatePlayheadGhostHoldNotes():Void
|
function updatePlayheadGhostHoldNotes():Void
|
||||||
{
|
{
|
||||||
// Ensure all the ghost hold notes exist.
|
// Ensure all the ghost hold notes exist.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue