Merge branch 'master' into fix-invisible-marker

This commit is contained in:
Dan Balasescu 2017-09-27 14:17:42 +09:00 committed by GitHub
commit 43d56bc9d7
6 changed files with 25 additions and 42 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);
@ -69,7 +69,7 @@ namespace osu.Game.Tests.Beatmaps.IO
public void TestImportWhenFileOpen() public void TestImportWhenFileOpen()
{ {
//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("TestImportWhenFileOpen"))
{ {
var osu = loadOsu(host); var osu = loadOsu(host);

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;
} }
@ -242,26 +232,14 @@ namespace osu.Game.Online.API
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

@ -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

@ -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)