1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

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;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users; using osu.Game.Users;
@ -17,13 +17,19 @@ namespace osu.Game.Tests.Visual
typeof(HostInfo) typeof(HostInfo)
}; };
private readonly Bindable<User> host = new Bindable<User>(new User { Username = "SomeHost" });
public TestCaseMatchHostInfo() public TestCaseMatchHostInfo()
{ {
Child = new HostInfo(new Room { Host = { Value = new User { Username = "ImAHost" }}}) HostInfo hostInfo;
Child = hostInfo = new HostInfo
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = 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>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Online.Multiplayer;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -13,13 +13,16 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
public class HostInfo : CompositeDrawable 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; AutoSizeAxes = Axes.X;
Height = 50; Height = 50;
LinkFlowContainer linkContainer;
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
@ -27,11 +30,7 @@ namespace osu.Game.Screens.Multi.Match.Components
Spacing = new Vector2(5, 0), Spacing = new Vector2(5, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
new UpdateableAvatar avatar = new UpdateableAvatar { Size = new Vector2(50) },
{
Size = new Vector2(50),
User = room.Host.Value
},
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.CentreLeft, 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.AddText("hosted by");
linkContainer.NewLine(); 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 @@ namespace osu.Game.Screens.Multi.Match.Components
ViewBeatmapButton viewBeatmapButton; ViewBeatmapButton viewBeatmapButton;
OsuSpriteText name; OsuSpriteText name;
EndDateInfo endDate; EndDateInfo endDate;
HostInfo hostInfo;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -69,7 +70,7 @@ namespace osu.Game.Screens.Multi.Match.Components
endDate = new EndDateInfo { TextSize = 14 } endDate = new EndDateInfo { TextSize = 14 }
} }
}, },
new HostInfo(room), hostInfo = new HostInfo(),
}, },
}, },
new FillFlowContainer new FillFlowContainer
@ -95,6 +96,7 @@ namespace osu.Game.Screens.Multi.Match.Components
viewBeatmapButton.Beatmap.BindTo(bindings.CurrentBeatmap); viewBeatmapButton.Beatmap.BindTo(bindings.CurrentBeatmap);
readyButton.Beatmap.BindTo(bindings.CurrentBeatmap); readyButton.Beatmap.BindTo(bindings.CurrentBeatmap);
hostInfo.Host.BindTo(bindings.Host);
bindings.Availability.BindValueChanged(_ => updateAvailabilityStatus()); bindings.Availability.BindValueChanged(_ => updateAvailabilityStatus());
bindings.Status.BindValueChanged(_ => updateAvailabilityStatus()); bindings.Status.BindValueChanged(_ => updateAvailabilityStatus());