1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 23:33:23 +08:00

Merge pull request #19662 from peppy/startup-correct-username

Use a placeholder user with the correct username during login process
This commit is contained in:
Dan Balasescu 2022-08-10 13:09:37 +09:00 committed by GitHub
commit 888c4c8e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -137,6 +137,17 @@ namespace osu.Game.Online.API
state.Value = APIState.Connecting;
if (localUser.IsDefault)
{
// Show a placeholder user if saved credentials are available.
// This is useful for storing local scores and showing a placeholder username after starting the game,
// until a valid connection has been established.
localUser.Value = new APIUser
{
Username = ProvidedUsername,
};
}
// save the username at this point, if the user requested for it to be.
config.SetValue(OsuSetting.Username, config.Get<bool>(OsuSetting.SaveUsername) ? ProvidedUsername : string.Empty);
@ -402,7 +413,7 @@ namespace osu.Game.Online.API
}
}
public bool IsLoggedIn => localUser.Value.Id > 1; // TODO: should this also be true if attempting to connect?
public bool IsLoggedIn => State.Value > APIState.Offline;
public void Queue(APIRequest request)
{

View File

@ -104,11 +104,11 @@ namespace osu.Game.Overlays
filterControl.CardSize.BindValueChanged(_ => onCardSizeChanged());
apiUser = api.LocalUser.GetBoundCopy();
apiUser.BindValueChanged(_ =>
apiUser.BindValueChanged(_ => Schedule(() =>
{
if (api.IsLoggedIn)
addContentToResultsArea(Drawable.Empty());
});
}));
}
public void ShowWithSearch(string query)