From da38c1738ad97cfa15d87300e1686749cf804ffb Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Wed, 26 Jul 2023 21:34:09 -0700 Subject: [PATCH] ok i think it works now --- source/funkin/editors/charter/Charter.hx | 39 ++++++++++++++----- source/funkin/editors/charter/CharterEvent.hx | 4 +- .../funkin/editors/charter/CharterEventAdd.hx | 7 ++-- .../editors/charter/CharterEventScreen.hx | 7 ++-- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 83985f9a..2f337e3e 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -378,7 +378,7 @@ class Charter extends UIState { }; uiGroup.add(scrollBar); - songPosInfo = new UIText(FlxG.width - 30 - 400, scrollBar.y + 10, 400, "00:00\nBeat: 0\nStep: 0\nMeasure: 0"); + songPosInfo = new UIText(FlxG.width - 30 - 400, scrollBar.y + 10, 400, "00:00\nBeat: 0\nStep: 0\nMeasure: 0\nBPM: 0"); songPosInfo.alignment = RIGHT; uiGroup.add(songPosInfo); @@ -403,7 +403,6 @@ class Charter extends UIState { addEventSpr.alpha = 0; addEventSpr.cameras = [charterCamera]; - // adds grid and notes so that they're ALWAYS behind the UI add(gridBackdrop); add(sectionSeparator); @@ -851,7 +850,8 @@ class Charter extends UIState { songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(FlxG.sound.music.length)}' + '\nStep: ${curStep}' + '\nBeat: ${curBeat}' - + '\nMeasure: ${curMeasure}'; + + '\nMeasure: ${curMeasure}' + + '\nBPM: ${Conductor.bpm}'; if (FlxG.sound.music.playing) { conductorFollowerSpr.y = curStepFloat * 40; @@ -1229,16 +1229,10 @@ class Charter extends UIState { public function buildChart() { PlayState.SONG.strumLines = []; - PlayState.SONG.events = []; for(s in strumLines) { s.strumLine.notes = []; PlayState.SONG.strumLines.push(s.strumLine); } - for(e in eventsGroup.members) { - for(event in e.events) { - PlayState.SONG.events.push(event); - } - } for(n in notesGroup.members) { var strLineID = Std.int(n.id / 4); if (PlayState.SONG.strumLines[strLineID] != null) { @@ -1251,6 +1245,33 @@ class Charter extends UIState { }); } } + buildEvents(); + } + + public function buildEvents() { + PlayState.SONG.events = []; + for(e in eventsGroup.members) { + for(event in e.events) { + event.time = Conductor.getTimeForStep(e.step); + PlayState.SONG.events.push(event); + } + } + } + + public function updateBPMEvents(newEvent:CharterEvent) { + var hasBPMChange = false; + for (event in newEvent.events) + if (event.name == "BPM Change") { + hasBPMChange = true; + break; + } + + if (!hasBPMChange) return; + buildEvents(); + + // Za BPM + Conductor.mapBPMChanges(PlayState.SONG); + Conductor.changeBPM(PlayState.SONG.meta.bpm, cast PlayState.SONG.meta.beatsPerMesure.getDefault(4), cast PlayState.SONG.meta.stepsPerBeat.getDefault(4)); } public inline function hitsoundsEnabled(id:Int) diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index 796247c6..8123f3ed 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -77,8 +77,8 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { } public function handleDrag(change:FlxPoint) { - step += change.x; - y = (step * 40) - 17; + y = ((step += change.x) * 40) - 17; + Charter.instance.updateBPMEvents(this); } public function refreshEventIcons() { diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index 71378b8a..19547f1a 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -19,14 +19,13 @@ class CharterEventAdd extends UISliceSprite { public override function onHovered() { super.onHovered(); if (FlxG.mouse.justReleased) { - var state = cast(FlxG.state, Charter); if (curCharterEvent != null) { - FlxG.state.openSubState(new CharterEventScreen(curCharterEvent)); + Charter.instance.openSubState(new CharterEventScreen(curCharterEvent)); } else { var event:CharterEvent = new CharterEvent(step, []); - state.eventsGroup.add(event); + Charter.instance.eventsGroup.add(event); - FlxG.state.openSubState(new CharterEventScreen(event)); + Charter.instance.openSubState(new CharterEventScreen(event)); } } } diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 8859738e..c4f913d4 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -69,11 +69,10 @@ class CharterEventScreen extends UISubstateWindow { saveCurTab(); chartEvent.refreshEventIcons(); - if (chartEvent.events.length <= 0) { - var state = cast(FlxG.state, Charter); - state.eventsGroup.remove(chartEvent, true); - } + if (chartEvent.events.length <= 0) + Charter.instance.eventsGroup.remove(chartEvent, true); close(); + Charter.instance.updateBPMEvents(chartEvent); }); saveButton.x -= saveButton.bWidth; saveButton.y -= saveButton.bHeight;