fixes to intro UI, main UI, don't allow folder to be set to penumbra mod folder

This commit is contained in:
Stanley Dimant
2022-07-05 21:14:01 +02:00
parent 0b1a9ed34d
commit 3b5afb9a60
4 changed files with 24 additions and 11 deletions

View File

@@ -310,11 +310,15 @@ namespace MareSynchronos.UI
var cacheDirectory = _pluginConfiguration.CacheFolder;
if (ImGui.InputText("Cache Folder##cache", ref cacheDirectory, 255))
{
_pluginConfiguration.CacheFolder = cacheDirectory;
if (!string.IsNullOrEmpty(_pluginConfiguration.CacheFolder)
&& Directory.Exists(_pluginConfiguration.CacheFolder)
&& (_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder)))
_isPenumbraDirectory = cacheDirectory.ToLower() == _ipcManager.PenumbraModDirectory()?.ToLower();
_isDirectoryWritable = IsDirectoryWritable(cacheDirectory);
if (!string.IsNullOrEmpty(cacheDirectory)
&& Directory.Exists(cacheDirectory)
&& _isDirectoryWritable
&& !_isPenumbraDirectory)
{
_pluginConfiguration.CacheFolder = cacheDirectory;
_pluginConfiguration.Save();
_fileCacheManager.StartWatchers();
}
@@ -329,10 +333,11 @@ namespace MareSynchronos.UI
{
if (!success) return;
_pluginConfiguration.CacheFolder = path;
_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
if (_isDirectoryWritable)
_isDirectoryWritable = IsDirectoryWritable(path);
_isPenumbraDirectory = path.ToLower() == _ipcManager.PenumbraModDirectory()?.ToLower();
if (_isDirectoryWritable && !_isPenumbraDirectory)
{
_pluginConfiguration.CacheFolder = path;
_pluginConfiguration.Save();
_fileCacheManager.StartWatchers();
}
@@ -340,11 +345,17 @@ namespace MareSynchronos.UI
}
ImGui.PopFont();
if (!Directory.Exists(cacheDirectory) || !_isDirectoryWritable)
if (_isPenumbraDirectory)
{
ColorTextWrapped("Do not point the cache path directly to the Penumbra directory. If necessary, make a subfolder in it.", ImGuiColors.DalamudRed);
}
else if (!Directory.Exists(cacheDirectory) || !_isDirectoryWritable)
{
ColorTextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.", ImGuiColors.DalamudRed);
}
int maxCacheSize = _pluginConfiguration.MaxLocalCacheInGiB;
if (ImGui.SliderInt("Maximum Cache Size in GB", ref maxCacheSize, 1, 50, "%d GB"))
{
@@ -354,6 +365,7 @@ namespace MareSynchronos.UI
}
private bool _isDirectoryWritable = false;
private bool _isPenumbraDirectory = false;
public bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
{