mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 16:57:21 +08:00
Make Info updateable.
This commit is contained in:
parent
574d7b24ff
commit
63c50f82eb
@ -16,15 +16,27 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
|
|||||||
{
|
{
|
||||||
public class Info : Container
|
public class Info : Container
|
||||||
{
|
{
|
||||||
|
private const float transition_duration = 250;
|
||||||
private const float metadata_width = 225;
|
private const float metadata_width = 225;
|
||||||
private const float spacing = 20;
|
private const float spacing = 20;
|
||||||
|
|
||||||
private readonly BeatmapSetInfo set;
|
private readonly MetadataSection description, source, tags;
|
||||||
|
|
||||||
private readonly Box successRateBackground;
|
private readonly Box successRateBackground;
|
||||||
private readonly SuccessRate successRate;
|
private readonly SuccessRate successRate;
|
||||||
private readonly FillFlowContainer metadataFlow;
|
|
||||||
private readonly ScrollContainer descriptionScroll;
|
private BeatmapSetInfo beatmapSet;
|
||||||
|
public BeatmapSetInfo BeatmapSet
|
||||||
|
{
|
||||||
|
get { return beatmapSet; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == beatmapSet) return;
|
||||||
|
beatmapSet = value;
|
||||||
|
|
||||||
|
source.Text = BeatmapSet.Metadata.Source;
|
||||||
|
tags.Text = BeatmapSet.Metadata.Tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo Beatmap
|
||||||
{
|
{
|
||||||
@ -32,10 +44,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
|
|||||||
set { successRate.Beatmap = value; }
|
set { successRate.Beatmap = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info(BeatmapSetInfo set)
|
public Info()
|
||||||
{
|
{
|
||||||
this.set = set;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 220;
|
Height = 220;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
@ -64,10 +74,11 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Right = metadata_width + OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 },
|
Padding = new MarginPadding { Right = metadata_width + OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 },
|
||||||
Child = descriptionScroll = new ScrollContainer
|
Child = new ScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarVisible = false,
|
ScrollbarVisible = false,
|
||||||
|
Child = description = new MetadataSection("Description"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new ScrollContainer
|
new ScrollContainer
|
||||||
@ -79,11 +90,17 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
|
|||||||
ScrollbarVisible = false,
|
ScrollbarVisible = false,
|
||||||
Padding = new MarginPadding { Horizontal = 10 },
|
Padding = new MarginPadding { Horizontal = 10 },
|
||||||
Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing },
|
Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing },
|
||||||
Child = metadataFlow = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
|
LayoutDuration = transition_duration,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
source = new MetadataSection("Source"),
|
||||||
|
tags = new MetadataSection("Tags"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -114,55 +131,59 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
successRateBackground.Colour = colours.GrayE;
|
successRateBackground.Colour = colours.GrayE;
|
||||||
descriptionScroll.Child = new MetadataSection("Description", "", colours.Gray5);
|
source.TextColour = description.TextColour = colours.Gray5;
|
||||||
metadataFlow.Children = new[]
|
tags.TextColour = colours.BlueDark;
|
||||||
{
|
|
||||||
new MetadataSection("Source", set.Metadata.Source, colours.Gray5),
|
|
||||||
new MetadataSection("Tags", set.Metadata.Tags, colours.BlueDark),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MetadataSection : FillFlowContainer
|
private class MetadataSection : FillFlowContainer
|
||||||
{
|
{
|
||||||
private readonly OsuSpriteText header;
|
private readonly OsuSpriteText header;
|
||||||
|
private readonly TextFlowContainer textFlow;
|
||||||
|
|
||||||
public MetadataSection(string title, string body, Color4 textColour)
|
public string Text
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
this.FadeOut(transition_duration);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.FadeIn(transition_duration);
|
||||||
|
textFlow.Clear();
|
||||||
|
textFlow.AddText(value, s => s.TextSize = 14);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color4 TextColour
|
||||||
|
{
|
||||||
|
get { return textFlow.Colour; }
|
||||||
|
set { textFlow.Colour = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataSection(string title)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Direction = FillDirection.Vertical;
|
|
||||||
Spacing = new Vector2(5f);
|
Spacing = new Vector2(5f);
|
||||||
|
|
||||||
TextFlowContainer content;
|
InternalChildren = new Drawable[]
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
header = new OsuSpriteText
|
header = new OsuSpriteText
|
||||||
{
|
{
|
||||||
|
Text = title,
|
||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
Text = title,
|
|
||||||
Shadow = false,
|
Shadow = false,
|
||||||
Margin = new MarginPadding { Top = 20 },
|
Margin = new MarginPadding { Top = 20 },
|
||||||
},
|
},
|
||||||
content = new TextFlowContainer
|
textFlow = new TextFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(body))
|
|
||||||
{
|
|
||||||
content.AddText(body, t =>
|
|
||||||
{
|
|
||||||
t.TextSize = 14;
|
|
||||||
t.Colour = textColour;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 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 System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -19,7 +20,8 @@ namespace osu.Game.Overlays
|
|||||||
public const float X_PADDING = 40;
|
public const float X_PADDING = 40;
|
||||||
public const float RIGHT_WIDTH = 275;
|
public const float RIGHT_WIDTH = 275;
|
||||||
|
|
||||||
private readonly ReverseChildIDFillFlowContainer<Drawable> scrollContent;
|
private readonly Header header;
|
||||||
|
private readonly Info info;
|
||||||
|
|
||||||
public OnlineBeatmapSetOverlay()
|
public OnlineBeatmapSetOverlay()
|
||||||
{
|
{
|
||||||
@ -53,14 +55,21 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarVisible = false,
|
ScrollbarVisible = false,
|
||||||
Child = scrollContent = new ReverseChildIDFillFlowContainer<Drawable>
|
Child = new ReverseChildIDFillFlowContainer<Drawable>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
// header = new Header(),
|
||||||
|
info = new Info(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
@ -77,15 +86,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public void ShowBeatmapSet(BeatmapSetInfo set)
|
public void ShowBeatmapSet(BeatmapSetInfo set)
|
||||||
{
|
{
|
||||||
Header header;
|
/*header.BeatmapSet = */info.BeatmapSet = set;
|
||||||
Info info;
|
info.Beatmap = set.Beatmaps.Last();
|
||||||
scrollContent.Children = new Drawable[]
|
|
||||||
{
|
|
||||||
header = new Header(set),
|
|
||||||
info = new Info(set),
|
|
||||||
};
|
|
||||||
|
|
||||||
header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b;
|
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user