mirror of
https://github.com/ppy/osu
synced 2025-01-10 16:19:47 +00:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into news-sidebar-new
This commit is contained in:
commit
ab16c32bb1
@ -0,0 +1,128 @@
|
||||
// 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.Graphics;
|
||||
using System.IO;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Screens;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public abstract class DirectorySelectScreen : OsuScreen
|
||||
{
|
||||
private TriangleButton selectionButton;
|
||||
|
||||
private DirectorySelector directorySelector;
|
||||
|
||||
/// <summary>
|
||||
/// Text to display in the header to inform the user of what they are selecting.
|
||||
/// </summary>
|
||||
public abstract LocalisableString HeaderText { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called upon selection of a directory by the user.
|
||||
/// </summary>
|
||||
/// <param name="directory">The selected directory</param>
|
||||
protected abstract void OnSelection(DirectoryInfo directory);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current directory is considered to be valid and can be selected.
|
||||
/// </summary>
|
||||
/// <param name="info">The current directory.</param>
|
||||
/// <returns>Whether the selected directory is considered valid.</returns>
|
||||
protected virtual bool IsValidDirectory(DirectoryInfo info) => true;
|
||||
|
||||
/// <summary>
|
||||
/// The path at which to start selection from.
|
||||
/// </summary>
|
||||
protected virtual DirectoryInfo InitialPath => null;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChild = new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.5f, 0.8f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.GreySeafoamDark
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Relative, 0.8f),
|
||||
new Dimension(),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = HeaderText,
|
||||
Font = OsuFont.Default.With(size: 40),
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
directorySelector = new DirectorySelector
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
selectionButton = new TriangleButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 300,
|
||||
Text = "Select directory",
|
||||
Action = () => OnSelection(directorySelector.CurrentPath.Value)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
if (InitialPath != null)
|
||||
directorySelector.CurrentPath.Value = InitialPath;
|
||||
|
||||
directorySelector.CurrentPath.BindValueChanged(e => selectionButton.Enabled.Value = e.NewValue != null && IsValidDirectory(e.NewValue), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
|
||||
this.FadeOut(250);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,24 +4,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Screens;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
{
|
||||
public class MigrationSelectScreen : OsuScreen
|
||||
public class MigrationSelectScreen : DirectorySelectScreen
|
||||
{
|
||||
private DirectorySelector directorySelector;
|
||||
[Resolved]
|
||||
private Storage storage { get; set; }
|
||||
|
||||
protected override DirectoryInfo InitialPath => new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent;
|
||||
|
||||
public override bool AllowExternalScreenChange => false;
|
||||
|
||||
@ -29,84 +24,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
|
||||
public override bool HideOverlaysOnEnter => true;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, Storage storage, OsuColour colours)
|
||||
public override LocalisableString HeaderText => "Please select a new location";
|
||||
|
||||
protected override void OnSelection(DirectoryInfo directory)
|
||||
{
|
||||
game?.Toolbar.Hide();
|
||||
|
||||
// begin selection in the parent directory of the current storage location
|
||||
var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
|
||||
|
||||
InternalChild = new Container
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.5f, 0.8f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = colours.GreySeafoamDark,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Relative, 0.8f),
|
||||
new Dimension(),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "Please select a new location",
|
||||
Font = OsuFont.Default.With(size: 40)
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
directorySelector = new DirectorySelector(initialPath)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new TriangleButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 300,
|
||||
Text = "Begin folder migration",
|
||||
Action = start
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
base.OnSuspending(next);
|
||||
|
||||
this.FadeOut(250);
|
||||
}
|
||||
|
||||
private void start()
|
||||
{
|
||||
var target = directorySelector.CurrentPath.Value;
|
||||
var target = directory;
|
||||
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user