mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 15:27:20 +08:00
DialogManager -> DialogOverlay, cleaned up how BeatmapDeletDialog works, added global DialogOverlay
This commit is contained in:
parent
50d172be39
commit
ce1798b8bc
@ -9,9 +9,9 @@ using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
public class TestCaseDialogManager : TestCase
|
||||
public class TestCaseDialogOverlay : TestCase
|
||||
{
|
||||
public override string Name => @"Dialog Manager";
|
||||
public override string Name => @"Dialog Overlay";
|
||||
|
||||
public override string Description => @"Display dialogs";
|
||||
|
||||
@ -19,12 +19,11 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
var manager = new DialogManager();
|
||||
var manager = new DialogOverlay();
|
||||
Add(manager);
|
||||
|
||||
AddButton("dialog #1", () => manager.Push(new PopupDialog
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Icon = FontAwesome.fa_trash_o,
|
||||
HeaderText = @"Confirm deletion of",
|
||||
BodyText = @"Ayase Rie - Yuima-ru*World TVver.",
|
||||
@ -45,7 +44,6 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
AddButton("dialog #2", () => manager.Push(new PopupDialog
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Icon = FontAwesome.fa_gear,
|
||||
HeaderText = @"What do you want to do with",
|
||||
BodyText = "Camellia as \"Bang Riot\" - Blastix Riotz",
|
@ -194,7 +194,7 @@
|
||||
<Compile Include="Platform\TestStorage.cs" />
|
||||
<Compile Include="Tests\TestCaseOptions.cs" />
|
||||
<Compile Include="Tests\TestCasePauseOverlay.cs" />
|
||||
<Compile Include="Tests\TestCaseDialogManager.cs" />
|
||||
<Compile Include="Tests\TestCaseDialogOverlay.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup />
|
||||
|
@ -42,6 +42,8 @@ namespace osu.Game
|
||||
|
||||
private NotificationManager notificationManager;
|
||||
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private Intro intro
|
||||
{
|
||||
get
|
||||
@ -142,6 +144,11 @@ namespace osu.Game
|
||||
Origin = Anchor.TopRight,
|
||||
}).LoadAsync(this, overlayContent.Add);
|
||||
|
||||
(dialogOverlay = new DialogOverlay
|
||||
{
|
||||
Depth = -4,
|
||||
}).LoadAsync(this, overlayContent.Add);
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
{
|
||||
if (entry.Level < LogLevel.Important) return;
|
||||
@ -155,6 +162,7 @@ namespace osu.Game
|
||||
Dependencies.Cache(options);
|
||||
Dependencies.Cache(musicController);
|
||||
Dependencies.Cache(notificationManager);
|
||||
Dependencies.Cache(dialogOverlay);
|
||||
|
||||
(Toolbar = new Toolbar
|
||||
{
|
||||
|
@ -145,6 +145,8 @@ namespace osu.Game.Overlays.Dialog
|
||||
|
||||
public PopupDialog()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
content = new Container
|
||||
|
@ -11,7 +11,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class DialogManager : FocusedOverlayContainer
|
||||
public class DialogOverlay : FocusedOverlayContainer
|
||||
{
|
||||
private Container dialogContainer;
|
||||
private PopupDialog currentDialog;
|
||||
@ -29,10 +29,10 @@ namespace osu.Game.Overlays
|
||||
State = Visibility.Hidden;
|
||||
};
|
||||
|
||||
var oldDialog = currentDialog;
|
||||
var lastDialog = currentDialog;
|
||||
currentDialog = dialog;
|
||||
oldDialog?.Hide();
|
||||
oldDialog?.Expire();
|
||||
lastDialog?.Hide();
|
||||
lastDialog?.Expire();
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
@ -47,7 +47,7 @@ namespace osu.Game.Overlays
|
||||
darken.FadeOut(200, EasingTypes.InSine);
|
||||
}
|
||||
|
||||
public DialogManager()
|
||||
public DialogOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
@ -2,7 +2,9 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
@ -10,7 +12,13 @@ namespace osu.Game
|
||||
{
|
||||
public class BeatmapDeleteDialog : PopupDialog
|
||||
{
|
||||
public Action<WorkingBeatmap> OnDelete;
|
||||
private BeatmapDatabase database;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDatabase beatmapDatabase)
|
||||
{
|
||||
database = beatmapDatabase;
|
||||
}
|
||||
|
||||
public BeatmapDeleteDialog(WorkingBeatmap beatmap)
|
||||
{
|
||||
@ -24,7 +32,8 @@ namespace osu.Game
|
||||
Text = @"Yes. Totally. Delete it.",
|
||||
Action = () =>
|
||||
{
|
||||
OnDelete?.Invoke(beatmap);
|
||||
beatmap.Dispose();
|
||||
database.Delete(beatmap.BeatmapSetInfo);
|
||||
},
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
|
@ -27,6 +27,7 @@ using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -38,6 +39,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private CarouselContainer carousel;
|
||||
private TrackManager trackManager;
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225);
|
||||
private BeatmapInfoWedge beatmapInfoWedge;
|
||||
@ -58,7 +60,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, Framework.Game game,
|
||||
OsuGame osuGame, OsuColour colours)
|
||||
OsuGame osuGame, DialogOverlay dialog, OsuColour colours)
|
||||
{
|
||||
const float carousel_width = 640;
|
||||
const float filter_height = 100;
|
||||
@ -142,6 +144,7 @@ namespace osu.Game.Screens.Select
|
||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||
|
||||
trackManager = audio.Track;
|
||||
dialogOverlay = dialog;
|
||||
|
||||
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
||||
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
|
||||
@ -383,19 +386,13 @@ namespace osu.Game.Screens.Select
|
||||
return true;
|
||||
case Key.Delete:
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
{
|
||||
// TODO: Delete beatmap dialog here
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Beatmap != null)
|
||||
{
|
||||
Beatmap.Dispose();
|
||||
database.Delete(Beatmap.BeatmapSetInfo);
|
||||
}
|
||||
dialogOverlay.Push(new BeatmapDeleteDialog(Beatmap));
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
|
@ -286,7 +286,7 @@
|
||||
<Compile Include="Overlays\Dialog\PopupDialogOKButton.cs" />
|
||||
<Compile Include="Overlays\Dialog\PopupDialogCancelButton.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapDeleteDialog.cs" />
|
||||
<Compile Include="Overlays\DialogManager.cs" />
|
||||
<Compile Include="Overlays\DialogOverlay.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
x
Reference in New Issue
Block a user