Reduce warning/suggestion count to zero.

This commit is contained in:
Dean Herbert
2017-03-09 15:52:40 +09:00
parent a048e666d7
commit d7497330b2
22 changed files with 84 additions and 87 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Screens.Testing; using osu.Framework.Screens.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -38,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests
WorkingBeatmap beatmap = null; WorkingBeatmap beatmap = null;
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault(); var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Mode == PlayMode.Osu);
if (beatmapInfo != null) if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo); beatmap = db.GetWorkingBeatmap(beatmapInfo);

View File

@ -3,11 +3,8 @@
using System; using System;
using System.IO; using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Input.Handlers; using osu.Framework.Input.Handlers;
using osu.Framework.Platform;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Modes; using osu.Game.Modes;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -20,16 +17,9 @@ namespace osu.Desktop.VisualTests.Tests
private InputHandler replay; private InputHandler replay;
private Func<Stream> getReplayStream; private Func<Stream> getReplayStream;
private ScoreDatabase scoreDatabase;
public override string Description => @"Testing replay playback."; public override string Description => @"Testing replay playback.";
[BackgroundDependencyLoader]
private void load(Storage storage)
{
scoreDatabase = new ScoreDatabase(storage);
}
protected override Player CreatePlayer(WorkingBeatmap beatmap) protected override Player CreatePlayer(WorkingBeatmap beatmap)
{ {
var player = base.CreatePlayer(beatmap); var player = base.CreatePlayer(beatmap);

View File

@ -189,7 +189,7 @@ namespace osu.Desktop.Overlays
private class UpdateProgressNotification : ProgressNotification private class UpdateProgressNotification : ProgressNotification
{ {
protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification(this) protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification()
{ {
Text = @"Update ready to install. Click to restart!", Text = @"Update ready to install. Click to restart!",
Activated = () => Activated = () =>

View File

@ -24,10 +24,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private SliderBody body; private SliderBody body;
private SliderBall ball; private SliderBall ball;
private SliderBouncer bouncer1, bouncer2; private SliderBouncer bouncer2;
public DrawableSlider(Slider s) : base(s) public DrawableSlider(Slider s) : base(s)
{ {
SliderBouncer bouncer1;
slider = s; slider = s;
Children = new Drawable[] Children = new Drawable[]
@ -124,8 +125,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
protected override void CheckJudgement(bool userTriggered) protected override void CheckJudgement(bool userTriggered)
{ {
var j = Judgement as OsuJudgementInfo; var j = (OsuJudgementInfo)Judgement;
var sc = initialCircle.Judgement as OsuJudgementInfo; var sc = (OsuJudgementInfo)initialCircle.Judgement;
if (!userTriggered && Time.Current >= HitObject.EndTime) if (!userTriggered && Time.Current >= HitObject.EndTime)
{ {

View File

@ -65,12 +65,13 @@ namespace osu.Game.Modes.Osu
private double applyModsToTime(double v) => v; private double applyModsToTime(double v) => v;
private double applyModsToRate(double v) => v; private double applyModsToRate(double v) => v;
public bool DelayedMovements; // ModManager.CheckActive(Mods.Relax2);
private void createAutoReplay() private void createAutoReplay()
{ {
int buttonIndex = 0; int buttonIndex = 0;
bool delayedMovements = false;// ModManager.CheckActive(Mods.Relax2); EasingTypes preferredEasing = DelayedMovements ? EasingTypes.InOutCubic : EasingTypes.Out;
EasingTypes preferredEasing = delayedMovements ? EasingTypes.InOutCubic : EasingTypes.Out;
addFrameToReplay(new LegacyReplayFrame(-100000, 256, 500, LegacyButtonState.None)); addFrameToReplay(new LegacyReplayFrame(-100000, 256, 500, LegacyButtonState.None));
addFrameToReplay(new LegacyReplayFrame(beatmap.HitObjects[0].StartTime - 1500, 256, 500, LegacyButtonState.None)); addFrameToReplay(new LegacyReplayFrame(beatmap.HitObjects[0].StartTime - 1500, 256, 500, LegacyButtonState.None));
@ -85,7 +86,7 @@ namespace osu.Game.Modes.Osu
for (int i = 0; i < beatmap.HitObjects.Count; i++) for (int i = 0; i < beatmap.HitObjects.Count; i++)
{ {
OsuHitObject h = beatmap.HitObjects[i] as OsuHitObject; OsuHitObject h = (OsuHitObject)beatmap.HitObjects[i];
//if (h.EndTime < InputManager.ReplayStartTime) //if (h.EndTime < InputManager.ReplayStartTime)
//{ //{
@ -95,9 +96,9 @@ namespace osu.Game.Modes.Osu
int endDelay = h is Spinner ? 1 : 0; int endDelay = h is Spinner ? 1 : 0;
if (delayedMovements && i > 0) if (DelayedMovements && i > 0)
{ {
OsuHitObject last = beatmap.HitObjects[i - 1] as OsuHitObject; OsuHitObject last = (OsuHitObject)beatmap.HitObjects[i - 1];
//Make the cursor stay at a hitObject as long as possible (mainly for autopilot). //Make the cursor stay at a hitObject as long as possible (mainly for autopilot).
if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50) if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)

View File

@ -3,6 +3,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.IO.Legacy; using osu.Game.IO.Legacy;
using osu.Game.IPC; using osu.Game.IPC;
@ -18,6 +19,7 @@ namespace osu.Game.Database
private const string replay_folder = @"replays"; private const string replay_folder = @"replays";
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private ScoreIPCChannel ipc; private ScoreIPCChannel ipc;
public ScoreDatabase(Storage storage, IIpcHost importHost = null, BeatmapDatabase beatmaps = null) public ScoreDatabase(Storage storage, IIpcHost importHost = null, BeatmapDatabase beatmaps = null)
@ -45,7 +47,7 @@ namespace osu.Game.Database
var version = sr.ReadInt32(); var version = sr.ReadInt32();
/* score.FileChecksum = */ /* score.FileChecksum = */
var beatmapHash = sr.ReadString(); var beatmapHash = sr.ReadString();
score.Beatmap = beatmaps.Query<BeatmapInfo>().Where(b => b.Hash == beatmapHash).FirstOrDefault(); score.Beatmap = beatmaps.Query<BeatmapInfo>().FirstOrDefault(b => b.Hash == beatmapHash);
/* score.PlayerName = */ /* score.PlayerName = */
sr.ReadString(); sr.ReadString();
/* var localScoreChecksum = */ /* var localScoreChecksum = */

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -184,6 +185,9 @@ namespace osu.Game.IO.Legacy
{ {
if (formatter == null) if (formatter == null)
initialize(); initialize();
Debug.Assert(formatter != null, "formatter != null");
return formatter.Deserialize(stream); return formatter.Deserialize(stream);
} }
@ -203,46 +207,39 @@ namespace osu.Game.IO.Legacy
List<Type> tmpTypes = new List<Type>(); List<Type> tmpTypes = new List<Type>();
Type genType = null; Type genType = null;
try if (typeName.Contains("System.Collections.Generic") && typeName.Contains("[["))
{ {
if (typeName.Contains("System.Collections.Generic") && typeName.Contains("[[")) string[] splitTyps = typeName.Split('[');
{
string[] splitTyps = typeName.Split('[');
foreach (string typ in splitTyps) foreach (string typ in splitTyps)
{
if (typ.Contains("Version"))
{ {
if (typ.Contains("Version")) string asmTmp = typ.Substring(typ.IndexOf(',') + 1);
{ string asmName = asmTmp.Remove(asmTmp.IndexOf(']')).Trim();
string asmTmp = typ.Substring(typ.IndexOf(',') + 1); string typName = typ.Remove(typ.IndexOf(','));
string asmName = asmTmp.Remove(asmTmp.IndexOf(']')).Trim(); tmpTypes.Add(BindToType(asmName, typName));
string typName = typ.Remove(typ.IndexOf(','));
tmpTypes.Add(BindToType(asmName, typName));
}
else if (typ.Contains("Generic"))
{
genType = BindToType(assemblyName, typ);
}
} }
if (genType != null && tmpTypes.Count > 0) else if (typ.Contains("Generic"))
{ {
return genType.MakeGenericType(tmpTypes.ToArray()); genType = BindToType(assemblyName, typ);
} }
} }
if (genType != null && tmpTypes.Count > 0)
string toAssemblyName = assemblyName.Split(',')[0];
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{ {
if (a.FullName.Split(',')[0] == toAssemblyName) return genType.MakeGenericType(tmpTypes.ToArray());
{
typeToDeserialize = a.GetType(typeName);
break;
}
} }
} }
catch (Exception exception)
string toAssemblyName = assemblyName.Split(',')[0];
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly a in assemblies)
{ {
throw exception; if (a.FullName.Split(',')[0] == toAssemblyName)
{
typeToDeserialize = a.GetType(typeName);
break;
}
} }
cache.Add(assemblyName + typeName, typeToDeserialize); cache.Add(assemblyName + typeName, typeToDeserialize);

View File

@ -8,6 +8,8 @@ using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
// ReSharper disable ConditionIsAlwaysTrueOrFalse (we're allowing nulls to be passed to the writer where the underlying class doesn't).
// ReSharper disable HeuristicUnreachableCode
namespace osu.Game.IO.Legacy namespace osu.Game.IO.Legacy
{ {

View File

@ -19,7 +19,10 @@ namespace osu.Game.IPC
MessageReceived += msg => MessageReceived += msg =>
{ {
Debug.Assert(beatmaps != null); Debug.Assert(beatmaps != null);
ImportAsync(msg.Path); ImportAsync(msg.Path).ContinueWith(t =>
{
if (t.Exception != null) throw t.Exception;
}, TaskContinuationOptions.OnlyOnFaulted);
}; };
} }

View File

@ -129,10 +129,13 @@ namespace osu.Game.Modes.Objects.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
string hitType = ((HitObject.Sample?.Type ?? SampleType.None) == SampleType.None ? SampleType.Normal : HitObject.Sample.Type).ToString().ToLower(); SampleType type = HitObject.Sample?.Type ?? SampleType.None;
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower(); if (type == SampleType.None)
type = SampleType.Normal;
Sample = audio.Sample.Get($@"Gameplay/{sampleSet}-hit{hitType}"); SampleSet sampleSet = HitObject.Sample?.Set ?? SampleSet.Normal;
Sample = audio.Sample.Get($@"Gameplay/{sampleSet.ToString().ToLower()}-hit{type.ToString().ToLower()}");
} }
private List<DrawableHitObject<HitObjectType>> nestedHitObjects; private List<DrawableHitObject<HitObjectType>> nestedHitObjects;

View File

@ -50,6 +50,7 @@ namespace osu.Game
{ {
get get
{ {
// ReSharper disable once RedundantAssignment
bool isDebug = false; bool isDebug = false;
// Debug.Assert conditions are only evaluated in debug mode // Debug.Assert conditions are only evaluated in debug mode
Debug.Assert(isDebug = true); Debug.Assert(isDebug = true);

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -30,7 +31,7 @@ namespace osu.Game.Overlays
{ {
private MusicControllerBackground backgroundSprite; private MusicControllerBackground backgroundSprite;
private DragBar progress; private DragBar progress;
private TextAwesome playButton, listButton; private TextAwesome playButton;
private SpriteText title, artist; private SpriteText title, artist;
private List<BeatmapSetInfo> playList; private List<BeatmapSetInfo> playList;
@ -59,6 +60,8 @@ namespace osu.Game.Overlays
protected override bool OnDrag(InputState state) protected override bool OnDrag(InputState state)
{ {
Trace.Assert(state.Mouse.PositionMouseDown != null, "state.Mouse.PositionMouseDown != null");
Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value; Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
// Diminish the drag distance as we go further to simulate "rubber band" feeling. // Diminish the drag distance as we go further to simulate "rubber band" feeling.
@ -187,7 +190,7 @@ namespace osu.Game.Overlays
Position = new Vector2(20, -30), Position = new Vector2(20, -30),
Children = new Drawable[] Children = new Drawable[]
{ {
listButton = new TextAwesome new TextAwesome
{ {
TextSize = 15, TextSize = 15,
Icon = FontAwesome.fa_bars, Icon = FontAwesome.fa_bars,

View File

@ -10,11 +10,8 @@ namespace osu.Game.Overlays.Notifications
{ {
public class ProgressCompletionNotification : SimpleNotification public class ProgressCompletionNotification : SimpleNotification
{ {
private ProgressNotification progressNotification; public ProgressCompletionNotification()
public ProgressCompletionNotification(ProgressNotification progressNotification)
{ {
this.progressNotification = progressNotification;
Icon = FontAwesome.fa_check; Icon = FontAwesome.fa_check;
} }

View File

@ -90,7 +90,7 @@ namespace osu.Game.Overlays.Notifications
private ProgressNotificationState state; private ProgressNotificationState state;
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification(this) protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification()
{ {
Activated = CompletionClickAction, Activated = CompletionClickAction,
Text = $"Task \"{Text}\" has completed!" Text = $"Task \"{Text}\" has completed!"

View File

@ -81,10 +81,8 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
if (base.Read = value) base.Read = value;
Light.FadeOut(100); Light.FadeTo(value ? 1 : 0, 100);
else
Light.FadeIn(100);
} }
} }
} }

View File

@ -147,11 +147,8 @@ namespace osu.Game.Overlays
var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected); var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected);
var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate); var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate);
if (next != null) if (next != null) next.Selected = true;
{ if (previous != null) previous.Selected = false;
previous.Selected = false;
next.Selected = true;
}
} }
} }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Toolbar
protected override bool BlockPassThroughInput => false; protected override bool BlockPassThroughInput => false;
private const int transition_time = 500; private const double transition_time = 500;
private const float alpha_hovering = 0.8f; private const float alpha_hovering = 0.8f;
private const float alpha_normal = 0.6f; private const float alpha_normal = 0.6f;

View File

@ -21,7 +21,7 @@ namespace osu.Game.Screens
{ {
private BackButton popButton; private BackButton popButton;
private const int transition_time = 1000; private const double transition_time = 1000;
protected virtual IEnumerable<Type> PossibleChildren => null; protected virtual IEnumerable<Type> PossibleChildren => null;

View File

@ -28,16 +28,11 @@ namespace osu.Game.Screens.Menu
{ {
private Container iconText; private Container iconText;
private Container box; private Container box;
private Box boxColourLayer;
private Box boxHoverLayer; private Box boxHoverLayer;
private Color4 colour;
private TextAwesome icon; private TextAwesome icon;
private string internalName; private string internalName;
private readonly FontAwesome symbol;
private Action clickAction; private Action clickAction;
private readonly float extraWidth;
private Key triggerKey; private Key triggerKey;
private string text;
private SampleChannel sampleClick; private SampleChannel sampleClick;
public override bool Contains(Vector2 screenSpacePos) public override bool Contains(Vector2 screenSpacePos)
@ -48,12 +43,8 @@ namespace osu.Game.Screens.Menu
public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown)
{ {
this.internalName = internalName; this.internalName = internalName;
this.symbol = symbol;
this.colour = colour;
this.clickAction = clickAction; this.clickAction = clickAction;
this.extraWidth = extraWidth;
this.triggerKey = triggerKey; this.triggerKey = triggerKey;
this.text = text;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Alpha = 0; Alpha = 0;
@ -80,7 +71,7 @@ namespace osu.Game.Screens.Menu
Shear = new Vector2(ButtonSystem.WEDGE_WIDTH / boxSize.Y, 0), Shear = new Vector2(ButtonSystem.WEDGE_WIDTH / boxSize.Y, 0),
Children = new [] Children = new []
{ {
boxColourLayer = new Box new Box
{ {
EdgeSmoothness = new Vector2(1.5f, 0), EdgeSmoothness = new Vector2(1.5f, 0),
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -321,12 +312,12 @@ namespace osu.Game.Screens.Menu
case ButtonState.Expanded: case ButtonState.Expanded:
const int expand_duration = 500; const int expand_duration = 500;
box.ScaleTo(new Vector2(1, 1), expand_duration, EasingTypes.OutExpo); box.ScaleTo(new Vector2(1, 1), expand_duration, EasingTypes.OutExpo);
FadeIn(expand_duration / 6); FadeIn(expand_duration / 6f);
break; break;
case ButtonState.Exploded: case ButtonState.Exploded:
const int explode_duration = 200; const int explode_duration = 200;
box.ScaleTo(new Vector2(2, 1), explode_duration, EasingTypes.OutExpo); box.ScaleTo(new Vector2(2, 1), explode_duration, EasingTypes.OutExpo);
FadeOut(explode_duration / 4 * 3); FadeOut(explode_duration / 4f * 3);
break; break;
} }
} }

View File

@ -81,6 +81,9 @@ namespace osu.Game.Screens.Play
if ((Beatmap?.Beatmap?.HitObjects.Count ?? 0) == 0) if ((Beatmap?.Beatmap?.HitObjects.Count ?? 0) == 0)
throw new Exception("No valid objects were found!"); throw new Exception("No valid objects were found!");
if (Beatmap == null)
throw new Exception("Beatmap was not loaded");
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -167,7 +167,7 @@ namespace osu.Game.Screens.Play
{ {
new Sprite new Sprite
{ {
Texture = beatmap.Background, Texture = beatmap?.Background,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
@ -176,7 +176,7 @@ namespace osu.Game.Screens.Play
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = beatmap.BeatmapInfo?.Version, Text = beatmap?.BeatmapInfo?.Version,
TextSize = 26, TextSize = 26,
Font = @"Exo2.0-MediumItalic", Font = @"Exo2.0-MediumItalic",
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -109,7 +110,11 @@ namespace osu.Game.Screens.Tournament
break; break;
case ScrollState.Stopped: case ScrollState.Stopped:
// Find closest to center // Find closest to center
if (!Children.Any())
break;
Drawable closest = null; Drawable closest = null;
foreach (var c in Children) foreach (var c in Children)
{ {
if (!(c is ScrollingTeam)) if (!(c is ScrollingTeam))
@ -128,6 +133,8 @@ namespace osu.Game.Screens.Tournament
closest = c; closest = c;
} }
Trace.Assert(closest != null, "closest != null");
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f); offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
ScrollingTeam st = closest as ScrollingTeam; ScrollingTeam st = closest as ScrollingTeam;
@ -310,7 +317,7 @@ namespace osu.Game.Screens.Tournament
public override void Apply(Drawable d) public override void Apply(Drawable d)
{ {
base.Apply(d); base.Apply(d);
(d as ScrollingTeamContainer).speed = CurrentValue; ((ScrollingTeamContainer)d).speed = CurrentValue;
} }
} }