From 326f4e1fe3c4c2b62117a0e61de95ded394c15f4 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Fri, 14 Mar 2025 14:14:03 -0700 Subject: [PATCH] add batched notes to this branch --- .../editors/charter/CharterBackdropGroup.hx | 44 ++++++++++++++++--- .../editors/charter/CharterEventScreenNew.hx | 2 - source/funkin/editors/charter/CharterNote.hx | 4 ++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/source/funkin/editors/charter/CharterBackdropGroup.hx b/source/funkin/editors/charter/CharterBackdropGroup.hx index 3741f9b2..0b73878a 100644 --- a/source/funkin/editors/charter/CharterBackdropGroup.hx +++ b/source/funkin/editors/charter/CharterBackdropGroup.hx @@ -89,8 +89,7 @@ class CharterBackdropGroup extends FlxTypedGroup { notesGroup.forEach((n) -> { if(n.exists && n.visible) { var onStr:Bool = (n.snappedToGrid ? n.strumLineID : CoolUtil.boundInt(Std.int((n.x+n.width)/(40*strumLine.keyCount)), 0, strumLineGroup.members.length-1)) == i; - if(onStr) - grid.notesGroup.add(n); + if(onStr) grid.notesGroup.add(n); } }); @@ -118,8 +117,7 @@ class CharterBackdropGroup extends FlxTypedGroup { if (cameras != null) FlxCamera._defaultCameras = cameras; - while (i < length) - { + while (i < length) { basic = members[i++]; if (basic != null && basic != draggingObj && basic.exists && basic.visible) basic.draw(); @@ -130,6 +128,42 @@ class CharterBackdropGroup extends FlxTypedGroup { } } +// Batches note draws (neos idea) >:D -lunar +class NotesDrawGroup extends FlxFastTypedGroup { + public override function draw() @:privateAccess { + var oldDefaultCameras = FlxCamera._defaultCameras; + if (cameras != null) + FlxCamera._defaultCameras = cameras; + + var i:Int = 0; + var note:CharterNote = null; + + while (i < length) { + note = members[i++]; + if (note != null && note.exists && note.visible) { + if (note.snappedToGrid) note.x = (note.strumLine != null ? note.strumLine.x : 0) + (note.id % (note.strumLine != null ? note.strumLine.keyCount : 4)) * 40; + note.drawMembers(); + } + } + + i = 0; note = null; + while (i < length) { + note = members[i++]; + if (note != null && note.exists && note.visible) + note.drawSuper(); + } + + i = 0; note = null; + while (i < length) { + note = members[i++]; + if (note != null && note.exists && note.visible) + note.drawNoteTypeText(); + } + + FlxCamera._defaultCameras = oldDefaultCameras; + } +} + class CharterBackdrop extends FlxTypedGroup { public var gridBackDrop:FlxBackdrop; public var topLimit:FlxSprite; @@ -143,7 +177,7 @@ class CharterBackdrop extends FlxTypedGroup { public var beatSeparator:FlxBackdrop; public var sectionSeparator:FlxBackdrop; - public var notesGroup:FlxFastTypedGroup = new FlxFastTypedGroup(); + public var notesGroup:NotesDrawGroup = new NotesDrawGroup(); public var strumLine:CharterStrumline; public var gridShader:CustomShader = new CustomShader("engine/charterGrid"); diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx index 988f6939..e2a39de4 100644 --- a/source/funkin/editors/charter/CharterEventScreenNew.hx +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -296,9 +296,7 @@ class CharterEventScreenNew extends MusicBeatSubstate { Charter.instance.updateBPMEvents(); Charter.undos.addToUndo(CEditEvent(chartEvent, oldEvents, [for (event in events) Reflect.copy(event)])); - } - close(); } diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx index 58f3f617..3ac30d66 100644 --- a/source/funkin/editors/charter/CharterNote.hx +++ b/source/funkin/editors/charter/CharterNote.hx @@ -201,6 +201,10 @@ class CharterNote extends UISprite implements ICharterSelectable { drawMembers(); drawSuper(); + drawNoteTypeText(); + } + + public inline function drawNoteTypeText() { if(typeText.exists && typeText.visible && typeVisible) { typeText.alpha = typeAlpha; typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));