1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +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()
{
//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);
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Beatmaps.IO
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);
Assert.IsFalse(File.Exists(temp));
waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000);
}
}
[Test]
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())
using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenFileOpen"))
{
var osu = loadOsu(host);
@ -101,8 +100,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var osu = new OsuGameBase();
Task.Run(() => host.Run(osu));
while (!osu.IsLoaded)
Thread.Sleep(1);
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
return osu;
}
@ -113,30 +111,17 @@ namespace osu.Game.Tests.Beatmaps.IO
var store = osu.Dependencies.Get<BeatmapManager>();
Action waitAction = () =>
{
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.");
waitForOrAssert(() => (resultSets = store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526)).Any(),
@"BeatmapSet did not import to the database in allocated time.", timeout);
//ensure we were stored to beatmap database backing...
Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1).");
IEnumerable<BeatmapInfo> resultBeatmaps = null;
//if we don't re-check here, the set will be inserted but the beatmaps won't be present yet.
waitAction = () =>
{
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");
waitForOrAssert(() => (resultBeatmaps = store.QueryBeatmaps(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() == 12,
@"Beatmaps did not import to the database in allocated time", timeout);
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;
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;
case APIState.Offline:
case APIState.Connecting:
//work to restore a connection...
if (!HasLogin)
{
//OsuGame.Scheduler.Add(() => { OsuGame.ShowLogin(); });
State = APIState.Offline;
Thread.Sleep(500);
Thread.Sleep(50);
continue;
}
if (State < APIState.Connecting)
State = APIState.Connecting;
State = APIState.Connecting;
if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(Username, Password))
{
@ -125,7 +123,8 @@ namespace osu.Game.Online.API
var userReq = new GetUserRequest();
userReq.Success += u => {
userReq.Success += u =>
{
LocalUser.Value = u;
//we're connected!
State = APIState.Online;
@ -133,16 +132,14 @@ namespace osu.Game.Online.API
};
if (!handleRequest(userReq))
{
State = APIState.Failing;
continue;
}
break;
}
//hard bail if we can't get a valid access token.
if (authentication.RequestAccessToken() == null)
{
Logout(false);
State = APIState.Offline;
continue;
}
@ -162,20 +159,12 @@ namespace osu.Game.Online.API
}
}
private void clearCredentials()
{
Username = null;
Password = null;
}
public void Login(string username, string password)
{
Debug.Assert(State == APIState.Offline);
Username = username;
Password = password;
State = APIState.Connecting;
}
/// <summary>
@ -204,7 +193,7 @@ namespace osu.Game.Online.API
switch (statusCode)
{
case HttpStatusCode.Unauthorized:
State = APIState.Offline;
Logout(false);
return true;
case HttpStatusCode.RequestTimeout:
failureCount++;
@ -215,6 +204,7 @@ namespace osu.Game.Online.API
return false;
State = APIState.Failing;
flushQueue();
return true;
}
@ -235,33 +225,21 @@ namespace osu.Game.Online.API
public APIState State
{
get { return state; }
set
private set
{
APIState oldState = state;
APIState newState = value;
state = value;
switch (state)
{
case APIState.Failing:
case APIState.Offline:
flushQueue();
break;
}
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);
log.Add($@"We just went {newState}!");
Scheduler.Add(delegate
{
components.ForEach(c => c.APIStateChanged(this, newState));
OnStateChange?.Invoke(oldState, newState);
});
}
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();
State = APIState.Offline;
LocalUser.Value = createGuestUser();
}

View File

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

View File

@ -23,6 +23,9 @@ namespace osu.Game.Overlays
private readonly Header header;
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()
{
FirstWaveColour = OsuColour.Gray(0.4f);

View File

@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Direct
public Header()
{
Tabs.Current.Value = DirectTab.Search;
Tabs.Current.Value = DirectTab.NewestMaps;
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;
getSetsRequest = new GetBeatmapSetsRequest(currentQuery,
getSetsRequest = new GetBeatmapSetsRequest(currentQuery.Value ?? string.Empty,
((FilterControl)Filter).Ruleset.Value,
Filter.DisplayStyleControl.Dropdown.Current.Value,
Filter.Tabs.Current.Value); //todo: sort direction (?)

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings.Sections.General;
using OpenTK.Graphics;
@ -28,35 +29,43 @@ namespace osu.Game.Overlays
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
new OsuContextMenuContainer
{
Width = 360,
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,
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.6f,
},
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;
// receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
protected override bool OnClick(InputState state)

View File

@ -38,6 +38,6 @@ namespace osu.Game.Rulesets.Scoring
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)
{
base.LoadBeatmap(beatmap);
foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks)
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)
{
base.LoadBeatmap(beatmap);
foreach (var breakPeriod in beatmap.Beatmap.Breaks)
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)
{
base.LoadBeatmap(beatmap);
ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo;
cpi.TimingPoints.ForEach(addTimingPoint);

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
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());
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
marker.Colour = colours.Red;
}
protected override bool OnDragStart(InputState state) => true;
protected override bool OnDragEnd(InputState state) => true;
protected override bool OnDrag(InputState state)
@ -61,10 +56,14 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
protected override void Update()
{
base.Update();
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
{
public MarkerVisualisation()

View File

@ -25,16 +25,29 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Beatmap.ValueChanged += b =>
{
timeline.Clear();
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, b.Track.Length), 1);
updateRelativeChildSize();
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 virtual void LoadBeatmap(WorkingBeatmap beatmap)
{
timeline.Clear();
}
}
}

View File

@ -186,9 +186,9 @@ namespace osu.Game.Screens.Ranking
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;

View File

@ -124,7 +124,6 @@
<HintPath>$(SolutionDir)\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<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>
<Private>True</Private>