2021-07-06 06:15:17 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-06 06:15:17 +08:00
|
|
|
using System.IO;
|
2022-06-06 19:11:43 +08:00
|
|
|
using System.Linq;
|
2021-07-06 06:15:17 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-07-21 21:01:00 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-07-06 06:15:17 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterfaceV2
|
|
|
|
{
|
|
|
|
public class OsuFileSelector : FileSelector
|
|
|
|
{
|
|
|
|
public OsuFileSelector(string initialPath = null, string[] validFileExtensions = null)
|
|
|
|
: base(initialPath, validFileExtensions)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override ScrollContainer<Drawable> CreateScrollContainer() => new OsuScrollContainer();
|
|
|
|
|
2021-07-06 06:20:58 +08:00
|
|
|
protected override DirectorySelectorBreadcrumbDisplay CreateBreadcrumb() => new OsuDirectorySelectorBreadcrumbDisplay();
|
2021-07-06 06:15:17 +08:00
|
|
|
|
2021-07-06 06:20:58 +08:00
|
|
|
protected override DirectorySelectorDirectory CreateParentDirectoryItem(DirectoryInfo directory) => new OsuDirectorySelectorParentDirectory(directory);
|
2021-07-06 06:15:17 +08:00
|
|
|
|
2021-07-06 06:20:58 +08:00
|
|
|
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new OsuDirectorySelectorDirectory(directory, displayName);
|
2021-07-06 06:15:17 +08:00
|
|
|
|
|
|
|
protected override DirectoryListingFile CreateFileItem(FileInfo file) => new OsuDirectoryListingFile(file);
|
|
|
|
|
|
|
|
protected override void NotifySelectionError() => this.FlashColour(Colour4.Red, 300);
|
|
|
|
|
|
|
|
protected class OsuDirectoryListingFile : DirectoryListingFile
|
|
|
|
{
|
|
|
|
public OsuDirectoryListingFile(FileInfo file)
|
|
|
|
: base(file)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Flow.AutoSizeAxes = Axes.X;
|
|
|
|
Flow.Height = OsuDirectorySelector.ITEM_HEIGHT;
|
|
|
|
|
2021-07-21 21:01:00 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2021-07-06 06:15:17 +08:00
|
|
|
{
|
2021-07-21 21:01:00 +08:00
|
|
|
new OsuDirectorySelectorDirectory.Background
|
|
|
|
{
|
|
|
|
Depth = 1
|
|
|
|
},
|
2021-07-29 19:29:11 +08:00
|
|
|
new HoverClickSounds()
|
2021-07-06 06:15:17 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override IconUsage? Icon
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2022-06-16 17:00:27 +08:00
|
|
|
if (OsuGameBase.VIDEO_EXTENSIONS.Contains(File.Extension))
|
2022-06-06 19:11:43 +08:00
|
|
|
return FontAwesome.Regular.FileVideo;
|
|
|
|
|
2021-07-06 06:15:17 +08:00
|
|
|
switch (File.Extension)
|
|
|
|
{
|
|
|
|
case @".ogg":
|
|
|
|
case @".mp3":
|
|
|
|
case @".wav":
|
|
|
|
return FontAwesome.Regular.FileAudio;
|
|
|
|
|
|
|
|
case @".jpg":
|
|
|
|
case @".jpeg":
|
|
|
|
case @".png":
|
|
|
|
return FontAwesome.Regular.FileImage;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FontAwesome.Regular.File;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override SpriteText CreateSpriteText() => new OsuSpriteText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|