1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 22:02:56 +08:00

Reduce error count.

This commit is contained in:
Dean Herbert 2017-03-09 14:24:16 +09:00
parent 149bf7b5fc
commit da751804b6
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
30 changed files with 54 additions and 75 deletions

View File

@ -5,7 +5,7 @@ using Newtonsoft.Json;
namespace osu.Desktop.Deploy
{
internal class GitHubObject
public class GitHubObject
{
[JsonProperty(@"id")]
public int Id;

View File

@ -5,7 +5,7 @@ using Newtonsoft.Json;
namespace osu.Desktop.Deploy
{
internal class GitHubRelease
public class GitHubRelease
{
[JsonProperty(@"id")]
public int Id;

View File

@ -76,10 +76,7 @@ namespace osu.Desktop
if (isFile)
{
var paths = ((object[])e.Data.GetData(DataFormats.FileDrop)).Select(f => f.ToString()).ToArray();
if (allowed_extensions.Any(ext => paths.All(p => p.EndsWith(ext))))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
e.Effect = allowed_extensions.Any(ext => paths.All(p => p.EndsWith(ext))) ? DragDropEffects.Copy : DragDropEffects.None;
}
}
}

View File

@ -31,7 +31,7 @@ namespace osu.Game.Modes.Mania.UI
PopOutCount.Anchor = Anchor.BottomCentre;
PopOutCount.Origin = Anchor.Centre;
PopOutCount.FadeColour(PopOutColor, 0);
PopOutCount.FadeColour(PopOutColor);
OriginalColour = DisplayedCountSpriteText.Colour;
}

View File

@ -79,12 +79,9 @@ namespace osu.Game.Modes.Osu.Objects
// We select the amount of points for the approximation by requiring the discrete curvature
// to be smaller than the provided tolerance. The exact angle required to meet the tolerance
// is: 2 * Math.Acos(1 - TOLERANCE / r)
if (2 * r <= tolerance)
// This special case is required for extremely short sliders where the radius is smaller than
// the tolerance. This is a pathological rather than a realistic case.
amountPoints = 2;
else
amountPoints = Math.Max(2, (int)Math.Ceiling(thetaRange / (2 * Math.Acos(1 - tolerance / r))));
// The special case is required for extremely short sliders where the radius is smaller than
// the tolerance. This is a pathological rather than a realistic case.
amountPoints = 2 * r <= tolerance ? 2 : Math.Max(2, (int)Math.Ceiling(thetaRange / (2 * Math.Acos(1 - tolerance / r))));
List<Vector2> output = new List<Vector2>(amountPoints);

View File

@ -1,12 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Game.Modes.Osu.Objects.Drawables.Connections;
using System;
using System.Collections.Generic;
using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables
namespace osu.Game.Modes.Osu.Objects.Drawables.Connections
{
public class FollowPointRenderer : ConnectionRenderer<OsuHitObject>
{

View File

@ -34,11 +34,11 @@ namespace osu.Game.Modes.Osu.Objects
List<Vector2> points = new List<Vector2> { new Vector2(int.Parse(split[0]), int.Parse(split[1])) };
string[] pointsplit = split[5].Split('|');
for (int i = 0; i < pointsplit.Length; i++)
foreach (string t in pointsplit)
{
if (pointsplit[i].Length == 1)
if (t.Length == 1)
{
switch (pointsplit[i])
switch (t)
{
case @"C":
curveType = CurveTypes.Catmull;
@ -56,7 +56,7 @@ namespace osu.Game.Modes.Osu.Objects
continue;
}
string[] temp = pointsplit[i].Split(':');
string[] temp = t.Split(':');
Vector2 v = new Vector2(
(int)Convert.ToDouble(temp[0], CultureInfo.InvariantCulture),
(int)Convert.ToDouble(temp[1], CultureInfo.InvariantCulture)

View File

@ -173,9 +173,11 @@ namespace osu.Game.IO.Legacy
private static void initialize()
{
versionBinder = new VersionConfigToNamespaceAssemblyObjectBinder();
formatter = new BinaryFormatter();
formatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
formatter.Binder = versionBinder;
formatter = new BinaryFormatter
{
AssemblyFormat = FormatterAssemblyStyle.Simple,
Binder = versionBinder
};
}
public static object Deserialize(Stream stream)

View File

@ -73,13 +73,16 @@ namespace osu.Game.IO.Legacy
}
}
/// <summary> Writes a DateTime to the buffer. <summary>
/// <summary>
/// Writes DateTime to the buffer.
/// </summary>
/// <param name="dt"></param>
public void Write(DateTime dt)
{
Write(dt.ToUniversalTime().Ticks);
}
/// <summary> Writes a generic ICollection (such as an IList<T>) to the buffer. </summary>
/// <summary> Writes a generic ICollection (such as an IList(T)) to the buffer.</summary>
public void Write<T>(List<T> c) where T : ILegacySerializable
{
if (c == null)
@ -212,9 +215,11 @@ namespace osu.Game.IO.Legacy
default:
Write((byte)ObjType.otherType);
BinaryFormatter b = new BinaryFormatter();
b.AssemblyFormat = FormatterAssemblyStyle.Simple;
b.TypeFormat = FormatterTypeStyle.TypesWhenNeeded;
BinaryFormatter b = new BinaryFormatter
{
AssemblyFormat = FormatterAssemblyStyle.Simple,
TypeFormat = FormatterTypeStyle.TypesWhenNeeded
};
b.Serialize(BaseStream, obj);
break;
} // switch

View File

@ -16,7 +16,7 @@ namespace osu.Game.IPC
: base(host)
{
this.beatmaps = beatmaps;
MessageReceived += (msg) =>
MessageReceived += msg =>
{
Debug.Assert(beatmaps != null);
ImportAsync(msg.Path);

View File

@ -16,10 +16,13 @@ namespace osu.Game.IPC
: base(host)
{
this.scores = scores;
MessageReceived += (msg) =>
MessageReceived += msg =>
{
Debug.Assert(scores != null);
ImportAsync(msg.Path);
ImportAsync(msg.Path).ContinueWith(t =>
{
if (t.Exception != null) throw t.Exception;
}, TaskContinuationOptions.OnlyOnFaulted);
};
}

View File

@ -253,7 +253,7 @@ namespace osu.Game.Modes
public void ReadFromStream(SerializationReader sr)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}
public void WriteToStream(SerializationWriter sw)

View File

@ -134,19 +134,11 @@ namespace osu.Game.Modes.UI
updateCount(Count);
}
/// <summary>
/// Animates roll-back to 0.
/// </summary>
public void Roll()
{
Roll(0);
}
/// <summary>
/// Animates roll-up/roll-back to an specific value.
/// </summary>
/// <param name="newValue">Target value.</param>
public virtual void Roll(ulong newValue)
public virtual void Roll(ulong newValue = 0)
{
updateCount(newValue, true);
}

View File

@ -89,5 +89,5 @@ namespace osu.Game.Online.API
public delegate void APIFailureHandler(Exception e);
public delegate void APISuccessHandler();
public delegate void APISuccessHandler<T>(T content);
public delegate void APISuccessHandler<in T>(T content);
}

View File

@ -167,7 +167,7 @@ namespace osu.Game.Overlays.Mods
// 1.05x
// 1.20x
multiplierLabel.Text = string.Format("{0:N2}x", multiplier);
multiplierLabel.Text = $"{multiplier:N2}x";
string rankedString = ranked ? "Ranked" : "Unranked";
rankedLabel.Text = $@"{rankedString}, Score Multiplier: ";

View File

@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Options
bindable.ValueChanged += bindable_ValueChanged;
bindable_ValueChanged(null, null);
if (bindable?.Disabled ?? true)
if ((bool)bindable?.Disabled)
Alpha = 0.3f;
}
}

View File

@ -64,11 +64,8 @@ namespace osu.Game.Overlays.Toolbar
}
};
int amountButtons = 0;
foreach (PlayMode m in Enum.GetValues(typeof(PlayMode)))
{
++amountButtons;
var localMode = m;
modeButtons.Add(new ToolbarModeButton
{

View File

@ -94,11 +94,7 @@ namespace osu.Game.Overlays.Toolbar
userId = value;
Sprite newSprite;
if (userId > 1)
newSprite = new OnlineSprite($@"https://a.ppy.sh/{userId}");
else
newSprite = new Sprite { Texture = guestTexture };
var newSprite = userId > 1 ? new OnlineSprite($@"https://a.ppy.sh/{userId}") : new Sprite { Texture = guestTexture };
newSprite.FillMode = FillMode.Fit;

View File

@ -30,11 +30,7 @@ namespace osu.Game.Screens.Backgrounds
Schedule(() =>
{
Background newBackground;
if (beatmap == null)
newBackground = new Background(@"Backgrounds/bg1");
else
newBackground = new BeatmapBackground(beatmap);
var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap);
newBackground.LoadAsync(Game, delegate
{

View File

@ -25,7 +25,6 @@ namespace osu.Game.Screens
protected virtual IEnumerable<Type> PossibleChildren => null;
private FillFlowContainer childModeButtons;
private Container textContainer;
private Box box;
@ -80,6 +79,8 @@ namespace osu.Game.Screens
public ScreenWhiteBox()
{
FillFlowContainer childModeButtons;
Children = new Drawable[]
{
box = new Box

View File

@ -234,9 +234,7 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleClick = audio.Sample.Get($@"Menu/menu-{internalName}-click");
if (sampleClick == null)
sampleClick = audio.Sample.Get(internalName.Contains(@"back") ? @"Menu/menuback" : @"Menu/menuhit");
sampleClick = audio.Sample.Get($@"Menu/menu-{internalName}-click") ?? audio.Sample.Get(internalName.Contains(@"back") ? @"Menu/menuback" : @"Menu/menuhit");
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)

View File

@ -19,7 +19,7 @@ using OpenTK.Input;
namespace osu.Game.Screens.Menu
{
public partial class ButtonSystem : Container, IStateful<MenuState>
public class ButtonSystem : Container, IStateful<MenuState>
{
public Action OnEdit;
public Action OnExit;

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Play
//further: change default values here and in KeyCounterCollection if needed, instead of passing them in every constructor
public Color4 KeyDownTextColor { get; set; } = Color4.DarkGray;
public Color4 KeyUpTextColor { get; set; } = Color4.White;
public int FadeTime { get; set; } = 0;
public int FadeTime { get; set; }
protected KeyCounter(string name)
{

View File

@ -50,7 +50,7 @@ namespace osu.Game.Screens.Play
},
new OsuSpriteText
{
Text = String.Format("{0:n0}", value),
Text = $"{value:n0}",
Font = @"Exo2.0-Bold",
Shadow = true,
ShadowColour = new Color4(0, 0, 0, 0.25f),

View File

@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play
private PauseOverlay pauseOverlay;
[BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config)
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
{
var beatmap = Beatmap.Beatmap;

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@ -60,7 +59,7 @@ namespace osu.Game.Screens.Select
{
searchTextBox = new SearchTextBox {
RelativeSizeAxes = Axes.X,
OnChange = (TextBox sender, bool newText) =>
OnChange = (sender, newText) =>
{
if (newText)
FilterChanged?.Invoke();

View File

@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Position = new Vector2(BackButton.SIZE_EXTENDED.X + padding, 0),
Position = new Vector2(TwoLayerButton.SIZE_EXTENDED.X + padding, 0),
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,

View File

@ -341,7 +341,7 @@ namespace osu.Game.Screens.Select
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
changeBackground(beatmap);
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
carousel.SelectBeatmap(beatmap.BeatmapInfo);
}
/// <summary>

View File

@ -267,10 +267,7 @@ namespace osu.Game.Screens.Tournament
}
};
if (writeOp == null)
writeOp = Task.Run(writeAction);
else
writeOp = writeOp.ContinueWith(t => { writeAction(); });
writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run(writeAction);
}
private void reloadTeams()

View File

@ -263,9 +263,9 @@ namespace osu.Game.Screens.Tournament
private void addFlags()
{
for (int i = 0; i < availableTeams.Count; i++)
foreach (Team t in availableTeams)
{
Add(new ScrollingTeam(availableTeams[i])
Add(new ScrollingTeam(t)
{
X = leftPos + DrawWidth
});