new offset setting (testing required)

This commit is contained in:
Frakist
2023-07-28 10:31:24 +03:00
parent bff5465b28
commit a28c15a754
8 changed files with 84 additions and 81 deletions
+2 -1
View File
@@ -7,4 +7,5 @@ latest/windows/haxe/
!.vscode/tasks.json
.haxelib/
docs/doc.xml
mods/Baldi's Basics in Funkin'/
mods/Baldi's Basics in Funkin'/
project.xml
-2
View File
@@ -185,8 +185,6 @@
<haxelib name="discord-rpc" if="DISCORD_RPC"/>
<haxelib name="markdown" />
<haxelib name="hxcpp-debug-server" if="desktop debug"/>
<haxedef name="no-deprecation-warnings"/>
<!-- _________________________________ Additional stuff _______________________________ -->
+12 -4
View File
@@ -58,8 +58,16 @@ class Conductor
/**
* Current position of the song, in milliseconds.
*/
public static var songPosition:Float;
public static var songPosition(get, default):Float;
private static function get_songPosition() {
if (songOffset != Options.songOffset) trace(songOffset = Options.songOffset);
return songPosition - songOffset;
}
/**
* Offset of the song
*/
public static var songOffset:Float = 0;
/**
* Current step
@@ -159,15 +167,15 @@ class Conductor
private static function __updateSongPos(elapsed:Float) {
if (FlxG.sound.music == null || !FlxG.sound.music.playing) {
lastSongPos = FlxG.sound.music != null ? FlxG.sound.music.time : 0;
lastSongPos = FlxG.sound.music != null ? FlxG.sound.music.time - songOffset : -songOffset;
return;
}
if (lastSongPos != (lastSongPos = FlxG.sound.music.time)) {
if (lastSongPos != (lastSongPos = FlxG.sound.music.time - songOffset)) {
// update conductor
songPosition = lastSongPos;
} else {
songPosition += elapsed * 1000;
songPosition = songPosition + songOffset + elapsed * 1000;
}
}
@@ -1,5 +1,4 @@
#if macro
import haxe.macro.*;
import haxe.macro.Expr;
import haxe.macro.Type;
#end
+36 -70
View File
@@ -585,8 +585,6 @@ class Charter extends UIState {
if (FlxG.mouse.justPressed)
FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
if (gridBackdropDummy.hovered) {
// SETUP
// AUTO DETECT
if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20))
gridActionType = BOX;
@@ -602,7 +600,7 @@ class Charter extends UIState {
note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Math.floor(mousePos.y / 40), id, 0, 0);
notesGroup.add(note);
selection = [note];
addToUndo(CPlaceNote(note));
addToUndo(CCreateSelection([note]));
}
}
}
@@ -670,18 +668,37 @@ class Charter extends UIState {
return null;
}
public function createSelection(selection:Selection, addToUndo:Bool = true) {
if (selection.length <= 0) return [];
selection.loop(function (n:CharterNote) {
notesGroup.add(n);
n.revive();
}, function (e:CharterEvent) {
eventsGroup.add(e);
e.revive();
});
sortNotes();
if (addToUndo)
this.addToUndo(CCreateSelection(selection));
return [];
}
public function deleteSelection(selection:Selection, addToUndo:Bool = true) {
if (selection.length <= 0) return [];
selection.loop(function (note:CharterNote) {
notesGroup.remove(note, true);
note.kill();
this.selection.remove(note);
}, function (event:CharterEvent) {
eventsGroup.remove(event, true);
event.kill();
this.selection.remove(event);
});
for (objects in [notesGroup, eventsGroup]) {
var group = cast(objects, FlxTypedGroup<Dynamic>);
var member = 0;
while(member < group.members.length) {
var s = group.members[member];
if (selection.contains(s))
deleteSingleSelection(s, false);
else member++;
}
}
sortNotes();
if (addToUndo)
this.addToUndo(CDeleteSelection(selection));
@@ -1017,40 +1034,14 @@ class Charter extends UIState {
selection = [];
var v = undoList.shift();
switch(v) {
case null:
// do nothing
case null: // do nothing
case CCreateSelection(selection):
selection.loop(function (n:CharterNote) {
notesGroup.remove(n, true);
n.kill();
this.selection.remove(n);
}, function (e:CharterEvent) {
eventsGroup.remove(e, true);
e.kill();
this.selection.remove(e);
});
deleteSelection(selection, false);
case CDeleteSelection(selection):
selection.loop(function (n:CharterNote) {
notesGroup.add(n);
n.revive();
}, function (e:CharterEvent) {
eventsGroup.add(e);
e.revive();
});
sortNotes();
case CPlaceNote(note):
notesGroup.remove(note, true);
note.kill();
selection.remove(note);
createSelection(selection, false);
case CSustainChange(changes):
for(n in changes)
n.note.updatePos(n.note.step, n.note.id, n.before, n.note.type);
case CPlaceEvent(event):
eventsGroup.remove(event, true);
event.kill();
selection.remove(event);
case CEditEvent(event, oldEvents, newEvents):
//
case CSelectionDrag(selection, change):
for (s in selection)
if (s.draggable) s.handleDrag(change * -1);
@@ -1079,32 +1070,11 @@ class Charter extends UIState {
selection = [];
var v = redoList.shift();
switch(v) {
case null:
// do nothing
case null: // do nothing
case CCreateSelection(selection):
selection.loop(function (n:CharterNote) {
notesGroup.add(n);
n.revive();
}, function (e:CharterEvent) {
eventsGroup.add(e);
e.revive();
});
createSelection(selection, false);
case CDeleteSelection(selection):
selection.loop(function (n:CharterNote) {
notesGroup.remove(n, true);
n.kill();
}, function (e:CharterEvent) {
eventsGroup.remove(e, true);
e.kill();
});
case CPlaceNote(note):
notesGroup.add(note);
note.revive();
case CPlaceEvent(event):
eventsGroup.add(event);
event.revive();
case CEditEvent(event, oldEvents, newEvents):
//
deleteSelection(selection, false);
case CSustainChange(changes):
for(n in changes)
n.note.updatePos(n.note.step, n.note.id, n.after, n.note.type);
@@ -1264,7 +1234,6 @@ class Charter extends UIState {
public function updateBPMEvents(newEvent:CharterEvent) {
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));
@@ -1276,13 +1245,10 @@ class Charter extends UIState {
}
enum CharterChange {
CPlaceNote(note:CharterNote);
CSustainChange(notes:Array<NoteSustainChange>);
CPlaceEvent(event:CharterEvent); // TODO
CEditEvent(event:CharterEvent, oldEvents:Array<ChartEvent>, newEvents:Array<ChartEvent>); // TODO
CCreateSelection(selection:Selection);
CDeleteSelection(selection:Selection);
CSelectionDrag(selection:Selection, change:FlxPoint);
CSustainChange(notes:Array<NoteSustainChange>);
CCreateStrumLine(strumLineID:Int, strumLine:ChartStrumLine);
CDeleteStrumLine(strumLineID:Int, strumLine:ChartStrumLine);
}
+3 -3
View File
@@ -809,7 +809,7 @@ class PlayState extends MusicBeatState
startedCountdown = true;
Conductor.songPosition = 0;
Conductor.songPosition -= Conductor.crochet * introLength;
Conductor.songPosition -= Conductor.crochet * introLength - Conductor.songOffset;
var swagCounter:Int = 0;
@@ -1040,7 +1040,7 @@ class PlayState extends MusicBeatState
FlxG.sound.music.play();
Conductor.songPosition = FlxG.sound.music.time;
vocals.time = Conductor.songPosition;
vocals.time = Conductor.songPosition + Conductor.songOffset;
vocals.play();
scripts.call("onVocalsResync");
}
@@ -1128,7 +1128,7 @@ class PlayState extends MusicBeatState
{
if (startedCountdown)
{
Conductor.songPosition += elapsed * 1000;
Conductor.songPosition += Conductor.songOffset + elapsed * 1000;
if (Conductor.songPosition >= 0)
startSong();
}
+1
View File
@@ -31,6 +31,7 @@ class Options
public static var betaUpdates:Bool = false;
public static var splashesEnabled:Bool = true;
public static var hitWindow:Float = 250;
public static var songOffset:Float = 0;
public static var framerate:Int = 120;
public static var gpuOnlyBitmaps:Bool = #if mac false #else true #end; // causes issues on mac
@@ -1,6 +1,9 @@
package funkin.options.categories;
import funkin.backend.system.Conductor;
class GameplayOptions extends OptionsScreen {
var __metronome = FlxG.sound.load(Paths.sound('editors/charter/metronome'));
public override function new() {
super("Gameplay", 'Change Gameplay options such as Downscroll, Scroll Speed, Naughtyness...');
add(new Checkbox(
@@ -11,6 +14,14 @@ class GameplayOptions extends OptionsScreen {
"Ghost Tapping",
"If unchecked, trying to hit any strum that have no note that can be hit will cause a miss.",
"ghostTapping"));
add(new NumOption(
"Song Offset",
"Changes the offset at which the song should start",
-999, // minimum
999, // maximum
1, // change
"songOffset", // save name or smth
__changeOffset)); // callback
add(new Checkbox(
"Naughtyness",
"If unchecked, will censor Week 7 cutscenes",
@@ -20,4 +31,23 @@ class GameplayOptions extends OptionsScreen {
"If unchecked, will disable camera zooming every 4 beats",
"camZoomOnBeat"));
}
private function __changeOffset(offset) Conductor.songOffset = offset;
var __lastBeat:Int = 0;
var __lastSongBeat:Int = 0;
override function update(elapsed) {
super.update(elapsed);
FlxG.camera.zoom = CoolUtil.fpsLerp(FlxG.camera.zoom, 1, 0.04);
if (members[2].selected) {
FlxG.sound.music.volume = 0.5;
if (__lastBeat != Conductor.curBeat) {
FlxG.camera.zoom += 0.03;
__lastBeat = Conductor.curBeat;
}
if (__lastSongBeat != Math.floor(Conductor.getStepForTime(FlxG.sound.music.time / 2) / Conductor.stepsPerBeat)) {
__metronome.replay();
__lastSongBeat = Math.floor(Conductor.getStepForTime(FlxG.sound.music.time / 2) / Conductor.stepsPerBeat);
}
}
else FlxG.sound.music.volume = 1;
}
}