1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 10:22:56 +08:00

Get some more of the design's layout in place

This commit is contained in:
Drew DeVault 2016-10-13 18:15:43 -04:00
parent e13374ed23
commit 7a22c60c7c
3 changed files with 127 additions and 37 deletions

View File

@ -12,10 +12,14 @@ using osu.Game.GameModes.Backgrounds;
using osu.Framework;
using osu.Game.Database;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Drawables;
using OpenTK.Graphics;
using OpenTK;
using osu.Game.Graphics;
namespace osu.Game.GameModes.Play
{
class BeatmapButton : FlowContainer
class BeatmapButton : AutoSizeContainer
{
private BeatmapSet beatmapSet;
private Beatmap beatmap;
@ -24,9 +28,41 @@ namespace osu.Game.GameModes.Play
{
this.beatmapSet = set;
this.beatmap = beatmap;
Children = new[]
Children = new Drawable[]
{
new SpriteText { Text = beatmap.Version },
new Box
{
Colour = new Color4(40, 86, 102, 255), // TODO: texture
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1),
},
new FlowContainer
{
Padding = new MarginPadding(5),
Direction = FlowDirection.HorizontalOnly,
Children = new Drawable[]
{
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255)),
new FlowContainer
{
Padding = new MarginPadding { Left = 10 },
Direction = FlowDirection.HorizontalOnly,
Children = new[]
{
new SpriteText
{
Text = beatmap.Version,
TextSize = 20,
},
new SpriteText
{
Text = string.Format(" mapped by {0}", beatmap.Version),
TextSize = 16,
},
}
}
}
}
};
}
}

View File

@ -2,15 +2,11 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Beatmaps;
using osu.Game.GameModes.Backgrounds;
using osu.Framework;
using osu.Game.Database;
using osu.Framework.Graphics.Primitives;
using OpenTK;
using System.Linq;
@ -23,7 +19,7 @@ namespace osu.Game.GameModes.Play
{
class BeatmapGroup : AutoSizeContainer
{
private const float collapsedAlpha = 0.75f;
private const float collapsedAlpha = 0.3f;
public event Action<BeatmapSet> SetSelected;
public event Action<BeatmapSet, Beatmap> BeatmapSelected;
@ -64,29 +60,14 @@ namespace osu.Game.GameModes.Play
topContainer = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Children = new[]
{
new AutoSizeContainer
{
Children = new Drawable[]
{
new Box
{
Colour = new Color4(0, 0, 0, 0.75f),
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1),
},
new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 }
}
}
}
Children = new[] { new BeatmapSetBox(beatmapSet) }
}
};
difficulties = new FlowContainer // Deliberately not added to children
{
Margin = new MarginPadding { Top = 10 },
Padding = new MarginPadding { Left = 50 },
Spacing = new Vector2(0, 10),
Margin = new MarginPadding { Top = 5 },
Padding = new MarginPadding { Left = 25 },
Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly,
Children = this.BeatmapSet.Beatmaps.Select(b => new BeatmapButton(this.BeatmapSet, b))
};
@ -99,4 +80,71 @@ namespace osu.Game.GameModes.Play
return true;
}
}
class BeatmapSetBox : AutoSizeContainer
{
private BeatmapSet beatmapSet;
public BeatmapSetBox(BeatmapSet beatmapSet)
{
this.beatmapSet = beatmapSet;
Children = new Drawable[]
{
new Box
{
Colour = new Color4(85, 85, 85, 255), // TODO: Gradient, and beatmap texture
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1),
},
new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Spacing = new Vector2(0, 2),
Padding = new MarginPadding { Top = 3, Left = 20, Right = 20, Bottom = 3 },
Children = new[]
{
// TODO: Make these italic
new SpriteText
{
Text = this.beatmapSet.Metadata.TitleUnicode ?? this.beatmapSet.Metadata.Title,
TextSize = 20
},
new SpriteText
{
Text = this.beatmapSet.Metadata.ArtistUnicode ?? this.beatmapSet.Metadata.Artist,
TextSize = 16
},
new FlowContainer
{
Children = new[]
{
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255)),
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(246, 101, 166, 255)),
}
}
}
}
};
}
}
class DifficultyIcon : Container
{
public DifficultyIcon(FontAwesome icon, Color4 color)
{
const float size = 20;
Size = new Vector2(size);
Children = new[]
{
new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = size,
Size = new Vector2(size),
Colour = color,
Icon = icon
}
};
}
}
}

View File

@ -23,6 +23,7 @@ namespace osu.Game.GameModes.Play
{
private Bindable<PlayMode> playMode;
private BeatmapDatabase beatmaps;
private BeatmapSet selectedBeatmapSet;
// TODO: use currently selected track as bg
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
@ -30,17 +31,20 @@ namespace osu.Game.GameModes.Play
private ScrollContainer scrollContainer;
private FlowContainer setList;
private void selectBeatmapSet(BeatmapSet beatmapSet)
{
selectedBeatmapSet = beatmapSet;
foreach (var child in setList.Children)
{
var childGroup = child as BeatmapGroup;
childGroup.Collapsed = childGroup.BeatmapSet != beatmapSet;
}
}
private void addBeatmapSet(BeatmapSet beatmapSet)
{
var group = new BeatmapGroup(beatmapSet);
group.SetSelected += (selectedSet) =>
{
foreach (var child in setList.Children)
{
var childGroup = child as BeatmapGroup;
childGroup.Collapsed = childGroup.BeatmapSet != selectedSet;
}
};
group.SetSelected += (selectedSet) => selectBeatmapSet(selectedSet);
setList.Add(group);
}
@ -106,7 +110,9 @@ namespace osu.Game.GameModes.Play
beatmaps = (game as OsuGameBase).Beatmaps;
beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
addBeatmapSets();
(setList.Children.First() as BeatmapGroup).Collapsed = false;
var first = setList.Children.First() as BeatmapGroup;
first.Collapsed = false;
selectedBeatmapSet = first.BeatmapSet;
}
protected override void Dispose(bool isDisposing)