public StorageErrorDialog(OsuStorage storage, OsuStorageError error) { HeaderText = "osu! 儲存錯誤"; Icon = FontAwesome.Solid.ExclamationTriangle; var buttons = new List <PopupDialogButton>(); switch (error) { case OsuStorageError.NotAccessible: BodyText = $"指定的位置 (\"{storage.CustomStoragePath}\") 無法被訪問. 如果導向的目錄是外置硬碟, 請連接後再試一次."; buttons.AddRange(new PopupDialogButton[] { new PopupDialogCancelButton { Text = "再試一次", Action = () => { if (!storage.TryChangeToCustomStorage(out var nextError)) { dialogOverlay.Push(new StorageErrorDialog(storage, nextError)); } } }, new PopupDialogCancelButton { Text = "先用默認位置 直到下一次開始遊戲", }, new PopupDialogOkButton { Text = "復原默認位置", Action = storage.ResetCustomStoragePath }, });
/// <summary> /// Attempts to change to the user's custom storage path. /// </summary> /// <param name="error">The error that occurred.</param> /// <returns>Whether the custom storage path was used successfully. If not, <paramref name="error"/> will be populated with the reason.</returns> public bool TryChangeToCustomStorage(out OsuStorageError error) { Debug.Assert(!string.IsNullOrEmpty(CustomStoragePath)); error = OsuStorageError.None; Storage lastStorage = UnderlyingStorage; try { Storage userStorage = host.GetStorage(CustomStoragePath); if (!userStorage.ExistsDirectory(".") || !userStorage.GetFiles(".").Any()) { error = OsuStorageError.AccessibleButEmpty; } ChangeTargetStorage(userStorage); } catch { error = OsuStorageError.NotAccessible; ChangeTargetStorage(lastStorage); } return(error == OsuStorageError.None); }
public StorageErrorDialog(OsuStorage storage, OsuStorageError error) { HeaderText = "osu! storage error"; Icon = FontAwesome.Solid.ExclamationTriangle; var buttons = new List <PopupDialogButton>(); switch (error) { case OsuStorageError.NotAccessible: BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is not accessible. If it is on external storage, please reconnect the device and try again."; buttons.AddRange(new PopupDialogButton[] { new PopupDialogCancelButton { Text = "Try again", Action = () => { if (!storage.TryChangeToCustomStorage(out var nextError)) { dialogOverlay.Push(new StorageErrorDialog(storage, nextError)); } } }, new PopupDialogCancelButton { Text = "Use default location until restart", }, new PopupDialogOkButton { Text = "Reset to default location", Action = storage.ResetCustomStoragePath }, });