2022-07-23 02:01:22 +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.
|
|
|
|
|
2024-03-13 22:18:20 +08:00
|
|
|
using System.Collections.Generic;
|
2022-07-23 02:01:22 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Localisation;
|
2024-03-13 22:18:20 +08:00
|
|
|
using System.Linq;
|
2022-07-23 02:01:22 +08:00
|
|
|
using osu.Game.Graphics;
|
2023-02-16 04:09:55 +08:00
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2022-07-23 02:01:22 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2024-03-13 22:18:20 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-07-23 02:01:22 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public abstract partial class ModSelectColumn : CompositeDrawable, IHasAccentColour
|
2022-07-23 02:01:22 +08:00
|
|
|
{
|
|
|
|
public readonly Container TopLevelContent;
|
|
|
|
|
|
|
|
public LocalisableString HeaderText
|
|
|
|
{
|
|
|
|
set => createHeaderText(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
{
|
|
|
|
get => headerBackground.Colour;
|
2023-02-16 04:09:55 +08:00
|
|
|
set
|
|
|
|
{
|
|
|
|
headerBackground.Colour = value;
|
2023-02-18 04:23:58 +08:00
|
|
|
|
2023-02-16 04:09:55 +08:00
|
|
|
var hsv = new Colour4(value.R, value.G, value.B, 1f).ToHSV();
|
2023-02-18 04:23:58 +08:00
|
|
|
var trianglesColour = Colour4.FromHSV(hsv.X, hsv.Y + 0.2f, hsv.Z - 0.1f);
|
2024-01-23 09:54:27 +08:00
|
|
|
triangles.Colour = ColourInfo.GradientVertical(trianglesColour, value);
|
2023-02-16 04:09:55 +08:00
|
|
|
}
|
2022-07-23 02:01:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Determines whether this column should accept user input.
|
|
|
|
/// </summary>
|
2022-07-25 05:29:18 +08:00
|
|
|
public readonly Bindable<bool> Active = new BindableBool(true);
|
2022-07-23 02:01:22 +08:00
|
|
|
|
2023-05-02 19:15:33 +08:00
|
|
|
public string SearchTerm
|
|
|
|
{
|
2023-05-30 12:38:39 +08:00
|
|
|
set => ItemsFlow.SearchTerm = value;
|
2023-05-02 19:15:33 +08:00
|
|
|
}
|
|
|
|
|
2022-07-23 02:01:22 +08:00
|
|
|
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => base.ReceivePositionalInputAtSubTree(screenSpacePos) && Active.Value;
|
|
|
|
|
|
|
|
protected readonly Container ControlContainer;
|
2023-05-03 19:00:46 +08:00
|
|
|
protected readonly ModSearchContainer ItemsFlow;
|
2022-07-23 02:01:22 +08:00
|
|
|
|
|
|
|
private readonly TextFlowContainer headerText;
|
|
|
|
private readonly Box headerBackground;
|
|
|
|
private readonly Container contentContainer;
|
|
|
|
private readonly Box contentBackground;
|
2023-02-16 04:09:55 +08:00
|
|
|
private readonly TrianglesV2 triangles;
|
2022-07-23 02:01:22 +08:00
|
|
|
|
|
|
|
private const float header_height = 42;
|
|
|
|
|
2023-09-13 16:05:42 +08:00
|
|
|
protected const float WIDTH = 320;
|
|
|
|
|
2022-07-23 02:01:22 +08:00
|
|
|
protected ModSelectColumn()
|
|
|
|
{
|
2023-09-13 16:05:42 +08:00
|
|
|
Width = WIDTH;
|
2022-07-23 02:01:22 +08:00
|
|
|
RelativeSizeAxes = Axes.Y;
|
|
|
|
Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0);
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
TopLevelContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = header_height + ModSelectPanel.CORNER_RADIUS,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
headerBackground = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = header_height + ModSelectPanel.CORNER_RADIUS
|
|
|
|
},
|
2023-02-16 04:09:55 +08:00
|
|
|
triangles = new TrianglesV2
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = header_height,
|
|
|
|
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
2023-02-17 20:16:00 +08:00
|
|
|
Velocity = 0.7f,
|
2024-01-23 09:54:27 +08:00
|
|
|
ClampAxes = Axes.Y
|
2023-02-16 04:09:55 +08:00
|
|
|
},
|
2022-07-23 02:01:22 +08:00
|
|
|
headerText = new OsuTextFlowContainer(t =>
|
|
|
|
{
|
|
|
|
t.Font = OsuFont.TorusAlternate.With(size: 17);
|
|
|
|
t.Shadow = false;
|
|
|
|
t.Colour = Colour4.Black;
|
|
|
|
})
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Horizontal = 17,
|
|
|
|
Bottom = ModSelectPanel.CORNER_RADIUS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Top = header_height },
|
|
|
|
Child = contentContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = ModSelectPanel.CORNER_RADIUS,
|
|
|
|
BorderThickness = 3,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
contentBackground = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension()
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
ControlContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Padding = new MarginPadding { Horizontal = 14 }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuScrollContainer(Direction.Vertical)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ClampExtension = 100,
|
|
|
|
ScrollbarOverlapsContent = false,
|
2023-05-03 19:00:46 +08:00
|
|
|
Child = ItemsFlow = new ModSearchContainer
|
2022-07-23 02:01:22 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(0, 7),
|
|
|
|
Padding = new MarginPadding(7)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createHeaderText(LocalisableString text)
|
|
|
|
{
|
|
|
|
headerText.Clear();
|
|
|
|
|
2024-03-13 22:18:20 +08:00
|
|
|
ITextPart part = headerText.AddText(text);
|
|
|
|
part.DrawablePartsRecreated += applySemiBoldToFirstWord;
|
|
|
|
applySemiBoldToFirstWord(part.Drawables);
|
2022-07-23 02:01:22 +08:00
|
|
|
|
2024-03-13 22:18:20 +08:00
|
|
|
void applySemiBoldToFirstWord(IEnumerable<Drawable> d)
|
2022-07-23 02:01:22 +08:00
|
|
|
{
|
2024-03-13 22:18:20 +08:00
|
|
|
if (d.FirstOrDefault() is OsuSpriteText firstWord)
|
|
|
|
firstWord.Font = firstWord.Font.With(weight: FontWeight.SemiBold);
|
|
|
|
}
|
2022-07-23 02:01:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
contentContainer.BorderColour = ColourInfo.GradientVertical(colourProvider.Background4, colourProvider.Background3);
|
|
|
|
contentBackground.Colour = colourProvider.Background4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|