From daf3179f79278d69cf333318b71b81bda79b15fa Mon Sep 17 00:00:00 2001 From: Ralty <78720179+Raltyro@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:14:56 +0700 Subject: [PATCH] Conductor Final Continuous Tempo & Time Sigs --- .../charter/event-icons/BPM Change End.png | Bin 0 -> 215 bytes .../charter/event-icons/BPM Change Start.png | Bin 0 -> 204 bytes .../charter/event-icons/BPM Change.png | Bin 185 -> 186 bytes source/funkin/backend/system/Conductor.hx | 14 +++++-- source/funkin/backend/utils/CoolUtil.hx | 39 ++++++++++++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 assets/images/editors/charter/event-icons/BPM Change End.png create mode 100644 assets/images/editors/charter/event-icons/BPM Change Start.png diff --git a/assets/images/editors/charter/event-icons/BPM Change End.png b/assets/images/editors/charter/event-icons/BPM Change End.png new file mode 100644 index 0000000000000000000000000000000000000000..c8e19949b03b6e8b7506d5667a6adf0e807bd3e6 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJXMsm#F#`kNVGw3Kp1&dmC@2x& z6XFV_|NsBr_jmf=BYm3_SXed-W|@fs1^KQqvjHi_k|4ie28U-i(tw-@PZ!6Kid&`q zo?J&9c$jZ@hy4Hl@jyvOZRdgMO_MI}Z2a%baU!MJ;TFRLiS9E~igZ+NN^uuVoi4QF z_UbET+y5$shn9!hvV1?gRUt{+#l`2P_=7o>jM+c=6K62ZTX^%RKhO>aPgg&ebxsLQ E0CR9l0ssI2 literal 0 HcmV?d00001 diff --git a/assets/images/editors/charter/event-icons/BPM Change Start.png b/assets/images/editors/charter/event-icons/BPM Change Start.png new file mode 100644 index 0000000000000000000000000000000000000000..4011f562a415895872efde5165c1de32876780d0 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJXMsm#F#`kNVGw3Kp1&dmC@31> z6XFV_|NsBr_jh{7-v2DsoAs=6fg;9|?0-(U6n^@zF1~BQ+l7q!6B~}P&M}@4a8#^wFKfi7kdU3XgA;e(4vq}ku42C^|BvrA t*?FZb`HV9?Zxlb(RH|d$*zolyqv}c~#@H$Kl|Zu@JYD@<);T3K0RSURL{R!~g&P`~FU6*(?ZTyRCER0#b}6L4Lsu4$p3+0XZ(7E{-7;w~`r{ z#1&YW-NjYeIh>D394aU@EMwd}XG+i15C@+0Jy~yar?WD?L hD5=CFU@CB!;lXB}=YjDsKP) delta 130 zcmdnRxRY^$UG;x3==(dJWwRgy14G2@v)_RfV@Z%-FoVOh8)-m}v!{z=NX4yW1|~5! zaW;d3lE9({qaH;baq(nvgVUZTBRpA;6qo@)qxV74#YQp;Y?~~s95NkOv?!=Kw=gbZ bOOjx?lFTzb+)Y0WXdHv5tDnm{r-UW|jwLKL diff --git a/source/funkin/backend/system/Conductor.hx b/source/funkin/backend/system/Conductor.hx index c722c511..8a9fe6db 100644 --- a/source/funkin/backend/system/Conductor.hx +++ b/source/funkin/backend/system/Conductor.hx @@ -216,7 +216,7 @@ final class Conductor //if (beatsPerMeasure == curChange.beatsPerMeasure && stepsPerBeat == curChange.stepsPerBeat) continue; /* TODO: make so time sigs doesnt stop the bpm change if its in the duration of bpm change */ - if (curChange.songTime != time) curChange = mapBPMChange(curChange, time, curChange.bpm, null, prevChange); + if (curChange.songTime != time) curChange = mapBPMChange(prevChange = curChange, time, curChange.bpm, null, prevChange); curChange.beatsPerMeasure = params[0]; curChange.stepsPerBeat = params[1]; @@ -278,10 +278,16 @@ final class Conductor if (curChangeIndex != oldChangeIndex) { var prev = bpmChangeMap[oldChangeIndex]; - if (beatsPerMeasure != prev.beatsPerMeasure || stepsPerBeat != prev.stepsPerBeat) - onTimeSignatureChange.dispatch(beatsPerMeasure, stepsPerBeat); + if (prev) { + if (beatsPerMeasure != prev.beatsPerMeasure || stepsPerBeat != prev.stepsPerBeat) + onTimeSignatureChange.dispatch(beatsPerMeasure, stepsPerBeat); - if (curChange.bpm != prev.bpm) onBPMChange.dispatch(curChange.bpm, curChange.endSongTime); + if (curChange.bpm != prev.bpm) onBPMChange.dispatch(curChange.bpm, curChange.endSongTime); + } + else { + onTimeSignatureChange.dispatch(beatsPerMeasure, stepsPerBeat); + onBPMChange.dispatch(curChange.bpm, curChange.endSongTime); + } } if (curStep != (curStep = CoolUtil.floorInt(curStepFloat))) { diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index a9de75ca..e6af4393 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -737,6 +737,15 @@ class CoolUtil @:noUsing public static inline function maxInt(p1:Int, p2:Int) return p1 < p2 ? p2 : p1; + /** + * Equivalent of `Math.min`, except doesn't require a Int -> Float -> Int conversion. + * @param p1 + * @param p2 + * @return return p1 > p2 ? p2 : p1 + */ + @:noUsing public static inline function minInt(p1:Int, p2:Int) + return p1 > p2 ? p2 : p1; + /** * Equivalent of `Math.floor`, except doesn't require a Int -> Float -> Int conversion. * @param e Value to get the floor of. @@ -778,6 +787,36 @@ class CoolUtil return file.file; } + public static inline function bound(Value:Float, Min:Float, Max:Float):Float { + #if cpp + var _hx_tmp1:Float = Value; + var _hx_tmp2:Float = Min; + var _hx_tmp3:Float = Max; + return untyped __cpp__("((({0}) < ({1})) ? ({1}) : (({0}) > ({2})) ? ({2}) : ({0}))", _hx_tmp1, _hx_tmp2, _hx_tmp3); + #else + return (Value < Min) ? Min : (Value > Max) ? Max : Value; + #end + } + + public static inline function boundInt(Value:Int, Min:Int, Max:Int):Int { + #if cpp + var _hx_tmp1:Int = Value; + var _hx_tmp2:Int = Min; + var _hx_tmp3:Int = Max; + return untyped __cpp__("((({0}) < ({1})) ? ({1}) : (({0}) > ({2})) ? ({2}) : ({0}))", _hx_tmp1, _hx_tmp2, _hx_tmp3); + #else + return (Value < Min) ? Min : (Value > Max) ? Max : Value; + #end + } + + public static inline function boolToInt(b:Bool):Int { + #if cpp + return untyped __cpp__("(({0}) ? 1 : 0)", b); + #else + return b ? 1 : 0; + #end + } + /** * Converts a string of "1..3,5,7..9,8..5" into an array of numbers like [1,2,3,5,7,8,9,8,7,6,5] * @param input String to parse