Skip to content

Commit

Permalink
Merge pull request #227 from andy840119/typo/lyric-line-to-lyric
Browse files Browse the repository at this point in the history
Rename from LyricLine to lyric
  • Loading branch information
andy840119 authored Oct 25, 2020
2 parents ed031d8 + cd6ad71 commit 266fcff
Show file tree
Hide file tree
Showing 48 changed files with 170 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void TestDecodeBeatmapLyric()
Assert.AreEqual(1, working.GetPlayableBeatmap(new KaraokeRuleset().RulesetInfo, Array.Empty<Mod>()).BeatmapInfo.BeatmapVersion);

// Test lyric part decode result
var lyrics = working.Beatmap.HitObjects.OfType<LyricLine>();
var lyrics = working.Beatmap.HitObjects.OfType<Lyric>();
Assert.AreEqual(54, lyrics.Count());

// Test note decode part
Expand Down Expand Up @@ -83,7 +83,7 @@ public void TestDecodeStyle()
var beatmap = decodeBeatmap("karaoke-style-samples");

// Get lyric
var lyric = beatmap.HitObjects.OfType<LyricLine>().FirstOrDefault();
var lyric = beatmap.HitObjects.OfType<Lyric>().FirstOrDefault();

// Check is not null
Assert.IsTrue(lyric != null);
Expand All @@ -101,7 +101,7 @@ public void TestDecodeTranslate()

// Get translate
var translates = beatmap.AvailableTranslates();
var lyrics = beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();

// Check is not null
Assert.IsTrue(translates != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void TestEncodeBeatmapLyric()
{
HitObjects = new List<HitObject>
{
new LyricLine
new Lyric
{
StartTime = start_time,
Duration = duration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestDecodeLyric()
var beatmap = decodeLrcLine(lyric_text);

// Get first beatmap
var lyric = beatmap.HitObjects.OfType<LyricLine>().FirstOrDefault();
var lyric = beatmap.HitObjects.OfType<Lyric>().FirstOrDefault();

// Check lyric
Assert.AreEqual(lyric?.Text, "からおけ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObj
{
switch (hitObject)
{
case LyricLine line:
case Lyric line:
yield return createConvertValue(line);

break;
}

static ConvertValue createConvertValue(LyricLine obj) => new ConvertValue
static ConvertValue createConvertValue(Lyric obj) => new ConvertValue
{
StartTime = obj.StartTime,
EndTime = obj.EndTime,
Expand Down
10 changes: 5 additions & 5 deletions osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneLyricLineStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ public TestSceneLyricLineStyle()
AddStep("Test", () => initialLyricLine(createDefaultLyricLine()));
}

private void initialLyricLine(LyricLine lyricLine) => layoutArea.Child = drawableLyricLine = new TestDrawableLyricLine(this, lyricLine);
private void initialLyricLine(Lyric lyricLine) => layoutArea.Child = drawableLyricLine = new TestDrawableLyricLine(this, lyricLine);

private LyricLine createDefaultLyricLine()
private Lyric createDefaultLyricLine()
{
var startTime = Time.Current;
const double duration = 1000000;

return new LyricLine
return new Lyric
{
StartTime = startTime,
Duration = duration,
Expand Down Expand Up @@ -376,14 +376,14 @@ private LyricLine createDefaultLyricLine()
};
}

public class TestDrawableLyricLine : DrawableLyricLine
public class TestDrawableLyricLine : DrawableLyric
{
private readonly TestSceneLyricLineStyle testScene;

public KaraokeFont Font { get; private set; }
private bool defaultValueAssigned;

public TestDrawableLyricLine(TestSceneLyricLineStyle testCase, LyricLine hitObject)
public TestDrawableLyricLine(TestSceneLyricLineStyle testCase, Lyric hitObject)
: base(hitObject)
{
testScene = testCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public void TestDisplayToolTip()
}
}

private void setTooltip(string testName, Action<LyricLine> callBack)
private void setTooltip(string testName, Action<Lyric> callBack)
{
AddStep(testName, () =>
{
var singer = new LyricLine
var singer = new Lyric
{
Text = "karaoke!"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SetUp() => Schedule(() =>
public void TestDisplayToolTip()
{
var beatmap = new TestKaraokeBeatmap(null);
var lyrics = beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();

foreach (var lyric in lyrics)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TestSceneKaraokeModPerfect()

// TODO : test case = false will be added after saiten system is implemented.
[Ignore("Saiten should judgement by note, not lyric.")]
public void TestLyric(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new LyricLine
public void TestLyric(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Lyric
{
StartTime = 1000,
Duration = 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
namespace osu.Game.Rulesets.Karaoke.Tests.Skinning
{
[TestFixture]
public class TestSceneLyricLine : KaraokeSkinnableTestScene
public class TestSceneLyric : KaraokeSkinnableTestScene
{
public TestSceneLyricLine()
public TestSceneLyric()
{
AddStep("Default Lyric", () => SetContents(() => testSingle()));
}
Expand All @@ -27,7 +27,7 @@ private Drawable testSingle(bool auto = false, double timeOffset = 0)
var startTime = Time.Current + 1000 + timeOffset;
const double duration = 2500;

var lyric = new LyricLine
var lyric = new Lyric
{
StartTime = startTime,
Duration = duration,
Expand Down Expand Up @@ -77,7 +77,7 @@ private Drawable testSingle(bool auto = false, double timeOffset = 0)

lyric.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

var drawable = CreateDrawableLyricLine(lyric, auto);
var drawable = CreateDrawableLyric(lyric, auto);

foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(new[] { drawable });
Expand All @@ -87,17 +87,17 @@ private Drawable testSingle(bool auto = false, double timeOffset = 0)

private int depthIndex;

protected virtual TestDrawableLyricLine CreateDrawableLyricLine(LyricLine lyric, bool auto)
=> new TestDrawableLyricLine(lyric, auto)
protected virtual TestDrawableLyric CreateDrawableLyric(Lyric lyric, bool auto)
=> new TestDrawableLyric(lyric, auto)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = depthIndex++
};

protected class TestDrawableLyricLine : DrawableLyricLine
protected class TestDrawableLyric : DrawableLyric
{
public TestDrawableLyricLine(LyricLine h, bool auto)
public TestDrawableLyric(Lyric h, bool auto)
: base(h)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,22 @@ private void processNotes(Beatmap beatmap, IList<string> lines)
// Remove all karaoke note
beatmap.HitObjects.RemoveAll(x => x is Note);

var lyricLines = beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();

for (int l = 0; l < lyricLines.Count; l++)
for (int l = 0; l < lyrics.Count; l++)
{
var lyricLine = lyricLines[l];
var lyric = lyrics[l];
var line = lines.ElementAtOrDefault(l)?.Split('=').Last();

// Create default note if not exist
if (string.IsNullOrEmpty(line))
{
beatmap.HitObjects.AddRange(lyricLine.CreateDefaultNotes());
beatmap.HitObjects.AddRange(lyric.CreateDefaultNotes());
continue;
}

var notes = line.Split(',');
var defaultNotes = lyricLine.CreateDefaultNotes().ToList();
var defaultNotes = lyric.CreateDefaultNotes().ToList();
var minNoteNumber = Math.Min(notes.Length, defaultNotes.Count);

// Process each note
Expand Down Expand Up @@ -222,11 +222,11 @@ Tone convertTone(string tone)

private void processStyle(Beatmap beatmap, IList<string> styleLines)
{
var lyricLines = beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();

for (int l = 0; l < lyricLines.Count; l++)
for (int l = 0; l < lyrics.Count; l++)
{
var lyricLine = lyricLines[l];
var lyric = lyrics[l];
var line = styleLines.ElementAtOrDefault(l)?.Split('=').Last();

// TODO : maybe create default layer and style index here?
Expand All @@ -237,18 +237,18 @@ private void processStyle(Beatmap beatmap, IList<string> styleLines)
var fontIndexStr = line.Split(',').ElementAtOrDefault(1);

if (int.TryParse(layoutIndexStr, out int layoutIndex))
lyricLine.LayoutIndex = layoutIndex;
lyric.LayoutIndex = layoutIndex;

if (int.TryParse(fontIndexStr, out int fontIndex))
lyricLine.FontIndex = fontIndex;
lyric.FontIndex = fontIndex;
}
}

private void processTranslate(Beatmap beatmap, IEnumerable<string> translateLines)
{
var availableTranslates = new List<BeatmapSetOnlineLanguage>();

var lyrics = beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = beatmap.HitObjects.OfType<Lyric>().ToList();
var translates = translateLines.Select(translate => new
{
key = translate.Split('=').FirstOrDefault()?.Split('[').LastOrDefault()?.Split(']').FirstOrDefault(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public string Encode(Beatmap output)
private IEnumerable<string> encodeNote(Beatmap output)
{
var notes = output.HitObjects.OfType<Note>().ToList();
var lyrics = output.HitObjects.OfType<LyricLine>().ToList();
var lyrics = output.HitObjects.OfType<Lyric>().ToList();
return notes.GroupBy(x => x.ParentLyric).Select(g =>
{
// Get note group
Expand Down Expand Up @@ -61,12 +61,12 @@ static string convertNote(Note note)

private IEnumerable<string> encodeStyle(Beatmap output)
{
var lyricLines = output.HitObjects.OfType<LyricLine>().ToList();
var lyrics = output.HitObjects.OfType<Lyric>().ToList();

for (var i = 0; i < lyricLines.Count; i++)
for (var i = 0; i < lyrics.Count; i++)
{
var lyricLine = lyricLines[i];
yield return $"@style{i}={lyricLine.LayoutIndex},{lyricLine.FontIndex}";
var lyric = lyrics[i];
yield return $"@style{i}={lyric.LayoutIndex},{lyric.FontIndex}";
}
}

Expand All @@ -75,7 +75,7 @@ private IEnumerable<string> encodeTranslate(Beatmap output)
if (!output.AnyTranslate())
yield break;

var lyrics = output.HitObjects.OfType<LyricLine>().ToList();
var lyrics = output.HitObjects.OfType<Lyric>().ToList();
var availableTranslates = output.AvailableTranslates();

foreach (var translate in availableTranslates)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void ParseStreamInto(LineBufferedReader stream, Beatmap outpu
var startTime = timeTags.FirstOrDefault(x => x.Time > 0).Time;
var duration = timeTags.LastOrDefault(x => x.Time > 0).Time - startTime;

var lyric = new LyricLine
var lyric = new Lyric
{
Text = line.Text,
// Start time and end time should be re-assigned
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public string Encode(Beatmap output)
{
var lyric = new Lyric
{
Lines = output.HitObjects.OfType<Objects.LyricLine>().Select(encodeLyric).ToArray(),
Lines = output.HitObjects.OfType<Objects.Lyric>().Select(encodeLyric).ToArray(),
};
var encodeResult = new LrcParser().Encode(lyric);
return encodeResult;
}

private LyricLine encodeLyric(Objects.LyricLine lyric) =>
private LyricLine encodeLyric(Objects.Lyric lyric) =>
new LyricLine
{
Text = lyric.Text,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class KaraokeBeatmap : Beatmap<KaraokeHitObject>
public override IEnumerable<BeatmapStatistic> GetStatistics()
{
int singers = SingerMetadata.Singers.Count;
int lyrics = HitObjects.Count(s => s is LyricLine);
int lyrics = HitObjects.Count(s => s is Lyric);

var defaultStatistic = new List<BeatmapStatistic>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override void PostProcess()
{
base.PostProcess();

var lyrics = Beatmap.HitObjects.OfType<LyricLine>().ToList();
var lyrics = Beatmap.HitObjects.OfType<Lyric>().ToList();

if (!lyrics.Any())
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace osu.Game.Rulesets.Karaoke.Beatmaps.Patterns
{
public class LegacyKaraokeLayoutGenerator : IPatternGenerator<LyricLine>
public class LegacyKaraokeLayoutGenerator : IPatternGenerator<Lyric>
{
private const int number_of_line = 2;

public void Generate(IEnumerable<LyricLine> hitObjects)
public void Generate(IEnumerable<Lyric> hitObjects)
{
var lyrics = hitObjects.ToList();

Expand Down Expand Up @@ -47,7 +47,7 @@ public void Generate(IEnumerable<LyricLine> hitObjects)
/// ****** (right) 13
/// </example>
/// <param name="lyrics">Lyrics</param>
private void assignLayoutArrangement(IList<LyricLine> lyrics)
private void assignLayoutArrangement(IList<Lyric> lyrics)
{
// Force change to new line if lyric has long time
const int new_lyric_line_time = 15000;
Expand All @@ -71,26 +71,26 @@ private void assignLayoutArrangement(IList<LyricLine> lyrics)
}
}

private void assignLyricTime(IList<LyricLine> lyrics)
private void assignLyricTime(IList<Lyric> lyrics)
{
// Reset working time
lyrics.ForEach(h => h.InitialWorkingTime());

// Apply start time
for (int i = 0; i < lyrics.Count; i++)
{
var lastLyricLine = i >= number_of_line ? lyrics[i - number_of_line] : null;
var lyricLine = lyrics[i];
var lastLyric = i >= number_of_line ? lyrics[i - number_of_line] : null;
var lyric = lyrics[i];

if (lastLyricLine == null)
if (lastLyric == null)
continue;

// Adjust start time and end time
var lyricEndTime = lyricLine.EndTime;
lyricLine.StartTime = lastLyricLine.EndTime + 1000;
var lyricEndTime = lyric.EndTime;
lyric.StartTime = lastLyric.EndTime + 1000;

// Should re-assign duration here
lyricLine.Duration = lyricEndTime - lyricLine.StartTime;
lyric.Duration = lyricEndTime - lyric.StartTime;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public KaraokeSessionStatics(KaraokeRulesetConfigManager config, IBeatmap beatma
Set(KaraokeRulesetSession.PlaybackSpeed, overridePlaybackSpeed ? playbackSpeedValue : 0, -10, 10);

// Practice
Set<LyricLine>(KaraokeRulesetSession.NowLyric, null);
Set<Lyric>(KaraokeRulesetSession.NowLyric, null);

// Saiten stsus
Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotInitialized);
Expand Down
Loading

0 comments on commit 266fcff

Please sign in to comment.