mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Tidy namespaces.
This commit is contained in:
139
osu.Game/Beatmaps/Drawable/BeatmapGroup.cs
Normal file
139
osu.Game/Beatmaps/Drawable/BeatmapGroup.cs
Normal file
@ -0,0 +1,139 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
class BeatmapGroup : Container, IStateful<BeatmapGroup.GroupState>
|
||||
{
|
||||
public enum GroupState
|
||||
{
|
||||
Collapsed,
|
||||
Expanded,
|
||||
}
|
||||
|
||||
private const float collapsedAlpha = 0.5f;
|
||||
private const float collapsedWidth = 0.8f;
|
||||
|
||||
private BeatmapInfo selectedBeatmap;
|
||||
public BeatmapInfo SelectedBeatmap
|
||||
{
|
||||
get { return selectedBeatmap; }
|
||||
set
|
||||
{
|
||||
selectedBeatmap = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Action<BeatmapGroup, BeatmapInfo> BeatmapSelected;
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
private BeatmapSetHeader header;
|
||||
private FlowContainer difficulties;
|
||||
private bool collapsed;
|
||||
public GroupState State
|
||||
{
|
||||
get { return collapsed ? GroupState.Collapsed : GroupState.Expanded; }
|
||||
set
|
||||
{
|
||||
bool val = value == GroupState.Collapsed;
|
||||
if (collapsed == val)
|
||||
return;
|
||||
collapsed = val;
|
||||
ClearTransformations();
|
||||
const float uncollapsedAlpha = 1;
|
||||
FadeTo(collapsed ? collapsedAlpha : uncollapsedAlpha, 250);
|
||||
if (collapsed)
|
||||
difficulties.Hide();
|
||||
else
|
||||
difficulties.Show();
|
||||
header.ClearTransformations();
|
||||
header.Width = collapsed ? collapsedWidth : 1; // TODO: Transform
|
||||
header.BorderColour = new Color4(
|
||||
header.BorderColour.R,
|
||||
header.BorderColour.G,
|
||||
header.BorderColour.B,
|
||||
collapsed ? 0 : 255);
|
||||
header.GlowRadius = collapsed ? 0 : 5;
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
BeatmapSet = beatmapSet;
|
||||
selectedBeatmap = beatmapSet.Beatmaps[0];
|
||||
Alpha = collapsedAlpha;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
float difficultyWidth = 1;
|
||||
Children = new[]
|
||||
{
|
||||
new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
header = new BeatmapSetHeader(beatmapSet)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = collapsedWidth,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
difficulties = new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
Padding = new MarginPadding { Left = 75 },
|
||||
Spacing = new Vector2(0, 5),
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Alpha = 0,
|
||||
Children = BeatmapSet.Beatmaps.Select(
|
||||
b => {
|
||||
float width = difficultyWidth;
|
||||
if (difficultyWidth > 0.8f) difficultyWidth -= 0.025f;
|
||||
return new BeatmapPanel(BeatmapSet, b)
|
||||
{
|
||||
MapSelected = updateSelected,
|
||||
Selected = width == 1,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = width,
|
||||
};
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
collapsed = true;
|
||||
}
|
||||
|
||||
private void updateSelected(BeatmapInfo map)
|
||||
{
|
||||
foreach (BeatmapPanel panel in difficulties.Children)
|
||||
panel.Selected = panel.Beatmap == map;
|
||||
BeatmapSelected?.Invoke(this, map);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
BeatmapSelected?.Invoke(this, selectedBeatmap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
108
osu.Game/Beatmaps/Drawable/BeatmapPanel.cs
Normal file
108
osu.Game/Beatmaps/Drawable/BeatmapPanel.cs
Normal file
@ -0,0 +1,108 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
class BeatmapPanel : Container
|
||||
{
|
||||
public BeatmapInfo Beatmap;
|
||||
|
||||
public Action<BeatmapInfo> MapSelected;
|
||||
|
||||
private bool selected;
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get { return selected; }
|
||||
set
|
||||
{
|
||||
if (selected == value)
|
||||
return;
|
||||
selected = value;
|
||||
BorderColour = new Color4(
|
||||
BorderColour.R,
|
||||
BorderColour.G,
|
||||
BorderColour.B,
|
||||
selected ? 255 : 0);
|
||||
GlowRadius = selected ? 3 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapPanel(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
BorderThickness = 2;
|
||||
BorderColour = new Color4(221, 255, 255, 0);
|
||||
GlowColour = new Color4(166, 221, 251, 0.75f); // TODO: Get actual color for this
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = new Color4(40, 86, 102, 255), // TODO: gradient
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Padding = new MarginPadding(5),
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255)),
|
||||
new FlowContainer
|
||||
{
|
||||
Padding = new MarginPadding { Left = 10 },
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Text = beatmap.Version,
|
||||
TextSize = 20,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = string.Format(" mapped by {0}",
|
||||
(beatmap.Metadata ?? set.Metadata).Author),
|
||||
TextSize = 16,
|
||||
},
|
||||
}
|
||||
},
|
||||
new StarCounter { Count = beatmap.BaseDifficulty?.OverallDifficulty ?? 5, StarSize = 8 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
MapSelected?.Invoke(Beatmap);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
80
osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs
Normal file
80
osu.Game/Beatmaps/Drawable/BeatmapSetHeader.cs
Normal file
@ -0,0 +1,80 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
class BeatmapSetHeader : Container
|
||||
{
|
||||
public BeatmapSetHeader(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
BorderThickness = 2;
|
||||
BorderColour = new Color4(221, 255, 255, 0);
|
||||
GlowColour = new Color4(166, 221, 251, 0.5f); // TODO: Get actual color for this
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = new Color4(85, 85, 85, 255),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new Box // TODO: Gradient
|
||||
{
|
||||
Colour = new Color4(0, 0, 0, 100),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
}
|
||||
}
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Spacing = new Vector2(0, 2),
|
||||
Padding = new MarginPadding { Top = 3, Left = 20, Right = 20, Bottom = 3 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
// TODO: Make these italic
|
||||
new SpriteText
|
||||
{
|
||||
Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode,
|
||||
TextSize = 20
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode,
|
||||
TextSize = 16
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
30
osu.Game/Beatmaps/Drawable/DifficultyIcon.cs
Normal file
30
osu.Game/Beatmaps/Drawable/DifficultyIcon.cs
Normal file
@ -0,0 +1,30 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawable
|
||||
{
|
||||
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,
|
||||
Colour = color,
|
||||
Icon = icon
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user