Restructure

This commit is contained in:
Dean Herbert
2019-02-11 19:11:34 +09:00
parent e2e615cc5c
commit 88ffc78103
16 changed files with 243 additions and 323 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi.Components
[BackgroundDependencyLoader]
private void load()
{
CurrentBeatmap.BindValueChanged(v => updateText(), true);
CurrentItem.BindValueChanged(v => updateText(), true);
}
private float textSize = OsuSpriteText.FONT_SIZE;
@ -53,7 +53,9 @@ namespace osu.Game.Screens.Multi.Components
textFlow.Clear();
if (CurrentBeatmap.Value == null)
var beatmap = CurrentItem.Value?.Beatmap;
if (beatmap == null)
textFlow.AddText("No beatmap selected", s =>
{
s.TextSize = TextSize;
@ -65,7 +67,7 @@ namespace osu.Game.Screens.Multi.Components
{
new OsuSpriteText
{
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.ArtistUnicode, CurrentBeatmap.Value.Metadata.Artist)),
Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)),
TextSize = TextSize,
},
new OsuSpriteText
@ -75,10 +77,10 @@ namespace osu.Game.Screens.Multi.Components
},
new OsuSpriteText
{
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.TitleUnicode, CurrentBeatmap.Value.Metadata.Title)),
Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)),
TextSize = TextSize,
}
}, null, LinkAction.OpenBeatmap, CurrentBeatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap");
}, null, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap");
}
}
}

View File

@ -51,14 +51,16 @@ namespace osu.Game.Screens.Multi.Components
}
};
CurrentBeatmap.BindValueChanged(v =>
CurrentItem.BindValueChanged(item =>
{
beatmapAuthor.Clear();
if (v != null)
var beatmap = item?.Beatmap;
if (beatmap != null)
{
beatmapAuthor.AddText("mapped by ", s => s.Colour = OsuColour.Gray(0.8f));
beatmapAuthor.AddLink(v.Metadata.Author.Username, null, LinkAction.OpenUserProfile, v.Metadata.Author.Id.ToString(), "View Profile");
beatmapAuthor.AddLink(beatmap.Metadata.Author.Username, null, LinkAction.OpenUserProfile, beatmap.Metadata.Author.Id.ToString(), "View Profile");
}
}, true);
}

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Online.Multiplayer;
using osuTK;
namespace osu.Game.Screens.Multi.Components
@ -45,17 +46,17 @@ namespace osu.Game.Screens.Multi.Components
},
};
CurrentBeatmap.BindValueChanged(_ => updateBeatmap());
CurrentRuleset.BindValueChanged(_ => updateBeatmap(), true);
CurrentItem.BindValueChanged(updateBeatmap, true);
Type.BindValueChanged(v => gameTypeContainer.Child = new DrawableGameType(v) { Size = new Vector2(height) }, true);
}
private void updateBeatmap()
private void updateBeatmap(PlaylistItem item)
{
if (CurrentBeatmap.Value != null)
if (item?.Beatmap != null)
{
rulesetContainer.FadeIn(transition_duration);
rulesetContainer.Child = new DifficultyIcon(CurrentBeatmap.Value, CurrentRuleset.Value) { Size = new Vector2(height) };
rulesetContainer.Child = new DifficultyIcon(item.Beatmap, item.Ruleset) { Size = new Vector2(height) };
}
else
rulesetContainer.FadeOut(transition_duration);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Screens.Multi.Components
InternalChild = sprite = CreateBackgroundSprite();
sprite.Beatmap.BindTo(CurrentBeatmap);
CurrentItem.BindValueChanged(i => sprite.Beatmap.Value = i?.Beatmap, true);
}
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both };