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,9 +43,17 @@ namespace osu.Game.Tournament.Screens
private void load(Storage storage, OsuColour colours)
{
// 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))
{
// If the original path info for osu! stable is not empty, set it to the parent directory of that location
initialPath = new DirectoryInfo(stableInfo.StablePath.Value).Parent?.FullName;
}
AddRangeInternal(new Drawable[]
{
new Container
{
Masking = true,
CornerRadius = 10,
@ -89,6 +97,14 @@ namespace osu.Game.Tournament.Screens
}
},
new Drawable[]
{
new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20),
Children = new Drawable[]
{
new TriangleButton
{
@ -96,22 +112,38 @@ namespace osu.Game.Tournament.Screens
Origin = Anchor.Centre,
Width = 300,
Text = "Select stable path",
Action = () => { start(storage); }
Action = () => changePath(storage)
},
new TriangleButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 300,
Text = "Auto detect",
Action = autoDetect
},
}
}
}
}
}
},
},
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 start(Storage storage)
private void changePath(Storage storage)
{
var target = directorySelector.CurrentDirectory.Value.FullName;
if (checkExists(target))
if (File.Exists(Path.Combine(target, "ipc.txt")))
{
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
}
}
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));
}
}
}
}