2019-01-24 16:43:03 +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-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-07-15 04:31:15 +08:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2018-07-31 17:00:42 +08:00
|
|
|
|
using osu.Game.Overlays.Mods.Sections;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-01-25 13:10:59 +08:00
|
|
|
|
using osu.Game.Screens;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
|
{
|
|
|
|
|
public class ModSelectOverlay : WaveOverlayContainer
|
|
|
|
|
{
|
2020-02-04 09:21:06 +08:00
|
|
|
|
public const float HEIGHT = 510;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected readonly TriangleButton DeselectAllButton;
|
2019-12-06 17:57:11 +08:00
|
|
|
|
protected readonly TriangleButton CustomiseButton;
|
2019-06-04 00:09:21 +08:00
|
|
|
|
protected readonly TriangleButton CloseButton;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
|
|
|
|
|
protected readonly OsuSpriteText MultiplierLabel;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-26 13:01:15 +08:00
|
|
|
|
protected override bool BlockNonPositionalInput => false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-02 13:48:05 +08:00
|
|
|
|
protected override bool DimMainContent => false;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected readonly FillFlowContainer<ModSection> ModSectionsContainer;
|
|
|
|
|
|
2020-10-14 14:13:49 +08:00
|
|
|
|
protected readonly ModSettingsContainer ModSettingsContainer;
|
2019-10-08 18:34:09 +08:00
|
|
|
|
|
2020-01-30 16:37:52 +08:00
|
|
|
|
public readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-12-12 17:53:25 +08:00
|
|
|
|
private Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-07 14:58:24 +08:00
|
|
|
|
protected Color4 LowMultiplierColour;
|
|
|
|
|
protected Color4 HighMultiplierColour;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-07 14:58:24 +08:00
|
|
|
|
private const float content_width = 0.8f;
|
2020-04-24 13:41:38 +08:00
|
|
|
|
private const float footer_button_spacing = 20;
|
|
|
|
|
|
2019-06-07 14:58:24 +08:00
|
|
|
|
private readonly FillFlowContainer footerContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private SampleChannel sampleOn, sampleOff;
|
|
|
|
|
|
|
|
|
|
public ModSelectOverlay()
|
|
|
|
|
{
|
2020-03-11 09:18:41 +08:00
|
|
|
|
Waves.FirstWaveColour = Color4Extensions.FromHex(@"19b0e2");
|
|
|
|
|
Waves.SecondWaveColour = Color4Extensions.FromHex(@"2280a2");
|
|
|
|
|
Waves.ThirdWaveColour = Color4Extensions.FromHex(@"005774");
|
|
|
|
|
Waves.FourthWaveColour = Color4Extensions.FromHex(@"003a4e");
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-02 03:41:41 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2019-01-25 13:10:59 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING };
|
2018-07-31 17:00:42 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = new Color4(36, 50, 68, 255)
|
|
|
|
|
},
|
|
|
|
|
new Triangles
|
|
|
|
|
{
|
|
|
|
|
TriangleScale = 5,
|
2020-02-02 03:24:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
ColourLight = new Color4(53, 66, 82, 255),
|
|
|
|
|
ColourDark = new Color4(41, 54, 70, 255),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new GridContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 90),
|
|
|
|
|
new Dimension(GridSizeMode.Distributed),
|
2020-04-24 13:34:00 +08:00
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2018-07-31 17:00:42 +08:00
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(10).Opacity(100),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Width = content_width,
|
2019-01-25 13:10:59 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING },
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new OsuSpriteText
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Text = @"Gameplay Mods",
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 22, weight: FontWeight.Bold),
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Shadow = true,
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 4,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new OsuTextFlowContainer(text =>
|
|
|
|
|
{
|
2019-02-20 18:32:30 +08:00
|
|
|
|
text.Font = text.Font.With(size: 18);
|
2018-07-31 17:00:42 +08:00
|
|
|
|
text.Shadow = true;
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Text = "Mods provide different ways to enjoy gameplay. Some have an effect on the score you can achieve during ranked play.\nOthers are just for fun.",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-07 15:42:55 +08:00
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-12-07 15:42:55 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-12-07 15:42:55 +08:00
|
|
|
|
// Body
|
|
|
|
|
new OsuScrollContainer
|
2018-07-31 17:00:42 +08:00
|
|
|
|
{
|
2020-12-07 15:42:55 +08:00
|
|
|
|
ScrollbarVisible = false,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Vertical = 10,
|
|
|
|
|
Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
ModSectionsContainer = new FillFlowContainer<ModSection>
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Spacing = new Vector2(0f, 10f),
|
|
|
|
|
Width = content_width,
|
|
|
|
|
LayoutDuration = 200,
|
|
|
|
|
LayoutEasing = Easing.OutQuint,
|
|
|
|
|
Children = new ModSection[]
|
|
|
|
|
{
|
|
|
|
|
new DifficultyReductionSection { Action = modButtonPressed },
|
|
|
|
|
new DifficultyIncreaseSection { Action = modButtonPressed },
|
|
|
|
|
new AutomationSection { Action = modButtonPressed },
|
|
|
|
|
new ConversionSection { Action = modButtonPressed },
|
|
|
|
|
new FunSection { Action = modButtonPressed },
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
ModSettingsContainer = new ModSettingsContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Width = 0.3f,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Padding = new MarginPadding(30),
|
|
|
|
|
SelectedMods = { BindTarget = SelectedMods },
|
|
|
|
|
},
|
|
|
|
|
}
|
2018-07-31 17:00:42 +08:00
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
// Footer
|
|
|
|
|
new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-24 13:34:00 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
new Box
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = new Color4(172, 20, 116, 255),
|
|
|
|
|
Alpha = 0.5f,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
footerContainer = new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Width = content_width,
|
2020-04-24 13:41:38 +08:00
|
|
|
|
Spacing = new Vector2(footer_button_spacing, footer_button_spacing / 2),
|
2020-04-24 13:44:17 +08:00
|
|
|
|
LayoutDuration = 100,
|
|
|
|
|
LayoutEasing = Easing.OutQuint,
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Padding = new MarginPadding
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-08-14 16:26:25 +08:00
|
|
|
|
Vertical = 15,
|
2019-01-25 13:10:59 +08:00
|
|
|
|
Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
DeselectAllButton = new TriangleButton
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-31 17:00:42 +08:00
|
|
|
|
Width = 180,
|
2019-06-07 14:32:48 +08:00
|
|
|
|
Text = "Deselect All",
|
2021-01-05 15:18:13 +08:00
|
|
|
|
Action = deselectAll,
|
2020-04-24 13:41:38 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2018-07-31 17:00:42 +08:00
|
|
|
|
},
|
2019-12-06 17:57:11 +08:00
|
|
|
|
CustomiseButton = new TriangleButton
|
2019-10-08 18:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
Width = 180,
|
2019-12-11 12:19:13 +08:00
|
|
|
|
Text = "Customisation",
|
2020-12-07 03:35:14 +08:00
|
|
|
|
Action = () => ModSettingsContainer.ToggleVisibility(),
|
2019-12-06 16:09:48 +08:00
|
|
|
|
Enabled = { Value = false },
|
2020-04-24 13:41:38 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2019-10-08 18:34:09 +08:00
|
|
|
|
},
|
2019-06-04 00:09:21 +08:00
|
|
|
|
CloseButton = new TriangleButton
|
|
|
|
|
{
|
|
|
|
|
Width = 180,
|
2019-06-07 14:32:48 +08:00
|
|
|
|
Text = "Close",
|
2019-06-06 02:01:21 +08:00
|
|
|
|
Action = Hide,
|
2020-04-24 13:41:38 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2019-06-04 00:09:21 +08:00
|
|
|
|
},
|
2020-04-24 13:41:38 +08:00
|
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-24 13:41:38 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Spacing = new Vector2(footer_button_spacing / 2, 0),
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Children = new Drawable[]
|
2018-07-31 17:00:42 +08:00
|
|
|
|
{
|
2020-04-24 13:41:38 +08:00
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = @"Score Multiplier:",
|
|
|
|
|
Font = OsuFont.GetFont(size: 30),
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
},
|
2020-04-27 10:29:22 +08:00
|
|
|
|
MultiplierLabel = new OsuSpriteText
|
2020-04-24 13:41:38 +08:00
|
|
|
|
{
|
2020-04-27 10:50:11 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold),
|
2020-04-24 13:41:38 +08:00
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2020-04-28 12:26:42 +08:00
|
|
|
|
Width = 70, // make width fixed so reflow doesn't occur when multiplier number changes.
|
2020-04-24 13:41:38 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
2018-07-31 17:00:42 +08:00
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-31 17:00:42 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2020-10-14 14:21:28 +08:00
|
|
|
|
|
|
|
|
|
((IBindable<bool>)CustomiseButton.Enabled).BindTo(ModSettingsContainer.HasSettingsForSelection);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-06-07 14:58:24 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2020-01-30 16:37:52 +08:00
|
|
|
|
private void load(OsuColour colours, AudioManager audio, OsuGameBase osu)
|
2019-06-07 14:58:24 +08:00
|
|
|
|
{
|
|
|
|
|
LowMultiplierColour = colours.Red;
|
|
|
|
|
HighMultiplierColour = colours.Green;
|
|
|
|
|
|
2019-12-12 17:53:25 +08:00
|
|
|
|
availableMods = osu.AvailableMods.GetBoundCopy();
|
2019-06-07 14:58:24 +08:00
|
|
|
|
|
|
|
|
|
sampleOn = audio.Samples.Get(@"UI/check-on");
|
|
|
|
|
sampleOff = audio.Samples.Get(@"UI/check-off");
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-05 15:18:13 +08:00
|
|
|
|
private void deselectAll()
|
2019-06-07 14:58:24 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
|
|
|
|
section.DeselectAll();
|
|
|
|
|
|
|
|
|
|
refreshSelectedMods();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deselect one or more mods.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
|
|
|
|
|
/// <param name="immediate">Set to true to bypass animations and update selections immediately.</param>
|
2021-01-05 15:18:13 +08:00
|
|
|
|
private void deselectTypes(Type[] modTypes, bool immediate = false)
|
2019-06-07 14:58:24 +08:00
|
|
|
|
{
|
|
|
|
|
if (modTypes.Length == 0) return;
|
|
|
|
|
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
|
|
|
|
section.DeselectTypes(modTypes, immediate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-12-12 17:53:25 +08:00
|
|
|
|
availableMods.BindValueChanged(availableModsChanged, true);
|
2019-06-07 14:58:24 +08:00
|
|
|
|
SelectedMods.BindValueChanged(selectedModsChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
|
|
|
|
|
footerContainer.MoveToX(footerContainer.DrawSize.X, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
|
|
|
|
|
footerContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
|
|
|
|
|
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
|
|
|
|
{
|
|
|
|
|
section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
|
|
|
|
|
section.ButtonsContainer.MoveToX(100f, WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
|
|
|
|
|
section.ButtonsContainer.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InSine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
|
|
|
|
|
footerContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
footerContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
|
|
|
|
{
|
|
|
|
|
section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
section.ButtonsContainer.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
section.ButtonsContainer.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
|
|
|
|
{
|
2020-09-14 02:50:21 +08:00
|
|
|
|
// don't absorb control as ToolbarRulesetSelector uses control + number to navigate
|
|
|
|
|
if (e.ControlPressed) return false;
|
|
|
|
|
|
2019-06-07 14:58:24 +08:00
|
|
|
|
switch (e.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Number1:
|
|
|
|
|
DeselectAllButton.Click();
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case Key.Number2:
|
|
|
|
|
CloseButton.Click();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(e);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 12:17:22 +08:00
|
|
|
|
public override bool OnPressed(GlobalAction action) => false; // handled by back button
|
|
|
|
|
|
2019-12-12 17:53:25 +08:00
|
|
|
|
private void availableModsChanged(ValueChangedEvent<Dictionary<ModType, IReadOnlyList<Mod>>> mods)
|
2019-06-07 14:58:24 +08:00
|
|
|
|
{
|
2019-12-12 17:53:25 +08:00
|
|
|
|
if (mods.NewValue == null) return;
|
2019-06-07 14:58:24 +08:00
|
|
|
|
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
2019-12-12 17:53:25 +08:00
|
|
|
|
section.Mods = mods.NewValue[section.ModType];
|
2019-06-07 14:58:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 12:19:02 +08:00
|
|
|
|
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
2019-06-07 14:58:24 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (var section in ModSectionsContainer.Children)
|
2021-01-01 08:47:13 +08:00
|
|
|
|
section.UpdateSelectedMods(mods.NewValue);
|
2019-06-07 14:58:24 +08:00
|
|
|
|
|
|
|
|
|
updateMods();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateMods()
|
|
|
|
|
{
|
|
|
|
|
var multiplier = 1.0;
|
|
|
|
|
|
|
|
|
|
foreach (var mod in SelectedMods.Value)
|
|
|
|
|
{
|
|
|
|
|
multiplier *= mod.ScoreMultiplier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MultiplierLabel.Text = $"{multiplier:N2}x";
|
|
|
|
|
if (multiplier > 1.0)
|
|
|
|
|
MultiplierLabel.FadeColour(HighMultiplierColour, 200);
|
|
|
|
|
else if (multiplier < 1.0)
|
|
|
|
|
MultiplierLabel.FadeColour(LowMultiplierColour, 200);
|
|
|
|
|
else
|
|
|
|
|
MultiplierLabel.FadeColour(Color4.White, 200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void modButtonPressed(Mod selectedMod)
|
|
|
|
|
{
|
|
|
|
|
if (selectedMod != null)
|
|
|
|
|
{
|
2019-06-11 13:28:52 +08:00
|
|
|
|
if (State.Value == Visibility.Visible) sampleOn?.Play();
|
2020-01-21 12:30:11 +08:00
|
|
|
|
|
2021-01-05 15:18:13 +08:00
|
|
|
|
deselectTypes(selectedMod.IncompatibleMods, true);
|
2020-01-21 12:30:11 +08:00
|
|
|
|
|
2020-12-07 03:35:14 +08:00
|
|
|
|
if (selectedMod.RequiresConfiguration) ModSettingsContainer.Show();
|
2019-06-07 14:58:24 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-06-11 13:28:52 +08:00
|
|
|
|
if (State.Value == Visibility.Visible) sampleOff?.Play();
|
2019-06-07 14:58:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshSelectedMods();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
|
|
|
|
|
|
|
|
|
#region Disposal
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
2019-12-12 23:23:32 +08:00
|
|
|
|
availableMods?.UnbindAll();
|
|
|
|
|
SelectedMods?.UnbindAll();
|
2019-06-07 14:58:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|