Skip to content

Commit

Permalink
Merge pull request #121 from andy840119/slave/clean-up
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
andy840119 authored Jun 26, 2020
2 parents bac59e0 + f2357b2 commit 9c30aa0
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public TestSceneLyricLineLayout()
private LyricLine createDefaultLyricLine(string text, string[] ruby, string[] romaji, string translate)
{
var startTime = Time.Current;
var duration = 1000000;
const double duration = 1000000;

using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public TestSceneLyricLineStyle()
private LyricLine createDefaultLyricLine()
{
var startTime = Time.Current;
var duration = 1000000;
const double duration = 1000000;

return new LyricLine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public class TestSceneKaraokeModAutoplay : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModAutoplay()
{
}

// mod auto-play will cause crash
/*
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public class TestSceneKaraokeModAutoplayBySinger : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModAutoplayBySinger()
{
}

// mod auto-play will cause crash
/*
[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TestSceneKaraokeModDisableNote : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModDisableNote()
{
}

[Test]
public void TestCheckNoteExistInPlayfield() => CreateModTest(new ModTestData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TestSceneKaraokeModFlashlight : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModFlashlight()
{
}

[Test]
public void TestFlashlightExist() => CreateModTest(new ModTestData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public class TestSceneKaraokeModFun : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModFun()
{
}

[Test]
public void TestSnowMod() => CreateModTest(new ModTestData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TestSceneKaraokeModPractice : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokeModPractice()
{
}

[Test]
public void TestAllPanelExist() => CreateModTest(new ModTestData
{
Expand All @@ -30,10 +26,9 @@ public void TestAllPanelExist() => CreateModTest(new ModTestData
var overlays = Player.DrawableRuleset.Overlays;
var karaokeHudOverlay = overlays.OfType<KaraokeHUDOverlay>().FirstOrDefault();
var actionContainer = karaokeHudOverlay.OfType<KaraokeHUDOverlay.KaraokeActionContainer>().FirstOrDefault();
var controlLayer = actionContainer?.Child as ControlLayer;

// todo : test overlays is exist.
return controlLayer != null;
return actionContainer?.Child is ControlLayer;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
Expand All @@ -26,7 +25,7 @@ public TestSceneLyricLine()
private Drawable testSingle(bool auto = false, double timeOffset = 0)
{
var startTime = Time.Current + 1000 + timeOffset;
var duration = 2500;
const double duration = 2500;

var lyric = new LyricLine
{
Expand Down
4 changes: 0 additions & 4 deletions osu.Game.Rulesets.Karaoke.Tests/UI/TestSceneKaraokePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ public class TestSceneKaraokePlayer : PlayerTestScene
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestKaraokeBeatmap(ruleset);

protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public TestSceneKaraokePlayer()
{
}
}
}
5 changes: 3 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/KaraokeHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpaceP
// Only note and lyric playfield can interact with mouse input.
if (Playfield.NotePlayfield.ReceivePositionalInputAt(screenSpacePosition))
return Playfield.NotePlayfield;
else if(Playfield.LyricPlayfield.ReceivePositionalInputAt(screenSpacePosition))
if (Playfield.LyricPlayfield.ReceivePositionalInputAt(screenSpacePosition))
return Playfield.LyricPlayfield;

return null;
Expand All @@ -51,14 +51,15 @@ protected override Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpaceP
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
{
var result = base.SnapScreenSpacePositionToValidTime(screenSpacePosition);

if (result.Playfield is NotePlayfield)
{
// Apply Y value because it's disappeared.
result.ScreenSpacePosition.Y = screenSpacePosition.Y;
// then disable time change by moving x
result.Time = null;
}

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Edit/KaraokeSelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public override bool HandleMovement(MoveSelectionEvent moveEvent)

private void performColumnMovement(Tone lastTone, MoveSelectionEvent moveEvent)
{
if (!(moveEvent.Blueprint is NoteSelectionBlueprint noteBlueprint))
if (!(moveEvent.Blueprint is NoteSelectionBlueprint))
return;

var karaokePlayfield = ((KaraokeHitObjectComposer)composer).Playfield;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public KaraokeChangelogBuild(string organization, string project, string branch
}

/// <summary>
/// Orgination name
/// Organization name
/// </summary>
public string OrganizationName { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ private void computeImageSize()
}

protected override MarkdownPipeline CreateBuilder()
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
.UseYamlFrontMatter()
.UseEmojiAndSmiley()
.UseAdvancedExtensions().Build();
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
.UseYamlFrontMatter()
.UseEmojiAndSmiley()
.UseAdvancedExtensions().Build();
}

protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private Task fetchListing()

if (reposAscending.Any())
{
builds = reposAscending.Reverse().Where(x=>x.Type == ContentType.Dir).Select(x => new KaraokeChangelogBuild(organizationName, projectName)
builds = reposAscending.Reverse().Where(x => x.Type == ContentType.Dir).Select(x => new KaraokeChangelogBuild(organizationName, projectName)
{
RootUrl = x.HtmlUrl,
Path = x.Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Karaoke.Replays
public class KaraokeAutoGeneratorBySinger : AutoGenerator
{
private readonly CancellationTokenSource cancelSource = new CancellationTokenSource();
private readonly Task<Dictionary<double,float?>> readTask;
private readonly Task<Dictionary<double, float?>> readTask;

/// <summary>
/// Using audio's vioce to generate replay frames
Expand All @@ -28,14 +28,15 @@ public class KaraokeAutoGeneratorBySinger : AutoGenerator
/// <param name="beatmap"></param>
/// <param name="data"></param>
public KaraokeAutoGeneratorBySinger(KaraokeBeatmap beatmap, Stream data)
: base(beatmap)
: base(beatmap)
{
if (data == null)
return;

readTask = Task.Run(() =>
{
int decodeStream = 0;

using (var fileCallbacks = new FileCallbacks(new DataStreamFileProcedures(data)))
{
decodeStream = Bass.CreateStream(StreamSystem.NoBuffer, BassFlags.Decode | BassFlags.Float, fileCallbacks.Callbacks, fileCallbacks.Handle);
Expand Down Expand Up @@ -86,14 +87,15 @@ public override Replay Generate()
private IEnumerable<ReplayFrame> getReplayFrames(IDictionary<double, float?> pitches)
{
var lastPitch = pitches.FirstOrDefault();

foreach (var pitch in pitches)
{
if (pitch.Value != null)
{
var scale = Beatmap.PitchToScale(pitch.Value ?? 0);
yield return new KaraokeReplayFrame(pitch.Key, scale);
}
else if(lastPitch.Value != null)
else if (lastPitch.Value != null)
yield return new KaraokeReplayFrame(pitch.Key);

lastPitch = pitch;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Replays/KaraokeReplayFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public KaraokeReplayFrame()
}

public KaraokeReplayFrame(double time)
: base(time)
: base(time)
{
}

Expand Down
9 changes: 1 addition & 8 deletions osu.Game.Rulesets.Karaoke/Skinning/LegacyJudgementLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ private void load(ISkinSource skin, IScrollingInfo scrollingInfo)

protected virtual void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
if (direction.NewValue == ScrollingDirection.Left)
{
Scale = Vector2.One;
}
else
{
Scale = new Vector2(-1, 1);
}
Scale = direction.NewValue == ScrollingDirection.Left ? Vector2.One : new Vector2(-1, 1);
}

protected override void Update()
Expand Down
14 changes: 9 additions & 5 deletions osu.Game.Rulesets.Karaoke/Skinning/LegacyNotePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,17 @@ protected Sprite GetSpriteFromLookup(ISkin skin, LegacyKaraokeSkinConfigurationL
return null;
}

Sprite getSpriteByName(string name) => (Sprite)skin.GetAnimation(name, true, true).With(d =>
Sprite getSpriteByName(string spriteName) => (Sprite)skin.GetAnimation(spriteName, true, true).With(d =>
{
if (d == null)
return;
switch (d)
{
case null:
return;

if (d is TextureAnimation animation)
animation.IsPlaying = false;
case TextureAnimation animation:
animation.IsPlaying = false;
break;
}
});
}

Expand Down
9 changes: 1 addition & 8 deletions osu.Game.Rulesets.Karaoke/Skinning/LegacyStageBackground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ private void load(ISkinSource skin, IScrollingInfo scrollingInfo)

protected virtual void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
if (direction.NewValue == ScrollingDirection.Left)
{
Scale = Vector2.One;
}
else
{
Scale = new Vector2(-1, 1);
}
Scale = direction.NewValue == ScrollingDirection.Left ? Vector2.One : new Vector2(-1, 1);
}

private Texture getTexture(ISkinSource skin) => skin.GetTexture(GetTextureName());
Expand Down
9 changes: 1 addition & 8 deletions osu.Game.Rulesets.Karaoke/UI/DefaultHitExplosion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,7 @@ protected override void LoadComplete()

private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
if (direction.NewValue == ScrollingDirection.Left)
{
Anchor = Anchor.CentreLeft;
}
else
{
Anchor = Anchor.CentreRight;
}
Anchor = direction.NewValue == ScrollingDirection.Left ? Anchor.CentreLeft : Anchor.CentreRight;
}
}
}
10 changes: 7 additions & 3 deletions osu.Game.Rulesets.Karaoke/UI/KaraokeSettingsSubsection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ private void load(OsuGame game)
{
Text = "Change log",
TooltipText = "Let's see what karaoke! changed.",
Action = ()=>
Action = () =>
{
var overlayContent = game.Children[3] as Container;
if(changelogOverlay == null && !overlayContent.Children.OfType<KaraokeChangelogOverlay>().Any())

if (overlayContent == null)
return;

if (changelogOverlay == null && !overlayContent.Children.OfType<KaraokeChangelogOverlay>().Any())
overlayContent.Add(changelogOverlay = new KaraokeChangelogOverlay("karaoke-dev"));

changelogOverlay.Show();
changelogOverlay?.Show();
}
}
};
Expand Down

0 comments on commit 9c30aa0

Please sign in to comment.