ok i think it works now

This commit is contained in:
lunarcleint
2023-07-26 21:34:09 -07:00
parent 56e9d2d37c
commit da38c1738a
4 changed files with 38 additions and 19 deletions
+30 -9
View File
@@ -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)
@@ -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() {
@@ -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));
}
}
}
@@ -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;