1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 14:12:55 +08:00

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
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
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
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Screens.Testing;
using osu.Game.Beatmaps;
@ -38,7 +39,7 @@ namespace osu.Desktop.VisualTests.Tests
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)
beatmap = db.GetWorkingBeatmap(beatmapInfo);

View File

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

View File

@ -189,7 +189,7 @@ namespace osu.Desktop.Overlays
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!",
Activated = () =>

View File

@ -24,10 +24,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private SliderBody body;
private SliderBall ball;
private SliderBouncer bouncer1, bouncer2;
private SliderBouncer bouncer2;
public DrawableSlider(Slider s) : base(s)
{
SliderBouncer bouncer1;
slider = s;
Children = new Drawable[]
@ -124,8 +125,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
protected override void CheckJudgement(bool userTriggered)
{
var j = Judgement as OsuJudgementInfo;
var sc = initialCircle.Judgement as OsuJudgementInfo;
var j = (OsuJudgementInfo)Judgement;
var sc = (OsuJudgementInfo)initialCircle.Judgement;
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 applyModsToRate(double v) => v;
public bool DelayedMovements; // ModManager.CheckActive(Mods.Relax2);
private void createAutoReplay()
{
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(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++)
{
OsuHitObject h = beatmap.HitObjects[i] as OsuHitObject;
OsuHitObject h = (OsuHitObject)beatmap.HitObjects[i];
//if (h.EndTime < InputManager.ReplayStartTime)
//{
@ -95,9 +96,9 @@ namespace osu.Game.Modes.Osu
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).
if (h.StartTime - h.HitWindowFor(OsuScoreResult.Miss) > last.EndTime + h.HitWindowFor(OsuScoreResult.Hit50) + 50)

View File

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq;
using osu.Framework.Platform;
using osu.Game.IO.Legacy;
using osu.Game.IPC;
@ -18,6 +19,7 @@ namespace osu.Game.Database
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;
public ScoreDatabase(Storage storage, IIpcHost importHost = null, BeatmapDatabase beatmaps = null)
@ -45,7 +47,7 @@ namespace osu.Game.Database
var version = sr.ReadInt32();
/* score.FileChecksum = */
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 = */
sr.ReadString();
/* var localScoreChecksum = */

View File

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

View File

@ -8,6 +8,8 @@ using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
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
{

View File

@ -19,7 +19,10 @@ namespace osu.Game.IPC
MessageReceived += msg =>
{
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]
private void load(AudioManager audio)
{
string hitType = ((HitObject.Sample?.Type ?? SampleType.None) == SampleType.None ? SampleType.Normal : HitObject.Sample.Type).ToString().ToLower();
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower();
SampleType type = HitObject.Sample?.Type ?? SampleType.None;
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;

View File

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

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using OpenTK;
using OpenTK.Graphics;
@ -30,7 +31,7 @@ namespace osu.Game.Overlays
{
private MusicControllerBackground backgroundSprite;
private DragBar progress;
private TextAwesome playButton, listButton;
private TextAwesome playButton;
private SpriteText title, artist;
private List<BeatmapSetInfo> playList;
@ -59,6 +60,8 @@ namespace osu.Game.Overlays
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;
// 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),
Children = new Drawable[]
{
listButton = new TextAwesome
new TextAwesome
{
TextSize = 15,
Icon = FontAwesome.fa_bars,

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Toolbar
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_normal = 0.6f;

View File

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

View File

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

View File

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

View File

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

View File

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