Skip to content

Commit

Permalink
[director] Fixed separated slide creation
Browse files Browse the repository at this point in the history
  • Loading branch information
hozuki committed Mar 3, 2017
1 parent d70bf90 commit c39e409
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
20 changes: 20 additions & 0 deletions StarlightDirector/StarlightDirector.Entities/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ private static void OnTypeChanged(DependencyObject obj, DependencyPropertyChange
note.IsSlide = note.IsSlideInternal();
note.UpdateFlickTypeStep2();
note.DecideRenderingAsFlickOrSlide();

if (note.IsFlick) {
note.UpdateAsFlickNote();
} else if (note.IsSlide) {
note.UpdateAsSlideNote();
}
}

private static void OnFlickTypeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) {
Expand Down Expand Up @@ -536,6 +542,20 @@ private void SetNextSyncTargetInternal(Note next) {
IsSync = _prevSyncTarget != null || _nextSyncTarget != null;
}

private void UpdateAsSlideNote() {
if (HasPrevFlickOrSlide && PrevFlickOrSlideNote.IsSlide) {
PrevFlickOrSlideNote.FlickType = NoteFlickType.Tap;
}
}

private void UpdateAsFlickNote() {
if (HasPrevFlickOrSlide && PrevFlickOrSlideNote.IsSlide) {
var pos1 = (int)PrevFlickOrSlideNote.FinishPosition;
var pos2 = (int)FinishPosition;
PrevFlickOrSlideNote.FlickType = pos2 >= pos1 ? NoteFlickType.FlickRight : NoteFlickType.FlickLeft;
}
}

private Note _prevFlickOrSlideNote;
private Note _nextFlickOrSlideNote;
private Note _prevSyncTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<Grid.LayoutTransform>
<ScaleTransform ScaleY="-1" ScaleX="1" />
</Grid.LayoutTransform>
<Canvas Grid.Column="2" Name="SpecialNoteLayer" Background="Transparent"/>
<Grid Name="ContentsGrid" Grid.Column="1">
<Canvas Name="BarLayer" SizeChanged="BarLayer_OnSizeChanged"/>
<Canvas Name="EditingLineLayer">
Expand All @@ -29,6 +30,5 @@
<primitives:LineLayer x:Name="LineLayer"/>
<Canvas Name="NoteLayer" SizeChanged="NoteLayer_OnSizeChanged"/>
</Grid>
<Canvas Grid.Column="2" Name="SpecialNoteLayer" Background="Transparent"/>
</Grid>
</controls:ScoreViewerBase>
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,29 @@ private void CmdEditNoteSetSlideTypeToFlick_Executed(object sender, ExecutedRout
private void CmdEditNoteSetSlideTypeToSlide_CanExecute(object sender, CanExecuteRoutedEventArgs e) {
var notes = Editor.GetSelectedScoreNotes();
var scoreNotes = notes as List<ScoreNote> ?? notes.ToList();
if (scoreNotes.Count == 0) {
e.CanExecute = false;
return;
}
if (scoreNotes.Count == 1) {
var note = scoreNotes[0].Note;
if (note.HasPrevFlickOrSlide || note.HasNextFlickOrSlide) {
switch (scoreNotes.Count) {
case 0:
e.CanExecute = false;
return;
}
case 1:
var note = scoreNotes[0].Note;
if (note.HasPrevFlickOrSlide || note.HasNextFlickOrSlide) {
e.CanExecute = false;
return;
}
break;
}

Note groupPrevNote = null;
scoreNotes.Sort((c1, c2) => Note.TimingThenPositionComparison(c1.Note, c2.Note));
foreach (var scoreNote in scoreNotes) {
var note = scoreNote.Note;
if (!note.IsFlick && !note.IsSlide || note.IsHoldEnd) {
if ((!note.IsFlick && !note.IsSlide) || note.IsHoldEnd) {
e.CanExecute = false;
return;
}
var prevNote = note.PrevFlickOrSlideNote;
if (prevNote != null && prevNote != groupPrevNote) {
if (prevNote != null && prevNote != groupPrevNote && !prevNote.IsSlide) {
e.CanExecute = false;
return;
}
Expand Down

0 comments on commit c39e409

Please sign in to comment.