mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Merge pull request #19622 from bdach/mod-overlay/integration-in-solo
Add mod preset column to solo mod select overlay
This commit is contained in:
commit
21f6fefcde
@ -137,7 +137,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddUntilStep("any column dimmed", () => this.ChildrenOfType<ModColumn>().Any(column => !column.Active.Value));
|
||||
|
||||
ModColumn lastColumn = null;
|
||||
ModSelectColumn lastColumn = null;
|
||||
|
||||
AddAssert("last column dimmed", () => !this.ChildrenOfType<ModColumn>().Last().Active.Value);
|
||||
AddStep("request scroll to last column", () =>
|
||||
|
@ -74,6 +74,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString RestoreAllRecentlyDeletedBeatmaps => new TranslatableString(getKey(@"restore_all_recently_deleted_beatmaps"), @"Restore all recently deleted beatmaps");
|
||||
|
||||
/// <summary>
|
||||
/// "Delete ALL mod presets"
|
||||
/// </summary>
|
||||
public static LocalisableString DeleteAllModPresets => new TranslatableString(getKey(@"delete_all_mod_presets"), @"Delete ALL mod presets");
|
||||
|
||||
/// <summary>
|
||||
/// "Restore all recently deleted mod presets"
|
||||
/// </summary>
|
||||
public static LocalisableString RestoreAllRecentlyDeletedModPresets => new TranslatableString(getKey(@"restore_all_recently_deleted_mod_presets"), @"Restore all recently deleted mod presets");
|
||||
|
||||
private static string getKey(string key) => $"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Localisation;
|
||||
@ -72,6 +74,11 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
protected virtual bool AllowCustomisation => true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the column with available mod presets should be shown.
|
||||
/// </summary>
|
||||
protected virtual bool ShowPresets => false;
|
||||
|
||||
protected virtual ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, false);
|
||||
|
||||
protected virtual IReadOnlyList<Mod> ComputeNewModsFromSelection(IReadOnlyList<Mod> oldSelection, IReadOnlyList<Mod> newSelection) => newSelection;
|
||||
@ -139,40 +146,37 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
MainAreaContent.AddRange(new Drawable[]
|
||||
{
|
||||
new Container
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = (ShowTotalMultiplier ? DifficultyMultiplierDisplay.HEIGHT : 0) + PADDING,
|
||||
Bottom = PADDING
|
||||
},
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
columnScroll = new ColumnScrollContainer
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
ClampExtension = 100,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = columnFlow = new ColumnFlowContainer
|
||||
Top = (ShowTotalMultiplier ? DifficultyMultiplierDisplay.HEIGHT : 0) + PADDING,
|
||||
Bottom = PADDING
|
||||
},
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
columnScroll = new ColumnScrollContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(SHEAR, 0),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Horizontal = 70 },
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
Children = new[]
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
ClampExtension = 100,
|
||||
ScrollbarOverlapsContent = false,
|
||||
Child = columnFlow = new ColumnFlowContainer
|
||||
{
|
||||
createModColumnContent(ModType.DifficultyReduction),
|
||||
createModColumnContent(ModType.DifficultyIncrease),
|
||||
createModColumnContent(ModType.Automation),
|
||||
createModColumnContent(ModType.Conversion),
|
||||
createModColumnContent(ModType.Fun)
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(SHEAR, 0),
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Horizontal = 70 },
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
ChildrenEnumerable = createColumns()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,7 +273,7 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
public void SelectAll()
|
||||
{
|
||||
foreach (var column in columnFlow.Columns)
|
||||
foreach (var column in columnFlow.Columns.OfType<ModColumn>())
|
||||
column.SelectAll();
|
||||
}
|
||||
|
||||
@ -278,10 +282,27 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
public void DeselectAll()
|
||||
{
|
||||
foreach (var column in columnFlow.Columns)
|
||||
foreach (var column in columnFlow.Columns.OfType<ModColumn>())
|
||||
column.DeselectAll();
|
||||
}
|
||||
|
||||
private IEnumerable<ColumnDimContainer> createColumns()
|
||||
{
|
||||
if (ShowPresets)
|
||||
{
|
||||
yield return new ColumnDimContainer(new ModPresetColumn
|
||||
{
|
||||
Margin = new MarginPadding { Right = 10 }
|
||||
});
|
||||
}
|
||||
|
||||
yield return createModColumnContent(ModType.DifficultyReduction);
|
||||
yield return createModColumnContent(ModType.DifficultyIncrease);
|
||||
yield return createModColumnContent(ModType.Automation);
|
||||
yield return createModColumnContent(ModType.Conversion);
|
||||
yield return createModColumnContent(ModType.Fun);
|
||||
}
|
||||
|
||||
private ColumnDimContainer createModColumnContent(ModType modType)
|
||||
{
|
||||
var column = CreateModColumn(modType).With(column =>
|
||||
@ -290,12 +311,7 @@ namespace osu.Game.Overlays.Mods
|
||||
column.Margin = new MarginPadding { Right = 10 };
|
||||
});
|
||||
|
||||
return new ColumnDimContainer(column)
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
RequestScroll = col => columnScroll.ScrollIntoView(col, extraScroll: 140),
|
||||
};
|
||||
return new ColumnDimContainer(column);
|
||||
}
|
||||
|
||||
private void createLocalMods()
|
||||
@ -317,7 +333,7 @@ namespace osu.Game.Overlays.Mods
|
||||
AvailableMods.Value = newLocalAvailableMods;
|
||||
filterMods();
|
||||
|
||||
foreach (var column in columnFlow.Columns)
|
||||
foreach (var column in columnFlow.Columns.OfType<ModColumn>())
|
||||
column.AvailableMods = AvailableMods.Value.GetValueOrDefault(column.ModType, Array.Empty<ModState>());
|
||||
}
|
||||
|
||||
@ -458,7 +474,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
var column = columnFlow[i].Column;
|
||||
|
||||
bool allFiltered = column.AvailableMods.All(modState => modState.Filtered.Value);
|
||||
bool allFiltered = column is ModColumn modColumn && modColumn.AvailableMods.All(modState => modState.Filtered.Value);
|
||||
|
||||
double delay = allFiltered ? 0 : nonFilteredColumnCount * 30;
|
||||
double duration = allFiltered ? 0 : fade_in_duration;
|
||||
@ -516,14 +532,19 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
var column = columnFlow[i].Column;
|
||||
|
||||
bool allFiltered = column.AvailableMods.All(modState => modState.Filtered.Value);
|
||||
bool allFiltered = false;
|
||||
|
||||
if (column is ModColumn modColumn)
|
||||
{
|
||||
allFiltered = modColumn.AvailableMods.All(modState => modState.Filtered.Value);
|
||||
modColumn.FlushPendingSelections();
|
||||
}
|
||||
|
||||
double duration = allFiltered ? 0 : fade_out_duration;
|
||||
float newYPosition = 0;
|
||||
if (!allFiltered)
|
||||
newYPosition = nonFilteredColumnCount % 2 == 0 ? -distance : distance;
|
||||
|
||||
column.FlushPendingSelections();
|
||||
column.TopLevelContent
|
||||
.MoveToY(newYPosition, duration, Easing.OutQuint)
|
||||
.FadeOut(duration, Easing.OutQuint);
|
||||
@ -589,6 +610,7 @@ namespace osu.Game.Overlays.Mods
|
||||
/// <summary>
|
||||
/// Manages horizontal scrolling of mod columns, along with the "active" states of each column based on visibility.
|
||||
/// </summary>
|
||||
[Cached]
|
||||
internal class ColumnScrollContainer : OsuScrollContainer<ColumnFlowContainer>
|
||||
{
|
||||
public ColumnScrollContainer()
|
||||
@ -632,7 +654,7 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
internal class ColumnFlowContainer : FillFlowContainer<ColumnDimContainer>
|
||||
{
|
||||
public IEnumerable<ModColumn> Columns => Children.Select(dimWrapper => dimWrapper.Column);
|
||||
public IEnumerable<ModSelectColumn> Columns => Children.Select(dimWrapper => dimWrapper.Column);
|
||||
|
||||
public override void Add(ColumnDimContainer dimContainer)
|
||||
{
|
||||
@ -648,7 +670,7 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
internal class ColumnDimContainer : Container
|
||||
{
|
||||
public ModColumn Column { get; }
|
||||
public ModSelectColumn Column { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Tracks whether this column is in an interactive state. Generally only the case when the column is on-screen.
|
||||
@ -663,12 +685,21 @@ namespace osu.Game.Overlays.Mods
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
public ColumnDimContainer(ModColumn column)
|
||||
public ColumnDimContainer(ModSelectColumn column)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Child = Column = column;
|
||||
column.Active.BindTo(Active);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ColumnScrollContainer columnScroll)
|
||||
{
|
||||
RequestScroll = col => columnScroll.ScrollIntoView(col, extraScroll: 140);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -677,7 +708,7 @@ namespace osu.Game.Overlays.Mods
|
||||
FinishTransforms();
|
||||
}
|
||||
|
||||
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate || Column.SelectionAnimationRunning;
|
||||
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate || (Column as ModColumn)?.SelectionAnimationRunning == true;
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
|
@ -0,0 +1,89 @@
|
||||
// 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 System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public class ModPresetSettings : SettingsSubsection
|
||||
{
|
||||
protected override LocalisableString Header => "Mod presets";
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private INotificationOverlay? notificationOverlay { get; set; }
|
||||
|
||||
private SettingsButton undeleteButton = null!;
|
||||
private SettingsButton deleteAllButton = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IDialogOverlay? dialogOverlay)
|
||||
{
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
deleteAllButton = new DangerousSettingsButton
|
||||
{
|
||||
Text = MaintenanceSettingsStrings.DeleteAllModPresets,
|
||||
Action = () =>
|
||||
{
|
||||
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
|
||||
{
|
||||
deleteAllButton.Enabled.Value = false;
|
||||
Task.Run(deleteAllModPresets).ContinueWith(t => Schedule(onAllModPresetsDeleted, t));
|
||||
}));
|
||||
}
|
||||
},
|
||||
undeleteButton = new SettingsButton
|
||||
{
|
||||
Text = MaintenanceSettingsStrings.RestoreAllRecentlyDeletedModPresets,
|
||||
Action = () => Task.Run(undeleteModPresets).ContinueWith(t => Schedule(onModPresetsUndeleted, t))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteAllModPresets() =>
|
||||
realm.Write(r =>
|
||||
{
|
||||
foreach (var preset in r.All<ModPreset>())
|
||||
preset.DeletePending = true;
|
||||
});
|
||||
|
||||
private void onAllModPresetsDeleted(Task deletionTask)
|
||||
{
|
||||
deleteAllButton.Enabled.Value = true;
|
||||
|
||||
if (deletionTask.IsCompletedSuccessfully)
|
||||
notificationOverlay?.Post(new ProgressCompletionNotification { Text = "Deleted all mod presets!" });
|
||||
else if (deletionTask.IsFaulted)
|
||||
Logger.Error(deletionTask.Exception, "Failed to delete all mod presets");
|
||||
}
|
||||
|
||||
private void undeleteModPresets() =>
|
||||
realm.Write(r =>
|
||||
{
|
||||
foreach (var preset in r.All<ModPreset>().Where(preset => preset.DeletePending))
|
||||
preset.DeletePending = false;
|
||||
});
|
||||
|
||||
private void onModPresetsUndeleted(Task undeletionTask)
|
||||
{
|
||||
undeleteButton.Enabled.Value = true;
|
||||
|
||||
if (undeletionTask.IsCompletedSuccessfully)
|
||||
notificationOverlay?.Post(new ProgressCompletionNotification { Text = "Restored all deleted mod presets!" });
|
||||
else if (undeletionTask.IsFaulted)
|
||||
Logger.Error(undeletionTask.Exception, "Failed to restore mod presets");
|
||||
}
|
||||
}
|
||||
}
|
@ -25,7 +25,8 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
new BeatmapSettings(),
|
||||
new SkinSettings(),
|
||||
new CollectionsSettings(),
|
||||
new ScoreSettings()
|
||||
new ScoreSettings(),
|
||||
new ModPresetSettings()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ namespace osu.Game.Screens.Select
|
||||
(new FooterButtonOptions(), BeatmapOptions)
|
||||
};
|
||||
|
||||
protected virtual ModSelectOverlay CreateModSelectOverlay() => new UserModSelectOverlay();
|
||||
protected virtual ModSelectOverlay CreateModSelectOverlay() => new SoloModSelectOverlay();
|
||||
|
||||
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
|
||||
{
|
||||
@ -927,5 +927,10 @@ namespace osu.Game.Screens.Select
|
||||
return base.OnHover(e);
|
||||
}
|
||||
}
|
||||
|
||||
private class SoloModSelectOverlay : UserModSelectOverlay
|
||||
{
|
||||
protected override bool ShowPresets => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user