From 9ed4501d5f353d3ab405f3f3b886a33f59c6ef54 Mon Sep 17 00:00:00 2001 From: Frakits Date: Sun, 9 Mar 2025 16:50:01 +0200 Subject: [PATCH 1/7] THIS COMMIT! --- source/funkin/editors/charter/Charter.hx | 4 +- .../funkin/editors/charter/CharterEventAdd.hx | 4 +- .../editors/charter/CharterEventScreenNew.hx | 315 ++++++++++++++++++ source/funkin/editors/ui/UIButtonList.hx | 2 +- source/funkin/editors/ui/UIDropDown.hx | 8 +- 5 files changed, 323 insertions(+), 10 deletions(-) create mode 100644 source/funkin/editors/charter/CharterEventScreenNew.hx diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 80a5f900..2f166df6 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -48,6 +48,8 @@ class Charter extends UIState { public var scrollBar:UIScrollBar; public var songPosInfo:UIText; + public var shouldScroll:Bool = true; + public var quantButtons:Array = []; public var playBackSlider:UISlider; @@ -1332,7 +1334,7 @@ class Charter extends UIState { UIUtil.processShortcuts(topMenu); if (!topMenuSpr.anyMenuOpened) { - if (FlxG.mouse.wheel != 0) { + if (FlxG.mouse.wheel != 0 && shouldScroll) { if (FlxG.keys.pressed.CONTROL) { zoom += 0.25 * FlxG.mouse.wheel; __camZoom = Math.pow(2, zoom); diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index a286edf7..7370e60f 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -22,9 +22,9 @@ class CharterEventAdd extends UISliceSprite { public override function onHovered() { super.onHovered(); - if (FlxG.mouse.justReleased) { + if (FlxG.mouse.justReleased && FlxG.state.subState == null) { if (curCharterEvent != null) - Charter.instance.openSubState(new CharterEventScreen(step, global, curCharterEvent)); + Charter.instance.openSubState(new CharterEventScreenNew(x + 40, y, curCharterEvent)); else Charter.instance.openSubState(new CharterEventScreen(step, global)); } diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx new file mode 100644 index 00000000..ea018424 --- /dev/null +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -0,0 +1,315 @@ +package funkin.editors.charter; + +import flixel.group.FlxGroup; +import flixel.util.FlxColor; +import funkin.backend.chart.ChartData.ChartEvent; +import funkin.backend.chart.EventsData; +import funkin.backend.system.Conductor; +import funkin.game.Character; +import funkin.game.Stage; + +using StringTools; + +class CharterEventScreenNew extends MusicBeatSubstate { + public var cam:FlxCamera; + public var chartEvent:CharterEvent; + + public var events:Array = []; + public var eventsList:UIButtonList; + + public var eventName:UIText; + + public var paramsPanel:FlxGroup; + public var paramsFields:Array = []; + + public var xPos:Float; + public var yPos:Float; + + public var bWidth:Float; + + var bg:UISliceSprite; + + public function new(xPos:Float, yPos:Float, ?chartEvent:Null) { + if (chartEvent != null) this.chartEvent = chartEvent; + this.xPos = xPos; this.yPos = yPos; + super(); + } + + public override function create() { + super.create(); + + FlxG.sound.music.pause(); // prevent the song from continuing + Charter.instance.vocals.pause(); + for (strumLine in Charter.instance.strumLines.members) strumLine.vocals.pause(); + + events = chartEvent.events.copy(); + + FlxG.state.persistentUpdate = true; + + camera = cam = new FlxCamera(xPos, yPos, 0, 0); + cam.bgColor = 0; + FlxG.cameras.add(cam, false); + + bg = new UISliceSprite(xPos + 100, yPos, 0, 0, 'editors/ui/inputbox'); + bg.alpha = 0.75; + bg.cameras = [cam]; + cam.x = bg.getScreenPosition(Charter.instance.charterCamera).x; + cam.y = bg.getScreenPosition(Charter.instance.charterCamera).y; + bg.setPosition(0, 0); + add(bg); + + paramsPanel = new FlxGroup(); + paramsPanel.cameras = [cam]; + add(paramsPanel); + + eventName = new UIText(95, 10, 0, "", 24); + eventName.cameras = [cam]; + add(eventName); + + eventsList = new UIButtonList(10,-20,75, 570, null, FlxPoint.get(75, 40), null, 0); + eventsList.alpha = 0; + eventsList.cameras = [cam]; + eventsList.addButton.callback = () -> openSubState(new CharterEventTypeSelection(function(eventName) { + events.push({ + time: Conductor.getTimeForStep(chartEvent.step), + params: [], + name: eventName + }); + eventsList.add(new EventButtonNew(events[events.length-1], CharterEvent.generateEventIcon(events[events.length-1]), events.length-1, this, eventsList)); + changeTab(events.length-1); + })); + for (k=>i in events) + eventsList.add(new EventButtonNew(i, CharterEvent.generateEventIcon(i), k, this, eventsList)); + add(eventsList); + + changeTab(0); + } + + public var curEvent:Int = -1; + + public function changeTab(id:Int, save:Bool = true) { + if (save) + saveCurTab(); + + // destroy old elements + paramsFields = []; + for(e in paramsPanel) { + e.destroy(); + paramsPanel.remove(e); + } + + if (id >= 0 && id < events.length) { + curEvent = id; + var curEvent = events[curEvent]; + eventName.text = curEvent.name; + // add new elements + var y:Float = eventName.y + eventName.height + 10; + for(k=>param in EventsData.getEventParams(curEvent.name)) { + function addLabel() { + var label:UIText = new UIText(eventName.x, y, 0, param.name); + y += label.height + 4; + paramsPanel.add(label); + }; + + var value:Dynamic = CoolUtil.getDefault(curEvent.params[k], param.defValue); + var lastAdded = switch(param.type) { + case TString: + addLabel(); + var textBox:UITextBox = new UITextBox(eventName.x, y, cast value); + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; + case TBool: + var checkbox = new UICheckbox(eventName.x, y, param.name, cast value); + paramsPanel.add(checkbox); paramsFields.push(checkbox); + checkbox; + case TInt(min, max, step): + addLabel(); + var numericStepper = new UINumericStepper(eventName.x, y, cast value, step.getDefault(1), 0, min, max); + paramsPanel.add(numericStepper); paramsFields.push(numericStepper); + numericStepper; + case TFloat(min, max, step, precision): + addLabel(); + var numericStepper = new UINumericStepper(eventName.x, y, cast value, step.getDefault(1), precision, min, max); + paramsPanel.add(numericStepper); paramsFields.push(numericStepper); + numericStepper; + case TStrumLine: + addLabel(); + var dropdown = new UIDropDown(eventName.x, y, 320, 32, [for(k=>s in cast(FlxG.state, Charter).strumLines.members) 'Strumline #${k+1} (${s.strumLine.characters[0]})'], cast value); + paramsPanel.add(dropdown); paramsFields.push(dropdown); + dropdown; + case TColorWheel: + addLabel(); + var colorWheel = new UIColorwheel(eventName.x, y, value is String ? FlxColor.fromString(value) : Std.int(value)); + paramsPanel.add(colorWheel); paramsFields.push(colorWheel); + colorWheel; + case TDropDown(options): + addLabel(); + var optionIndex = options.indexOf(cast value); + if(optionIndex < 0) { + optionIndex = 0; + } + var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, optionIndex); + paramsPanel.add(dropdown); paramsFields.push(dropdown); + dropdown; + case TCharacter: + addLabel(); + var charFileList = Character.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = charFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; + case TStage: + addLabel(); + var stageFileList = Stage.getList(false); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + textBox.suggestItems = stageFileList; + paramsPanel.add(textBox); paramsFields.push(textBox); + textBox; + default: + paramsFields.push(null); + null; + } + if (lastAdded is UISliceSprite) { + y += cast(lastAdded, UISliceSprite).bHeight + 4; + bWidth = Math.max(bWidth, cast(lastAdded, UISliceSprite).bWidth + eventName.x + 10); + } + else if (lastAdded is FlxSprite) { + y += cast(lastAdded, FlxSprite).height + 6; + bWidth = Math.max(bWidth, cast(lastAdded, UISliceSprite).width + eventName.x + 10); + } + } + + y = Math.max(y, eventsList.buttonSize.y * (eventsList.buttons.length + 1)); + + if (bg.getScreenPosition(Charter.instance.charterCamera).y + y > FlxG.height) { + var ychange = (bg.getScreenPosition(Charter.instance.charterCamera).y + y) - FlxG.height; + cam.y -= ychange; + bg.y -= ychange; + } + + bg.bWidth = cast bWidth; + bg.bHeight = cast y + 10; + cam.width = cast bWidth; + cam.height = cast y + 10; + eventsList.bHeight = cast y + 30; + } else { + eventName.text = "No event"; + curEvent = -1; + } + update(0); + } + + var clickedWhileHovering = false; + override public function update(elapsed:Float) { + var mousepoint = FlxG.mouse.getPositionInCameraView(cam); + if (FlxG.mouse.justPressed && (FlxMath.inBounds(mousepoint.x, 0, cam.width) && FlxMath.inBounds(mousepoint.y, 0, cam.height))) clickedWhileHovering = true; + + if (FlxMath.inBounds(mousepoint.x, 0, cam.width) && FlxMath.inBounds(mousepoint.y, 0, cam.height)) { + Charter.instance.shouldScroll = false; + } + else if (Charter.instance.curContextMenu == null && ((FlxG.mouse.justReleased && !clickedWhileHovering) || FlxG.mouse.wheel != 0)) { + Charter.instance.shouldScroll = true; + quit(); + } + super.update(elapsed); + + if (FlxG.mouse.justReleased) clickedWhileHovering = false; + } + + public function quit() { + saveCurTab(); + chartEvent.refreshEventIcons(); + + if (events.length <= 0) + Charter.instance.deleteSelection([chartEvent]); + else if (events.length > 0) { + chartEvent.events = [for (i in eventsList.buttons.members) i.event]; + var oldEvents:Array = chartEvent.events.copy(); + chartEvent.refreshEventIcons(); + Charter.instance.updateBPMEvents(); + + Charter.undos.addToUndo(CEditEvent(chartEvent, oldEvents, [for (event in events) Reflect.copy(event)])); + } + + close(); + } + + public function saveCurTab() { + if (curEvent < 0) return; + + events[curEvent].params = [ + for(p in paramsFields) { + if (p is UIDropDown) { + var dataParams = EventsData.getEventParams(events[curEvent].name); + if (dataParams[paramsFields.indexOf(p)].type == TStrumLine) cast(p, UIDropDown).index; + else cast(p, UIDropDown).label.text; + } + else if (p is UINumericStepper) { + var stepper = cast(p, UINumericStepper); + @:privateAccess stepper.__onChange(stepper.label.text); + if (stepper.precision == 0) // int + Std.int(stepper.value); + else + stepper.value; + } + else if (p is UITextBox) + cast(p, UITextBox).label.text; + else if (p is UICheckbox) + cast(p, UICheckbox).checked; + else if (p is UIColorwheel) + cast(p, UIColorwheel).curColor; + else + null; + } + ]; + } + public override function destroy() { + super.destroy(); + FlxG.cameras.remove(cam); + } +} + +class EventButtonNew extends UIButton { + public var icon:FlxSprite = null; + public var event:ChartEvent = null; + public var deleteButton:UIButton; + public var deleteIcon:FlxSprite; + + public function new(event:ChartEvent, icon:FlxSprite, id:Int, substate:CharterEventScreenNew, parent:UIButtonList) { + this.icon = icon; + this.event = event; + super(0, 0, null, function() { + substate.changeTab(id); + for(i in parent.buttons.members) + i.alpha = i == this ? 1 : 0.25; + }, 73, 40); + autoAlpha = false; + + members.push(icon); + icon.setPosition(18 - icon.width / 2, 20 - icon.height / 2); + + deleteButton = new UIButton(bWidth - 30, y + (bHeight - 26) / 2, null, function () { + substate.events.splice(id, 1); + substate.changeTab(id, false); + parent.remove(this); + }, 26, 26); + deleteButton.color = FlxColor.RED; + deleteButton.autoAlpha = false; + members.push(deleteButton); + + deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 4).loadGraphic(Paths.image('editors/delete-button')); + deleteIcon.antialiasing = false; + members.push(deleteIcon); + } + + override function update(elapsed) { + super.update(elapsed); + + deleteButton.selectable = selectable; + deleteButton.shouldPress = shouldPress; + + icon.setPosition(x + (18 - icon.width / 2),y + (20 - icon.height / 2)); + deleteButton.setPosition(x + (bWidth - 30), y + (bHeight - 26) / 2); + deleteIcon.setPosition(deleteButton.x + (10/2), deleteButton.y + 4); + } +} \ No newline at end of file diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index 8384b89f..963cffed 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -62,7 +62,7 @@ class UIButtonList extends UIWindow { public inline function remove(button:T) { nextscrollY -= button.bHeight; - buttons.members.remove(button); + buttons.remove(button, true); button.destroy(); } diff --git a/source/funkin/editors/ui/UIDropDown.hx b/source/funkin/editors/ui/UIDropDown.hx index ff246b5d..0dbd1545 100644 --- a/source/funkin/editors/ui/UIDropDown.hx +++ b/source/funkin/editors/ui/UIDropDown.hx @@ -76,12 +76,8 @@ class UIDropDown extends UISliceSprite { public override function update(elapsed:Float) { var opened = curMenu.contextMenuOpened(); framesOffset = (opened || (hovered && FlxG.mouse.pressed)) ? 18 : (hovered ? 9 : 0); - if (FlxG.mouse.justReleased && (hovered || dropButton.hovered)) { - if (opened) - UIState.state.curContextMenu.preventOutOfBoxClickDeletion(); - else - openContextMenu(); - } + if (FlxG.mouse.justReleased && (hovered || dropButton.hovered) && !opened) + openContextMenu(); super.update(elapsed); From d2487c699b505bdbb6d3abe5671ed7d70f11c15f Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Tue, 11 Mar 2025 16:03:44 -0700 Subject: [PATCH 2/7] less jankiness >:D --- .../funkin/editors/charter/CharterEventAdd.hx | 2 +- .../editors/charter/CharterEventScreenNew.hx | 130 ++++++++++-------- source/funkin/editors/ui/UIButtonList.hx | 5 +- 3 files changed, 78 insertions(+), 59 deletions(-) diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index 7370e60f..4fd68721 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -24,7 +24,7 @@ class CharterEventAdd extends UISliceSprite { super.onHovered(); if (FlxG.mouse.justReleased && FlxG.state.subState == null) { if (curCharterEvent != null) - Charter.instance.openSubState(new CharterEventScreenNew(x + 40, y, curCharterEvent)); + Charter.instance.openSubState(new CharterEventScreenNew(curCharterEvent)); else Charter.instance.openSubState(new CharterEventScreen(step, global)); } diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx index ea018424..c96371ab 100644 --- a/source/funkin/editors/charter/CharterEventScreenNew.hx +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -22,16 +22,12 @@ class CharterEventScreenNew extends MusicBeatSubstate { public var paramsPanel:FlxGroup; public var paramsFields:Array = []; - public var xPos:Float; - public var yPos:Float; - public var bWidth:Float; var bg:UISliceSprite; - public function new(xPos:Float, yPos:Float, ?chartEvent:Null) { + public function new(?chartEvent:Null) { if (chartEvent != null) this.chartEvent = chartEvent; - this.xPos = xPos; this.yPos = yPos; super(); } @@ -46,15 +42,13 @@ class CharterEventScreenNew extends MusicBeatSubstate { FlxG.state.persistentUpdate = true; - camera = cam = new FlxCamera(xPos, yPos, 0, 0); + camera = cam = new FlxCamera(); cam.bgColor = 0; FlxG.cameras.add(cam, false); - bg = new UISliceSprite(xPos + 100, yPos, 0, 0, 'editors/ui/inputbox'); + bg = new UISliceSprite(0, 0, 0, 0, 'editors/ui/inputbox'); bg.alpha = 0.75; bg.cameras = [cam]; - cam.x = bg.getScreenPosition(Charter.instance.charterCamera).x; - cam.y = bg.getScreenPosition(Charter.instance.charterCamera).y; bg.setPosition(0, 0); add(bg); @@ -62,30 +56,38 @@ class CharterEventScreenNew extends MusicBeatSubstate { paramsPanel.cameras = [cam]; add(paramsPanel); - eventName = new UIText(95, 10, 0, "", 24); + eventName = new UIText(10+75+10, 10, 0, "", 24); eventName.cameras = [cam]; add(eventName); - eventsList = new UIButtonList(10,-20,75, 570, null, FlxPoint.get(75, 40), null, 0); + eventsList = new UIButtonList(10, 10, 75, 570, null, FlxPoint.get(75, 40), null, 0); eventsList.alpha = 0; eventsList.cameras = [cam]; - eventsList.addButton.callback = () -> openSubState(new CharterEventTypeSelection(function(eventName) { - events.push({ - time: Conductor.getTimeForStep(chartEvent.step), - params: [], - name: eventName - }); - eventsList.add(new EventButtonNew(events[events.length-1], CharterEvent.generateEventIcon(events[events.length-1]), events.length-1, this, eventsList)); - changeTab(events.length-1); - })); + eventsList.addButton.callback = () -> { + __ignoreLastClick = true; // Stop closing >:D + openSubState(new CharterEventTypeSelection(function(eventName) { + events.push({ + time: Conductor.getTimeForStep(chartEvent.step), + params: [], + name: eventName + }); + eventsList.add(new EventButtonNew(events[events.length-1], CharterEvent.generateEventIcon(events[events.length-1]), events.length-1, this, eventsList)); + changeTab(events.length-1); + })); + }; for (k=>i in events) eventsList.add(new EventButtonNew(i, CharterEvent.generateEventIcon(i), k, this, eventsList)); add(eventsList); + // this took forever to find out omg >:D -lunar + eventsList.cameraSpacing = 0; eventsList.topHeight = 0; + changeTab(0); + boundWindow(); } public var curEvent:Int = -1; + public var winHeight:Float = 0; public function changeTab(id:Int, save:Bool = true) { if (save) @@ -103,43 +105,48 @@ class CharterEventScreenNew extends MusicBeatSubstate { var curEvent = events[curEvent]; eventName.text = curEvent.name; // add new elements - var y:Float = eventName.y + eventName.height + 10; + winHeight = eventName.y + eventName.height + 6; + bWidth = eventName.x + eventName.width+16; + for(k=>param in EventsData.getEventParams(curEvent.name)) { function addLabel() { - var label:UIText = new UIText(eventName.x, y, 0, param.name); - y += label.height + 4; + var label:UIText = new UIText(eventName.x+6, winHeight, 0, param.name); + winHeight += label.height + 4; paramsPanel.add(label); + + bWidth = Math.max(bWidth, label.x+label.width+10); }; var value:Dynamic = CoolUtil.getDefault(curEvent.params[k], param.defValue); var lastAdded = switch(param.type) { case TString: addLabel(); - var textBox:UITextBox = new UITextBox(eventName.x, y, cast value); + var textBox:UITextBox = new UITextBox(eventName.x+6, winHeight, cast value); paramsPanel.add(textBox); paramsFields.push(textBox); textBox; case TBool: - var checkbox = new UICheckbox(eventName.x, y, param.name, cast value); + winHeight += 2; + var checkbox = new UICheckbox(eventName.x+8, winHeight, param.name, cast value); paramsPanel.add(checkbox); paramsFields.push(checkbox); checkbox; case TInt(min, max, step): addLabel(); - var numericStepper = new UINumericStepper(eventName.x, y, cast value, step.getDefault(1), 0, min, max); + var numericStepper = new UINumericStepper(eventName.x+6, winHeight, cast value, step.getDefault(1), 0, min, max); paramsPanel.add(numericStepper); paramsFields.push(numericStepper); numericStepper; case TFloat(min, max, step, precision): addLabel(); - var numericStepper = new UINumericStepper(eventName.x, y, cast value, step.getDefault(1), precision, min, max); + var numericStepper = new UINumericStepper(eventName.x+6, winHeight, cast value, step.getDefault(1), precision, min, max); paramsPanel.add(numericStepper); paramsFields.push(numericStepper); numericStepper; case TStrumLine: addLabel(); - var dropdown = new UIDropDown(eventName.x, y, 320, 32, [for(k=>s in cast(FlxG.state, Charter).strumLines.members) 'Strumline #${k+1} (${s.strumLine.characters[0]})'], cast value); + var dropdown = new UIDropDown(eventName.x+6, winHeight, 320, 32, [for(k=>s in cast(FlxG.state, Charter).strumLines.members) 'Strumline #${k+1} (${s.strumLine.characters[0]})'], cast value); paramsPanel.add(dropdown); paramsFields.push(dropdown); dropdown; case TColorWheel: addLabel(); - var colorWheel = new UIColorwheel(eventName.x, y, value is String ? FlxColor.fromString(value) : Std.int(value)); + var colorWheel = new UIColorwheel(eventName.x+6, winHeight, value is String ? FlxColor.fromString(value) : Std.int(value)); paramsPanel.add(colorWheel); paramsFields.push(colorWheel); colorWheel; case TDropDown(options): @@ -148,20 +155,20 @@ class CharterEventScreenNew extends MusicBeatSubstate { if(optionIndex < 0) { optionIndex = 0; } - var dropdown = new UIDropDown(eventName.x, y, 320, 32, options, optionIndex); + var dropdown = new UIDropDown(eventName.x+6, winHeight, 320, 32, options, optionIndex); paramsPanel.add(dropdown); paramsFields.push(dropdown); dropdown; case TCharacter: addLabel(); var charFileList = Character.getList(false); - var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x+6, winHeight, cast value); textBox.suggestItems = charFileList; paramsPanel.add(textBox); paramsFields.push(textBox); textBox; case TStage: addLabel(); var stageFileList = Stage.getList(false); - var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x, y, cast value); + var textBox:UIAutoCompleteTextBox = new UIAutoCompleteTextBox(eventName.x+6, winHeight, cast value); textBox.suggestItems = stageFileList; paramsPanel.add(textBox); paramsFields.push(textBox); textBox; @@ -170,28 +177,16 @@ class CharterEventScreenNew extends MusicBeatSubstate { null; } if (lastAdded is UISliceSprite) { - y += cast(lastAdded, UISliceSprite).bHeight + 4; - bWidth = Math.max(bWidth, cast(lastAdded, UISliceSprite).bWidth + eventName.x + 10); + winHeight += cast(lastAdded, UISliceSprite).bHeight + 4; + bWidth = Math.max(bWidth, eventName.x + 6 + cast(lastAdded, UISliceSprite).bWidth + 6 + 10); } else if (lastAdded is FlxSprite) { - y += cast(lastAdded, FlxSprite).height + 6; - bWidth = Math.max(bWidth, cast(lastAdded, UISliceSprite).width + eventName.x + 10); + winHeight += cast(lastAdded, FlxSprite).height + 6; + bWidth = Math.max(bWidth, eventName.x + 6 + cast(lastAdded, FlxSprite).width + 6 + 10); } } - y = Math.max(y, eventsList.buttonSize.y * (eventsList.buttons.length + 1)); - - if (bg.getScreenPosition(Charter.instance.charterCamera).y + y > FlxG.height) { - var ychange = (bg.getScreenPosition(Charter.instance.charterCamera).y + y) - FlxG.height; - cam.y -= ychange; - bg.y -= ychange; - } - - bg.bWidth = cast bWidth; - bg.bHeight = cast y + 10; - cam.width = cast bWidth; - cam.height = cast y + 10; - eventsList.bHeight = cast y + 30; + winHeight = Math.max(winHeight - 4, (eventsList.buttonSize.y * (eventsList.buttons.length + 1)) + 4); } else { eventName.text = "No event"; curEvent = -1; @@ -199,21 +194,44 @@ class CharterEventScreenNew extends MusicBeatSubstate { update(0); } - var clickedWhileHovering = false; + public function boundWindow() { + var screenPos:FlxPoint = CoolUtil.pointToScreenPosition(FlxPoint.get(chartEvent.x, chartEvent.y + chartEvent.bHeight)); + screenPos.x -= chartEvent.global ? -8 : 68+12; screenPos.y += 8; + + var screenSpaceY:Float = (screenPos.y + winHeight + 10) - FlxG.height; + if (screenSpaceY > -8) winHeight -= screenSpaceY + 8; + + screenPos.x = FlxMath.bound(screenPos.x, 4, FlxG.width - bWidth - 4); + + bg.bWidth = cam.width = cast bWidth-6; + bg.bHeight = cam.height = cast winHeight + 10; + eventsList.bHeight = cast winHeight - 10; + + cam.x = screenPos.x; cam.y = screenPos.y; + screenPos.put(); + } + + @:noCompletion var __clickedWhileHovering = false; + @:noCompletion var __ignoreLastClick:Bool = false; override public function update(elapsed:Float) { var mousepoint = FlxG.mouse.getPositionInCameraView(cam); - if (FlxG.mouse.justPressed && (FlxMath.inBounds(mousepoint.x, 0, cam.width) && FlxMath.inBounds(mousepoint.y, 0, cam.height))) clickedWhileHovering = true; + if (FlxG.mouse.justPressed && (FlxMath.inBounds(mousepoint.x, 0, bg.bWidth) && FlxMath.inBounds(mousepoint.y, 0, bg.bHeight))) __clickedWhileHovering = true; - if (FlxMath.inBounds(mousepoint.x, 0, cam.width) && FlxMath.inBounds(mousepoint.y, 0, cam.height)) { + if (FlxMath.inBounds(mousepoint.x, 0, bg.bWidth) && FlxMath.inBounds(mousepoint.y, 0, bg.bHeight)) { Charter.instance.shouldScroll = false; } - else if (Charter.instance.curContextMenu == null && ((FlxG.mouse.justReleased && !clickedWhileHovering) || FlxG.mouse.wheel != 0)) { - Charter.instance.shouldScroll = true; - quit(); + else if (Charter.instance.curContextMenu == null && ((FlxG.mouse.justReleased && !__clickedWhileHovering) || FlxG.mouse.wheel != 0)) { + if (__ignoreLastClick) + __ignoreLastClick = false; + else { + Charter.instance.shouldScroll = true; + quit(); + } } super.update(elapsed); - if (FlxG.mouse.justReleased) clickedWhileHovering = false; + if (FlxG.mouse.justReleased) __clickedWhileHovering = false; + boundWindow(); } public function quit() { diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index 963cffed..896579f9 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -132,9 +132,10 @@ class UIButtonList extends UIWindow { addButton.selectable = (hovered && !dragging); if (__lastDrawCameras[0] != null) { - buttonCameras.height = bHeight - cameraSpacing - 1; // -1 for the little gap at the bottom of the window + // -1 on each vertical sides for the little gap at the bottom of the window + buttonCameras.height = bHeight - cameraSpacing - 2; buttonCameras.x = __lastDrawCameras[0].x + x - __lastDrawCameras[0].scroll.x; - buttonCameras.y = __lastDrawCameras[0].y + y + cameraSpacing - __lastDrawCameras[0].scroll.y; + buttonCameras.y = __lastDrawCameras[0].y + y + cameraSpacing - __lastDrawCameras[0].scroll.y+1; buttonCameras.zoom = __lastDrawCameras[0].zoom; } } From 56913f88e0672d1d1e74e6ab88578884c6589c63 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Wed, 12 Mar 2025 15:10:17 -0700 Subject: [PATCH 3/7] kinda important.,., --- source/funkin/editors/charter/Charter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 2f166df6..e10f7a1b 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1330,7 +1330,7 @@ class Charter extends UIState { if (true) { __crochet = ((60 / Conductor.bpm) * 1000); - if(FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null) + if(FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null && (this.subState == null || !(this.subState is CharterEventScreenNew))) UIUtil.processShortcuts(topMenu); if (!topMenuSpr.anyMenuOpened) { From 6ae02ebd3e72edda79830e94fb0e1e276aae793a Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Wed, 12 Mar 2025 23:58:04 -0700 Subject: [PATCH 4/7] stuff and inc --- .../editors/charter/CharterEventScreenNew.hx | 71 +++++++++++++++---- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx index c96371ab..ee859a41 100644 --- a/source/funkin/editors/charter/CharterEventScreenNew.hx +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -12,6 +12,7 @@ using StringTools; class CharterEventScreenNew extends MusicBeatSubstate { public var cam:FlxCamera; + public var eventCam:FlxCamera; public var chartEvent:CharterEvent; public var events:Array = []; @@ -22,6 +23,8 @@ class CharterEventScreenNew extends MusicBeatSubstate { public var paramsPanel:FlxGroup; public var paramsFields:Array = []; + public var downIndicator:UIText; + public var bWidth:Float; var bg:UISliceSprite; @@ -44,7 +47,12 @@ class CharterEventScreenNew extends MusicBeatSubstate { camera = cam = new FlxCamera(); cam.bgColor = 0; + + eventCam = new FlxCamera(); + eventCam.bgColor = 0; + FlxG.cameras.add(cam, false); + FlxG.cameras.add(eventCam, false); bg = new UISliceSprite(0, 0, 0, 0, 'editors/ui/inputbox'); bg.alpha = 0.75; @@ -53,13 +61,20 @@ class CharterEventScreenNew extends MusicBeatSubstate { add(bg); paramsPanel = new FlxGroup(); - paramsPanel.cameras = [cam]; + paramsPanel.cameras = [eventCam]; add(paramsPanel); - eventName = new UIText(10+75+10, 10, 0, "", 24); - eventName.cameras = [cam]; + eventName = new UIText(0, 0, 0, "", 24); + eventName.cameras = [eventCam]; add(eventName); + downIndicator = new UIText(0, 0, 0, "↓", 16); + downIndicator.cameras = [eventCam]; + downIndicator.scrollFactor.set(); + downIndicator.borderSize = 2; + downIndicator.alpha = 0; + add(downIndicator); + eventsList = new UIButtonList(10, 10, 75, 570, null, FlxPoint.get(75, 40), null, 0); eventsList.alpha = 0; eventsList.cameras = [cam]; @@ -186,7 +201,9 @@ class CharterEventScreenNew extends MusicBeatSubstate { } } - winHeight = Math.max(winHeight - 4, (eventsList.buttonSize.y * (eventsList.buttons.length + 1)) + 4); + bWidth += 10+75+10+4; // add events list width to account for event name being on a diff cam +4 because margins >:D + winHeight = Math.max(winHeight, (eventsList.buttonSize.y * (eventsList.buttons.length + 1))-4) + 10; + eventCam.scroll.y = 0; } else { eventName.text = "No event"; curEvent = -1; @@ -198,29 +215,54 @@ class CharterEventScreenNew extends MusicBeatSubstate { var screenPos:FlxPoint = CoolUtil.pointToScreenPosition(FlxPoint.get(chartEvent.x, chartEvent.y + chartEvent.bHeight)); screenPos.x -= chartEvent.global ? -8 : 68+12; screenPos.y += 8; - var screenSpaceY:Float = (screenPos.y + winHeight + 10) - FlxG.height; - if (screenSpaceY > -8) winHeight -= screenSpaceY + 8; - - screenPos.x = FlxMath.bound(screenPos.x, 4, FlxG.width - bWidth - 4); - bg.bWidth = cam.width = cast bWidth-6; bg.bHeight = cam.height = cast winHeight + 10; eventsList.bHeight = cast winHeight - 10; + // Bound stuff from being off screen + var screenSpaceY:Float = (screenPos.y + winHeight + 10) - FlxG.height; + screenPos.x = FlxMath.bound(screenPos.x, 4, FlxG.width - bWidth - 4); + if (screenSpaceY > -8) { // border of 8 of screen >:D + bg.bHeight -= cast screenSpaceY + 8; cam.height -= cast screenSpaceY + 8; + + screenSpaceY -= 20; // events list is slight diff with its camera + if (screenSpaceY > -8) eventsList.bHeight -= cast screenSpaceY + 8; + } + cam.x = screenPos.x; cam.y = screenPos.y; + + eventCam.x = cam.x+10+75+10; eventCam.y = cam.y+10; + eventCam.width = bg.bWidth-(10+75+10); eventCam.height = bg.bHeight - 20; + screenPos.put(); } @:noCompletion var __clickedWhileHovering = false; @:noCompletion var __ignoreLastClick:Bool = false; + var sinner:Float = 0; override public function update(elapsed:Float) { var mousepoint = FlxG.mouse.getPositionInCameraView(cam); + boundWindow(); + if (FlxG.mouse.justPressed && (FlxMath.inBounds(mousepoint.x, 0, bg.bWidth) && FlxMath.inBounds(mousepoint.y, 0, bg.bHeight))) __clickedWhileHovering = true; + var boundingParamY:Float = 0; + var lastParamSprite:FlxObject = paramsFields != null ? cast paramsFields[paramsFields.length-1] : null; + if (lastParamSprite != null) boundingParamY = lastParamSprite.y; + if (FlxMath.inBounds(mousepoint.x, 0, bg.bWidth) && FlxMath.inBounds(mousepoint.y, 0, bg.bHeight)) { Charter.instance.shouldScroll = false; - } - else if (Charter.instance.curContextMenu == null && ((FlxG.mouse.justReleased && !__clickedWhileHovering) || FlxG.mouse.wheel != 0)) { + if (FlxMath.inBounds(mousepoint.x, 10+75+10, eventCam.width) && FlxMath.inBounds(mousepoint.y, 10, eventCam.height)) { + var boundingParamYHeight:Float = boundingParamY; + if (lastParamSprite != null) { + if (lastParamSprite is UISliceSprite) boundingParamYHeight += cast(lastParamSprite, UISliceSprite).bHeight; + else if (lastParamSprite is FlxSprite) boundingParamYHeight += cast(lastParamSprite, FlxSprite).height; + } + + if (boundingParamYHeight > eventCam.height) + eventCam.scroll.y = CoolUtil.bound(eventCam.scroll.y - (FlxG.mouse.wheel * 12), 0, boundingParamYHeight - eventCam.height); + } + } else if (Charter.instance.curContextMenu == null && ((FlxG.mouse.justReleased && !__clickedWhileHovering) || FlxG.mouse.wheel != 0)) { if (__ignoreLastClick) __ignoreLastClick = false; else { @@ -231,7 +273,11 @@ class CharterEventScreenNew extends MusicBeatSubstate { super.update(elapsed); if (FlxG.mouse.justReleased) __clickedWhileHovering = false; - boundWindow(); + + sinner += elapsed; + + downIndicator.setPosition(((eventCam.width/2)) - (downIndicator.fieldWidth/2), (eventCam.height-downIndicator.height) - 2 - (FlxMath.fastSin(sinner*2) * 2)); + downIndicator.alpha = CoolUtil.fpsLerp(downIndicator.alpha, (eventCam.scroll.y+eventCam.height > boundingParamY) ? 0 : 1, 1/3); } public function quit() { @@ -284,6 +330,7 @@ class CharterEventScreenNew extends MusicBeatSubstate { public override function destroy() { super.destroy(); FlxG.cameras.remove(cam); + FlxG.cameras.remove(eventCam); } } From e68f2415049d12431a771a7758f1ce766a88a6f8 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Thu, 13 Mar 2025 15:19:42 -0700 Subject: [PATCH 5/7] fix jank --- .../editors/charter/CharterEventScreenNew.hx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx index ee859a41..988f6939 100644 --- a/source/funkin/editors/charter/CharterEventScreenNew.hx +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -115,14 +115,16 @@ class CharterEventScreenNew extends MusicBeatSubstate { paramsPanel.remove(e); } + winHeight = eventName.y + eventName.height + 6; + eventCam.scroll.y = 0; + if (id >= 0 && id < events.length) { curEvent = id; var curEvent = events[curEvent]; eventName.text = curEvent.name; - // add new elements - winHeight = eventName.y + eventName.height + 6; bWidth = eventName.x + eventName.width+16; + // add new elements for(k=>param in EventsData.getEventParams(curEvent.name)) { function addLabel() { var label:UIText = new UIText(eventName.x+6, winHeight, 0, param.name); @@ -200,14 +202,15 @@ class CharterEventScreenNew extends MusicBeatSubstate { bWidth = Math.max(bWidth, eventName.x + 6 + cast(lastAdded, FlxSprite).width + 6 + 10); } } - - bWidth += 10+75+10+4; // add events list width to account for event name being on a diff cam +4 because margins >:D - winHeight = Math.max(winHeight, (eventsList.buttonSize.y * (eventsList.buttons.length + 1))-4) + 10; - eventCam.scroll.y = 0; } else { eventName.text = "No event"; curEvent = -1; + + bWidth = eventName.x + eventName.width+16; } + + winHeight = Math.max(winHeight, (eventsList.buttonSize.y * (eventsList.buttons.length + 1))-4) + 10; + bWidth += 10+75+10+4; // add events list width to account for event name being on a diff cam +4 because margins >:D update(0); } @@ -287,12 +290,13 @@ class CharterEventScreenNew extends MusicBeatSubstate { if (events.length <= 0) Charter.instance.deleteSelection([chartEvent]); else if (events.length > 0) { - chartEvent.events = [for (i in eventsList.buttons.members) i.event]; var oldEvents:Array = chartEvent.events.copy(); + chartEvent.events = [for (i in eventsList.buttons.members) i.event]; chartEvent.refreshEventIcons(); Charter.instance.updateBPMEvents(); Charter.undos.addToUndo(CEditEvent(chartEvent, oldEvents, [for (event in events) Reflect.copy(event)])); + } close(); From 326f4e1fe3c4c2b62117a0e61de95ded394c15f4 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Fri, 14 Mar 2025 14:14:03 -0700 Subject: [PATCH 6/7] 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)); From 196d14ae824945dbbfd8ce9ed4b82acf98ad60f5 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Tue, 18 Mar 2025 00:41:20 -0700 Subject: [PATCH 7/7] gdfgd --- source/funkin/editors/charter/CharterEventScreenNew.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/CharterEventScreenNew.hx b/source/funkin/editors/charter/CharterEventScreenNew.hx index e2a39de4..06ee004c 100644 --- a/source/funkin/editors/charter/CharterEventScreenNew.hx +++ b/source/funkin/editors/charter/CharterEventScreenNew.hx @@ -224,7 +224,7 @@ class CharterEventScreenNew extends MusicBeatSubstate { // Bound stuff from being off screen var screenSpaceY:Float = (screenPos.y + winHeight + 10) - FlxG.height; - screenPos.x = FlxMath.bound(screenPos.x, 4, FlxG.width - bWidth - 4); + screenPos.x = FlxMath.bound(screenPos.x, 4, (FlxG.width - 20) - bWidth - 4); // FlxG.width - 20 for the scroll bar on the right if (screenSpaceY > -8) { // border of 8 of screen >:D bg.bHeight -= cast screenSpaceY + 8; cam.height -= cast screenSpaceY + 8;