1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:43:00 +08:00

Moved refresh button to directoryselector

This commit is contained in:
Shivam 2020-05-17 22:28:24 +02:00
parent 4bc858a215
commit fbbf51851e

View File

@ -43,75 +43,107 @@ namespace osu.Game.Tournament.Screens
private void load(Storage storage, OsuColour colours) private void load(Storage storage, OsuColour colours)
{ {
// begin selection in the parent directory of the current storage location // begin selection in the parent directory of the current storage location
var initialPath = new DirectoryInfo(stableInfo.StablePath.Value).FullName; var initialPath = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent?.FullName;
AddInternal(new Container if (!string.IsNullOrEmpty(stableInfo.StablePath.Value))
{ {
Masking = true, // If the original path info for osu! stable is not empty, set it to the parent directory of that location
CornerRadius = 10, initialPath = new DirectoryInfo(stableInfo.StablePath.Value).Parent?.FullName;
RelativeSizeAxes = Axes.Both, }
Anchor = Anchor.Centre,
Origin = Anchor.Centre, AddRangeInternal(new Drawable[]
Size = new Vector2(0.5f, 0.8f), {
Children = new Drawable[] new Container
{ {
new Box Masking = true,
CornerRadius = 10,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.5f, 0.8f),
Children = new Drawable[]
{ {
Colour = colours.GreySeafoamDark, new Box
RelativeSizeAxes = Axes.Both,
},
new GridContainer
{
RelativeSizeAxes = Axes.Both,
RowDimensions = new[]
{ {
new Dimension(), Colour = colours.GreySeafoamDark,
new Dimension(GridSizeMode.Relative, 0.8f), RelativeSizeAxes = Axes.Both,
new Dimension(),
}, },
Content = new[] new GridContainer
{ {
new Drawable[] RelativeSizeAxes = Axes.Both,
RowDimensions = new[]
{ {
new OsuSpriteText new Dimension(),
{ new Dimension(GridSizeMode.Relative, 0.8f),
Anchor = Anchor.Centre, new Dimension(),
Origin = Anchor.Centre,
Text = "Please select a new location",
Font = OsuFont.Default.With(size: 40)
},
}, },
new Drawable[] Content = new[]
{ {
directorySelector = new DirectorySelector(initialPath) new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, 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 FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20),
Children = new Drawable[]
{
new TriangleButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 300,
Text = "Select stable path",
Action = () => changePath(storage)
},
new TriangleButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 300,
Text = "Auto detect",
Action = autoDetect
},
}
}
} }
},
new Drawable[]
{
new TriangleButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 300,
Text = "Select stable path",
Action = () => { start(storage); }
},
} }
} }
} },
},
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
State = { Value = Visibility.Visible },
Action = () => sceneManager?.SetScreen(typeof(SetupScreen))
} }
}); });
} }
private static bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt")); private void changePath(Storage storage)
private void start(Storage storage)
{ {
var target = directorySelector.CurrentDirectory.Value.FullName; var target = directorySelector.CurrentDirectory.Value.FullName;
if (checkExists(target)) if (File.Exists(Path.Combine(target, "ipc.txt")))
{ {
stableInfo.StablePath.Value = target; stableInfo.StablePath.Value = target;
@ -145,5 +177,22 @@ namespace osu.Game.Tournament.Screens
// Return an error in the picker that the directory does not contain ipc.txt // Return an error in the picker that the directory does not contain ipc.txt
} }
} }
private void autoDetect()
{
var fileBasedIpc = ipc as FileBasedIPC;
fileBasedIpc?.LocateStableStorage();
if (fileBasedIpc?.IPCStorage == null)
{
// Could not auto detect
overlay = new DialogOverlay();
overlay.Push(new IPCNotFoundDialog());
AddInternal(overlay);
}
else
{
sceneManager?.SetScreen(typeof(SetupScreen));
}
}
} }
} }