mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 19:07:20 +08:00
User interface setup for custom IPC location
Right now makes use of another ActionableInfo field. Probably a better idea to add an extra button to the Current IPC Storage actionable field.
This commit is contained in:
parent
9944a514da
commit
3fc888ef95
27
osu.Game.Tournament/Components/IPCNotFoundDialog.cs
Normal file
27
osu.Game.Tournament/Components/IPCNotFoundDialog.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.Sprites;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Tournament.Components
|
||||
{
|
||||
public class IPCNotFoundDialog : PopupDialog
|
||||
{
|
||||
public IPCNotFoundDialog()
|
||||
{
|
||||
BodyText = "Select a directory that contains an osu! Cutting Edge installation";
|
||||
|
||||
Icon = FontAwesome.Regular.Angry;
|
||||
HeaderText = @"This is an invalid IPC Directory!";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Alright.",
|
||||
Action = () => { Expire(); }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -26,6 +28,7 @@ namespace osu.Game.Tournament.Screens
|
||||
|
||||
private LoginOverlay loginOverlay;
|
||||
private ActionableInfo resolution;
|
||||
private const string stable_config = "tournament/stable.json";
|
||||
|
||||
[Resolved]
|
||||
private MatchIPCInfo ipc { get; set; }
|
||||
@ -36,8 +39,17 @@ namespace osu.Game.Tournament.Screens
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
private Bindable<Size> windowSize;
|
||||
|
||||
[Resolved]
|
||||
private Storage storage { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private StableInfo stableInfo { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FrameworkConfigManager frameworkConfig)
|
||||
{
|
||||
@ -62,7 +74,6 @@ namespace osu.Game.Tournament.Screens
|
||||
private void reload()
|
||||
{
|
||||
var fileBasedIpc = ipc as FileBasedIPC;
|
||||
|
||||
fillFlow.Children = new Drawable[]
|
||||
{
|
||||
new ActionableInfo
|
||||
@ -74,11 +85,28 @@ namespace osu.Game.Tournament.Screens
|
||||
fileBasedIpc?.LocateStableStorage();
|
||||
reload();
|
||||
},
|
||||
Value = fileBasedIpc?.Storage?.GetFullPath(string.Empty) ?? "Not found",
|
||||
Failing = fileBasedIpc?.Storage == null,
|
||||
Value = fileBasedIpc?.IPCStorage?.GetFullPath(string.Empty) ?? "Not found",
|
||||
Failing = fileBasedIpc?.IPCStorage == null,
|
||||
Description = "The osu!stable installation which is currently being used as a data source. If a source is not found, make sure you have created an empty ipc.txt in your stable cutting-edge installation, and that it is registered as the default osu! install."
|
||||
},
|
||||
new ActionableInfo
|
||||
{
|
||||
Label = "Custom IPC source",
|
||||
ButtonText = "Change path",
|
||||
Action = () =>
|
||||
{
|
||||
stableInfo.StablePath.BindValueChanged(_ =>
|
||||
{
|
||||
fileBasedIpc?.LocateStableStorage();
|
||||
Schedule(reload);
|
||||
});
|
||||
sceneManager.SetScreen(new StablePathSelectScreen());
|
||||
},
|
||||
Value = fileBasedIpc?.IPCStorage?.GetFullPath(string.Empty) ?? "Not found",
|
||||
Failing = fileBasedIpc?.IPCStorage == null,
|
||||
Description = "The osu!stable installation which is currently being used as a data source. If a source is not found, you can manually select the desired osu! installation that you want to use."
|
||||
},
|
||||
new ActionableInfo
|
||||
{
|
||||
Label = "Current User",
|
||||
ButtonText = "Change Login",
|
||||
|
149
osu.Game.Tournament/Screens/StablePathSelectScreen.cs
Normal file
149
osu.Game.Tournament/Screens/StablePathSelectScreen.cs
Normal file
@ -0,0 +1,149 @@
|
||||
// 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 System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tournament.Screens
|
||||
{
|
||||
public class StablePathSelectScreen : TournamentScreen
|
||||
{
|
||||
private DirectorySelector directorySelector;
|
||||
|
||||
private const string stable_config = "tournament/stable.json";
|
||||
|
||||
[Resolved]
|
||||
private StableInfo stableInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private MatchIPCInfo ipc { get; set; }
|
||||
|
||||
private DialogOverlay overlay;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private TournamentSceneManager sceneManager { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
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;
|
||||
|
||||
AddInternal(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 = "Select stable path",
|
||||
Action = () => { start(storage); }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
|
||||
|
||||
private void start(Storage storage)
|
||||
{
|
||||
var target = directorySelector.CurrentDirectory.Value.FullName;
|
||||
|
||||
if (checkExists(target))
|
||||
{
|
||||
stableInfo.StablePath.Value = target;
|
||||
|
||||
try
|
||||
{
|
||||
using (var stream = storage.GetStream(stable_config, FileAccess.Write, FileMode.Create))
|
||||
using (var sw = new StreamWriter(stream))
|
||||
{
|
||||
sw.Write(JsonConvert.SerializeObject(stableInfo,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore,
|
||||
}));
|
||||
}
|
||||
|
||||
sceneManager?.SetScreen(typeof(SetupScreen));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Error during migration: {e.Message}", level: LogLevel.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
overlay = new DialogOverlay();
|
||||
overlay.Push(new IPCNotFoundDialog());
|
||||
AddInternal(overlay);
|
||||
Logger.Log("Folder is not an osu! stable CE directory");
|
||||
// Return an error in the picker that the directory does not contain ipc.txt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user