1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Merge remote-tracking branch 'refs/remotes/ppy/master' into break_overlay_take_three

This commit is contained in:
EVAST9919 2017-09-28 14:44:31 +03:00
commit e7632b6e6f
16 changed files with 97 additions and 99 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Beatmaps.IO
public void TestImportWhenClosed() public void TestImportWhenClosed()
{ {
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. //unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
using (HeadlessGameHost host = new HeadlessGameHost()) using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenClosed"))
{ {
var osu = loadOsu(host); var osu = loadOsu(host);
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Beatmaps.IO
ensureLoaded(osu); ensureLoaded(osu);
Assert.IsFalse(File.Exists(temp)); waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
} }
} }
@ -61,15 +61,14 @@ namespace osu.Game.Tests.Beatmaps.IO
ensureLoaded(osu); ensureLoaded(osu);
Assert.IsFalse(File.Exists(temp)); waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000);
} }
} }
[Test] [Test]
public void TestImportWhenFileOpen() public void TestImportWhenFileOpen()
{ {
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenFileOpen"))
using (HeadlessGameHost host = new HeadlessGameHost())
{ {
var osu = loadOsu(host); var osu = loadOsu(host);
@ -101,8 +100,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var osu = new OsuGameBase(); var osu = new OsuGameBase();
Task.Run(() => host.Run(osu)); Task.Run(() => host.Run(osu));
while (!osu.IsLoaded) waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
Thread.Sleep(1);
return osu; return osu;
} }
@ -113,30 +111,17 @@ namespace osu.Game.Tests.Beatmaps.IO
var store = osu.Dependencies.Get<BeatmapManager>(); var store = osu.Dependencies.Get<BeatmapManager>();
Action waitAction = () => waitForOrAssert(() => (resultSets = store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526)).Any(),
{ @"BeatmapSet did not import to the database in allocated time.", timeout);
while (!(resultSets = store.QueryBeatmapSets(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.");
//ensure we were stored to beatmap database backing... //ensure we were stored to beatmap database backing...
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1)."); Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
IEnumerable<BeatmapInfo> resultBeatmaps = null; IEnumerable<BeatmapInfo> resultBeatmaps = null;
//if we don't re-check here, the set will be inserted but the beatmaps won't be present yet. //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
waitAction = () => waitForOrAssert(() => (resultBeatmaps = store.QueryBeatmaps(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() == 12,
{ @"Beatmaps did not import to the database in allocated time", timeout);
while ((resultBeatmaps = store.QueryBeatmaps(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
Thread.Sleep(50);
};
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout),
@"Beatmaps did not import to the database in allocated time");
var set = store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526).First(); var set = store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526).First();
@ -160,5 +145,11 @@ namespace osu.Game.Tests.Beatmaps.IO
beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap; beatmap = store.GetWorkingBeatmap(set.Beatmaps.First(b => b.RulesetID == 3))?.Beatmap;
Assert.IsTrue(beatmap?.HitObjects.Count > 0); Assert.IsTrue(beatmap?.HitObjects.Count > 0);
} }
private void waitForOrAssert(Func<bool> result, string failureMessage, int timeout = 60000)
{
Action waitAction = () => { while (!result()) Thread.Sleep(20); };
Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), failureMessage);
}
} }
} }

View File

@ -101,18 +101,16 @@ namespace osu.Game.Online.API
} }
break; break;
case APIState.Offline: case APIState.Offline:
case APIState.Connecting:
//work to restore a connection... //work to restore a connection...
if (!HasLogin) if (!HasLogin)
{ {
//OsuGame.Scheduler.Add(() => { OsuGame.ShowLogin(); });
State = APIState.Offline; State = APIState.Offline;
Thread.Sleep(500); Thread.Sleep(50);
continue; continue;
} }
if (State < APIState.Connecting) State = APIState.Connecting;
State = APIState.Connecting;
if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(Username, Password)) if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(Username, Password))
{ {
@ -125,7 +123,8 @@ namespace osu.Game.Online.API
var userReq = new GetUserRequest(); var userReq = new GetUserRequest();
userReq.Success += u => { userReq.Success += u =>
{
LocalUser.Value = u; LocalUser.Value = u;
//we're connected! //we're connected!
State = APIState.Online; State = APIState.Online;
@ -133,16 +132,14 @@ namespace osu.Game.Online.API
}; };
if (!handleRequest(userReq)) if (!handleRequest(userReq))
{
State = APIState.Failing;
continue; continue;
}
break; break;
} }
//hard bail if we can't get a valid access token. //hard bail if we can't get a valid access token.
if (authentication.RequestAccessToken() == null) if (authentication.RequestAccessToken() == null)
{ {
Logout(false);
State = APIState.Offline; State = APIState.Offline;
continue; continue;
} }
@ -162,20 +159,12 @@ namespace osu.Game.Online.API
} }
} }
private void clearCredentials()
{
Username = null;
Password = null;
}
public void Login(string username, string password) public void Login(string username, string password)
{ {
Debug.Assert(State == APIState.Offline); Debug.Assert(State == APIState.Offline);
Username = username; Username = username;
Password = password; Password = password;
State = APIState.Connecting;
} }
/// <summary> /// <summary>
@ -204,7 +193,7 @@ namespace osu.Game.Online.API
switch (statusCode) switch (statusCode)
{ {
case HttpStatusCode.Unauthorized: case HttpStatusCode.Unauthorized:
State = APIState.Offline; Logout(false);
return true; return true;
case HttpStatusCode.RequestTimeout: case HttpStatusCode.RequestTimeout:
failureCount++; failureCount++;
@ -215,6 +204,7 @@ namespace osu.Game.Online.API
return false; return false;
State = APIState.Failing; State = APIState.Failing;
flushQueue();
return true; return true;
} }
@ -235,33 +225,21 @@ namespace osu.Game.Online.API
public APIState State public APIState State
{ {
get { return state; } get { return state; }
set private set
{ {
APIState oldState = state; APIState oldState = state;
APIState newState = value; APIState newState = value;
state = value; state = value;
switch (state)
{
case APIState.Failing:
case APIState.Offline:
flushQueue();
break;
}
if (oldState != newState) if (oldState != newState)
{ {
//OsuGame.Scheduler.Add(delegate log.Add($@"We just went {newState}!");
Scheduler.Add(delegate
{ {
//NotificationOverlay.ShowMessage($@"We just went {newState}!", newState == APIState.Online ? Color4.YellowGreen : Color4.OrangeRed, 5000); components.ForEach(c => c.APIStateChanged(this, newState));
log.Add($@"We just went {newState}!"); OnStateChange?.Invoke(oldState, newState);
Scheduler.Add(delegate });
{
components.ForEach(c => c.APIStateChanged(this, newState));
OnStateChange?.Invoke(oldState, newState);
});
}
} }
} }
} }
@ -292,11 +270,12 @@ namespace osu.Game.Online.API
} }
} }
public void Logout() public void Logout(bool clearUsername = true)
{ {
clearCredentials(); flushQueue();
if (clearUsername) Username = null;
Password = null;
authentication.Clear(); authentication.Clear();
State = APIState.Offline;
LocalUser.Value = createGuestUser(); LocalUser.Value = createGuestUser();
} }

View File

@ -80,7 +80,7 @@ namespace osu.Game.Online.API.Requests
} }
[JsonProperty(@"statistics")] [JsonProperty(@"statistics")]
private Dictionary<string, dynamic> jsonStats private Dictionary<string, object> jsonStats
{ {
set set
{ {

View File

@ -23,6 +23,9 @@ namespace osu.Game.Overlays
private readonly Header header; private readonly Header header;
private readonly Info info; private readonly Info info;
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
public BeatmapSetOverlay() public BeatmapSetOverlay()
{ {
FirstWaveColour = OsuColour.Gray(0.4f); FirstWaveColour = OsuColour.Gray(0.4f);

View File

@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Direct
public Header() public Header()
{ {
Tabs.Current.Value = DirectTab.Search; Tabs.Current.Value = DirectTab.NewestMaps;
Tabs.Current.TriggerChange(); Tabs.Current.TriggerChange();
} }
} }

View File

@ -251,7 +251,7 @@ namespace osu.Game.Overlays
if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return; if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return;
getSetsRequest = new GetBeatmapSetsRequest(currentQuery, getSetsRequest = new GetBeatmapSetsRequest(currentQuery.Value ?? string.Empty,
((FilterControl)Filter).Ruleset.Value, ((FilterControl)Filter).Ruleset.Value,
Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.DisplayStyleControl.Dropdown.Current.Value,
Filter.Tabs.Current.Value); //todo: sort direction (?) Filter.Tabs.Current.Value); //todo: sort direction (?)

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Overlays.Settings.Sections.General; using osu.Game.Overlays.Settings.Sections.General;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -28,35 +29,43 @@ namespace osu.Game.Overlays
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
new OsuContextMenuContainer new OsuContextMenuContainer
{ {
Width = 360, Width = 360,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Masking = true,
AutoSizeDuration = transition_time,
AutoSizeEasing = Easing.OutQuint,
Children = new Drawable[] Children = new Drawable[]
{ {
settingsSection = new LoginSettings
{
Padding = new MarginPadding(10),
RequestHide = Hide,
},
new Box new Box
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft, Colour = Color4.Black,
Origin = Anchor.BottomLeft, Alpha = 0.6f,
Height = 3,
Colour = colours.Yellow,
Alpha = 1,
}, },
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Masking = true,
AutoSizeDuration = transition_time,
AutoSizeEasing = Easing.OutQuint,
Children = new Drawable[]
{
settingsSection = new LoginSettings
{
Padding = new MarginPadding(10),
RequestHide = Hide,
},
new Box
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Height = 3,
Colour = colours.Yellow,
Alpha = 1,
},
}
}
} }
} }
}; };

View File

@ -34,6 +34,7 @@ namespace osu.Game.Overlays
public const float CONTENT_X_MARGIN = 50; public const float CONTENT_X_MARGIN = 50;
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)

View File

@ -38,6 +38,6 @@ namespace osu.Game.Rulesets.Scoring
public DateTimeOffset Date; public DateTimeOffset Date;
public Dictionary<string, dynamic> Statistics = new Dictionary<string, dynamic>(); public Dictionary<string, object> Statistics = new Dictionary<string, object>();
} }
} }

View File

@ -15,6 +15,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks) foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks)
Add(new BookmarkVisualisation(bookmark)); Add(new BookmarkVisualisation(bookmark));
} }

View File

@ -16,6 +16,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
foreach (var breakPeriod in beatmap.Beatmap.Breaks) foreach (var breakPeriod in beatmap.Beatmap.Breaks)
Add(new BreakVisualisation(breakPeriod)); Add(new BreakVisualisation(breakPeriod));
} }

View File

@ -18,6 +18,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo; ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo;
cpi.TimingPoints.ForEach(addTimingPoint); cpi.TimingPoints.ForEach(addTimingPoint);

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
@ -23,12 +24,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Add(marker = new MarkerVisualisation()); Add(marker = new MarkerVisualisation());
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
marker.Colour = colours.Red;
}
protected override bool OnDragStart(InputState state) => true; protected override bool OnDragStart(InputState state) => true;
protected override bool OnDragEnd(InputState state) => true; protected override bool OnDragEnd(InputState state) => true;
protected override bool OnDrag(InputState state) protected override bool OnDrag(InputState state)
@ -61,10 +56,14 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
marker.X = (float)(Beatmap.Value?.Track.CurrentTime ?? 0); marker.X = (float)(Beatmap.Value?.Track.CurrentTime ?? 0);
} }
protected override void LoadBeatmap(WorkingBeatmap beatmap)
{
// block base call so we don't clear our marker (can be reused on beatmap change).
}
private class MarkerVisualisation : CompositeDrawable private class MarkerVisualisation : CompositeDrawable
{ {
public MarkerVisualisation() public MarkerVisualisation()

View File

@ -25,16 +25,29 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
timeline.Clear(); updateRelativeChildSize();
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, b.Track.Length), 1);
LoadBeatmap(b); LoadBeatmap(b);
}; };
} }
private void updateRelativeChildSize()
{
// the track may not be loaded completely (only has a length once it is).
if (!Beatmap.Value.Track.IsLoaded)
{
timeline.RelativeChildSize = Vector2.One;
Schedule(updateRelativeChildSize);
return;
}
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
}
protected void Add(Drawable visualisation) => timeline.Add(visualisation); protected void Add(Drawable visualisation) => timeline.Add(visualisation);
protected virtual void LoadBeatmap(WorkingBeatmap beatmap) protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
{ {
timeline.Clear();
} }
} }
} }

View File

@ -186,9 +186,9 @@ namespace osu.Game.Screens.Ranking
private class DrawableScoreStatistic : Container private class DrawableScoreStatistic : Container
{ {
private readonly KeyValuePair<string, dynamic> statistic; private readonly KeyValuePair<string, object> statistic;
public DrawableScoreStatistic(KeyValuePair<string, dynamic> statistic) public DrawableScoreStatistic(KeyValuePair<string, object> statistic)
{ {
this.statistic = statistic; this.statistic = statistic;

View File

@ -124,7 +124,6 @@
<HintPath>$(SolutionDir)\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath> <HintPath>$(SolutionDir)\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> <Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath> <HintPath>$(SolutionDir)\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath>
<Private>True</Private> <Private>True</Private>