mirror of
https://github.com/ppy/osu
synced 2024-12-16 11:56:31 +00:00
Add selection interactions
This commit is contained in:
parent
bc6e705e2b
commit
71f58285fc
@ -29,10 +29,5 @@ namespace osu.Game.GameModes.Play
|
|||||||
new SpriteText { Text = beatmap.Version },
|
new SpriteText { Text = beatmap.Version },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,48 +15,66 @@ using osu.Framework.Graphics.Primitives;
|
|||||||
using OpenTK;
|
using OpenTK;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Drawables;
|
using osu.Framework.Graphics.Drawables;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play
|
namespace osu.Game.GameModes.Play
|
||||||
{
|
{
|
||||||
class BeatmapGroup : FlowContainer
|
class BeatmapGroup : FlowContainer
|
||||||
{
|
{
|
||||||
private BeatmapSet beatmapSet;
|
public event Action<BeatmapSet> SetSelected;
|
||||||
|
public event Action<BeatmapSet, Beatmap> BeatmapSelected;
|
||||||
|
public BeatmapSet BeatmapSet;
|
||||||
|
private FlowContainer difficulties;
|
||||||
private bool collapsed;
|
private bool collapsed;
|
||||||
public bool Collapsed
|
public bool Collapsed
|
||||||
{
|
{
|
||||||
get { return collapsed; }
|
get { return collapsed; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (collapsed == value)
|
||||||
|
return;
|
||||||
collapsed = value;
|
collapsed = value;
|
||||||
|
this.ClearTransformations();
|
||||||
|
const float collapsedAlpha = 0.75f;
|
||||||
|
const float uncollapsedAlpha = 1;
|
||||||
|
Transforms.Add(new TransformAlpha(Clock)
|
||||||
|
{
|
||||||
|
StartValue = collapsed ? uncollapsedAlpha : collapsedAlpha,
|
||||||
|
EndValue = collapsed ? collapsedAlpha : uncollapsedAlpha,
|
||||||
|
StartTime = Time,
|
||||||
|
EndTime = Time + 250,
|
||||||
|
});
|
||||||
if (collapsed)
|
if (collapsed)
|
||||||
Alpha = 0.75f;
|
Remove(difficulties);
|
||||||
else
|
else
|
||||||
Alpha = 1;
|
Add(difficulties);
|
||||||
// TODO: whatever
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapGroup(BeatmapSet beatmapSet)
|
public BeatmapGroup(BeatmapSet beatmapSet)
|
||||||
{
|
{
|
||||||
this.beatmapSet = beatmapSet;
|
BeatmapSet = beatmapSet;
|
||||||
this.collapsed = true;
|
|
||||||
Direction = FlowDirection.VerticalOnly;
|
Direction = FlowDirection.VerticalOnly;
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteText() { Text = this.beatmapSet.Metadata.Title, TextSize = 25 },
|
new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 },
|
||||||
new FlowContainer
|
|
||||||
{
|
|
||||||
Spacing = new Vector2(0, 10),
|
|
||||||
Padding = new MarginPadding { Left = 50 },
|
|
||||||
Direction = FlowDirection.VerticalOnly,
|
|
||||||
Children = this.beatmapSet.Beatmaps.Select(b => new BeatmapButton(this.beatmapSet, b))
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
difficulties = new FlowContainer // Deliberately not added to children
|
||||||
|
{
|
||||||
|
Spacing = new Vector2(0, 10),
|
||||||
|
Padding = new MarginPadding { Left = 50 },
|
||||||
|
Direction = FlowDirection.VerticalOnly,
|
||||||
|
Children = this.BeatmapSet.Beatmaps.Select(b => new BeatmapButton(this.BeatmapSet, b))
|
||||||
|
};
|
||||||
|
collapsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
base.Load(game);
|
SetSelected?.Invoke(BeatmapSet);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using osu.Game.GameModes.Backgrounds;
|
|||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Play
|
namespace osu.Game.GameModes.Play
|
||||||
{
|
{
|
||||||
@ -25,12 +26,26 @@ namespace osu.Game.GameModes.Play
|
|||||||
|
|
||||||
private ScrollContainer scrollContainer;
|
private ScrollContainer scrollContainer;
|
||||||
private FlowContainer setList;
|
private FlowContainer setList;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
setList.Add(group);
|
||||||
|
}
|
||||||
|
|
||||||
private void addBeatmapSets()
|
private void addBeatmapSets()
|
||||||
{
|
{
|
||||||
var sets = beatmaps.GetBeatmapSets();
|
var sets = beatmaps.GetBeatmapSets();
|
||||||
foreach (var beatmapSet in sets)
|
foreach (var beatmapSet in sets)
|
||||||
setList.Add(new BeatmapGroup(beatmapSet));
|
addBeatmapSet(beatmapSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaySongSelect()
|
public PlaySongSelect()
|
||||||
@ -65,8 +80,9 @@ namespace osu.Game.GameModes.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
beatmaps = (game as OsuGameBase).Beatmaps;
|
beatmaps = (game as OsuGameBase).Beatmaps;
|
||||||
beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => setList.Add(new BeatmapGroup(bset)));
|
beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
|
||||||
addBeatmapSets();
|
addBeatmapSets();
|
||||||
|
(setList.Children.First() as BeatmapGroup).Collapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
Loading…
Reference in New Issue
Block a user