mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 23:12:56 +08:00
Simplify code
This commit is contained in:
parent
9a3dd12f30
commit
07ee36a4ef
@ -13,7 +13,6 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
@ -29,12 +28,11 @@ namespace osu.Game.Screens.Import
|
|||||||
|
|
||||||
public override bool HideOverlaysOnEnter => true;
|
public override bool HideOverlaysOnEnter => true;
|
||||||
|
|
||||||
private string[] fileExtensions = { ".foo" };
|
private string[] fileExtensions;
|
||||||
private string defaultPath;
|
private string defaultPath;
|
||||||
|
|
||||||
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();
|
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();
|
||||||
private readonly IBindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
|
private readonly IBindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
|
||||||
private readonly Bindable<FileFilterType> filterType = new Bindable<FileFilterType>(FileFilterType.All);
|
|
||||||
private TextFlowContainer currentFileText;
|
private TextFlowContainer currentFileText;
|
||||||
private OsuScrollContainer fileNameScroll;
|
private OsuScrollContainer fileNameScroll;
|
||||||
private readonly OverlayColourProvider overlayColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
private readonly OverlayColourProvider overlayColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||||
@ -42,15 +40,12 @@ namespace osu.Game.Screens.Import
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuGameBase gameBase { get; set; }
|
private OsuGameBase gameBase { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private DialogOverlay dialogOverlay { get; set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(Storage storage)
|
private void load(Storage storage)
|
||||||
{
|
{
|
||||||
storage.GetStorageForDirectory("imports");
|
storage.GetStorageForDirectory("imports");
|
||||||
var originalPath = storage.GetFullPath("imports", true);
|
var originalPath = storage.GetFullPath("imports", true);
|
||||||
|
fileExtensions = new string[] { ".osk", ".osr", ".osz" };
|
||||||
defaultPath = originalPath;
|
defaultPath = originalPath;
|
||||||
|
|
||||||
InternalChild = contentContainer = new Container
|
InternalChild = contentContainer = new Container
|
||||||
@ -131,85 +126,43 @@ namespace osu.Game.Screens.Import
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Bottom = 15, Top =15 },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
|
||||||
{
|
|
||||||
Colour = overlayColourProvider.Background4,
|
|
||||||
RelativeSizeAxes = Axes.Both
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Spacing = new Vector2(10),
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsEnumDropdown<FileFilterType>
|
new TriangleButton
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
LabelText = "File Type",
|
|
||||||
Current = filterType,
|
|
||||||
Margin = new MarginPadding { Bottom = 15 }
|
|
||||||
},
|
|
||||||
new GridContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Margin = new MarginPadding { Top = 15 },
|
|
||||||
RowDimensions = new[]
|
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.AutoSize)
|
Text = "Import",
|
||||||
},
|
Anchor = Anchor.BottomCentre,
|
||||||
Content = new[]
|
Origin = Anchor.BottomCentre,
|
||||||
{
|
RelativeSizeAxes = Axes.X,
|
||||||
new Drawable[]
|
Height = 50,
|
||||||
|
Width = 0.9f,
|
||||||
|
Action = () =>
|
||||||
{
|
{
|
||||||
new TriangleButton
|
var d = currentFile.Value?.FullName;
|
||||||
{
|
if (d != null)
|
||||||
Anchor = Anchor.BottomCentre,
|
startImport(d);
|
||||||
Origin = Anchor.BottomCentre,
|
else
|
||||||
RelativeSizeAxes = Axes.X,
|
currentFileText.FlashColour(Color4.Red, 500);
|
||||||
Height = 50,
|
}
|
||||||
Width = 0.9f,
|
|
||||||
Text = "Refresh",
|
|
||||||
Action = refresh
|
|
||||||
},
|
|
||||||
new TriangleButton
|
|
||||||
{
|
|
||||||
Text = "Import",
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 50,
|
|
||||||
Width = 0.9f,
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
var d = currentFile.Value?.FullName;
|
|
||||||
if (d != null)
|
|
||||||
startImport(d);
|
|
||||||
else
|
|
||||||
currentFileText.FlashColour(Color4.Red, 500);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fileNameScroll.ScrollContent.Anchor = Anchor.Centre;
|
fileNameScroll.ScrollContent.Anchor = Anchor.Centre;
|
||||||
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
||||||
|
|
||||||
@ -218,37 +171,6 @@ namespace osu.Game.Screens.Import
|
|||||||
{
|
{
|
||||||
currentFile.Value = null;
|
currentFile.Value = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
filterType.BindValueChanged(onFilterTypeChanged, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onFilterTypeChanged(ValueChangedEvent<FileFilterType> v)
|
|
||||||
{
|
|
||||||
switch (v.NewValue)
|
|
||||||
{
|
|
||||||
case FileFilterType.Beatmap:
|
|
||||||
fileExtensions = new string[] { ".osz" };
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FileFilterType.Skin:
|
|
||||||
fileExtensions = new string[] { ".osk" };
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FileFilterType.Replay:
|
|
||||||
fileExtensions = new string[] { ".osr" };
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case FileFilterType.All:
|
|
||||||
fileExtensions = new string[] { ".osk", ".osr", ".osz" };
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refresh()
|
|
||||||
{
|
|
||||||
currentFile.UnbindBindings();
|
currentFile.UnbindBindings();
|
||||||
currentDirectory.UnbindBindings();
|
currentDirectory.UnbindBindings();
|
||||||
|
|
||||||
@ -265,7 +187,6 @@ namespace osu.Game.Screens.Import
|
|||||||
|
|
||||||
fileSelectContainer.Add(fileSelector);
|
fileSelectContainer.Add(fileSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)
|
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)
|
||||||
{
|
{
|
||||||
currentFileText.Text = v.NewValue?.Name ?? "Select a file";
|
currentFileText.Text = v.NewValue?.Name ?? "Select a file";
|
||||||
@ -298,7 +219,6 @@ namespace osu.Game.Screens.Import
|
|||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
refresh();
|
|
||||||
currentFileText.Text = "File not exist";
|
currentFileText.Text = "File not exist";
|
||||||
currentFileText.FlashColour(Color4.Red, 500);
|
currentFileText.FlashColour(Color4.Red, 500);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user