Skip to content

Commit

Permalink
Clean-up code by rider <3
Browse files Browse the repository at this point in the history
Also update nuget package.
  • Loading branch information
andy840119 committed Aug 2, 2020
1 parent 80ca68d commit 577ce61
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Game.Rulesets.Karaoke.Configuration;
using osu.Game.Rulesets.Karaoke.UI;

namespace osu.Game.Rulesets.Karaoke.Tests.Skinning
Expand Down
7 changes: 4 additions & 3 deletions osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ private void load(KaraokeRulesetConfigManager config, IBindable<IReadOnlyList<Mo
{
session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Edit);
return;
}
}

this.beatmap = beatmap.Value.Beatmap;

var disableMicrophoneDeviceByMod = mods.Value.OfType<IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled);

if (disableMicrophoneDeviceByMod)
{
session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay);
return;
}


var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable();

if (!beatmapSaitenable)
{
session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening);
Expand All @@ -72,7 +73,7 @@ private void load(KaraokeRulesetConfigManager config, IBindable<IReadOnlyList<Mo

session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Saitening);
}
catch(Exception ex)
catch (Exception ex)
{
Logger.Error(ex, "Microphone initialize error.");
// todo : set real error by exception
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
using osu.Game.Rulesets.Karaoke.Mods;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Replays;
using osu.Game.Rulesets.Karaoke.Resources.Fonts;
using osu.Game.Rulesets.Karaoke.Scoring;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.UI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void computeImageSize()
}
}

private IDictionary<string, string> githubUrls = new Dictionary<string, string>
private readonly IDictionary<string, string> githubUrls = new Dictionary<string, string>
{
{ "karaoke", "https://github.com/karaoke-dev/karaoke/" },
{ "edge", "https://github.com/karaoke-dev/karaoke" },
Expand All @@ -193,13 +193,14 @@ protected override void AddLinkText(string text, LinkInline linkInline)
var baseUri = new Uri(githubUrls[text]);

// Get hash tag with number
var pattern = @"(\#[0-9]+\b)(?!;)";
const string pattern = @"(\#[0-9]+\b)(?!;)";
var issueOrRequests = Regex.Matches(linkInline.Url, pattern, RegexOptions.IgnoreCase);

if (!issueOrRequests.Any())
return;

AddText("(");

foreach (var issue in issueOrRequests.Select(x=>x.Value))
{
AddDrawable(new MarkdownLinkText($"{text}{issue}", new LinkInline
Expand All @@ -210,10 +211,12 @@ protected override void AddLinkText(string text, LinkInline linkInline)
if(issue != issueOrRequests.LastOrDefault()?.Value)
AddText(", ");
}

AddText(")");

// add use name if has user
var user = linkInline.Url.Split('@').LastOrDefault();

if (!string.IsNullOrEmpty(user))
{
var textScale = new Vector2(0.7f);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class KaraokeInternalSkin : ISkin

protected abstract string ResourceName { get; }

public KaraokeInternalSkin()
protected KaraokeInternalSkin()
{
// TODO : need a better way to load resource
var assembly = Assembly.GetExecutingAssembly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.IO;
using osu.Game.Rulesets.Karaoke.Beatmaps.Formats;
using osu.Game.Rulesets.Karaoke.Skinning.Components;
Expand Down
14 changes: 13 additions & 1 deletion osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public SaitenStatusMode SaitenStatusMode
set
{
statusMode = value;
Children = new Drawable[]
Children = new[]
{
CreateIcon(statusMode == SaitenStatusMode.Saitening),
CreateStatusSpriteText(GetSaitenStatusText(statusMode))
Expand All @@ -64,28 +64,40 @@ protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode)
{
case SaitenStatusMode.AndroidMicrophonePermissionDeclined:
return "Go to setting to open permission for lazer.";

case SaitenStatusMode.AndroidDoesNotSupported:
return "Android device haven't support saiten system yet :(";

case SaitenStatusMode.IOSMicrophonePermissionDeclined:
return "Go to setting to open permission for lazer.";

case SaitenStatusMode.IOSDoesNotSupported:
return "iOS device haven't support saiten system yet :(";

case SaitenStatusMode.OSXMicrophonePermissionDeclined:
return "Go to setting to open permission for lazer.";

case SaitenStatusMode.OSXDoesNotSupported:
return "Osx device haven't support saiten system yet :(";

case SaitenStatusMode.WindowsMicrophonePermissionDeclined:
return "Open lazer with admin permission to enable saiten system.";

case SaitenStatusMode.NotSaitening:
return "This beatmap is not saitenable.";

case SaitenStatusMode.AutoPlay:
return "Auto play mode.";

case SaitenStatusMode.Edit:
return "Edit mode.";

case SaitenStatusMode.Saitening:
return "Saiteining...";

case SaitenStatusMode.NotInitialized:
return "Seems microphone device is not ready.";

default:
return "Weird... Should not goes to here either :oops:";
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
<PackageReference Include="Octokit" Version="0.48.0" />
<PackageReference Include="osu.Framework.Microphone" Version="1.0.10" />
<PackageReference Include="ppy.osu.Game" Version="2020.725.0" />
<PackageReference Include="ppy.osu.Game" Version="2020.801.0" />
<PackageReference Include="LyricMaker" Version="1.1.1" />
<PackageReference Include="NicoKaraParser" Version="1.1.0" />
<PackageReference Include="osu.KaraokeFramework" Version="1.2.1" />
Expand Down

0 comments on commit 577ce61

Please sign in to comment.