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

Merge branch 'master' into chat-commands

This commit is contained in:
Dean Herbert 2017-09-25 15:52:35 +08:00 committed by GitHub
commit a80f0d4858
13 changed files with 69 additions and 19 deletions

@ -1 +1 @@
Subproject commit e1352a8b0b5d1ba8acd9335a56c714d2ccc2f6a6 Subproject commit 5f3a7fe4d0537820a33b817a41623b4b22a3ec59

View File

@ -54,6 +54,8 @@ namespace osu.Game.Configuration
// Graphics // Graphics
Set(OsuSetting.ShowFpsDisplay, false); Set(OsuSetting.ShowFpsDisplay, false);
Set(OsuSetting.CursorRotation, true);
Set(OsuSetting.MenuParallax, true); Set(OsuSetting.MenuParallax, true);
Set(OsuSetting.SnakingInSliders, true); Set(OsuSetting.SnakingInSliders, true);
@ -96,6 +98,7 @@ namespace osu.Game.Configuration
AudioOffset, AudioOffset,
MenuMusic, MenuMusic,
MenuVoice, MenuVoice,
CursorRotation,
MenuParallax, MenuParallax,
BeatmapDetailTab, BeatmapDetailTab,
Username, Username,

View File

@ -20,13 +20,14 @@ namespace osu.Game.Graphics.Cursor
{ {
protected override Drawable CreateCursor() => new Cursor(); protected override Drawable CreateCursor() => new Cursor();
private Bindable<bool> cursorRotate;
private bool dragging; private bool dragging;
private bool startRotation; private bool startRotation;
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(InputState state)
{ {
if (dragging) if (cursorRotate && dragging)
{ {
Debug.Assert(state.Mouse.PositionMouseDown != null); Debug.Assert(state.Mouse.PositionMouseDown != null);
@ -102,6 +103,12 @@ namespace osu.Game.Graphics.Cursor
ActiveCursor.ScaleTo(0, 500, Easing.In); ActiveCursor.ScaleTo(0, 500, Easing.In);
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
cursorRotate = config.GetBindable<bool>(OsuSetting.CursorRotation);
}
public class Cursor : Container public class Cursor : Container
{ {
private Container cursorContainer; private Container cursorContainer;

View File

@ -49,7 +49,7 @@ namespace osu.Game.IO.Legacy
int len = ReadInt32(); int len = ReadInt32();
if (len > 0) return ReadBytes(len); if (len > 0) return ReadBytes(len);
if (len < 0) return null; if (len < 0) return null;
return new byte[0]; return Array.Empty<byte>();
} }
/// <summary> Reads a char array from the buffer, handling nulls and the array length. </summary> /// <summary> Reads a char array from the buffer, handling nulls and the array length. </summary>
@ -58,7 +58,7 @@ namespace osu.Game.IO.Legacy
int len = ReadInt32(); int len = ReadInt32();
if (len > 0) return ReadChars(len); if (len > 0) return ReadChars(len);
if (len < 0) return null; if (len < 0) return null;
return new char[0]; return Array.Empty<char>();
} }
/// <summary> Reads a DateTime from the buffer. </summary> /// <summary> Reads a DateTime from the buffer. </summary>

View File

@ -2,7 +2,6 @@
// 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; using System;
using osu.Framework.Extensions;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
namespace osu.Game.Online.API namespace osu.Game.Online.API
@ -70,13 +69,11 @@ namespace osu.Game.Online.API
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}"; protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
private double remainingTime => Math.Max(0, Timeout - (DateTime.Now.TotalMilliseconds() - (startTime ?? 0))); private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow - (startTime ?? DateTimeOffset.MinValue)).TotalMilliseconds);
public bool ExceededTimeout => remainingTime == 0; public bool ExceededTimeout => remainingTime == 0;
private double? startTime; private DateTimeOffset? startTime;
public double StartTime => startTime ?? -1;
protected APIAccess API; protected APIAccess API;
protected WebRequest WebRequest; protected WebRequest WebRequest;
@ -96,7 +93,7 @@ namespace osu.Game.Online.API
return; return;
if (startTime == null) if (startTime == null)
startTime = DateTime.Now.TotalMilliseconds(); startTime = DateTimeOffset.UtcNow;
if (remainingTime <= 0) if (remainingTime <= 0)
throw new TimeoutException(@"API request timeout hit"); throw new TimeoutException(@"API request timeout hit");

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Globalization; using System.Globalization;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Extensions;
namespace osu.Game.Online.API namespace osu.Game.Online.API
{ {
@ -22,12 +21,12 @@ namespace osu.Game.Online.API
{ {
get get
{ {
return AccessTokenExpiry - DateTime.Now.ToUnixTimestamp(); return AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds();
} }
set set
{ {
AccessTokenExpiry = DateTime.Now.AddSeconds(value).ToUnixTimestamp(); AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds();
} }
} }

View File

@ -10,7 +10,7 @@ namespace osu.Game.Online.API.Requests
{ {
private readonly BeatmapInfo beatmap; private readonly BeatmapInfo beatmap;
private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.Hash}&filename={beatmap.Path}"; private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}";
public GetBeatmapDetailsRequest(BeatmapInfo beatmap) public GetBeatmapDetailsRequest(BeatmapInfo beatmap)
{ {

View File

@ -127,7 +127,7 @@ namespace osu.Game.Overlays.Mods
if (mod == null) if (mod == null)
{ {
Mods = new Mod[0]; Mods = Array.Empty<Mod>();
Alpha = 0; Alpha = 0;
} }
else else

View File

@ -1,10 +1,25 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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 osu.Framework.Allocation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Graphics namespace osu.Game.Overlays.Settings.Sections.Graphics
{ {
public class DetailSettings : SettingsSubsection public class DetailSettings : SettingsSubsection
{ {
protected override string Header => "Detail Settings"; protected override string Header => "Detail Settings";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
Children = new[]
{
new SettingsCheckbox
{
LabelText = "Rotate cursor when dragging",
Bindable = config.GetBindable<bool>(OsuSetting.CursorRotation)
},
};
}
} }
} }

View File

@ -121,13 +121,14 @@ namespace osu.Game.Screens.Menu
}; };
} }
private bool rightward;
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
{ {
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
if (!IsHovered) return; if (!IsHovered) return;
bool rightward = beatIndex % 2 == 1;
double duration = timingPoint.BeatLength / 2; double duration = timingPoint.BeatLength / 2;
icon.RotateTo(rightward ? 10 : -10, duration * 2, Easing.InOutSine); icon.RotateTo(rightward ? 10 : -10, duration * 2, Easing.InOutSine);
@ -139,6 +140,8 @@ namespace osu.Game.Screens.Menu
i => i.MoveToY(0, duration, Easing.In), i => i.MoveToY(0, duration, Easing.In),
i => i.ScaleTo(new Vector2(1, 0.9f), duration, Easing.In) i => i.ScaleTo(new Vector2(1, 0.9f), duration, Easing.In)
); );
rightward = !rightward;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
@ -152,7 +155,7 @@ namespace osu.Game.Screens.Menu
double duration = TimeUntilNextBeat; double duration = TimeUntilNextBeat;
icon.ClearTransforms(); icon.ClearTransforms();
icon.RotateTo(10, duration, Easing.InOutSine); icon.RotateTo(rightward ? -10 : 10, duration, Easing.InOutSine);
icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out); icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out);
return true; return true;
} }

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; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -58,6 +59,31 @@ namespace osu.Game.Screens.Select
Action = action, Action = action,
}); });
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
/// <param name="text">Text on the button.</param>
/// <param name="colour">Colour of the button.</param>
/// <param name="hotkey">Hotkey of the button.</param>
/// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param>
/// <param name="depth">
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
/// </param>
public void AddButton(string text, Color4 colour, OverlayContainer overlay, Key? hotkey = null, float depth = 0)
{
overlays.Add(overlay);
AddButton(text, colour, () =>
{
foreach (var o in overlays)
{
if (o == overlay)
o.ToggleVisibility();
else
o.Hide();
}
}, hotkey, depth);
}
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint); private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint);
public Footer() public Footer()

View File

@ -45,7 +45,7 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);

View File

@ -164,7 +164,7 @@ namespace osu.Game.Screens.Select
if (Footer != null) if (Footer != null)
{ {
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
} }