1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge remote-tracking branch 'upstream/master' into less-mods-enum

# Conflicts:
#	osu.Game.Modes.Mania/ManiaMod.cs
#	osu.Game.Modes.Osu/OsuMod.cs
#	osu.Game/Modes/Mod.cs
This commit is contained in:
Dean Herbert 2017-03-07 13:42:50 +09:00
commit 3e4cd0dc7c
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
177 changed files with 666 additions and 526 deletions

@ -1 +1 @@
Subproject commit 169f0a758c6b565ee42832f99bf4b5303f4413a6
Subproject commit 476c8792ee6b42cf4e5f0362b4eb09c0230807d8

@ -1 +1 @@
Subproject commit 93eb5bf99bb642bf339d7dce09c2d946412dadd6
Subproject commit 9533590f839aa6e27ed7f8b9064a0e7dc08ad861

View File

@ -40,7 +40,7 @@ namespace osu.Desktop.Deploy
/// <summary>
/// How many previous build deltas we want to keep when publishing.
/// </summary>
const int keep_delta_count = 3;
private const int keep_delta_count = 3;
private static string codeSigningCmd => string.IsNullOrEmpty(codeSigningPassword) ? "" : $"-n \"/a /f {codeSigningCertPath} /p {codeSigningPassword} /t http://timestamp.comodoca.com/authenticode\"";
@ -172,10 +172,10 @@ namespace osu.Desktop.Deploy
}
//remove excess deltas
var deltas = releaseLines.Where(l => l.Filename.Contains("-delta"));
if (deltas.Count() > keep_delta_count)
var deltas = releaseLines.Where(l => l.Filename.Contains("-delta")).ToArray();
if (deltas.Length > keep_delta_count)
{
foreach (var l in deltas.Take(deltas.Count() - keep_delta_count))
foreach (var l in deltas.Take(deltas.Length - keep_delta_count))
{
write($"- Removing old delta {l.Filename}", ConsoleColor.Yellow);
File.Delete(Path.Combine(ReleasesFolder, l.Filename));
@ -342,8 +342,9 @@ namespace osu.Desktop.Deploy
};
Process p = Process.Start(psi);
if (p == null || p.ExitCode == 0) return true;
string output = p.StandardOutput.ReadToEnd();
if (p.ExitCode == 0) return true;
write(output);
error($"Command {command} {args} failed!");

View File

@ -23,7 +23,7 @@ namespace osu.Desktop.VisualTests.Platform
platform = new SQLitePlatformWin32();
else
platform = new SQLitePlatformGeneric();
return new SQLiteConnection(platform, $@":memory:");
return new SQLiteConnection(platform, @":memory:");
}
}
}

View File

@ -4,9 +4,9 @@
using osu.Framework.Screens.Testing;
using osu.Game.Screens.Select.Options;
namespace osu.Desktop.VisualTests
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseBeatmapOptionsOverlay : TestCase
internal class TestCaseBeatmapOptionsOverlay : TestCase
{
public override string Description => @"Beatmap options in song select";

View File

@ -8,7 +8,7 @@ using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseChatDisplay : TestCase
internal class TestCaseChatDisplay : TestCase
{
private ScheduledDelegate messageRequest;
@ -18,7 +18,7 @@ namespace osu.Desktop.VisualTests.Tests
{
base.Reset();
Add(new ChatOverlay()
Add(new ChatOverlay
{
State = Visibility.Visible
});

View File

@ -8,11 +8,11 @@ using osu.Game.Overlays.Dialog;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseDialogOverlay : TestCase
internal class TestCaseDialogOverlay : TestCase
{
public override string Description => @"Display dialogs";
DialogOverlay overlay;
private DialogOverlay overlay;
public override void Reset()
{

View File

@ -2,23 +2,16 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Platform;
using osu.Framework.Screens.Testing;
using osu.Game.Screens.Tournament;
using osu.Game.Screens.Tournament.Teams;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseDrawings : TestCase
internal class TestCaseDrawings : TestCase
{
public override string Description => "Tournament drawings";
[BackgroundDependencyLoader]
private void load(Storage storage)
{
}
public override void Reset()
{
base.Reset();
@ -29,7 +22,7 @@ namespace osu.Desktop.VisualTests.Tests
});
}
class TestTeamList : ITeamList
private class TestTeamList : ITeamList
{
public IEnumerable<Team> Teams { get; } = new[]
{

View File

@ -18,7 +18,7 @@ using OpenTK;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseGamefield : TestCase
internal class TestCaseGamefield : TestCase
{
public override string Description => @"Showing hitobjects and what not.";
@ -31,7 +31,7 @@ namespace osu.Desktop.VisualTests.Tests
int time = 500;
for (int i = 0; i < 100; i++)
{
objects.Add(new HitCircle()
objects.Add(new HitCircle
{
StartTime = time,
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384)),

View File

@ -17,12 +17,12 @@ using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseHitObjects : TestCase
internal class TestCaseHitObjects : TestCase
{
private StopwatchClock rateAdjustClock;
private FramedClock framedClock;
bool auto = false;
private bool auto;
public TestCaseHitObjects()
{
@ -31,9 +31,9 @@ namespace osu.Desktop.VisualTests.Tests
playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
}
HitObjectType mode = HitObjectType.Slider;
private HitObjectType mode = HitObjectType.Slider;
BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
private BindableNumber<double> playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 };
private Container playfieldContainer;
private Container approachContainer;
@ -61,7 +61,7 @@ namespace osu.Desktop.VisualTests.Tests
add(new DrawableSlider(new Slider
{
StartTime = framedClock.CurrentTime + 600,
ControlPoints = new List<Vector2>()
ControlPoints = new List<Vector2>
{
new Vector2(-200, 0),
new Vector2(400, 0),
@ -93,7 +93,7 @@ namespace osu.Desktop.VisualTests.Tests
AddButton(@"slider", () => load(HitObjectType.Slider));
AddButton(@"spinner", () => load(HitObjectType.Spinner));
AddToggle(@"auto", (state) => { auto = state; load(mode); });
AddToggle(@"auto", state => { auto = state; load(mode); });
ButtonsContainer.Add(new SpriteText { Text = "Playback Speed" });
ButtonsContainer.Add(new BasicSliderBar<double>
@ -122,8 +122,9 @@ namespace osu.Desktop.VisualTests.Tests
load(mode);
}
int depth;
void add(DrawableHitObject h)
private int depth;
private void add(DrawableHitObject h)
{
h.Anchor = Anchor.Centre;
h.Depth = depth++;

View File

@ -15,7 +15,7 @@ using osu.Game.Screens.Play;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseKeyCounter : TestCase
internal class TestCaseKeyCounter : TestCase
{
public override string Description => @"Tests key counter";

View File

@ -9,7 +9,7 @@ using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseMenuButtonSystem : TestCase
internal class TestCaseMenuButtonSystem : TestCase
{
public override string Description => @"Main menu button system";

View File

@ -8,7 +8,7 @@ using osu.Game.Modes;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseModSelectOverlay : TestCase
internal class TestCaseModSelectOverlay : TestCase
{
public override string Description => @"Tests the mod select overlay";

View File

@ -9,7 +9,7 @@ using osu.Framework.Graphics.Containers;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseMusicController : TestCase
internal class TestCaseMusicController : TestCase
{
public override string Description => @"Tests music controller ui.";
@ -30,7 +30,7 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.Centre
};
Add(mc);
AddToggle(@"Show", (state) => mc.State = state ? Visibility.Visible : Visibility.Hidden);
AddToggle(@"Show", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
}
}
}

View File

@ -12,11 +12,11 @@ using osu.Framework.Graphics.Containers;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseNotificationManager : TestCase
internal class TestCaseNotificationManager : TestCase
{
public override string Description => @"I handle notifications";
NotificationManager manager;
private NotificationManager manager;
public override void Reset()
{
@ -30,7 +30,7 @@ namespace osu.Desktop.VisualTests.Tests
Origin = Anchor.TopRight,
});
AddToggle(@"show", (state) => manager.State = state ? Visibility.Visible : Visibility.Hidden);
AddToggle(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden);
AddButton(@"simple #1", sendNotification1);
AddButton(@"simple #2", sendNotification2);
@ -95,7 +95,7 @@ namespace osu.Desktop.VisualTests.Tests
progressingNotifications.Add(n);
}
List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
private List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
private void sendProgress1()
{

View File

@ -6,7 +6,7 @@ using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseOptions : TestCase
internal class TestCaseOptions : TestCase
{
public override string Description => @"Tests the options overlay";

View File

@ -7,7 +7,7 @@ using osu.Game.Screens.Play;
namespace osu.Desktop.VisualTests.Tests
{
class TestCasePauseOverlay : TestCase
internal class TestCasePauseOverlay : TestCase
{
public override string Description => @"Tests the pause overlay";

View File

@ -11,7 +11,7 @@ using osu.Game.Screens.Select;
namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlaySongSelect : TestCase
internal class TestCasePlaySongSelect : TestCase
{
private BeatmapDatabase db, oldDb;
private TestStorage storage;

View File

@ -18,7 +18,7 @@ using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{
class TestCasePlayer : TestCase
internal class TestCasePlayer : TestCase
{
private WorkingBeatmap beatmap;
@ -27,6 +27,7 @@ namespace osu.Desktop.VisualTests.Tests
[BackgroundDependencyLoader]
private void load(BeatmapDatabase db)
{
// ReSharper disable once ReplaceWithSingleCallToFirstOrDefault (TableQuery doesn't have correct LINQ implementation for First/FirstOrDefault).
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);
@ -43,7 +44,7 @@ namespace osu.Desktop.VisualTests.Tests
int time = 1500;
for (int i = 0; i < 50; i++)
{
objects.Add(new HitCircle()
objects.Add(new HitCircle
{
StartTime = time,
Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : 512,
@ -91,7 +92,7 @@ namespace osu.Desktop.VisualTests.Tests
});
}
class TestWorkingBeatmap : WorkingBeatmap
private class TestWorkingBeatmap : WorkingBeatmap
{
public TestWorkingBeatmap(Beatmap beatmap)
: base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet)

View File

@ -18,7 +18,7 @@ using osu.Framework.Graphics.Primitives;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseScoreCounter : TestCase
internal class TestCaseScoreCounter : TestCase
{
public override string Description => @"Tests multiple counters";

View File

@ -12,7 +12,7 @@ using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseTextAwesome : TestCase
internal class TestCaseTextAwesome : TestCase
{
public override string Description => @"Tests display of icons";
@ -22,7 +22,7 @@ namespace osu.Desktop.VisualTests.Tests
FillFlowContainer flow;
Add(flow = new FillFlowContainer()
Add(flow = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),

View File

@ -7,7 +7,7 @@ using osu.Game.Screens.Play;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseTwoLayerButton : TestCase
internal class TestCaseTwoLayerButton : TestCase
{
public override string Description => @"Back and skip and what not";

View File

@ -7,13 +7,13 @@ using osu.Game.Screens.Backgrounds;
namespace osu.Desktop.VisualTests
{
class VisualTestGame : OsuGameBase
internal class VisualTestGame : OsuGameBase
{
protected override void LoadComplete()
{
base.LoadComplete();
(new BackgroundScreenDefault() { Depth = 10 }).LoadAsync(this, AddInternal);
new BackgroundScreenDefault { Depth = 10 }.LoadAsync(this, AddInternal);
// Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load().

View File

@ -17,16 +17,16 @@ namespace osu.Desktop.Beatmaps.IO
{
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
private string basePath { get; set; }
private Beatmap firstMap { get; set; }
private string basePath { get; }
private Beatmap firstMap { get; }
public LegacyFilesystemReader(string path)
{
basePath = path;
BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray();
BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(Path.GetFileName).ToArray();
if (BeatmapFilenames.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(f => Path.GetFileName(f)).FirstOrDefault();
StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(Path.GetFileName).FirstOrDefault();
using (var stream = new StreamReader(GetStream(BeatmapFilenames[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);

View File

@ -13,12 +13,10 @@ using osu.Game.Screens.Menu;
namespace osu.Desktop
{
class OsuGameDesktop : OsuGame
internal class OsuGameDesktop : OsuGame
{
private VersionManager versionManager;
public override bool IsDeployedBuild => versionManager.IsDeployedBuild;
public OsuGameDesktop(string[] args = null)
: base(args)
{
@ -44,7 +42,7 @@ namespace osu.Desktop
if (desktopWindow != null)
{
desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
desktopWindow.Title = @"osu!lazer";
desktopWindow.Title = Name;
desktopWindow.DragEnter += dragEnter;
desktopWindow.DragDrop += dragDrop;
@ -66,10 +64,7 @@ namespace osu.Desktop
if (isFile)
{
var paths = (e.Data.GetData(DataFormats.FileDrop) as object[]).Select(f => f.ToString()).ToArray();
if (paths.Any(p => !p.EndsWith(".osz")))
e.Effect = DragDropEffects.None;
else
e.Effect = DragDropEffects.Copy;
e.Effect = paths.Any(p => !p.EndsWith(".osz")) ? DragDropEffects.None : DragDropEffects.Copy;
}
}
}

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@ -11,7 +10,6 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using Squirrel;
using System.Reflection;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
@ -19,6 +17,7 @@ using OpenTK;
using OpenTK.Graphics;
using System.Net.Http;
using osu.Framework.Logging;
using osu.Game;
namespace osu.Desktop.Overlays
{
@ -27,16 +26,12 @@ namespace osu.Desktop.Overlays
private UpdateManager updateManager;
private NotificationManager notificationManager;
AssemblyName assembly = Assembly.GetEntryAssembly().GetName();
public bool IsDeployedBuild => assembly.Version.Major > 0;
protected override bool HideOnEscape => false;
public override bool HandleInput => false;
[BackgroundDependencyLoader]
private void load(NotificationManager notification, OsuColour colours, TextureStore textures)
private void load(NotificationManager notification, OsuColour colours, TextureStore textures, OsuGameBase game)
{
notificationManager = notification;
@ -45,17 +40,6 @@ namespace osu.Desktop.Overlays
Origin = Anchor.BottomCentre;
Alpha = 0;
bool isDebug = false;
Debug.Assert(isDebug = true);
string version;
if (!IsDeployedBuild)
{
version = @"local " + (isDebug ? @"debug" : @"release");
}
else
version = $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}";
Children = new Drawable[]
{
new FillFlowContainer
@ -76,12 +60,12 @@ namespace osu.Desktop.Overlays
new OsuSpriteText
{
Font = @"Exo2.0-Bold",
Text = $@"osu!lazer"
Text = game.Name
},
new OsuSpriteText
{
Colour = isDebug ? colours.Red : Color4.White,
Text = version
Colour = game.IsDebug ? colours.Red : Color4.White,
Text = game.Version
},
}
},
@ -92,7 +76,7 @@ namespace osu.Desktop.Overlays
TextSize = 12,
Colour = colours.Yellow,
Font = @"Venera",
Text = $@"Development Build"
Text = @"Development Build"
},
new Sprite
{
@ -104,7 +88,7 @@ namespace osu.Desktop.Overlays
}
};
if (IsDeployedBuild)
if (game.IsDeployedBuild)
checkForUpdateAsync();
}
@ -203,7 +187,7 @@ namespace osu.Desktop.Overlays
{
}
class UpdateProgressNotification : ProgressNotification
private class UpdateProgressNotification : ProgressNotification
{
protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification(this)
{
@ -228,6 +212,7 @@ namespace osu.Desktop.Overlays
new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.fa_upload,
Colour = Color4.White,
}

View File

@ -8,7 +8,7 @@ using osu.Game.Beatmaps;
namespace osu.Game.Modes.Catch.Objects
{
class CatchConverter : HitObjectConverter<CatchBaseHit>
internal class CatchConverter : HitObjectConverter<CatchBaseHit>
{
public override List<CatchBaseHit> Convert(Beatmap beatmap)
{

View File

@ -10,7 +10,7 @@ using OpenTK;
namespace osu.Game.Modes.Catch.Objects.Drawable
{
class DrawableFruit : Sprite
internal class DrawableFruit : Sprite
{
private CatchBaseHit h;

View File

@ -26,8 +26,8 @@ namespace osu.Game.Modes.Mania.Objects.Drawable
{
Texture = textures.Get(@"Menu/logo");
Transforms.Add(new TransformPositionY() { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f });
Transforms.Add(new TransformAlpha() { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 });
Transforms.Add(new TransformPositionY { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f });
Transforms.Add(new TransformAlpha { StartTime = note.StartTime + note.Duration + 200, EndTime = note.StartTime + note.Duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}

View File

@ -9,7 +9,7 @@ using osu.Game.Beatmaps;
namespace osu.Game.Modes.Mania.Objects
{
class ManiaConverter : HitObjectConverter<ManiaBaseHit>
internal class ManiaConverter : HitObjectConverter<ManiaBaseHit>
{
private readonly int columns;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Modes.Mania.UI
/// </summary>
public class ManiaComboCounter : TaikoComboCounter
{
protected ushort KeysHeld = 0;
protected ushort KeysHeld;
protected Color4 OriginalColour;

View File

@ -11,11 +11,8 @@ namespace osu.Game.Modes.Mania.UI
{
public class ManiaPlayfield : Playfield
{
private readonly int columns;
public ManiaPlayfield(int columns)
{
this.columns = columns;
RelativeSizeAxes = Axes.Both;
Size = new Vector2(columns / 20f, 1f);
Anchor = Anchor.BottomCentre;
@ -24,7 +21,7 @@ namespace osu.Game.Modes.Mania.UI
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
for (int i = 0; i < columns; i++)
Add(new Box()
Add(new Box
{
RelativeSizeAxes = Axes.Y,
Size = new Vector2(2, 1),

View File

@ -17,7 +17,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Connections
public double EndTime;
public Vector2 EndPosition;
const float width = 8;
private const float width = 8;
public FollowPoint()
{

View File

@ -74,13 +74,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
for (int d = (int)(PointDistance * 1.5); d < distance - PointDistance; d += PointDistance)
{
float fraction = ((float)d / distance);
float fraction = (float)d / distance;
Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector;
Vector2 pointEndPosition = startPosition + fraction * distanceVector;
double fadeOutTime = startTime + fraction * duration;
double fadeInTime = fadeOutTime - PreEmpt;
Add(new FollowPoint()
Add(new FollowPoint
{
StartTime = fadeInTime,
EndTime = fadeOutTime,

View File

@ -49,7 +49,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
return true;
},
},
number = new NumberPiece()
number = new NumberPiece
{
Text = h is Spinner ? "S" : (HitObject.ComboIndex + 1).ToString(),
},
@ -59,7 +59,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
Colour = osuObject.Colour,
},
ApproachCircle = new ApproachCircle()
ApproachCircle = new ApproachCircle
{
Colour = osuObject.Colour,
}
@ -69,9 +69,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Size = circle.DrawSize;
}
double hit50 = 150;
double hit100 = 80;
double hit300 = 30;
private double hit50 = 150;
private double hit100 = 80;
private double hit300 = 30;
protected override void CheckJudgement(bool userTriggered)
{
@ -84,7 +84,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
double hitOffset = Math.Abs(Judgement.TimeOffset);
OsuJudgementInfo osuJudgement = Judgement as OsuJudgementInfo;
OsuJudgementInfo osuJudgement = (OsuJudgementInfo)Judgement;
if (hitOffset < hit50)
{

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.ComponentModel;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes.Osu.Objects.Drawables
@ -18,7 +17,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
}
public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.Hit300 };
protected override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.Hit300 };
protected override void UpdateState(ArmedState state)
{

View File

@ -21,10 +21,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
private Container<DrawableSliderTick> ticks;
SliderBody body;
SliderBall ball;
private SliderBody body;
private SliderBall ball;
SliderBouncer bouncer1, bouncer2;
private SliderBouncer bouncer1, bouncer2;
public DrawableSlider(Slider s) : base(s)
{
@ -94,7 +94,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
// pass all input through.
public override bool Contains(Vector2 screenSpacePos) => true;
int currentRepeat;
private int currentRepeat;
protected override void Update()
{
@ -103,7 +103,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
double progress = MathHelper.Clamp((Time.Current - slider.StartTime) / slider.Duration, 0, 1);
int repeat = (int)(progress * slider.RepeatCount);
progress = (progress * slider.RepeatCount) % 1;
progress = progress * slider.RepeatCount % 1;
if (repeat > currentRepeat)
{

View File

@ -26,7 +26,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
public override bool RemoveWhenNotAlive => false;
public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.SliderTick };
protected override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.SliderTick };
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
{
@ -71,7 +71,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
protected override void CheckJudgement(bool userTriggered)
{
var j = Judgement as OsuJudgementInfo;
var j = (OsuJudgementInfo)Judgement;
if (Judgement.TimeOffset >= 0)
{

View File

@ -75,7 +75,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
if (Time.Current < HitObject.StartTime) return;
var j = Judgement as OsuJudgementInfo;
var j = (OsuJudgementInfo)Judgement;
disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100);
@ -108,9 +108,9 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
}
}
private Vector2 scaleToCircle => (circle.Scale * circle.DrawWidth / DrawWidth) * 0.95f;
private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f;
private float spinsPerMinuteNeeded = 100 + (5 * 15); //TODO: read per-map OD and place it on the 5
private float spinsPerMinuteNeeded = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5
private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f);

View File

@ -15,7 +15,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
private readonly Slider slider;
private Box follow;
const float width = 128;
private const float width = 128;
public SliderBall(Slider slider)
{
@ -81,7 +81,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
return base.OnMouseMove(state);
}
bool tracking;
private bool tracking;
public bool Tracking
{
get { return tracking; }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
set { Disc.Colour = value; }
}
Color4 completeColour;
private Color4 completeColour;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -37,7 +37,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
completeColour = colours.YellowLight.Opacity(0.8f);
}
class SpinnerBorder : Container
private class SpinnerBorder : Container
{
public SpinnerBorder()
{
@ -116,7 +116,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
};
}
bool tracking;
private bool tracking;
public bool Tracking
{
get { return tracking; }
@ -130,7 +130,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
}
}
bool complete;
private bool complete;
public bool Complete
{
get { return complete; }

View File

@ -8,7 +8,7 @@ using System.Linq;
namespace osu.Game.Modes.Osu.Objects
{
class OsuHitObjectDifficulty
internal class OsuHitObjectDifficulty
{
/// <summary>
/// Factor by how much speed / aim strain decays per second.
@ -63,7 +63,7 @@ namespace osu.Game.Modes.Osu.Objects
MaxCombo += slider.Ticks.Count();
// We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps.
scalingFactor = (52.0f / circleRadius);
scalingFactor = 52.0f / circleRadius;
if (circleRadius < 30)
{
float smallCircleBonus = Math.Min(30.0f - circleRadius, 5.0f) / 50.0f;
@ -130,7 +130,7 @@ namespace osu.Game.Modes.Osu.Objects
else if (distance > almost_diameter)
return 1.2 + 0.4 * (distance - almost_diameter) / (stream_spacing_threshold - almost_diameter);
else if (distance > almost_diameter / 2)
return 0.95 + 0.25 * (distance - (almost_diameter / 2)) / (almost_diameter / 2);
return 0.95 + 0.25 * (distance - almost_diameter / 2) / (almost_diameter / 2);
else
return 0.95;

View File

@ -30,11 +30,8 @@ namespace osu.Game.Modes.Osu.Objects
break;
case HitObjectType.Slider:
CurveTypes curveType = CurveTypes.Catmull;
int repeatCount;
double length = 0;
List<Vector2> points = new List<Vector2>();
points.Add(new Vector2(int.Parse(split[0]), int.Parse(split[1])));
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++)
@ -67,12 +64,10 @@ namespace osu.Game.Modes.Osu.Objects
points.Add(v);
}
repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture);
int repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture);
if (repeatCount > 9000)
{
throw new ArgumentOutOfRangeException("wacky man");
}
throw new ArgumentOutOfRangeException(nameof(repeatCount), @"Repeat count is way too high");
if (split.Length > 7)
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);

View File

@ -59,10 +59,9 @@ namespace osu.Game.Modes.Osu.Objects
if (i == ControlPoints.Count - 1 || ControlPoints[i] == ControlPoints[i + 1])
{
List<Vector2> subpath = calculateSubpath(subControlPoints);
for (int j = 0; j < subpath.Count; ++j)
// Only add those vertices that add a new segment to the path.
if (calculatedPath.Count == 0 || calculatedPath.Last() != subpath[j])
calculatedPath.Add(subpath[j]);
foreach (Vector2 t in subpath)
if (calculatedPath.Count == 0 || calculatedPath.Last() != t)
calculatedPath.Add(t);
subControlPoints.Clear();
}
@ -175,7 +174,7 @@ namespace osu.Game.Modes.Osu.Objects
path.Clear();
int i = 0;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) ;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) { }
path.Add(interpolateVertices(i, d0) + Offset);

View File

@ -100,22 +100,23 @@ namespace osu.Game.Modes.Osu
protected bool CalculateStrainValues()
{
// Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment.
List<OsuHitObjectDifficulty>.Enumerator hitObjectsEnumerator = DifficultyHitObjects.GetEnumerator();
if (!hitObjectsEnumerator.MoveNext()) return false;
OsuHitObjectDifficulty currentHitObject = hitObjectsEnumerator.Current;
OsuHitObjectDifficulty nextHitObject;
// First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject.
while (hitObjectsEnumerator.MoveNext())
using (List<OsuHitObjectDifficulty>.Enumerator hitObjectsEnumerator = DifficultyHitObjects.GetEnumerator())
{
nextHitObject = hitObjectsEnumerator.Current;
nextHitObject.CalculateStrains(currentHitObject, TimeRate);
currentHitObject = nextHitObject;
}
return true;
if (!hitObjectsEnumerator.MoveNext()) return false;
OsuHitObjectDifficulty current = hitObjectsEnumerator.Current;
// First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject.
while (hitObjectsEnumerator.MoveNext())
{
var next = hitObjectsEnumerator.Current;
next?.CalculateStrains(current, TimeRate);
current = next;
}
return true;
}
}
/// <summary>
@ -184,7 +185,7 @@ namespace osu.Game.Modes.Osu
}
// Those values are used as array indices. Be careful when changing them!
public enum DifficultyType : int
public enum DifficultyType
{
Speed = 0,
Aim,

View File

@ -3,7 +3,7 @@
namespace osu.Game.Modes.Osu
{
class OsuScore : Score
internal class OsuScore : Score
{
}
}

View File

@ -6,7 +6,7 @@ using osu.Game.Modes.Osu.Objects.Drawables;
namespace osu.Game.Modes.Osu
{
class OsuScoreProcessor : ScoreProcessor
internal class OsuScoreProcessor : ScoreProcessor
{
public OsuScoreProcessor(int hitObjectCount)
: base(hitObjectCount)
@ -35,8 +35,9 @@ namespace osu.Game.Modes.Osu
int score = 0;
int maxScore = 0;
foreach (OsuJudgementInfo j in Judgements)
foreach (var judgementInfo in Judgements)
{
var j = (OsuJudgementInfo)judgementInfo;
score += j.ScoreValue;
maxScore += j.MaxScoreValue;
}

View File

@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.UI
/// </summary>
public class OsuComboCounter : ComboCounter
{
protected uint ScheduledPopOutCurrentId = 0;
protected uint ScheduledPopOutCurrentId;
protected virtual float PopOutSmallScale => 1.1f;
protected virtual bool CanPopOutWhileRolling => false;

View File

@ -17,12 +17,17 @@ namespace osu.Game.Modes.Osu.UI
protected override DrawableHitObject GetVisualRepresentation(OsuHitObject h)
{
if (h is HitCircle)
return new DrawableHitCircle(h as HitCircle);
if (h is Slider)
return new DrawableSlider(h as Slider);
if (h is Spinner)
return new DrawableSpinner(h as Spinner);
var circle = h as HitCircle;
if (circle != null)
return new DrawableHitCircle(circle);
var slider = h as Slider;
if (slider != null)
return new DrawableSlider(slider);
var spinner = h as Spinner;
if (spinner != null)
return new DrawableSpinner(spinner);
return null;
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Modes.Osu.UI
Margin = new MarginPadding { Right = 5 },
};
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter()
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
@ -31,7 +31,7 @@ namespace osu.Game.Modes.Osu.UI
Margin = new MarginPadding { Right = 5 },
};
protected override ComboCounter CreateComboCounter() => new OsuComboCounter()
protected override ComboCounter CreateComboCounter() => new OsuComboCounter
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,

View File

@ -10,7 +10,7 @@ using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
class DrawableTaikoHit : Sprite
internal class DrawableTaikoHit : Sprite
{
private TaikoBaseHit h;

View File

@ -8,7 +8,7 @@ using osu.Game.Beatmaps;
namespace osu.Game.Modes.Taiko.Objects
{
class TaikoConverter : HitObjectConverter<TaikoBaseHit>
internal class TaikoConverter : HitObjectConverter<TaikoBaseHit>
{
public override List<TaikoBaseHit> Convert(Beatmap beatmap)
{

View File

@ -23,7 +23,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[TestFixture]
public class ImportBeatmapTest
{
const string osz_path = @"../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
private const string osz_path = @"../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
[OneTimeSetUp]
public void SetUp()
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.IsTrue(File.Exists(temp));
using (FileStream stream = File.OpenRead(temp))
using (File.OpenRead(temp))
osu.Dependencies.Get<BeatmapDatabase>().Import(temp);
ensureLoaded(osu);
@ -107,7 +107,7 @@ namespace osu.Game.Tests.Beatmaps.IO
private string prepareTempCopy(string path)
{
var temp = Path.GetTempFileName();
return new FileInfo(osz_path).CopyTo(temp, true).FullName;
return new FileInfo(path).CopyTo(temp, true).FullName;
}
private OsuGameBase loadOsu(GameHost host)
@ -130,13 +130,13 @@ namespace osu.Game.Tests.Beatmaps.IO
Action waitAction = () =>
{
while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() == 0)
while (!(resultSets = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Any())
Thread.Sleep(50);
};
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
$@"BeatmapSet did not import to the database in allocated time.");
@"BeatmapSet did not import to the database in allocated time.");
//ensure we were stored to beatmap database backing...
@ -168,7 +168,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var beatmap = osu.Dependencies.Get<BeatmapDatabase>().GetWorkingBeatmap(set.Beatmaps.First(b => b.Mode == PlayMode.Osu))?.Beatmap;
Assert.IsTrue(beatmap.HitObjects.Count > 0);
Assert.IsTrue(beatmap?.HitObjects.Count > 0);
}
}
}

View File

@ -77,7 +77,7 @@ namespace osu.Game.Tests.Beatmaps.IO
using (var stream = new StreamReader(
reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
{
Assert.AreEqual("osu file format v13", stream.ReadLine().Trim());
Assert.AreEqual("osu file format v13", stream.ReadLine()?.Trim());
}
}
}

View File

@ -37,7 +37,7 @@ namespace osu.Game.Beatmaps
protected abstract HitObjectConverter<T> Converter { get; }
public DifficultyCalculator(Beatmap beatmap)
protected DifficultyCalculator(Beatmap beatmap)
{
Objects = Converter.Convert(beatmap);
PreprocessHitObjects();

View File

@ -6,7 +6,7 @@ using osu.Framework.Graphics.Sprites;
namespace osu.Game.Beatmaps.Drawables
{
class BeatmapBackgroundSprite : Sprite
internal class BeatmapBackgroundSprite : Sprite
{
private readonly WorkingBeatmap working;

View File

@ -10,7 +10,7 @@ using osu.Game.Database;
namespace osu.Game.Beatmaps.Drawables
{
class BeatmapGroup : IStateful<BeatmapGroupState>
internal class BeatmapGroup : IStateful<BeatmapGroupState>
{
public BeatmapPanel SelectedPanel;

View File

@ -18,7 +18,7 @@ using osu.Game.Graphics.Sprites;
namespace osu.Game.Beatmaps.Drawables
{
class BeatmapPanel : Panel
internal class BeatmapPanel : Panel
{
public BeatmapInfo Beatmap;
private Sprite background;

View File

@ -17,7 +17,7 @@ using OpenTK.Graphics;
namespace osu.Game.Beatmaps.Drawables
{
class BeatmapSetHeader : Panel
internal class BeatmapSetHeader : Panel
{
public Action<BeatmapSetHeader> GainedSelection;
private SpriteText title, artist;
@ -96,7 +96,7 @@ namespace osu.Game.Beatmaps.Drawables
base.Dispose(isDisposing);
}
class PanelBackground : BufferedContainer
private class PanelBackground : BufferedContainer
{
private readonly WorkingBeatmap working;
@ -160,7 +160,7 @@ namespace osu.Game.Beatmaps.Drawables
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
}.LoadAsync(game, (bg) =>
}.LoadAsync(game, bg =>
{
Add(bg);
ForceRedraw();

View File

@ -12,7 +12,7 @@ using OpenTK.Graphics;
namespace osu.Game.Beatmaps.Drawables
{
class DifficultyIcon : Container
internal class DifficultyIcon : Container
{
private readonly BeatmapInfo beatmap;
private OsuColour palette;
@ -34,6 +34,7 @@ namespace osu.Game.Beatmaps.Drawables
new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = Size.X,
Colour = getColour(beatmap),
Icon = FontAwesome.fa_circle
@ -41,6 +42,7 @@ namespace osu.Game.Beatmaps.Drawables
new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = Size.X,
Colour = Color4.White,
Icon = Ruleset.GetRuleset(beatmap.Mode).Icon
@ -48,7 +50,7 @@ namespace osu.Game.Beatmaps.Drawables
};
}
enum DifficultyRating
private enum DifficultyRating
{
Easy,
Normal,

View File

@ -12,7 +12,7 @@ using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Beatmaps.Drawables
{
class Panel : Container, IStateful<PanelSelectedState>
internal class Panel : Container, IStateful<PanelSelectedState>
{
public const float MAX_HEIGHT = 80;
@ -115,7 +115,7 @@ namespace osu.Game.Beatmaps.Drawables
}
}
enum PanelSelectedState
internal enum PanelSelectedState
{
Hidden,
NotSelected,

View File

@ -17,8 +17,9 @@ namespace osu.Game.Beatmaps.Formats
public static BeatmapDecoder GetDecoder(TextReader stream)
{
var line = stream.ReadLine().Trim();
if (!decoders.ContainsKey(line))
var line = stream.ReadLine()?.Trim();
if (line == null || !decoders.ContainsKey(line))
throw new IOException(@"Unknown file format");
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]);
}

View File

@ -197,7 +197,7 @@ namespace osu.Game.Beatmaps.Formats
if (split.Length > 2)
{
int kiaiFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
//int kiaiFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
cp = new ControlPoint
{
@ -219,15 +219,18 @@ namespace osu.Game.Beatmaps.Formats
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {val}");
byte r, g, b;
if (!byte.TryParse(split[0], out r) || !byte.TryParse(split[1], out g) || !byte.TryParse(split[2], out b))
throw new InvalidOperationException($@"Color must be specified with 8-bit integer components");
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
// Note: the combo index specified in the beatmap is discarded
beatmap.ComboColors.Add(new Color4
if (key.StartsWith(@"Combo"))
{
R = r / 255f,
G = g / 255f,
B = b / 255f,
A = 1f,
});
beatmap.ComboColors.Add(new Color4
{
R = r / 255f,
G = g / 255f,
B = b / 255f,
A = 1f,
});
}
}
protected override void ParseFile(TextReader stream, Beatmap beatmap)
@ -235,10 +238,9 @@ namespace osu.Game.Beatmaps.Formats
HitObjectParser parser = null;
var section = Section.None;
string line;
while (true)
{
line = stream.ReadLine();
var line = stream.ReadLine();
if (line == null)
break;
if (string.IsNullOrEmpty(line))

View File

@ -15,7 +15,8 @@ namespace osu.Game.Beatmaps.Timing
public double BeatLength;
public double VelocityAdjustment;
public bool TimingChange;
public bool KiaiMode;
}
internal enum TimeSignatures

View File

@ -3,7 +3,7 @@
namespace osu.Game.Beatmaps.Timing
{
class TimingChange : ControlPoint
internal class TimingChange : ControlPoint
{
public TimingChange(double beatLength)
{

View File

@ -20,11 +20,12 @@ namespace osu.Game.Database
{
public class BeatmapDatabase
{
private SQLiteConnection connection { get; set; }
private SQLiteConnection connection { get; }
private Storage storage;
public event Action<BeatmapSetInfo> BeatmapSetAdded;
public event Action<BeatmapSetInfo> BeatmapSetRemoved;
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private BeatmapImporter ipc;
public BeatmapDatabase(Storage storage, GameHost importHost = null)
@ -73,7 +74,7 @@ namespace osu.Game.Database
}
catch (Exception e)
{
Logger.Error(e, $@"Could not delete beatmap {b.ToString()}");
Logger.Error(e, $@"Could not delete beatmap {b}");
}
}
@ -149,7 +150,7 @@ namespace osu.Game.Database
catch (Exception e)
{
e = e.InnerException ?? e;
Logger.Error(e, $@"Could not import beatmap set");
Logger.Error(e, @"Could not import beatmap set");
}
// Batch commit with multiple sets to database
@ -318,8 +319,7 @@ namespace osu.Game.Database
return item;
}
readonly Type[] validTypes = new[]
{
private readonly Type[] validTypes = {
typeof(BeatmapSetInfo),
typeof(BeatmapInfo),
typeof(BeatmapMetadata),
@ -329,7 +329,7 @@ namespace osu.Game.Database
public void Update<T>(T record, bool cascade = true) where T : class
{
if (validTypes.All(t => t != typeof(T)))
throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase");
throw new ArgumentException("Must be a type managed by BeatmapDatabase", nameof(T));
if (cascade)
connection.UpdateWithChildren(record);
else

View File

@ -15,9 +15,9 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int? OnlineBeatmapID { get; set; } = null;
public int? OnlineBeatmapID { get; set; }
public int? OnlineBeatmapSetID { get; set; } = null;
public int? OnlineBeatmapSetID { get; set; }
[ForeignKey(typeof(BeatmapSetInfo))]
public int BeatmapSetInfoID { get; set; }
@ -57,7 +57,7 @@ namespace osu.Game.Database
{
get
{
return StoredBookmarks.Split(',').Select(b => int.Parse(b)).ToArray();
return StoredBookmarks.Split(',').Select(int.Parse).ToArray();
}
set
{
@ -77,7 +77,7 @@ namespace osu.Game.Database
{
get
{
return (starDifficulty < 0) ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty;
return starDifficulty < 0 ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty;
}
set { starDifficulty = value; }

View File

@ -10,7 +10,7 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int? OnlineBeatmapSetID { get; set; } = null;
public int? OnlineBeatmapSetID { get; set; }
public string Title { get; set; }
public string TitleUnicode { get; set; }

View File

@ -12,7 +12,7 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int? OnlineBeatmapSetID { get; set; } = null;
public int? OnlineBeatmapSetID { get; set; }
[OneToOne(CascadeOperations = CascadeOperation.All)]
public BeatmapMetadata Metadata { get; set; }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Graphics.Backgrounds
{
public Sprite Sprite;
string textureName;
private string textureName;
public Background(string textureName = @"")
{

View File

@ -117,7 +117,7 @@ namespace osu.Game.Graphics.Backgrounds
private void addTriangle(bool randomY)
{
var sprite = CreateTriangle();
float triangleHeight = (sprite.DrawHeight / DrawHeight);
float triangleHeight = sprite.DrawHeight / DrawHeight;
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1);
Add(sprite);
}

View File

@ -12,7 +12,7 @@ using osu.Framework.Configuration;
namespace osu.Game.Graphics.Containers
{
class ParallaxContainer : Container
internal class ParallaxContainer : Container
{
public float ParallaxAmount = 0.02f;
@ -51,7 +51,7 @@ namespace osu.Game.Graphics.Containers
};
}
bool firstUpdate = true;
private bool firstUpdate = true;
protected override void Update()
{

View File

@ -16,8 +16,7 @@ using osu.Framework.Graphics.Colour;
namespace osu.Game.Graphics.Cursor
{
class CursorTrail : Drawable
internal class CursorTrail : Drawable
{
public override bool Contains(Vector2 screenSpacePos) => true;
public override bool HandleInput => true;
@ -46,7 +45,7 @@ namespace osu.Game.Graphics.Cursor
{
base.ApplyDrawNode(node);
TrailDrawNode tNode = node as TrailDrawNode;
TrailDrawNode tNode = (TrailDrawNode)node;
tNode.Shader = shader;
tNode.Texture = texture;
tNode.Size = size;
@ -117,7 +116,7 @@ namespace osu.Game.Graphics.Cursor
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = (size.X / 2) * 0.9f;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{
@ -137,7 +136,7 @@ namespace osu.Game.Graphics.Cursor
currentIndex = (currentIndex + 1) % max_sprites;
}
struct TrailPart
private struct TrailPart
{
public Vector2 Position;
public float Time;
@ -145,12 +144,12 @@ namespace osu.Game.Graphics.Cursor
public bool WasUpdated;
}
class TrailDrawNodeSharedData
private class TrailDrawNodeSharedData
{
public VertexBuffer<TexturedVertex2D> VertexBuffer;
}
class TrailDrawNode : DrawNode
private class TrailDrawNode : DrawNode
{
public Shader Shader;
public Texture Texture;

View File

@ -17,7 +17,7 @@ using System;
namespace osu.Game.Graphics.Cursor
{
class OsuCursorContainer : CursorContainer
internal class OsuCursorContainer : CursorContainer
{
protected override Drawable CreateCursor() => new OsuCursor();
@ -40,7 +40,7 @@ namespace osu.Game.Graphics.Cursor
return base.OnMouseUp(state, args);
}
class OsuCursor : Container
private class OsuCursor : Container
{
private Container cursorContainer;
private Bindable<double> cursorScale;

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics;
namespace osu.Game.Graphics.Processing
{
class RatioAdjust : Container
internal class RatioAdjust : Container
{
public override bool Contains(Vector2 screenSpacePos) => true;

View File

@ -26,11 +26,6 @@ namespace osu.Game.Graphics
Text = ((char)icon).ToString();
}
}
public TextAwesome()
{
Origin = Framework.Graphics.Anchor.Centre;
}
}
public enum FontAwesome

View File

@ -100,7 +100,7 @@ namespace osu.Game.Graphics.UserInterface
Delay(click_duration);
Schedule(delegate {
colourContainer.ResizeTo(new Vector2(0.8f, 1f), 0, EasingTypes.None);
colourContainer.ResizeTo(new Vector2(0.8f, 1f));
spriteText.Spacing = Vector2.Zero;
glowContainer.FadeOut();
});

View File

@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface
private Box fill;
const float border_width = 3;
private const float border_width = 3;
private Color4 glowingColour, idleColour;
public Nub()

View File

@ -36,10 +36,7 @@ namespace osu.Game.Graphics.UserInterface
protected override void UpdateContentHeight()
{
if (State == DropDownMenuState.Opened)
ContentContainer.ResizeTo(new Vector2(1, ContentHeight), 300, EasingTypes.OutQuint);
else
ContentContainer.ResizeTo(new Vector2(1, 0), 300, EasingTypes.OutQuint);
ContentContainer.ResizeTo(State == DropDownMenuState.Opened ? new Vector2(1, ContentHeight) : new Vector2(1, 0), 300, EasingTypes.OutQuint);
}
}
}

View File

@ -49,7 +49,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Apply(Drawable d)
{
base.Apply(d);
(d as PercentageCounter).DisplayedCount = CurrentValue;
((PercentageCounter)d).DisplayedCount = CurrentValue;
}
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
/// Type of the Transform to use.
/// </summary>
/// <remarks>
/// Must be a subclass of Transform<T>
/// Must be a subclass of Transform(T)
/// </remarks>
protected virtual Type TransformType => typeof(Transform<T>);
@ -107,7 +107,7 @@ namespace osu.Game.Graphics.UserInterface
{
Children = new Drawable[]
{
DisplayedCountSpriteText = new OsuSpriteText()
DisplayedCountSpriteText = new OsuSpriteText
{
Font = @"Venera"
},

View File

@ -66,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
public override void Apply(Drawable d)
{
base.Apply(d);
(d as ScoreCounter).DisplayedCount = CurrentValue;
((ScoreCounter)d).DisplayedCount = CurrentValue;
}
}
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface
private float minStarAlpha => 0.5f;
private const float star_size = 20;
private float star_spacing = 4;
private const float star_spacing = 4;
private float count;
@ -145,7 +145,7 @@ namespace osu.Game.Graphics.UserInterface
}
}
class Star : Container
private class Star : Container
{
public TextAwesome Icon;
public Star()

View File

@ -98,6 +98,7 @@ namespace osu.Game.Graphics.UserInterface
icon = new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 25,
},
}

View File

@ -87,7 +87,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
}
ScheduledDelegate popOutDelegate;
private ScheduledDelegate popOutDelegate;
private VolumeMeter volumeMeterEffect;
private VolumeMeter volumeMeterMusic;

View File

@ -8,7 +8,7 @@ using OpenTK.Input;
namespace osu.Game.Graphics.UserInterface.Volume
{
class VolumeControlReceptor : Container
internal class VolumeControlReceptor : Container
{
public Action<InputState> ActionRequested;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
internal class VolumeMeter : Container
{
private Box meterFill;
public BindableDouble Bindable { get; private set; } = new BindableDouble();
public BindableDouble Bindable { get; } = new BindableDouble();
public VolumeMeter(string meterName)
{

View File

@ -1,19 +1,21 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Database;
namespace osu.Game.IPC
{
public class BeatmapImporter
public class BeatmapImporter : IDisposable
{
private IpcChannel<BeatmapImportMessage> channel;
private BeatmapDatabase beatmaps;
public BeatmapImporter(GameHost host, BeatmapDatabase beatmaps = null)
public BeatmapImporter(GameHost host, BeatmapDatabase beatmaps = null)
{
this.beatmaps = beatmaps;
@ -35,7 +37,12 @@ namespace osu.Game.IPC
{
Debug.Assert(beatmaps != null);
ImportAsync(msg.Path);
ImportAsync(msg.Path).ContinueWith(t => Logger.Error(t.Exception, @"error during async import"), TaskContinuationOptions.OnlyOnFaulted);
}
public void Dispose()
{
throw new NotImplementedException();
}
}

View File

@ -24,11 +24,11 @@ namespace osu.Game.Modes.Objects.Drawables
public JudgementInfo Judgement;
public abstract JudgementInfo CreateJudgementInfo();
protected abstract JudgementInfo CreateJudgementInfo();
public HitObject HitObject;
public DrawableHitObject(HitObject hitObject)
protected DrawableHitObject(HitObject hitObject)
{
HitObject = hitObject;
}
@ -52,12 +52,15 @@ namespace osu.Game.Modes.Objects.Drawables
}
}
SampleChannel sample;
private SampleChannel sample;
[BackgroundDependencyLoader]
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;
if (type == SampleType.None)
type = SampleType.Normal;
string hitType = type.ToString().ToLower();
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower();
sample = audio.Sample.Get($@"Gameplay/{sampleSet}-hit{hitType}");
@ -98,7 +101,6 @@ namespace osu.Game.Modes.Objects.Drawables
/// <summary>
/// Process a hit of this hitobject. Carries out judgement.
/// </summary>
/// <param name="judgement">Preliminary judgement information provided by the hit source.</param>
/// <returns>Whether a hit was processed.</returns>
protected bool UpdateJudgement(bool userTriggered)
{

View File

@ -10,7 +10,7 @@ namespace osu.Game.Modes
{
public abstract class ScoreProcessor
{
public virtual Score GetScore() => new Score()
public virtual Score GetScore() => new Score
{
TotalScore = TotalScore,
Combo = Combo,
@ -51,7 +51,7 @@ namespace osu.Game.Modes
/// Initializes a new instance of the <see cref="ScoreProcessor"/> class.
/// </summary>
/// <param name="hitObjectCount">Number of HitObjects. It is used for specifying Judgements collection Capacity</param>
public ScoreProcessor(int hitObjectCount = 0)
protected ScoreProcessor(int hitObjectCount = 0)
{
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
Judgements = new List<JudgementInfo>(hitObjectCount);

View File

@ -260,7 +260,7 @@ namespace osu.Game.Modes.UI
public override void Apply(Drawable d)
{
base.Apply(d);
(d as ComboCounter).DisplayedCount = CurrentValue;
((ComboCounter)d).DisplayedCount = CurrentValue;
}
}

View File

@ -51,7 +51,7 @@ namespace osu.Game.Modes.UI
public override void Apply(Drawable d)
{
base.Apply(d);
(d as ComboResultCounter).DisplayedCount = CurrentValue;
((ComboResultCounter)d).DisplayedCount = CurrentValue;
}
}
}

View File

@ -17,10 +17,9 @@ namespace osu.Game.Modes.UI
{
public class HealthDisplay : Container
{
private Box background;
private Container fill;
public BindableDouble Current = new BindableDouble()
public BindableDouble Current = new BindableDouble
{
MinValue = 0,
MaxValue = 1
@ -30,7 +29,7 @@ namespace osu.Game.Modes.UI
{
Children = new Drawable[]
{
background = new Box
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,

View File

@ -54,7 +54,7 @@ namespace osu.Game.Modes.UI
protected virtual List<T> Convert(Beatmap beatmap) => Converter.Convert(beatmap);
public HitRenderer()
protected HitRenderer()
{
RelativeSizeAxes = Axes.Both;
}

View File

@ -27,7 +27,7 @@ namespace osu.Game.Modes.UI
}
private Color4 backgroundColour;
new public Color4 Colour
public new Color4 Colour
{
get
{

View File

@ -11,17 +11,16 @@ namespace osu.Game.Modes.UI
public abstract class Playfield : Container
{
public HitObjectContainer HitObjects;
private Container<Drawable> content;
public virtual void Add(DrawableHitObject h) => HitObjects.Add(h);
public override bool Contains(Vector2 screenSpacePos) => true;
protected override Container<Drawable> Content => content;
protected override Container<Drawable> Content { get; }
public Playfield()
protected Playfield()
{
AddInternal(content = new ScaledContainer()
AddInternal(Content = new ScaledContainer
{
RelativeSizeAxes = Axes.Both,
});

View File

@ -50,7 +50,7 @@ namespace osu.Game.Modes.UI
AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f);
}
public ScoreOverlay()
protected ScoreOverlay()
{
RelativeSizeAxes = Axes.Both;

View File

@ -20,10 +20,10 @@ namespace osu.Game.Online.API
private OAuth authentication;
public string Endpoint = @"https://new.ppy.sh";
const string client_id = @"5";
const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
private const string client_id = @"5";
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
private ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
public Scheduler Scheduler = new Scheduler();
@ -38,22 +38,15 @@ namespace osu.Game.Online.API
public string Token
{
get { return authentication.Token?.ToString(); }
set
{
if (string.IsNullOrEmpty(value))
authentication.Token = null;
else
authentication.Token = OAuthToken.Parse(value);
}
set { authentication.Token = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value); }
}
protected bool HasLogin => Token != null || (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password));
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (should dispose of this or at very least keep a reference).
private Thread thread;
Logger log;
private Logger log;
public APIAccess()
{
@ -88,22 +81,22 @@ namespace osu.Game.Online.API
/// <summary>
/// Number of consecutive requests which failed due to network issues.
/// </summary>
int failureCount = 0;
private int failureCount;
private void run()
{
while (true)
while (thread.IsAlive)
{
switch (State)
{
case APIState.Failing:
//todo: replace this with a ping request.
log.Add($@"In a failing state, waiting a bit before we try again...");
log.Add(@"In a failing state, waiting a bit before we try again...");
Thread.Sleep(5000);
if (queue.Count == 0)
{
log.Add($@"Queueing a ping request");
Queue(new ListChannelsRequest() { Timeout = 5000 });
log.Add(@"Queueing a ping request");
Queue(new ListChannelsRequest { Timeout = 5000 });
}
break;
case APIState.Offline:
@ -131,7 +124,7 @@ namespace osu.Game.Online.API
var userReq = new GetUserRequest();
userReq.Success += (u) => {
userReq.Success += u => {
LocalUser.Value = u;
//we're connected!
State = APIState.Online;
@ -291,7 +284,7 @@ namespace osu.Game.Online.API
if (failOldRequests)
{
APIRequest req;
while (queue.TryDequeue(out req))
while (oldQueue.TryDequeue(out req))
req.Fail(new Exception(@"Disconnected from server"));
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Online.API
private void onSuccess()
{
Success?.Invoke((WebRequest as JsonWebRequest<T>).ResponseObject);
Success?.Invoke(((JsonWebRequest<T>)WebRequest).ResponseObject);
}
public new event APISuccessHandler<T> Success;

View File

@ -48,7 +48,7 @@ namespace osu.Game.Online.API
try
{
string[] parts = value.Split('/');
return new OAuthToken()
return new OAuthToken
{
AccessToken = parts[0],
AccessTokenExpiry = long.Parse(parts[1], NumberFormatInfo.InvariantInfo),

Some files were not shown because too many files have changed in this diff Show More