mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Fix host info not working
This commit is contained in:
parent
2f32c4d4d1
commit
1dd2a4e368
@ -3,8 +3,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Match.Components;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -17,13 +17,19 @@ namespace osu.Game.Tests.Visual
|
||||
typeof(HostInfo)
|
||||
};
|
||||
|
||||
private readonly Bindable<User> host = new Bindable<User>(new User { Username = "SomeHost" });
|
||||
|
||||
public TestCaseMatchHostInfo()
|
||||
{
|
||||
Child = new HostInfo(new Room { Host = { Value = new User { Username = "ImAHost" }}})
|
||||
HostInfo hostInfo;
|
||||
|
||||
Child = hostInfo = new HostInfo
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
|
||||
hostInfo.Host.BindTo(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
@ -13,13 +13,16 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
public class HostInfo : CompositeDrawable
|
||||
{
|
||||
public HostInfo(Room room)
|
||||
public readonly IBindable<User> Host = new Bindable<User>();
|
||||
|
||||
private readonly LinkFlowContainer linkContainer;
|
||||
private readonly UpdateableAvatar avatar;
|
||||
|
||||
public HostInfo()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
Height = 50;
|
||||
|
||||
LinkFlowContainer linkContainer;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
@ -27,11 +30,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
Spacing = new Vector2(5, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new UpdateableAvatar
|
||||
{
|
||||
Size = new Vector2(50),
|
||||
User = room.Host.Value
|
||||
},
|
||||
avatar = new UpdateableAvatar { Size = new Vector2(50) },
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
@ -43,11 +42,20 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
}
|
||||
};
|
||||
|
||||
if (room.Host.Value != null)
|
||||
|
||||
|
||||
Host.BindValueChanged(updateHost);
|
||||
}
|
||||
|
||||
private void updateHost(User host)
|
||||
{
|
||||
avatar.User = host;
|
||||
|
||||
if (host != null)
|
||||
{
|
||||
linkContainer.AddText("hosted by");
|
||||
linkContainer.NewLine();
|
||||
linkContainer.AddLink(room.Host.Value.Username, null, LinkAction.OpenUserProfile, room.Host.Value.Id.ToString(), "View Profile", s => s.Font = "Exo2.0-BoldItalic");
|
||||
linkContainer.AddLink(host.Username, null, LinkAction.OpenUserProfile, host.Id.ToString(), "View Profile", s => s.Font = "Exo2.0-BoldItalic");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
ViewBeatmapButton viewBeatmapButton;
|
||||
OsuSpriteText name;
|
||||
EndDateInfo endDate;
|
||||
HostInfo hostInfo;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -69,7 +70,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
endDate = new EndDateInfo { TextSize = 14 }
|
||||
}
|
||||
},
|
||||
new HostInfo(room),
|
||||
hostInfo = new HostInfo(),
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -95,6 +96,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
|
||||
viewBeatmapButton.Beatmap.BindTo(bindings.CurrentBeatmap);
|
||||
readyButton.Beatmap.BindTo(bindings.CurrentBeatmap);
|
||||
hostInfo.Host.BindTo(bindings.Host);
|
||||
|
||||
bindings.Availability.BindValueChanged(_ => updateAvailabilityStatus());
|
||||
bindings.Status.BindValueChanged(_ => updateAvailabilityStatus());
|
||||
|
Loading…
Reference in New Issue
Block a user