2024-02-01 15:19:09 +00: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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2024-02-10 07:02:26 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Game.Graphics.Containers;
|
2024-02-01 15:19:09 +00:00
|
|
|
using osu.Game.Localisation;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI
|
|
|
|
{
|
|
|
|
public partial class OsuAnalysisSettings : AnalysisSettings
|
|
|
|
{
|
|
|
|
protected new DrawableOsuRuleset drawableRuleset => (DrawableOsuRuleset)base.drawableRuleset;
|
|
|
|
|
|
|
|
private readonly PlayerCheckbox hitMarkerToggle;
|
|
|
|
private readonly PlayerCheckbox aimMarkerToggle;
|
|
|
|
private readonly PlayerCheckbox hideCursorToggle;
|
2024-02-10 07:02:26 +00:00
|
|
|
private readonly PlayerCheckbox aimLinesToggle;
|
|
|
|
private readonly FillFlowContainer modTogglesContainer;
|
2024-02-01 15:19:09 +00:00
|
|
|
|
|
|
|
public OsuAnalysisSettings(DrawableRuleset drawableRuleset)
|
|
|
|
: base(drawableRuleset)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
hitMarkerToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.HitMarkers },
|
|
|
|
aimMarkerToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.AimMarkers },
|
2024-02-10 07:02:26 +00:00
|
|
|
aimLinesToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.AimLines },
|
|
|
|
hideCursorToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.HideCursor },
|
|
|
|
new OsuScrollContainer(Direction.Horizontal)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = ModSwitchSmall.DEFAULT_SIZE,
|
|
|
|
ScrollbarOverlapsContent = false,
|
|
|
|
Child = modTogglesContainer = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
AutoSizeAxes = Axes.X
|
|
|
|
}
|
|
|
|
}
|
2024-02-01 15:19:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var mod in drawableRuleset.Mods)
|
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
if (mod is IToggleableVisibility toggleableMod)
|
2024-02-01 15:19:09 +00:00
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
var modSwitch = new SelectableModSwitchSmall(mod)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Active = { Value = true }
|
|
|
|
};
|
|
|
|
modSwitch.Active.BindValueChanged((v) => onModToggle(toggleableMod, v));
|
|
|
|
modTogglesContainer.Add(modSwitch);
|
2024-02-01 15:19:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
drawableRuleset.Playfield.MarkersContainer.HitMarkerEnabled.BindTo(hitMarkerToggle.Current);
|
|
|
|
drawableRuleset.Playfield.MarkersContainer.AimMarkersEnabled.BindTo(aimMarkerToggle.Current);
|
2024-02-10 07:02:26 +00:00
|
|
|
drawableRuleset.Playfield.MarkersContainer.AimLinesEnabled.BindTo(aimLinesToggle.Current);
|
2024-02-01 15:19:09 +00:00
|
|
|
hideCursorToggle.Current.BindValueChanged(onCursorToggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onCursorToggle(ValueChangedEvent<bool> hide)
|
|
|
|
{
|
|
|
|
// this only hides half the cursor
|
|
|
|
if (hide.NewValue)
|
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
drawableRuleset.Playfield.Cursor.FadeOut();
|
2024-02-01 15:19:09 +00:00
|
|
|
} else
|
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
drawableRuleset.Playfield.Cursor.FadeIn();
|
2024-02-01 15:19:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-10 07:02:26 +00:00
|
|
|
private void onModToggle(IToggleableVisibility mod, ValueChangedEvent<bool> toggled)
|
2024-02-01 15:19:09 +00:00
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
if (toggled.NewValue)
|
2024-02-01 15:19:09 +00:00
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
mod.ToggleOnVisibility(drawableRuleset.Playfield);
|
2024-02-01 15:19:09 +00:00
|
|
|
} else
|
|
|
|
{
|
2024-02-10 07:02:26 +00:00
|
|
|
mod.ToggleOffVisibility(drawableRuleset.Playfield);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private partial class SelectableModSwitchSmall : ModSwitchSmall
|
|
|
|
{
|
|
|
|
public SelectableModSwitchSmall(IMod mod)
|
|
|
|
: base(mod)
|
|
|
|
{}
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
Active.Value = !Active.Value;
|
|
|
|
return true;
|
2024-02-01 15:19:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|