2019-03-04 12:24:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-11-06 18:23:03 +08:00
|
|
|
|
2018-11-22 16:25:46 +08:00
|
|
|
using System;
|
2018-11-06 18:23:03 +08:00
|
|
|
using osu.Framework.Allocation;
|
2018-11-11 00:29:42 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-11-06 18:23:03 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-05-15 11:08:23 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-11-06 18:23:03 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-11-22 16:25:46 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-11-06 18:23:03 +08:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Screens.Menu;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-11-06 18:23:03 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
|
|
|
public class SongBar : CompositeDrawable
|
|
|
|
{
|
|
|
|
private BeatmapInfo beatmap;
|
|
|
|
|
|
|
|
public BeatmapInfo Beatmap
|
|
|
|
{
|
|
|
|
get => beatmap;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (beatmap == value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
beatmap = value;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private LegacyMods mods;
|
|
|
|
|
|
|
|
public LegacyMods Mods
|
|
|
|
{
|
|
|
|
get => mods;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
mods = value;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Container panelContents;
|
2018-11-11 00:29:42 +08:00
|
|
|
private Container innerPanel;
|
|
|
|
private Container outerPanel;
|
2018-11-16 17:14:42 +08:00
|
|
|
private TournamentBeatmapPanel panel;
|
|
|
|
|
|
|
|
private float panelWidth => expanded ? 0.6f : 1;
|
2018-11-11 00:29:42 +08:00
|
|
|
|
|
|
|
private const float main_width = 0.97f;
|
2018-11-22 12:17:51 +08:00
|
|
|
private const float inner_panel_width = 0.7f;
|
2018-11-11 00:29:42 +08:00
|
|
|
|
2018-11-16 17:14:42 +08:00
|
|
|
private bool expanded;
|
|
|
|
|
2018-11-11 00:29:42 +08:00
|
|
|
public bool Expanded
|
|
|
|
{
|
2018-11-16 17:14:42 +08:00
|
|
|
get => expanded;
|
2018-11-11 00:29:42 +08:00
|
|
|
set
|
|
|
|
{
|
2018-11-16 17:14:42 +08:00
|
|
|
expanded = value;
|
2018-11-16 18:43:54 +08:00
|
|
|
panel?.ResizeWidthTo(panelWidth, 800, Easing.OutQuint);
|
2018-11-16 17:14:42 +08:00
|
|
|
|
|
|
|
if (expanded)
|
2018-11-11 00:29:42 +08:00
|
|
|
{
|
2018-11-22 12:17:51 +08:00
|
|
|
innerPanel.ResizeWidthTo(inner_panel_width, 800, Easing.OutQuint);
|
2018-11-11 00:29:42 +08:00
|
|
|
outerPanel.ResizeWidthTo(main_width, 800, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
innerPanel.ResizeWidthTo(1, 800, Easing.OutQuint);
|
2018-11-16 18:43:54 +08:00
|
|
|
outerPanel.ResizeWidthTo(0.25f, 800, Easing.OutQuint);
|
2018-11-11 00:29:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 18:23:03 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2018-11-11 00:29:42 +08:00
|
|
|
outerPanel = new Container
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
|
|
|
Masking = true,
|
2018-11-11 00:29:42 +08:00
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Radius = 5,
|
|
|
|
},
|
2018-11-06 18:23:03 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
2018-11-11 00:29:42 +08:00
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
X = -(1 - main_width) / 2,
|
2018-11-06 18:23:03 +08:00
|
|
|
Y = -10,
|
2018-11-16 17:14:42 +08:00
|
|
|
Width = main_width,
|
2018-11-06 18:23:03 +08:00
|
|
|
Height = TournamentBeatmapPanel.HEIGHT,
|
|
|
|
CornerRadius = TournamentBeatmapPanel.HEIGHT / 2,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.Gray(0.93f),
|
|
|
|
},
|
2018-11-16 17:14:42 +08:00
|
|
|
new OsuLogo
|
|
|
|
{
|
|
|
|
Triangles = false,
|
|
|
|
Colour = OsuColour.Gray(0.33f),
|
|
|
|
Scale = new Vector2(0.08f),
|
|
|
|
Margin = new MarginPadding(50),
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
},
|
2018-11-11 00:29:42 +08:00
|
|
|
innerPanel = new Container
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = TournamentBeatmapPanel.HEIGHT / 2,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-11-22 12:17:51 +08:00
|
|
|
Width = inner_panel_width,
|
2018-11-06 18:23:03 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = OsuColour.Gray(0.86f),
|
|
|
|
},
|
|
|
|
panelContents = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-11-22 12:17:51 +08:00
|
|
|
|
|
|
|
Expanded = true;
|
2018-11-06 18:23:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void update()
|
|
|
|
{
|
|
|
|
if (beatmap == null)
|
|
|
|
{
|
|
|
|
panelContents.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-08 15:43:35 +08:00
|
|
|
var bpm = beatmap.BeatmapSet.OnlineInfo.BPM;
|
2019-07-08 01:25:36 +08:00
|
|
|
var length = beatmap.Length;
|
2018-11-22 13:10:33 +08:00
|
|
|
string hardRockExtra = "";
|
|
|
|
string srExtra = "";
|
2018-11-06 18:23:03 +08:00
|
|
|
|
2019-03-04 11:06:41 +08:00
|
|
|
//var ar = beatmap.BaseDifficulty.ApproachRate;
|
2018-11-22 13:10:33 +08:00
|
|
|
if ((mods & LegacyMods.HardRock) > 0)
|
|
|
|
{
|
|
|
|
hardRockExtra = "*";
|
|
|
|
srExtra = "*";
|
|
|
|
}
|
2018-11-06 18:23:03 +08:00
|
|
|
|
|
|
|
if ((mods & LegacyMods.DoubleTime) > 0)
|
|
|
|
{
|
|
|
|
//ar *= 1.5f;
|
|
|
|
bpm *= 1.5f;
|
|
|
|
length /= 1.5f;
|
2018-11-22 13:10:33 +08:00
|
|
|
srExtra = "*";
|
2018-11-06 18:23:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
panelContents.Children = new Drawable[]
|
|
|
|
{
|
2019-07-09 22:53:34 +08:00
|
|
|
new DiffPiece(("Length", TimeSpan.FromMilliseconds(length).ToString(@"mm\:ss")))
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
2018-11-22 16:25:46 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2018-11-06 18:23:03 +08:00
|
|
|
},
|
2018-11-22 16:25:46 +08:00
|
|
|
new DiffPiece(("BPM", $"{bpm:0.#}"))
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
2018-11-22 16:25:46 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.TopLeft
|
2018-11-06 18:23:03 +08:00
|
|
|
},
|
2019-02-03 10:24:43 +08:00
|
|
|
new DiffPiece(
|
|
|
|
//("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
|
|
|
//("AR", $"{ar:0.#}{srExtra}"),
|
|
|
|
("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
|
|
|
("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
|
|
|
|
)
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
2018-11-22 16:25:46 +08:00
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.BottomRight
|
2018-11-06 18:23:03 +08:00
|
|
|
},
|
2018-11-22 16:25:46 +08:00
|
|
|
new DiffPiece(("Star Rating", $"{beatmap.StarDifficulty:0.#}{srExtra}"))
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
2018-11-22 16:25:46 +08:00
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.TopRight
|
2018-11-06 18:23:03 +08:00
|
|
|
},
|
2018-11-16 17:14:42 +08:00
|
|
|
panel = new TournamentBeatmapPanel(beatmap)
|
2018-11-06 18:23:03 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
2018-11-16 17:14:42 +08:00
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(panelWidth, 1)
|
2018-11-06 18:23:03 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2018-11-22 16:25:46 +08:00
|
|
|
|
|
|
|
public class DiffPiece : TextFlowContainer
|
|
|
|
{
|
|
|
|
public DiffPiece(params (string heading, string content)[] tuples)
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding { Horizontal = 15, Vertical = 1 };
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
void cp(SpriteText s, Color4 colour)
|
|
|
|
{
|
|
|
|
s.Colour = colour;
|
2019-03-04 11:06:41 +08:00
|
|
|
s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15);
|
2018-11-22 16:25:46 +08:00
|
|
|
}
|
|
|
|
|
2019-06-13 16:04:57 +08:00
|
|
|
for (var i = 0; i < tuples.Length; i++)
|
2018-11-22 16:25:46 +08:00
|
|
|
{
|
2019-06-13 16:04:57 +08:00
|
|
|
var tuple = tuples[i];
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
{
|
2018-11-22 16:25:46 +08:00
|
|
|
AddText(" / ", s =>
|
|
|
|
{
|
|
|
|
cp(s, OsuColour.Gray(0.33f));
|
|
|
|
s.Spacing = new Vector2(-2, 0);
|
|
|
|
});
|
2019-06-13 16:04:57 +08:00
|
|
|
}
|
2018-11-22 16:25:46 +08:00
|
|
|
|
2019-06-13 16:04:57 +08:00
|
|
|
AddText(new OsuSpriteText { Text = tuple.heading }, s => cp(s, OsuColour.Gray(0.33f)));
|
2018-11-22 16:25:46 +08:00
|
|
|
AddText(" ", s => cp(s, OsuColour.Gray(0.33f)));
|
2019-06-13 16:04:57 +08:00
|
|
|
AddText(new OsuSpriteText { Text = tuple.content }, s => cp(s, OsuColour.Gray(0.5f)));
|
2018-11-22 16:25:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 18:23:03 +08:00
|
|
|
}
|
|
|
|
}
|