-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edbb0de
commit 0e89bba
Showing
5 changed files
with
75 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Utils | ||
{ | ||
public class NoteUtilsTest | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.UserInterface; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Rulesets.Karaoke.Edit.Blueprints.Notes.Components; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Rulesets.Karaoke.Objects.Drawables; | ||
using osu.Game.Rulesets.Karaoke.Utils; | ||
using osu.Game.Screens.Edit; | ||
using osuTK; | ||
|
||
|
@@ -32,10 +34,10 @@ public class NoteSelectionBlueprint : KaraokeSelectionBlueprint<Note> | |
private void splitNote() | ||
{ | ||
// TODO : percentage should be enter by dialog | ||
var splittedNote = HitObject.CopyByPercentage(0.5); | ||
EditorBeatmap?.Add(splittedNote); | ||
// Change object's duration | ||
HitObject.Duration = HitObject.Duration - splittedNote.Duration; | ||
var (firstNote, secondNote) = NoteUtils.SplitNote(HitObject, 0.5); | ||
EditorBeatmap?.Add(firstNote); | ||
EditorBeatmap?.Add(secondNote); | ||
EditorBeatmap?.Remove(HitObject); | ||
} | ||
|
||
public void ChangeDisplay(bool display) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using System; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Utils | ||
{ | ||
public static class NoteUtils | ||
{ | ||
public static Note SplitNote(Note note, double startPercentage, double durationPercentage) | ||
{ | ||
if (startPercentage < 0 || startPercentage + durationPercentage > 1) | ||
throw new ArgumentOutOfRangeException($"{nameof(Note)} cannot assign split range of start from {startPercentage} and duration {durationPercentage}"); | ||
|
||
var startTime = note.StartTime + note.Duration * startPercentage; | ||
var duration = note.Duration * durationPercentage; | ||
|
||
return copyByTime(note, startTime, duration); | ||
} | ||
public static Tuple<Note, Note> SplitNote(Note note, double percentage = 0.5) | ||
{ | ||
if (percentage <= 0 || percentage >= 1) | ||
throw new ArgumentOutOfRangeException(nameof(Note)); | ||
|
||
var firstNoteStartTime = note.StartTime; | ||
var firstNoteDuration = note.Duration * percentage; | ||
|
||
var secondNoteStartTime = firstNoteStartTime + firstNoteDuration; | ||
var secondNoteDuration = note.Duration * (1 - percentage); | ||
|
||
var firstNote = copyByTime(note, firstNoteStartTime, firstNoteDuration); | ||
var secondNote = copyByTime(note, secondNoteStartTime, secondNoteDuration); | ||
|
||
return new Tuple<Note, Note>(firstNote, secondNote); | ||
} | ||
|
||
private static Note copyByTime(Note oritinNote, double startTime, double duration) | ||
{ | ||
return new Note | ||
{ | ||
StartTime = startTime, | ||
Duration = duration, | ||
StartIndex = oritinNote.StartIndex, | ||
EndIndex = oritinNote.EndIndex, | ||
Text = oritinNote.Text, | ||
Singers = oritinNote.Singers, | ||
Display = oritinNote.Display, | ||
Tone = oritinNote.Tone, | ||
ParentLyric = oritinNote.ParentLyric | ||
}; | ||
} | ||
|
||
public static Note CombineNote(Note firstLyric, Note secondLyric) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |