diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index be6e947..1315880 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -783,7 +783,6 @@ public class SettingsUi : WindowMediatorSubscriberBase + UiSharedService.TooltipSeparator + "Hold CTRL to enable this button"); } - _uiShared.DrawCacheDirectorySetting(); ImGui.TextUnformatted($"Currently utilized local storage: {UiSharedService.ByteToString(_uiShared.FileCacheSize)}"); bool isLinux = Util.IsWine(); diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index 636d299..00b18f2 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -594,36 +594,39 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase ImGui.InputText("Storage Folder##cache", ref cacheDirectory, 255, ImGuiInputTextFlags.ReadOnly); ImGui.SameLine(); - ImGui.PushFont(UiBuilder.IconFont); - string folderIcon = FontAwesomeIcon.Folder.ToIconString(); - if (ImGui.Button(folderIcon + "##chooseCacheFolder")) + using (ImRaii.Disabled(_cacheMonitor.MareWatcher != null)) { - FileDialogManager.OpenFolderDialog("Pick Loporrit Storage Folder", (success, path) => + if (NormalizedIconButton(FontAwesomeIcon.Folder)) { - if (!success) return; - - _isOneDrive = path.Contains("onedrive", StringComparison.OrdinalIgnoreCase); - _isPenumbraDirectory = string.Equals(path.ToLowerInvariant(), _ipcManager.PenumbraModDirectory?.ToLowerInvariant(), StringComparison.Ordinal); - _isDirectoryWritable = IsDirectoryWritable(path); - _cacheDirectoryHasOtherFilesThanCache = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Any(f => Path.GetFileNameWithoutExtension(f).Length != 40); - _cacheDirectoryIsValidPath = PathRegex().IsMatch(path); - - if (!string.IsNullOrEmpty(path) - && Directory.Exists(path) - && _isDirectoryWritable - && !_isPenumbraDirectory - && !_isOneDrive - && !_cacheDirectoryHasOtherFilesThanCache - && _cacheDirectoryIsValidPath) + FileDialogManager.OpenFolderDialog("Pick Loporrit Storage Folder", (success, path) => { - _configService.Current.CacheFolder = path; - _configService.Save(); - _cacheMonitor.StartMareWatcher(path); - _cacheMonitor.InvokeScan(); - } - }); + if (!success) return; + + _isOneDrive = path.Contains("onedrive", StringComparison.OrdinalIgnoreCase); + _isPenumbraDirectory = string.Equals(path.ToLowerInvariant(), _ipcManager.PenumbraModDirectory?.ToLowerInvariant(), StringComparison.Ordinal); + _isDirectoryWritable = IsDirectoryWritable(path); + _cacheDirectoryHasOtherFilesThanCache = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Any(f => Path.GetFileNameWithoutExtension(f).Length != 40); + _cacheDirectoryIsValidPath = PathRegex().IsMatch(path); + + if (!string.IsNullOrEmpty(path) + && Directory.Exists(path) + && _isDirectoryWritable + && !_isPenumbraDirectory + && !_cacheDirectoryHasOtherFilesThanCache + && _cacheDirectoryIsValidPath) + { + _configService.Current.CacheFolder = path; + _configService.Save(); + _cacheMonitor.StartMareWatcher(path); + _cacheMonitor.InvokeScan(); + } + }); + } + } + if (_cacheMonitor.MareWatcher != null) + { + AttachToolTip("Stop the Monitoring before changing the Storage folder. As long as monitoring is active, you cannot change the Storage folder location."); } - ImGui.PopFont(); if (_isPenumbraDirectory) {