Skip to content

Commit

Permalink
Minor chart editor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowMario committed Sep 16, 2024
1 parent a6369c7 commit bcd13b5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
56 changes: 37 additions & 19 deletions source/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
var closeNotes:Array<MetaNote> = curRenderedNotes.members.filter(function(note:MetaNote)
{
var chartY:Float = FlxG.mouse.y - note.chartY;
return ((note.isEvent && noteData < 0) || note.songData[1] == noteData) && chartY >= 0 && chartY < GRID_SIZE;
return ((note.isEvent && noteData < 0) || (!note.isEvent && note.songData[1] == noteData)) && chartY >= 0 && chartY < GRID_SIZE;
});
closeNotes.sort(function(a:MetaNote, b:MetaNote) return Math.abs(a.strumTime - FlxG.mouse.y) < Math.abs(b.strumTime - FlxG.mouse.y) ? 1 : -1);

Expand Down Expand Up @@ -1532,11 +1532,19 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
var pushedEvents:Array<EventMetaNote> = [];
movingNotes.forEachAlive(function(note:MetaNote)
{
notes.push(note);
if(!note.isEvent) pushedNotes.push(note);
else pushedEvents.push(cast (note, EventMetaNote));
if(!note.isEvent)
{
notes.push(note);
pushedNotes.push(note);
}
else
{
events.push(cast (note, EventMetaNote));
pushedEvents.push(cast (note, EventMetaNote));
}
});
notes.sort(PlayState.sortByTime);
events.sort(PlayState.sortByTime);
movingNotes.clear();
isMovingNotes = false;
softReloadNotes();
Expand Down Expand Up @@ -2656,6 +2664,11 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU

note.setStrumTime(Math.max(-5000, strumTimeStepper.value + (note.strumTime - firstTime)));
positionNoteYOnTime(note, curSec);

if(note.isEvent)
{
cast (note, EventMetaNote).updateEventText();
}
}
softReloadNotes();
};
Expand Down Expand Up @@ -2841,25 +2854,21 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
});
var clearButton:PsychUIButton = new PsychUIButton(objX + 200, objY, 'Clear', function()
{
if(affectNotes.checked)
for (note in curRenderedNotes)
{
for (note in curRenderedNotes)
{
if(note == null || note.isEvent) continue;
if(note == null) continue;

selectedNotes.remove(note);
if(!note.isEvent && affectNotes.checked)
{
notes.remove(note);
trace('removed normal note');
}
}
if(affectEvents.checked)
{
for (event in curRenderedNotes)
if(note.isEvent && affectEvents.checked)
{
if(event == null || !event.isEvent) continue;

selectedNotes.remove(event);
events.remove(cast (event, EventMetaNote));
events.remove(cast (note, EventMetaNote));
trace('removed event note');
}
selectedNotes.remove(note);
}
softReloadNotes(true);
});
Expand Down Expand Up @@ -4782,6 +4791,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
case SELECT_NOTE:
resetSelectedNotes();
selectedNotes = action.data.old;
if(lockedEvents) selectedNotes = selectedNotes.filter((note:MetaNote) -> !note.isEvent);
onSelectNote();
}
showOutput('Undo #${currentUndo+1}: ${action.action}');
Expand Down Expand Up @@ -4813,6 +4823,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
case SELECT_NOTE:
resetSelectedNotes();
selectedNotes = action.data.current;
if(lockedEvents) selectedNotes = selectedNotes.filter((note:MetaNote) -> !note.isEvent);
onSelectNote();
}
showOutput('Redo #${currentUndo+1}: ${action.action}');
Expand Down Expand Up @@ -4852,21 +4863,28 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
function actionRemoveNotes(dataNotes:Array<MetaNote>, dataEvents:Array<EventMetaNote>)
{
if(dataNotes != null && dataNotes.length > 0)
{
for (note in dataNotes)
{
if(note != null)
{
notes.remove(note);
selectedNotes.remove(note);
}

}
}
if(dataEvents != null && dataEvents.length > 0)
{
for (event in dataEvents)
{
if(event != null)
{
events.remove(event);
trace(events.remove(event));
selectedNotes.remove(event);
}

}
}
softReloadNotes();
}

Expand Down
1 change: 1 addition & 0 deletions source/states/editors/content/MetaNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MetaNote extends Note
{
this.songData[1] = v;
this.noteData = v % ChartingState.GRID_COLUMNS_PER_PLAYER;
this.mustPress = (v < ChartingState.GRID_COLUMNS_PER_PLAYER);

if(!PlayState.isPixelStage)
loadNoteAnims();
Expand Down

0 comments on commit bcd13b5

Please sign in to comment.