Fix host info not working

This commit is contained in:
smoogipoo 2018-12-25 18:07:19 +09:00
parent 2f32c4d4d1
commit 1dd2a4e368
3 changed files with 30 additions and 14 deletions

View File

@ -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 @@ public class TestCaseMatchHostInfo : OsuTestCase
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);
}
}
}

View File

@ -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 @@ public HostInfo(Room room)
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 @@ public HostInfo(Room room)
}
};
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");
}
}
}

View File

@ -35,6 +35,7 @@ public Info(Room room)
ViewBeatmapButton viewBeatmapButton;
OsuSpriteText name;
EndDateInfo endDate;
HostInfo hostInfo;
Children = new Drawable[]
{
@ -69,7 +70,7 @@ public Info(Room room)
endDate = new EndDateInfo { TextSize = 14 }
}
},
new HostInfo(room),
hostInfo = new HostInfo(),
},
},
new FillFlowContainer
@ -95,6 +96,7 @@ public Info(Room room)
viewBeatmapButton.Beatmap.BindTo(bindings.CurrentBeatmap);
readyButton.Beatmap.BindTo(bindings.CurrentBeatmap);
hostInfo.Host.BindTo(bindings.Host);
bindings.Availability.BindValueChanged(_ => updateAvailabilityStatus());
bindings.Status.BindValueChanged(_ => updateAvailabilityStatus());