mirror of
https://github.com/ppy/osu
synced 2025-01-11 00:29:30 +00:00
Merge pull request #26337 from bdach/persist-user-status-to-config
Store user online state in config for next launch
This commit is contained in:
commit
18820e60b3
@ -20,6 +20,7 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Filter;
|
using osu.Game.Screens.Select.Filter;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Configuration
|
namespace osu.Game.Configuration
|
||||||
{
|
{
|
||||||
@ -193,6 +194,7 @@ namespace osu.Game.Configuration
|
|||||||
SetDefault(OsuSetting.LastProcessedMetadataId, -1);
|
SetDefault(OsuSetting.LastProcessedMetadataId, -1);
|
||||||
|
|
||||||
SetDefault(OsuSetting.ComboColourNormalisationAmount, 0.2f, 0f, 1f, 0.01f);
|
SetDefault(OsuSetting.ComboColourNormalisationAmount, 0.2f, 0f, 1f, 0.01f);
|
||||||
|
SetDefault<UserStatus?>(OsuSetting.UserOnlineStatus, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CheckLookupContainsPrivateInformation(OsuSetting lookup)
|
protected override bool CheckLookupContainsPrivateInformation(OsuSetting lookup)
|
||||||
@ -420,5 +422,6 @@ namespace osu.Game.Configuration
|
|||||||
EditorShowSpeedChanges,
|
EditorShowSpeedChanges,
|
||||||
TouchDisableGameplayTaps,
|
TouchDisableGameplayTaps,
|
||||||
ModSelectTextSearchStartsActive,
|
ModSelectTextSearchStartsActive,
|
||||||
|
UserOnlineStatus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,9 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private Bindable<UserActivity> activity { get; } = new Bindable<UserActivity>();
|
private Bindable<UserActivity> activity { get; } = new Bindable<UserActivity>();
|
||||||
|
|
||||||
|
private Bindable<UserStatus?> configStatus { get; } = new Bindable<UserStatus?>();
|
||||||
|
private Bindable<UserStatus?> localUserStatus { get; } = new Bindable<UserStatus?>();
|
||||||
|
|
||||||
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
|
protected bool HasLogin => authentication.Token.Value != null || (!string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password));
|
||||||
|
|
||||||
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
||||||
@ -85,12 +88,20 @@ namespace osu.Game.Online.API
|
|||||||
authentication.TokenString = config.Get<string>(OsuSetting.Token);
|
authentication.TokenString = config.Get<string>(OsuSetting.Token);
|
||||||
authentication.Token.ValueChanged += onTokenChanged;
|
authentication.Token.ValueChanged += onTokenChanged;
|
||||||
|
|
||||||
|
config.BindWith(OsuSetting.UserOnlineStatus, configStatus);
|
||||||
|
|
||||||
localUser.BindValueChanged(u =>
|
localUser.BindValueChanged(u =>
|
||||||
{
|
{
|
||||||
u.OldValue?.Activity.UnbindFrom(activity);
|
u.OldValue?.Activity.UnbindFrom(activity);
|
||||||
u.NewValue.Activity.BindTo(activity);
|
u.NewValue.Activity.BindTo(activity);
|
||||||
|
|
||||||
|
if (u.OldValue != null)
|
||||||
|
localUserStatus.UnbindFrom(u.OldValue.Status);
|
||||||
|
localUserStatus.BindTo(u.NewValue.Status);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
localUserStatus.BindValueChanged(val => configStatus.Value = val.NewValue);
|
||||||
|
|
||||||
var thread = new Thread(run)
|
var thread = new Thread(run)
|
||||||
{
|
{
|
||||||
Name = "APIAccess",
|
Name = "APIAccess",
|
||||||
@ -200,6 +211,7 @@ namespace osu.Game.Online.API
|
|||||||
setLocalUser(new APIUser
|
setLocalUser(new APIUser
|
||||||
{
|
{
|
||||||
Username = ProvidedUsername,
|
Username = ProvidedUsername,
|
||||||
|
Status = { Value = configStatus.Value ?? UserStatus.Online }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,8 +258,7 @@ namespace osu.Game.Online.API
|
|||||||
};
|
};
|
||||||
userReq.Success += user =>
|
userReq.Success += user =>
|
||||||
{
|
{
|
||||||
// todo: save/pull from settings
|
user.Status.Value = configStatus.Value ?? UserStatus.Online;
|
||||||
user.Status.Value = UserStatus.Online;
|
|
||||||
|
|
||||||
setLocalUser(user);
|
setLocalUser(user);
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ namespace osu.Game.Online.Metadata
|
|||||||
public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence;
|
public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence;
|
||||||
private readonly BindableBool isWatchingUserPresence = new BindableBool();
|
private readonly BindableBool isWatchingUserPresence = new BindableBool();
|
||||||
|
|
||||||
// ReSharper disable once InconsistentlySynchronizedField
|
|
||||||
public override IBindableDictionary<int, UserPresence> UserStates => userStates;
|
public override IBindableDictionary<int, UserPresence> UserStates => userStates;
|
||||||
private readonly BindableDictionary<int, UserPresence> userStates = new BindableDictionary<int, UserPresence>();
|
private readonly BindableDictionary<int, UserPresence> userStates = new BindableDictionary<int, UserPresence>();
|
||||||
|
|
||||||
@ -192,7 +191,7 @@ namespace osu.Game.Online.Metadata
|
|||||||
{
|
{
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (presence != null)
|
if (presence?.Status != null)
|
||||||
userStates[userId] = presence.Value;
|
userStates[userId] = presence.Value;
|
||||||
else
|
else
|
||||||
userStates.Remove(userId);
|
userStates.Remove(userId);
|
||||||
|
@ -143,6 +143,8 @@ namespace osu.Game.Overlays.Login
|
|||||||
panel.Status.BindTo(api.LocalUser.Value.Status);
|
panel.Status.BindTo(api.LocalUser.Value.Status);
|
||||||
panel.Activity.BindTo(api.LocalUser.Value.Activity);
|
panel.Activity.BindTo(api.LocalUser.Value.Activity);
|
||||||
|
|
||||||
|
panel.Status.BindValueChanged(_ => updateDropdownCurrent(), true);
|
||||||
|
|
||||||
dropdown.Current.BindValueChanged(action =>
|
dropdown.Current.BindValueChanged(action =>
|
||||||
{
|
{
|
||||||
switch (action.NewValue)
|
switch (action.NewValue)
|
||||||
@ -174,6 +176,24 @@ namespace osu.Game.Overlays.Login
|
|||||||
ScheduleAfterChildren(() => GetContainingInputManager()?.ChangeFocus(form));
|
ScheduleAfterChildren(() => GetContainingInputManager()?.ChangeFocus(form));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private void updateDropdownCurrent()
|
||||||
|
{
|
||||||
|
switch (panel.Status.Value)
|
||||||
|
{
|
||||||
|
case UserStatus.Online:
|
||||||
|
dropdown.Current.Value = UserAction.Online;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UserStatus.DoNotDisturb:
|
||||||
|
dropdown.Current.Value = UserAction.DoNotDisturb;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UserStatus.Offline:
|
||||||
|
dropdown.Current.Value = UserAction.AppearOffline;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool AcceptsFocus => true;
|
public override bool AcceptsFocus => true;
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e) => true;
|
protected override bool OnClick(ClickEvent e) => true;
|
||||||
|
Loading…
Reference in New Issue
Block a user