mirror of
https://github.com/osukey/osukey.git
synced 2025-05-03 04:37:30 +09:00
Move activity (writable) bindable to APIAccess so it correctly transfers between users
This commit is contained in:
parent
20b43c20c8
commit
f358fce9ab
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -61,12 +62,16 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void UserActivitiesTests()
|
public void UserActivitiesTests()
|
||||||
{
|
{
|
||||||
AddStep("idle", () => { peppy.Activity.Value = null; });
|
Bindable<UserActivity> activity = new Bindable<UserActivity>();
|
||||||
AddStep("spectating", () => { peppy.Activity.Value = new UserActivity.Spectating(); });
|
|
||||||
AddStep("solo", () => { peppy.Activity.Value = new UserActivity.SoloGame(null, null); });
|
peppy.Activity.BindTo(activity);
|
||||||
AddStep("choosing", () => { peppy.Activity.Value = new UserActivity.ChoosingBeatmap(); });
|
|
||||||
AddStep("editing", () => { peppy.Activity.Value = new UserActivity.Editing(null); });
|
AddStep("idle", () => { activity.Value = null; });
|
||||||
AddStep("modding", () => { peppy.Activity.Value = new UserActivity.Modding(); });
|
AddStep("spectating", () => { activity.Value = new UserActivity.Spectating(); });
|
||||||
|
AddStep("solo", () => { activity.Value = new UserActivity.SoloGame(null, null); });
|
||||||
|
AddStep("choosing", () => { activity.Value = new UserActivity.ChoosingBeatmap(); });
|
||||||
|
AddStep("editing", () => { activity.Value = new UserActivity.Editing(null); });
|
||||||
|
AddStep("modding", () => { activity.Value = new UserActivity.Modding(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
|
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
|
||||||
|
|
||||||
|
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||||
|
|
||||||
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();
|
||||||
@ -55,6 +57,12 @@ 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;
|
||||||
|
|
||||||
|
LocalUser.BindValueChanged(u =>
|
||||||
|
{
|
||||||
|
u.OldValue?.Activity.UnbindFrom(Activity);
|
||||||
|
u.NewValue.Activity.BindTo(Activity);
|
||||||
|
}, true);
|
||||||
|
|
||||||
var thread = new Thread(run)
|
var thread = new Thread(run)
|
||||||
{
|
{
|
||||||
Name = "APIAccess",
|
Name = "APIAccess",
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Online.API
|
|||||||
Id = 1001,
|
Id = 1001,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public Bindable<UserActivity> Activity { get; } = new Bindable<UserActivity>();
|
||||||
|
|
||||||
public bool IsLoggedIn => true;
|
public bool IsLoggedIn => true;
|
||||||
|
|
||||||
public string ProvidedUsername => LocalUser.Value.Username;
|
public string ProvidedUsername => LocalUser.Value.Username;
|
||||||
@ -41,6 +43,15 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DummyAPIAccess()
|
||||||
|
{
|
||||||
|
LocalUser.BindValueChanged(u =>
|
||||||
|
{
|
||||||
|
u.OldValue?.Activity.UnbindFrom(Activity);
|
||||||
|
u.NewValue.Activity.BindTo(Activity);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Queue(APIRequest request)
|
public virtual void Queue(APIRequest request)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,11 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Bindable<User> LocalUser { get; }
|
Bindable<User> LocalUser { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current user's activity.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<UserActivity> Activity { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns whether the local user is logged in.
|
/// Returns whether the local user is logged in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -156,7 +156,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
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);
|
||||||
|
|
||||||
dropdown.Current.ValueChanged += action =>
|
dropdown.Current.BindValueChanged(action =>
|
||||||
{
|
{
|
||||||
switch (action.NewValue)
|
switch (action.NewValue)
|
||||||
{
|
{
|
||||||
@ -179,9 +179,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
api.Logout();
|
api.Logout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
}, true);
|
||||||
dropdown.Current.TriggerChange();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ namespace osu.Game.Screens
|
|||||||
private void updateActivity()
|
private void updateActivity()
|
||||||
{
|
{
|
||||||
if (api != null)
|
if (api != null)
|
||||||
api.LocalUser.Value.Activity.Value = activity;
|
api.Activity.Value = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
public Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
public Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
||||||
|
|
||||||
public Bindable<UserActivity> Activity = new Bindable<UserActivity>();
|
public IBindable<UserActivity> Activity = new Bindable<UserActivity>();
|
||||||
|
|
||||||
//public Team Team;
|
//public Team Team;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
public readonly Bindable<UserStatus> Status = new Bindable<UserStatus>();
|
||||||
|
|
||||||
public readonly Bindable<UserActivity> Activity = new Bindable<UserActivity>();
|
public readonly IBindable<UserActivity> Activity = new Bindable<UserActivity>();
|
||||||
|
|
||||||
public new Action Action;
|
public new Action Action;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user