mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Substitute APIUser
for UserProfile
in overlay
This commit is contained in:
@ -5,14 +5,13 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class FollowersButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public override LocalisableString TooltipText => FriendsStrings.ButtonsDisabled;
|
||||
|
||||
@ -22,7 +21,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
private void load()
|
||||
{
|
||||
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
|
||||
UserProfile.BindValueChanged(user => SetValue(user.NewValue?.User.FollowerCount ?? 0), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class LevelBadge : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public LocalisableString TooltipText { get; private set; }
|
||||
|
||||
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(user => updateLevel(user.NewValue));
|
||||
UserProfile.BindValueChanged(user => updateLevel(user.NewValue?.User));
|
||||
}
|
||||
|
||||
private void updateLevel(APIUser? user)
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class LevelProgressBar : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public LocalisableString TooltipText { get; }
|
||||
|
||||
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
}
|
||||
};
|
||||
|
||||
User.BindValueChanged(user => updateProgress(user.NewValue));
|
||||
UserProfile.BindValueChanged(user => updateProgress(user.NewValue?.User));
|
||||
}
|
||||
|
||||
private void updateProgress(APIUser? user)
|
||||
|
@ -5,14 +5,13 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class MappingSubscribersButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public override LocalisableString TooltipText => FollowsStrings.MappingFollowers;
|
||||
|
||||
@ -21,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
|
||||
UserProfile.BindValueChanged(user => SetValue(user.NewValue?.User.MappingFollowerCount ?? 0), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osuTK;
|
||||
@ -16,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class MessageUserButton : ProfileHeaderButton
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public override LocalisableString TooltipText => UsersStrings.CardSendMessage;
|
||||
|
||||
@ -49,12 +48,16 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
if (!Content.IsPresent) return;
|
||||
|
||||
channelManager?.OpenPrivateChannel(User.Value);
|
||||
channelManager?.OpenPrivateChannel(UserProfile.Value?.User);
|
||||
userOverlay?.Hide();
|
||||
chatOverlay?.Show();
|
||||
};
|
||||
|
||||
User.ValueChanged += e => Content.Alpha = e.NewValue != null && !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0;
|
||||
UserProfile.ValueChanged += e =>
|
||||
{
|
||||
var user = e.NewValue?.User;
|
||||
Content.Alpha = user != null && !user.PMFriendsOnly && apiProvider.LocalUser.Value.Id != user.Id ? 1 : 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,13 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public partial class OverlinedTotalPlayTime : CompositeDrawable, IHasTooltip
|
||||
{
|
||||
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
|
||||
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
|
||||
|
||||
public LocalisableString TooltipText { get; set; }
|
||||
|
||||
@ -36,13 +35,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
LineColour = colourProvider.Highlight1,
|
||||
};
|
||||
|
||||
User.BindValueChanged(updateTime, true);
|
||||
UserProfile.BindValueChanged(updateTime, true);
|
||||
}
|
||||
|
||||
private void updateTime(ValueChangedEvent<APIUser?> user)
|
||||
private void updateTime(ValueChangedEvent<UserProfile?> userProfile)
|
||||
{
|
||||
TooltipText = (user.NewValue?.Statistics?.PlayTime ?? 0) / 3600 + " hours";
|
||||
info.Content = formatTime(user.NewValue?.Statistics?.PlayTime);
|
||||
int? playTime = userProfile.NewValue?.User.Statistics?.PlayTime;
|
||||
TooltipText = (playTime ?? 0) / 3600 + " hours";
|
||||
info.Content = formatTime(playTime);
|
||||
}
|
||||
|
||||
private string formatTime(int? secondsNull)
|
||||
|
Reference in New Issue
Block a user