Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public partial class SettingsListPiece<T> : SettingsPieceBasePanel, ISettingsIte

private readonly CurrentValueText valueText = new CurrentValueText
{
RelativeSizeAxes = Axes.X
RelativeSizeAxes = Axes.X,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
};

public List<T> Values { get; set; }
Expand Down Expand Up @@ -83,7 +85,9 @@ public LocalisableString Text
Alpha = 0,
Font = OsuFont.GetFont(size: 20),
Y = -5,
RelativeSizeAxes = Axes.X
RelativeSizeAxes = Axes.X,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
};

Schedule(() => AddInternal(currentText));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public partial class SettingsPieceBasePanel : CompositeDrawable
Size = new Vector2(25)
};

protected GridContainer FirstLineGrid { get; private set; }

public virtual LocalisableString Description
{
get => description;
Expand Down Expand Up @@ -91,14 +93,6 @@ private void load(AudioManager audio)
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
},
new Container
{
RelativeSizeAxes = Axes.X,
Height = 25,
Margin = new MarginPadding { Top = 10 },
Padding = new MarginPadding { Left = 10 + 25 + 5 },
Child = CreateSideDrawable()
},
FillFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
Expand All @@ -108,7 +102,33 @@ private void load(AudioManager audio)
Spacing = new Vector2(5),
Children = new Drawable[]
{
SpriteIcon,
FirstLineGrid = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
RowDimensions = [new Dimension(GridSizeMode.AutoSize)],
ColumnDimensions =
[
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
],
Content = new[]
{
new Drawable[]
{
SpriteIcon,
CreateSideDrawable().With(d =>
{
d.Anchor = Anchor.CentreLeft;
d.Origin = Anchor.CentreLeft;
d.Margin = new MarginPadding
{
Horizontal = 5,
};
}),
},
},
},
SpriteText,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ private void load()
RelativeSizeAxes = Axes.X;
Width = 1;

SpriteText.Anchor = SpriteText.Origin = SpriteIcon.Anchor = SpriteIcon.Origin = Anchor.BottomRight;
SpriteText.Anchor = SpriteText.Origin = FirstLineGrid.Anchor = FirstLineGrid.Origin = Anchor.BottomRight;
FillFlow.Direction = FillDirection.Horizontal;

SpriteIcon.Hide();
FirstLineGrid.Hide();
}

protected override void OnColorChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Numerics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
Expand All @@ -14,35 +15,73 @@ namespace osu.Game.Rulesets.Hikariii.Features.Player.Graphics.SideBar.Settings.I
public partial class SettingsSlider<T> : OsuSliderBar<T>
where T : struct, INumber<T>, IMinMaxValue<T>, IConvertible
{
/// <summary>
/// Controls whether to show a hint line below the slider body.
/// </summary>
public readonly BindableBool HintActive = new BindableBool();

private Circle baseLine;
private Container circle;

[BackgroundDependencyLoader]
private void load()
{
Height = 1;
Child = circle = new Container

Children = new Drawable[]
{
RelativePositionAxes = Axes.X,
Size = new Vector2(25),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Child = new Circle
baseLine = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Height = 2,
Alpha = 0,
},
circle = new Container
{
RelativePositionAxes = Axes.X,
X = -0.5f
Size = new Vector2(25),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Child = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.X,
X = -0.5f
}
}
};

RangePadding = 0;
}

protected override void LoadComplete()
{
base.LoadComplete();
HintActive.BindValueChanged(onLineStatusChanged);
}

private void onLineStatusChanged(ValueChangedEvent<bool> e)
{
if (e.NewValue)
{
baseLine.ResizeHeightTo(4, 250, Easing.OutExpo);
baseLine.FadeTo(0.8f, 250, Easing.OutExpo);
}
else
{
baseLine.ResizeHeightTo(2, 250, Easing.OutExpo);
baseLine.FadeOut(250, Easing.OutExpo);
}
}

protected override void UpdateValue(float value)
{
circle.MoveToX(value, 250, Easing.OutExpo);
circle.ScaleTo(value + 0.2f, 250, Easing.OutBack);
circle.ScaleTo(value * 0.75f + 0.25f, 250, Easing.OutBack);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

using System;
using System.Numerics;
using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;

namespace osu.Game.Rulesets.Hikariii.Features.Player.Graphics.SideBar.Settings.Items
Expand All @@ -27,17 +29,36 @@ public LocalisableString TooltipText

protected override IconUsage DefaultIcon => FontAwesome.Solid.SlidersH;

protected override Drawable CreateSideDrawable() => new SettingsSlider<T>
protected override Drawable CreateSideDrawable() => slider = new SettingsSlider<T>
{
RelativeSizeAxes = Axes.Both,
Current = Bindable,
DisplayAsPercentage = DisplayAsPercentage,
TransferValueOnCommit = TransferValueOnCommit,
};

[CanBeNull]
private SettingsSlider<T> slider;

protected override void OnMiddleClick()
{
Bindable.Value = Bindable.Default;
}

protected override bool OnHover(HoverEvent e)
{
if (slider != null)
slider.HintActive.Value = true;

return base.OnHover(e);
}

protected override void OnHoverLost(HoverLostEvent e)
{
if (slider != null)
slider.HintActive.Value = false;

base.OnHoverLost(e);
}
}
}
Loading