From 6149753495307ab4befc5c40308218cdd2ae3246 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 19 Apr 2023 02:48:18 +0200 Subject: [PATCH] play here --- TODO.md | 2 +- source/funkin/editors/charter/Charter.hx | 16 +++++++++++----- source/funkin/game/PlayState.hx | 5 +++-- source/funkin/game/StrumLine.hx | 13 ++++++++----- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/TODO.md b/TODO.md index b22cc686..ba57f794 100644 --- a/TODO.md +++ b/TODO.md @@ -11,7 +11,7 @@ - [x] Fix the strumlines bar when zooming out - [ ] Step based zooming - [ ] Algorithm to make note placements faster & sorted out - - [ ] Play here working + - [x] Play here working - [ ] Events (including Camera Movement) - [ ] Custom Notes - [ ] Metadata Editing diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index f8c2163e..45e61f5d 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -341,7 +341,8 @@ class Charter extends UIState { scrollBar = new UIScrollBar(FlxG.width - 20, topMenuSpr.bHeight, 1000, 0, 100); scrollBar.cameras = [uiCamera]; scrollBar.onChange = function(v) { - Conductor.songPosition = Conductor.getTimeForStep(v); + if (!FlxG.sound.music.playing) + Conductor.songPosition = Conductor.getTimeForStep(v); }; uiGroup.add(scrollBar); @@ -658,6 +659,9 @@ class Charter extends UIState { } } + public static var startTime:Float = 0; + public static var startHere:Bool = false; + function updateDisplaySprites() { conductorFollowerSpr.scale.set(gridBackdrop.strumlinesAmount * 4 * 40, 4); conductorFollowerSpr.updateHitbox(); @@ -793,9 +797,9 @@ class Charter extends UIState { FlxG.sound.music.pause(); vocals.pause(); } else { - vocals.time = FlxG.sound.music.time = Conductor.songPosition; FlxG.sound.music.play(); vocals.play(); + vocals.time = FlxG.sound.music.time = Conductor.songPosition; } } @@ -834,11 +838,11 @@ class Charter extends UIState { inline function _chart_playtest(_) playtestChart(0, false); inline function _chart_playtest_here(_) - playtestChart(Conductor.songPosition, false); + playtestChart(Conductor.songPosition, false, true); inline function _chart_playtest_opponent(_) playtestChart(0, true); inline function _chart_playtest_opponent_here(_) - playtestChart(Conductor.songPosition, true); + playtestChart(Conductor.songPosition, true, true); function _playback_metronome(t) { t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0; @@ -913,8 +917,10 @@ class Charter extends UIState { ])); } - public function playtestChart(time:Float = 0, opponentMode = false) { + public function playtestChart(time:Float = 0, opponentMode = false, here = false) { buildChart(); + startHere = here; + startTime = Conductor.songPosition; PlayState.opponentMode = opponentMode; PlayState.chartingMode = true; FlxG.switchState(new PlayState()); diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 1724ae38..cc0d09d1 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1,5 +1,6 @@ package funkin.game; +import funkin.editors.charter.Charter; import funkin.savedata.FunkinSave; import flixel.graphics.FlxGraphic; import funkin.backend.chart.Chart; @@ -629,7 +630,7 @@ class PlayState extends MusicBeatState // CAMERA & HUD INITIALISATION #if REGION for(str in strumLines) - str.generate(str.data); + str.generate(str.data, (chartingMode && Charter.startHere) ? Charter.startTime : null); camFollow = new FlxObject(0, 0, 2, 2); camFollow.setPosition(camPos.x, camPos.y); @@ -858,7 +859,7 @@ class PlayState extends MusicBeatState vocals.pause(); inst.pause(); - inst.time = vocals.time = 0; + inst.time = vocals.time = (chartingMode && Charter.startHere) ? Charter.startTime : 0; vocals.play(); inst.play(); diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index bfa440f7..1755420a 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -64,7 +64,7 @@ class StrumLine extends FlxTypedGroup { private inline function set_ghostTapping(b:Bool):Bool return this.ghostTapping = b; - + private var strumOffset:Float = 0.25; public function new(characters:Array, strumOffset:Float = 0.25, cpu:Bool = false, opponentSide:Bool = true, ?controls:Controls) { @@ -77,10 +77,13 @@ class StrumLine extends FlxTypedGroup { this.notes = new NoteGroup(); } - public function generate(strumLine:ChartStrumLine) { + public function generate(strumLine:ChartStrumLine, ?startTime:Float) { if (strumLine.notes != null) for(note in strumLine.notes) { + if (startTime != null && startTime > note.time) + continue; + notes.add(new Note(this, note, false)); - + if (note.sLen > Conductor.stepCrochet * 0.75) { var len:Float = note.sLen; var curLen:Float = 0; @@ -108,10 +111,10 @@ class StrumLine extends FlxTypedGroup { public function updateNotes() { notes.forEach(updateNote); } - + var __updateNote_strum:Strum; public function updateNote(daNote:Note) { - + for(e in members) { if (e.ID == daNote.noteData % 4) { __updateNote_strum = e;