mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 00:37:18 +08:00
Merge branch 'master' into irenderer-glwrapper
This commit is contained in:
commit
e1189da824
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
connectionPool = new DrawablePool<FollowPointConnection>(1, 200),
|
||||
connectionPool = new DrawablePool<FollowPointConnection>(10, 200),
|
||||
pointPool = new DrawablePool<FollowPoint>(50, 1000)
|
||||
};
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
@ -112,21 +114,36 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuRulesetConfigManager config)
|
||||
private void load(OsuRulesetConfigManager config, IBeatmap beatmap)
|
||||
{
|
||||
config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle);
|
||||
|
||||
RegisterPool<HitCircle, DrawableHitCircle>(10, 100);
|
||||
var osuBeatmap = (OsuBeatmap)beatmap;
|
||||
|
||||
RegisterPool<Slider, DrawableSlider>(10, 100);
|
||||
RegisterPool<SliderHeadCircle, DrawableSliderHead>(10, 100);
|
||||
RegisterPool<SliderTailCircle, DrawableSliderTail>(10, 100);
|
||||
RegisterPool<SliderTick, DrawableSliderTick>(10, 100);
|
||||
RegisterPool<SliderRepeat, DrawableSliderRepeat>(5, 50);
|
||||
RegisterPool<HitCircle, DrawableHitCircle>(20, 100);
|
||||
|
||||
// handle edge cases where a beatmap has a slider with many repeats.
|
||||
int maxRepeatsOnOneSlider = 0;
|
||||
int maxTicksOnOneSlider = 0;
|
||||
|
||||
if (osuBeatmap != null)
|
||||
{
|
||||
foreach (var slider in osuBeatmap.HitObjects.OfType<Slider>())
|
||||
{
|
||||
maxRepeatsOnOneSlider = Math.Max(maxRepeatsOnOneSlider, slider.RepeatCount);
|
||||
maxTicksOnOneSlider = Math.Max(maxTicksOnOneSlider, slider.NestedHitObjects.OfType<SliderTick>().Count());
|
||||
}
|
||||
}
|
||||
|
||||
RegisterPool<Slider, DrawableSlider>(20, 100);
|
||||
RegisterPool<SliderHeadCircle, DrawableSliderHead>(20, 100);
|
||||
RegisterPool<SliderTailCircle, DrawableSliderTail>(20, 100);
|
||||
RegisterPool<SliderTick, DrawableSliderTick>(Math.Max(maxTicksOnOneSlider, 20), Math.Max(maxTicksOnOneSlider, 200));
|
||||
RegisterPool<SliderRepeat, DrawableSliderRepeat>(Math.Max(maxRepeatsOnOneSlider, 20), Math.Max(maxRepeatsOnOneSlider, 200));
|
||||
|
||||
RegisterPool<Spinner, DrawableSpinner>(2, 20);
|
||||
RegisterPool<SpinnerTick, DrawableSpinnerTick>(10, 100);
|
||||
RegisterPool<SpinnerBonusTick, DrawableSpinnerBonusTick>(10, 100);
|
||||
RegisterPool<SpinnerTick, DrawableSpinnerTick>(10, 200);
|
||||
RegisterPool<SpinnerBonusTick, DrawableSpinnerBonusTick>(10, 200);
|
||||
}
|
||||
|
||||
protected override HitObjectLifetimeEntry CreateLifetimeEntry(HitObject hitObject) => new OsuHitObjectLifetimeEntry(hitObject);
|
||||
@ -173,7 +190,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
private readonly Action<DrawableOsuJudgement> onLoaded;
|
||||
|
||||
public DrawableJudgementPool(HitResult result, Action<DrawableOsuJudgement> onLoaded)
|
||||
: base(10)
|
||||
: base(20)
|
||||
{
|
||||
this.result = result;
|
||||
this.onLoaded = onLoaded;
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -148,6 +149,16 @@ namespace osu.Game.Tests.Online
|
||||
Assert.That(apiMod.Settings["speed_change"], Is.EqualTo(1.01d));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerialisedModSettingPresence()
|
||||
{
|
||||
var mod = new TestMod();
|
||||
|
||||
mod.TestSetting.Value = mod.TestSetting.Default;
|
||||
JObject serialised = JObject.Parse(JsonConvert.SerializeObject(new APIMod(mod)));
|
||||
Assert.False(serialised.ContainsKey("settings"));
|
||||
}
|
||||
|
||||
private class TestRuleset : Ruleset
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[]
|
||||
|
@ -200,10 +200,12 @@ namespace osu.Game.Tests.Visual.Collections
|
||||
AddStep("click confirmation", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(dialogOverlay.CurrentDialog.ChildrenOfType<PopupDialogButton>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
assertCollectionCount(0);
|
||||
|
||||
AddStep("release mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -190,7 +190,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
AddAssert("track stopped", () => !track.IsRunning);
|
||||
}
|
||||
|
||||
private TestPreviewTrackManager.TestPreviewTrack getTrack() => (TestPreviewTrackManager.TestPreviewTrack)trackManager.Get(null);
|
||||
private TestPreviewTrackManager.TestPreviewTrack getTrack() => (TestPreviewTrackManager.TestPreviewTrack)trackManager.Get(CreateAPIBeatmapSet());
|
||||
|
||||
private TestPreviewTrackManager.TestPreviewTrack getOwnedTrack()
|
||||
{
|
||||
|
@ -56,8 +56,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Test]
|
||||
public void TestCreateNewBeatmap()
|
||||
{
|
||||
AddAssert("status is none", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.None);
|
||||
AddStep("save beatmap", () => Editor.Save());
|
||||
AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == currentBeatmapSetID)?.Value.DeletePending == false);
|
||||
AddAssert("status is modified", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.LocallyModified);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -208,6 +210,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
AddAssert("created difficulty has no objects", () => EditorBeatmap.HitObjects.Count == 0);
|
||||
|
||||
AddAssert("status is modified", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.LocallyModified);
|
||||
|
||||
AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = secondDifficultyName);
|
||||
AddStep("save beatmap", () => Editor.Save());
|
||||
AddAssert("new beatmap persisted", () =>
|
||||
@ -218,7 +222,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
return beatmap != null
|
||||
&& beatmap.DifficultyName == secondDifficultyName
|
||||
&& set != null
|
||||
&& set.PerformRead(s => s.Beatmaps.Count == 2 && s.Beatmaps.Any(b => b.DifficultyName == secondDifficultyName));
|
||||
&& set.PerformRead(s => s.Beatmaps.Count == 2 && s.Beatmaps.Any(b => b.DifficultyName == secondDifficultyName) && s.Beatmaps.All(b => s.Status == BeatmapOnlineStatus.LocallyModified));
|
||||
});
|
||||
}
|
||||
|
||||
@ -294,7 +298,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("approach rate correctly copied", () => EditorBeatmap.Difficulty.ApproachRate == 4);
|
||||
AddAssert("combo colours correctly copied", () => EditorBeatmap.BeatmapSkin.AsNonNull().ComboColours.Count == 2);
|
||||
|
||||
AddAssert("status not copied", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.None);
|
||||
AddAssert("status is modified", () => EditorBeatmap.BeatmapInfo.Status == BeatmapOnlineStatus.LocallyModified);
|
||||
AddAssert("online ID not copied", () => EditorBeatmap.BeatmapInfo.OnlineID == -1);
|
||||
|
||||
AddStep("save beatmap", () => Editor.Save());
|
||||
|
@ -83,6 +83,20 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Beatmap = dummyBeatmap,
|
||||
},
|
||||
new APIRecentActivity
|
||||
{
|
||||
User = dummyUser,
|
||||
Type = RecentActivityType.BeatmapsetApprove,
|
||||
Approval = BeatmapApproval.Approved,
|
||||
Beatmapset = dummyBeatmap,
|
||||
},
|
||||
new APIRecentActivity
|
||||
{
|
||||
User = dummyUser,
|
||||
Type = RecentActivityType.BeatmapsetApprove,
|
||||
Approval = BeatmapApproval.Loved,
|
||||
Beatmapset = dummyBeatmap,
|
||||
},
|
||||
new APIRecentActivity
|
||||
{
|
||||
User = dummyUser,
|
||||
Type = RecentActivityType.BeatmapsetApprove,
|
||||
@ -90,6 +104,13 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Beatmapset = dummyBeatmap,
|
||||
},
|
||||
new APIRecentActivity
|
||||
{
|
||||
User = dummyUser,
|
||||
Type = RecentActivityType.BeatmapsetApprove,
|
||||
Approval = BeatmapApproval.Ranked,
|
||||
Beatmapset = dummyBeatmap,
|
||||
},
|
||||
new APIRecentActivity
|
||||
{
|
||||
User = dummyUser,
|
||||
Type = RecentActivityType.BeatmapsetDelete,
|
||||
|
@ -11,9 +11,11 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
@ -35,16 +37,27 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Cached(typeof(IDialogOverlay))]
|
||||
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
base.Content.Add(content = new PopoverContainer
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(30),
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = content = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(30),
|
||||
}
|
||||
},
|
||||
dialogOverlay
|
||||
});
|
||||
}
|
||||
|
||||
@ -205,6 +218,46 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddUntilStep("popover closed", () => !this.ChildrenOfType<OsuPopover>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeleteFlow()
|
||||
{
|
||||
ModPresetColumn modPresetColumn = null!;
|
||||
|
||||
AddStep("create content", () => Child = modPresetColumn = new ModPresetColumn
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
|
||||
AddUntilStep("items loaded", () => modPresetColumn.IsLoaded && modPresetColumn.ItemsLoaded);
|
||||
AddStep("right click first panel", () =>
|
||||
{
|
||||
var panel = this.ChildrenOfType<ModPresetPanel>().First();
|
||||
InputManager.MoveMouseTo(panel);
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for context menu", () => this.ChildrenOfType<OsuContextMenu>().Any());
|
||||
AddStep("click delete", () =>
|
||||
{
|
||||
var deleteItem = this.ChildrenOfType<DrawableOsuMenuItem>().Single();
|
||||
InputManager.MoveMouseTo(deleteItem);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for dialog", () => dialogOverlay.CurrentDialog is DeleteModPresetDialog);
|
||||
AddStep("hold confirm", () =>
|
||||
{
|
||||
var confirmButton = this.ChildrenOfType<PopupDialogDangerousButton>().Single();
|
||||
InputManager.MoveMouseTo(confirmButton);
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("wait for dialog to close", () => dialogOverlay.CurrentDialog == null);
|
||||
AddStep("release mouse", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
AddUntilStep("preset deletion occurred", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2);
|
||||
AddAssert("preset soft-deleted", () => Realm.Run(r => r.All<ModPreset>().Count(preset => preset.DeletePending) == 1));
|
||||
}
|
||||
|
||||
private ICollection<ModPreset> createTestPresets() => new[]
|
||||
{
|
||||
new ModPreset
|
||||
|
@ -1,12 +1,15 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
@ -23,6 +26,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("reset selected mods", () => SelectedMods.SetDefault());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVariousModPresets()
|
||||
{
|
||||
@ -37,6 +46,78 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPresetSelectionStateAfterExternalModChanges()
|
||||
{
|
||||
ModPresetPanel? panel = null;
|
||||
|
||||
AddStep("create panel", () => Child = panel = new ModPresetPanel(createTestPresets().First().ToLiveUnmanaged())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 0.5f
|
||||
});
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to HR", () => SelectedMods.Value = new[] { new OsuModHardRock() });
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to DT", () => SelectedMods.Value = new[] { new OsuModDoubleTime() });
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to HR+DT", () => SelectedMods.Value = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
AddAssert("panel is active", () => panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to HR+customised DT", () => SelectedMods.Value = new Mod[]
|
||||
{
|
||||
new OsuModHardRock(),
|
||||
new OsuModDoubleTime
|
||||
{
|
||||
SpeedChange = { Value = 1.25 }
|
||||
}
|
||||
});
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to HR+DT", () => SelectedMods.Value = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
AddAssert("panel is active", () => panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("customise mod in place", () => SelectedMods.Value.OfType<OsuModDoubleTime>().Single().SpeedChange.Value = 1.33);
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
|
||||
AddStep("set mods to HD+HR+DT", () => SelectedMods.Value = new Mod[] { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
AddAssert("panel is not active", () => !panel.AsNonNull().Active.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestActivatingPresetTogglesIncludedMods()
|
||||
{
|
||||
ModPresetPanel? panel = null;
|
||||
|
||||
AddStep("create panel", () => Child = panel = new ModPresetPanel(createTestPresets().First().ToLiveUnmanaged())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 0.5f
|
||||
});
|
||||
|
||||
AddStep("activate panel", () => panel.AsNonNull().TriggerClick());
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
|
||||
AddStep("deactivate panel", () => panel.AsNonNull().TriggerClick());
|
||||
assertSelectedModsEquivalentTo(Array.Empty<Mod>());
|
||||
|
||||
AddStep("set different mod", () => SelectedMods.Value = new[] { new OsuModHidden() });
|
||||
AddStep("activate panel", () => panel.AsNonNull().TriggerClick());
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() });
|
||||
|
||||
AddStep("set customised mod", () => SelectedMods.Value = new[] { new OsuModDoubleTime { SpeedChange = { Value = 1.25 } } });
|
||||
AddStep("activate panel", () => panel.AsNonNull().TriggerClick());
|
||||
assertSelectedModsEquivalentTo(new Mod[] { new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.5 } } });
|
||||
}
|
||||
|
||||
private void assertSelectedModsEquivalentTo(IEnumerable<Mod> mods)
|
||||
=> AddAssert("selected mods changed correctly", () => new HashSet<Mod>(SelectedMods.Value).SetEquals(mods));
|
||||
|
||||
private static IEnumerable<ModPreset> createTestPresets() => new[]
|
||||
{
|
||||
new ModPreset
|
||||
|
@ -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", () =>
|
||||
|
@ -121,7 +121,8 @@ namespace osu.Game.Beatmaps
|
||||
OnlineID = -1;
|
||||
LastOnlineUpdate = null;
|
||||
OnlineMD5Hash = string.Empty;
|
||||
Status = BeatmapOnlineStatus.None;
|
||||
if (Status != BeatmapOnlineStatus.LocallyModified)
|
||||
Status = BeatmapOnlineStatus.None;
|
||||
}
|
||||
|
||||
#region Properties we may not want persisted (but also maybe no harm?)
|
||||
|
@ -313,9 +313,12 @@ namespace osu.Game.Beatmaps
|
||||
beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
|
||||
beatmapInfo.Hash = stream.ComputeSHA2Hash();
|
||||
|
||||
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
||||
|
||||
AddFile(setInfo, stream, createBeatmapFilenameFromMetadata(beatmapInfo));
|
||||
|
||||
setInfo.Hash = beatmapImporter.ComputeHash(setInfo);
|
||||
setInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
||||
|
||||
Realm.Write(r =>
|
||||
{
|
||||
|
@ -3,13 +3,23 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public enum BeatmapOnlineStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a special status given when local changes are made via the editor.
|
||||
/// Once in this state, online status changes should be ignored unless the beatmap is reverted or submitted.
|
||||
/// </summary>
|
||||
[Description("Local")]
|
||||
[LocalisableDescription(typeof(SongSelectStrings), nameof(SongSelectStrings.LocallyModified))]
|
||||
LocallyModified = -4,
|
||||
|
||||
None = -3,
|
||||
|
||||
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowStatusGraveyard))]
|
||||
|
@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using osu.Framework.Development;
|
||||
@ -51,6 +52,9 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Queue an update for a beatmap set.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This may happen during initial import, or at a later stage in response to a user action or server event.
|
||||
/// </remarks>
|
||||
/// <param name="beatmapSet">The beatmap set to update. Updates will be applied directly (so a transaction should be started if this instance is managed).</param>
|
||||
/// <param name="preferOnlineFetch">Whether metadata from an online source should be preferred. If <c>true</c>, the local cache will be skipped to ensure the freshest data state possible.</param>
|
||||
public void Update(BeatmapSetInfo beatmapSet, bool preferOnlineFetch)
|
||||
@ -89,21 +93,26 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
beatmapInfo.Status = res.Status;
|
||||
|
||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||
|
||||
beatmapInfo.BeatmapSet.Status = res.BeatmapSet?.Status ?? BeatmapOnlineStatus.None;
|
||||
beatmapInfo.BeatmapSet.OnlineID = res.OnlineBeatmapSetID;
|
||||
beatmapInfo.BeatmapSet.DateRanked = res.BeatmapSet?.Ranked;
|
||||
beatmapInfo.BeatmapSet.DateSubmitted = res.BeatmapSet?.Submitted;
|
||||
|
||||
beatmapInfo.OnlineID = res.OnlineID;
|
||||
beatmapInfo.OnlineMD5Hash = res.MD5Hash;
|
||||
beatmapInfo.LastOnlineUpdate = res.LastUpdated;
|
||||
|
||||
beatmapInfo.OnlineID = res.OnlineID;
|
||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||
beatmapInfo.BeatmapSet.OnlineID = res.OnlineBeatmapSetID;
|
||||
|
||||
beatmapInfo.Metadata.Author.OnlineID = res.AuthorID;
|
||||
// Some metadata should only be applied if there's no local changes.
|
||||
if (shouldSaveOnlineMetadata(beatmapInfo))
|
||||
{
|
||||
beatmapInfo.Status = res.Status;
|
||||
beatmapInfo.Metadata.Author.OnlineID = res.AuthorID;
|
||||
}
|
||||
|
||||
if (beatmapInfo.BeatmapSet.Beatmaps.All(shouldSaveOnlineMetadata))
|
||||
{
|
||||
beatmapInfo.BeatmapSet.Status = res.BeatmapSet?.Status ?? BeatmapOnlineStatus.None;
|
||||
beatmapInfo.BeatmapSet.DateRanked = res.BeatmapSet?.Ranked;
|
||||
beatmapInfo.BeatmapSet.DateSubmitted = res.BeatmapSet?.Submitted;
|
||||
}
|
||||
|
||||
logForModel(set, $"Online retrieval mapped {beatmapInfo} to {res.OnlineBeatmapSetID} / {res.OnlineID}.");
|
||||
}
|
||||
@ -202,19 +211,26 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
var status = (BeatmapOnlineStatus)reader.GetByte(2);
|
||||
|
||||
beatmapInfo.Status = status;
|
||||
// Some metadata should only be applied if there's no local changes.
|
||||
if (shouldSaveOnlineMetadata(beatmapInfo))
|
||||
{
|
||||
beatmapInfo.Status = status;
|
||||
beatmapInfo.Metadata.Author.OnlineID = reader.GetInt32(3);
|
||||
}
|
||||
|
||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||
|
||||
beatmapInfo.BeatmapSet.Status = status;
|
||||
beatmapInfo.BeatmapSet.OnlineID = reader.GetInt32(0);
|
||||
// TODO: DateSubmitted and DateRanked are not provided by local cache.
|
||||
beatmapInfo.OnlineID = reader.GetInt32(1);
|
||||
beatmapInfo.Metadata.Author.OnlineID = reader.GetInt32(3);
|
||||
|
||||
beatmapInfo.OnlineMD5Hash = reader.GetString(4);
|
||||
beatmapInfo.LastOnlineUpdate = reader.GetDateTimeOffset(5);
|
||||
|
||||
Debug.Assert(beatmapInfo.BeatmapSet != null);
|
||||
beatmapInfo.BeatmapSet.OnlineID = reader.GetInt32(0);
|
||||
|
||||
if (beatmapInfo.BeatmapSet.Beatmaps.All(shouldSaveOnlineMetadata))
|
||||
{
|
||||
beatmapInfo.BeatmapSet.Status = status;
|
||||
}
|
||||
|
||||
logForModel(set, $"Cached local retrieval for {beatmapInfo}.");
|
||||
return true;
|
||||
}
|
||||
@ -233,6 +249,12 @@ namespace osu.Game.Beatmaps
|
||||
private void logForModel(BeatmapSetInfo set, string message) =>
|
||||
RealmArchiveModelImporter<BeatmapSetInfo>.LogForModel(set, $"[{nameof(BeatmapUpdaterMetadataLookup)}] {message}");
|
||||
|
||||
/// <summary>
|
||||
/// Check whether the provided beatmap is in a state where online "ranked" status metadata should be saved against it.
|
||||
/// Handles the case where a user may have locally modified a beatmap in the editor and expects the local status to stick.
|
||||
/// </summary>
|
||||
private static bool shouldSaveOnlineMetadata(BeatmapInfo beatmapInfo) => beatmapInfo.MatchesOnlineVersion || beatmapInfo.Status != BeatmapOnlineStatus.LocallyModified;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
cacheDownloadRequest?.Dispose();
|
||||
|
@ -6,15 +6,18 @@ using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public class BeatmapSetOnlineStatusPill : CircularContainer
|
||||
public class BeatmapSetOnlineStatusPill : CircularContainer, IHasTooltip
|
||||
{
|
||||
private BeatmapOnlineStatus status;
|
||||
|
||||
@ -96,5 +99,19 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
background.Colour = OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter;
|
||||
}
|
||||
|
||||
public LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Status)
|
||||
{
|
||||
case BeatmapOnlineStatus.LocallyModified:
|
||||
return SongSelectStrings.LocallyModifiedTooltip;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,33 +3,17 @@
|
||||
|
||||
using System;
|
||||
using Humanizer;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Collections
|
||||
{
|
||||
public class DeleteCollectionDialog : PopupDialog
|
||||
public class DeleteCollectionDialog : DeleteConfirmationDialog
|
||||
{
|
||||
public DeleteCollectionDialog(Live<BeatmapCollection> collection, Action deleteAction)
|
||||
{
|
||||
HeaderText = "Confirm deletion of";
|
||||
BodyText = collection.PerformRead(c => $"{c.Name} ({"beatmap".ToQuantity(c.BeatmapMD5Hashes.Count)})");
|
||||
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Yes. Go for it.",
|
||||
Action = deleteAction
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"No! Abort mission!",
|
||||
},
|
||||
};
|
||||
DeleteAction = deleteAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using Realms;
|
||||
@ -292,6 +293,11 @@ namespace osu.Game.Database
|
||||
foreach (var s in pendingDeleteSkins)
|
||||
realm.Remove(s);
|
||||
|
||||
var pendingDeletePresets = realm.All<ModPreset>().Where(s => s.DeletePending);
|
||||
|
||||
foreach (var s in pendingDeletePresets)
|
||||
realm.Remove(s);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,9 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case BeatmapOnlineStatus.LocallyModified:
|
||||
return Color4.OrangeRed;
|
||||
|
||||
case BeatmapOnlineStatus.Ranked:
|
||||
case BeatmapOnlineStatus.Approved:
|
||||
return Color4Extensions.FromHex(@"b3ff66");
|
||||
|
29
osu.Game/Localisation/DeleteConfirmationDialogStrings.cs
Normal file
29
osu.Game/Localisation/DeleteConfirmationDialogStrings.cs
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class DeleteConfirmationDialogStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.DeleteConfirmationDialog";
|
||||
|
||||
/// <summary>
|
||||
/// "Confirm deletion of"
|
||||
/// </summary>
|
||||
public static LocalisableString HeaderText => new TranslatableString(getKey(@"header_text"), @"Confirm deletion of");
|
||||
|
||||
/// <summary>
|
||||
/// "Yes. Go for it."
|
||||
/// </summary>
|
||||
public static LocalisableString Confirm => new TranslatableString(getKey(@"confirm"), @"Yes. Go for it.");
|
||||
|
||||
/// <summary>
|
||||
/// "No! Abort mission"
|
||||
/// </summary>
|
||||
public static LocalisableString Cancel => new TranslatableString(getKey(@"cancel"), @"No! Abort mission");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -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}";
|
||||
}
|
||||
}
|
||||
|
24
osu.Game/Localisation/SongSelectStrings.cs
Normal file
24
osu.Game/Localisation/SongSelectStrings.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.Localisation;
|
||||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class SongSelectStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.SongSelect";
|
||||
|
||||
/// <summary>
|
||||
/// "Local"
|
||||
/// </summary>
|
||||
public static LocalisableString LocallyModified => new TranslatableString(getKey(@"locally_modified"), @"Local");
|
||||
|
||||
/// <summary>
|
||||
/// "Has been locally modified"
|
||||
/// </summary>
|
||||
public static LocalisableString LocallyModifiedTooltip => new TranslatableString(getKey(@"locally_modified_tooltip"), @"Has been locally modified");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
@ -23,7 +20,7 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
[JsonProperty("acronym")]
|
||||
[Key(0)]
|
||||
public string Acronym { get; set; }
|
||||
public string Acronym { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("settings")]
|
||||
[Key(1)]
|
||||
@ -49,7 +46,7 @@ namespace osu.Game.Online.API
|
||||
}
|
||||
}
|
||||
|
||||
public Mod ToMod([NotNull] Ruleset ruleset)
|
||||
public Mod ToMod(Ruleset ruleset)
|
||||
{
|
||||
Mod resultMod = ruleset.CreateModFromAcronym(Acronym);
|
||||
|
||||
@ -80,6 +77,8 @@ namespace osu.Game.Online.API
|
||||
return resultMod;
|
||||
}
|
||||
|
||||
public bool ShouldSerializeSettings() => Settings.Count > 0;
|
||||
|
||||
public bool Equals(APIMod other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
|
42
osu.Game/Overlays/Dialog/DeleteConfirmationDialog.cs
Normal file
42
osu.Game/Overlays/Dialog/DeleteConfirmationDialog.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for various confirmation dialogs that concern deletion actions.
|
||||
/// Differs from <see cref="ConfirmDialog"/> in that the confirmation button is a "dangerous" one
|
||||
/// (requires the confirm button to be held).
|
||||
/// </summary>
|
||||
public abstract class DeleteConfirmationDialog : PopupDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// The action which performs the deletion.
|
||||
/// </summary>
|
||||
protected Action? DeleteAction { get; set; }
|
||||
|
||||
protected DeleteConfirmationDialog()
|
||||
{
|
||||
HeaderText = DeleteConfirmationDialogStrings.HeaderText;
|
||||
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogDangerousButton
|
||||
{
|
||||
Text = DeleteConfirmationDialogStrings.Confirm,
|
||||
Action = () => DeleteAction?.Invoke()
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = DeleteConfirmationDialogStrings.Cancel
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
18
osu.Game/Overlays/Mods/DeleteModPresetDialog.cs
Normal file
18
osu.Game/Overlays/Mods/DeleteModPresetDialog.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.Game.Database;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class DeleteModPresetDialog : DeleteConfirmationDialog
|
||||
{
|
||||
public DeleteModPresetDialog(Live<ModPreset> modPreset)
|
||||
{
|
||||
BodyText = modPreset.PerformRead(preset => preset.Name);
|
||||
DeleteAction = () => modPreset.PerformWrite(preset => preset.DeletePending = true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +1,44 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class ModPresetPanel : ModSelectPanel, IHasCustomTooltip<ModPreset>
|
||||
public class ModPresetPanel : ModSelectPanel, IHasCustomTooltip<ModPreset>, IHasContextMenu
|
||||
{
|
||||
public readonly Live<ModPreset> Preset;
|
||||
|
||||
public override BindableBool Active { get; } = new BindableBool();
|
||||
|
||||
[Resolved]
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
|
||||
|
||||
private ModSettingChangeTracker? settingChangeTracker;
|
||||
|
||||
public ModPresetPanel(Live<ModPreset> preset)
|
||||
{
|
||||
Preset = preset;
|
||||
|
||||
Title = preset.Value.Name;
|
||||
Description = preset.Value.Description;
|
||||
|
||||
Action = toggleRequestedByUser;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -30,7 +47,58 @@ namespace osu.Game.Overlays.Mods
|
||||
AccentColour = colours.Orange1;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
selectedMods.BindValueChanged(_ => selectedModsChanged(), true);
|
||||
}
|
||||
|
||||
private void toggleRequestedByUser()
|
||||
{
|
||||
// if the preset is not active at the point of the user click, then set the mods using the preset directly, discarding any previous selections.
|
||||
// if the preset is active when the user has clicked it, then it means that the set of active mods is exactly equal to the set of mods in the preset
|
||||
// (there are no other active mods than what the preset specifies, and the mod settings match exactly).
|
||||
// therefore it's safe to just clear selected mods, since it will have the effect of toggling the preset off.
|
||||
selectedMods.Value = !Active.Value
|
||||
? Preset.Value.Mods.ToArray()
|
||||
: Array.Empty<Mod>();
|
||||
}
|
||||
|
||||
private void selectedModsChanged()
|
||||
{
|
||||
settingChangeTracker?.Dispose();
|
||||
settingChangeTracker = new ModSettingChangeTracker(selectedMods.Value);
|
||||
settingChangeTracker.SettingChanged = _ => updateActiveState();
|
||||
updateActiveState();
|
||||
}
|
||||
|
||||
private void updateActiveState()
|
||||
{
|
||||
Active.Value = new HashSet<Mod>(Preset.Value.Mods).SetEquals(selectedMods.Value);
|
||||
}
|
||||
|
||||
#region IHasCustomTooltip
|
||||
|
||||
public ModPreset TooltipContent => Preset.Value;
|
||||
public ITooltip<ModPreset> GetCustomTooltip() => new ModPresetTooltip(ColourProvider);
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHasContextMenu
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => dialogOverlay?.Push(new DeleteModPresetDialog(Preset)))
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
settingChangeTracker?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -120,7 +120,13 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
};
|
||||
|
||||
default:
|
||||
return Empty();
|
||||
return new RecentActivityIcon(activity)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 11,
|
||||
FillMode = FillMode.Fit,
|
||||
Margin = new MarginPadding { Top = 2, Vertical = 2 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
119
osu.Game/Overlays/Profile/Sections/Recent/RecentActivityIcon.cs
Normal file
119
osu.Game/Overlays/Profile/Sections/Recent/RecentActivityIcon.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class RecentActivityIcon : Container
|
||||
{
|
||||
private readonly SpriteIcon icon;
|
||||
private readonly APIRecentActivity activity;
|
||||
|
||||
public RecentActivityIcon(APIRecentActivity activity)
|
||||
{
|
||||
this.activity = activity;
|
||||
Child = icon = new SpriteIcon
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
// references:
|
||||
// https://github.com/ppy/osu-web/blob/659b371dcadf25b4f601a4c9895a813078301084/resources/assets/lib/profile-page/parse-event.tsx
|
||||
// https://github.com/ppy/osu-web/blob/master/resources/assets/less/bem/profile-extra-entries.less#L98-L128
|
||||
switch (activity.Type)
|
||||
{
|
||||
case RecentActivityType.BeatmapPlaycount:
|
||||
icon.Icon = FontAwesome.Solid.Play;
|
||||
icon.Colour = Color4.White;
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetApprove:
|
||||
icon.Icon = FontAwesome.Solid.Check;
|
||||
icon.Colour = getColorForApprovalType(activity.Approval);
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetDelete:
|
||||
icon.Icon = FontAwesome.Solid.TrashAlt;
|
||||
icon.Colour = colours.Red1;
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetRevive:
|
||||
icon.Icon = FontAwesome.Solid.TrashRestore;
|
||||
icon.Colour = Color4.White;
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpdate:
|
||||
icon.Icon = FontAwesome.Solid.SyncAlt;
|
||||
icon.Colour = colours.Green1;
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpload:
|
||||
icon.Icon = FontAwesome.Solid.ArrowUp;
|
||||
icon.Colour = colours.Orange1;
|
||||
break;
|
||||
|
||||
case RecentActivityType.RankLost:
|
||||
icon.Icon = FontAwesome.Solid.AngleDoubleDown;
|
||||
icon.Colour = Color4.White;
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportAgain:
|
||||
icon.Icon = FontAwesome.Solid.Heart;
|
||||
icon.Colour = colours.Pink;
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportFirst:
|
||||
icon.Icon = FontAwesome.Solid.Heart;
|
||||
icon.Colour = colours.Pink;
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportGift:
|
||||
icon.Icon = FontAwesome.Solid.Gift;
|
||||
icon.Colour = colours.Pink;
|
||||
break;
|
||||
|
||||
case RecentActivityType.UsernameChange:
|
||||
icon.Icon = FontAwesome.Solid.Tag;
|
||||
icon.Colour = Color4.White;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 getColorForApprovalType(BeatmapApproval approvalType)
|
||||
{
|
||||
switch (approvalType)
|
||||
{
|
||||
case BeatmapApproval.Approved:
|
||||
case BeatmapApproval.Ranked:
|
||||
return colours.Lime1;
|
||||
|
||||
case BeatmapApproval.Loved:
|
||||
return colours.Pink1;
|
||||
|
||||
case BeatmapApproval.Qualified:
|
||||
return colours.Blue1;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException($"Unsupported {nameof(BeatmapApproval)} type", approvalType, nameof(approvalType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +1,17 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public class MassDeleteConfirmationDialog : PopupDialog
|
||||
public class MassDeleteConfirmationDialog : DeleteConfirmationDialog
|
||||
{
|
||||
public MassDeleteConfirmationDialog(Action deleteAction)
|
||||
{
|
||||
BodyText = "Everything?";
|
||||
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
HeaderText = @"Confirm deletion of";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogDangerousButton
|
||||
{
|
||||
Text = @"Yes. Go for it.",
|
||||
Action = deleteAction
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"No! Abort mission!",
|
||||
},
|
||||
};
|
||||
DeleteAction = deleteAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
|
@ -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()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,27 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class BeatmapClearScoresDialog : PopupDialog
|
||||
public class BeatmapClearScoresDialog : DeleteConfirmationDialog
|
||||
{
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; }
|
||||
private ScoreManager scoreManager { get; set; } = null!;
|
||||
|
||||
public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action onCompletion)
|
||||
{
|
||||
BodyText = beatmapInfo.GetDisplayTitle();
|
||||
Icon = FontAwesome.Solid.Eraser;
|
||||
HeaderText = @"Clearing all local scores. Are you sure?";
|
||||
Buttons = new PopupDialogButton[]
|
||||
BodyText = $"All local scores on {beatmapInfo.GetDisplayTitle()}";
|
||||
DeleteAction = () =>
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Yes. Please.",
|
||||
Action = () =>
|
||||
{
|
||||
Task.Run(() => scoreManager.Delete(beatmapInfo))
|
||||
.ContinueWith(_ => onCompletion);
|
||||
}
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"No, I'm still attached.",
|
||||
},
|
||||
Task.Run(() => scoreManager.Delete(beatmapInfo))
|
||||
.ContinueWith(_ => onCompletion);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,26 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class BeatmapDeleteDialog : PopupDialog
|
||||
public class BeatmapDeleteDialog : DeleteConfirmationDialog
|
||||
{
|
||||
private BeatmapManager manager;
|
||||
private readonly BeatmapSetInfo beatmapSet;
|
||||
|
||||
public BeatmapDeleteDialog(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
this.beatmapSet = beatmapSet;
|
||||
BodyText = $@"{beatmapSet.Metadata.Artist} - {beatmapSet.Metadata.Title}";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager beatmapManager)
|
||||
{
|
||||
manager = beatmapManager;
|
||||
}
|
||||
|
||||
public BeatmapDeleteDialog(BeatmapSetInfo beatmap)
|
||||
{
|
||||
BodyText = $@"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}";
|
||||
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
HeaderText = @"Confirm deletion of";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogDangerousButton
|
||||
{
|
||||
Text = @"Yes. Totally. Delete it.",
|
||||
Action = () => manager?.Delete(beatmap),
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"Firetruck, I didn't mean to!",
|
||||
},
|
||||
};
|
||||
DeleteAction = () => beatmapManager.Delete(beatmapSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Scoring;
|
||||
@ -12,44 +10,25 @@ using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class LocalScoreDeleteDialog : PopupDialog
|
||||
public class LocalScoreDeleteDialog : DeleteConfirmationDialog
|
||||
{
|
||||
private readonly ScoreInfo score;
|
||||
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
public LocalScoreDeleteDialog(ScoreInfo score)
|
||||
{
|
||||
this.score = score;
|
||||
Debug.Assert(score != null);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(BeatmapManager beatmapManager, ScoreManager scoreManager)
|
||||
{
|
||||
BeatmapInfo beatmapInfo = beatmapManager.QueryBeatmap(b => b.ID == score.BeatmapInfoID);
|
||||
BeatmapInfo? beatmapInfo = beatmapManager.QueryBeatmap(b => b.ID == score.BeatmapInfoID);
|
||||
Debug.Assert(beatmapInfo != null);
|
||||
|
||||
BodyText = $"{score.User} ({score.DisplayAccuracy}, {score.Rank})";
|
||||
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
HeaderText = "Confirm deletion of local score";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogDangerousButton
|
||||
{
|
||||
Text = "Yes. Please.",
|
||||
Action = () => scoreManager?.Delete(score)
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = "No, I'm still attached.",
|
||||
},
|
||||
};
|
||||
DeleteAction = () => scoreManager.Delete(score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,29 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class SkinDeleteDialog : PopupDialog
|
||||
public class SkinDeleteDialog : DeleteConfirmationDialog
|
||||
{
|
||||
[Resolved]
|
||||
private SkinManager manager { get; set; }
|
||||
private readonly Skin skin;
|
||||
|
||||
public SkinDeleteDialog(Skin skin)
|
||||
{
|
||||
this.skin = skin;
|
||||
BodyText = skin.SkinInfo.Value.Name;
|
||||
Icon = FontAwesome.Regular.TrashAlt;
|
||||
HeaderText = @"Confirm deletion of";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogDangerousButton
|
||||
{
|
||||
Text = @"Yes. Totally. Delete it.",
|
||||
Action = () =>
|
||||
{
|
||||
if (manager == null)
|
||||
return;
|
||||
}
|
||||
|
||||
manager.Delete(skin.SkinInfo.Value);
|
||||
manager.CurrentSkinInfo.SetDefault();
|
||||
},
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
Text = @"Firetruck, I didn't mean to!",
|
||||
},
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SkinManager manager)
|
||||
{
|
||||
DeleteAction = () =>
|
||||
{
|
||||
manager.Delete(skin.SkinInfo.Value);
|
||||
manager.CurrentSkinInfo.SetDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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…
x
Reference in New Issue
Block a user